summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/Attic/Makefile36
-rw-r--r--src/lib/libcrypto/Makefile.ssl36
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl138
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c15
-rw-r--r--src/lib/libcrypto/asn1/a_bmp.c6
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c19
-rw-r--r--src/lib/libcrypto/asn1/a_digest.c11
-rw-r--r--src/lib/libcrypto/asn1/a_dup.c2
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c25
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c10
-rw-r--r--src/lib/libcrypto/asn1/a_hdr.c6
-rw-r--r--src/lib/libcrypto/asn1/a_i2d_fp.c2
-rw-r--r--src/lib/libcrypto/asn1/a_int.c41
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c390
-rw-r--r--src/lib/libcrypto/asn1/a_null.c119
-rw-r--r--src/lib/libcrypto/asn1/a_object.c6
-rw-r--r--src/lib/libcrypto/asn1/a_octet.c20
-rw-r--r--src/lib/libcrypto/asn1/a_print.c32
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c15
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c247
-rw-r--r--src/lib/libcrypto/asn1/a_time.c6
-rw-r--r--src/lib/libcrypto/asn1/a_type.c2
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c10
-rw-r--r--src/lib/libcrypto/asn1/a_utf8.c155
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c9
-rw-r--r--src/lib/libcrypto/asn1/a_vis.c6
-rw-r--r--src/lib/libcrypto/asn1/asn1.h290
-rw-r--r--src/lib/libcrypto/asn1/asn1_err.c24
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c19
-rw-r--r--src/lib/libcrypto/asn1/asn1_mac.h14
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c78
-rw-r--r--src/lib/libcrypto/asn1/d2i_dhp.c4
-rw-r--r--src/lib/libcrypto/asn1/d2i_dsap.c4
-rw-r--r--src/lib/libcrypto/asn1/d2i_pr.c23
-rw-r--r--src/lib/libcrypto/asn1/d2i_r_pr.c11
-rw-r--r--src/lib/libcrypto/asn1/d2i_r_pu.c10
-rw-r--r--src/lib/libcrypto/asn1/d2i_s_pr.c4
-rw-r--r--src/lib/libcrypto/asn1/d2i_s_pu.c4
-rw-r--r--src/lib/libcrypto/asn1/evp_asn1.c24
-rw-r--r--src/lib/libcrypto/asn1/f_enum.c2
-rw-r--r--src/lib/libcrypto/asn1/f_int.c2
-rw-r--r--src/lib/libcrypto/asn1/f_string.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_dhp.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_dsap.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_r_pr.c8
-rw-r--r--src/lib/libcrypto/asn1/i2d_r_pu.c8
-rw-r--r--src/lib/libcrypto/asn1/i2d_s_pr.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_s_pu.c2
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c25
-rw-r--r--src/lib/libcrypto/asn1/p5_pbe.c13
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c33
-rw-r--r--src/lib/libcrypto/asn1/p7_dgst.c10
-rw-r--r--src/lib/libcrypto/asn1/p7_enc.c6
-rw-r--r--src/lib/libcrypto/asn1/p7_enc_c.c7
-rw-r--r--src/lib/libcrypto/asn1/p7_evp.c6
-rw-r--r--src/lib/libcrypto/asn1/p7_i_s.c6
-rw-r--r--src/lib/libcrypto/asn1/p7_lib.c8
-rw-r--r--src/lib/libcrypto/asn1/p7_recip.c8
-rw-r--r--src/lib/libcrypto/asn1/p7_s_e.c4
-rw-r--r--src/lib/libcrypto/asn1/p7_signd.c4
-rw-r--r--src/lib/libcrypto/asn1/p7_signi.c10
-rw-r--r--src/lib/libcrypto/asn1/p8_key.c131
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c6
-rw-r--r--src/lib/libcrypto/asn1/pkcs8.c131
-rw-r--r--src/lib/libcrypto/asn1/t_bitst.c99
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c2
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c10
-rw-r--r--src/lib/libcrypto/asn1/t_req.c27
-rw-r--r--src/lib/libcrypto/asn1/t_spki.c116
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c9
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c102
-rw-r--r--src/lib/libcrypto/asn1/x_algor.c2
-rw-r--r--src/lib/libcrypto/asn1/x_attrib.c2
-rw-r--r--src/lib/libcrypto/asn1/x_cinf.c16
-rw-r--r--src/lib/libcrypto/asn1/x_crl.c57
-rw-r--r--src/lib/libcrypto/asn1/x_exten.c15
-rw-r--r--src/lib/libcrypto/asn1/x_info.c3
-rw-r--r--src/lib/libcrypto/asn1/x_name.c2
-rw-r--r--src/lib/libcrypto/asn1/x_pkey.c8
-rw-r--r--src/lib/libcrypto/asn1/x_pubkey.c118
-rw-r--r--src/lib/libcrypto/asn1/x_req.c18
-rw-r--r--src/lib/libcrypto/asn1/x_sig.c6
-rw-r--r--src/lib/libcrypto/asn1/x_spki.c14
-rw-r--r--src/lib/libcrypto/asn1/x_val.c10
-rw-r--r--src/lib/libcrypto/asn1/x_x509.c67
-rw-r--r--src/lib/libcrypto/asn1/x_x509a.c200
-rw-r--r--src/lib/libcrypto/bf/bf_cbc.c32
-rw-r--r--src/lib/libcrypto/bf/bf_cfb64.c4
-rw-r--r--src/lib/libcrypto/bf/bf_ecb.c12
-rw-r--r--src/lib/libcrypto/bf/bf_enc.c44
-rw-r--r--src/lib/libcrypto/bf/bf_locl.h6
-rw-r--r--src/lib/libcrypto/bf/bf_ofb64.c4
-rw-r--r--src/lib/libcrypto/bf/bf_opts.c2
-rw-r--r--src/lib/libcrypto/bf/bf_pi.h2
-rw-r--r--src/lib/libcrypto/bf/bf_skey.c4
-rw-r--r--src/lib/libcrypto/bf/bfspeed.c2
-rw-r--r--src/lib/libcrypto/bf/bftest.c12
-rw-r--r--src/lib/libcrypto/bf/blowfish.h24
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl48
-rw-r--r--src/lib/libcrypto/bio/b_dump.c4
-rw-r--r--src/lib/libcrypto/bio/b_print.c631
-rw-r--r--src/lib/libcrypto/bio/b_sock.c24
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c26
-rw-r--r--src/lib/libcrypto/bio/bf_nbio.c20
-rw-r--r--src/lib/libcrypto/bio/bf_null.c16
-rw-r--r--src/lib/libcrypto/bio/bio.h54
-rw-r--r--src/lib/libcrypto/bio/bio_err.c7
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c56
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c1
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c256
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c42
-rw-r--r--src/lib/libcrypto/bio/bss_file.c3
-rw-r--r--src/lib/libcrypto/bio/bss_log.c14
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c58
-rw-r--r--src/lib/libcrypto/bio/bss_null.c1
-rw-r--r--src/lib/libcrypto/bio/bss_rtcp.c1
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c5
-rw-r--r--src/lib/libcrypto/bn/Makefile.ssl104
-rw-r--r--src/lib/libcrypto/bn/asm/README9
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.s2415
-rw-r--r--src/lib/libcrypto/bn/asm/mips3.s143
-rw-r--r--src/lib/libcrypto/bn/bn.h135
-rw-r--r--src/lib/libcrypto/bn/bn_add.c4
-rw-r--r--src/lib/libcrypto/bn/bn_asm.c145
-rw-r--r--src/lib/libcrypto/bn/bn_comba.c345
-rw-r--r--src/lib/libcrypto/bn/bn_ctx.c144
-rw-r--r--src/lib/libcrypto/bn/bn_div.c206
-rw-r--r--src/lib/libcrypto/bn/bn_err.c2
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c238
-rw-r--r--src/lib/libcrypto/bn/bn_exp2.c14
-rw-r--r--src/lib/libcrypto/bn/bn_gcd.c28
-rw-r--r--src/lib/libcrypto/bn/bn_lcl.h125
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c60
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c313
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c247
-rw-r--r--src/lib/libcrypto/bn/bn_opts.c324
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c378
-rw-r--r--src/lib/libcrypto/bn/bn_prime.h4
-rw-r--r--src/lib/libcrypto/bn/bn_prime.pl69
-rw-r--r--src/lib/libcrypto/bn/bn_print.c23
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c25
-rw-r--r--src/lib/libcrypto/bn/bn_recp.c43
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c25
-rw-r--r--src/lib/libcrypto/bn/bn_word.c2
-rw-r--r--src/lib/libcrypto/bn/bnspeed.c2
-rw-r--r--src/lib/libcrypto/bn/bntest.c239
-rw-r--r--src/lib/libcrypto/bn/comba.pl285
-rw-r--r--src/lib/libcrypto/bn/d.c72
-rw-r--r--src/lib/libcrypto/bn/divtest.c41
-rw-r--r--src/lib/libcrypto/bn/exp.c2
-rw-r--r--src/lib/libcrypto/bn/expspeed.c2
-rw-r--r--src/lib/libcrypto/bn/exptest.c15
-rw-r--r--src/lib/libcrypto/bn/new23
-rw-r--r--src/lib/libcrypto/bn/old/b_sqr.c199
-rw-r--r--src/lib/libcrypto/bn/old/bn_com.c90
-rw-r--r--src/lib/libcrypto/bn/old/bn_high.c135
-rw-r--r--src/lib/libcrypto/bn/old/bn_ka.c567
-rw-r--r--src/lib/libcrypto/bn/old/bn_low.c194
-rw-r--r--src/lib/libcrypto/bn/old/bn_m.c139
-rw-r--r--src/lib/libcrypto/bn/old/bn_mul.c.works219
-rw-r--r--src/lib/libcrypto/bn/old/bn_wmul.c173
-rw-r--r--src/lib/libcrypto/bn/old/build3
-rw-r--r--src/lib/libcrypto/bn/old/info22
-rw-r--r--src/lib/libcrypto/bn/old/test.works205
-rw-r--r--src/lib/libcrypto/bn/test.c241
-rw-r--r--src/lib/libcrypto/buffer/Makefile.ssl3
-rw-r--r--src/lib/libcrypto/cast/c_ecb.c2
-rw-r--r--src/lib/libcrypto/cast/cast_lcl.h16
-rw-r--r--src/lib/libcrypto/cast/cast_s.h16
-rw-r--r--src/lib/libcrypto/cast/cast_spd.c2
-rw-r--r--src/lib/libcrypto/cast/castopts.c2
-rw-r--r--src/lib/libcrypto/cast/casttest.c18
-rw-r--r--src/lib/libcrypto/comp/comp.h1
-rw-r--r--src/lib/libcrypto/conf/conf.c32
-rw-r--r--src/lib/libcrypto/conf/conf.h2
-rw-r--r--src/lib/libcrypto/cryptlib.c6
-rw-r--r--src/lib/libcrypto/crypto-lib.com439
-rw-r--r--src/lib/libcrypto/crypto.h204
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl14
-rw-r--r--src/lib/libcrypto/des/cbc3_enc.c20
-rw-r--r--src/lib/libcrypto/des/des.c22
-rw-r--r--src/lib/libcrypto/des/des.h7
-rw-r--r--src/lib/libcrypto/des/des_locl.h10
-rw-r--r--src/lib/libcrypto/des/des_opts.c10
-rw-r--r--src/lib/libcrypto/des/destest.c81
-rw-r--r--src/lib/libcrypto/des/enc_read.c4
-rw-r--r--src/lib/libcrypto/des/enc_writ.c13
-rw-r--r--src/lib/libcrypto/des/fcrypt.c10
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c2
-rw-r--r--src/lib/libcrypto/des/rand_key.c153
-rw-r--r--src/lib/libcrypto/des/read_pwd.c19
-rw-r--r--src/lib/libcrypto/des/rpc_enc.c2
-rw-r--r--src/lib/libcrypto/des/set_key.c37
-rw-r--r--src/lib/libcrypto/des/speed.c10
-rw-r--r--src/lib/libcrypto/des/str2key.c20
-rw-r--r--src/lib/libcrypto/dh/Makefile.ssl20
-rw-r--r--src/lib/libcrypto/dh/dh.h51
-rw-r--r--src/lib/libcrypto/dh/dh_check.c10
-rw-r--r--src/lib/libcrypto/dh/dh_gen.c19
-rw-r--r--src/lib/libcrypto/dh/dh_key.c65
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c92
-rw-r--r--src/lib/libcrypto/dh/dhtest.c12
-rw-r--r--src/lib/libcrypto/doc/DH_generate_key.pod50
-rw-r--r--src/lib/libcrypto/doc/DH_generate_parameters.pod72
-rw-r--r--src/lib/libcrypto/doc/DH_get_ex_new_index.pod36
-rw-r--r--src/lib/libcrypto/doc/DH_new.pod40
-rw-r--r--src/lib/libcrypto/doc/DH_set_method.pod99
-rw-r--r--src/lib/libcrypto/doc/DH_size.pod33
-rw-r--r--src/lib/libcrypto/doc/DSA_SIG_new.pod39
-rw-r--r--src/lib/libcrypto/doc/DSA_do_sign.pod47
-rw-r--r--src/lib/libcrypto/doc/DSA_dup_DH.pod36
-rw-r--r--src/lib/libcrypto/doc/DSA_generate_key.pod33
-rw-r--r--src/lib/libcrypto/doc/DSA_generate_parameters.pod105
-rw-r--r--src/lib/libcrypto/doc/DSA_get_ex_new_index.pod36
-rw-r--r--src/lib/libcrypto/doc/DSA_new.pod41
-rw-r--r--src/lib/libcrypto/doc/DSA_set_method.pod111
-rw-r--r--src/lib/libcrypto/doc/DSA_sign.pod66
-rw-r--r--src/lib/libcrypto/doc/DSA_size.pod33
-rw-r--r--src/lib/libcrypto/doc/ERR_GET_LIB.pod51
-rw-r--r--src/lib/libcrypto/doc/ERR_clear_error.pod29
-rw-r--r--src/lib/libcrypto/doc/ERR_error_string.pod65
-rw-r--r--src/lib/libcrypto/doc/ERR_get_error.pod62
-rw-r--r--src/lib/libcrypto/doc/ERR_load_crypto_strings.pod46
-rw-r--r--src/lib/libcrypto/doc/ERR_load_strings.pod54
-rw-r--r--src/lib/libcrypto/doc/ERR_print_errors.pod51
-rw-r--r--src/lib/libcrypto/doc/ERR_put_error.pod44
-rw-r--r--src/lib/libcrypto/doc/ERR_remove_state.pod34
-rw-r--r--src/lib/libcrypto/doc/EVP_DigestInit.pod197
-rw-r--r--src/lib/libcrypto/doc/EVP_EncryptInit.pod224
-rw-r--r--src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod46
-rw-r--r--src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod65
-rw-r--r--src/lib/libcrypto/doc/RAND_add.pod68
-rw-r--r--src/lib/libcrypto/doc/RAND_bytes.pod46
-rw-r--r--src/lib/libcrypto/doc/RAND_cleanup.pod29
-rw-r--r--src/lib/libcrypto/doc/RAND_load_file.pod53
-rw-r--r--src/lib/libcrypto/doc/RAND_set_rand_method.pod57
-rw-r--r--src/lib/libcrypto/doc/RSA_blinding_on.pod43
-rw-r--r--src/lib/libcrypto/doc/RSA_check_key.pod39
-rw-r--r--src/lib/libcrypto/doc/RSA_generate_key.pod68
-rw-r--r--src/lib/libcrypto/doc/RSA_get_ex_new_index.pod122
-rw-r--r--src/lib/libcrypto/doc/RSA_new.pod38
-rw-r--r--src/lib/libcrypto/doc/RSA_padding_add_PKCS1_type_1.pod124
-rw-r--r--src/lib/libcrypto/doc/RSA_print.pod48
-rw-r--r--src/lib/libcrypto/doc/RSA_private_encrypt.pod69
-rw-r--r--src/lib/libcrypto/doc/RSA_public_encrypt.pod86
-rw-r--r--src/lib/libcrypto/doc/RSA_set_method.pod153
-rw-r--r--src/lib/libcrypto/doc/RSA_sign.pod62
-rw-r--r--src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod59
-rw-r--r--src/lib/libcrypto/doc/RSA_size.pod33
-rw-r--r--src/lib/libcrypto/doc/bn.pod148
-rw-r--r--src/lib/libcrypto/doc/d2i_DHparams.pod30
-rw-r--r--src/lib/libcrypto/doc/d2i_RSAPublicKey.pod39
-rw-r--r--src/lib/libcrypto/doc/dh.pod68
-rw-r--r--src/lib/libcrypto/doc/dsa.pod104
-rw-r--r--src/lib/libcrypto/doc/lh_stats.pod60
-rw-r--r--src/lib/libcrypto/doc/rsa.pod115
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl31
-rw-r--r--src/lib/libcrypto/dsa/dsa.h61
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_err.c1
-rw-r--r--src/lib/libcrypto/dsa/dsa_gen.c171
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c68
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c321
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c123
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c68
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c28
-rw-r--r--src/lib/libcrypto/ebcdic.c217
-rw-r--r--src/lib/libcrypto/ebcdic.h14
-rw-r--r--src/lib/libcrypto/err/Makefile.ssl21
-rw-r--r--src/lib/libcrypto/err/err.c20
-rw-r--r--src/lib/libcrypto/err/err.h10
-rw-r--r--src/lib/libcrypto/err/err_all.c2
-rw-r--r--src/lib/libcrypto/err/openssl.ec5
-rw-r--r--src/lib/libcrypto/evp/Makefile.ssl46
-rw-r--r--src/lib/libcrypto/evp/bio_b64.c18
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c30
-rw-r--r--src/lib/libcrypto/evp/bio_md.c17
-rw-r--r--src/lib/libcrypto/evp/bio_ok.c33
-rw-r--r--src/lib/libcrypto/evp/c_all.c136
-rw-r--r--src/lib/libcrypto/evp/c_allc.c149
-rw-r--r--src/lib/libcrypto/evp/c_alld.c100
-rw-r--r--src/lib/libcrypto/evp/e_cbc_3d.c10
-rw-r--r--src/lib/libcrypto/evp/e_cbc_d.c2
-rw-r--r--src/lib/libcrypto/evp/e_cfb_3d.c10
-rw-r--r--src/lib/libcrypto/evp/e_cfb_d.c2
-rw-r--r--src/lib/libcrypto/evp/e_ecb_3d.c10
-rw-r--r--src/lib/libcrypto/evp/e_ecb_d.c2
-rw-r--r--src/lib/libcrypto/evp/e_ofb_3d.c10
-rw-r--r--src/lib/libcrypto/evp/e_ofb_d.c2
-rw-r--r--src/lib/libcrypto/evp/e_xcbc_d.c2
-rw-r--r--src/lib/libcrypto/evp/encode.c4
-rw-r--r--src/lib/libcrypto/evp/evp.h43
-rw-r--r--src/lib/libcrypto/evp/evp_err.c8
-rw-r--r--src/lib/libcrypto/evp/evp_key.c11
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c6
-rw-r--r--src/lib/libcrypto/evp/evp_pkey.c265
-rw-r--r--src/lib/libcrypto/evp/p_lib.c64
-rw-r--r--src/lib/libcrypto/evp/p_open.c6
-rw-r--r--src/lib/libcrypto/evp/p_seal.c5
-rw-r--r--src/lib/libcrypto/ex_data.c40
-rw-r--r--src/lib/libcrypto/hmac/hmac.c4
-rw-r--r--src/lib/libcrypto/hmac/hmac.h4
-rw-r--r--src/lib/libcrypto/hmac/hmactest.c2
-rw-r--r--src/lib/libcrypto/install.com1
-rw-r--r--src/lib/libcrypto/lhash/Makefile.ssl7
-rw-r--r--src/lib/libcrypto/lhash/lhash.c40
-rw-r--r--src/lib/libcrypto/lhash/lhash.h14
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl4
-rw-r--r--src/lib/libcrypto/md2/md2.h4
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c8
-rw-r--r--src/lib/libcrypto/md2/md2_one.c2
-rw-r--r--src/lib/libcrypto/md2/md2test.c4
-rw-r--r--src/lib/libcrypto/md32_common.h41
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl9
-rw-r--r--src/lib/libcrypto/md5/md5.h4
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c154
-rw-r--r--src/lib/libcrypto/md5/md5_locl.h17
-rw-r--r--src/lib/libcrypto/md5/md5_one.c2
-rw-r--r--src/lib/libcrypto/md5/md5test.c4
-rw-r--r--src/lib/libcrypto/mdc2/Makefile.ssl4
-rw-r--r--src/lib/libcrypto/mdc2/mdc2.h5
-rw-r--r--src/lib/libcrypto/mem.c432
-rw-r--r--src/lib/libcrypto/mem_dbg.c703
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl3
-rw-r--r--src/lib/libcrypto/objects/o_names.c106
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c22
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl54
-rw-r--r--src/lib/libcrypto/objects/objects.h74
-rw-r--r--src/lib/libcrypto/opensslconf.h.in19
-rw-r--r--src/lib/libcrypto/opensslv.h6
-rw-r--r--src/lib/libcrypto/pem/pem.h38
-rw-r--r--src/lib/libcrypto/pem/pem_all.c94
-rw-r--r--src/lib/libcrypto/pem/pem_err.c3
-rw-r--r--src/lib/libcrypto/pem/pem_info.c11
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c222
-rw-r--r--src/lib/libcrypto/pem/pem_seal.c6
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl9
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl6
-rw-r--r--src/lib/libcrypto/pkcs12/Makefile.ssl23
-rw-r--r--src/lib/libcrypto/pkcs12/p12_add.c26
-rw-r--r--src/lib/libcrypto/pkcs12/p12_attr.c10
-rw-r--r--src/lib/libcrypto/pkcs12/p12_bags.c8
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_init.c6
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c23
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c30
-rw-r--r--src/lib/libcrypto/pkcs12/p12_lib.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mac.c16
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mutl.c13
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c212
-rw-r--r--src/lib/libcrypto/pkcs12/pk12err.c2
-rw-r--r--src/lib/libcrypto/pkcs12/pkcs12.h3
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl85
-rw-r--r--src/lib/libcrypto/pkcs7/bio_ber.c18
-rw-r--r--src/lib/libcrypto/pkcs7/dec.c12
-rw-r--r--src/lib/libcrypto/pkcs7/enc.c15
-rw-r--r--src/lib/libcrypto/pkcs7/example.c15
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_attr.c85
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c121
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_lib.c54
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_mime.c673
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_smime.c427
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7.h85
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7err.c39
-rw-r--r--src/lib/libcrypto/pkcs7/sign.c13
-rw-r--r--src/lib/libcrypto/pkcs7/verify.c11
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl17
-rw-r--r--src/lib/libcrypto/rand/md_rand.c312
-rw-r--r--src/lib/libcrypto/rand/md_rand_munged.c515
-rw-r--r--src/lib/libcrypto/rand/rand.h29
-rw-r--r--src/lib/libcrypto/rand/rand_egd.c110
-rw-r--r--src/lib/libcrypto/rand/rand_err.c93
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c18
-rw-r--r--src/lib/libcrypto/rand/randfile.c108
-rw-r--r--src/lib/libcrypto/rand/randtest.c2
-rw-r--r--src/lib/libcrypto/rc2/rc2speed.c2
-rw-r--r--src/lib/libcrypto/rc2/rc2test.c6
-rw-r--r--src/lib/libcrypto/rc4/rc4.h4
-rw-r--r--src/lib/libcrypto/rc4/rc4_enc.c186
-rw-r--r--src/lib/libcrypto/rc4/rc4_skey.c2
-rw-r--r--src/lib/libcrypto/rc4/rc4speed.c2
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c8
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.ssl5
-rw-r--r--src/lib/libcrypto/ripemd/asm/rips.cpp6
-rw-r--r--src/lib/libcrypto/ripemd/asm/rm-win32.asm3433
-rw-r--r--src/lib/libcrypto/ripemd/asm/rmd-586.pl108
-rw-r--r--src/lib/libcrypto/ripemd/ripemd.h27
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c448
-rw-r--r--src/lib/libcrypto/ripemd/rmd_locl.h184
-rw-r--r--src/lib/libcrypto/ripemd/rmd_one.c5
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c4
-rw-r--r--src/lib/libcrypto/rsa/Makefile.ssl45
-rw-r--r--src/lib/libcrypto/rsa/rsa.h33
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_err.c5
-rw-r--r--src/lib/libcrypto/rsa/rsa_gen.c1
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c24
-rw-r--r--src/lib/libcrypto/rsa/rsa_null.c149
-rw-r--r--src/lib/libcrypto/rsa/rsa_oaep.c3
-rw-r--r--src/lib/libcrypto/rsa/rsa_oaep_test.c309
-rw-r--r--src/lib/libcrypto/rsa/rsa_pk1.c18
-rw-r--r--src/lib/libcrypto/rsa/rsa_saos.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c153
-rw-r--r--src/lib/libcrypto/rsa/rsa_ssl.c11
-rw-r--r--src/lib/libcrypto/rsa/rsa_test.c314
-rw-r--r--src/lib/libcrypto/sha/Makefile.ssl4
-rw-r--r--src/lib/libcrypto/sha/asm/s1-win32.asm1138
-rw-r--r--src/lib/libcrypto/sha/asm/sha1-586.pl107
-rw-r--r--src/lib/libcrypto/sha/sha.h10
-rw-r--r--src/lib/libcrypto/sha/sha1dgst.c437
-rw-r--r--src/lib/libcrypto/sha/sha1s.cpp5
-rw-r--r--src/lib/libcrypto/sha/sha1test.c10
-rw-r--r--src/lib/libcrypto/sha/sha_dgst.c435
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h563
-rw-r--r--src/lib/libcrypto/sha/shatest.c10
-rw-r--r--src/lib/libcrypto/stack/Makefile.ssl3
-rw-r--r--src/lib/libcrypto/stack/stack.c8
-rw-r--r--src/lib/libcrypto/stack/stack.h4
-rw-r--r--src/lib/libcrypto/threads/README14
-rw-r--r--src/lib/libcrypto/threads/mttest.c122
-rw-r--r--src/lib/libcrypto/threads/profile.sh4
-rw-r--r--src/lib/libcrypto/threads/ptest.bat4
-rw-r--r--src/lib/libcrypto/threads/pthread.sh9
-rw-r--r--src/lib/libcrypto/threads/pthread2.sh7
-rw-r--r--src/lib/libcrypto/threads/pthreads-vms.com9
-rw-r--r--src/lib/libcrypto/threads/purify.sh4
-rw-r--r--src/lib/libcrypto/threads/solaris.sh4
-rw-r--r--src/lib/libcrypto/threads/th-lock.c55
-rw-r--r--src/lib/libcrypto/threads/win32.bat4
-rw-r--r--src/lib/libcrypto/txt_db/Makefile.ssl5
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.c8
-rw-r--r--src/lib/libcrypto/util/domd2
-rw-r--r--src/lib/libcrypto/util/libeay.num403
-rw-r--r--src/lib/libcrypto/util/mkdef.pl139
-rw-r--r--src/lib/libcrypto/util/mkerr.pl2
-rw-r--r--src/lib/libcrypto/util/pl/BC-32.pl2
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32.pl2
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl2
-rw-r--r--src/lib/libcrypto/util/pod2man.pl1181
-rw-r--r--src/lib/libcrypto/util/selftest.pl174
-rw-r--r--src/lib/libcrypto/util/ssleay.num10
-rw-r--r--src/lib/libcrypto/x509/Makefile.ssl123
-rw-r--r--src/lib/libcrypto/x509/by_dir.c19
-rw-r--r--src/lib/libcrypto/x509/by_file.c63
-rw-r--r--src/lib/libcrypto/x509/x509.h239
-rw-r--r--src/lib/libcrypto/x509/x509_att.c326
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c23
-rw-r--r--src/lib/libcrypto/x509/x509_d2.c8
-rw-r--r--src/lib/libcrypto/x509/x509_def.c2
-rw-r--r--src/lib/libcrypto/x509/x509_err.c17
-rw-r--r--src/lib/libcrypto/x509/x509_ext.c17
-rw-r--r--src/lib/libcrypto/x509/x509_lu.c26
-rw-r--r--src/lib/libcrypto/x509/x509_r2x.c2
-rw-r--r--src/lib/libcrypto/x509/x509_req.c165
-rw-r--r--src/lib/libcrypto/x509/x509_set.c14
-rw-r--r--src/lib/libcrypto/x509/x509_trs.c263
-rw-r--r--src/lib/libcrypto/x509/x509_txt.c11
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c3
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c206
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.h20
-rw-r--r--src/lib/libcrypto/x509/x509name.c66
-rw-r--r--src/lib/libcrypto/x509/x509spki.c121
-rw-r--r--src/lib/libcrypto/x509/x_all.c100
-rw-r--r--src/lib/libcrypto/x509v3/Makefile.ssl43
-rw-r--r--src/lib/libcrypto/x509v3/README4
-rw-r--r--src/lib/libcrypto/x509v3/ext_dat.h97
-rw-r--r--src/lib/libcrypto/x509v3/tabtest.c88
-rw-r--r--src/lib/libcrypto/x509v3/v3_akey.c12
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c9
-rw-r--r--src/lib/libcrypto/x509v3/v3_bcons.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_bitst.c10
-rw-r--r--src/lib/libcrypto/x509v3/v3_conf.c34
-rw-r--r--src/lib/libcrypto/x509v3/v3_cpols.c14
-rw-r--r--src/lib/libcrypto/x509v3/v3_crld.c18
-rw-r--r--src/lib/libcrypto/x509v3/v3_enum.c13
-rw-r--r--src/lib/libcrypto/x509v3/v3_genn.c70
-rw-r--r--src/lib/libcrypto/x509v3/v3_ia5.c13
-rw-r--r--src/lib/libcrypto/x509v3/v3_info.c236
-rw-r--r--src/lib/libcrypto/x509v3/v3_int.c13
-rw-r--r--src/lib/libcrypto/x509v3/v3_lib.c88
-rw-r--r--src/lib/libcrypto/x509v3/v3_pku.c6
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c16
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c456
-rw-r--r--src/lib/libcrypto/x509v3/v3_skey.c21
-rw-r--r--src/lib/libcrypto/x509v3/v3_sxnet.c28
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3err.c4
-rw-r--r--src/lib/libcrypto/x509v3/x509v3.h135
-rw-r--r--src/lib/libssl/LICENSE2
-rw-r--r--src/lib/libssl/bio_ssl.c33
-rw-r--r--src/lib/libssl/crypto-patent/Makefile26
-rw-r--r--src/lib/libssl/crypto-patent/shlib_version2
-rw-r--r--src/lib/libssl/crypto/Makefile24
-rw-r--r--src/lib/libssl/crypto/shlib_version2
-rw-r--r--src/lib/libssl/doc/openssl.cnf38
-rw-r--r--src/lib/libssl/doc/openssl.txt120
-rw-r--r--src/lib/libssl/s23_clnt.c16
-rw-r--r--src/lib/libssl/s23_lib.c17
-rw-r--r--src/lib/libssl/s23_pkt.c2
-rw-r--r--src/lib/libssl/s23_srvr.c135
-rw-r--r--src/lib/libssl/s3_both.c164
-rw-r--r--src/lib/libssl/s3_clnt.c43
-rw-r--r--src/lib/libssl/s3_lib.c377
-rw-r--r--src/lib/libssl/s3_pkt.c761
-rw-r--r--src/lib/libssl/s3_srvr.c185
-rw-r--r--src/lib/libssl/shlib_version2
-rw-r--r--src/lib/libssl/src/CHANGES1106
-rw-r--r--src/lib/libssl/src/Configure282
-rw-r--r--src/lib/libssl/src/FAQ130
-rw-r--r--src/lib/libssl/src/INSTALL159
-rw-r--r--src/lib/libssl/src/INSTALL.MacOS72
-rw-r--r--src/lib/libssl/src/INSTALL.VMS103
-rw-r--r--src/lib/libssl/src/INSTALL.W32194
-rw-r--r--src/lib/libssl/src/LICENSE2
-rw-r--r--src/lib/libssl/src/MacOS/GUSI_Init.cpp62
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.cpp2753
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.hpp104
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.cpp170
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.hpp147
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp215
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp1607
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h103
-rw-r--r--src/lib/libssl/src/MacOS/OpenSSL.mcp.hqx4880
-rw-r--r--src/lib/libssl/src/MacOS/TODO18
-rw-r--r--src/lib/libssl/src/MacOS/_MWERKS_GUSI_prefix.h9
-rw-r--r--src/lib/libssl/src/MacOS/_MWERKS_prefix.h9
-rw-r--r--src/lib/libssl/src/MacOS/buildinf.h5
-rw-r--r--src/lib/libssl/src/MacOS/mklinks.as.hqx820
-rw-r--r--src/lib/libssl/src/MacOS/opensslconf.h116
-rw-r--r--src/lib/libssl/src/Makefile.org51
-rw-r--r--src/lib/libssl/src/NEWS36
-rw-r--r--src/lib/libssl/src/README85
-rw-r--r--src/lib/libssl/src/VMS/install.com3
-rw-r--r--src/lib/libssl/src/VMS/test-includes.com28
-rw-r--r--src/lib/libssl/src/VMS/vms_idhacks.h154
-rw-r--r--src/lib/libssl/src/apps/CA.com20
-rw-r--r--src/lib/libssl/src/apps/CA.pl13
-rw-r--r--src/lib/libssl/src/apps/CA.pl.in162
-rw-r--r--src/lib/libssl/src/apps/CA.sh2
-rw-r--r--src/lib/libssl/src/apps/Makefile.ssl239
-rw-r--r--src/lib/libssl/src/apps/app_rand.c211
-rw-r--r--src/lib/libssl/src/apps/apps.c90
-rw-r--r--src/lib/libssl/src/apps/apps.h20
-rw-r--r--src/lib/libssl/src/apps/asn1pars.c14
-rw-r--r--src/lib/libssl/src/apps/ca.c219
-rw-r--r--src/lib/libssl/src/apps/ciphers.c16
-rw-r--r--src/lib/libssl/src/apps/crl.c83
-rw-r--r--src/lib/libssl/src/apps/crl2p7.c8
-rw-r--r--src/lib/libssl/src/apps/dgst.c3
-rw-r--r--src/lib/libssl/src/apps/dh.c13
-rw-r--r--src/lib/libssl/src/apps/dhparam.c368
-rw-r--r--src/lib/libssl/src/apps/dsa.c86
-rw-r--r--src/lib/libssl/src/apps/dsaparam.c48
-rw-r--r--src/lib/libssl/src/apps/enc.c157
-rw-r--r--src/lib/libssl/src/apps/errstr.c2
-rw-r--r--src/lib/libssl/src/apps/gendh.c48
-rw-r--r--src/lib/libssl/src/apps/gendsa.c65
-rw-r--r--src/lib/libssl/src/apps/genrsa.c104
-rw-r--r--src/lib/libssl/src/apps/makeapps.com48
-rw-r--r--src/lib/libssl/src/apps/nseq.c16
-rw-r--r--src/lib/libssl/src/apps/openssl-vms.cnf30
-rw-r--r--src/lib/libssl/src/apps/openssl.c27
-rw-r--r--src/lib/libssl/src/apps/openssl.cnf38
-rw-r--r--src/lib/libssl/src/apps/passwd.c475
-rw-r--r--src/lib/libssl/src/apps/pkcs12.c211
-rw-r--r--src/lib/libssl/src/apps/pkcs7.c96
-rw-r--r--src/lib/libssl/src/apps/pkcs8.c131
-rw-r--r--src/lib/libssl/src/apps/progs.h32
-rw-r--r--src/lib/libssl/src/apps/progs.pl18
-rw-r--r--src/lib/libssl/src/apps/req.c411
-rw-r--r--src/lib/libssl/src/apps/rsa.c119
-rw-r--r--src/lib/libssl/src/apps/s_client.c93
-rw-r--r--src/lib/libssl/src/apps/s_server.c140
-rw-r--r--src/lib/libssl/src/apps/s_time.c31
-rw-r--r--src/lib/libssl/src/apps/sess_id.c5
-rw-r--r--src/lib/libssl/src/apps/smime.c646
-rw-r--r--src/lib/libssl/src/apps/speed.c58
-rw-r--r--src/lib/libssl/src/apps/spkac.c274
-rw-r--r--src/lib/libssl/src/apps/verify.c165
-rw-r--r--src/lib/libssl/src/apps/version.c2
-rw-r--r--src/lib/libssl/src/apps/x509.c268
-rw-r--r--src/lib/libssl/src/bugs/SSLv38
-rw-r--r--src/lib/libssl/src/certs/ca-cert.pem30
-rw-r--r--src/lib/libssl/src/certs/pca-cert.pem28
-rw-r--r--src/lib/libssl/src/config79
-rw-r--r--src/lib/libssl/src/crypto/Makefile36
-rw-r--r--src/lib/libssl/src/crypto/Makefile.ssl36
-rw-r--r--src/lib/libssl/src/crypto/asn1/Makefile.ssl138
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bitstr.c15
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bmp.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bytes.c19
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_digest.c11
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_dup.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_enum.c25
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_gentm.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_hdr.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_i2d_fp.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_int.c41
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_mbstr.c390
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_null.c119
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_object.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_octet.c20
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_print.c32
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_sign.c15
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strnid.c247
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_time.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_type.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_utctm.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_utf8.c155
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_verify.c9
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_vis.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1.h290
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_err.c24
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_lib.c19
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_mac.h14
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_par.c78
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_dhp.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_dsap.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_pr.c23
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_r_pr.c11
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_r_pu.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_s_pr.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_s_pu.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/evp_asn1.c24
-rw-r--r--src/lib/libssl/src/crypto/asn1/f_enum.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/f_int.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/f_string.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_dhp.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_dsap.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_r_pr.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_r_pu.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_s_pr.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_s_pu.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/n_pkey.c25
-rw-r--r--src/lib/libssl/src/crypto/asn1/p5_pbe.c13
-rw-r--r--src/lib/libssl/src/crypto/asn1/p5_pbev2.c33
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_dgst.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_enc.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_enc_c.c7
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_evp.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_i_s.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_lib.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_recip.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_s_e.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_signd.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_signi.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/p8_key.c131
-rw-r--r--src/lib/libssl/src/crypto/asn1/p8_pkey.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/pkcs8.c131
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_bitst.c99
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_crl.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_pkey.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_req.c27
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_spki.c116
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_x509.c9
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_x509a.c102
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_algor.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_attrib.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_cinf.c16
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_crl.c57
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_exten.c15
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_info.c3
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_name.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_pkey.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_pubkey.c118
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_req.c18
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_sig.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_spki.c14
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_val.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_x509.c67
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_x509a.c200
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_cbc.c32
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_cfb64.c4
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_ecb.c12
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_enc.c44
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_locl.h6
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_ofb64.c4
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_opts.c2
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_pi.h2
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_skey.c4
-rw-r--r--src/lib/libssl/src/crypto/bf/bfspeed.c2
-rw-r--r--src/lib/libssl/src/crypto/bf/bftest.c12
-rw-r--r--src/lib/libssl/src/crypto/bf/blowfish.h24
-rw-r--r--src/lib/libssl/src/crypto/bio/Makefile.ssl48
-rw-r--r--src/lib/libssl/src/crypto/bio/b_dump.c4
-rw-r--r--src/lib/libssl/src/crypto/bio/b_print.c631
-rw-r--r--src/lib/libssl/src/crypto/bio/b_sock.c24
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_buff.c26
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_nbio.c20
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_null.c16
-rw-r--r--src/lib/libssl/src/crypto/bio/bio.h54
-rw-r--r--src/lib/libssl/src/crypto/bio/bio_err.c7
-rw-r--r--src/lib/libssl/src/crypto/bio/bio_lib.c56
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_acpt.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_bio.c256
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_conn.c42
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_file.c3
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_log.c14
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_mem.c58
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_null.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_rtcp.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_sock.c5
-rw-r--r--src/lib/libssl/src/crypto/bn/Makefile.ssl104
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/README9
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/alpha.s2415
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/mips3.s143
-rw-r--r--src/lib/libssl/src/crypto/bn/bn.h135
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_add.c4
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_asm.c145
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_comba.c345
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_ctx.c144
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_div.c206
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_err.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_exp.c238
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_exp2.c14
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_gcd.c28
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lcl.h125
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lib.c60
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mont.c313
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mul.c247
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_opts.c324
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_prime.c378
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_prime.h4
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_prime.pl69
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_print.c23
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_rand.c25
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_recp.c43
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_sqr.c25
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_word.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bnspeed.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bntest.c239
-rw-r--r--src/lib/libssl/src/crypto/bn/comba.pl285
-rw-r--r--src/lib/libssl/src/crypto/bn/d.c72
-rw-r--r--src/lib/libssl/src/crypto/bn/divtest.c41
-rw-r--r--src/lib/libssl/src/crypto/bn/exp.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/expspeed.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/exptest.c15
-rw-r--r--src/lib/libssl/src/crypto/bn/new23
-rw-r--r--src/lib/libssl/src/crypto/bn/old/b_sqr.c199
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_com.c90
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_high.c135
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_ka.c567
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_low.c194
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_m.c139
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_mul.c.works219
-rw-r--r--src/lib/libssl/src/crypto/bn/old/bn_wmul.c173
-rw-r--r--src/lib/libssl/src/crypto/bn/old/build3
-rw-r--r--src/lib/libssl/src/crypto/bn/old/info22
-rw-r--r--src/lib/libssl/src/crypto/bn/old/test.works205
-rw-r--r--src/lib/libssl/src/crypto/bn/test.c241
-rw-r--r--src/lib/libssl/src/crypto/buffer/Makefile.ssl3
-rw-r--r--src/lib/libssl/src/crypto/cast/c_ecb.c2
-rw-r--r--src/lib/libssl/src/crypto/cast/cast_lcl.h16
-rw-r--r--src/lib/libssl/src/crypto/cast/cast_s.h16
-rw-r--r--src/lib/libssl/src/crypto/cast/cast_spd.c2
-rw-r--r--src/lib/libssl/src/crypto/cast/castopts.c2
-rw-r--r--src/lib/libssl/src/crypto/cast/casttest.c18
-rw-r--r--src/lib/libssl/src/crypto/comp/comp.h1
-rw-r--r--src/lib/libssl/src/crypto/conf/conf.c32
-rw-r--r--src/lib/libssl/src/crypto/conf/conf.h2
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.c6
-rw-r--r--src/lib/libssl/src/crypto/crypto-lib.com439
-rw-r--r--src/lib/libssl/src/crypto/crypto.h204
-rw-r--r--src/lib/libssl/src/crypto/des/Makefile.ssl14
-rw-r--r--src/lib/libssl/src/crypto/des/cbc3_enc.c20
-rw-r--r--src/lib/libssl/src/crypto/des/des.c22
-rw-r--r--src/lib/libssl/src/crypto/des/des.h7
-rw-r--r--src/lib/libssl/src/crypto/des/des_locl.h10
-rw-r--r--src/lib/libssl/src/crypto/des/des_opts.c10
-rw-r--r--src/lib/libssl/src/crypto/des/destest.c81
-rw-r--r--src/lib/libssl/src/crypto/des/enc_read.c4
-rw-r--r--src/lib/libssl/src/crypto/des/enc_writ.c13
-rw-r--r--src/lib/libssl/src/crypto/des/fcrypt.c10
-rw-r--r--src/lib/libssl/src/crypto/des/fcrypt_b.c2
-rw-r--r--src/lib/libssl/src/crypto/des/rand_key.c153
-rw-r--r--src/lib/libssl/src/crypto/des/read_pwd.c19
-rw-r--r--src/lib/libssl/src/crypto/des/rpc_enc.c2
-rw-r--r--src/lib/libssl/src/crypto/des/set_key.c37
-rw-r--r--src/lib/libssl/src/crypto/des/speed.c10
-rw-r--r--src/lib/libssl/src/crypto/des/str2key.c20
-rw-r--r--src/lib/libssl/src/crypto/dh/Makefile.ssl20
-rw-r--r--src/lib/libssl/src/crypto/dh/dh.h51
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_check.c10
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_gen.c19
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_key.c65
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_lib.c92
-rw-r--r--src/lib/libssl/src/crypto/dh/dhtest.c12
-rw-r--r--src/lib/libssl/src/crypto/dsa/Makefile.ssl31
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa.h61
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_asn1.c4
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_err.c1
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_gen.c171
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_lib.c68
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_ossl.c321
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_sign.c123
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_vrf.c68
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsatest.c28
-rw-r--r--src/lib/libssl/src/crypto/ebcdic.c217
-rw-r--r--src/lib/libssl/src/crypto/ebcdic.h14
-rw-r--r--src/lib/libssl/src/crypto/err/Makefile.ssl21
-rw-r--r--src/lib/libssl/src/crypto/err/err.c20
-rw-r--r--src/lib/libssl/src/crypto/err/err.h10
-rw-r--r--src/lib/libssl/src/crypto/err/err_all.c2
-rw-r--r--src/lib/libssl/src/crypto/err/openssl.ec5
-rw-r--r--src/lib/libssl/src/crypto/evp/Makefile.ssl46
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_b64.c18
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_enc.c30
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_md.c17
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_ok.c33
-rw-r--r--src/lib/libssl/src/crypto/evp/c_all.c136
-rw-r--r--src/lib/libssl/src/crypto/evp/c_allc.c149
-rw-r--r--src/lib/libssl/src/crypto/evp/c_alld.c100
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_3d.c10
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_d.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_3d.c10
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_d.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_3d.c10
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_d.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_3d.c10
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_d.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/e_xcbc_d.c2
-rw-r--r--src/lib/libssl/src/crypto/evp/encode.c4
-rw-r--r--src/lib/libssl/src/crypto/evp/evp.h43
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_err.c8
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_key.c11
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_lib.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_pkey.c265
-rw-r--r--src/lib/libssl/src/crypto/evp/p_lib.c64
-rw-r--r--src/lib/libssl/src/crypto/evp/p_open.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/p_seal.c5
-rw-r--r--src/lib/libssl/src/crypto/ex_data.c40
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmac.c4
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmac.h4
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmactest.c2
-rw-r--r--src/lib/libssl/src/crypto/install.com1
-rw-r--r--src/lib/libssl/src/crypto/lhash/Makefile.ssl7
-rw-r--r--src/lib/libssl/src/crypto/lhash/lhash.c40
-rw-r--r--src/lib/libssl/src/crypto/lhash/lhash.h14
-rw-r--r--src/lib/libssl/src/crypto/md2/Makefile.ssl4
-rw-r--r--src/lib/libssl/src/crypto/md2/md2.h4
-rw-r--r--src/lib/libssl/src/crypto/md2/md2_dgst.c8
-rw-r--r--src/lib/libssl/src/crypto/md2/md2_one.c2
-rw-r--r--src/lib/libssl/src/crypto/md2/md2test.c4
-rw-r--r--src/lib/libssl/src/crypto/md32_common.h41
-rw-r--r--src/lib/libssl/src/crypto/md5/Makefile.ssl9
-rw-r--r--src/lib/libssl/src/crypto/md5/md5.h4
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_dgst.c154
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_locl.h17
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_one.c2
-rw-r--r--src/lib/libssl/src/crypto/md5/md5test.c4
-rw-r--r--src/lib/libssl/src/crypto/mdc2/Makefile.ssl4
-rw-r--r--src/lib/libssl/src/crypto/mdc2/mdc2.h5
-rw-r--r--src/lib/libssl/src/crypto/mem.c432
-rw-r--r--src/lib/libssl/src/crypto/mem_dbg.c703
-rw-r--r--src/lib/libssl/src/crypto/objects/Makefile.ssl3
-rw-r--r--src/lib/libssl/src/crypto/objects/o_names.c106
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.c22
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.pl54
-rw-r--r--src/lib/libssl/src/crypto/objects/objects.h74
-rw-r--r--src/lib/libssl/src/crypto/opensslconf.h.in19
-rw-r--r--src/lib/libssl/src/crypto/opensslv.h6
-rw-r--r--src/lib/libssl/src/crypto/pem/pem.h38
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_all.c94
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_err.c3
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_info.c11
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_lib.c222
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_seal.c6
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86ms.pl9
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86unix.pl6
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/Makefile.ssl23
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_add.c26
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_attr.c10
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_bags.c8
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_crpt.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_decr.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_init.c6
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_key.c23
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_kiss.c30
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_lib.c4
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_mac.c16
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_mutl.c13
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_npas.c212
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/pk12err.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/pkcs12.h3
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/Makefile.ssl85
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/bio_ber.c18
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/dec.c12
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/enc.c15
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/example.c15
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_attr.c85
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_doit.c121
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_lib.c54
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_mime.c673
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_smime.c427
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pkcs7.h85
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pkcs7err.c39
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/sign.c13
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/verify.c11
-rw-r--r--src/lib/libssl/src/crypto/rand/Makefile.ssl17
-rw-r--r--src/lib/libssl/src/crypto/rand/md_rand.c312
-rw-r--r--src/lib/libssl/src/crypto/rand/md_rand_munged.c515
-rw-r--r--src/lib/libssl/src/crypto/rand/rand.h29
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_egd.c110
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_err.c93
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_lib.c18
-rw-r--r--src/lib/libssl/src/crypto/rand/randfile.c108
-rw-r--r--src/lib/libssl/src/crypto/rand/randtest.c2
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2speed.c2
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2test.c6
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4.h4
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4_enc.c186
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4_skey.c2
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4speed.c2
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4test.c8
-rw-r--r--src/lib/libssl/src/crypto/ripemd/Makefile.ssl5
-rw-r--r--src/lib/libssl/src/crypto/ripemd/asm/rips.cpp6
-rw-r--r--src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm3433
-rw-r--r--src/lib/libssl/src/crypto/ripemd/asm/rmd-586.pl108
-rw-r--r--src/lib/libssl/src/crypto/ripemd/ripemd.h27
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_dgst.c448
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_locl.h184
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_one.c5
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmdtest.c4
-rw-r--r--src/lib/libssl/src/crypto/rsa/Makefile.ssl45
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa.h33
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_eay.c4
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_err.c5
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_gen.c1
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_lib.c24
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_null.c149
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_oaep.c3
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_oaep_test.c309
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_pk1.c18
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_saos.c2
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_sign.c153
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_ssl.c11
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_test.c314
-rw-r--r--src/lib/libssl/src/crypto/sha/Makefile.ssl4
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/s1-win32.asm1138
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sha1-586.pl107
-rw-r--r--src/lib/libssl/src/crypto/sha/sha.h10
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1dgst.c437
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1s.cpp5
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1test.c10
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_dgst.c435
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_locl.h563
-rw-r--r--src/lib/libssl/src/crypto/sha/shatest.c10
-rw-r--r--src/lib/libssl/src/crypto/stack/Makefile.ssl3
-rw-r--r--src/lib/libssl/src/crypto/stack/stack.c8
-rw-r--r--src/lib/libssl/src/crypto/stack/stack.h4
-rw-r--r--src/lib/libssl/src/crypto/threads/README14
-rw-r--r--src/lib/libssl/src/crypto/threads/mttest.c122
-rw-r--r--src/lib/libssl/src/crypto/threads/profile.sh4
-rw-r--r--src/lib/libssl/src/crypto/threads/ptest.bat4
-rw-r--r--src/lib/libssl/src/crypto/threads/pthread.sh9
-rw-r--r--src/lib/libssl/src/crypto/threads/pthread2.sh7
-rw-r--r--src/lib/libssl/src/crypto/threads/pthreads-vms.com9
-rw-r--r--src/lib/libssl/src/crypto/threads/purify.sh4
-rw-r--r--src/lib/libssl/src/crypto/threads/solaris.sh4
-rw-r--r--src/lib/libssl/src/crypto/threads/th-lock.c55
-rw-r--r--src/lib/libssl/src/crypto/threads/win32.bat4
-rw-r--r--src/lib/libssl/src/crypto/txt_db/Makefile.ssl5
-rw-r--r--src/lib/libssl/src/crypto/txt_db/txt_db.c8
-rw-r--r--src/lib/libssl/src/crypto/x509/Makefile.ssl123
-rw-r--r--src/lib/libssl/src/crypto/x509/by_dir.c19
-rw-r--r--src/lib/libssl/src/crypto/x509/by_file.c63
-rw-r--r--src/lib/libssl/src/crypto/x509/x509.h239
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_att.c326
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_cmp.c23
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_d2.c8
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_def.c2
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_err.c17
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_ext.c17
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_lu.c26
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_r2x.c2
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_req.c165
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_set.c14
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_trs.c263
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_txt.c11
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_v3.c3
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.c206
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.h20
-rw-r--r--src/lib/libssl/src/crypto/x509/x509name.c66
-rw-r--r--src/lib/libssl/src/crypto/x509/x509spki.c121
-rw-r--r--src/lib/libssl/src/crypto/x509/x_all.c100
-rw-r--r--src/lib/libssl/src/crypto/x509v3/Makefile.ssl43
-rw-r--r--src/lib/libssl/src/crypto/x509v3/README4
-rw-r--r--src/lib/libssl/src/crypto/x509v3/ext_dat.h97
-rw-r--r--src/lib/libssl/src/crypto/x509v3/tabtest.c88
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_akey.c12
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_alt.c9
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_bcons.c4
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_bitst.c10
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_conf.c34
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_cpols.c14
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_crld.c18
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_enum.c13
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_genn.c70
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_ia5.c13
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_info.c236
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_int.c13
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_lib.c88
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_pku.c6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_prn.c16
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_purp.c456
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_skey.c21
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_sxnet.c28
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_utl.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3err.c4
-rw-r--r--src/lib/libssl/src/crypto/x509v3/x509v3.h135
-rw-r--r--src/lib/libssl/src/demos/bio/saccept.c2
-rw-r--r--src/lib/libssl/src/demos/bio/sconnect.c2
-rw-r--r--src/lib/libssl/src/demos/selfsign.c54
-rw-r--r--src/lib/libssl/src/demos/ssl/cli.cpp1
-rw-r--r--src/lib/libssl/src/dep/crypto.txt1043
-rw-r--r--src/lib/libssl/src/dep/files566
-rw-r--r--src/lib/libssl/src/dep/gen.pl113
-rw-r--r--src/lib/libssl/src/dep/ssl.txt156
-rw-r--r--src/lib/libssl/src/doc/README10
-rw-r--r--src/lib/libssl/src/doc/apps/CA.pl.pod138
-rw-r--r--src/lib/libssl/src/doc/apps/asn1parse.pod129
-rw-r--r--src/lib/libssl/src/doc/apps/ca.pod479
-rw-r--r--src/lib/libssl/src/doc/apps/ciphers.pod342
-rw-r--r--src/lib/libssl/src/doc/apps/config.pod138
-rw-r--r--src/lib/libssl/src/doc/apps/crl.pod117
-rw-r--r--src/lib/libssl/src/doc/apps/crl2pkcs7.pod90
-rw-r--r--src/lib/libssl/src/doc/apps/dgst.pod49
-rw-r--r--src/lib/libssl/src/doc/apps/dhparam.pod115
-rw-r--r--src/lib/libssl/src/doc/apps/dsa.pod150
-rw-r--r--src/lib/libssl/src/doc/apps/dsaparam.pod102
-rw-r--r--src/lib/libssl/src/doc/apps/enc.pod257
-rw-r--r--src/lib/libssl/src/doc/apps/gendsa.pod58
-rw-r--r--src/lib/libssl/src/doc/apps/genrsa.pod85
-rw-r--r--src/lib/libssl/src/doc/apps/nseq.pod70
-rw-r--r--src/lib/libssl/src/doc/apps/openssl.pod298
-rw-r--r--src/lib/libssl/src/doc/apps/passwd.pod69
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs12.pod310
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs7.pod97
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs8.pod235
-rw-r--r--src/lib/libssl/src/doc/apps/req.pod528
-rw-r--r--src/lib/libssl/src/doc/apps/rsa.pod156
-rw-r--r--src/lib/libssl/src/doc/apps/s_client.pod213
-rw-r--r--src/lib/libssl/src/doc/apps/s_server.pod265
-rw-r--r--src/lib/libssl/src/doc/apps/sess_id.pod151
-rw-r--r--src/lib/libssl/src/doc/apps/smime.pod325
-rw-r--r--src/lib/libssl/src/doc/apps/speed.pod45
-rw-r--r--src/lib/libssl/src/doc/apps/spkac.pod127
-rw-r--r--src/lib/libssl/src/doc/apps/verify.pod273
-rw-r--r--src/lib/libssl/src/doc/apps/version.pod56
-rw-r--r--src/lib/libssl/src/doc/apps/x509.pod543
-rw-r--r--src/lib/libssl/src/doc/c-indentation.el11
-rw-r--r--src/lib/libssl/src/doc/crypto.pod27
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_CTX_new.pod53
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_CTX_start.pod51
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_add.pod99
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_add_word.pod57
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_bn2bin.pod95
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_cmp.pod48
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_copy.pod34
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_generate_prime.pod102
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod95
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod81
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_new.pod53
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_num_bytes.pod37
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_rand.pod45
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_set_bit.pod66
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_zero.pod55
-rw-r--r--src/lib/libssl/src/doc/crypto/CRYPTO_set_ex_data.pod51
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_generate_key.pod50
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod72
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_get_ex_new_index.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_new.pod40
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_set_method.pod99
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_size.pod33
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod39
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_do_sign.pod47
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_generate_key.pod33
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod105
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_get_ex_new_index.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_new.pod41
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_set_method.pod111
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_sign.pod66
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_size.pod33
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_GET_LIB.pod51
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_clear_error.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_error_string.pod65
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_get_error.pod62
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_load_crypto_strings.pod46
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_load_strings.pod54
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_print_errors.pod51
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_put_error.pod44
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_remove_state.pod34
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod197
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod224
-rw-r--r--src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod46
-rw-r--r--src/lib/libssl/src/doc/crypto/OpenSSL_add_all_algorithms.pod65
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_add.pod68
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_bytes.pod46
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_cleanup.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_egd.pod38
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_load_file.pod53
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_set_rand_method.pod57
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_blinding_on.pod43
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_check_key.pod39
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_generate_key.pod68
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_get_ex_new_index.pod122
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_new.pod38
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_padding_add_PKCS1_type_1.pod124
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_print.pod48
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod69
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod86
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_set_method.pod153
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_sign.pod62
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod59
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_size.pod33
-rw-r--r--src/lib/libssl/src/doc/crypto/blowfish.pod106
-rw-r--r--src/lib/libssl/src/doc/crypto/bn.pod148
-rw-r--r--src/lib/libssl/src/doc/crypto/bn_internal.pod225
-rw-r--r--src/lib/libssl/src/doc/crypto/buffer.pod73
-rw-r--r--src/lib/libssl/src/doc/crypto/crypto.pod67
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_DHparams.pod30
-rw-r--r--src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod39
-rw-r--r--src/lib/libssl/src/doc/crypto/des_modes.pod250
-rw-r--r--src/lib/libssl/src/doc/crypto/dh.pod68
-rw-r--r--src/lib/libssl/src/doc/crypto/dsa.pod104
-rw-r--r--src/lib/libssl/src/doc/crypto/err.pod187
-rw-r--r--src/lib/libssl/src/doc/crypto/hmac.pod75
-rw-r--r--src/lib/libssl/src/doc/crypto/lh_stats.pod60
-rw-r--r--src/lib/libssl/src/doc/crypto/lhash.pod155
-rw-r--r--src/lib/libssl/src/doc/crypto/md5.pod85
-rw-r--r--src/lib/libssl/src/doc/crypto/mdc2.pod64
-rw-r--r--src/lib/libssl/src/doc/crypto/rand.pod158
-rw-r--r--src/lib/libssl/src/doc/crypto/rc4.pod62
-rw-r--r--src/lib/libssl/src/doc/crypto/ripemd.pod66
-rw-r--r--src/lib/libssl/src/doc/crypto/rsa.pod115
-rw-r--r--src/lib/libssl/src/doc/crypto/sha.pod70
-rw-r--r--src/lib/libssl/src/doc/crypto/threads.pod70
-rw-r--r--src/lib/libssl/src/doc/openssl.pod304
-rw-r--r--src/lib/libssl/src/doc/openssl.txt120
-rw-r--r--src/lib/libssl/src/doc/ssl.pod633
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_error.pod91
-rw-r--r--src/lib/libssl/src/doc/ssl/ssl.pod634
-rw-r--r--src/lib/libssl/src/doc/ssleay.txt4
-rw-r--r--src/lib/libssl/src/e_os.h53
-rw-r--r--src/lib/libssl/src/install.com1
-rw-r--r--src/lib/libssl/src/makevms.com157
-rw-r--r--src/lib/libssl/src/ms/test.bat8
-rw-r--r--src/lib/libssl/src/mt/README14
-rw-r--r--src/lib/libssl/src/mt/mttest.c1092
-rw-r--r--src/lib/libssl/src/mt/profile.sh4
-rw-r--r--src/lib/libssl/src/mt/ptest.bat4
-rw-r--r--src/lib/libssl/src/mt/pthread.sh9
-rw-r--r--src/lib/libssl/src/mt/purify.sh4
-rw-r--r--src/lib/libssl/src/mt/solaris.sh4
-rw-r--r--src/lib/libssl/src/mt/win32.bat4
-rw-r--r--src/lib/libssl/src/rsaref/Makefile.ssl5
-rw-r--r--src/lib/libssl/src/rsaref/rsaref.c9
-rw-r--r--src/lib/libssl/src/ssl/Makefile.ssl47
-rw-r--r--src/lib/libssl/src/ssl/bio_ssl.c33
-rw-r--r--src/lib/libssl/src/ssl/install.com1
-rw-r--r--src/lib/libssl/src/ssl/s23_clnt.c16
-rw-r--r--src/lib/libssl/src/ssl/s23_lib.c17
-rw-r--r--src/lib/libssl/src/ssl/s23_pkt.c2
-rw-r--r--src/lib/libssl/src/ssl/s23_srvr.c135
-rw-r--r--src/lib/libssl/src/ssl/s2_clnt.c77
-rw-r--r--src/lib/libssl/src/ssl/s2_enc.c9
-rw-r--r--src/lib/libssl/src/ssl/s2_lib.c100
-rw-r--r--src/lib/libssl/src/ssl/s2_meth.c10
-rw-r--r--src/lib/libssl/src/ssl/s2_pkt.c10
-rw-r--r--src/lib/libssl/src/ssl/s2_srvr.c23
-rw-r--r--src/lib/libssl/src/ssl/s3_both.c164
-rw-r--r--src/lib/libssl/src/ssl/s3_clnt.c43
-rw-r--r--src/lib/libssl/src/ssl/s3_enc.c18
-rw-r--r--src/lib/libssl/src/ssl/s3_lib.c377
-rw-r--r--src/lib/libssl/src/ssl/s3_pkt.c761
-rw-r--r--src/lib/libssl/src/ssl/s3_srvr.c185
-rw-r--r--src/lib/libssl/src/ssl/ssl-lib.com28
-rw-r--r--src/lib/libssl/src/ssl/ssl.h117
-rw-r--r--src/lib/libssl/src/ssl/ssl2.h4
-rw-r--r--src/lib/libssl/src/ssl/ssl3.h95
-rw-r--r--src/lib/libssl/src/ssl/ssl_asn1.c32
-rw-r--r--src/lib/libssl/src/ssl/ssl_cert.c33
-rw-r--r--src/lib/libssl/src/ssl/ssl_ciph.c825
-rw-r--r--src/lib/libssl/src/ssl/ssl_err.c18
-rw-r--r--src/lib/libssl/src/ssl/ssl_lib.c175
-rw-r--r--src/lib/libssl/src/ssl/ssl_locl.h152
-rw-r--r--src/lib/libssl/src/ssl/ssl_sess.c89
-rw-r--r--src/lib/libssl/src/ssl/ssl_stat.c8
-rw-r--r--src/lib/libssl/src/ssl/ssl_task.c2
-rw-r--r--src/lib/libssl/src/ssl/ssl_txt.c7
-rw-r--r--src/lib/libssl/src/ssl/ssltest.c226
-rw-r--r--src/lib/libssl/src/ssl/t1_enc.c6
-rw-r--r--src/lib/libssl/src/ssl/t1_lib.c14
-rw-r--r--src/lib/libssl/src/ssl/tls1.h6
-rw-r--r--src/lib/libssl/src/test/Makefile.ssl58
-rw-r--r--src/lib/libssl/src/test/dsa-ca.pem43
-rw-r--r--src/lib/libssl/src/test/dsa-pca.pem49
-rw-r--r--src/lib/libssl/src/test/maketests.com30
-rw-r--r--src/lib/libssl/src/test/rsa_test.c314
-rw-r--r--src/lib/libssl/src/test/tcrl.com23
-rw-r--r--src/lib/libssl/src/test/testca.com4
-rw-r--r--src/lib/libssl/src/test/testenc.com18
-rw-r--r--src/lib/libssl/src/test/testgen2
-rw-r--r--src/lib/libssl/src/test/testgen.com5
-rw-r--r--src/lib/libssl/src/test/tests.com16
-rw-r--r--src/lib/libssl/src/test/testssl6
-rw-r--r--src/lib/libssl/src/test/testssl.com8
-rw-r--r--src/lib/libssl/src/test/tpkcs7.com13
-rw-r--r--src/lib/libssl/src/test/tpkcs7d.com7
-rw-r--r--src/lib/libssl/src/test/treq.com23
-rw-r--r--src/lib/libssl/src/test/trsa.com23
-rw-r--r--src/lib/libssl/src/test/tsid.com23
-rw-r--r--src/lib/libssl/src/test/tx509.com23
-rw-r--r--src/lib/libssl/src/util/domd2
-rw-r--r--src/lib/libssl/src/util/libeay.num403
-rw-r--r--src/lib/libssl/src/util/mkdef.pl139
-rw-r--r--src/lib/libssl/src/util/mkerr.pl2
-rw-r--r--src/lib/libssl/src/util/pl/BC-32.pl2
-rw-r--r--src/lib/libssl/src/util/pl/Mingw32.pl2
-rw-r--r--src/lib/libssl/src/util/pl/VC-32.pl2
-rw-r--r--src/lib/libssl/src/util/pod2man.pl1181
-rw-r--r--src/lib/libssl/src/util/selftest.pl174
-rw-r--r--src/lib/libssl/src/util/ssleay.num10
-rw-r--r--src/lib/libssl/ssl-patent/shlib_version2
-rw-r--r--src/lib/libssl/ssl.h117
-rw-r--r--src/lib/libssl/ssl/shlib_version2
-rw-r--r--src/lib/libssl/ssl2.h4
-rw-r--r--src/lib/libssl/ssl3.h95
-rw-r--r--src/lib/libssl/ssl_asn1.c32
-rw-r--r--src/lib/libssl/ssl_cert.c33
-rw-r--r--src/lib/libssl/ssl_ciph.c825
-rw-r--r--src/lib/libssl/ssl_err.c18
-rw-r--r--src/lib/libssl/ssl_lib.c175
-rw-r--r--src/lib/libssl/ssl_locl.h152
-rw-r--r--src/lib/libssl/ssl_sess.c89
-rw-r--r--src/lib/libssl/ssl_stat.c8
-rw-r--r--src/lib/libssl/ssl_txt.c7
-rw-r--r--src/lib/libssl/t1_enc.c6
-rw-r--r--src/lib/libssl/t1_lib.c14
-rw-r--r--src/lib/libssl/test/Makefile.ssl58
-rw-r--r--src/lib/libssl/test/dsa-ca.pem43
-rw-r--r--src/lib/libssl/test/dsa-pca.pem49
-rw-r--r--src/lib/libssl/test/maketests.com30
-rw-r--r--src/lib/libssl/test/rsa_test.c314
-rw-r--r--src/lib/libssl/test/tcrl.com23
-rw-r--r--src/lib/libssl/test/testca.com4
-rw-r--r--src/lib/libssl/test/testenc.com18
-rw-r--r--src/lib/libssl/test/testgen2
-rw-r--r--src/lib/libssl/test/testgen.com5
-rw-r--r--src/lib/libssl/test/tests.com16
-rw-r--r--src/lib/libssl/test/testssl6
-rw-r--r--src/lib/libssl/test/testssl.com8
-rw-r--r--src/lib/libssl/test/tpkcs7.com13
-rw-r--r--src/lib/libssl/test/tpkcs7d.com7
-rw-r--r--src/lib/libssl/test/treq.com23
-rw-r--r--src/lib/libssl/test/trsa.com23
-rw-r--r--src/lib/libssl/test/tsid.com23
-rw-r--r--src/lib/libssl/test/tx509.com23
-rw-r--r--src/lib/libssl/tls1.h6
1262 files changed, 87546 insertions, 32806 deletions
diff --git a/src/lib/libcrypto/Attic/Makefile b/src/lib/libcrypto/Attic/Makefile
index f4813d3aaa..c0b6e906a8 100644
--- a/src/lib/libcrypto/Attic/Makefile
+++ b/src/lib/libcrypto/Attic/Makefile
@@ -34,8 +34,8 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
34GENERAL=Makefile README crypto-lib.com install.com 34GENERAL=Makefile README crypto-lib.com install.com
35 35
36LIB= $(TOP)/libcrypto.a 36LIB= $(TOP)/libcrypto.a
37LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c cpt_err.c 37LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c
38LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o cpt_err.o 38LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o
39 39
40SRC= $(LIBSRC) 40SRC= $(LIBSRC)
41 41
@@ -57,6 +57,11 @@ buildinf.h: ../Makefile.ssl
57 echo " #define DATE \"`date`\""; \ 57 echo " #define DATE \"`date`\""; \
58 echo "#endif" ) >buildinf.h 58 echo "#endif" ) >buildinf.h
59 59
60testapps:
61 if echo ${SDIRS} | fgrep ' des '; \
62 then cd des && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' des; fi
63 cd pkcs7 && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' testapps
64
60subdirs: 65subdirs:
61 @for i in $(SDIRS) ;\ 66 @for i in $(SDIRS) ;\
62 do \ 67 do \
@@ -122,7 +127,7 @@ lint:
122 done; 127 done;
123 128
124depend: 129depend:
125 if [ ! -e buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist 130 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist
126 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC) 131 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC)
127 if [ ! -s buildinf.h ]; then rm buildinf.h; fi 132 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
128 @for i in $(SDIRS) ;\ 133 @for i in $(SDIRS) ;\
@@ -151,29 +156,40 @@ dclean:
151# DO NOT DELETE THIS LINE -- make depend depends on it. 156# DO NOT DELETE THIS LINE -- make depend depends on it.
152 157
153cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h 158cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h
154cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/stack.h 159cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
160cpt_err.o: ../include/openssl/stack.h
155cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h 161cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h
156cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 162cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
157cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 163cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
158cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 164cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
159cryptlib.o: ../include/openssl/stack.h cryptlib.h 165cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
166cryptlib.o: cryptlib.h
160cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h 167cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h
161cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 168cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
162cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h 169cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h
163cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 170cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
164cversion.o: ../include/openssl/stack.h buildinf.h cryptlib.h 171cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
172cversion.o: buildinf.h cryptlib.h
165ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h 173ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h
166ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 174ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
167ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h 175ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h
168ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 176ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
169ex_data.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 177ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
178ex_data.o: ../include/openssl/stack.h cryptlib.h
170mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h 179mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h
171mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 180mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
172mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h 181mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h
173mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 182mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
174mem.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 183mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h cryptlib.h
184mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h
185mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
186mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h
187mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
188mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
189mem_dbg.o: ../include/openssl/stack.h cryptlib.h
175tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h 190tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h
176tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 191tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
177tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h 192tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h
178tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 193tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
179tmdiff.o: ../include/openssl/stack.h ../include/openssl/tmdiff.h cryptlib.h 194tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
195tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
index 2fcbf18545..cab75d9f80 100644
--- a/src/lib/libcrypto/Makefile.ssl
+++ b/src/lib/libcrypto/Makefile.ssl
@@ -34,8 +34,8 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
34GENERAL=Makefile README crypto-lib.com install.com 34GENERAL=Makefile README crypto-lib.com install.com
35 35
36LIB= $(TOP)/libcrypto.a 36LIB= $(TOP)/libcrypto.a
37LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c cpt_err.c 37LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c
38LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o cpt_err.o 38LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o
39 39
40SRC= $(LIBSRC) 40SRC= $(LIBSRC)
41 41
@@ -57,6 +57,11 @@ buildinf.h: ../Makefile.ssl
57 echo " #define DATE \"`date`\""; \ 57 echo " #define DATE \"`date`\""; \
58 echo "#endif" ) >buildinf.h 58 echo "#endif" ) >buildinf.h
59 59
60testapps:
61 if echo ${SDIRS} | fgrep ' des '; \
62 then cd des && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' des; fi
63 cd pkcs7 && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' testapps
64
60subdirs: 65subdirs:
61 @for i in $(SDIRS) ;\ 66 @for i in $(SDIRS) ;\
62 do \ 67 do \
@@ -122,7 +127,7 @@ lint:
122 done; 127 done;
123 128
124depend: 129depend:
125 if [ ! -e buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist 130 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist
126 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC) 131 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC)
127 if [ ! -s buildinf.h ]; then rm buildinf.h; fi 132 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
128 @for i in $(SDIRS) ;\ 133 @for i in $(SDIRS) ;\
@@ -151,29 +156,40 @@ dclean:
151# DO NOT DELETE THIS LINE -- make depend depends on it. 156# DO NOT DELETE THIS LINE -- make depend depends on it.
152 157
153cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h 158cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h
154cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/stack.h 159cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
160cpt_err.o: ../include/openssl/stack.h
155cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h 161cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h
156cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 162cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
157cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 163cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
158cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 164cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
159cryptlib.o: ../include/openssl/stack.h cryptlib.h 165cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
166cryptlib.o: cryptlib.h
160cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h 167cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h
161cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 168cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
162cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h 169cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h
163cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 170cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
164cversion.o: ../include/openssl/stack.h buildinf.h cryptlib.h 171cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
172cversion.o: buildinf.h cryptlib.h
165ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h 173ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h
166ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 174ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
167ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h 175ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h
168ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 176ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
169ex_data.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 177ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
178ex_data.o: ../include/openssl/stack.h cryptlib.h
170mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h 179mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h
171mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 180mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
172mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h 181mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h
173mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 182mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
174mem.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 183mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h cryptlib.h
184mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h
185mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
186mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h
187mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
188mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
189mem_dbg.o: ../include/openssl/stack.h cryptlib.h
175tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h 190tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h
176tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 191tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
177tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h 192tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h
178tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 193tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
179tmdiff.o: ../include/openssl/stack.h ../include/openssl/tmdiff.h cryptlib.h 194tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
195tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
index 5d668411f6..a17a713a75 100644
--- a/src/lib/libcrypto/asn1/Makefile.ssl
+++ b/src/lib/libcrypto/asn1/Makefile.ssl
@@ -23,34 +23,34 @@ APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(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 \ 25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \
26 a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_bmp.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_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c \ 27 a_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c \
28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \ 28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \
29 x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c nsseq.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 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.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 \ 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\ 32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
33 t_req.c t_x509.c t_crl.c t_pkey.c \ 33 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 \ 34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \
35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ 35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \
36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.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 \ 37 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 \ 38 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 39 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c
40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \ 40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \
41 a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_bmp.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 \
42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o \ 42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o \
43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \ 43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \
44 x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o nsseq.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 \
45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.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 \ 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 \ 47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
48 t_req.o t_x509.o t_crl.o t_pkey.o \ 48 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 \ 49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \
50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ 50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \
51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.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 \ 52 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 \ 53 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 54 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o
55 55
56SRC= $(LIBSRC) 56SRC= $(LIBSRC)
@@ -160,11 +160,13 @@ a_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
160a_digest.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 160a_digest.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
161a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 161a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
162a_digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 162a_digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
163a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h 163a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
164a_digest.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 164a_digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
165a_digest.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 165a_digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
166a_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 166a_digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
167a_digest.o: ../../include/openssl/stack.h ../cryptlib.h 167a_digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
168a_digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
169a_digest.o: ../cryptlib.h
168a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 170a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
169a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 171a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
170a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 172a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -207,6 +209,13 @@ a_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
207a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 209a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
208a_int.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 210a_int.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209a_int.o: ../cryptlib.h 211a_int.o: ../cryptlib.h
212a_mbstr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
213a_mbstr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
214a_mbstr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
215a_mbstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
216a_mbstr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
217a_mbstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
218a_mbstr.o: ../cryptlib.h
210a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 219a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
211a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 220a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
212a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 221a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -214,6 +223,13 @@ a_meth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 223a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
215a_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 224a_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
216a_meth.o: ../cryptlib.h 225a_meth.o: ../cryptlib.h
226a_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
227a_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
228a_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
229a_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
230a_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
231a_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
232a_null.o: ../cryptlib.h
217a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 233a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
218a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 234a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
219a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 235a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -259,6 +275,13 @@ a_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
259a_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 275a_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
260a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 276a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
261a_sign.o: ../cryptlib.h 277a_sign.o: ../cryptlib.h
278a_strnid.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
279a_strnid.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
280a_strnid.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
281a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
282a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
283a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
284a_strnid.o: ../../include/openssl/stack.h ../cryptlib.h
262a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 285a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
263a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 286a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
264a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 287a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -788,6 +811,24 @@ p8_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
788p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 811p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
789p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 812p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
790p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 813p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
814t_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
815t_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
816t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
817t_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
818t_bitst.o: ../../include/openssl/des.h ../../include/openssl/dh.h
819t_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
820t_bitst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
821t_bitst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
822t_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
823t_bitst.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
824t_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
825t_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
826t_bitst.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
827t_bitst.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
828t_bitst.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
829t_bitst.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
830t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
831t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h
791t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 832t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
792t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 833t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
793t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 834t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -812,15 +853,17 @@ t_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
812t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 853t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
813t_pkey.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 854t_pkey.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
814t_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 855t_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
815t_pkey.o: ../../include/openssl/stack.h ../cryptlib.h 856t_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
857t_pkey.o: ../cryptlib.h
816t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 858t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
817t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 859t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
818t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 860t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
819t_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 861t_req.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
820t_req.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 862t_req.o: ../../include/openssl/des.h ../../include/openssl/dh.h
821t_req.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 863t_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
822t_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h 864t_req.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
823t_req.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 865t_req.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
866t_req.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
824t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 867t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
825t_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 868t_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
826t_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 869t_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -829,7 +872,24 @@ t_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
829t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 872t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
830t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 873t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
831t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 874t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
832t_req.o: ../cryptlib.h 875t_req.o: ../../include/openssl/x509v3.h ../cryptlib.h
876t_spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
877t_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
878t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
879t_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
880t_spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h
881t_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
882t_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
883t_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
884t_spki.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
885t_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
886t_spki.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
887t_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
888t_spki.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
889t_spki.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
890t_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
891t_spki.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
892t_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
833t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 893t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
834t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 894t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
835t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 895t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -848,6 +908,23 @@ t_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
848t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 908t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
849t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 909t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
850t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h 910t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h
911t_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
912t_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
913t_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
914t_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
915t_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
916t_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
917t_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
918t_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
919t_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
920t_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
921t_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
922t_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
923t_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
924t_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
925t_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
926t_x509a.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
927t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
851x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 928x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
852x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 929x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
853x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 930x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -1088,3 +1165,20 @@ x_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1088x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 1165x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1089x_x509.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 1166x_x509.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
1090x_x509.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 1167x_x509.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
1168x_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
1169x_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1170x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1171x_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1172x_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
1173x_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
1174x_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1175x_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1176x_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
1177x_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
1178x_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1179x_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1180x_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1181x_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1182x_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1183x_x509a.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
1184x_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 38ea802be8..c77456b315 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -60,6 +60,15 @@
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)
70{ return M_ASN1_BIT_STRING_set(x, d, len); }
71
63int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) 72int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
64 { 73 {
65 int ret,j,r,bits,len; 74 int ret,j,r,bits,len;
@@ -121,7 +130,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
121 130
122 if ((a == NULL) || ((*a) == NULL)) 131 if ((a == NULL) || ((*a) == NULL))
123 { 132 {
124 if ((ret=ASN1_BIT_STRING_new()) == NULL) return(NULL); 133 if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL);
125 } 134 }
126 else 135 else
127 ret=(*a); 136 ret=(*a);
@@ -164,7 +173,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
164 s=NULL; 173 s=NULL;
165 174
166 ret->length=(int)len; 175 ret->length=(int)len;
167 if (ret->data != NULL) Free((char *)ret->data); 176 if (ret->data != NULL) Free(ret->data);
168 ret->data=s; 177 ret->data=s;
169 ret->type=V_ASN1_BIT_STRING; 178 ret->type=V_ASN1_BIT_STRING;
170 if (a != NULL) (*a)=ret; 179 if (a != NULL) (*a)=ret;
@@ -173,7 +182,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
173err: 182err:
174 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i); 183 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i);
175 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 184 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
176 ASN1_BIT_STRING_free(ret); 185 M_ASN1_BIT_STRING_free(ret);
177 return(NULL); 186 return(NULL);
178 } 187 }
179 188
diff --git a/src/lib/libcrypto/asn1/a_bmp.c b/src/lib/libcrypto/asn1/a_bmp.c
index 6075871984..d9ac5a0475 100644
--- a/src/lib/libcrypto/asn1/a_bmp.c
+++ b/src/lib/libcrypto/asn1/a_bmp.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_BMPSTRING *ASN1_BMPSTRING_new(void)
64{ return M_ASN1_BMPSTRING_new(); }
65
66void ASN1_BMPSTRING_free(ASN1_BMPSTRING *x)
67{ M_ASN1_BMPSTRING_free(x); }
68
63int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp) 69int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index e452e03b88..8cde695804 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -71,7 +71,7 @@ B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN, 71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
72 }; 72 };
73 73
74static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c); 74static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
75/* type is a 'bitmap' of acceptable string types. 75/* type is a 'bitmap' of acceptable string types.
76 */ 76 */
77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp, 77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
@@ -124,7 +124,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
124 else 124 else
125 s=NULL; 125 s=NULL;
126 126
127 if (ret->data != NULL) Free((char *)ret->data); 127 if (ret->data != NULL) Free(ret->data);
128 ret->length=(int)len; 128 ret->length=(int)len;
129 ret->data=s; 129 ret->data=s;
130 ret->type=tag; 130 ret->type=tag;
@@ -205,7 +205,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
205 c.tag=Ptag; 205 c.tag=Ptag;
206 c.xclass=Pclass; 206 c.xclass=Pclass;
207 c.max=(length == 0)?0:(p+length); 207 c.max=(length == 0)?0:(p+length);
208 if (!asn1_collate_primative(ret,&c)) 208 if (!asn1_collate_primitive(ret,&c))
209 goto err; 209 goto err;
210 else 210 else
211 { 211 {
@@ -218,8 +218,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
218 { 218 {
219 if ((ret->length < len) || (ret->data == NULL)) 219 if ((ret->length < len) || (ret->data == NULL))
220 { 220 {
221 if (ret->data != NULL) Free((char *)ret->data); 221 if (ret->data != NULL) Free(ret->data);
222 s=(unsigned char *)Malloc((int)len); 222 s=(unsigned char *)Malloc((int)len + 1);
223 if (s == NULL) 223 if (s == NULL)
224 { 224 {
225 i=ERR_R_MALLOC_FAILURE; 225 i=ERR_R_MALLOC_FAILURE;
@@ -229,12 +229,13 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
229 else 229 else
230 s=ret->data; 230 s=ret->data;
231 memcpy(s,p,(int)len); 231 memcpy(s,p,(int)len);
232 s[len] = '\0';
232 p+=len; 233 p+=len;
233 } 234 }
234 else 235 else
235 { 236 {
236 s=NULL; 237 s=NULL;
237 if (ret->data != NULL) Free((char *)ret->data); 238 if (ret->data != NULL) Free(ret->data);
238 } 239 }
239 240
240 ret->length=(int)len; 241 ret->length=(int)len;
@@ -253,11 +254,11 @@ err:
253 } 254 }
254 255
255 256
256/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapes 257/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapse
257 * them into the one struture that is then returned */ 258 * them into the one structure that is then returned */
258/* There have been a few bug fixes for this function from 259/* There have been a few bug fixes for this function from
259 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */ 260 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
260static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c) 261static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
261 { 262 {
262 ASN1_STRING *os=NULL; 263 ASN1_STRING *os=NULL;
263 BUF_MEM b; 264 BUF_MEM b;
diff --git a/src/lib/libcrypto/asn1/a_digest.c b/src/lib/libcrypto/asn1/a_digest.c
index 8c45add557..3370aae998 100644
--- a/src/lib/libcrypto/asn1/a_digest.c
+++ b/src/lib/libcrypto/asn1/a_digest.c
@@ -58,16 +58,19 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/evp.h> 68#include <openssl/evp.h>
66#include <openssl/buffer.h> 69#include <openssl/buffer.h>
67#include <openssl/x509.h> 70#include <openssl/x509.h>
68 71
69int ASN1_digest(int (*i2d)(), EVP_MD *type, char *data, unsigned char *md, 72int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
70 unsigned int *len) 73 unsigned char *md, unsigned int *len)
71 { 74 {
72 EVP_MD_CTX ctx; 75 EVP_MD_CTX ctx;
73 int i; 76 int i;
diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c
index c0a8709f3b..3202a816d0 100644
--- a/src/lib/libcrypto/asn1/a_dup.c
+++ b/src/lib/libcrypto/asn1/a_dup.c
@@ -78,6 +78,6 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
78 i=i2d(x,&p); 78 i=i2d(x,&p);
79 p= b; 79 p= b;
80 ret=d2i(NULL,&p,i); 80 ret=d2i(NULL,&p,i);
81 Free((char *)b); 81 Free(b);
82 return(ret); 82 return(ret);
83 } 83 }
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index 9239ecc439..ccf62e5a04 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -65,6 +65,12 @@
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
68int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp) 74int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp)
69 { 75 {
70 int pad=0,ret,r,i,t; 76 int pad=0,ret,r,i,t;
@@ -142,7 +148,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
142 148
143 if ((a == NULL) || ((*a) == NULL)) 149 if ((a == NULL) || ((*a) == NULL))
144 { 150 {
145 if ((ret=ASN1_ENUMERATED_new()) == NULL) return(NULL); 151 if ((ret=M_ASN1_ENUMERATED_new()) == NULL) return(NULL);
146 ret->type=V_ASN1_ENUMERATED; 152 ret->type=V_ASN1_ENUMERATED;
147 } 153 }
148 else 154 else
@@ -171,7 +177,12 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
171 goto err; 177 goto err;
172 } 178 }
173 to=s; 179 to=s;
174 if (*p & 0x80) /* a negative number */ 180 if(!len) {
181 /* Strictly speaking this is an illegal ENUMERATED but we
182 * tolerate it.
183 */
184 ret->type=V_ASN1_ENUMERATED;
185 } else if (*p & 0x80) /* a negative number */
175 { 186 {
176 ret->type=V_ASN1_NEG_ENUMERATED; 187 ret->type=V_ASN1_NEG_ENUMERATED;
177 if ((*p == 0xff) && (len != 1)) { 188 if ((*p == 0xff) && (len != 1)) {
@@ -208,7 +219,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
208 p+=len; 219 p+=len;
209 } 220 }
210 221
211 if (ret->data != NULL) Free((char *)ret->data); 222 if (ret->data != NULL) Free(ret->data);
212 ret->data=s; 223 ret->data=s;
213 ret->length=(int)len; 224 ret->length=(int)len;
214 if (a != NULL) (*a)=ret; 225 if (a != NULL) (*a)=ret;
@@ -217,7 +228,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
217err: 228err:
218 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i); 229 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i);
219 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 230 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
220 ASN1_ENUMERATED_free(ret); 231 M_ASN1_ENUMERATED_free(ret);
221 return(NULL); 232 return(NULL);
222 } 233 }
223 234
@@ -231,7 +242,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
231 if (a->length < (sizeof(long)+1)) 242 if (a->length < (sizeof(long)+1))
232 { 243 {
233 if (a->data != NULL) 244 if (a->data != NULL)
234 Free((char *)a->data); 245 Free(a->data);
235 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL) 246 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
236 memset((char *)a->data,0,sizeof(long)+1); 247 memset((char *)a->data,0,sizeof(long)+1);
237 } 248 }
@@ -295,7 +306,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
295 int len,j; 306 int len,j;
296 307
297 if (ai == NULL) 308 if (ai == NULL)
298 ret=ASN1_ENUMERATED_new(); 309 ret=M_ASN1_ENUMERATED_new();
299 else 310 else
300 ret=ai; 311 ret=ai;
301 if (ret == NULL) 312 if (ret == NULL)
@@ -311,7 +322,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
311 ret->length=BN_bn2bin(bn,ret->data); 322 ret->length=BN_bn2bin(bn,ret->data);
312 return(ret); 323 return(ret);
313err: 324err:
314 if (ret != ai) ASN1_ENUMERATED_free(ret); 325 if (ret != ai) M_ASN1_ENUMERATED_free(ret);
315 return(NULL); 326 return(NULL);
316 } 327 }
317 328
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
index 226474f057..84062170e8 100644
--- a/src/lib/libcrypto/asn1/a_gentm.c
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -63,6 +63,12 @@
63#include "cryptlib.h" 63#include "cryptlib.h"
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65 65
66ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void)
67{ return M_ASN1_GENERALIZEDTIME_new(); }
68
69void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *x)
70{ M_ASN1_GENERALIZEDTIME_free(x); }
71
66int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) 72int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
67 { 73 {
68#ifdef CHARSET_EBCDIC 74#ifdef CHARSET_EBCDIC
@@ -106,7 +112,7 @@ ASN1_GENERALIZEDTIME *d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,
106 return(ret); 112 return(ret);
107err: 113err:
108 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 114 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
109 ASN1_GENERALIZEDTIME_free(ret); 115 M_ASN1_GENERALIZEDTIME_free(ret);
110 return(NULL); 116 return(NULL);
111 } 117 }
112 118
@@ -193,7 +199,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
193#endif 199#endif
194 200
195 if (s == NULL) 201 if (s == NULL)
196 s=ASN1_GENERALIZEDTIME_new(); 202 s=M_ASN1_GENERALIZEDTIME_new();
197 if (s == NULL) 203 if (s == NULL)
198 return(NULL); 204 return(NULL);
199 205
diff --git a/src/lib/libcrypto/asn1/a_hdr.c b/src/lib/libcrypto/asn1/a_hdr.c
index 1171d36443..434610e8e1 100644
--- a/src/lib/libcrypto/asn1/a_hdr.c
+++ b/src/lib/libcrypto/asn1/a_hdr.c
@@ -102,7 +102,7 @@ ASN1_HEADER *ASN1_HEADER_new(void)
102 ASN1_CTX c; 102 ASN1_CTX c;
103 103
104 M_ASN1_New_Malloc(ret,ASN1_HEADER); 104 M_ASN1_New_Malloc(ret,ASN1_HEADER);
105 M_ASN1_New(ret->header,ASN1_OCTET_STRING_new); 105 M_ASN1_New(ret->header,M_ASN1_OCTET_STRING_new);
106 ret->meth=NULL; 106 ret->meth=NULL;
107 ret->data=NULL; 107 ret->data=NULL;
108 return(ret); 108 return(ret);
@@ -112,8 +112,8 @@ ASN1_HEADER *ASN1_HEADER_new(void)
112void ASN1_HEADER_free(ASN1_HEADER *a) 112void ASN1_HEADER_free(ASN1_HEADER *a)
113 { 113 {
114 if (a == NULL) return; 114 if (a == NULL) return;
115 ASN1_OCTET_STRING_free(a->header); 115 M_ASN1_OCTET_STRING_free(a->header);
116 if (a->meth != NULL) 116 if (a->meth != NULL)
117 a->meth->destroy(a->data); 117 a->meth->destroy(a->data);
118 Free((char *)a); 118 Free(a);
119 } 119 }
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c
index 6bd845443c..d9b8035e17 100644
--- a/src/lib/libcrypto/asn1/a_i2d_fp.c
+++ b/src/lib/libcrypto/asn1/a_i2d_fp.c
@@ -108,6 +108,6 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x)
108 j+=i; 108 j+=i;
109 n-=i; 109 n-=i;
110 } 110 }
111 Free((char *)b); 111 Free(b);
112 return(ret); 112 return(ret);
113 } 113 }
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index d05436378b..8b6794e8c1 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -60,6 +60,18 @@
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)
70{ return M_ASN1_INTEGER_dup(x);}
71
72int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
73{ return M_ASN1_INTEGER_cmp(x,y);}
74
63/* 75/*
64 * This converts an ASN1 INTEGER into its DER encoding. 76 * This converts an ASN1 INTEGER into its DER encoding.
65 * The internal representation is an ASN1_STRING whose data is a big endian 77 * The internal representation is an ASN1_STRING whose data is a big endian
@@ -160,7 +172,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
160 172
161 if ((a == NULL) || ((*a) == NULL)) 173 if ((a == NULL) || ((*a) == NULL))
162 { 174 {
163 if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL); 175 if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
164 ret->type=V_ASN1_INTEGER; 176 ret->type=V_ASN1_INTEGER;
165 } 177 }
166 else 178 else
@@ -190,7 +202,12 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
190 goto err; 202 goto err;
191 } 203 }
192 to=s; 204 to=s;
193 if (*p & 0x80) /* a negative number */ 205 if(!len) {
206 /* Strictly speaking this is an illegal INTEGER but we
207 * tolerate it.
208 */
209 ret->type=V_ASN1_INTEGER;
210 } else if (*p & 0x80) /* a negative number */
194 { 211 {
195 ret->type=V_ASN1_NEG_INTEGER; 212 ret->type=V_ASN1_NEG_INTEGER;
196 if ((*p == 0xff) && (len != 1)) { 213 if ((*p == 0xff) && (len != 1)) {
@@ -231,7 +248,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
231 memcpy(s,p,(int)len); 248 memcpy(s,p,(int)len);
232 } 249 }
233 250
234 if (ret->data != NULL) Free((char *)ret->data); 251 if (ret->data != NULL) Free(ret->data);
235 ret->data=s; 252 ret->data=s;
236 ret->length=(int)len; 253 ret->length=(int)len;
237 if (a != NULL) (*a)=ret; 254 if (a != NULL) (*a)=ret;
@@ -240,7 +257,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
240err: 257err:
241 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i); 258 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
242 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 259 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
243 ASN1_INTEGER_free(ret); 260 M_ASN1_INTEGER_free(ret);
244 return(NULL); 261 return(NULL);
245 } 262 }
246 263
@@ -260,7 +277,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
260 277
261 if ((a == NULL) || ((*a) == NULL)) 278 if ((a == NULL) || ((*a) == NULL))
262 { 279 {
263 if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL); 280 if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
264 ret->type=V_ASN1_INTEGER; 281 ret->type=V_ASN1_INTEGER;
265 } 282 }
266 else 283 else
@@ -289,7 +306,8 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
289 goto err; 306 goto err;
290 } 307 }
291 to=s; 308 to=s;
292 ret->type=V_ASN1_INTEGER; 309 ret->type=V_ASN1_INTEGER;
310 if(len) {
293 if ((*p == 0) && (len != 1)) 311 if ((*p == 0) && (len != 1))
294 { 312 {
295 p++; 313 p++;
@@ -297,8 +315,9 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
297 } 315 }
298 memcpy(s,p,(int)len); 316 memcpy(s,p,(int)len);
299 p+=len; 317 p+=len;
318 }
300 319
301 if (ret->data != NULL) Free((char *)ret->data); 320 if (ret->data != NULL) Free(ret->data);
302 ret->data=s; 321 ret->data=s;
303 ret->length=(int)len; 322 ret->length=(int)len;
304 if (a != NULL) (*a)=ret; 323 if (a != NULL) (*a)=ret;
@@ -307,7 +326,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
307err: 326err:
308 ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i); 327 ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i);
309 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 328 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
310 ASN1_INTEGER_free(ret); 329 M_ASN1_INTEGER_free(ret);
311 return(NULL); 330 return(NULL);
312 } 331 }
313 332
@@ -321,7 +340,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
321 if (a->length < (sizeof(long)+1)) 340 if (a->length < (sizeof(long)+1))
322 { 341 {
323 if (a->data != NULL) 342 if (a->data != NULL)
324 Free((char *)a->data); 343 Free(a->data);
325 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL) 344 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
326 memset((char *)a->data,0,sizeof(long)+1); 345 memset((char *)a->data,0,sizeof(long)+1);
327 } 346 }
@@ -385,7 +404,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
385 int len,j; 404 int len,j;
386 405
387 if (ai == NULL) 406 if (ai == NULL)
388 ret=ASN1_INTEGER_new(); 407 ret=M_ASN1_INTEGER_new();
389 else 408 else
390 ret=ai; 409 ret=ai;
391 if (ret == NULL) 410 if (ret == NULL)
@@ -401,7 +420,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
401 ret->length=BN_bn2bin(bn,ret->data); 420 ret->length=BN_bn2bin(bn,ret->data);
402 return(ret); 421 return(ret);
403err: 422err:
404 if (ret != ai) ASN1_INTEGER_free(ret); 423 if (ret != ai) M_ASN1_INTEGER_free(ret);
405 return(NULL); 424 return(NULL);
406 } 425 }
407 426
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
new file mode 100644
index 0000000000..7a710d5459
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -0,0 +1,390 @@
1/* a_mbstr.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 <ctype.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63
64static int traverse_string(const unsigned char *p, int len, int inform,
65 int (*rfunc)(unsigned long value, void *in), void *arg);
66static int in_utf8(unsigned long value, void *arg);
67static int out_utf8(unsigned long value, void *arg);
68static int type_str(unsigned long value, void *arg);
69static int cpy_asc(unsigned long value, void *arg);
70static int cpy_bmp(unsigned long value, void *arg);
71static int cpy_univ(unsigned long value, void *arg);
72static int cpy_utf8(unsigned long value, void *arg);
73static int is_printable(unsigned long value);
74
75/* These functions take a string in UTF8, ASCII or multibyte form and
76 * a mask of permissible ASN1 string types. It then works out the minimal
77 * type (using the order Printable < IA5 < T61 < BMP < Universal < UTF8)
78 * and creates a string of the correct type with the supplied data.
79 * Yes this is horrible: it has to be :-(
80 * The 'ncopy' form checks minimum and maximum size limits too.
81 */
82
83int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
84 int inform, unsigned long mask)
85{
86 return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
87}
88
89int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
90 int inform, unsigned long mask,
91 long minsize, long maxsize)
92{
93 int str_type;
94 int ret;
95 int outform, outlen;
96 ASN1_STRING *dest;
97 unsigned char *p;
98 int nchar;
99 char strbuf[32];
100 int (*cpyfunc)(unsigned long,void *) = NULL;
101 if(len == -1) len = strlen((const char *)in);
102 if(!mask) mask = DIRSTRING_TYPE;
103
104 /* First do a string check and work out the number of characters */
105 switch(inform) {
106
107 case MBSTRING_BMP:
108 if(len & 1) {
109 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
110 ASN1_R_INVALID_BMPSTRING_LENGTH);
111 return -1;
112 }
113 nchar = len >> 1;
114 break;
115
116 case MBSTRING_UNIV:
117 if(len & 3) {
118 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
119 ASN1_R_INVALID_UNIVERSALSTRING_LENGTH);
120 return -1;
121 }
122 nchar = len >> 2;
123 break;
124
125 case MBSTRING_UTF8:
126 nchar = 0;
127 /* This counts the characters and does utf8 syntax checking */
128 ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar);
129 if(ret < 0) {
130 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
131 ASN1_R_INVALID_UTF8STRING);
132 return -1;
133 }
134 break;
135
136 case MBSTRING_ASC:
137 nchar = len;
138 break;
139
140 default:
141 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_UNKNOWN_FORMAT);
142 return -1;
143 }
144
145 if((minsize > 0) && (nchar < minsize)) {
146 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT);
147 sprintf(strbuf, "%ld", minsize);
148 ERR_add_error_data(2, "minsize=", strbuf);
149 return -1;
150 }
151
152 if((maxsize > 0) && (nchar > maxsize)) {
153 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG);
154 sprintf(strbuf, "%ld", maxsize);
155 ERR_add_error_data(2, "maxsize=", strbuf);
156 return -1;
157 }
158
159 /* Now work out minimal type (if any) */
160 if(traverse_string(in, len, inform, type_str, &mask) < 0) {
161 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_ILLEGAL_CHARACTERS);
162 return -1;
163 }
164
165
166 /* Now work out output format and string type */
167 outform = MBSTRING_ASC;
168 if(mask & B_ASN1_PRINTABLESTRING) str_type = V_ASN1_PRINTABLESTRING;
169 else if(mask & B_ASN1_IA5STRING) str_type = V_ASN1_IA5STRING;
170 else if(mask & B_ASN1_T61STRING) str_type = V_ASN1_T61STRING;
171 else if(mask & B_ASN1_BMPSTRING) {
172 str_type = V_ASN1_BMPSTRING;
173 outform = MBSTRING_BMP;
174 } else if(mask & B_ASN1_UNIVERSALSTRING) {
175 str_type = V_ASN1_UNIVERSALSTRING;
176 outform = MBSTRING_UNIV;
177 } else {
178 str_type = V_ASN1_UTF8STRING;
179 outform = MBSTRING_UTF8;
180 }
181 if(!out) return str_type;
182 if(*out) {
183 dest = *out;
184 if(dest->data) {
185 dest->length = 0;
186 Free(dest->data);
187 dest->data = NULL;
188 }
189 dest->type = str_type;
190 } else {
191 dest = ASN1_STRING_type_new(str_type);
192 if(!dest) {
193 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
194 ERR_R_MALLOC_FAILURE);
195 return -1;
196 }
197 *out = dest;
198 }
199 /* If both the same type just copy across */
200 if(inform == outform) {
201 if(!ASN1_STRING_set(dest, in, len)) {
202 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
203 return -1;
204 }
205 return str_type;
206 }
207
208 /* Work out how much space the destination will need */
209 switch(outform) {
210 case MBSTRING_ASC:
211 outlen = nchar;
212 cpyfunc = cpy_asc;
213 break;
214
215 case MBSTRING_BMP:
216 outlen = nchar << 1;
217 cpyfunc = cpy_bmp;
218 break;
219
220 case MBSTRING_UNIV:
221 outlen = nchar << 2;
222 cpyfunc = cpy_univ;
223 break;
224
225 case MBSTRING_UTF8:
226 outlen = 0;
227 traverse_string(in, len, inform, out_utf8, &outlen);
228 cpyfunc = cpy_utf8;
229 break;
230 }
231 if(!(p = Malloc(outlen + 1))) {
232 ASN1_STRING_free(dest);
233 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
234 return -1;
235 }
236 dest->length = outlen;
237 dest->data = p;
238 p[outlen] = 0;
239 traverse_string(in, len, inform, cpyfunc, &p);
240 return str_type;
241}
242
243/* This function traverses a string and passes the value of each character
244 * to an optional function along with a void * argument.
245 */
246
247static int traverse_string(const unsigned char *p, int len, int inform,
248 int (*rfunc)(unsigned long value, void *in), void *arg)
249{
250 unsigned long value;
251 int ret;
252 while(len) {
253 if(inform == MBSTRING_ASC) {
254 value = *p++;
255 len--;
256 } else if(inform == MBSTRING_BMP) {
257 value = *p++ << 8;
258 value |= *p++;
259 len -= 2;
260 } else if(inform == MBSTRING_UNIV) {
261 value = *p++ << 24;
262 value |= *p++ << 16;
263 value |= *p++ << 8;
264 value |= *p++;
265 len -= 4;
266 } else {
267 ret = UTF8_getc(p, len, &value);
268 if(ret < 0) return -1;
269 len -= ret;
270 p += ret;
271 }
272 if(rfunc) {
273 ret = rfunc(value, arg);
274 if(ret <= 0) return ret;
275 }
276 }
277 return 1;
278}
279
280/* Various utility functions for traverse_string */
281
282/* Just count number of characters */
283
284static int in_utf8(unsigned long value, void *arg)
285{
286 int *nchar;
287 nchar = arg;
288 (*nchar)++;
289 return 1;
290}
291
292/* Determine size of output as a UTF8 String */
293
294static int out_utf8(unsigned long value, void *arg)
295{
296 long *outlen;
297 outlen = arg;
298 *outlen += UTF8_putc(NULL, -1, value);
299 return 1;
300}
301
302/* Determine the "type" of a string: check each character against a
303 * supplied "mask".
304 */
305
306static int type_str(unsigned long value, void *arg)
307{
308 unsigned long types;
309 types = *((unsigned long *)arg);
310 if((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
311 types &= ~B_ASN1_PRINTABLESTRING;
312 if((types & B_ASN1_IA5STRING) && (value > 127))
313 types &= ~B_ASN1_IA5STRING;
314 if((types & B_ASN1_T61STRING) && (value > 0xff))
315 types &= ~B_ASN1_T61STRING;
316 if((types & B_ASN1_BMPSTRING) && (value > 0xffff))
317 types &= ~B_ASN1_BMPSTRING;
318 if(!types) return -1;
319 *((unsigned long *)arg) = types;
320 return 1;
321}
322
323/* Copy one byte per character ASCII like strings */
324
325static int cpy_asc(unsigned long value, void *arg)
326{
327 unsigned char **p, *q;
328 p = arg;
329 q = *p;
330 *q = (unsigned char) value;
331 (*p)++;
332 return 1;
333}
334
335/* Copy two byte per character BMPStrings */
336
337static int cpy_bmp(unsigned long value, void *arg)
338{
339 unsigned char **p, *q;
340 p = arg;
341 q = *p;
342 *q++ = (unsigned char) ((value >> 8) & 0xff);
343 *q = (unsigned char) (value & 0xff);
344 *p += 2;
345 return 1;
346}
347
348/* Copy four byte per character UniversalStrings */
349
350static int cpy_univ(unsigned long value, void *arg)
351{
352 unsigned char **p, *q;
353 p = arg;
354 q = *p;
355 *q++ = (unsigned char) ((value >> 24) & 0xff);
356 *q++ = (unsigned char) ((value >> 16) & 0xff);
357 *q++ = (unsigned char) ((value >> 8) & 0xff);
358 *q = (unsigned char) (value & 0xff);
359 *p += 4;
360 return 1;
361}
362
363/* Copy to a UTF8String */
364
365static int cpy_utf8(unsigned long value, void *arg)
366{
367 unsigned char **p;
368 int ret;
369 p = arg;
370 /* We already know there is enough room so pass 0xff as the length */
371 ret = UTF8_putc(*p, 0xff, value);
372 *p += ret;
373 return 1;
374}
375
376/* Return 1 if the character is permitted in a PrintableString */
377static int is_printable(unsigned long value)
378{
379 int ch;
380 if(value > 0x7f) return 0;
381 ch = (int) value;
382 /* Note: we can't use 'isalnum' because certain accented
383 * characters may count as alphanumeric in some environments.
384 */
385 if((ch >= 'a') && (ch <= 'z')) return 1;
386 if((ch >= 'A') && (ch <= 'Z')) return 1;
387 if((ch >= '0') && (ch <= '9')) return 1;
388 if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1;
389 return 0;
390}
diff --git a/src/lib/libcrypto/asn1/a_null.c b/src/lib/libcrypto/asn1/a_null.c
new file mode 100644
index 0000000000..119fd784be
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_null.c
@@ -0,0 +1,119 @@
1/* a_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1.h>
62
63/* ASN1 functions for NULL type. For compatibility with other ASN1 code
64 * it returns a pointer to an "ASN1_NULL" structure. The new/free functions
65 * don't need to do any allocating because nothing is stored in a NULL.
66 */
67
68int i2d_ASN1_NULL(ASN1_NULL *a, unsigned char **pp)
69 {
70 if(!a) return 0;
71 if (pp) ASN1_put_object(pp,0,0,V_ASN1_NULL,V_ASN1_UNIVERSAL);
72 return 2;
73 }
74
75ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp, long length)
76 {
77 ASN1_NULL *ret = NULL;
78 unsigned char *p;
79 long len;
80 int inf,tag,xclass;
81 int i=0;
82
83 p= *pp;
84 inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
85 if (inf & 0x80)
86 {
87 i=ASN1_R_BAD_OBJECT_HEADER;
88 goto err;
89 }
90
91 if (tag != V_ASN1_NULL)
92 {
93 i=ASN1_R_EXPECTING_A_NULL;
94 goto err;
95 }
96
97 if (len != 0)
98 {
99 i=ASN1_R_NULL_IS_WRONG_LENGTH;
100 goto err;
101 }
102 ret=(ASN1_NULL *)1;
103 if (a != NULL) (*a)=ret;
104 *pp=p;
105 return(ret);
106err:
107 ASN1err(ASN1_F_D2I_ASN1_NULL,i);
108 return(ret);
109 }
110
111ASN1_NULL *ASN1_NULL_new(void)
112{
113 return (ASN1_NULL *)1;
114}
115
116void ASN1_NULL_free(ASN1_NULL *a)
117{
118 return;
119}
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index b94b418ee8..09d56fb669 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -222,8 +222,8 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
222 } 222 }
223 if ((ret->data == NULL) || (ret->length < len)) 223 if ((ret->data == NULL) || (ret->length < len))
224 { 224 {
225 if (ret->data != NULL) Free((char *)ret->data); 225 if (ret->data != NULL) Free(ret->data);
226 ret->data=(unsigned char *)Malloc((int)len); 226 ret->data=(unsigned char *)Malloc(len ? (int)len : 1);
227 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; 227 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
228 if (ret->data == NULL) 228 if (ret->data == NULL)
229 { i=ERR_R_MALLOC_FAILURE; goto err; } 229 { i=ERR_R_MALLOC_FAILURE; goto err; }
@@ -269,7 +269,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
269 if (a == NULL) return; 269 if (a == NULL) return;
270 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) 270 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS)
271 { 271 {
272#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause mempory leaks */ 272#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause memory leaks */
273 if (a->sn != NULL) Free((void *)a->sn); 273 if (a->sn != NULL) Free((void *)a->sn);
274 if (a->ln != NULL) Free((void *)a->ln); 274 if (a->ln != NULL) Free((void *)a->ln);
275#endif 275#endif
diff --git a/src/lib/libcrypto/asn1/a_octet.c b/src/lib/libcrypto/asn1/a_octet.c
index 7659a13bd3..2586f4327d 100644
--- a/src/lib/libcrypto/asn1/a_octet.c
+++ b/src/lib/libcrypto/asn1/a_octet.c
@@ -60,11 +60,23 @@
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)
70{ return M_ASN1_OCTET_STRING_dup(x); }
71
72int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b)
73{ return M_ASN1_OCTET_STRING_cmp(a, b); }
74
75int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, unsigned char *d, int len)
76{ return M_ASN1_OCTET_STRING_set(x, d, len); }
77
63int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp) 78int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp)
64 { 79{ return M_i2d_ASN1_OCTET_STRING(a, pp); }
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
66 V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL));
67 }
68 80
69ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, 81ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
70 unsigned char **pp, long length) 82 unsigned char **pp, long length)
diff --git a/src/lib/libcrypto/asn1/a_print.c b/src/lib/libcrypto/asn1/a_print.c
index cdec7a1561..b7bd2bd18a 100644
--- a/src/lib/libcrypto/asn1/a_print.c
+++ b/src/lib/libcrypto/asn1/a_print.c
@@ -60,6 +60,12 @@
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
63int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp) 69int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp)
64 { return(M_i2d_ASN1_IA5STRING(a,pp)); } 70 { return(M_i2d_ASN1_IA5STRING(a,pp)); }
65 71
@@ -67,15 +73,30 @@ ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, unsigned char **pp,
67 long l) 73 long l)
68 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); } 74 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); }
69 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
70ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp, 82ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp,
71 long l) 83 long l)
72 { return(M_d2i_ASN1_T61STRING(a,pp,l)); } 84 { return(M_d2i_ASN1_T61STRING(a,pp,l)); }
73 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
74ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, 92ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
75 unsigned char **pp, long l) 93 unsigned char **pp, long l)
76 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp, 94 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp,
77 l)); } 95 l)); }
78 96
97int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp)
98 { return(M_i2d_ASN1_PRINTABLESTRING(a,pp)); }
99
79int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp) 100int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp)
80 { return(M_i2d_ASN1_PRINTABLE(a,pp)); } 101 { return(M_i2d_ASN1_PRINTABLE(a,pp)); }
81 102
@@ -149,6 +170,11 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
149 return(1); 170 return(1);
150 } 171 }
151 172
173ASN1_STRING *DIRECTORYSTRING_new(void)
174{ return M_DIRECTORYSTRING_new();}
175
176void DIRECTORYSTRING_free(ASN1_STRING *x)
177{ M_DIRECTORYSTRING_free(x);}
152 178
153int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp) 179int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp)
154 { return(M_i2d_DIRECTORYSTRING(a,pp)); } 180 { return(M_i2d_DIRECTORYSTRING(a,pp)); }
@@ -157,6 +183,12 @@ ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
157 long l) 183 long l)
158 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); } 184 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); }
159 185
186ASN1_STRING *DISPLAYTEXT_new(void)
187{ return M_DISPLAYTEXT_new();}
188
189void DISPLAYTEXT_free(ASN1_STRING *x)
190{ M_DISPLAYTEXT_free(x);}
191
160int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp) 192int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp)
161 { return(M_i2d_DISPLAYTEXT(a,pp)); } 193 { return(M_i2d_DISPLAYTEXT(a,pp)); }
162 194
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 57595692e5..cfb4bca4f1 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -58,10 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/bn.h> 68#include <openssl/bn.h>
66#include <openssl/evp.h> 69#include <openssl/evp.h>
67#include <openssl/x509.h> 70#include <openssl/x509.h>
@@ -126,11 +129,11 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
126 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB); 129 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB);
127 goto err; 130 goto err;
128 } 131 }
129 if (signature->data != NULL) Free((char *)signature->data); 132 if (signature->data != NULL) Free(signature->data);
130 signature->data=buf_out; 133 signature->data=buf_out;
131 buf_out=NULL; 134 buf_out=NULL;
132 signature->length=outl; 135 signature->length=outl;
133 /* In the interests of compatability, I'll make sure that 136 /* In the interests of compatibility, I'll make sure that
134 * the bit string has a 'not-used bits' value of 0 137 * the bit string has a 'not-used bits' value of 0
135 */ 138 */
136 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 139 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
@@ -138,8 +141,8 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
138err: 141err:
139 memset(&ctx,0,sizeof(ctx)); 142 memset(&ctx,0,sizeof(ctx));
140 if (buf_in != NULL) 143 if (buf_in != NULL)
141 { memset((char *)buf_in,0,(unsigned int)inl); Free((char *)buf_in); } 144 { memset((char *)buf_in,0,(unsigned int)inl); Free(buf_in); }
142 if (buf_out != NULL) 145 if (buf_out != NULL)
143 { memset((char *)buf_out,0,outll); Free((char *)buf_out); } 146 { memset((char *)buf_out,0,outll); Free(buf_out); }
144 return(outl); 147 return(outl);
145 } 148 }
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
new file mode 100644
index 0000000000..ab8417ffab
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -0,0 +1,247 @@
1/* a_strnid.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 <ctype.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63#include <openssl/objects.h>
64
65
66static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
67static void st_free(ASN1_STRING_TABLE *tbl);
68static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b);
69static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b);
70
71
72/* This is the global mask for the mbstring functions: this is use to
73 * mask out certain types (such as BMPString and UTF8String) because
74 * certain software (e.g. Netscape) has problems with them.
75 */
76
77static unsigned long global_mask = 0xFFFFFFFFL;
78
79void ASN1_STRING_set_default_mask(unsigned long mask)
80{
81 global_mask = mask;
82}
83
84unsigned long ASN1_STRING_get_default_mask(void)
85{
86 return global_mask;
87}
88
89/* This function sets the default to various "flavours" of configuration.
90 * based on an ASCII string. Currently this is:
91 * MASK:XXXX : a numerical mask value.
92 * nobmp : Don't use BMPStrings (just Printable, T61).
93 * pkix : PKIX recommendation in RFC2459.
94 * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004).
95 * default: the default value, Printable, T61, BMP.
96 */
97
98int ASN1_STRING_set_default_mask_asc(char *p)
99{
100 unsigned long mask;
101 char *end;
102 if(!strncmp(p, "MASK:", 5)) {
103 if(!p[5]) return 0;
104 mask = strtoul(p + 5, &end, 0);
105 if(*end) return 0;
106 } else if(!strcmp(p, "nombstr"))
107 mask = ~(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING);
108 else if(!strcmp(p, "pkix"))
109 mask = ~B_ASN1_T61STRING;
110 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING;
111 else if(!strcmp(p, "default"))
112 mask = 0xFFFFFFFFL;
113 else return 0;
114 ASN1_STRING_set_default_mask(mask);
115 return 1;
116}
117
118/* The following function generates an ASN1_STRING based on limits in a table.
119 * Frequently the types and length of an ASN1_STRING are restricted by a
120 * corresponding OID. For example certificates and certificate requests.
121 */
122
123ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
124 int inlen, int inform, int nid)
125{
126 ASN1_STRING_TABLE *tbl;
127 ASN1_STRING *str = NULL;
128 unsigned long mask;
129 int ret;
130 if(!out) out = &str;
131 tbl = ASN1_STRING_TABLE_get(nid);
132 if(tbl) {
133 mask = tbl->mask;
134 if(!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask;
135 ret = ASN1_mbstring_ncopy(out, in, inlen, inform, tbl->mask,
136 tbl->minsize, tbl->maxsize);
137 } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask);
138 if(ret <= 0) return NULL;
139 return *out;
140}
141
142/* Now the tables and helper functions for the string table:
143 */
144
145/* size limits: this stuff is taken straight from RFC2459 */
146
147#define ub_name 32768
148#define ub_common_name 64
149#define ub_locality_name 128
150#define ub_state_name 128
151#define ub_organization_name 64
152#define ub_organization_unit_name 64
153#define ub_title 64
154#define ub_email_address 128
155
156/* This table must be kept in NID order */
157
158static ASN1_STRING_TABLE tbl_standard[] = {
159{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
160{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
161{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
162{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
163{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
164{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE, 0},
165{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING, STABLE_NO_MASK},
166{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
167{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
168{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
169{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
170{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
171{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
172{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
173{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}
174};
175
176static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b)
177{
178 return (*a)->nid - (*b)->nid;
179}
180
181static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b)
182{
183 return a->nid - b->nid;
184}
185
186ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
187{
188 int idx;
189 ASN1_STRING_TABLE *ttmp;
190 ASN1_STRING_TABLE fnd;
191 fnd.nid = nid;
192 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd,
193 (char *)tbl_standard,
194 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
195 sizeof(ASN1_STRING_TABLE), (int(*)())table_cmp);
196 if(ttmp) return ttmp;
197 if(!stable) return NULL;
198 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
199 if(idx < 0) return NULL;
200 return sk_ASN1_STRING_TABLE_value(stable, idx);
201}
202
203int ASN1_STRING_TABLE_add(int nid,
204 long minsize, long maxsize, unsigned long mask,
205 unsigned long flags)
206{
207 ASN1_STRING_TABLE *tmp;
208 char new_nid = 0;
209 flags &= ~STABLE_FLAGS_MALLOC;
210 if(!stable) stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
211 if(!stable) {
212 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE);
213 return 0;
214 }
215 if(!(tmp = ASN1_STRING_TABLE_get(nid))) {
216 tmp = Malloc(sizeof(ASN1_STRING_TABLE));
217 if(!tmp) {
218 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD,
219 ERR_R_MALLOC_FAILURE);
220 return 0;
221 }
222 tmp->flags = flags | STABLE_FLAGS_MALLOC;
223 tmp->nid = nid;
224 new_nid = 1;
225 } else tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags;
226 if(minsize != -1) tmp->minsize = minsize;
227 if(maxsize != -1) tmp->maxsize = maxsize;
228 tmp->mask = mask;
229 if(new_nid) sk_ASN1_STRING_TABLE_push(stable, tmp);
230 return 1;
231}
232
233void ASN1_STRING_TABLE_cleanup(void)
234{
235 STACK_OF(ASN1_STRING_TABLE) *tmp;
236 tmp = stable;
237 if(!tmp) return;
238 stable = NULL;
239 sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);
240}
241
242static void st_free(ASN1_STRING_TABLE *tbl)
243{
244 if(tbl->flags & STABLE_FLAGS_MALLOC) Free(tbl);
245}
246
247IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index c1690a5694..b193f1c71f 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -66,6 +66,12 @@
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68 68
69ASN1_TIME *ASN1_TIME_new(void)
70{ return M_ASN1_TIME_new(); }
71
72void ASN1_TIME_free(ASN1_TIME *x)
73{ M_ASN1_TIME_free(x); }
74
69int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp) 75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
70 { 76 {
71#ifdef CHARSET_EBCDIC 77#ifdef CHARSET_EBCDIC
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index 3f2ecee5c2..161ef81197 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -282,7 +282,7 @@ void ASN1_TYPE_free(ASN1_TYPE *a)
282 { 282 {
283 if (a == NULL) return; 283 if (a == NULL) return;
284 ASN1_TYPE_component_free(a); 284 ASN1_TYPE_component_free(a);
285 Free((char *)(char *)a); 285 Free(a);
286 } 286 }
287 287
288int ASN1_TYPE_get(ASN1_TYPE *a) 288int ASN1_TYPE_get(ASN1_TYPE *a)
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index 688199fdd2..07565974e3 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -66,6 +66,12 @@
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68 68
69ASN1_UTCTIME *ASN1_UTCTIME_new(void)
70{ return M_ASN1_UTCTIME_new(); }
71
72void ASN1_UTCTIME_free(ASN1_UTCTIME *x)
73{ M_ASN1_UTCTIME_free(x); }
74
69int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) 75int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
70 { 76 {
71#ifndef CHARSET_EBCDIC 77#ifndef CHARSET_EBCDIC
@@ -109,7 +115,7 @@ ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, unsigned char **pp,
109 return(ret); 115 return(ret);
110err: 116err:
111 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 117 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
112 ASN1_UTCTIME_free(ret); 118 M_ASN1_UTCTIME_free(ret);
113 return(NULL); 119 return(NULL);
114 } 120 }
115 121
@@ -192,7 +198,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
192#endif 198#endif
193 199
194 if (s == NULL) 200 if (s == NULL)
195 s=ASN1_UTCTIME_new(); 201 s=M_ASN1_UTCTIME_new();
196 if (s == NULL) 202 if (s == NULL)
197 return(NULL); 203 return(NULL);
198 204
diff --git a/src/lib/libcrypto/asn1/a_utf8.c b/src/lib/libcrypto/asn1/a_utf8.c
index 4a8a92e9e4..b5125af224 100644
--- a/src/lib/libcrypto/asn1/a_utf8.c
+++ b/src/lib/libcrypto/asn1/a_utf8.c
@@ -60,6 +60,12 @@
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
63int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp) 69int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
@@ -81,3 +87,152 @@ ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, unsigned char **pp,
81 return(ret); 87 return(ret);
82 } 88 }
83 89
90
91/* UTF8 utilities */
92
93/* This parses a UTF8 string one character at a time. It is passed a pointer
94 * to the string and the length of the string. It sets 'value' to the value of
95 * the current character. It returns the number of characters read or a
96 * negative error code:
97 * -1 = string too short
98 * -2 = illegal character
99 * -3 = subsequent characters not of the form 10xxxxxx
100 * -4 = character encoded incorrectly (not minimal length).
101 */
102
103int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
104{
105 const unsigned char *p;
106 unsigned long value;
107 int ret;
108 if(len <= 0) return 0;
109 p = str;
110
111 /* Check syntax and work out the encoded value (if correct) */
112 if((*p & 0x80) == 0) {
113 value = *p++ & 0x7f;
114 ret = 1;
115 } else if((*p & 0xe0) == 0xc0) {
116 if(len < 2) return -1;
117 if((p[1] & 0xc0) != 0x80) return -3;
118 value = (*p++ & 0x1f) << 6;
119 value |= *p++ & 0x3f;
120 if(value < 0x80) return -4;
121 ret = 2;
122 } else if((*p & 0xf0) == 0xe0) {
123 if(len < 3) return -1;
124 if( ((p[1] & 0xc0) != 0x80)
125 || ((p[2] & 0xc0) != 0x80) ) return -3;
126 value = (*p++ & 0xf) << 12;
127 value |= (*p++ & 0x3f) << 6;
128 value |= *p++ & 0x3f;
129 if(value < 0x800) return -4;
130 ret = 3;
131 } else if((*p & 0xf8) == 0xf0) {
132 if(len < 4) return -1;
133 if( ((p[1] & 0xc0) != 0x80)
134 || ((p[2] & 0xc0) != 0x80)
135 || ((p[3] & 0xc0) != 0x80) ) return -3;
136 value = (*p++ & 0x7) << 18;
137 value |= (*p++ & 0x3f) << 12;
138 value |= (*p++ & 0x3f) << 6;
139 value |= *p++ & 0x3f;
140 if(value < 0x10000) return -4;
141 ret = 4;
142 } else if((*p & 0xfc) == 0xf8) {
143 if(len < 5) return -1;
144 if( ((p[1] & 0xc0) != 0x80)
145 || ((p[2] & 0xc0) != 0x80)
146 || ((p[3] & 0xc0) != 0x80)
147 || ((p[4] & 0xc0) != 0x80) ) return -3;
148 value = (*p++ & 0x3) << 24;
149 value |= (*p++ & 0x3f) << 18;
150 value |= (*p++ & 0x3f) << 12;
151 value |= (*p++ & 0x3f) << 6;
152 value |= *p++ & 0x3f;
153 if(value < 0x200000) return -4;
154 ret = 5;
155 } else if((*p & 0xfe) == 0xfc) {
156 if(len < 6) return -1;
157 if( ((p[1] & 0xc0) != 0x80)
158 || ((p[2] & 0xc0) != 0x80)
159 || ((p[3] & 0xc0) != 0x80)
160 || ((p[4] & 0xc0) != 0x80)
161 || ((p[5] & 0xc0) != 0x80) ) return -3;
162 value = (*p++ & 0x1) << 30;
163 value |= (*p++ & 0x3f) << 24;
164 value |= (*p++ & 0x3f) << 18;
165 value |= (*p++ & 0x3f) << 12;
166 value |= (*p++ & 0x3f) << 6;
167 value |= *p++ & 0x3f;
168 if(value < 0x4000000) return -4;
169 ret = 6;
170 } else return -2;
171 *val = value;
172 return ret;
173}
174
175/* This takes a character 'value' and writes the UTF8 encoded value in
176 * 'str' where 'str' is a buffer containing 'len' characters. Returns
177 * the number of characters written or -1 if 'len' is too small. 'str' can
178 * be set to NULL in which case it just returns the number of characters.
179 * It will need at most 6 characters.
180 */
181
182int UTF8_putc(unsigned char *str, int len, unsigned long value)
183{
184 if(!str) len = 6; /* Maximum we will need */
185 else if(len <= 0) return -1;
186 if(value < 0x80) {
187 if(str) *str = (unsigned char)value;
188 return 1;
189 }
190 if(value < 0x800) {
191 if(len < 2) return -1;
192 if(str) {
193 *str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
194 *str = (unsigned char)((value & 0x3f) | 0x80);
195 }
196 return 2;
197 }
198 if(value < 0x10000) {
199 if(len < 3) return -1;
200 if(str) {
201 *str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
202 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
203 *str = (unsigned char)((value & 0x3f) | 0x80);
204 }
205 return 3;
206 }
207 if(value < 0x200000) {
208 if(len < 4) return -1;
209 if(str) {
210 *str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
211 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
212 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
213 *str = (unsigned char)((value & 0x3f) | 0x80);
214 }
215 return 4;
216 }
217 if(value < 0x4000000) {
218 if(len < 5) return -1;
219 if(str) {
220 *str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
221 *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
222 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
223 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
224 *str = (unsigned char)((value & 0x3f) | 0x80);
225 }
226 return 5;
227 }
228 if(len < 6) return -1;
229 if(str) {
230 *str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
231 *str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
232 *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
233 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
234 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
235 *str = (unsigned char)((value & 0x3f) | 0x80);
236 }
237 return 6;
238}
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index 6383d2c698..d4aede85c3 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -58,10 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/bn.h> 68#include <openssl/bn.h>
66#include <openssl/x509.h> 69#include <openssl/x509.h>
67#include <openssl/objects.h> 70#include <openssl/objects.h>
@@ -98,7 +101,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
98 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 101 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
99 102
100 memset(buf_in,0,(unsigned int)inl); 103 memset(buf_in,0,(unsigned int)inl);
101 Free((char *)buf_in); 104 Free(buf_in);
102 105
103 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 106 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
104 (unsigned int)signature->length,pkey) <= 0) 107 (unsigned int)signature->length,pkey) <= 0)
diff --git a/src/lib/libcrypto/asn1/a_vis.c b/src/lib/libcrypto/asn1/a_vis.c
index 2072be780d..5cfc080bec 100644
--- a/src/lib/libcrypto/asn1/a_vis.c
+++ b/src/lib/libcrypto/asn1/a_vis.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_VISIBLESTRING *ASN1_VISIBLESTRING_new(void)
64{ return M_ASN1_VISIBLESTRING_new(); }
65
66void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *x)
67{ M_ASN1_VISIBLESTRING_free(x); }
68
63int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **pp) 69int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index 5c2d8999bc..99bd64a11e 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -68,6 +68,10 @@ extern "C" {
68#include <openssl/stack.h> 68#include <openssl/stack.h>
69#include <openssl/safestack.h> 69#include <openssl/safestack.h>
70 70
71#ifdef VMS
72#include <openssl/vms_idhacks.h>
73#endif
74
71#define V_ASN1_UNIVERSAL 0x00 75#define V_ASN1_UNIVERSAL 0x00
72#define V_ASN1_APPLICATION 0x40 76#define V_ASN1_APPLICATION 0x40
73#define V_ASN1_CONTEXT_SPECIFIC 0x80 77#define V_ASN1_CONTEXT_SPECIFIC 0x80
@@ -77,7 +81,7 @@ extern "C" {
77#define V_ASN1_PRIMITIVE_TAG 0x1f 81#define V_ASN1_PRIMITIVE_TAG 0x1f
78#define V_ASN1_PRIMATIVE_TAG 0x1f 82#define V_ASN1_PRIMATIVE_TAG 0x1f
79 83
80#define V_ASN1_APP_CHOOSE -2 /* let the recipent choose */ 84#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
81 85
82#define V_ASN1_UNDEF -1 86#define V_ASN1_UNDEF -1
83#define V_ASN1_EOC 0 87#define V_ASN1_EOC 0
@@ -129,6 +133,13 @@ extern "C" {
129#define B_ASN1_UNKNOWN 0x1000 133#define B_ASN1_UNKNOWN 0x1000
130#define B_ASN1_UTF8STRING 0x2000 134#define B_ASN1_UTF8STRING 0x2000
131 135
136/* For use with ASN1_mbstring_copy() */
137#define MBSTRING_FLAG 0x1000
138#define MBSTRING_ASC (MBSTRING_FLAG|1)
139#define MBSTRING_BMP (MBSTRING_FLAG|2)
140#define MBSTRING_UNIV (MBSTRING_FLAG|3)
141#define MBSTRING_UTF8 (MBSTRING_FLAG|4)
142
132#define DECLARE_ASN1_SET_OF(type) \ 143#define DECLARE_ASN1_SET_OF(type) \
133int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \ 144int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
134 int (*func)(type *,unsigned char **), int ex_tag, \ 145 int (*func)(type *,unsigned char **), int ex_tag, \
@@ -165,7 +176,7 @@ typedef struct asn1_ctx_st
165 int tag; /* tag from last 'get object' */ 176 int tag; /* tag from last 'get object' */
166 int xclass; /* class from last 'get object' */ 177 int xclass; /* class from last 'get object' */
167 long slen; /* length of last 'get object' */ 178 long slen; /* length of last 'get object' */
168 unsigned char *max; /* largest value of p alowed */ 179 unsigned char *max; /* largest value of p allowed */
169 unsigned char *q;/* temporary variable */ 180 unsigned char *q;/* temporary variable */
170 unsigned char **pp;/* variable */ 181 unsigned char **pp;/* variable */
171 int line; /* used in error processing */ 182 int line; /* used in error processing */
@@ -200,7 +211,34 @@ typedef struct asn1_string_st
200 long flags; 211 long flags;
201 } ASN1_STRING; 212 } ASN1_STRING;
202 213
203#ifndef DEBUG 214#define STABLE_FLAGS_MALLOC 0x01
215#define STABLE_NO_MASK 0x02
216#define DIRSTRING_TYPE \
217 (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
218#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
219
220typedef struct asn1_string_table_st {
221 int nid;
222 long minsize;
223 long maxsize;
224 unsigned long mask;
225 unsigned long flags;
226} ASN1_STRING_TABLE;
227
228DECLARE_STACK_OF(ASN1_STRING_TABLE)
229
230/* size limits: this stuff is taken straight from RFC2459 */
231
232#define ub_name 32768
233#define ub_common_name 64
234#define ub_locality_name 128
235#define ub_state_name 128
236#define ub_organization_name 64
237#define ub_organization_unit_name 64
238#define ub_title 64
239#define ub_email_address 128
240
241#ifdef NO_ASN1_TYPEDEFS
204#define ASN1_INTEGER ASN1_STRING 242#define ASN1_INTEGER ASN1_STRING
205#define ASN1_ENUMERATED ASN1_STRING 243#define ASN1_ENUMERATED ASN1_STRING
206#define ASN1_BIT_STRING ASN1_STRING 244#define ASN1_BIT_STRING ASN1_STRING
@@ -234,6 +272,8 @@ typedef struct asn1_string_st ASN1_VISIBLESTRING;
234typedef struct asn1_string_st ASN1_UTF8STRING; 272typedef struct asn1_string_st ASN1_UTF8STRING;
235#endif 273#endif
236 274
275typedef int ASN1_NULL;
276
237typedef struct asn1_type_st 277typedef struct asn1_type_st
238 { 278 {
239 int type; 279 int type;
@@ -281,60 +321,58 @@ typedef struct asn1_header_st
281 ASN1_METHOD *meth; 321 ASN1_METHOD *meth;
282 } ASN1_HEADER; 322 } ASN1_HEADER;
283 323
284#define ASN1_STRING_length(x) ((x)->length) 324/* This is used to contain a list of bit names */
285#define ASN1_STRING_type(x) ((x)->type) 325typedef struct BIT_STRING_BITNAME_st {
286#define ASN1_STRING_data(x) ((x)->data) 326 int bitnum;
327 const char *lname;
328 const char *sname;
329} BIT_STRING_BITNAME;
330
331
332#define M_ASN1_STRING_length(x) ((x)->length)
333#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n))
334#define M_ASN1_STRING_type(x) ((x)->type)
335#define M_ASN1_STRING_data(x) ((x)->data)
287 336
288/* Macros for string operations */ 337/* Macros for string operations */
289#define ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ 338#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\
290 ASN1_STRING_type_new(V_ASN1_BIT_STRING) 339 ASN1_STRING_type_new(V_ASN1_BIT_STRING)
291#define ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 340#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
292#define ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ 341#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
293 ASN1_STRING_dup((ASN1_STRING *)a) 342 ASN1_STRING_dup((ASN1_STRING *)a)
294#define ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ 343#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
295 (ASN1_STRING *)a,(ASN1_STRING *)b) 344 (ASN1_STRING *)a,(ASN1_STRING *)b)
296#define ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 345#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
297/* i2d_ASN1_BIT_STRING() is a function */
298/* d2i_ASN1_BIT_STRING() is a function */
299 346
300#define ASN1_INTEGER_new() (ASN1_INTEGER *)\ 347#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\
301 ASN1_STRING_type_new(V_ASN1_INTEGER) 348 ASN1_STRING_type_new(V_ASN1_INTEGER)
302#define ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) 349#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a)
303#define ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) 350#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)
304#define ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ 351#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\
305 (ASN1_STRING *)a,(ASN1_STRING *)b) 352 (ASN1_STRING *)a,(ASN1_STRING *)b)
306/* ASN1_INTEGER_set() is a function, also see BN_to_ASN1_INTEGER() */
307/* ASN1_INTEGER_get() is a function, also see ASN1_INTEGER_to_BN() */
308/* i2d_ASN1_INTEGER() is a function */
309/* d2i_ASN1_INTEGER() is a function */
310 353
311#define ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ 354#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\
312 ASN1_STRING_type_new(V_ASN1_ENUMERATED) 355 ASN1_STRING_type_new(V_ASN1_ENUMERATED)
313#define ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) 356#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a)
314#define ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) 357#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a)
315#define ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ 358#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\
316 (ASN1_STRING *)a,(ASN1_STRING *)b) 359 (ASN1_STRING *)a,(ASN1_STRING *)b)
317/* ASN1_ENUMERATED_set() is a function, also see BN_to_ASN1_ENUMERATED() */
318/* ASN1_ENUMERATED_get() is a function, also see ASN1_ENUMERATED_to_BN() */
319/* i2d_ASN1_ENUMERATED() is a function */
320/* d2i_ASN1_ENUMERATED() is a function */
321 360
322#define ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ 361#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\
323 ASN1_STRING_type_new(V_ASN1_OCTET_STRING) 362 ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
324#define ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 363#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
325#define ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ 364#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
326 ASN1_STRING_dup((ASN1_STRING *)a) 365 ASN1_STRING_dup((ASN1_STRING *)a)
327#define ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ 366#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
328 (ASN1_STRING *)a,(ASN1_STRING *)b) 367 (ASN1_STRING *)a,(ASN1_STRING *)b)
329#define ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 368#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
330#define ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) 369#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b)
331#define M_i2d_ASN1_OCTET_STRING(a,pp) \ 370#define M_i2d_ASN1_OCTET_STRING(a,pp) \
332 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ 371 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
333 V_ASN1_OCTET_STRING) 372 V_ASN1_UNIVERSAL)
334/* d2i_ASN1_OCTET_STRING() is a function */
335 373
336#define ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) 374#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING)
337#define ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) 375#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)
338#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 376#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
339 pp,a->type,V_ASN1_UNIVERSAL) 377 pp,a->type,V_ASN1_UNIVERSAL)
340#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 378#define M_d2i_ASN1_PRINTABLE(a,pp,l) \
@@ -345,10 +383,11 @@ typedef struct asn1_header_st
345 B_ASN1_BIT_STRING| \ 383 B_ASN1_BIT_STRING| \
346 B_ASN1_UNIVERSALSTRING|\ 384 B_ASN1_UNIVERSALSTRING|\
347 B_ASN1_BMPSTRING|\ 385 B_ASN1_BMPSTRING|\
386 B_ASN1_UTF8STRING|\
348 B_ASN1_UNKNOWN) 387 B_ASN1_UNKNOWN)
349 388
350#define DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 389#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
351#define DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 390#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
352#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 391#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
353 pp,a->type,V_ASN1_UNIVERSAL) 392 pp,a->type,V_ASN1_UNIVERSAL)
354#define M_d2i_DIRECTORYSTRING(a,pp,l) \ 393#define M_d2i_DIRECTORYSTRING(a,pp,l) \
@@ -359,8 +398,8 @@ typedef struct asn1_header_st
359 B_ASN1_UNIVERSALSTRING|\ 398 B_ASN1_UNIVERSALSTRING|\
360 B_ASN1_UTF8STRING) 399 B_ASN1_UTF8STRING)
361 400
362#define DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 401#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
363#define DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) 402#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
364#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 403#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
365 pp,a->type,V_ASN1_UNIVERSAL) 404 pp,a->type,V_ASN1_UNIVERSAL)
366#define M_d2i_DISPLAYTEXT(a,pp,l) \ 405#define M_d2i_DISPLAYTEXT(a,pp,l) \
@@ -369,9 +408,9 @@ typedef struct asn1_header_st
369 B_ASN1_BMPSTRING|\ 408 B_ASN1_BMPSTRING|\
370 B_ASN1_UTF8STRING) 409 B_ASN1_UTF8STRING)
371 410
372#define ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ 411#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
373 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 412 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
374#define ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 413#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
375#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ 414#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
376 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ 415 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
377 V_ASN1_UNIVERSAL) 416 V_ASN1_UNIVERSAL)
@@ -379,9 +418,9 @@ typedef struct asn1_header_st
379 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ 418 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
380 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) 419 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)
381 420
382#define ASN1_T61STRING_new() (ASN1_T61STRING_STRING *)\ 421#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\
383 ASN1_STRING_type_new(V_ASN1_T61STRING) 422 ASN1_STRING_type_new(V_ASN1_T61STRING)
384#define ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 423#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
385#define M_i2d_ASN1_T61STRING(a,pp) \ 424#define M_i2d_ASN1_T61STRING(a,pp) \
386 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ 425 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
387 V_ASN1_UNIVERSAL) 426 V_ASN1_UNIVERSAL)
@@ -389,10 +428,10 @@ typedef struct asn1_header_st
389 (ASN1_T61STRING *)d2i_ASN1_type_bytes\ 428 (ASN1_T61STRING *)d2i_ASN1_type_bytes\
390 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) 429 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)
391 430
392#define ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ 431#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\
393 ASN1_STRING_type_new(V_ASN1_IA5STRING) 432 ASN1_STRING_type_new(V_ASN1_IA5STRING)
394#define ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 433#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
395#define ASN1_IA5STRING_dup(a) \ 434#define M_ASN1_IA5STRING_dup(a) \
396 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) 435 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a)
397#define M_i2d_ASN1_IA5STRING(a,pp) \ 436#define M_i2d_ASN1_IA5STRING(a,pp) \
398 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ 437 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
@@ -401,38 +440,25 @@ typedef struct asn1_header_st
401 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ 440 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
402 B_ASN1_IA5STRING) 441 B_ASN1_IA5STRING)
403 442
404#define ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ 443#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\
405 ASN1_STRING_type_new(V_ASN1_UTCTIME) 444 ASN1_STRING_type_new(V_ASN1_UTCTIME)
406#define ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 445#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
407#define ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) 446#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)
408/* i2d_ASN1_UTCTIME() is a function */ 447
409/* d2i_ASN1_UTCTIME() is a function */ 448#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
410/* ASN1_UTCTIME_set() is a function */
411/* ASN1_UTCTIME_check() is a function */
412
413#define ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
414 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) 449 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
415#define ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 450#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
416#define ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ 451#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
417 (ASN1_STRING *)a) 452 (ASN1_STRING *)a)
418/* i2d_ASN1_GENERALIZEDTIME() is a function */
419/* d2i_ASN1_GENERALIZEDTIME() is a function */
420/* ASN1_GENERALIZEDTIME_set() is a function */
421/* ASN1_GENERALIZEDTIME_check() is a function */
422 453
423#define ASN1_TIME_new() (ASN1_TIME *)\ 454#define M_ASN1_TIME_new() (ASN1_TIME *)\
424 ASN1_STRING_type_new(V_ASN1_UTCTIME) 455 ASN1_STRING_type_new(V_ASN1_UTCTIME)
425#define ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 456#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
426#define ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) 457#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a)
427 458
428/* i2d_ASN1_TIME() is a function */ 459#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
429/* d2i_ASN1_TIME() is a function */
430/* ASN1_TIME_set() is a function */
431/* ASN1_TIME_check() is a function */
432
433#define ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
434 ASN1_STRING_type_new(V_ASN1_GENERALSTRING) 460 ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
435#define ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 461#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
436#define M_i2d_ASN1_GENERALSTRING(a,pp) \ 462#define M_i2d_ASN1_GENERALSTRING(a,pp) \
437 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ 463 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
438 V_ASN1_UNIVERSAL) 464 V_ASN1_UNIVERSAL)
@@ -440,9 +466,9 @@ typedef struct asn1_header_st
440 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ 466 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
441 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) 467 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)
442 468
443#define ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ 469#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\
444 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) 470 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
445#define ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 471#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
446#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ 472#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
447 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ 473 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
448 V_ASN1_UNIVERSAL) 474 V_ASN1_UNIVERSAL)
@@ -450,9 +476,9 @@ typedef struct asn1_header_st
450 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ 476 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
451 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) 477 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)
452 478
453#define ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ 479#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\
454 ASN1_STRING_type_new(V_ASN1_BMPSTRING) 480 ASN1_STRING_type_new(V_ASN1_BMPSTRING)
455#define ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 481#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
456#define M_i2d_ASN1_BMPSTRING(a,pp) \ 482#define M_i2d_ASN1_BMPSTRING(a,pp) \
457 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ 483 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
458 V_ASN1_UNIVERSAL) 484 V_ASN1_UNIVERSAL)
@@ -460,9 +486,9 @@ typedef struct asn1_header_st
460 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ 486 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
461 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) 487 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)
462 488
463#define ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ 489#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\
464 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 490 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
465#define ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 491#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
466#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ 492#define M_i2d_ASN1_VISIBLESTRING(a,pp) \
467 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ 493 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
468 V_ASN1_UNIVERSAL) 494 V_ASN1_UNIVERSAL)
@@ -470,9 +496,9 @@ typedef struct asn1_header_st
470 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ 496 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
471 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) 497 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)
472 498
473#define ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ 499#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\
474 ASN1_STRING_type_new(V_ASN1_UTF8STRING) 500 ASN1_STRING_type_new(V_ASN1_UTF8STRING)
475#define ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 501#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
476#define M_i2d_ASN1_UTF8STRING(a,pp) \ 502#define M_i2d_ASN1_UTF8STRING(a,pp) \
477 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ 503 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
478 V_ASN1_UNIVERSAL) 504 V_ASN1_UNIVERSAL)
@@ -500,7 +526,7 @@ ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
500DECLARE_STACK_OF(ASN1_OBJECT) 526DECLARE_STACK_OF(ASN1_OBJECT)
501DECLARE_ASN1_SET_OF(ASN1_OBJECT) 527DECLARE_ASN1_SET_OF(ASN1_OBJECT)
502 528
503ASN1_STRING * ASN1_STRING_new(void ); 529ASN1_STRING * ASN1_STRING_new(void);
504void ASN1_STRING_free(ASN1_STRING *a); 530void ASN1_STRING_free(ASN1_STRING *a);
505ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); 531ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a);
506ASN1_STRING * ASN1_STRING_type_new(int type ); 532ASN1_STRING * ASN1_STRING_type_new(int type );
@@ -508,23 +534,44 @@ int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
508 /* Since this is used to store all sorts of things, via macros, for now, make 534 /* Since this is used to store all sorts of things, via macros, for now, make
509 its data void * */ 535 its data void * */
510int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); 536int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
537int ASN1_STRING_length(ASN1_STRING *x);
538void ASN1_STRING_length_set(ASN1_STRING *x, int n);
539int ASN1_STRING_type(ASN1_STRING *x);
540unsigned char * ASN1_STRING_data(ASN1_STRING *x);
511 541
542ASN1_BIT_STRING * ASN1_BIT_STRING_new(void);
543void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
512int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); 544int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
513ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp, 545ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
514 long length); 546 long length);
547int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
548 int length );
515int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 549int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
516int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 550int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
517 551
552#ifdef HEADER_BIO_H
553int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
554 BIT_STRING_BITNAME *tbl, int indent);
555#endif
556int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
557int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
558 BIT_STRING_BITNAME *tbl);
518 559
519int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); 560int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
520int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length); 561int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
521 562
563ASN1_INTEGER * ASN1_INTEGER_new(void);
564void ASN1_INTEGER_free(ASN1_INTEGER *a);
522int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); 565int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
523ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp, 566ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
524 long length); 567 long length);
525ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp, 568ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
526 long length); 569 long length);
570ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
571int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
527 572
573ASN1_ENUMERATED * ASN1_ENUMERATED_new(void);
574void ASN1_ENUMERATED_free(ASN1_ENUMERATED *a);
528int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp); 575int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp);
529ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp, 576ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
530 long length); 577 long length);
@@ -537,49 +584,88 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
537ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); 584ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
538int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str); 585int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str);
539 586
587ASN1_OCTET_STRING * ASN1_OCTET_STRING_new(void);
588void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);
540int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp); 589int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp);
541ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, 590ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
542 unsigned char **pp,long length); 591 unsigned char **pp,long length);
592ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
593int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
594int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, unsigned char *data, int len);
543 595
596ASN1_VISIBLESTRING * ASN1_VISIBLESTRING_new(void);
597void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *a);
544int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp); 598int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp);
545ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a, 599ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a,
546 unsigned char **pp,long length); 600 unsigned char **pp,long length);
547 601
602ASN1_UTF8STRING * ASN1_UTF8STRING_new(void);
603void ASN1_UTF8STRING_free(ASN1_UTF8STRING *a);
548int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp); 604int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp);
549ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, 605ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a,
550 unsigned char **pp,long length); 606 unsigned char **pp,long length);
551 607
608ASN1_NULL * ASN1_NULL_new(void);
609void ASN1_NULL_free(ASN1_NULL *a);
610int i2d_ASN1_NULL(ASN1_NULL *a,unsigned char **pp);
611ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp,long length);
612
613ASN1_BMPSTRING * ASN1_BMPSTRING_new(void);
614void ASN1_BMPSTRING_free(ASN1_BMPSTRING *a);
552int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp); 615int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp);
553ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp, 616ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp,
554 long length); 617 long length);
555 618
619
620int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
621int UTF8_putc(unsigned char *str, int len, unsigned long value);
622
556int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp); 623int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp);
557ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a, 624ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a,
558 unsigned char **pp, long l); 625 unsigned char **pp, long l);
626
627ASN1_PRINTABLESTRING * ASN1_PRINTABLESTRING_new(void);
628void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a);
559ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, 629ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
560 unsigned char **pp, long l); 630 unsigned char **pp, long l);
631int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp);
561 632
633ASN1_STRING * DIRECTORYSTRING_new(void);
634void DIRECTORYSTRING_free(ASN1_STRING *a);
562int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp); 635int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp);
563ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp, 636ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
564 long length); 637 long length);
565 638
639ASN1_STRING * DISPLAYTEXT_new(void);
640void DISPLAYTEXT_free(ASN1_STRING *a);
566int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp); 641int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp);
567ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length); 642ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length);
568 643
644ASN1_T61STRING * ASN1_T61STRING_new(void);
645void ASN1_T61STRING_free(ASN1_IA5STRING *a);
569ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, 646ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a,
570 unsigned char **pp, long l); 647 unsigned char **pp, long l);
648
649ASN1_IA5STRING * ASN1_IA5STRING_new(void);
650void ASN1_IA5STRING_free(ASN1_IA5STRING *a);
571int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp); 651int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp);
572ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, 652ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a,
573 unsigned char **pp, long l); 653 unsigned char **pp, long l);
574 654
655ASN1_UTCTIME * ASN1_UTCTIME_new(void);
656void ASN1_UTCTIME_free(ASN1_UTCTIME *a);
575int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp); 657int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp);
576ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp, 658ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp,
577 long length); 659 long length);
578 660
661ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_new(void);
662void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *a);
579int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp); 663int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp);
580ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp, 664ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp,
581 long length); 665 long length);
582 666
667ASN1_TIME * ASN1_TIME_new(void);
668void ASN1_TIME_free(ASN1_TIME *a);
583int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp); 669int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp);
584ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length); 670ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length);
585ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); 671ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
@@ -654,6 +740,7 @@ int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
654int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); 740int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
655int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent); 741int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent);
656#endif 742#endif
743const char *ASN1_tag2str(int tag);
657 744
658/* Used to load and write netscape format cert/key */ 745/* Used to load and write netscape format cert/key */
659int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); 746int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
@@ -687,6 +774,21 @@ unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
687void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)()); 774void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
688ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct); 775ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
689 776
777void ASN1_STRING_set_default_mask(unsigned long mask);
778int ASN1_STRING_set_default_mask_asc(char *p);
779unsigned long ASN1_STRING_get_default_mask(void);
780int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
781 int inform, unsigned long mask);
782int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
783 int inform, unsigned long mask,
784 long minsize, long maxsize);
785
786ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
787 const unsigned char *in, int inlen, int inform, int nid);
788ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
789int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
790void ASN1_STRING_TABLE_cleanup(void);
791
690/* BEGIN ERROR CODES */ 792/* BEGIN ERROR CODES */
691/* The following lines are auto generated by the script mkerr.pl. Any changes 793/* The following lines are auto generated by the script mkerr.pl. Any changes
692 * made after this point may be overwritten when the script is next run. 794 * made after this point may be overwritten when the script is next run.
@@ -699,6 +801,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
699#define ASN1_F_A2I_ASN1_ENUMERATED 236 801#define ASN1_F_A2I_ASN1_ENUMERATED 236
700#define ASN1_F_A2I_ASN1_INTEGER 101 802#define ASN1_F_A2I_ASN1_INTEGER 101
701#define ASN1_F_A2I_ASN1_STRING 102 803#define ASN1_F_A2I_ASN1_STRING 102
804#define ASN1_F_ACCESS_DESCRIPTION_NEW 291
702#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103 805#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103
703#define ASN1_F_ASN1_D2I_BIO 104 806#define ASN1_F_ASN1_D2I_BIO 104
704#define ASN1_F_ASN1_D2I_FP 105 807#define ASN1_F_ASN1_D2I_FP 105
@@ -712,6 +815,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
712#define ASN1_F_ASN1_I2D_FP 110 815#define ASN1_F_ASN1_I2D_FP 110
713#define ASN1_F_ASN1_INTEGER_SET 111 816#define ASN1_F_ASN1_INTEGER_SET 111
714#define ASN1_F_ASN1_INTEGER_TO_BN 112 817#define ASN1_F_ASN1_INTEGER_TO_BN 112
818#define ASN1_F_ASN1_MBSTRING_COPY 282
715#define ASN1_F_ASN1_OBJECT_NEW 113 819#define ASN1_F_ASN1_OBJECT_NEW 113
716#define ASN1_F_ASN1_PACK_STRING 245 820#define ASN1_F_ASN1_PACK_STRING 245
717#define ASN1_F_ASN1_PBE_SET 253 821#define ASN1_F_ASN1_PBE_SET 253
@@ -719,6 +823,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
719#define ASN1_F_ASN1_SEQ_UNPACK 247 823#define ASN1_F_ASN1_SEQ_UNPACK 247
720#define ASN1_F_ASN1_SIGN 114 824#define ASN1_F_ASN1_SIGN 114
721#define ASN1_F_ASN1_STRING_NEW 115 825#define ASN1_F_ASN1_STRING_NEW 115
826#define ASN1_F_ASN1_STRING_TABLE_ADD 283
722#define ASN1_F_ASN1_STRING_TYPE_NEW 116 827#define ASN1_F_ASN1_STRING_TYPE_NEW 116
723#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117 828#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117
724#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118 829#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118
@@ -730,6 +835,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
730#define ASN1_F_BASIC_CONSTRAINTS_NEW 226 835#define ASN1_F_BASIC_CONSTRAINTS_NEW 226
731#define ASN1_F_BN_TO_ASN1_ENUMERATED 234 836#define ASN1_F_BN_TO_ASN1_ENUMERATED 234
732#define ASN1_F_BN_TO_ASN1_INTEGER 122 837#define ASN1_F_BN_TO_ASN1_INTEGER 122
838#define ASN1_F_D2I_ACCESS_DESCRIPTION 284
733#define ASN1_F_D2I_ASN1_BIT_STRING 123 839#define ASN1_F_D2I_ASN1_BIT_STRING 123
734#define ASN1_F_D2I_ASN1_BMPSTRING 124 840#define ASN1_F_D2I_ASN1_BMPSTRING 124
735#define ASN1_F_D2I_ASN1_BOOLEAN 125 841#define ASN1_F_D2I_ASN1_BOOLEAN 125
@@ -738,6 +844,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
738#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223 844#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223
739#define ASN1_F_D2I_ASN1_HEADER 127 845#define ASN1_F_D2I_ASN1_HEADER 127
740#define ASN1_F_D2I_ASN1_INTEGER 128 846#define ASN1_F_D2I_ASN1_INTEGER 128
847#define ASN1_F_D2I_ASN1_NULL 292
741#define ASN1_F_D2I_ASN1_OBJECT 129 848#define ASN1_F_D2I_ASN1_OBJECT 129
742#define ASN1_F_D2I_ASN1_OCTET_STRING 130 849#define ASN1_F_D2I_ASN1_OCTET_STRING 130
743#define ASN1_F_D2I_ASN1_PRINT_TYPE 131 850#define ASN1_F_D2I_ASN1_PRINT_TYPE 131
@@ -765,6 +872,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
765#define ASN1_F_D2I_NETSCAPE_SPKAC 143 872#define ASN1_F_D2I_NETSCAPE_SPKAC 143
766#define ASN1_F_D2I_NETSCAPE_SPKI 144 873#define ASN1_F_D2I_NETSCAPE_SPKI 144
767#define ASN1_F_D2I_NOTICEREF 268 874#define ASN1_F_D2I_NOTICEREF 268
875#define ASN1_F_D2I_OTHERNAME 287
768#define ASN1_F_D2I_PBE2PARAM 262 876#define ASN1_F_D2I_PBE2PARAM 262
769#define ASN1_F_D2I_PBEPARAM 249 877#define ASN1_F_D2I_PBEPARAM 249
770#define ASN1_F_D2I_PBKDF2PARAM 263 878#define ASN1_F_D2I_PBKDF2PARAM 263
@@ -796,6 +904,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
796#define ASN1_F_D2I_X509 159 904#define ASN1_F_D2I_X509 159
797#define ASN1_F_D2I_X509_ALGOR 160 905#define ASN1_F_D2I_X509_ALGOR 160
798#define ASN1_F_D2I_X509_ATTRIBUTE 161 906#define ASN1_F_D2I_X509_ATTRIBUTE 161
907#define ASN1_F_D2I_X509_CERT_AUX 285
799#define ASN1_F_D2I_X509_CINF 162 908#define ASN1_F_D2I_X509_CINF 162
800#define ASN1_F_D2I_X509_CRL 163 909#define ASN1_F_D2I_X509_CRL 163
801#define ASN1_F_D2I_X509_CRL_INFO 164 910#define ASN1_F_D2I_X509_CRL_INFO 164
@@ -819,12 +928,14 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
819#define ASN1_F_I2D_DSAPARAMS 178 928#define ASN1_F_I2D_DSAPARAMS 178
820#define ASN1_F_I2D_DSAPRIVATEKEY 179 929#define ASN1_F_I2D_DSAPRIVATEKEY 179
821#define ASN1_F_I2D_DSAPUBLICKEY 180 930#define ASN1_F_I2D_DSAPUBLICKEY 180
931#define ASN1_F_I2D_DSA_PUBKEY 290
822#define ASN1_F_I2D_NETSCAPE_RSA 181 932#define ASN1_F_I2D_NETSCAPE_RSA 181
823#define ASN1_F_I2D_PKCS7 182 933#define ASN1_F_I2D_PKCS7 182
824#define ASN1_F_I2D_PRIVATEKEY 183 934#define ASN1_F_I2D_PRIVATEKEY 183
825#define ASN1_F_I2D_PUBLICKEY 184 935#define ASN1_F_I2D_PUBLICKEY 184
826#define ASN1_F_I2D_RSAPRIVATEKEY 185 936#define ASN1_F_I2D_RSAPRIVATEKEY 185
827#define ASN1_F_I2D_RSAPUBLICKEY 186 937#define ASN1_F_I2D_RSAPUBLICKEY 186
938#define ASN1_F_I2D_RSA_PUBKEY 289
828#define ASN1_F_I2D_X509_ATTRIBUTE 187 939#define ASN1_F_I2D_X509_ATTRIBUTE 187
829#define ASN1_F_I2T_ASN1_OBJECT 188 940#define ASN1_F_I2T_ASN1_OBJECT 188
830#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229 941#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229
@@ -832,6 +943,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
832#define ASN1_F_NETSCAPE_SPKAC_NEW 190 943#define ASN1_F_NETSCAPE_SPKAC_NEW 190
833#define ASN1_F_NETSCAPE_SPKI_NEW 191 944#define ASN1_F_NETSCAPE_SPKI_NEW 191
834#define ASN1_F_NOTICEREF_NEW 272 945#define ASN1_F_NOTICEREF_NEW 272
946#define ASN1_F_OTHERNAME_NEW 288
835#define ASN1_F_PBE2PARAM_NEW 264 947#define ASN1_F_PBE2PARAM_NEW 264
836#define ASN1_F_PBEPARAM_NEW 251 948#define ASN1_F_PBEPARAM_NEW 251
837#define ASN1_F_PBKDF2PARAM_NEW 265 949#define ASN1_F_PBKDF2PARAM_NEW 265
@@ -859,6 +971,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
859#define ASN1_F_USERNOTICE_NEW 275 971#define ASN1_F_USERNOTICE_NEW 275
860#define ASN1_F_X509_ALGOR_NEW 202 972#define ASN1_F_X509_ALGOR_NEW 202
861#define ASN1_F_X509_ATTRIBUTE_NEW 203 973#define ASN1_F_X509_ATTRIBUTE_NEW 203
974#define ASN1_F_X509_CERT_AUX_NEW 286
862#define ASN1_F_X509_CINF_NEW 204 975#define ASN1_F_X509_CINF_NEW 204
863#define ASN1_F_X509_CRL_INFO_NEW 205 976#define ASN1_F_X509_CRL_INFO_NEW 205
864#define ASN1_F_X509_CRL_NEW 206 977#define ASN1_F_X509_CRL_NEW 206
@@ -889,6 +1002,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
889#define ASN1_R_BN_LIB 107 1002#define ASN1_R_BN_LIB 107
890#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108 1003#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108
891#define ASN1_R_BUFFER_TOO_SMALL 109 1004#define ASN1_R_BUFFER_TOO_SMALL 109
1005#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 166
892#define ASN1_R_DATA_IS_WRONG 110 1006#define ASN1_R_DATA_IS_WRONG 110
893#define ASN1_R_DECODE_ERROR 155 1007#define ASN1_R_DECODE_ERROR 155
894#define ASN1_R_DECODING_ERROR 111 1008#define ASN1_R_DECODING_ERROR 111
@@ -902,24 +1016,31 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
902#define ASN1_R_EXPECTING_A_BIT_STRING 116 1016#define ASN1_R_EXPECTING_A_BIT_STRING 116
903#define ASN1_R_EXPECTING_A_BOOLEAN 117 1017#define ASN1_R_EXPECTING_A_BOOLEAN 117
904#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151 1018#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151
1019#define ASN1_R_EXPECTING_A_NULL 164
905#define ASN1_R_EXPECTING_A_TIME 152 1020#define ASN1_R_EXPECTING_A_TIME 152
906#define ASN1_R_EXPECTING_A_UTCTIME 118 1021#define ASN1_R_EXPECTING_A_UTCTIME 118
907#define ASN1_R_FIRST_NUM_TOO_LARGE 119 1022#define ASN1_R_FIRST_NUM_TOO_LARGE 119
908#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153 1023#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153
909#define ASN1_R_HEADER_TOO_LONG 120 1024#define ASN1_R_HEADER_TOO_LONG 120
1025#define ASN1_R_ILLEGAL_CHARACTERS 158
1026#define ASN1_R_INVALID_BMPSTRING_LENGTH 159
910#define ASN1_R_INVALID_DIGIT 121 1027#define ASN1_R_INVALID_DIGIT 121
911#define ASN1_R_INVALID_SEPARATOR 122 1028#define ASN1_R_INVALID_SEPARATOR 122
912#define ASN1_R_INVALID_TIME_FORMAT 123 1029#define ASN1_R_INVALID_TIME_FORMAT 123
1030#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 160
1031#define ASN1_R_INVALID_UTF8STRING 161
913#define ASN1_R_IV_TOO_LARGE 124 1032#define ASN1_R_IV_TOO_LARGE 124
914#define ASN1_R_LENGTH_ERROR 125 1033#define ASN1_R_LENGTH_ERROR 125
915#define ASN1_R_MISSING_SECOND_NUMBER 126 1034#define ASN1_R_MISSING_SECOND_NUMBER 126
916#define ASN1_R_NON_HEX_CHARACTERS 127 1035#define ASN1_R_NON_HEX_CHARACTERS 127
917#define ASN1_R_NOT_ENOUGH_DATA 128 1036#define ASN1_R_NOT_ENOUGH_DATA 128
1037#define ASN1_R_NULL_IS_WRONG_LENGTH 165
918#define ASN1_R_ODD_NUMBER_OF_CHARS 129 1038#define ASN1_R_ODD_NUMBER_OF_CHARS 129
919#define ASN1_R_PARSING 130 1039#define ASN1_R_PARSING 130
920#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131 1040#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131
921#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132 1041#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132
922#define ASN1_R_SHORT_LINE 133 1042#define ASN1_R_SHORT_LINE 133
1043#define ASN1_R_STRING_TOO_LONG 163
923#define ASN1_R_STRING_TOO_SHORT 134 1044#define ASN1_R_STRING_TOO_SHORT 134
924#define ASN1_R_TAG_VALUE_TOO_HIGH 135 1045#define ASN1_R_TAG_VALUE_TOO_HIGH 135
925#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136 1046#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136
@@ -927,6 +1048,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
927#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138 1048#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138
928#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139 1049#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139
929#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140 1050#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140
1051#define ASN1_R_UNKNOWN_FORMAT 162
930#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141 1052#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141
931#define ASN1_R_UNKNOWN_OBJECT_TYPE 142 1053#define ASN1_R_UNKNOWN_OBJECT_TYPE 142
932#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143 1054#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143
diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c
index 16755a0b05..b183814242 100644
--- a/src/lib/libcrypto/asn1/asn1_err.c
+++ b/src/lib/libcrypto/asn1/asn1_err.c
@@ -69,19 +69,21 @@ static ERR_STRING_DATA ASN1_str_functs[]=
69{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"}, 69{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"},
70{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"}, 70{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"},
71{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"}, 71{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"},
72{ERR_PACK(0,ASN1_F_ACCESS_DESCRIPTION_NEW,0), "ACCESS_DESCRIPTION_new"},
72{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"}, 73{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"},
73{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"}, 74{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"},
74{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"}, 75{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"},
75{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"}, 76{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"},
76{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"}, 77{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"},
77{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"}, 78{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"},
78{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_NEW"}, 79{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_new"},
79{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"}, 80{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"},
80{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"}, 81{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"},
81{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"}, 82{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"},
82{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"}, 83{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"},
83{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"}, 84{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"},
84{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"}, 85{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"},
86{ERR_PACK(0,ASN1_F_ASN1_MBSTRING_COPY,0), "ASN1_mbstring_copy"},
85{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"}, 87{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"},
86{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"}, 88{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"},
87{ERR_PACK(0,ASN1_F_ASN1_PBE_SET,0), "ASN1_PBE_SET"}, 89{ERR_PACK(0,ASN1_F_ASN1_PBE_SET,0), "ASN1_PBE_SET"},
@@ -89,17 +91,19 @@ static ERR_STRING_DATA ASN1_str_functs[]=
89{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"}, 91{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"},
90{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"}, 92{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"},
91{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"}, 93{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"},
94{ERR_PACK(0,ASN1_F_ASN1_STRING_TABLE_ADD,0), "ASN1_STRING_TABLE_add"},
92{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"}, 95{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"},
93{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"}, 96{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"},
94{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"}, 97{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"},
95{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"}, 98{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"},
96{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"}, 99{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"},
97{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_NEW"}, 100{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_new"},
98{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"}, 101{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"},
99{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"}, 102{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"},
100{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"}, 103{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"},
101{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"}, 104{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"},
102{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"}, 105{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"},
106{ERR_PACK(0,ASN1_F_D2I_ACCESS_DESCRIPTION,0), "d2i_ACCESS_DESCRIPTION"},
103{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"}, 107{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"},
104{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"}, 108{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"},
105{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"}, 109{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"},
@@ -108,6 +112,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
108{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"}, 112{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"},
109{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"}, 113{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"},
110{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"}, 114{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"},
115{ERR_PACK(0,ASN1_F_D2I_ASN1_NULL,0), "d2i_ASN1_NULL"},
111{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"},
112{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"}, 117{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"},
113{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"}, 118{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"},
@@ -135,6 +140,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
135{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"}, 140{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"},
136{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"}, 141{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"},
137{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"}, 142{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"},
143{ERR_PACK(0,ASN1_F_D2I_OTHERNAME,0), "d2i_OTHERNAME"},
138{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"}, 144{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"},
139{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"}, 145{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"},
140{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"}, 146{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"},
@@ -166,6 +172,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
166{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"}, 172{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"},
167{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"}, 173{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"},
168{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"}, 174{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"},
175{ERR_PACK(0,ASN1_F_D2I_X509_CERT_AUX,0), "d2i_X509_CERT_AUX"},
169{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"}, 176{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"},
170{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"}, 177{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"},
171{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"}, 178{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"},
@@ -189,12 +196,14 @@ static ERR_STRING_DATA ASN1_str_functs[]=
189{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"}, 196{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"},
190{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"}, 197{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"},
191{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"}, 198{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"},
199{ERR_PACK(0,ASN1_F_I2D_DSA_PUBKEY,0), "i2d_DSA_PUBKEY"},
192{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"}, 200{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"},
193{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"}, 201{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"},
194{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"}, 202{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"},
195{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"}, 203{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"},
196{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"}, 204{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"},
197{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"}, 205{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"},
206{ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0), "i2d_RSA_PUBKEY"},
198{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"}, 207{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"},
199{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"}, 208{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"},
200{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"}, 209{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"},
@@ -202,6 +211,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
202{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"}, 211{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"},
203{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"}, 212{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"},
204{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"}, 213{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"},
214{ERR_PACK(0,ASN1_F_OTHERNAME_NEW,0), "OTHERNAME_new"},
205{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"}, 215{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"},
206{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"}, 216{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"},
207{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"}, 217{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"},
@@ -229,6 +239,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
229{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"}, 239{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"},
230{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"}, 240{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"},
231{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"}, 241{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"},
242{ERR_PACK(0,ASN1_F_X509_CERT_AUX_NEW,0), "X509_CERT_AUX_new"},
232{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"}, 243{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"},
233{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"}, 244{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"},
234{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"}, 245{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"},
@@ -262,6 +273,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
262{ASN1_R_BN_LIB ,"bn lib"}, 273{ASN1_R_BN_LIB ,"bn lib"},
263{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"}, 274{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"},
264{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"}, 275{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"},
276{ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER ,"cipher has no object identifier"},
265{ASN1_R_DATA_IS_WRONG ,"data is wrong"}, 277{ASN1_R_DATA_IS_WRONG ,"data is wrong"},
266{ASN1_R_DECODE_ERROR ,"decode error"}, 278{ASN1_R_DECODE_ERROR ,"decode error"},
267{ASN1_R_DECODING_ERROR ,"decoding error"}, 279{ASN1_R_DECODING_ERROR ,"decoding error"},
@@ -275,24 +287,31 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
275{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"}, 287{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"},
276{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"}, 288{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"},
277{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"}, 289{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"},
290{ASN1_R_EXPECTING_A_NULL ,"expecting a null"},
278{ASN1_R_EXPECTING_A_TIME ,"expecting a time"}, 291{ASN1_R_EXPECTING_A_TIME ,"expecting a time"},
279{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"}, 292{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"},
280{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"}, 293{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"},
281{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"}, 294{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"},
282{ASN1_R_HEADER_TOO_LONG ,"header too long"}, 295{ASN1_R_HEADER_TOO_LONG ,"header too long"},
296{ASN1_R_ILLEGAL_CHARACTERS ,"illegal characters"},
297{ASN1_R_INVALID_BMPSTRING_LENGTH ,"invalid bmpstring length"},
283{ASN1_R_INVALID_DIGIT ,"invalid digit"}, 298{ASN1_R_INVALID_DIGIT ,"invalid digit"},
284{ASN1_R_INVALID_SEPARATOR ,"invalid separator"}, 299{ASN1_R_INVALID_SEPARATOR ,"invalid separator"},
285{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"}, 300{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"},
301{ASN1_R_INVALID_UNIVERSALSTRING_LENGTH ,"invalid universalstring length"},
302{ASN1_R_INVALID_UTF8STRING ,"invalid utf8string"},
286{ASN1_R_IV_TOO_LARGE ,"iv too large"}, 303{ASN1_R_IV_TOO_LARGE ,"iv too large"},
287{ASN1_R_LENGTH_ERROR ,"length error"}, 304{ASN1_R_LENGTH_ERROR ,"length error"},
288{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"}, 305{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"},
289{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"}, 306{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"},
290{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"}, 307{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"},
308{ASN1_R_NULL_IS_WRONG_LENGTH ,"null is wrong length"},
291{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"}, 309{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"},
292{ASN1_R_PARSING ,"parsing"}, 310{ASN1_R_PARSING ,"parsing"},
293{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"}, 311{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"},
294{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"}, 312{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"},
295{ASN1_R_SHORT_LINE ,"short line"}, 313{ASN1_R_SHORT_LINE ,"short line"},
314{ASN1_R_STRING_TOO_LONG ,"string too long"},
296{ASN1_R_STRING_TOO_SHORT ,"string too short"}, 315{ASN1_R_STRING_TOO_SHORT ,"string too short"},
297{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"}, 316{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"},
298{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"}, 317{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
@@ -300,6 +319,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
300{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"}, 319{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"},
301{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"}, 320{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"},
302{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"}, 321{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"},
322{ASN1_R_UNKNOWN_FORMAT ,"unknown format"},
303{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"}, 323{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"},
304{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"}, 324{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"},
305{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"}, 325{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"},
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 95e54ed626..be8daa8688 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -176,7 +176,7 @@ static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max)
176 } 176 }
177 177
178/* class 0 is constructed 178/* class 0 is constructed
179 * constructed == 2 for indefinitle length constructed */ 179 * constructed == 2 for indefinite length constructed */
180void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, 180void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
181 int xclass) 181 int xclass)
182 { 182 {
@@ -349,7 +349,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
349 if (data != NULL) 349 if (data != NULL)
350 { 350 {
351 memcpy(str->data,data,len); 351 memcpy(str->data,data,len);
352 /* an alowance for strings :-) */ 352 /* an allowance for strings :-) */
353 str->data[len]='\0'; 353 str->data[len]='\0';
354 } 354 }
355 return(1); 355 return(1);
@@ -381,8 +381,8 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
381void ASN1_STRING_free(ASN1_STRING *a) 381void ASN1_STRING_free(ASN1_STRING *a)
382 { 382 {
383 if (a == NULL) return; 383 if (a == NULL) return;
384 if (a->data != NULL) Free((char *)a->data); 384 if (a->data != NULL) Free(a->data);
385 Free((char *)a); 385 Free(a);
386 } 386 }
387 387
388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b) 388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b)
@@ -411,3 +411,14 @@ void asn1_add_error(unsigned char *address, int offset)
411 ERR_add_error_data(4,"address=",buf1," offset=",buf2); 411 ERR_add_error_data(4,"address=",buf1," offset=",buf2);
412 } 412 }
413 413
414int ASN1_STRING_length(ASN1_STRING *x)
415{ return M_ASN1_STRING_length(x); }
416
417void ASN1_STRING_length_set(ASN1_STRING *x, int len)
418{ M_ASN1_STRING_length_set(x, len); return; }
419
420int ASN1_STRING_type(ASN1_STRING *x)
421{ return M_ASN1_STRING_type(x); }
422
423unsigned char * ASN1_STRING_data(ASN1_STRING *x)
424{ return M_ASN1_STRING_data(x); }
diff --git a/src/lib/libcrypto/asn1/asn1_mac.h b/src/lib/libcrypto/asn1/asn1_mac.h
index 93f9c5193c..4f2a82d340 100644
--- a/src/lib/libcrypto/asn1/asn1_mac.h
+++ b/src/lib/libcrypto/asn1/asn1_mac.h
@@ -106,6 +106,20 @@ err:\
106#define M_ASN1_D2I_start_sequence() \ 106#define M_ASN1_D2I_start_sequence() \
107 if (!asn1_GetSequence(&c,&length)) \ 107 if (!asn1_GetSequence(&c,&length)) \
108 { c.line=__LINE__; goto err; } 108 { c.line=__LINE__; goto err; }
109/* Begin reading ASN1 without a surrounding sequence */
110#define M_ASN1_D2I_begin() \
111 c.slen = length;
112
113/* End reading ASN1 with no check on length */
114#define M_ASN1_D2I_Finish_nolen(a, func, e) \
115 *pp=c.p; \
116 if (a != NULL) (*a)=ret; \
117 return(ret); \
118err:\
119 ASN1_MAC_H_err((e),c.error,c.line); \
120 asn1_add_error(*pp,(int)(c.q- *pp)); \
121 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
122 return(NULL)
109 123
110#define M_ASN1_D2I_end_sequence() \ 124#define M_ASN1_D2I_end_sequence() \
111 (((c.inf&1) == 0)?(c.slen <= 0): \ 125 (((c.inf&1) == 0)?(c.slen <= 0): \
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index 86886606ef..d1e9816bad 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -93,55 +93,8 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
93 sprintf(str,"cont [ %d ]",tag); 93 sprintf(str,"cont [ %d ]",tag);
94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) 94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
95 sprintf(str,"appl [ %d ]",tag); 95 sprintf(str,"appl [ %d ]",tag);
96 else if ((tag == V_ASN1_EOC) /* && (xclass == V_ASN1_UNIVERSAL) */) 96 else p = ASN1_tag2str(tag);
97 p="EOC";
98 else if (tag == V_ASN1_BOOLEAN)
99 p="BOOLEAN";
100 else if (tag == V_ASN1_INTEGER)
101 p="INTEGER";
102 else if (tag == V_ASN1_ENUMERATED)
103 p="ENUMERATED";
104 else if (tag == V_ASN1_BIT_STRING)
105 p="BIT STRING";
106 else if (tag == V_ASN1_OCTET_STRING)
107 p="OCTET STRING";
108 else if (tag == V_ASN1_NULL)
109 p="NULL";
110 else if (tag == V_ASN1_OBJECT)
111 p="OBJECT";
112 else if (tag == V_ASN1_SEQUENCE)
113 p="SEQUENCE";
114 else if (tag == V_ASN1_SET)
115 p="SET";
116 else if (tag == V_ASN1_PRINTABLESTRING)
117 p="PRINTABLESTRING";
118 else if (tag == V_ASN1_T61STRING)
119 p="T61STRING";
120 else if (tag == V_ASN1_IA5STRING)
121 p="IA5STRING";
122 else if (tag == V_ASN1_UTCTIME)
123 p="UTCTIME";
124 97
125 /* extras */
126 else if (tag == V_ASN1_NUMERICSTRING)
127 p="NUMERICSTRING";
128 else if (tag == V_ASN1_VIDEOTEXSTRING)
129 p="VIDEOTEXSTRING";
130 else if (tag == V_ASN1_GENERALIZEDTIME)
131 p="GENERALIZEDTIME";
132 else if (tag == V_ASN1_GRAPHICSTRING)
133 p="GRAPHICSTRING";
134 else if (tag == V_ASN1_VISIBLESTRING)
135 p="VISIBLESTRING";
136 else if (tag == V_ASN1_GENERALSTRING)
137 p="GENERALSTRING";
138 else if (tag == V_ASN1_UNIVERSALSTRING)
139 p="UNIVERSALSTRING";
140 else if (tag == V_ASN1_BMPSTRING)
141 p="BMPSTRING";
142 else
143 p2="(unknown)";
144
145 if (p2 != NULL) 98 if (p2 != NULL)
146 { 99 {
147 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err; 100 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err;
@@ -320,7 +273,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
320 os->length) <= 0) 273 os->length) <= 0)
321 goto end; 274 goto end;
322 } 275 }
323 ASN1_OCTET_STRING_free(os); 276 M_ASN1_OCTET_STRING_free(os);
324 os=NULL; 277 os=NULL;
325 } 278 }
326 } 279 }
@@ -354,7 +307,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
354 if (BIO_write(bp,"BAD INTEGER",11) <= 0) 307 if (BIO_write(bp,"BAD INTEGER",11) <= 0)
355 goto end; 308 goto end;
356 } 309 }
357 ASN1_INTEGER_free(bs); 310 M_ASN1_INTEGER_free(bs);
358 } 311 }
359 else if (tag == V_ASN1_ENUMERATED) 312 else if (tag == V_ASN1_ENUMERATED)
360 { 313 {
@@ -386,7 +339,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
386 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0) 339 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0)
387 goto end; 340 goto end;
388 } 341 }
389 ASN1_ENUMERATED_free(bs); 342 M_ASN1_ENUMERATED_free(bs);
390 } 343 }
391 344
392 if (!nl) 345 if (!nl)
@@ -405,7 +358,28 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
405 ret=1; 358 ret=1;
406end: 359end:
407 if (o != NULL) ASN1_OBJECT_free(o); 360 if (o != NULL) ASN1_OBJECT_free(o);
408 if (os != NULL) ASN1_OCTET_STRING_free(os); 361 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
409 *pp=p; 362 *pp=p;
410 return(ret); 363 return(ret);
411 } 364 }
365
366const char *ASN1_tag2str(int tag)
367{
368 const static char *tag2str[] = {
369 "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */
370 "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */
371 "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */
372 "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */
373 "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */
374 "VIDEOTEXSTRING", "IA5STRING", "UTCTIME","GENERALIZEDTIME", /* 21-24 */
375 "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */
376 "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */
377 };
378
379 if((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
380 tag &= ~0x100;
381
382 if(tag < 0 || tag > 30) return "(unknown)";
383 return tag2str[tag];
384}
385
diff --git a/src/lib/libcrypto/asn1/d2i_dhp.c b/src/lib/libcrypto/asn1/d2i_dhp.c
index a077211a4c..635ae829db 100644
--- a/src/lib/libcrypto/asn1/d2i_dhp.c
+++ b/src/lib/libcrypto/asn1/d2i_dhp.c
@@ -86,7 +86,7 @@ DH *d2i_DHparams(DH **a, unsigned char **pp, long length)
86 ret->length=(int)v; 86 ret->length=(int)v;
87 } 87 }
88 88
89 ASN1_BIT_STRING_free(bs); 89 M_ASN1_BIT_STRING_free(bs);
90 90
91 M_ASN1_D2I_Finish_2(a); 91 M_ASN1_D2I_Finish_2(a);
92 92
@@ -95,7 +95,7 @@ err_bn:
95err: 95err:
96 ASN1err(ASN1_F_D2I_DHPARAMS,i); 96 ASN1err(ASN1_F_D2I_DHPARAMS,i);
97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret); 97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret);
98 if (bs != NULL) ASN1_BIT_STRING_free(bs); 98 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
99 return(NULL); 99 return(NULL);
100 } 100 }
101#endif 101#endif
diff --git a/src/lib/libcrypto/asn1/d2i_dsap.c b/src/lib/libcrypto/asn1/d2i_dsap.c
index cdd7136f51..6d1c297133 100644
--- a/src/lib/libcrypto/asn1/d2i_dsap.c
+++ b/src/lib/libcrypto/asn1/d2i_dsap.c
@@ -83,7 +83,7 @@ DSA *d2i_DSAparams(DSA **a, unsigned char **pp, long length)
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; 84 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
85 85
86 ASN1_BIT_STRING_free(bs); 86 M_ASN1_BIT_STRING_free(bs);
87 87
88 M_ASN1_D2I_Finish_2(a); 88 M_ASN1_D2I_Finish_2(a);
89 89
@@ -92,7 +92,7 @@ err_bn:
92err: 92err:
93 ASN1err(ASN1_F_D2I_DSAPARAMS,i); 93 ASN1err(ASN1_F_D2I_DSAPARAMS,i);
94 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 94 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
95 if (bs != NULL) ASN1_BIT_STRING_free(bs); 95 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
96 return(NULL); 96 return(NULL);
97 } 97 }
98#endif 98#endif
diff --git a/src/lib/libcrypto/asn1/d2i_pr.c b/src/lib/libcrypto/asn1/d2i_pr.c
index f3d1aa6240..c92b8325d8 100644
--- a/src/lib/libcrypto/asn1/d2i_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_pr.c
@@ -112,3 +112,26 @@ err:
112 return(NULL); 112 return(NULL);
113 } 113 }
114 114
115/* This works like d2i_PrivateKey() except it automatically works out the type */
116
117EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
118 long length)
119{
120 STACK_OF(ASN1_TYPE) *inkey;
121 unsigned char *p;
122 int keytype;
123 p = *pp;
124 /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE):
125 * by analyzing it we can determine the passed structure: this
126 * assumes the input is surrounded by an ASN1 SEQUENCE.
127 */
128 inkey = d2i_ASN1_SET_OF_ASN1_TYPE(NULL, &p, length, d2i_ASN1_TYPE,
129 ASN1_TYPE_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
130 /* Since we only need to discern "traditional format" RSA and DSA
131 * keys we can just count the elements.
132 */
133 if(sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA;
134 else keytype = EVP_PKEY_RSA;
135 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
136 return d2i_PrivateKey(keytype, a, pp, length);
137}
diff --git a/src/lib/libcrypto/asn1/d2i_r_pr.c b/src/lib/libcrypto/asn1/d2i_r_pr.c
index 18f11b6f5e..6c8a45f821 100644
--- a/src/lib/libcrypto/asn1/d2i_r_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_r_pr.c
@@ -107,7 +107,7 @@ RSA *d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length)
107 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL) 107 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL)
108 goto err_bn; 108 goto err_bn;
109 109
110 ASN1_INTEGER_free(bs); 110 M_ASN1_INTEGER_free(bs);
111 111
112 M_ASN1_D2I_Finish_2(a); 112 M_ASN1_D2I_Finish_2(a);
113err_bn: 113err_bn:
@@ -115,7 +115,14 @@ err_bn:
115err: 115err:
116 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i); 116 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i);
117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); 117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
118 if (bs != NULL) ASN1_INTEGER_free(bs); 118 if (bs != NULL) M_ASN1_INTEGER_free(bs);
119
119 return(NULL); 120 return(NULL);
120 } 121 }
122#else /* !NO_RSA */
123
124# if PEDANTIC
125static void *dummy=&dummy;
126# endif
127
121#endif 128#endif
diff --git a/src/lib/libcrypto/asn1/d2i_r_pu.c b/src/lib/libcrypto/asn1/d2i_r_pu.c
index c4ae58b594..d1289f160e 100644
--- a/src/lib/libcrypto/asn1/d2i_r_pu.c
+++ b/src/lib/libcrypto/asn1/d2i_r_pu.c
@@ -81,7 +81,7 @@ RSA *d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length)
81 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 81 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
82 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; 82 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
83 83
84 ASN1_INTEGER_free(bs); 84 M_ASN1_INTEGER_free(bs);
85 bs=NULL; 85 bs=NULL;
86 86
87 M_ASN1_D2I_Finish_2(a); 87 M_ASN1_D2I_Finish_2(a);
@@ -91,7 +91,13 @@ err_bn:
91err: 91err:
92 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i); 92 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i);
93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); 93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
94 if (bs != NULL) ASN1_INTEGER_free(bs); 94 if (bs != NULL) M_ASN1_INTEGER_free(bs);
95 return(NULL); 95 return(NULL);
96 } 96 }
97#else /* !NO_RSA */
98
99# if PEDANTIC
100static void *dummy=&dummy;
101# endif
102
97#endif 103#endif
diff --git a/src/lib/libcrypto/asn1/d2i_s_pr.c b/src/lib/libcrypto/asn1/d2i_s_pr.c
index 050e1cc5fb..dec2a2ebd3 100644
--- a/src/lib/libcrypto/asn1/d2i_s_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_s_pr.c
@@ -91,7 +91,7 @@ DSA *d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length)
91 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key)) 91 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key))
92 == NULL) goto err_bn; 92 == NULL) goto err_bn;
93 93
94 ASN1_INTEGER_free(bs); 94 M_ASN1_INTEGER_free(bs);
95 95
96 M_ASN1_D2I_Finish_2(a); 96 M_ASN1_D2I_Finish_2(a);
97err_bn: 97err_bn:
@@ -99,7 +99,7 @@ err_bn:
99err: 99err:
100 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i); 100 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i);
101 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 101 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
102 if (bs != NULL) ASN1_INTEGER_free(bs); 102 if (bs != NULL) M_ASN1_INTEGER_free(bs);
103 return(NULL); 103 return(NULL);
104 } 104 }
105#endif 105#endif
diff --git a/src/lib/libcrypto/asn1/d2i_s_pu.c b/src/lib/libcrypto/asn1/d2i_s_pu.c
index 94ea1c313b..e0adaa0393 100644
--- a/src/lib/libcrypto/asn1/d2i_s_pu.c
+++ b/src/lib/libcrypto/asn1/d2i_s_pu.c
@@ -107,7 +107,7 @@ DSA *d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length)
107 ret->write_params=1; 107 ret->write_params=1;
108 } 108 }
109 109
110 ASN1_INTEGER_free(bs); 110 M_ASN1_INTEGER_free(bs);
111 bs=NULL; 111 bs=NULL;
112 M_ASN1_D2I_Finish_2(a); 112 M_ASN1_D2I_Finish_2(a);
113err_bn: 113err_bn:
@@ -115,7 +115,7 @@ err_bn:
115err: 115err:
116 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i); 116 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i);
117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
118 if (bs != NULL) ASN1_INTEGER_free(bs); 118 if (bs != NULL) M_ASN1_INTEGER_free(bs);
119 return(NULL); 119 return(NULL);
120 } 120 }
121#endif 121#endif
diff --git a/src/lib/libcrypto/asn1/evp_asn1.c b/src/lib/libcrypto/asn1/evp_asn1.c
index 41ced49c19..3506005a71 100644
--- a/src/lib/libcrypto/asn1/evp_asn1.c
+++ b/src/lib/libcrypto/asn1/evp_asn1.c
@@ -65,8 +65,8 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
65 { 65 {
66 ASN1_STRING *os; 66 ASN1_STRING *os;
67 67
68 if ((os=ASN1_OCTET_STRING_new()) == NULL) return(0); 68 if ((os=M_ASN1_OCTET_STRING_new()) == NULL) return(0);
69 if (!ASN1_OCTET_STRING_set(os,data,len)) return(0); 69 if (!M_ASN1_OCTET_STRING_set(os,data,len)) return(0);
70 ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os); 70 ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os);
71 return(1); 71 return(1);
72 } 72 }
@@ -83,8 +83,8 @@ int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
83 ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG); 83 ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG);
84 return(-1); 84 return(-1);
85 } 85 }
86 p=ASN1_STRING_data(a->value.octet_string); 86 p=M_ASN1_STRING_data(a->value.octet_string);
87 ret=ASN1_STRING_length(a->value.octet_string); 87 ret=M_ASN1_STRING_length(a->value.octet_string);
88 if (ret < max_len) 88 if (ret < max_len)
89 num=ret; 89 num=ret;
90 else 90 else
@@ -117,8 +117,8 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
117 /* Grow the 'string' */ 117 /* Grow the 'string' */
118 ASN1_STRING_set(osp,NULL,size); 118 ASN1_STRING_set(osp,NULL,size);
119 119
120 ASN1_STRING_length(osp)=size; 120 M_ASN1_STRING_length_set(osp, size);
121 p=ASN1_STRING_data(osp); 121 p=M_ASN1_STRING_data(osp);
122 122
123 ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); 123 ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
124 i2d_ASN1_INTEGER(&in,&p); 124 i2d_ASN1_INTEGER(&in,&p);
@@ -145,8 +145,8 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
145 { 145 {
146 goto err; 146 goto err;
147 } 147 }
148 p=ASN1_STRING_data(a->value.sequence); 148 p=M_ASN1_STRING_data(a->value.sequence);
149 length=ASN1_STRING_length(a->value.sequence); 149 length=M_ASN1_STRING_length(a->value.sequence);
150 150
151 c.pp= &p; 151 c.pp= &p;
152 c.p=p; 152 c.p=p;
@@ -165,21 +165,21 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
165 if (num != NULL) 165 if (num != NULL)
166 *num=ASN1_INTEGER_get(ai); 166 *num=ASN1_INTEGER_get(ai);
167 167
168 ret=ASN1_STRING_length(os); 168 ret=M_ASN1_STRING_length(os);
169 if (max_len > ret) 169 if (max_len > ret)
170 n=ret; 170 n=ret;
171 else 171 else
172 n=max_len; 172 n=max_len;
173 173
174 if (data != NULL) 174 if (data != NULL)
175 memcpy(data,ASN1_STRING_data(os),n); 175 memcpy(data,M_ASN1_STRING_data(os),n);
176 if (0) 176 if (0)
177 { 177 {
178err: 178err:
179 ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG); 179 ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG);
180 } 180 }
181 if (os != NULL) ASN1_OCTET_STRING_free(os); 181 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
182 if (ai != NULL) ASN1_INTEGER_free(ai); 182 if (ai != NULL) M_ASN1_INTEGER_free(ai);
183 return(ret); 183 return(ret);
184 } 184 }
185 185
diff --git a/src/lib/libcrypto/asn1/f_enum.c b/src/lib/libcrypto/asn1/f_enum.c
index 3bcceecdb8..3d0b1107cb 100644
--- a/src/lib/libcrypto/asn1/f_enum.c
+++ b/src/lib/libcrypto/asn1/f_enum.c
@@ -161,7 +161,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
161 if (sp == NULL) 161 if (sp == NULL)
162 { 162 {
163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE); 163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE);
164 if (s != NULL) Free((char *)s); 164 if (s != NULL) Free(s);
165 goto err; 165 goto err;
166 } 166 }
167 s=sp; 167 s=sp;
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 55560dd814..cd57331c3f 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -168,7 +168,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
168 if (sp == NULL) 168 if (sp == NULL)
169 { 169 {
170 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 170 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
171 if (s != NULL) Free((char *)s); 171 if (s != NULL) Free(s);
172 goto err; 172 goto err;
173 } 173 }
174 s=sp; 174 s=sp;
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c
index 5d0cf5a46d..088313689a 100644
--- a/src/lib/libcrypto/asn1/f_string.c
+++ b/src/lib/libcrypto/asn1/f_string.c
@@ -166,7 +166,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
166 if (sp == NULL) 166 if (sp == NULL)
167 { 167 {
168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE); 168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
169 if (s != NULL) Free((char *)s); 169 if (s != NULL) Free(s);
170 goto err; 170 goto err;
171 } 171 }
172 s=sp; 172 s=sp;
diff --git a/src/lib/libcrypto/asn1/i2d_dhp.c b/src/lib/libcrypto/asn1/i2d_dhp.c
index fdda4ec41b..61eeb646f9 100644
--- a/src/lib/libcrypto/asn1/i2d_dhp.c
+++ b/src/lib/libcrypto/asn1/i2d_dhp.c
@@ -118,7 +118,7 @@ int i2d_DHparams(DH *a, unsigned char **pp)
118 bs.length=BN_bn2bin(num[i],bs.data); 118 bs.length=BN_bn2bin(num[i],bs.data);
119 i2d_ASN1_INTEGER(&bs,&p); 119 i2d_ASN1_INTEGER(&bs,&p);
120 } 120 }
121 Free((char *)bs.data); 121 Free(bs.data);
122 ret=t; 122 ret=t;
123err: 123err:
124 if (num[2] != NULL) BN_free(num[2]); 124 if (num[2] != NULL) BN_free(num[2]);
diff --git a/src/lib/libcrypto/asn1/i2d_dsap.c b/src/lib/libcrypto/asn1/i2d_dsap.c
index f36f0da4e2..4021123ba3 100644
--- a/src/lib/libcrypto/asn1/i2d_dsap.c
+++ b/src/lib/libcrypto/asn1/i2d_dsap.c
@@ -107,7 +107,7 @@ int i2d_DSAparams(DSA *a, unsigned char **pp)
107 bs.length=BN_bn2bin(num[i],bs.data); 107 bs.length=BN_bn2bin(num[i],bs.data);
108 i2d_ASN1_INTEGER(&bs,&p); 108 i2d_ASN1_INTEGER(&bs,&p);
109 } 109 }
110 Free((char *)bs.data); 110 Free(bs.data);
111 ret=t; 111 ret=t;
112err: 112err:
113 *pp=p; 113 *pp=p;
diff --git a/src/lib/libcrypto/asn1/i2d_r_pr.c b/src/lib/libcrypto/asn1/i2d_r_pr.c
index 27e6844a7f..1250fa4b2d 100644
--- a/src/lib/libcrypto/asn1/i2d_r_pr.c
+++ b/src/lib/libcrypto/asn1/i2d_r_pr.c
@@ -119,9 +119,15 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
119 bs.length=BN_bn2bin(num[i],bs.data); 119 bs.length=BN_bn2bin(num[i],bs.data);
120 i2d_ASN1_INTEGER(&bs,&p); 120 i2d_ASN1_INTEGER(&bs,&p);
121 } 121 }
122 Free((char *)bs.data); 122 Free(bs.data);
123 *pp=p; 123 *pp=p;
124 return(t); 124 return(t);
125 } 125 }
126#else /* !NO_RSA */
127
128# if PEDANTIC
129static void *dummy=&dummy;
130# endif
131
126#endif 132#endif
127 133
diff --git a/src/lib/libcrypto/asn1/i2d_r_pu.c b/src/lib/libcrypto/asn1/i2d_r_pu.c
index 6d01bfa8b5..582b92ee4c 100644
--- a/src/lib/libcrypto/asn1/i2d_r_pu.c
+++ b/src/lib/libcrypto/asn1/i2d_r_pu.c
@@ -105,8 +105,14 @@ int i2d_RSAPublicKey(RSA *a, unsigned char **pp)
105 bs.length=BN_bn2bin(num[i],bs.data); 105 bs.length=BN_bn2bin(num[i],bs.data);
106 i2d_ASN1_INTEGER(&bs,&p); 106 i2d_ASN1_INTEGER(&bs,&p);
107 } 107 }
108 Free((char *)bs.data); 108 Free(bs.data);
109 *pp=p; 109 *pp=p;
110 return(t); 110 return(t);
111 } 111 }
112#else /* !NO_RSA */
113
114# if PEDANTIC
115static void *dummy=&dummy;
116# endif
117
112#endif 118#endif
diff --git a/src/lib/libcrypto/asn1/i2d_s_pr.c b/src/lib/libcrypto/asn1/i2d_s_pr.c
index 5d3dcdf197..e399ceaeb9 100644
--- a/src/lib/libcrypto/asn1/i2d_s_pr.c
+++ b/src/lib/libcrypto/asn1/i2d_s_pr.c
@@ -116,7 +116,7 @@ int i2d_DSAPrivateKey(DSA *a, unsigned char **pp)
116 bs.length=BN_bn2bin(num[i],bs.data); 116 bs.length=BN_bn2bin(num[i],bs.data);
117 i2d_ASN1_INTEGER(&bs,&p); 117 i2d_ASN1_INTEGER(&bs,&p);
118 } 118 }
119 Free((char *)bs.data); 119 Free(bs.data);
120 *pp=p; 120 *pp=p;
121 return(t); 121 return(t);
122 } 122 }
diff --git a/src/lib/libcrypto/asn1/i2d_s_pu.c b/src/lib/libcrypto/asn1/i2d_s_pu.c
index 18f790f746..ca7f251b71 100644
--- a/src/lib/libcrypto/asn1/i2d_s_pu.c
+++ b/src/lib/libcrypto/asn1/i2d_s_pu.c
@@ -121,7 +121,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp)
121 bs.length=BN_bn2bin(num[i],bs.data); 121 bs.length=BN_bn2bin(num[i],bs.data);
122 i2d_ASN1_INTEGER(&bs,&p); 122 i2d_ASN1_INTEGER(&bs,&p);
123 } 123 }
124 Free((char *)bs.data); 124 Free(bs.data);
125 *pp=p; 125 *pp=p;
126 if(all) return(t); 126 if(all) return(t);
127 else return(tot); 127 else return(tot);
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index cdc0d8b7c4..d804986b73 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -139,7 +139,7 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
139 } 139 }
140 140
141 if (pkey->private_key->data != NULL) 141 if (pkey->private_key->data != NULL)
142 Free((char *)pkey->private_key->data); 142 Free(pkey->private_key->data);
143 if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL) 143 if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL)
144 { 144 {
145 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); 145 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
@@ -205,10 +205,10 @@ RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)())
205 (char *)os->data,os->length) != 0)) 205 (char *)os->data,os->length) != 0))
206 { 206 {
207 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING); 207 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING);
208 ASN1_BIT_STRING_free(os); 208 M_ASN1_BIT_STRING_free(os);
209 goto err; 209 goto err;
210 } 210 }
211 ASN1_BIT_STRING_free(os); 211 M_ASN1_BIT_STRING_free(os);
212 c.q=c.p; 212 c.q=c.p;
213 if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err; 213 if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err;
214 c.slen-=(c.p-c.q); 214 c.slen-=(c.p-c.q);
@@ -279,7 +279,7 @@ RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length,
279 *pp=c.p; 279 *pp=c.p;
280err: 280err:
281 if (pkey != NULL) NETSCAPE_PKEY_free(pkey); 281 if (pkey != NULL) NETSCAPE_PKEY_free(pkey);
282 if (os != NULL) ASN1_BIT_STRING_free(os); 282 if (os != NULL) M_ASN1_BIT_STRING_free(os);
283 if (alg != NULL) X509_ALGOR_free(alg); 283 if (alg != NULL) X509_ALGOR_free(alg);
284 return(ret); 284 return(ret);
285 } 285 }
@@ -321,9 +321,9 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
321 ASN1_CTX c; 321 ASN1_CTX c;
322 322
323 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY); 323 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY);
324 M_ASN1_New(ret->version,ASN1_INTEGER_new); 324 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
325 M_ASN1_New(ret->algor,X509_ALGOR_new); 325 M_ASN1_New(ret->algor,X509_ALGOR_new);
326 M_ASN1_New(ret->private_key,ASN1_OCTET_STRING_new); 326 M_ASN1_New(ret->private_key,M_ASN1_OCTET_STRING_new);
327 return(ret); 327 return(ret);
328 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW); 328 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW);
329 } 329 }
@@ -331,11 +331,18 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
331static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a) 331static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a)
332 { 332 {
333 if (a == NULL) return; 333 if (a == NULL) return;
334 ASN1_INTEGER_free(a->version); 334 M_ASN1_INTEGER_free(a->version);
335 X509_ALGOR_free(a->algor); 335 X509_ALGOR_free(a->algor);
336 ASN1_OCTET_STRING_free(a->private_key); 336 M_ASN1_OCTET_STRING_free(a->private_key);
337 Free((char *)a); 337 Free(a);
338 } 338 }
339 339
340#endif /* NO_RC4 */ 340#endif /* NO_RC4 */
341
342#else /* !NO_RSA */
343
344# if PEDANTIC
345static void *dummy=&dummy;
346# endif
347
341#endif 348#endif
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c
index b831836e7b..64e90237cc 100644
--- a/src/lib/libcrypto/asn1/p5_pbe.c
+++ b/src/lib/libcrypto/asn1/p5_pbe.c
@@ -82,8 +82,8 @@ PBEPARAM *PBEPARAM_new(void)
82 PBEPARAM *ret=NULL; 82 PBEPARAM *ret=NULL;
83 ASN1_CTX c; 83 ASN1_CTX c;
84 M_ASN1_New_Malloc(ret, PBEPARAM); 84 M_ASN1_New_Malloc(ret, PBEPARAM);
85 M_ASN1_New(ret->iter,ASN1_INTEGER_new); 85 M_ASN1_New(ret->iter,M_ASN1_INTEGER_new);
86 M_ASN1_New(ret->salt,ASN1_OCTET_STRING_new); 86 M_ASN1_New(ret->salt,M_ASN1_OCTET_STRING_new);
87 return (ret); 87 return (ret);
88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW); 88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW);
89} 89}
@@ -101,9 +101,9 @@ PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length)
101void PBEPARAM_free (PBEPARAM *a) 101void PBEPARAM_free (PBEPARAM *a)
102{ 102{
103 if(a==NULL) return; 103 if(a==NULL) return;
104 ASN1_OCTET_STRING_free(a->salt); 104 M_ASN1_OCTET_STRING_free(a->salt);
105 ASN1_INTEGER_free (a->iter); 105 M_ASN1_INTEGER_free (a->iter);
106 Free ((char *)a); 106 Free (a);
107} 107}
108 108
109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */ 109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
@@ -129,7 +129,8 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt,
129 } 129 }
130 pbe->salt->length = saltlen; 130 pbe->salt->length = saltlen;
131 if (salt) memcpy (pbe->salt->data, salt, saltlen); 131 if (salt) memcpy (pbe->salt->data, salt, saltlen);
132 else RAND_bytes (pbe->salt->data, saltlen); 132 else if (RAND_bytes (pbe->salt->data, saltlen) <= 0)
133 return NULL;
133 134
134 if (!(astype = ASN1_TYPE_new())) { 135 if (!(astype = ASN1_TYPE_new())) {
135 ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE); 136 ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 09f4bf6112..4ce06a94ab 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -104,7 +104,7 @@ void PBE2PARAM_free (PBE2PARAM *a)
104 if(a==NULL) return; 104 if(a==NULL) return;
105 X509_ALGOR_free(a->keyfunc); 105 X509_ALGOR_free(a->keyfunc);
106 X509_ALGOR_free(a->encryption); 106 X509_ALGOR_free(a->encryption);
107 Free ((char *)a); 107 Free (a);
108} 108}
109 109
110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp) 110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
@@ -131,7 +131,7 @@ PBKDF2PARAM *PBKDF2PARAM_new(void)
131 ASN1_CTX c; 131 ASN1_CTX c;
132 M_ASN1_New_Malloc(ret, PBKDF2PARAM); 132 M_ASN1_New_Malloc(ret, PBKDF2PARAM);
133 M_ASN1_New(ret->salt, ASN1_TYPE_new); 133 M_ASN1_New(ret->salt, ASN1_TYPE_new);
134 M_ASN1_New(ret->iter, ASN1_INTEGER_new); 134 M_ASN1_New(ret->iter, M_ASN1_INTEGER_new);
135 ret->keylength = NULL; 135 ret->keylength = NULL;
136 ret->prf = NULL; 136 ret->prf = NULL;
137 return (ret); 137 return (ret);
@@ -155,10 +155,10 @@ void PBKDF2PARAM_free (PBKDF2PARAM *a)
155{ 155{
156 if(a==NULL) return; 156 if(a==NULL) return;
157 ASN1_TYPE_free(a->salt); 157 ASN1_TYPE_free(a->salt);
158 ASN1_INTEGER_free(a->iter); 158 M_ASN1_INTEGER_free(a->iter);
159 ASN1_INTEGER_free(a->keylength); 159 M_ASN1_INTEGER_free(a->keylength);
160 X509_ALGOR_free(a->prf); 160 X509_ALGOR_free(a->prf);
161 Free ((char *)a); 161 Free (a);
162} 162}
163 163
164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm: 164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
@@ -175,19 +175,26 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
175 PBKDF2PARAM *kdf = NULL; 175 PBKDF2PARAM *kdf = NULL;
176 PBE2PARAM *pbe2 = NULL; 176 PBE2PARAM *pbe2 = NULL;
177 ASN1_OCTET_STRING *osalt = NULL; 177 ASN1_OCTET_STRING *osalt = NULL;
178 ASN1_OBJECT *obj;
179
180 alg_nid = EVP_CIPHER_type(cipher);
181 if(alg_nid == NID_undef) {
182 ASN1err(ASN1_F_PKCS5_PBE2_SET,
183 ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
184 goto err;
185 }
186 obj = OBJ_nid2obj(alg_nid);
178 187
179 if(!(pbe2 = PBE2PARAM_new())) goto merr; 188 if(!(pbe2 = PBE2PARAM_new())) goto merr;
180 189
181 /* Setup the AlgorithmIdentifier for the encryption scheme */ 190 /* Setup the AlgorithmIdentifier for the encryption scheme */
182 scheme = pbe2->encryption; 191 scheme = pbe2->encryption;
183 192
184 alg_nid = EVP_CIPHER_type(cipher); 193 scheme->algorithm = obj;
185
186 scheme->algorithm = OBJ_nid2obj(alg_nid);
187 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr; 194 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr;
188 195
189 /* Create random IV */ 196 /* Create random IV */
190 RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)); 197 RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher));
191 198
192 /* Dummy cipherinit to just setup the IV */ 199 /* Dummy cipherinit to just setup the IV */
193 EVP_CipherInit(&ctx, cipher, NULL, iv, 0); 200 EVP_CipherInit(&ctx, cipher, NULL, iv, 0);
@@ -199,13 +206,13 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
199 EVP_CIPHER_CTX_cleanup(&ctx); 206 EVP_CIPHER_CTX_cleanup(&ctx);
200 207
201 if(!(kdf = PBKDF2PARAM_new())) goto merr; 208 if(!(kdf = PBKDF2PARAM_new())) goto merr;
202 if(!(osalt = ASN1_OCTET_STRING_new())) goto merr; 209 if(!(osalt = M_ASN1_OCTET_STRING_new())) goto merr;
203 210
204 if (!saltlen) saltlen = PKCS5_SALT_LEN; 211 if (!saltlen) saltlen = PKCS5_SALT_LEN;
205 if (!(osalt->data = Malloc (saltlen))) goto merr; 212 if (!(osalt->data = Malloc (saltlen))) goto merr;
206 osalt->length = saltlen; 213 osalt->length = saltlen;
207 if (salt) memcpy (osalt->data, salt, saltlen); 214 if (salt) memcpy (osalt->data, salt, saltlen);
208 else RAND_bytes (osalt->data, saltlen); 215 else if (RAND_bytes (osalt->data, saltlen) <= 0) goto merr;
209 216
210 if(iter <= 0) iter = PKCS5_DEFAULT_ITER; 217 if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
211 if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr; 218 if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr;
@@ -218,7 +225,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
218 /* If its RC2 then we'd better setup the key length */ 225 /* If its RC2 then we'd better setup the key length */
219 226
220 if(alg_nid == NID_rc2_cbc) { 227 if(alg_nid == NID_rc2_cbc) {
221 if(!(kdf->keylength = ASN1_INTEGER_new())) goto merr; 228 if(!(kdf->keylength = M_ASN1_INTEGER_new())) goto merr;
222 if(!ASN1_INTEGER_set (kdf->keylength, 229 if(!ASN1_INTEGER_set (kdf->keylength,
223 EVP_CIPHER_key_length(cipher))) goto merr; 230 EVP_CIPHER_key_length(cipher))) goto merr;
224 } 231 }
@@ -264,7 +271,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
264 err: 271 err:
265 PBE2PARAM_free(pbe2); 272 PBE2PARAM_free(pbe2);
266 /* Note 'scheme' is freed as part of pbe2 */ 273 /* Note 'scheme' is freed as part of pbe2 */
267 ASN1_OCTET_STRING_free(osalt); 274 M_ASN1_OCTET_STRING_free(osalt);
268 PBKDF2PARAM_free(kdf); 275 PBKDF2PARAM_free(kdf);
269 X509_ALGOR_free(kalg); 276 X509_ALGOR_free(kalg);
270 X509_ALGOR_free(ret); 277 X509_ALGOR_free(ret);
diff --git a/src/lib/libcrypto/asn1/p7_dgst.c b/src/lib/libcrypto/asn1/p7_dgst.c
index 62783a2b8d..cba90e94a1 100644
--- a/src/lib/libcrypto/asn1/p7_dgst.c
+++ b/src/lib/libcrypto/asn1/p7_dgst.c
@@ -101,10 +101,10 @@ PKCS7_DIGEST *PKCS7_DIGEST_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_DIGEST); 103 M_ASN1_New_Malloc(ret,PKCS7_DIGEST);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->md,X509_ALGOR_new); 105 M_ASN1_New(ret->md,X509_ALGOR_new);
106 M_ASN1_New(ret->contents,PKCS7_new); 106 M_ASN1_New(ret->contents,PKCS7_new);
107 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); 107 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
108 return(ret); 108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW); 109 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW);
110 } 110 }
@@ -112,10 +112,10 @@ PKCS7_DIGEST *PKCS7_DIGEST_new(void)
112void PKCS7_DIGEST_free(PKCS7_DIGEST *a) 112void PKCS7_DIGEST_free(PKCS7_DIGEST *a)
113 { 113 {
114 if (a == NULL) return; 114 if (a == NULL) return;
115 ASN1_INTEGER_free(a->version); 115 M_ASN1_INTEGER_free(a->version);
116 X509_ALGOR_free(a->md); 116 X509_ALGOR_free(a->md);
117 PKCS7_free(a->contents); 117 PKCS7_free(a->contents);
118 ASN1_OCTET_STRING_free(a->digest); 118 M_ASN1_OCTET_STRING_free(a->digest);
119 Free((char *)a); 119 Free(a);
120 } 120 }
121 121
diff --git a/src/lib/libcrypto/asn1/p7_enc.c b/src/lib/libcrypto/asn1/p7_enc.c
index 4741126587..83b0e15faa 100644
--- a/src/lib/libcrypto/asn1/p7_enc.c
+++ b/src/lib/libcrypto/asn1/p7_enc.c
@@ -95,7 +95,7 @@ PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void)
95 ASN1_CTX c; 95 ASN1_CTX c;
96 96
97 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT); 97 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT);
98 M_ASN1_New(ret->version,ASN1_INTEGER_new); 98 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
99 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 99 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
100 return(ret); 100 return(ret);
101 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW); 101 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW);
@@ -104,8 +104,8 @@ PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void)
104void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a) 104void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a)
105 { 105 {
106 if (a == NULL) return; 106 if (a == NULL) return;
107 ASN1_INTEGER_free(a->version); 107 M_ASN1_INTEGER_free(a->version);
108 PKCS7_ENC_CONTENT_free(a->enc_data); 108 PKCS7_ENC_CONTENT_free(a->enc_data);
109 Free((char *)a); 109 Free(a);
110 } 110 }
111 111
diff --git a/src/lib/libcrypto/asn1/p7_enc_c.c b/src/lib/libcrypto/asn1/p7_enc_c.c
index a832737a38..582cc78b06 100644
--- a/src/lib/libcrypto/asn1/p7_enc_c.c
+++ b/src/lib/libcrypto/asn1/p7_enc_c.c
@@ -101,7 +101,8 @@ PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new(void)
101 101
102 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT); 102 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT);
103 /* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */ 103 /* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */
104 ret->content_type=OBJ_nid2obj(NID_pkcs7_encrypted); 104 /* We will almost always want this: so make it the default */
105 ret->content_type=OBJ_nid2obj(NID_pkcs7_data);
105 M_ASN1_New(ret->algorithm,X509_ALGOR_new); 106 M_ASN1_New(ret->algorithm,X509_ALGOR_new);
106 ret->enc_data=NULL; 107 ret->enc_data=NULL;
107 return(ret); 108 return(ret);
@@ -113,7 +114,7 @@ void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a)
113 if (a == NULL) return; 114 if (a == NULL) return;
114 ASN1_OBJECT_free(a->content_type); 115 ASN1_OBJECT_free(a->content_type);
115 X509_ALGOR_free(a->algorithm); 116 X509_ALGOR_free(a->algorithm);
116 ASN1_OCTET_STRING_free(a->enc_data); 117 M_ASN1_OCTET_STRING_free(a->enc_data);
117 Free((char *)a); 118 Free(a);
118 } 119 }
119 120
diff --git a/src/lib/libcrypto/asn1/p7_evp.c b/src/lib/libcrypto/asn1/p7_evp.c
index b2b3d50dcd..4e734fdd28 100644
--- a/src/lib/libcrypto/asn1/p7_evp.c
+++ b/src/lib/libcrypto/asn1/p7_evp.c
@@ -101,7 +101,7 @@ PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE); 103 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null); 105 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null);
106 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 106 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
107 return(ret); 107 return(ret);
@@ -111,9 +111,9 @@ PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void)
111void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a) 111void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a)
112 { 112 {
113 if (a == NULL) return; 113 if (a == NULL) return;
114 ASN1_INTEGER_free(a->version); 114 M_ASN1_INTEGER_free(a->version);
115 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); 115 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
116 PKCS7_ENC_CONTENT_free(a->enc_data); 116 PKCS7_ENC_CONTENT_free(a->enc_data);
117 Free((char *)a); 117 Free(a);
118 } 118 }
119 119
diff --git a/src/lib/libcrypto/asn1/p7_i_s.c b/src/lib/libcrypto/asn1/p7_i_s.c
index 7d4b457e01..d21f7ddb84 100644
--- a/src/lib/libcrypto/asn1/p7_i_s.c
+++ b/src/lib/libcrypto/asn1/p7_i_s.c
@@ -96,7 +96,7 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void)
96 96
97 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL); 97 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL);
98 M_ASN1_New(ret->issuer,X509_NAME_new); 98 M_ASN1_New(ret->issuer,X509_NAME_new);
99 M_ASN1_New(ret->serial,ASN1_INTEGER_new); 99 M_ASN1_New(ret->serial,M_ASN1_INTEGER_new);
100 return(ret); 100 return(ret);
101 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW); 101 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW);
102 } 102 }
@@ -105,7 +105,7 @@ void PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a)
105 { 105 {
106 if (a == NULL) return; 106 if (a == NULL) return;
107 X509_NAME_free(a->issuer); 107 X509_NAME_free(a->issuer);
108 ASN1_INTEGER_free(a->serial); 108 M_ASN1_INTEGER_free(a->serial);
109 Free((char *)a); 109 Free(a);
110 } 110 }
111 111
diff --git a/src/lib/libcrypto/asn1/p7_lib.c b/src/lib/libcrypto/asn1/p7_lib.c
index 846be17158..86db82cfa1 100644
--- a/src/lib/libcrypto/asn1/p7_lib.c
+++ b/src/lib/libcrypto/asn1/p7_lib.c
@@ -152,7 +152,7 @@ PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
152 { 152 {
153 if ((*a)->asn1 != NULL) 153 if ((*a)->asn1 != NULL)
154 { 154 {
155 Free((char *)(*a)->asn1); 155 Free((*a)->asn1);
156 (*a)->asn1=NULL; 156 (*a)->asn1=NULL;
157 } 157 }
158 (*a)->length=0; 158 (*a)->length=0;
@@ -251,7 +251,7 @@ void PKCS7_free(PKCS7 *a)
251 { 251 {
252 ASN1_OBJECT_free(a->type); 252 ASN1_OBJECT_free(a->type);
253 } 253 }
254 Free((char *)(char *)a); 254 Free(a);
255 } 255 }
256 256
257void PKCS7_content_free(PKCS7 *a) 257void PKCS7_content_free(PKCS7 *a)
@@ -259,7 +259,7 @@ void PKCS7_content_free(PKCS7 *a)
259 if(a == NULL) 259 if(a == NULL)
260 return; 260 return;
261 261
262 if (a->asn1 != NULL) Free((char *)a->asn1); 262 if (a->asn1 != NULL) Free(a->asn1);
263 263
264 if (a->d.ptr != NULL) 264 if (a->d.ptr != NULL)
265 { 265 {
@@ -268,7 +268,7 @@ void PKCS7_content_free(PKCS7 *a)
268 switch (OBJ_obj2nid(a->type)) 268 switch (OBJ_obj2nid(a->type))
269 { 269 {
270 case NID_pkcs7_data: 270 case NID_pkcs7_data:
271 ASN1_OCTET_STRING_free(a->d.data); 271 M_ASN1_OCTET_STRING_free(a->d.data);
272 break; 272 break;
273 case NID_pkcs7_signed: 273 case NID_pkcs7_signed:
274 PKCS7_SIGNED_free(a->d.sign); 274 PKCS7_SIGNED_free(a->d.sign);
diff --git a/src/lib/libcrypto/asn1/p7_recip.c b/src/lib/libcrypto/asn1/p7_recip.c
index 9fda4f20d4..b1abfa3b8f 100644
--- a/src/lib/libcrypto/asn1/p7_recip.c
+++ b/src/lib/libcrypto/asn1/p7_recip.c
@@ -101,10 +101,10 @@ PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO); 103 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); 105 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
106 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new); 106 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new);
107 M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new); 107 M_ASN1_New(ret->enc_key,M_ASN1_OCTET_STRING_new);
108 ret->cert=NULL; 108 ret->cert=NULL;
109 return(ret); 109 return(ret);
110 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW); 110 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW);
@@ -113,10 +113,10 @@ PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void)
113void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a) 113void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a)
114 { 114 {
115 if (a == NULL) return; 115 if (a == NULL) return;
116 ASN1_INTEGER_free(a->version); 116 M_ASN1_INTEGER_free(a->version);
117 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); 117 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
118 X509_ALGOR_free(a->key_enc_algor); 118 X509_ALGOR_free(a->key_enc_algor);
119 ASN1_OCTET_STRING_free(a->enc_key); 119 M_ASN1_OCTET_STRING_free(a->enc_key);
120 if (a->cert != NULL) X509_free(a->cert); 120 if (a->cert != NULL) X509_free(a->cert);
121 Free(a); 121 Free(a);
122 } 122 }
diff --git a/src/lib/libcrypto/asn1/p7_s_e.c b/src/lib/libcrypto/asn1/p7_s_e.c
index 90946695c9..3d18fedf8e 100644
--- a/src/lib/libcrypto/asn1/p7_s_e.c
+++ b/src/lib/libcrypto/asn1/p7_s_e.c
@@ -119,7 +119,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
119 ASN1_CTX c; 119 ASN1_CTX c;
120 120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE); 121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new); 122 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
123 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null); 123 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null);
124 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null); 124 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null);
125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
@@ -133,7 +133,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
133void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a) 133void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a)
134 { 134 {
135 if (a == NULL) return; 135 if (a == NULL) return;
136 ASN1_INTEGER_free(a->version); 136 M_ASN1_INTEGER_free(a->version);
137 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); 137 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
138 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free); 138 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free);
139 PKCS7_ENC_CONTENT_free(a->enc_data); 139 PKCS7_ENC_CONTENT_free(a->enc_data);
diff --git a/src/lib/libcrypto/asn1/p7_signd.c b/src/lib/libcrypto/asn1/p7_signd.c
index 74f0f522e1..f6f16a8715 100644
--- a/src/lib/libcrypto/asn1/p7_signd.c
+++ b/src/lib/libcrypto/asn1/p7_signd.c
@@ -112,7 +112,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
112 ASN1_CTX c; 112 ASN1_CTX c;
113 113
114 M_ASN1_New_Malloc(ret,PKCS7_SIGNED); 114 M_ASN1_New_Malloc(ret,PKCS7_SIGNED);
115 M_ASN1_New(ret->version,ASN1_INTEGER_new); 115 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
116 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null); 116 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null);
117 M_ASN1_New(ret->contents,PKCS7_new); 117 M_ASN1_New(ret->contents,PKCS7_new);
118 ret->cert=NULL; 118 ret->cert=NULL;
@@ -125,7 +125,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
125void PKCS7_SIGNED_free(PKCS7_SIGNED *a) 125void PKCS7_SIGNED_free(PKCS7_SIGNED *a)
126 { 126 {
127 if (a == NULL) return; 127 if (a == NULL) return;
128 ASN1_INTEGER_free(a->version); 128 M_ASN1_INTEGER_free(a->version);
129 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free); 129 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free);
130 PKCS7_free(a->contents); 130 PKCS7_free(a->contents);
131 sk_X509_pop_free(a->cert,X509_free); 131 sk_X509_pop_free(a->cert,X509_free);
diff --git a/src/lib/libcrypto/asn1/p7_signi.c b/src/lib/libcrypto/asn1/p7_signi.c
index 21132ef4dd..f74658ffe6 100644
--- a/src/lib/libcrypto/asn1/p7_signi.c
+++ b/src/lib/libcrypto/asn1/p7_signi.c
@@ -119,12 +119,12 @@ PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void)
119 ASN1_CTX c; 119 ASN1_CTX c;
120 120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO); 121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new); 122 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); 123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new); 124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new);
125 ret->auth_attr=NULL; 125 ret->auth_attr=NULL;
126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new); 126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new);
127 M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new); 127 M_ASN1_New(ret->enc_digest,M_ASN1_OCTET_STRING_new);
128 ret->unauth_attr=NULL; 128 ret->unauth_attr=NULL;
129 ret->pkey=NULL; 129 ret->pkey=NULL;
130 return(ret); 130 return(ret);
@@ -134,16 +134,16 @@ PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void)
134void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a) 134void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a)
135 { 135 {
136 if (a == NULL) return; 136 if (a == NULL) return;
137 ASN1_INTEGER_free(a->version); 137 M_ASN1_INTEGER_free(a->version);
138 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); 138 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
139 X509_ALGOR_free(a->digest_alg); 139 X509_ALGOR_free(a->digest_alg);
140 sk_X509_ATTRIBUTE_pop_free(a->auth_attr,X509_ATTRIBUTE_free); 140 sk_X509_ATTRIBUTE_pop_free(a->auth_attr,X509_ATTRIBUTE_free);
141 X509_ALGOR_free(a->digest_enc_alg); 141 X509_ALGOR_free(a->digest_enc_alg);
142 ASN1_OCTET_STRING_free(a->enc_digest); 142 M_ASN1_OCTET_STRING_free(a->enc_digest);
143 sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free); 143 sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free);
144 if (a->pkey != NULL) 144 if (a->pkey != NULL)
145 EVP_PKEY_free(a->pkey); 145 EVP_PKEY_free(a->pkey);
146 Free((char *)a); 146 Free(a);
147 } 147 }
148 148
149IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO) 149IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO)
diff --git a/src/lib/libcrypto/asn1/p8_key.c b/src/lib/libcrypto/asn1/p8_key.c
new file mode 100644
index 0000000000..0b24374627
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p8_key.c
@@ -0,0 +1,131 @@
1/* crypto/asn1/p8_key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_Malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 Free(a);
130 }
131
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c
index aa9a4f6c96..59cfbe7f28 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -88,7 +88,7 @@ PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void)
88 PKCS8_PRIV_KEY_INFO *ret=NULL; 88 PKCS8_PRIV_KEY_INFO *ret=NULL;
89 ASN1_CTX c; 89 ASN1_CTX c;
90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO); 90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO);
91 M_ASN1_New (ret->version, ASN1_INTEGER_new); 91 M_ASN1_New (ret->version, M_ASN1_INTEGER_new);
92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new); 92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new);
93 M_ASN1_New (ret->pkey, ASN1_TYPE_new); 93 M_ASN1_New (ret->pkey, ASN1_TYPE_new);
94 ret->attributes = NULL; 94 ret->attributes = NULL;
@@ -109,15 +109,13 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes, 109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,
110 d2i_X509_ATTRIBUTE, 110 d2i_X509_ATTRIBUTE,
111 X509_ATTRIBUTE_free, 0); 111 X509_ATTRIBUTE_free, 0);
112 if (ASN1_TYPE_get(ret->pkey) == V_ASN1_SEQUENCE)
113 ret->broken = PKCS8_NO_OCTET;
114 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO); 112 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);
115} 113}
116 114
117void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a) 115void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a)
118{ 116{
119 if (a == NULL) return; 117 if (a == NULL) return;
120 ASN1_INTEGER_free (a->version); 118 M_ASN1_INTEGER_free (a->version);
121 X509_ALGOR_free(a->pkeyalg); 119 X509_ALGOR_free(a->pkeyalg);
122 /* Clear sensitive data */ 120 /* Clear sensitive data */
123 if (a->pkey->value.octet_string) 121 if (a->pkey->value.octet_string)
diff --git a/src/lib/libcrypto/asn1/pkcs8.c b/src/lib/libcrypto/asn1/pkcs8.c
index 29c4ea6a29..e69de29bb2 100644
--- a/src/lib/libcrypto/asn1/pkcs8.c
+++ b/src/lib/libcrypto/asn1/pkcs8.c
@@ -1,131 +0,0 @@
1/* crypto/asn1/pkcs8.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_Malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 Free((char *)a);
130 }
131
diff --git a/src/lib/libcrypto/asn1/t_bitst.c b/src/lib/libcrypto/asn1/t_bitst.c
new file mode 100644
index 0000000000..8ee789f082
--- /dev/null
+++ b/src/lib/libcrypto/asn1/t_bitst.c
@@ -0,0 +1,99 @@
1/* t_bitst.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/x509v3.h>
63
64int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
65 BIT_STRING_BITNAME *tbl, int indent)
66{
67 BIT_STRING_BITNAME *bnam;
68 char first = 1;
69 BIO_printf(out, "%*s", indent, "");
70 for(bnam = tbl; bnam->lname; bnam++) {
71 if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
72 if(!first) BIO_puts(out, ", ");
73 BIO_puts(out, bnam->lname);
74 first = 0;
75 }
76 }
77 BIO_puts(out, "\n");
78 return 1;
79}
80
81int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
82 BIT_STRING_BITNAME *tbl)
83{
84 int bitnum;
85 bitnum = ASN1_BIT_STRING_num_asc(name, tbl);
86 if(bitnum < 0) return 0;
87 if(bs) ASN1_BIT_STRING_set_bit(bs, bitnum, value);
88 return 1;
89}
90
91int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl)
92{
93 BIT_STRING_BITNAME *bnam;
94 for(bnam = tbl; bnam->lname; bnam++) {
95 if(!strcmp(bnam->sname, name) ||
96 !strcmp(bnam->lname, name) ) return bnam->bitnum;
97 }
98 return -1;
99}
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index c2e447ce6f..d78e4a8f88 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -160,7 +160,7 @@ static void ext_print(BIO *out, X509_EXTENSION *ex)
160 BIO_printf(out, ": %s\n", j ? "critical":"",""); 160 BIO_printf(out, ": %s\n", j ? "critical":"","");
161 if(!X509V3_EXT_print(out, ex, 0, 16)) { 161 if(!X509V3_EXT_print(out, ex, 0, 16)) {
162 BIO_printf(out, "%16s", ""); 162 BIO_printf(out, "%16s", "");
163 ASN1_OCTET_STRING_print(out,ex->value); 163 M_ASN1_OCTET_STRING_print(out,ex->value);
164 } 164 }
165 BIO_write(out,"\n",1); 165 BIO_write(out,"\n",1);
166} 166}
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index 0dc6e30c3d..e570ed1c47 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -133,7 +133,7 @@ int RSA_print(BIO *bp, RSA *x, int off)
133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err; 133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err;
134 ret=1; 134 ret=1;
135err: 135err:
136 if (m != NULL) Free((char *)m); 136 if (m != NULL) Free(m);
137 return(ret); 137 return(ret);
138 } 138 }
139#endif /* NO_RSA */ 139#endif /* NO_RSA */
@@ -204,7 +204,7 @@ int DSA_print(BIO *bp, DSA *x, int off)
204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err; 204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err;
205 ret=1; 205 ret=1;
206err: 206err:
207 if (m != NULL) Free((char *)m); 207 if (m != NULL) Free(m);
208 return(ret); 208 return(ret);
209 } 209 }
210#endif /* !NO_DSA */ 210#endif /* !NO_DSA */
@@ -298,7 +298,7 @@ int DHparams_print(BIO *bp, DH *x)
298 if (!print(bp,"generator:",x->g,m,4)) goto err; 298 if (!print(bp,"generator:",x->g,m,4)) goto err;
299 if (x->length != 0) 299 if (x->length != 0)
300 { 300 {
301 if (BIO_printf(bp," recomented-private-length: %d bits\n", 301 if (BIO_printf(bp," recommended-private-length: %d bits\n",
302 (int)x->length) <= 0) goto err; 302 (int)x->length) <= 0) goto err;
303 } 303 }
304 ret=1; 304 ret=1;
@@ -307,7 +307,7 @@ int DHparams_print(BIO *bp, DH *x)
307err: 307err:
308 DHerr(DH_F_DHPARAMS_PRINT,reason); 308 DHerr(DH_F_DHPARAMS_PRINT,reason);
309 } 309 }
310 if (m != NULL) Free((char *)m); 310 if (m != NULL) Free(m);
311 return(ret); 311 return(ret);
312 } 312 }
313#endif 313#endif
@@ -352,7 +352,7 @@ int DSAparams_print(BIO *bp, DSA *x)
352 if (!print(bp,"g:",x->g,m,4)) goto err; 352 if (!print(bp,"g:",x->g,m,4)) goto err;
353 ret=1; 353 ret=1;
354err: 354err:
355 if (m != NULL) Free((char *)m); 355 if (m != NULL) Free(m);
356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason); 356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason);
357 return(ret); 357 return(ret);
358 } 358 }
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index bdd749436a..81dd6355a8 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -62,6 +62,7 @@
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/x509v3.h>
65 66
66#ifndef NO_FP_API 67#ifndef NO_FP_API
67int X509_REQ_print_fp(FILE *fp, X509_REQ *x) 68int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
@@ -90,6 +91,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
90 X509_REQ_INFO *ri; 91 X509_REQ_INFO *ri;
91 EVP_PKEY *pkey; 92 EVP_PKEY *pkey;
92 STACK_OF(X509_ATTRIBUTE) *sk; 93 STACK_OF(X509_ATTRIBUTE) *sk;
94 STACK_OF(X509_EXTENSION) *exts;
93 char str[128]; 95 char str[128];
94 96
95 ri=x->req_info; 97 ri=x->req_info;
@@ -161,6 +163,8 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
161 int j,type=0,count=1,ii=0; 163 int j,type=0,count=1,ii=0;
162 164
163 a=sk_X509_ATTRIBUTE_value(sk,i); 165 a=sk_X509_ATTRIBUTE_value(sk,i);
166 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
167 continue;
164 sprintf(str,"%12s",""); 168 sprintf(str,"%12s","");
165 if (BIO_puts(bp,str) <= 0) goto err; 169 if (BIO_puts(bp,str) <= 0) goto err;
166 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 170 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
@@ -201,6 +205,29 @@ get_next:
201 } 205 }
202 } 206 }
203 207
208 exts = X509_REQ_get_extensions(x);
209 if(exts) {
210 BIO_printf(bp,"%8sRequested Extensions:\n","");
211 for (i=0; i<sk_X509_EXTENSION_num(exts); i++) {
212 ASN1_OBJECT *obj;
213 X509_EXTENSION *ex;
214 int j;
215 ex=sk_X509_EXTENSION_value(exts, i);
216 if (BIO_printf(bp,"%12s","") <= 0) goto err;
217 obj=X509_EXTENSION_get_object(ex);
218 i2a_ASN1_OBJECT(bp,obj);
219 j=X509_EXTENSION_get_critical(ex);
220 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
221 goto err;
222 if(!X509V3_EXT_print(bp, ex, 0, 16)) {
223 BIO_printf(bp, "%16s", "");
224 M_ASN1_OCTET_STRING_print(bp,ex->value);
225 }
226 if (BIO_write(bp,"\n",1) <= 0) goto err;
227 }
228 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
229 }
230
204 i=OBJ_obj2nid(x->sig_alg->algorithm); 231 i=OBJ_obj2nid(x->sig_alg->algorithm);
205 sprintf(str,"%4sSignature Algorithm: %s","", 232 sprintf(str,"%4sSignature Algorithm: %s","",
206 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); 233 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
diff --git a/src/lib/libcrypto/asn1/t_spki.c b/src/lib/libcrypto/asn1/t_spki.c
new file mode 100644
index 0000000000..d708434fca
--- /dev/null
+++ b/src/lib/libcrypto/asn1/t_spki.c
@@ -0,0 +1,116 @@
1/* t_spki.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/x509.h>
62#include <openssl/asn1_mac.h>
63
64/* Print out an SPKI */
65
66int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
67{
68 EVP_PKEY *pkey;
69 ASN1_IA5STRING *chal;
70 int i, n;
71 char *s;
72 BIO_printf(out, "Netscape SPKI:\n");
73 i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm);
74 BIO_printf(out," Public Key Algorithm: %s\n",
75 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
76 pkey = X509_PUBKEY_get(spki->spkac->pubkey);
77 if(!pkey) BIO_printf(out, " Unable to load public key\n");
78 else {
79#ifndef NO_RSA
80 if (pkey->type == EVP_PKEY_RSA)
81 {
82 BIO_printf(out," RSA Public Key: (%d bit)\n",
83 BN_num_bits(pkey->pkey.rsa->n));
84 RSA_print(out,pkey->pkey.rsa,2);
85 }
86 else
87#endif
88#ifndef NO_DSA
89 if (pkey->type == EVP_PKEY_DSA)
90 {
91 BIO_printf(out," DSA Public Key:\n");
92 DSA_print(out,pkey->pkey.dsa,2);
93 }
94 else
95#endif
96 BIO_printf(out," Unknown Public Key:\n");
97 EVP_PKEY_free(pkey);
98 }
99 chal = spki->spkac->challenge;
100 if(chal->length)
101 BIO_printf(out, " Challenge String: %s\n", chal->data);
102 i=OBJ_obj2nid(spki->sig_algor->algorithm);
103 BIO_printf(out," Signature Algorithm: %s",
104 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
105
106 n=spki->signature->length;
107 s=(char *)spki->signature->data;
108 for (i=0; i<n; i++)
109 {
110 if ((i%18) == 0) BIO_write(out,"\n ",7);
111 BIO_printf(out,"%02x%s",(unsigned char)s[i],
112 ((i+1) == n)?"":":");
113 }
114 BIO_write(out,"\n",1);
115 return 1;
116}
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 42f4d498cf..6ee1065ce9 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -188,11 +188,7 @@ int X509_print(BIO *bp, X509 *x)
188 BIO_printf(bp,"%8sX509v3 extensions:\n",""); 188 BIO_printf(bp,"%8sX509v3 extensions:\n","");
189 for (i=0; i<n; i++) 189 for (i=0; i<n; i++)
190 { 190 {
191#if 0
192 int data_type,pack_type;
193#endif
194 ASN1_OBJECT *obj; 191 ASN1_OBJECT *obj;
195
196 ex=X509_get_ext(x,i); 192 ex=X509_get_ext(x,i);
197 if (BIO_printf(bp,"%12s","") <= 0) goto err; 193 if (BIO_printf(bp,"%12s","") <= 0) goto err;
198 obj=X509_EXTENSION_get_object(ex); 194 obj=X509_EXTENSION_get_object(ex);
@@ -203,7 +199,7 @@ int X509_print(BIO *bp, X509 *x)
203 if(!X509V3_EXT_print(bp, ex, 0, 16)) 199 if(!X509V3_EXT_print(bp, ex, 0, 16))
204 { 200 {
205 BIO_printf(bp, "%16s", ""); 201 BIO_printf(bp, "%16s", "");
206 ASN1_OCTET_STRING_print(bp,ex->value); 202 M_ASN1_OCTET_STRING_print(bp,ex->value);
207 } 203 }
208 if (BIO_write(bp,"\n",1) <= 0) goto err; 204 if (BIO_write(bp,"\n",1) <= 0) goto err;
209 } 205 }
@@ -223,10 +219,11 @@ int X509_print(BIO *bp, X509 *x)
223 ((i+1) == n)?"":":") <= 0) goto err; 219 ((i+1) == n)?"":":") <= 0) goto err;
224 } 220 }
225 if (BIO_write(bp,"\n",1) != 1) goto err; 221 if (BIO_write(bp,"\n",1) != 1) goto err;
222 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
226 ret=1; 223 ret=1;
227err: 224err:
228 if (str != NULL) ASN1_STRING_free(str); 225 if (str != NULL) ASN1_STRING_free(str);
229 if (m != NULL) Free((char *)m); 226 if (m != NULL) Free(m);
230 return(ret); 227 return(ret);
231 } 228 }
232 229
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
new file mode 100644
index 0000000000..a18ebb586c
--- /dev/null
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -0,0 +1,102 @@
1/* t_x509a.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/evp.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h>
64
65/* X509_CERT_AUX and string set routines
66 */
67
68int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
69{
70 char oidstr[80], first;
71 int i;
72 if(!aux) return 1;
73 if(aux->trust) {
74 first = 1;
75 BIO_printf(out, "%*sTrusted Uses:\n%*s",
76 indent, "", indent + 2, "");
77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
78 if(!first) BIO_puts(out, ", ");
79 else first = 0;
80 OBJ_obj2txt(oidstr, 80,
81 sk_ASN1_OBJECT_value(aux->trust, i), 0);
82 BIO_puts(out, oidstr);
83 }
84 BIO_puts(out, "\n");
85 } else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, "");
86 if(aux->reject) {
87 first = 1;
88 BIO_printf(out, "%*sRejected Uses:\n%*s",
89 indent, "", indent + 2, "");
90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
91 if(!first) BIO_puts(out, ", ");
92 else first = 0;
93 OBJ_obj2txt(oidstr, 80,
94 sk_ASN1_OBJECT_value(aux->reject, i), 0);
95 BIO_puts(out, oidstr);
96 }
97 BIO_puts(out, "\n");
98 } else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
99 if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "",
100 aux->alias->data);
101 return 1;
102}
diff --git a/src/lib/libcrypto/asn1/x_algor.c b/src/lib/libcrypto/asn1/x_algor.c
index b2c20d139f..fe023842f8 100644
--- a/src/lib/libcrypto/asn1/x_algor.c
+++ b/src/lib/libcrypto/asn1/x_algor.c
@@ -111,7 +111,7 @@ void X509_ALGOR_free(X509_ALGOR *a)
111 if (a == NULL) return; 111 if (a == NULL) return;
112 ASN1_OBJECT_free(a->algorithm); 112 ASN1_OBJECT_free(a->algorithm);
113 ASN1_TYPE_free(a->parameter); 113 ASN1_TYPE_free(a->parameter);
114 Free((char *)a); 114 Free(a);
115 } 115 }
116 116
117IMPLEMENT_STACK_OF(X509_ALGOR) 117IMPLEMENT_STACK_OF(X509_ALGOR)
diff --git a/src/lib/libcrypto/asn1/x_attrib.c b/src/lib/libcrypto/asn1/x_attrib.c
index a1cbebf5a5..a874df79db 100644
--- a/src/lib/libcrypto/asn1/x_attrib.c
+++ b/src/lib/libcrypto/asn1/x_attrib.c
@@ -160,6 +160,6 @@ void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a)
160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free); 160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free);
161 else 161 else
162 ASN1_TYPE_free(a->value.single); 162 ASN1_TYPE_free(a->value.single);
163 Free((char *)a); 163 Free(a);
164 } 164 }
165 165
diff --git a/src/lib/libcrypto/asn1/x_cinf.c b/src/lib/libcrypto/asn1/x_cinf.c
index fe1b18a90f..b87c8fff17 100644
--- a/src/lib/libcrypto/asn1/x_cinf.c
+++ b/src/lib/libcrypto/asn1/x_cinf.c
@@ -115,7 +115,7 @@ X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
115 { 115 {
116 if (ret->version != NULL) 116 if (ret->version != NULL)
117 { 117 {
118 ASN1_INTEGER_free(ret->version); 118 M_ASN1_INTEGER_free(ret->version);
119 ret->version=NULL; 119 ret->version=NULL;
120 } 120 }
121 } 121 }
@@ -129,12 +129,12 @@ X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
129 { 129 {
130 if (ret->issuerUID != NULL) 130 if (ret->issuerUID != NULL)
131 { 131 {
132 ASN1_BIT_STRING_free(ret->issuerUID); 132 M_ASN1_BIT_STRING_free(ret->issuerUID);
133 ret->issuerUID=NULL; 133 ret->issuerUID=NULL;
134 } 134 }
135 if (ret->subjectUID != NULL) 135 if (ret->subjectUID != NULL)
136 { 136 {
137 ASN1_BIT_STRING_free(ret->subjectUID); 137 M_ASN1_BIT_STRING_free(ret->subjectUID);
138 ret->subjectUID=NULL; 138 ret->subjectUID=NULL;
139 } 139 }
140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1, 140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
@@ -170,7 +170,7 @@ X509_CINF *X509_CINF_new(void)
170 170
171 M_ASN1_New_Malloc(ret,X509_CINF); 171 M_ASN1_New_Malloc(ret,X509_CINF);
172 ret->version=NULL; 172 ret->version=NULL;
173 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); 173 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
174 M_ASN1_New(ret->signature,X509_ALGOR_new); 174 M_ASN1_New(ret->signature,X509_ALGOR_new);
175 M_ASN1_New(ret->issuer,X509_NAME_new); 175 M_ASN1_New(ret->issuer,X509_NAME_new);
176 M_ASN1_New(ret->validity,X509_VAL_new); 176 M_ASN1_New(ret->validity,X509_VAL_new);
@@ -186,15 +186,15 @@ X509_CINF *X509_CINF_new(void)
186void X509_CINF_free(X509_CINF *a) 186void X509_CINF_free(X509_CINF *a)
187 { 187 {
188 if (a == NULL) return; 188 if (a == NULL) return;
189 ASN1_INTEGER_free(a->version); 189 M_ASN1_INTEGER_free(a->version);
190 ASN1_INTEGER_free(a->serialNumber); 190 M_ASN1_INTEGER_free(a->serialNumber);
191 X509_ALGOR_free(a->signature); 191 X509_ALGOR_free(a->signature);
192 X509_NAME_free(a->issuer); 192 X509_NAME_free(a->issuer);
193 X509_VAL_free(a->validity); 193 X509_VAL_free(a->validity);
194 X509_NAME_free(a->subject); 194 X509_NAME_free(a->subject);
195 X509_PUBKEY_free(a->key); 195 X509_PUBKEY_free(a->key);
196 ASN1_BIT_STRING_free(a->issuerUID); 196 M_ASN1_BIT_STRING_free(a->issuerUID);
197 ASN1_BIT_STRING_free(a->subjectUID); 197 M_ASN1_BIT_STRING_free(a->subjectUID);
198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
199 Free(a); 199 Free(a);
200 } 200 }
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c
index cd46bbebc2..12a42d04c7 100644
--- a/src/lib/libcrypto/asn1/x_crl.c
+++ b/src/lib/libcrypto/asn1/x_crl.c
@@ -130,9 +130,9 @@ int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **pp)
130 } 130 }
131 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR); 131 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
132 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME); 132 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
133 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_UTCTIME); 133 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_TIME);
134 if (a->nextUpdate != NULL) 134 if (a->nextUpdate != NULL)
135 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_UTCTIME); } 135 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_TIME); }
136 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked, 136 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
137 i2d_X509_REVOKED); 137 i2d_X509_REVOKED);
138 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions, 138 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
@@ -157,20 +157,16 @@ X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp,
157 157
158 if ((ver == 0) && (ret->version != NULL)) 158 if ((ver == 0) && (ret->version != NULL))
159 { 159 {
160 ASN1_INTEGER_free(ret->version); 160 M_ASN1_INTEGER_free(ret->version);
161 ret->version=NULL; 161 ret->version=NULL;
162 } 162 }
163 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR); 163 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
164 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); 164 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
165 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME); 165 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME);
166 /* Manually handle the OPTIONAL ASN1_TIME stuff */ 166 /* Manually handle the OPTIONAL ASN1_TIME stuff */
167 if(c.slen != 0 167 /* First try UTCTime */
168 && ( (M_ASN1_next & ~V_ASN1_CONSTRUCTED) == 168 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_UTCTIME, V_ASN1_UTCTIME);
169 (V_ASN1_UNIVERSAL|V_ASN1_UTCTIME) 169 /* If that doesn't work try GeneralizedTime */
170 || (M_ASN1_next & ~V_ASN1_CONSTRUCTED) ==
171 (V_ASN1_UNIVERSAL|V_ASN1_GENERALIZEDTIME) ) ) {
172 M_ASN1_D2I_get(ret->nextUpdate,d2i_ASN1_TIME);
173 }
174 if(!ret->nextUpdate) 170 if(!ret->nextUpdate)
175 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME, 171 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME,
176 V_ASN1_GENERALIZEDTIME); 172 V_ASN1_GENERALIZEDTIME);
@@ -190,20 +186,17 @@ X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp,
190 } 186 }
191 } 187 }
192 188
193 if (ver >= 1) 189 if (ret->extensions != NULL)
194 { 190 {
195 if (ret->extensions != NULL) 191 while (sk_X509_EXTENSION_num(ret->extensions))
196 { 192 X509_EXTENSION_free(
197 while (sk_X509_EXTENSION_num(ret->extensions)) 193 sk_X509_EXTENSION_pop(ret->extensions));
198 X509_EXTENSION_free(
199 sk_X509_EXTENSION_pop(ret->extensions));
200 }
201
202 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
203 d2i_X509_EXTENSION,
204 X509_EXTENSION_free,0,
205 V_ASN1_SEQUENCE);
206 } 194 }
195
196 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
197 d2i_X509_EXTENSION,
198 X509_EXTENSION_free,0,
199 V_ASN1_SEQUENCE);
207 200
208 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO); 201 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO);
209 } 202 }
@@ -245,8 +238,8 @@ X509_REVOKED *X509_REVOKED_new(void)
245 ASN1_CTX c; 238 ASN1_CTX c;
246 239
247 M_ASN1_New_Malloc(ret,X509_REVOKED); 240 M_ASN1_New_Malloc(ret,X509_REVOKED);
248 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); 241 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
249 M_ASN1_New(ret->revocationDate,ASN1_UTCTIME_new); 242 M_ASN1_New(ret->revocationDate,M_ASN1_UTCTIME_new);
250 ret->extensions=NULL; 243 ret->extensions=NULL;
251 return(ret); 244 return(ret);
252 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW); 245 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW);
@@ -261,7 +254,7 @@ X509_CRL_INFO *X509_CRL_INFO_new(void)
261 ret->version=NULL; 254 ret->version=NULL;
262 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 255 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
263 M_ASN1_New(ret->issuer,X509_NAME_new); 256 M_ASN1_New(ret->issuer,X509_NAME_new);
264 M_ASN1_New(ret->lastUpdate,ASN1_UTCTIME_new); 257 M_ASN1_New(ret->lastUpdate,M_ASN1_UTCTIME_new);
265 ret->nextUpdate=NULL; 258 ret->nextUpdate=NULL;
266 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null); 259 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null);
267 M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null); 260 M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null);
@@ -279,7 +272,7 @@ X509_CRL *X509_CRL_new(void)
279 ret->references=1; 272 ret->references=1;
280 M_ASN1_New(ret->crl,X509_CRL_INFO_new); 273 M_ASN1_New(ret->crl,X509_CRL_INFO_new);
281 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 274 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
282 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 275 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
283 return(ret); 276 return(ret);
284 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW); 277 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW);
285 } 278 }
@@ -287,8 +280,8 @@ X509_CRL *X509_CRL_new(void)
287void X509_REVOKED_free(X509_REVOKED *a) 280void X509_REVOKED_free(X509_REVOKED *a)
288 { 281 {
289 if (a == NULL) return; 282 if (a == NULL) return;
290 ASN1_INTEGER_free(a->serialNumber); 283 M_ASN1_INTEGER_free(a->serialNumber);
291 ASN1_UTCTIME_free(a->revocationDate); 284 M_ASN1_UTCTIME_free(a->revocationDate);
292 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 285 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
293 Free(a); 286 Free(a);
294 } 287 }
@@ -296,12 +289,12 @@ void X509_REVOKED_free(X509_REVOKED *a)
296void X509_CRL_INFO_free(X509_CRL_INFO *a) 289void X509_CRL_INFO_free(X509_CRL_INFO *a)
297 { 290 {
298 if (a == NULL) return; 291 if (a == NULL) return;
299 ASN1_INTEGER_free(a->version); 292 M_ASN1_INTEGER_free(a->version);
300 X509_ALGOR_free(a->sig_alg); 293 X509_ALGOR_free(a->sig_alg);
301 X509_NAME_free(a->issuer); 294 X509_NAME_free(a->issuer);
302 ASN1_UTCTIME_free(a->lastUpdate); 295 M_ASN1_UTCTIME_free(a->lastUpdate);
303 if (a->nextUpdate) 296 if (a->nextUpdate)
304 ASN1_UTCTIME_free(a->nextUpdate); 297 M_ASN1_UTCTIME_free(a->nextUpdate);
305 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free); 298 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free);
306 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 299 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
307 Free(a); 300 Free(a);
@@ -328,7 +321,7 @@ void X509_CRL_free(X509_CRL *a)
328 321
329 X509_CRL_INFO_free(a->crl); 322 X509_CRL_INFO_free(a->crl);
330 X509_ALGOR_free(a->sig_alg); 323 X509_ALGOR_free(a->sig_alg);
331 ASN1_BIT_STRING_free(a->signature); 324 M_ASN1_BIT_STRING_free(a->signature);
332 Free(a); 325 Free(a);
333 } 326 }
334 327
diff --git a/src/lib/libcrypto/asn1/x_exten.c b/src/lib/libcrypto/asn1/x_exten.c
index d5f9e1df9e..185cbd78a0 100644
--- a/src/lib/libcrypto/asn1/x_exten.c
+++ b/src/lib/libcrypto/asn1/x_exten.c
@@ -100,10 +100,6 @@ X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, unsigned char **pp,
100 M_ASN1_D2I_start_sequence(); 100 M_ASN1_D2I_start_sequence();
101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT); 101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT);
102 102
103 if ((ret->argp != NULL) && (ret->ex_free != NULL))
104 ret->ex_free(ret);
105 ret->argl=0;
106 ret->argp=NULL;
107 ret->netscape_hack=0; 103 ret->netscape_hack=0;
108 if ((c.slen != 0) && 104 if ((c.slen != 0) &&
109 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN))) 105 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN)))
@@ -126,12 +122,9 @@ X509_EXTENSION *X509_EXTENSION_new(void)
126 122
127 M_ASN1_New_Malloc(ret,X509_EXTENSION); 123 M_ASN1_New_Malloc(ret,X509_EXTENSION);
128 ret->object=OBJ_nid2obj(NID_undef); 124 ret->object=OBJ_nid2obj(NID_undef);
129 M_ASN1_New(ret->value,ASN1_OCTET_STRING_new); 125 M_ASN1_New(ret->value,M_ASN1_OCTET_STRING_new);
130 ret->critical=0; 126 ret->critical=0;
131 ret->netscape_hack=0; 127 ret->netscape_hack=0;
132 ret->argl=0L;
133 ret->argp=NULL;
134 ret->ex_free=NULL;
135 return(ret); 128 return(ret);
136 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW); 129 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW);
137 } 130 }
@@ -139,10 +132,8 @@ X509_EXTENSION *X509_EXTENSION_new(void)
139void X509_EXTENSION_free(X509_EXTENSION *a) 132void X509_EXTENSION_free(X509_EXTENSION *a)
140 { 133 {
141 if (a == NULL) return; 134 if (a == NULL) return;
142 if ((a->argp != NULL) && (a->ex_free != NULL))
143 a->ex_free(a);
144 ASN1_OBJECT_free(a->object); 135 ASN1_OBJECT_free(a->object);
145 ASN1_OCTET_STRING_free(a->value); 136 M_ASN1_OCTET_STRING_free(a->value);
146 Free((char *)a); 137 Free(a);
147 } 138 }
148 139
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c
index 99ce011f07..7fdc6f9dc8 100644
--- a/src/lib/libcrypto/asn1/x_info.c
+++ b/src/lib/libcrypto/asn1/x_info.c
@@ -106,7 +106,8 @@ void X509_INFO_free(X509_INFO *x)
106 if (x->x509 != NULL) X509_free(x->x509); 106 if (x->x509 != NULL) X509_free(x->x509);
107 if (x->crl != NULL) X509_CRL_free(x->crl); 107 if (x->crl != NULL) X509_CRL_free(x->crl);
108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey); 108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey);
109 Free((char *)x); 109 if (x->enc_data != NULL) Free(x->enc_data);
110 Free(x);
110 } 111 }
111 112
112IMPLEMENT_STACK_OF(X509_INFO) 113IMPLEMENT_STACK_OF(X509_INFO)
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index b09fba33fb..64baf5719d 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -253,7 +253,7 @@ void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
253 { 253 {
254 if (a == NULL) return; 254 if (a == NULL) return;
255 ASN1_OBJECT_free(a->object); 255 ASN1_OBJECT_free(a->object);
256 ASN1_BIT_STRING_free(a->value); 256 M_ASN1_BIT_STRING_free(a->value);
257 Free(a); 257 Free(a);
258 } 258 }
259 259
diff --git a/src/lib/libcrypto/asn1/x_pkey.c b/src/lib/libcrypto/asn1/x_pkey.c
index b0057eb212..fe58919dbb 100644
--- a/src/lib/libcrypto/asn1/x_pkey.c
+++ b/src/lib/libcrypto/asn1/x_pkey.c
@@ -112,7 +112,7 @@ X509_PKEY *X509_PKEY_new(void)
112 M_ASN1_New_Malloc(ret,X509_PKEY); 112 M_ASN1_New_Malloc(ret,X509_PKEY);
113 ret->version=0; 113 ret->version=0;
114 M_ASN1_New(ret->enc_algor,X509_ALGOR_new); 114 M_ASN1_New(ret->enc_algor,X509_ALGOR_new);
115 M_ASN1_New(ret->enc_pkey,ASN1_OCTET_STRING_new); 115 M_ASN1_New(ret->enc_pkey,M_ASN1_OCTET_STRING_new);
116 ret->dec_pkey=NULL; 116 ret->dec_pkey=NULL;
117 ret->key_length=0; 117 ret->key_length=0;
118 ret->key_data=NULL; 118 ret->key_data=NULL;
@@ -144,8 +144,8 @@ void X509_PKEY_free(X509_PKEY *x)
144#endif 144#endif
145 145
146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor); 146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor);
147 if (x->enc_pkey != NULL) ASN1_OCTET_STRING_free(x->enc_pkey); 147 if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey);
148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey); 148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey);
149 if ((x->key_data != NULL) && (x->key_free)) Free((char *)x->key_data); 149 if ((x->key_data != NULL) && (x->key_free)) Free(x->key_data);
150 Free((char *)(char *)x); 150 Free(x);
151 } 151 }
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c
index 4ac32c59dd..81e9815222 100644
--- a/src/lib/libcrypto/asn1/x_pubkey.c
+++ b/src/lib/libcrypto/asn1/x_pubkey.c
@@ -100,7 +100,7 @@ X509_PUBKEY *X509_PUBKEY_new(void)
100 100
101 M_ASN1_New_Malloc(ret,X509_PUBKEY); 101 M_ASN1_New_Malloc(ret,X509_PUBKEY);
102 M_ASN1_New(ret->algor,X509_ALGOR_new); 102 M_ASN1_New(ret->algor,X509_ALGOR_new);
103 M_ASN1_New(ret->public_key,ASN1_BIT_STRING_new); 103 M_ASN1_New(ret->public_key,M_ASN1_BIT_STRING_new);
104 ret->pkey=NULL; 104 ret->pkey=NULL;
105 return(ret); 105 return(ret);
106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW); 106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW);
@@ -110,9 +110,9 @@ void X509_PUBKEY_free(X509_PUBKEY *a)
110 { 110 {
111 if (a == NULL) return; 111 if (a == NULL) return;
112 X509_ALGOR_free(a->algor); 112 X509_ALGOR_free(a->algor);
113 ASN1_BIT_STRING_free(a->public_key); 113 M_ASN1_BIT_STRING_free(a->public_key);
114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey); 114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey);
115 Free((char *)a); 115 Free(a);
116 } 116 }
117 117
118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) 118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
@@ -176,7 +176,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
176 if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err; 176 if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err;
177 p=s; 177 p=s;
178 i2d_PublicKey(pkey,&p); 178 i2d_PublicKey(pkey,&p);
179 if (!ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err; 179 if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err;
180 /* Set number of unused bits to zero */ 180 /* Set number of unused bits to zero */
181 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 181 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
182 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT; 182 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT;
@@ -252,3 +252,113 @@ err:
252 return(NULL); 252 return(NULL);
253 } 253 }
254 254
255/* Now two pseudo ASN1 routines that take an EVP_PKEY structure
256 * and encode or decode as X509_PUBKEY
257 */
258
259EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, unsigned char **pp,
260 long length)
261{
262 X509_PUBKEY *xpk;
263 EVP_PKEY *pktmp;
264 xpk = d2i_X509_PUBKEY(NULL, pp, length);
265 if(!xpk) return NULL;
266 pktmp = X509_PUBKEY_get(xpk);
267 X509_PUBKEY_free(xpk);
268 if(!pktmp) return NULL;
269 if(a) {
270 EVP_PKEY_free(*a);
271 *a = pktmp;
272 }
273 return pktmp;
274}
275
276int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
277{
278 X509_PUBKEY *xpk=NULL;
279 int ret;
280 if(!a) return 0;
281 if(!X509_PUBKEY_set(&xpk, a)) return 0;
282 ret = i2d_X509_PUBKEY(xpk, pp);
283 X509_PUBKEY_free(xpk);
284 return ret;
285}
286
287/* The following are equivalents but which return RSA and DSA
288 * keys
289 */
290#ifndef NO_RSA
291RSA *d2i_RSA_PUBKEY(RSA **a, unsigned char **pp,
292 long length)
293{
294 EVP_PKEY *pkey;
295 RSA *key;
296 unsigned char *q;
297 q = *pp;
298 pkey = d2i_PUBKEY(NULL, &q, length);
299 if(!pkey) return NULL;
300 key = EVP_PKEY_get1_RSA(pkey);
301 EVP_PKEY_free(pkey);
302 if(!key) return NULL;
303 *pp = q;
304 if(a) {
305 RSA_free(*a);
306 *a = key;
307 }
308 return key;
309}
310
311int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
312{
313 EVP_PKEY *pktmp;
314 int ret;
315 if(!a) return 0;
316 pktmp = EVP_PKEY_new();
317 if(!pktmp) {
318 ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE);
319 return 0;
320 }
321 EVP_PKEY_set1_RSA(pktmp, a);
322 ret = i2d_PUBKEY(pktmp, pp);
323 EVP_PKEY_free(pktmp);
324 return ret;
325}
326#endif
327
328#ifndef NO_DSA
329DSA *d2i_DSA_PUBKEY(DSA **a, unsigned char **pp,
330 long length)
331{
332 EVP_PKEY *pkey;
333 DSA *key;
334 unsigned char *q;
335 q = *pp;
336 pkey = d2i_PUBKEY(NULL, &q, length);
337 if(!pkey) return NULL;
338 key = EVP_PKEY_get1_DSA(pkey);
339 EVP_PKEY_free(pkey);
340 if(!key) return NULL;
341 *pp = q;
342 if(a) {
343 DSA_free(*a);
344 *a = key;
345 }
346 return key;
347}
348
349int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp)
350{
351 EVP_PKEY *pktmp;
352 int ret;
353 if(!a) return 0;
354 pktmp = EVP_PKEY_new();
355 if(!pktmp) {
356 ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE);
357 return 0;
358 }
359 EVP_PKEY_set1_DSA(pktmp, a);
360 ret = i2d_PUBKEY(pktmp, pp);
361 EVP_PKEY_free(pktmp);
362 return ret;
363}
364#endif
diff --git a/src/lib/libcrypto/asn1/x_req.c b/src/lib/libcrypto/asn1/x_req.c
index 9b1d6abe64..0cd572ee73 100644
--- a/src/lib/libcrypto/asn1/x_req.c
+++ b/src/lib/libcrypto/asn1/x_req.c
@@ -73,7 +73,7 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
73 * allow some CA Software to accept the cert request. 73 * allow some CA Software to accept the cert request.
74 * It is not following the PKCS standards ... 74 * It is not following the PKCS standards ...
75 * PKCS#10 pg 5 75 * PKCS#10 pg 5
76 * attributes [0] IMPLICIT Attibutes 76 * attributes [0] IMPLICIT Attributes
77 * NOTE: no OPTIONAL ... so it *must* be there 77 * NOTE: no OPTIONAL ... so it *must* be there
78 */ 78 */
79 if (a->req_kludge) 79 if (a->req_kludge)
@@ -94,7 +94,7 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
94 /* this is a *nasty* hack reported to be required by some CA's. 94 /* this is a *nasty* hack reported to be required by some CA's.
95 * It is not following the PKCS standards ... 95 * It is not following the PKCS standards ...
96 * PKCS#10 pg 5 96 * PKCS#10 pg 5
97 * attributes [0] IMPLICIT Attibutes 97 * attributes [0] IMPLICIT Attributes
98 * NOTE: no OPTIONAL ... so it *must* be there 98 * NOTE: no OPTIONAL ... so it *must* be there
99 */ 99 */
100 if (a->req_kludge) 100 if (a->req_kludge)
@@ -126,7 +126,7 @@ X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, unsigned char **pp,
126 * have been reported as requiring it. 126 * have been reported as requiring it.
127 * It is not following the PKCS standards ... 127 * It is not following the PKCS standards ...
128 * PKCS#10 pg 5 128 * PKCS#10 pg 5
129 * attributes [0] IMPLICIT Attibutes 129 * attributes [0] IMPLICIT Attributes
130 * NOTE: no OPTIONAL ... so it *must* be there 130 * NOTE: no OPTIONAL ... so it *must* be there
131 */ 131 */
132 if (asn1_Finish(&c)) 132 if (asn1_Finish(&c))
@@ -147,7 +147,7 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
147 ASN1_CTX c; 147 ASN1_CTX c;
148 148
149 M_ASN1_New_Malloc(ret,X509_REQ_INFO); 149 M_ASN1_New_Malloc(ret,X509_REQ_INFO);
150 M_ASN1_New(ret->version,ASN1_INTEGER_new); 150 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
151 M_ASN1_New(ret->subject,X509_NAME_new); 151 M_ASN1_New(ret->subject,X509_NAME_new);
152 M_ASN1_New(ret->pubkey,X509_PUBKEY_new); 152 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
153 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null); 153 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null);
@@ -159,11 +159,11 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
159void X509_REQ_INFO_free(X509_REQ_INFO *a) 159void X509_REQ_INFO_free(X509_REQ_INFO *a)
160 { 160 {
161 if (a == NULL) return; 161 if (a == NULL) return;
162 ASN1_INTEGER_free(a->version); 162 M_ASN1_INTEGER_free(a->version);
163 X509_NAME_free(a->subject); 163 X509_NAME_free(a->subject);
164 X509_PUBKEY_free(a->pubkey); 164 X509_PUBKEY_free(a->pubkey);
165 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free); 165 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free);
166 Free((char *)a); 166 Free(a);
167 } 167 }
168 168
169int i2d_X509_REQ(X509_REQ *a, unsigned char **pp) 169int i2d_X509_REQ(X509_REQ *a, unsigned char **pp)
@@ -203,7 +203,7 @@ X509_REQ *X509_REQ_new(void)
203 ret->references=1; 203 ret->references=1;
204 M_ASN1_New(ret->req_info,X509_REQ_INFO_new); 204 M_ASN1_New(ret->req_info,X509_REQ_INFO_new);
205 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 205 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
206 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 206 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
207 return(ret); 207 return(ret);
208 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW); 208 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW);
209 } 209 }
@@ -229,8 +229,8 @@ void X509_REQ_free(X509_REQ *a)
229 229
230 X509_REQ_INFO_free(a->req_info); 230 X509_REQ_INFO_free(a->req_info);
231 X509_ALGOR_free(a->sig_alg); 231 X509_ALGOR_free(a->sig_alg);
232 ASN1_BIT_STRING_free(a->signature); 232 M_ASN1_BIT_STRING_free(a->signature);
233 Free((char *)a); 233 Free(a);
234 } 234 }
235 235
236 236
diff --git a/src/lib/libcrypto/asn1/x_sig.c b/src/lib/libcrypto/asn1/x_sig.c
index c2782d1b9c..3559bd5368 100644
--- a/src/lib/libcrypto/asn1/x_sig.c
+++ b/src/lib/libcrypto/asn1/x_sig.c
@@ -94,7 +94,7 @@ X509_SIG *X509_SIG_new(void)
94 94
95 M_ASN1_New_Malloc(ret,X509_SIG); 95 M_ASN1_New_Malloc(ret,X509_SIG);
96 M_ASN1_New(ret->algor,X509_ALGOR_new); 96 M_ASN1_New(ret->algor,X509_ALGOR_new);
97 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); 97 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
98 return(ret); 98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW); 99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW);
100 } 100 }
@@ -103,8 +103,8 @@ void X509_SIG_free(X509_SIG *a)
103 { 103 {
104 if (a == NULL) return; 104 if (a == NULL) return;
105 X509_ALGOR_free(a->algor); 105 X509_ALGOR_free(a->algor);
106 ASN1_OCTET_STRING_free(a->digest); 106 M_ASN1_OCTET_STRING_free(a->digest);
107 Free((char *)a); 107 Free(a);
108 } 108 }
109 109
110 110
diff --git a/src/lib/libcrypto/asn1/x_spki.c b/src/lib/libcrypto/asn1/x_spki.c
index 43e0023839..8f5e7e6380 100644
--- a/src/lib/libcrypto/asn1/x_spki.c
+++ b/src/lib/libcrypto/asn1/x_spki.c
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59 /* This module was send to me my Pat Richards <patr@x509.com> who 59 /* This module was send to me my Pat Richards <patr@x509.com> who
60 * wrote it. It is under my Copyright with his permision 60 * wrote it. It is under my Copyright with his permission
61 */ 61 */
62 62
63#include <stdio.h> 63#include <stdio.h>
@@ -99,7 +99,7 @@ NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void)
99 99
100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC); 100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC);
101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new); 101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
102 M_ASN1_New(ret->challenge,ASN1_IA5STRING_new); 102 M_ASN1_New(ret->challenge,M_ASN1_IA5STRING_new);
103 return(ret); 103 return(ret);
104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW); 104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW);
105 } 105 }
@@ -108,8 +108,8 @@ void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a)
108 { 108 {
109 if (a == NULL) return; 109 if (a == NULL) return;
110 X509_PUBKEY_free(a->pubkey); 110 X509_PUBKEY_free(a->pubkey);
111 ASN1_IA5STRING_free(a->challenge); 111 M_ASN1_IA5STRING_free(a->challenge);
112 Free((char *)a); 112 Free(a);
113 } 113 }
114 114
115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp) 115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp)
@@ -150,7 +150,7 @@ NETSCAPE_SPKI *NETSCAPE_SPKI_new(void)
150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI); 150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI);
151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new); 151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new);
152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new); 152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new);
153 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 153 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
154 return(ret); 154 return(ret);
155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW); 155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW);
156 } 156 }
@@ -160,7 +160,7 @@ void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a)
160 if (a == NULL) return; 160 if (a == NULL) return;
161 NETSCAPE_SPKAC_free(a->spkac); 161 NETSCAPE_SPKAC_free(a->spkac);
162 X509_ALGOR_free(a->sig_algor); 162 X509_ALGOR_free(a->sig_algor);
163 ASN1_BIT_STRING_free(a->signature); 163 M_ASN1_BIT_STRING_free(a->signature);
164 Free((char *)a); 164 Free(a);
165 } 165 }
166 166
diff --git a/src/lib/libcrypto/asn1/x_val.c b/src/lib/libcrypto/asn1/x_val.c
index 84d6f7ca4d..1a2f49ffdf 100644
--- a/src/lib/libcrypto/asn1/x_val.c
+++ b/src/lib/libcrypto/asn1/x_val.c
@@ -93,8 +93,8 @@ X509_VAL *X509_VAL_new(void)
93 ASN1_CTX c; 93 ASN1_CTX c;
94 94
95 M_ASN1_New_Malloc(ret,X509_VAL); 95 M_ASN1_New_Malloc(ret,X509_VAL);
96 M_ASN1_New(ret->notBefore,ASN1_TIME_new); 96 M_ASN1_New(ret->notBefore,M_ASN1_TIME_new);
97 M_ASN1_New(ret->notAfter,ASN1_TIME_new); 97 M_ASN1_New(ret->notAfter,M_ASN1_TIME_new);
98 return(ret); 98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW); 99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW);
100 } 100 }
@@ -102,8 +102,8 @@ X509_VAL *X509_VAL_new(void)
102void X509_VAL_free(X509_VAL *a) 102void X509_VAL_free(X509_VAL *a)
103 { 103 {
104 if (a == NULL) return; 104 if (a == NULL) return;
105 ASN1_TIME_free(a->notBefore); 105 M_ASN1_TIME_free(a->notBefore);
106 ASN1_TIME_free(a->notAfter); 106 M_ASN1_TIME_free(a->notAfter);
107 Free((char *)a); 107 Free(a);
108 } 108 }
109 109
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c
index 7abf6b2a6b..11e564ea30 100644
--- a/src/lib/libcrypto/asn1/x_x509.c
+++ b/src/lib/libcrypto/asn1/x_x509.c
@@ -62,6 +62,9 @@
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65static int x509_meth_num = 0;
66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_meth = NULL;
67
65static ASN1_METHOD meth={ 68static ASN1_METHOD meth={
66 (int (*)()) i2d_X509, 69 (int (*)()) i2d_X509,
67 (char *(*)())d2i_X509, 70 (char *(*)())d2i_X509,
@@ -113,10 +116,13 @@ X509 *X509_new(void)
113 M_ASN1_New_Malloc(ret,X509); 116 M_ASN1_New_Malloc(ret,X509);
114 ret->references=1; 117 ret->references=1;
115 ret->valid=0; 118 ret->valid=0;
119 ret->ex_flags = 0;
116 ret->name=NULL; 120 ret->name=NULL;
121 ret->aux=NULL;
117 M_ASN1_New(ret->cert_info,X509_CINF_new); 122 M_ASN1_New(ret->cert_info,X509_CINF_new);
118 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 123 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
119 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 124 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
125 CRYPTO_new_ex_data(x509_meth, ret, &ret->ex_data);
120 return(ret); 126 return(ret);
121 M_ASN1_New_Error(ASN1_F_X509_NEW); 127 M_ASN1_New_Error(ASN1_F_X509_NEW);
122 } 128 }
@@ -140,12 +146,65 @@ void X509_free(X509 *a)
140 } 146 }
141#endif 147#endif
142 148
143 /* CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); */ 149 CRYPTO_free_ex_data(x509_meth,a,&a->ex_data);
144 X509_CINF_free(a->cert_info); 150 X509_CINF_free(a->cert_info);
145 X509_ALGOR_free(a->sig_alg); 151 X509_ALGOR_free(a->sig_alg);
146 ASN1_BIT_STRING_free(a->signature); 152 M_ASN1_BIT_STRING_free(a->signature);
153 X509_CERT_AUX_free(a->aux);
147 154
148 if (a->name != NULL) Free(a->name); 155 if (a->name != NULL) Free(a->name);
149 Free((char *)a); 156 Free(a);
157 }
158
159int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
160 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
161 {
162 x509_meth_num++;
163 return(CRYPTO_get_ex_new_index(x509_meth_num-1,
164 &x509_meth,argl,argp,new_func,dup_func,free_func));
165 }
166
167int X509_set_ex_data(X509 *r, int idx, void *arg)
168 {
169 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
150 } 170 }
151 171
172void *X509_get_ex_data(X509 *r, int idx)
173 {
174 return(CRYPTO_get_ex_data(&r->ex_data,idx));
175 }
176
177/* X509_AUX ASN1 routines. X509_AUX is the name given to
178 * a certificate with extra info tagged on the end. Since these
179 * functions set how a certificate is trusted they should only
180 * be used when the certificate comes from a reliable source
181 * such as local storage.
182 *
183 */
184
185X509 *d2i_X509_AUX(X509 **a, unsigned char **pp, long length)
186{
187 unsigned char *q;
188 X509 *ret;
189 /* Save start position */
190 q = *pp;
191 ret = d2i_X509(a, pp, length);
192 /* If certificate unreadable then forget it */
193 if(!ret) return NULL;
194 /* update length */
195 length -= *pp - q;
196 if(!length) return ret;
197 if(!d2i_X509_CERT_AUX(&ret->aux, pp, length)) goto err;
198 return ret;
199 err:
200 X509_free(ret);
201 return NULL;
202}
203
204int i2d_X509_AUX(X509 *a, unsigned char **pp)
205{
206 int length;
207 length = i2d_X509(a, pp);
208 if(a) length += i2d_X509_CERT_AUX(a->aux, pp);
209 return length;
210}
diff --git a/src/lib/libcrypto/asn1/x_x509a.c b/src/lib/libcrypto/asn1/x_x509a.c
new file mode 100644
index 0000000000..b9987ea968
--- /dev/null
+++ b/src/lib/libcrypto/asn1/x_x509a.c
@@ -0,0 +1,200 @@
1/* a_x509a.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/evp.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h>
64
65/* X509_CERT_AUX routines. These are used to encode additional
66 * user modifiable data about a certificate. This data is
67 * appended to the X509 encoding when the *_X509_AUX routines
68 * are used. This means that the "traditional" X509 routines
69 * will simply ignore the extra data.
70 */
71
72static X509_CERT_AUX *aux_get(X509 *x);
73
74X509_CERT_AUX *d2i_X509_CERT_AUX(X509_CERT_AUX **a, unsigned char **pp, long length)
75{
76 M_ASN1_D2I_vars(a, X509_CERT_AUX *, X509_CERT_AUX_new);
77
78 M_ASN1_D2I_Init();
79 M_ASN1_D2I_start_sequence();
80
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 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
129 M_ASN1_I2D_seq_total();
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
141static X509_CERT_AUX *aux_get(X509 *x)
142{
143 if(!x) return NULL;
144 if(!x->aux && !(x->aux = X509_CERT_AUX_new())) return NULL;
145 return x->aux;
146}
147
148int X509_alias_set1(X509 *x, unsigned char *name, int len)
149{
150 X509_CERT_AUX *aux;
151 if(!(aux = aux_get(x))) return 0;
152 if(!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) return 0;
153 return ASN1_STRING_set(aux->alias, name, len);
154}
155
156unsigned char *X509_alias_get0(X509 *x, int *len)
157{
158 if(!x->aux || !x->aux->alias) return NULL;
159 if(len) *len = x->aux->alias->length;
160 return x->aux->alias->data;
161}
162
163int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
164{
165 X509_CERT_AUX *aux;
166 ASN1_OBJECT *objtmp;
167 if(!(objtmp = OBJ_dup(obj))) return 0;
168 if(!(aux = aux_get(x))) return 0;
169 if(!aux->trust
170 && !(aux->trust = sk_ASN1_OBJECT_new_null())) return 0;
171 return sk_ASN1_OBJECT_push(aux->trust, objtmp);
172}
173
174int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
175{
176 X509_CERT_AUX *aux;
177 ASN1_OBJECT *objtmp;
178 if(!(objtmp = OBJ_dup(obj))) return 0;
179 if(!(aux = aux_get(x))) return 0;
180 if(!aux->reject
181 && !(aux->reject = sk_ASN1_OBJECT_new_null())) return 0;
182 return sk_ASN1_OBJECT_push(aux->reject, objtmp);
183}
184
185void X509_trust_clear(X509 *x)
186{
187 if(x->aux && x->aux->trust) {
188 sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free);
189 x->aux->trust = NULL;
190 }
191}
192
193void X509_reject_clear(X509 *x)
194{
195 if(x->aux && x->aux->reject) {
196 sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free);
197 x->aux->reject = NULL;
198 }
199}
200
diff --git a/src/lib/libcrypto/bf/bf_cbc.c b/src/lib/libcrypto/bf/bf_cbc.c
index 95d1cdcdf9..f949629dc6 100644
--- a/src/lib/libcrypto/bf/bf_cbc.c
+++ b/src/lib/libcrypto/bf/bf_cbc.c
@@ -59,8 +59,8 @@
59#include <openssl/blowfish.h> 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 62void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
63 BF_KEY *ks, unsigned char *iv, int encrypt) 63 const BF_KEY *schedule, unsigned char *ivec, int encrypt)
64 { 64 {
65 register BF_LONG tin0,tin1; 65 register BF_LONG tin0,tin1;
66 register BF_LONG tout0,tout1,xor0,xor1; 66 register BF_LONG tout0,tout1,xor0,xor1;
@@ -69,9 +69,9 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
69 69
70 if (encrypt) 70 if (encrypt)
71 { 71 {
72 n2l(iv,tout0); 72 n2l(ivec,tout0);
73 n2l(iv,tout1); 73 n2l(ivec,tout1);
74 iv-=8; 74 ivec-=8;
75 for (l-=8; l>=0; l-=8) 75 for (l-=8; l>=0; l-=8)
76 { 76 {
77 n2l(in,tin0); 77 n2l(in,tin0);
@@ -80,7 +80,7 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
80 tin1^=tout1; 80 tin1^=tout1;
81 tin[0]=tin0; 81 tin[0]=tin0;
82 tin[1]=tin1; 82 tin[1]=tin1;
83 BF_encrypt(tin,ks); 83 BF_encrypt(tin,schedule);
84 tout0=tin[0]; 84 tout0=tin[0];
85 tout1=tin[1]; 85 tout1=tin[1];
86 l2n(tout0,out); 86 l2n(tout0,out);
@@ -93,27 +93,27 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
93 tin1^=tout1; 93 tin1^=tout1;
94 tin[0]=tin0; 94 tin[0]=tin0;
95 tin[1]=tin1; 95 tin[1]=tin1;
96 BF_encrypt(tin,ks); 96 BF_encrypt(tin,schedule);
97 tout0=tin[0]; 97 tout0=tin[0];
98 tout1=tin[1]; 98 tout1=tin[1];
99 l2n(tout0,out); 99 l2n(tout0,out);
100 l2n(tout1,out); 100 l2n(tout1,out);
101 } 101 }
102 l2n(tout0,iv); 102 l2n(tout0,ivec);
103 l2n(tout1,iv); 103 l2n(tout1,ivec);
104 } 104 }
105 else 105 else
106 { 106 {
107 n2l(iv,xor0); 107 n2l(ivec,xor0);
108 n2l(iv,xor1); 108 n2l(ivec,xor1);
109 iv-=8; 109 ivec-=8;
110 for (l-=8; l>=0; l-=8) 110 for (l-=8; l>=0; l-=8)
111 { 111 {
112 n2l(in,tin0); 112 n2l(in,tin0);
113 n2l(in,tin1); 113 n2l(in,tin1);
114 tin[0]=tin0; 114 tin[0]=tin0;
115 tin[1]=tin1; 115 tin[1]=tin1;
116 BF_decrypt(tin,ks); 116 BF_decrypt(tin,schedule);
117 tout0=tin[0]^xor0; 117 tout0=tin[0]^xor0;
118 tout1=tin[1]^xor1; 118 tout1=tin[1]^xor1;
119 l2n(tout0,out); 119 l2n(tout0,out);
@@ -127,15 +127,15 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
127 n2l(in,tin1); 127 n2l(in,tin1);
128 tin[0]=tin0; 128 tin[0]=tin0;
129 tin[1]=tin1; 129 tin[1]=tin1;
130 BF_decrypt(tin,ks); 130 BF_decrypt(tin,schedule);
131 tout0=tin[0]^xor0; 131 tout0=tin[0]^xor0;
132 tout1=tin[1]^xor1; 132 tout1=tin[1]^xor1;
133 l2nn(tout0,tout1,out,l+8); 133 l2nn(tout0,tout1,out,l+8);
134 xor0=tin0; 134 xor0=tin0;
135 xor1=tin1; 135 xor1=tin1;
136 } 136 }
137 l2n(xor0,iv); 137 l2n(xor0,ivec);
138 l2n(xor1,iv); 138 l2n(xor1,ivec);
139 } 139 }
140 tin0=tin1=tout0=tout1=xor0=xor1=0; 140 tin0=tin1=tout0=tout1=xor0=xor1=0;
141 tin[0]=tin[1]=0; 141 tin[0]=tin[1]=0;
diff --git a/src/lib/libcrypto/bf/bf_cfb64.c b/src/lib/libcrypto/bf/bf_cfb64.c
index 1fb8905f49..6451c8d407 100644
--- a/src/lib/libcrypto/bf/bf_cfb64.c
+++ b/src/lib/libcrypto/bf/bf_cfb64.c
@@ -64,8 +64,8 @@
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66 66
67void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, 67void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
68 BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) 68 const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt)
69 { 69 {
70 register BF_LONG v0,v1,t; 70 register BF_LONG v0,v1,t;
71 register int n= *num; 71 register int n= *num;
diff --git a/src/lib/libcrypto/bf/bf_ecb.c b/src/lib/libcrypto/bf/bf_ecb.c
index 9f8a24cdff..341991636f 100644
--- a/src/lib/libcrypto/bf/bf_ecb.c
+++ b/src/lib/libcrypto/bf/bf_ecb.c
@@ -61,11 +61,11 @@
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' 63/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
64 * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, 64 * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
65 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) 65 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
66 */ 66 */
67 67
68const char *BF_version="BlowFish" OPENSSL_VERSION_PTEXT; 68const char *BF_version="Blowfish" OPENSSL_VERSION_PTEXT;
69 69
70const char *BF_options(void) 70const char *BF_options(void)
71 { 71 {
@@ -78,17 +78,17 @@ const char *BF_options(void)
78#endif 78#endif
79 } 79 }
80 80
81void BF_ecb_encrypt(unsigned char *in, unsigned char *out, BF_KEY *ks, 81void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
82 int encrypt) 82 const BF_KEY *key, int encrypt)
83 { 83 {
84 BF_LONG l,d[2]; 84 BF_LONG l,d[2];
85 85
86 n2l(in,l); d[0]=l; 86 n2l(in,l); d[0]=l;
87 n2l(in,l); d[1]=l; 87 n2l(in,l); d[1]=l;
88 if (encrypt) 88 if (encrypt)
89 BF_encrypt(d,ks); 89 BF_encrypt(d,key);
90 else 90 else
91 BF_decrypt(d,ks); 91 BF_decrypt(d,key);
92 l=d[0]; l2n(l,out); 92 l=d[0]; l2n(l,out);
93 l=d[1]; l2n(l,out); 93 l=d[1]; l2n(l,out);
94 l=d[0]=d[1]=0; 94 l=d[0]=d[1]=0;
diff --git a/src/lib/libcrypto/bf/bf_enc.c b/src/lib/libcrypto/bf/bf_enc.c
index ee01834561..b380acf959 100644
--- a/src/lib/libcrypto/bf/bf_enc.c
+++ b/src/lib/libcrypto/bf/bf_enc.c
@@ -60,7 +60,7 @@
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' 62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
63 * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, 63 * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
64 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) 64 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
65 */ 65 */
66 66
@@ -69,10 +69,11 @@
69to modify the code. 69to modify the code.
70#endif 70#endif
71 71
72void BF_encrypt(BF_LONG *data, BF_KEY *key) 72void BF_encrypt(BF_LONG *data, const BF_KEY *key)
73 { 73 {
74#ifndef BF_PTR2 74#ifndef BF_PTR2
75 register BF_LONG l,r,*p,*s; 75 register BF_LONG l,r;
76 const register BF_LONG *p,*s;
76 77
77 p=key->P; 78 p=key->P;
78 s= &(key->S[0]); 79 s= &(key->S[0]);
@@ -145,10 +146,11 @@ void BF_encrypt(BF_LONG *data, BF_KEY *key)
145 146
146#ifndef BF_DEFAULT_OPTIONS 147#ifndef BF_DEFAULT_OPTIONS
147 148
148void BF_decrypt(BF_LONG *data, BF_KEY *key) 149void BF_decrypt(BF_LONG *data, const BF_KEY *key)
149 { 150 {
150#ifndef BF_PTR2 151#ifndef BF_PTR2
151 register BF_LONG l,r,*p,*s; 152 register BF_LONG l,r;
153 const register BF_LONG *p,*s;
152 154
153 p=key->P; 155 p=key->P;
154 s= &(key->S[0]); 156 s= &(key->S[0]);
@@ -219,8 +221,8 @@ void BF_decrypt(BF_LONG *data, BF_KEY *key)
219#endif 221#endif
220 } 222 }
221 223
222void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 224void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
223 BF_KEY *ks, unsigned char *iv, int encrypt) 225 const BF_KEY *schedule, unsigned char *ivec, int encrypt)
224 { 226 {
225 register BF_LONG tin0,tin1; 227 register BF_LONG tin0,tin1;
226 register BF_LONG tout0,tout1,xor0,xor1; 228 register BF_LONG tout0,tout1,xor0,xor1;
@@ -229,9 +231,9 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
229 231
230 if (encrypt) 232 if (encrypt)
231 { 233 {
232 n2l(iv,tout0); 234 n2l(ivec,tout0);
233 n2l(iv,tout1); 235 n2l(ivec,tout1);
234 iv-=8; 236 ivec-=8;
235 for (l-=8; l>=0; l-=8) 237 for (l-=8; l>=0; l-=8)
236 { 238 {
237 n2l(in,tin0); 239 n2l(in,tin0);
@@ -240,7 +242,7 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
240 tin1^=tout1; 242 tin1^=tout1;
241 tin[0]=tin0; 243 tin[0]=tin0;
242 tin[1]=tin1; 244 tin[1]=tin1;
243 BF_encrypt(tin,ks); 245 BF_encrypt(tin,schedule);
244 tout0=tin[0]; 246 tout0=tin[0];
245 tout1=tin[1]; 247 tout1=tin[1];
246 l2n(tout0,out); 248 l2n(tout0,out);
@@ -253,27 +255,27 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
253 tin1^=tout1; 255 tin1^=tout1;
254 tin[0]=tin0; 256 tin[0]=tin0;
255 tin[1]=tin1; 257 tin[1]=tin1;
256 BF_encrypt(tin,ks); 258 BF_encrypt(tin,schedule);
257 tout0=tin[0]; 259 tout0=tin[0];
258 tout1=tin[1]; 260 tout1=tin[1];
259 l2n(tout0,out); 261 l2n(tout0,out);
260 l2n(tout1,out); 262 l2n(tout1,out);
261 } 263 }
262 l2n(tout0,iv); 264 l2n(tout0,ivec);
263 l2n(tout1,iv); 265 l2n(tout1,ivec);
264 } 266 }
265 else 267 else
266 { 268 {
267 n2l(iv,xor0); 269 n2l(ivec,xor0);
268 n2l(iv,xor1); 270 n2l(ivec,xor1);
269 iv-=8; 271 ivec-=8;
270 for (l-=8; l>=0; l-=8) 272 for (l-=8; l>=0; l-=8)
271 { 273 {
272 n2l(in,tin0); 274 n2l(in,tin0);
273 n2l(in,tin1); 275 n2l(in,tin1);
274 tin[0]=tin0; 276 tin[0]=tin0;
275 tin[1]=tin1; 277 tin[1]=tin1;
276 BF_decrypt(tin,ks); 278 BF_decrypt(tin,schedule);
277 tout0=tin[0]^xor0; 279 tout0=tin[0]^xor0;
278 tout1=tin[1]^xor1; 280 tout1=tin[1]^xor1;
279 l2n(tout0,out); 281 l2n(tout0,out);
@@ -287,15 +289,15 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
287 n2l(in,tin1); 289 n2l(in,tin1);
288 tin[0]=tin0; 290 tin[0]=tin0;
289 tin[1]=tin1; 291 tin[1]=tin1;
290 BF_decrypt(tin,ks); 292 BF_decrypt(tin,schedule);
291 tout0=tin[0]^xor0; 293 tout0=tin[0]^xor0;
292 tout1=tin[1]^xor1; 294 tout1=tin[1]^xor1;
293 l2nn(tout0,tout1,out,l+8); 295 l2nn(tout0,tout1,out,l+8);
294 xor0=tin0; 296 xor0=tin0;
295 xor1=tin1; 297 xor1=tin1;
296 } 298 }
297 l2n(xor0,iv); 299 l2n(xor0,ivec);
298 l2n(xor1,iv); 300 l2n(xor1,ivec);
299 } 301 }
300 tin0=tin1=tout0=tout1=xor0=xor1=0; 302 tin0=tin1=tout0=tout1=xor0=xor1=0;
301 tin[0]=tin[1]=0; 303 tin[0]=tin[1]=0;
diff --git a/src/lib/libcrypto/bf/bf_locl.h b/src/lib/libcrypto/bf/bf_locl.h
index 05756b5d3b..cc7c3ec992 100644
--- a/src/lib/libcrypto/bf/bf_locl.h
+++ b/src/lib/libcrypto/bf/bf_locl.h
@@ -148,7 +148,7 @@
148 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ 148 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
149 *((c)++)=(unsigned char)(((l) )&0xff)) 149 *((c)++)=(unsigned char)(((l) )&0xff))
150 150
151/* This is actually a big endian algorithm, the most significate byte 151/* This is actually a big endian algorithm, the most significant byte
152 * is used to lookup array 0 */ 152 * is used to lookup array 0 */
153 153
154#if defined(BF_PTR2) 154#if defined(BF_PTR2)
@@ -183,8 +183,8 @@
183 183
184/* 184/*
185 * This is normally very good on RISC platforms where normally you 185 * This is normally very good on RISC platforms where normally you
186 * have to explicitely "multiplicate" array index by sizeof(BF_LONG) 186 * have to explicitly "multiply" array index by sizeof(BF_LONG)
187 * in order to caclulate the effective address. This implementation 187 * in order to calculate the effective address. This implementation
188 * excuses CPU from this extra work. Power[PC] uses should have most 188 * excuses CPU from this extra work. Power[PC] uses should have most
189 * fun as (R>>BF_i)&BF_M gets folded into a single instruction, namely 189 * fun as (R>>BF_i)&BF_M gets folded into a single instruction, namely
190 * rlwinm. So let'em double-check if their compiler does it. 190 * rlwinm. So let'em double-check if their compiler does it.
diff --git a/src/lib/libcrypto/bf/bf_ofb64.c b/src/lib/libcrypto/bf/bf_ofb64.c
index 8ceb8d9bda..f2a9ff6e41 100644
--- a/src/lib/libcrypto/bf/bf_ofb64.c
+++ b/src/lib/libcrypto/bf/bf_ofb64.c
@@ -63,8 +63,8 @@
63 * used. The extra state information to record how much of the 63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, 66void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
67 BF_KEY *schedule, unsigned char *ivec, int *num) 67 const BF_KEY *schedule, unsigned char *ivec, int *num)
68 { 68 {
69 register BF_LONG v0,v1,t; 69 register BF_LONG v0,v1,t;
70 register int n= *num; 70 register int n= *num;
diff --git a/src/lib/libcrypto/bf/bf_opts.c b/src/lib/libcrypto/bf/bf_opts.c
index 5f330cc53c..bbe32b28c9 100644
--- a/src/lib/libcrypto/bf/bf_opts.c
+++ b/src/lib/libcrypto/bf/bf_opts.c
@@ -242,7 +242,7 @@ int main(int argc, char **argv)
242 } 242 }
243 243
244#ifndef TIMES 244#ifndef TIMES
245 fprintf(stderr,"To get the most acurate results, try to run this\n"); 245 fprintf(stderr,"To get the most accurate results, try to run this\n");
246 fprintf(stderr,"program when this computer is idle.\n"); 246 fprintf(stderr,"program when this computer is idle.\n");
247#endif 247#endif
248 248
diff --git a/src/lib/libcrypto/bf/bf_pi.h b/src/lib/libcrypto/bf/bf_pi.h
index 417b935538..9949513c68 100644
--- a/src/lib/libcrypto/bf/bf_pi.h
+++ b/src/lib/libcrypto/bf/bf_pi.h
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59static BF_KEY bf_init= { 59static const BF_KEY bf_init= {
60 { 60 {
61 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L, 61 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L,
62 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L, 62 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L,
diff --git a/src/lib/libcrypto/bf/bf_skey.c b/src/lib/libcrypto/bf/bf_skey.c
index eefa8e6f51..4d6a232fe0 100644
--- a/src/lib/libcrypto/bf/bf_skey.c
+++ b/src/lib/libcrypto/bf/bf_skey.c
@@ -62,11 +62,11 @@
62#include "bf_locl.h" 62#include "bf_locl.h"
63#include "bf_pi.h" 63#include "bf_pi.h"
64 64
65void BF_set_key(BF_KEY *key, int len, unsigned char *data) 65void BF_set_key(BF_KEY *key, int len, const unsigned char *data)
66 { 66 {
67 int i; 67 int i;
68 BF_LONG *p,ri,in[2]; 68 BF_LONG *p,ri,in[2];
69 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((char *)key,(char *)&bf_init,sizeof(BF_KEY));
diff --git a/src/lib/libcrypto/bf/bfspeed.c b/src/lib/libcrypto/bf/bfspeed.c
index 9b893e92cc..ecc9dff4e4 100644
--- a/src/lib/libcrypto/bf/bfspeed.c
+++ b/src/lib/libcrypto/bf/bfspeed.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
index 6ecd2609a9..5695250195 100644
--- a/src/lib/libcrypto/bf/bftest.c
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -76,18 +76,18 @@ int main(int argc, char *argv[])
76#include <openssl/ebcdic.h> 76#include <openssl/ebcdic.h>
77#endif 77#endif
78 78
79char *bf_key[2]={ 79static char *bf_key[2]={
80 "abcdefghijklmnopqrstuvwxyz", 80 "abcdefghijklmnopqrstuvwxyz",
81 "Who is John Galt?" 81 "Who is John Galt?"
82 }; 82 };
83 83
84/* big endian */ 84/* big endian */
85BF_LONG bf_plain[2][2]={ 85static BF_LONG bf_plain[2][2]={
86 {0x424c4f57L,0x46495348L}, 86 {0x424c4f57L,0x46495348L},
87 {0xfedcba98L,0x76543210L} 87 {0xfedcba98L,0x76543210L}
88 }; 88 };
89 89
90BF_LONG bf_cipher[2][2]={ 90static BF_LONG bf_cipher[2][2]={
91 {0x324ed0feL,0xf413a203L}, 91 {0x324ed0feL,0xf413a203L},
92 {0xcc91732bL,0x8022f684L} 92 {0xcc91732bL,0x8022f684L}
93 }; 93 };
@@ -228,16 +228,16 @@ static unsigned char ofb64_ok[]={
228 0x63,0xC2,0xCF,0x80,0xDA}; 228 0x63,0xC2,0xCF,0x80,0xDA};
229 229
230#define KEY_TEST_NUM 25 230#define KEY_TEST_NUM 25
231unsigned char key_test[KEY_TEST_NUM]={ 231static unsigned char key_test[KEY_TEST_NUM]={
232 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87, 232 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
233 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f, 233 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
234 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, 234 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
235 0x88}; 235 0x88};
236 236
237unsigned char key_data[8]= 237static unsigned char key_data[8]=
238 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}; 238 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
239 239
240unsigned char key_out[KEY_TEST_NUM][8]={ 240static unsigned char key_out[KEY_TEST_NUM][8]={
241 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E}, 241 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E},
242 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6}, 242 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6},
243 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3}, 243 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3},
diff --git a/src/lib/libcrypto/bf/blowfish.h b/src/lib/libcrypto/bf/blowfish.h
index 02f73b2f30..78acfd63b4 100644
--- a/src/lib/libcrypto/bf/blowfish.h
+++ b/src/lib/libcrypto/bf/blowfish.h
@@ -103,17 +103,19 @@ typedef struct bf_key_st
103 } BF_KEY; 103 } BF_KEY;
104 104
105 105
106void BF_set_key(BF_KEY *key, int len, unsigned char *data); 106void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
107void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key, 107
108 int enc); 108void BF_encrypt(BF_LONG *data,const BF_KEY *key);
109void BF_encrypt(BF_LONG *data,BF_KEY *key); 109void BF_decrypt(BF_LONG *data,const BF_KEY *key);
110void BF_decrypt(BF_LONG *data,BF_KEY *key); 110
111void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 111void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
112 BF_KEY *ks, unsigned char *iv, int enc); 112 const BF_KEY *key, int enc);
113void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, 113void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
114 BF_KEY *schedule, unsigned char *ivec, int *num, int enc); 114 const BF_KEY *schedule, unsigned char *ivec, int enc);
115void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, 115void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
116 BF_KEY *schedule, unsigned char *ivec, int *num); 116 const BF_KEY *schedule, unsigned char *ivec, int *num, int enc);
117void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
118 const BF_KEY *schedule, unsigned char *ivec, int *num);
117const char *BF_options(void); 119const char *BF_options(void);
118 120
119#ifdef __cplusplus 121#ifdef __cplusplus
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
index d9c381d263..2e7480ead9 100644
--- a/src/lib/libcrypto/bio/Makefile.ssl
+++ b/src/lib/libcrypto/bio/Makefile.ssl
@@ -90,17 +90,20 @@ b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
90b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 90b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
91b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 91b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
92b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 92b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
93b_dump.o: ../../include/openssl/stack.h ../cryptlib.h 93b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
94b_dump.o: ../cryptlib.h
94b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 95b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
95b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 96b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
96b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 97b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
97b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 98b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
98b_print.o: ../../include/openssl/stack.h ../cryptlib.h 99b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
100b_print.o: ../cryptlib.h
99b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 101b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
100b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 102b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
101b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 103b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 104b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
103b_sock.o: ../../include/openssl/stack.h ../cryptlib.h 105b_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
106b_sock.o: ../cryptlib.h
104bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 107bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
105bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 108bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
106bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 109bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -151,60 +154,65 @@ bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
151bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 154bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
152bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 155bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
153bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 156bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
154bio_cb.o: ../../include/openssl/stack.h ../cryptlib.h 157bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
158bio_cb.o: ../cryptlib.h
155bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 159bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
156bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h 160bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h
157bio_err.o: ../../include/openssl/stack.h 161bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
158bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 162bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
159bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 163bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
160bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 164bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
161bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 165bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
162bio_lib.o: ../../include/openssl/stack.h ../cryptlib.h 166bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
167bio_lib.o: ../cryptlib.h
163bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
164bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 169bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
165bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 170bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
166bss_acpt.o: ../../include/openssl/opensslconf.h 171bss_acpt.o: ../../include/openssl/opensslconf.h
167bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 172bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
168bss_acpt.o: ../cryptlib.h 173bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h
169bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 174bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
170bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h 175bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h
171bss_bio.o: ../../include/openssl/stack.h 176bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
172bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 177bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
173bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 178bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
174bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 179bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
175bss_conn.o: ../../include/openssl/opensslconf.h 180bss_conn.o: ../../include/openssl/opensslconf.h
176bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 181bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
177bss_conn.o: ../cryptlib.h 182bss_conn.o: ../../include/openssl/stack.h ../cryptlib.h
178bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 183bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
179bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 184bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
180bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 185bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
181bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 186bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
182bss_fd.o: ../../include/openssl/stack.h ../cryptlib.h bss_sock.c 187bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
188bss_fd.o: ../cryptlib.h bss_sock.c
183bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 189bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
184bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 190bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
185bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 191bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186bss_file.o: ../../include/openssl/opensslconf.h 192bss_file.o: ../../include/openssl/opensslconf.h
187bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 193bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
188bss_file.o: ../cryptlib.h 194bss_file.o: ../../include/openssl/stack.h ../cryptlib.h
189bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 195bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
190bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 196bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
191bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 197bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
192bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 198bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
193bss_log.o: ../../include/openssl/stack.h ../cryptlib.h 199bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
200bss_log.o: ../cryptlib.h
194bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 201bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
195bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 202bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
196bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 203bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
197bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 204bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
198bss_mem.o: ../../include/openssl/stack.h ../cryptlib.h 205bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
206bss_mem.o: ../cryptlib.h
199bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 207bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
200bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 208bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
201bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 209bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
202bss_null.o: ../../include/openssl/opensslconf.h 210bss_null.o: ../../include/openssl/opensslconf.h
203bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 211bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
204bss_null.o: ../cryptlib.h 212bss_null.o: ../../include/openssl/stack.h ../cryptlib.h
205bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 213bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
206bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 214bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
207bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 215bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
208bss_sock.o: ../../include/openssl/opensslconf.h 216bss_sock.o: ../../include/openssl/opensslconf.h
209bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 217bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
210bss_sock.o: ../cryptlib.h 218bss_sock.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c
index a7cd828978..f5aeb237f5 100644
--- a/src/lib/libcrypto/bio/b_dump.c
+++ b/src/lib/libcrypto/bio/b_dump.c
@@ -92,7 +92,7 @@ int BIO_dump(BIO *bio, const char *s, int len)
92 if (((i*DUMP_WIDTH)+j)>=len) { 92 if (((i*DUMP_WIDTH)+j)>=len) {
93 strcat(buf," "); 93 strcat(buf," ");
94 } else { 94 } else {
95 ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; 95 ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff;
96 sprintf(tmp,"%02x%c",ch,j==7?'-':' '); 96 sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
97 strcat(buf,tmp); 97 strcat(buf,tmp);
98 } 98 }
@@ -101,7 +101,7 @@ int BIO_dump(BIO *bio, const char *s, int len)
101 for(j=0;j<DUMP_WIDTH;j++) { 101 for(j=0;j<DUMP_WIDTH;j++) {
102 if (((i*DUMP_WIDTH)+j)>=len) 102 if (((i*DUMP_WIDTH)+j)>=len)
103 break; 103 break;
104 ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; 104 ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff;
105#ifndef CHARSET_EBCDIC 105#ifndef CHARSET_EBCDIC
106 sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); 106 sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
107#else 107#else
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index f448004298..2a5e8b58c9 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -62,26 +62,649 @@
62 62
63#include <stdio.h> 63#include <stdio.h>
64#include <stdarg.h> 64#include <stdarg.h>
65#include <string.h>
66#include <ctype.h>
65#include "cryptlib.h" 67#include "cryptlib.h"
68#ifndef NO_SYS_TYPES_H
69#include <sys/types.h>
70#endif
66#include <openssl/bio.h> 71#include <openssl/bio.h>
67 72
73#ifdef BN_LLONG
74# ifndef HAVE_LONG_LONG
75# define HAVE_LONG_LONG
76# endif
77#endif
78
79static void dopr (char *buffer, size_t maxlen, size_t *retlen,
80 const char *format, va_list args);
81
68int BIO_printf (BIO *bio, ...) 82int BIO_printf (BIO *bio, ...)
69 { 83 {
70 va_list args; 84 va_list args;
71 char *format; 85 char *format;
72 int ret; 86 int ret;
87 size_t retlen;
73 MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ 88 MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */
74 89
75 va_start(args, bio); 90 va_start(args, bio);
76 format=va_arg(args, char *); 91 format=va_arg(args, char *);
77 92
78 hugebuf[0]='\0'; 93 hugebuf[0]='\0';
79 94 dopr(hugebuf, sizeof(hugebuf), &retlen, format, args);
80 vsprintf(hugebuf,format,args); 95 ret=BIO_write(bio, hugebuf, (int)retlen);
81
82 ret=BIO_write(bio,hugebuf,strlen(hugebuf));
83 96
84 va_end(args); 97 va_end(args);
85 return(ret); 98 return(ret);
86 } 99 }
87 100
101/*
102 * Copyright Patrick Powell 1995
103 * This code is based on code written by Patrick Powell <papowell@astart.com>
104 * It may be used for any purpose as long as this notice remains intact
105 * on all source code distributions.
106 */
107
108/*
109 * This code contains numerious changes and enhancements which were
110 * made by lots of contributors over the last years to Patrick Powell's
111 * original code:
112 *
113 * o Patrick Powell <papowell@astart.com> (1995)
114 * o Brandon Long <blong@fiction.net> (1996, for Mutt)
115 * o Thomas Roessler <roessler@guug.de> (1998, for Mutt)
116 * o Michael Elkins <me@cs.hmc.edu> (1998, for Mutt)
117 * o Andrew Tridgell <tridge@samba.org> (1998, for Samba)
118 * o Luke Mewburn <lukem@netbsd.org> (1999, for LukemFTP)
119 * o Ralf S. Engelschall <rse@engelschall.com> (1999, for Pth)
120 */
121
122#if HAVE_LONG_DOUBLE
123#define LDOUBLE long double
124#else
125#define LDOUBLE double
126#endif
127
128#if HAVE_LONG_LONG
129#define LLONG long long
130#else
131#define LLONG long
132#endif
133
134static void fmtstr (char *, size_t *, size_t, char *, int, int, int);
135static void fmtint (char *, size_t *, size_t, LLONG, int, int, int, int);
136static void fmtfp (char *, size_t *, size_t, LDOUBLE, int, int, int);
137static void dopr_outch (char *, size_t *, size_t, int);
138
139/* format read states */
140#define DP_S_DEFAULT 0
141#define DP_S_FLAGS 1
142#define DP_S_MIN 2
143#define DP_S_DOT 3
144#define DP_S_MAX 4
145#define DP_S_MOD 5
146#define DP_S_CONV 6
147#define DP_S_DONE 7
148
149/* format flags - Bits */
150#define DP_F_MINUS (1 << 0)
151#define DP_F_PLUS (1 << 1)
152#define DP_F_SPACE (1 << 2)
153#define DP_F_NUM (1 << 3)
154#define DP_F_ZERO (1 << 4)
155#define DP_F_UP (1 << 5)
156#define DP_F_UNSIGNED (1 << 6)
157
158/* conversion flags */
159#define DP_C_SHORT 1
160#define DP_C_LONG 2
161#define DP_C_LDOUBLE 3
162#define DP_C_LLONG 4
163
164/* some handy macros */
165#define char_to_int(p) (p - '0')
166#define MAX(p,q) ((p >= q) ? p : q)
167
168static void
169dopr(
170 char *buffer,
171 size_t maxlen,
172 size_t *retlen,
173 const char *format,
174 va_list args)
175{
176 char ch;
177 LLONG value;
178 LDOUBLE fvalue;
179 char *strvalue;
180 int min;
181 int max;
182 int state;
183 int flags;
184 int cflags;
185 size_t currlen;
186
187 state = DP_S_DEFAULT;
188 flags = currlen = cflags = min = 0;
189 max = -1;
190 ch = *format++;
191
192 while (state != DP_S_DONE) {
193 if ((ch == '\0') || (currlen >= maxlen))
194 state = DP_S_DONE;
195
196 switch (state) {
197 case DP_S_DEFAULT:
198 if (ch == '%')
199 state = DP_S_FLAGS;
200 else
201 dopr_outch(buffer, &currlen, maxlen, ch);
202 ch = *format++;
203 break;
204 case DP_S_FLAGS:
205 switch (ch) {
206 case '-':
207 flags |= DP_F_MINUS;
208 ch = *format++;
209 break;
210 case '+':
211 flags |= DP_F_PLUS;
212 ch = *format++;
213 break;
214 case ' ':
215 flags |= DP_F_SPACE;
216 ch = *format++;
217 break;
218 case '#':
219 flags |= DP_F_NUM;
220 ch = *format++;
221 break;
222 case '0':
223 flags |= DP_F_ZERO;
224 ch = *format++;
225 break;
226 default:
227 state = DP_S_MIN;
228 break;
229 }
230 break;
231 case DP_S_MIN:
232 if (isdigit((unsigned char)ch)) {
233 min = 10 * min + char_to_int(ch);
234 ch = *format++;
235 } else if (ch == '*') {
236 min = va_arg(args, int);
237 ch = *format++;
238 state = DP_S_DOT;
239 } else
240 state = DP_S_DOT;
241 break;
242 case DP_S_DOT:
243 if (ch == '.') {
244 state = DP_S_MAX;
245 ch = *format++;
246 } else
247 state = DP_S_MOD;
248 break;
249 case DP_S_MAX:
250 if (isdigit((unsigned char)ch)) {
251 if (max < 0)
252 max = 0;
253 max = 10 * max + char_to_int(ch);
254 ch = *format++;
255 } else if (ch == '*') {
256 max = va_arg(args, int);
257 ch = *format++;
258 state = DP_S_MOD;
259 } else
260 state = DP_S_MOD;
261 break;
262 case DP_S_MOD:
263 switch (ch) {
264 case 'h':
265 cflags = DP_C_SHORT;
266 ch = *format++;
267 break;
268 case 'l':
269 if (*format == 'l') {
270 cflags = DP_C_LLONG;
271 format++;
272 } else
273 cflags = DP_C_LONG;
274 ch = *format++;
275 break;
276 case 'q':
277 cflags = DP_C_LLONG;
278 ch = *format++;
279 break;
280 case 'L':
281 cflags = DP_C_LDOUBLE;
282 ch = *format++;
283 break;
284 default:
285 break;
286 }
287 state = DP_S_CONV;
288 break;
289 case DP_S_CONV:
290 switch (ch) {
291 case 'd':
292 case 'i':
293 switch (cflags) {
294 case DP_C_SHORT:
295 value = (short int)va_arg(args, int);
296 break;
297 case DP_C_LONG:
298 value = va_arg(args, long int);
299 break;
300 case DP_C_LLONG:
301 value = va_arg(args, LLONG);
302 break;
303 default:
304 value = va_arg(args, int);
305 break;
306 }
307 fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags);
308 break;
309 case 'X':
310 flags |= DP_F_UP;
311 /* FALLTHROUGH */
312 case 'x':
313 case 'o':
314 case 'u':
315 flags |= DP_F_UNSIGNED;
316 switch (cflags) {
317 case DP_C_SHORT:
318 value = (unsigned short int)va_arg(args, unsigned int);
319 break;
320 case DP_C_LONG:
321 value = (LLONG) va_arg(args,
322 unsigned long int);
323 break;
324 case DP_C_LLONG:
325 value = va_arg(args, unsigned LLONG);
326 break;
327 default:
328 value = (LLONG) va_arg(args,
329 unsigned int);
330 break;
331 }
332 fmtint(buffer, &currlen, maxlen, value,
333 ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
334 min, max, flags);
335 break;
336 case 'f':
337 if (cflags == DP_C_LDOUBLE)
338 fvalue = va_arg(args, LDOUBLE);
339 else
340 fvalue = va_arg(args, double);
341 fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags);
342 break;
343 case 'E':
344 flags |= DP_F_UP;
345 case 'e':
346 if (cflags == DP_C_LDOUBLE)
347 fvalue = va_arg(args, LDOUBLE);
348 else
349 fvalue = va_arg(args, double);
350 break;
351 case 'G':
352 flags |= DP_F_UP;
353 case 'g':
354 if (cflags == DP_C_LDOUBLE)
355 fvalue = va_arg(args, LDOUBLE);
356 else
357 fvalue = va_arg(args, double);
358 break;
359 case 'c':
360 dopr_outch(buffer, &currlen, maxlen,
361 va_arg(args, int));
362 break;
363 case 's':
364 strvalue = va_arg(args, char *);
365 if (max < 0)
366 max = maxlen;
367 fmtstr(buffer, &currlen, maxlen, strvalue,
368 flags, min, max);
369 break;
370 case 'p':
371 value = (long)va_arg(args, void *);
372 fmtint(buffer, &currlen, maxlen,
373 value, 16, min, max, flags);
374 break;
375 case 'n': /* XXX */
376 if (cflags == DP_C_SHORT) {
377 short int *num;
378 num = va_arg(args, short int *);
379 *num = currlen;
380 } else if (cflags == DP_C_LONG) { /* XXX */
381 long int *num;
382 num = va_arg(args, long int *);
383 *num = (long int) currlen;
384 } else if (cflags == DP_C_LLONG) { /* XXX */
385 LLONG *num;
386 num = va_arg(args, LLONG *);
387 *num = (LLONG) currlen;
388 } else {
389 int *num;
390 num = va_arg(args, int *);
391 *num = currlen;
392 }
393 break;
394 case '%':
395 dopr_outch(buffer, &currlen, maxlen, ch);
396 break;
397 case 'w':
398 /* not supported yet, treat as next char */
399 ch = *format++;
400 break;
401 default:
402 /* unknown, skip */
403 break;
404 }
405 ch = *format++;
406 state = DP_S_DEFAULT;
407 flags = cflags = min = 0;
408 max = -1;
409 break;
410 case DP_S_DONE:
411 break;
412 default:
413 break;
414 }
415 }
416 if (currlen >= maxlen - 1)
417 currlen = maxlen - 1;
418 buffer[currlen] = '\0';
419 *retlen = currlen;
420 return;
421}
422
423static void
424fmtstr(
425 char *buffer,
426 size_t *currlen,
427 size_t maxlen,
428 char *value,
429 int flags,
430 int min,
431 int max)
432{
433 int padlen, strln;
434 int cnt = 0;
435
436 if (value == 0)
437 value = "<NULL>";
438 for (strln = 0; value[strln]; ++strln)
439 ;
440 padlen = min - strln;
441 if (padlen < 0)
442 padlen = 0;
443 if (flags & DP_F_MINUS)
444 padlen = -padlen;
445
446 while ((padlen > 0) && (cnt < max)) {
447 dopr_outch(buffer, currlen, maxlen, ' ');
448 --padlen;
449 ++cnt;
450 }
451 while (*value && (cnt < max)) {
452 dopr_outch(buffer, currlen, maxlen, *value++);
453 ++cnt;
454 }
455 while ((padlen < 0) && (cnt < max)) {
456 dopr_outch(buffer, currlen, maxlen, ' ');
457 ++padlen;
458 ++cnt;
459 }
460}
461
462static void
463fmtint(
464 char *buffer,
465 size_t *currlen,
466 size_t maxlen,
467 LLONG value,
468 int base,
469 int min,
470 int max,
471 int flags)
472{
473 int signvalue = 0;
474 unsigned LLONG uvalue;
475 char convert[20];
476 int place = 0;
477 int spadlen = 0;
478 int zpadlen = 0;
479 int caps = 0;
480
481 if (max < 0)
482 max = 0;
483 uvalue = value;
484 if (!(flags & DP_F_UNSIGNED)) {
485 if (value < 0) {
486 signvalue = '-';
487 uvalue = -value;
488 } else if (flags & DP_F_PLUS)
489 signvalue = '+';
490 else if (flags & DP_F_SPACE)
491 signvalue = ' ';
492 }
493 if (flags & DP_F_UP)
494 caps = 1;
495 do {
496 convert[place++] =
497 (caps ? "0123456789ABCDEF" : "0123456789abcdef")
498 [uvalue % (unsigned) base];
499 uvalue = (uvalue / (unsigned) base);
500 } while (uvalue && (place < 20));
501 if (place == 20)
502 place--;
503 convert[place] = 0;
504
505 zpadlen = max - place;
506 spadlen = min - MAX(max, place) - (signvalue ? 1 : 0);
507 if (zpadlen < 0)
508 zpadlen = 0;
509 if (spadlen < 0)
510 spadlen = 0;
511 if (flags & DP_F_ZERO) {
512 zpadlen = MAX(zpadlen, spadlen);
513 spadlen = 0;
514 }
515 if (flags & DP_F_MINUS)
516 spadlen = -spadlen;
517
518 /* spaces */
519 while (spadlen > 0) {
520 dopr_outch(buffer, currlen, maxlen, ' ');
521 --spadlen;
522 }
523
524 /* sign */
525 if (signvalue)
526 dopr_outch(buffer, currlen, maxlen, signvalue);
527
528 /* zeros */
529 if (zpadlen > 0) {
530 while (zpadlen > 0) {
531 dopr_outch(buffer, currlen, maxlen, '0');
532 --zpadlen;
533 }
534 }
535 /* digits */
536 while (place > 0)
537 dopr_outch(buffer, currlen, maxlen, convert[--place]);
538
539 /* left justified spaces */
540 while (spadlen < 0) {
541 dopr_outch(buffer, currlen, maxlen, ' ');
542 ++spadlen;
543 }
544 return;
545}
546
547static LDOUBLE
548abs_val(LDOUBLE value)
549{
550 LDOUBLE result = value;
551 if (value < 0)
552 result = -value;
553 return result;
554}
555
556static LDOUBLE
557pow10(int exp)
558{
559 LDOUBLE result = 1;
560 while (exp) {
561 result *= 10;
562 exp--;
563 }
564 return result;
565}
566
567static long
568round(LDOUBLE value)
569{
570 long intpart;
571 intpart = (long) value;
572 value = value - intpart;
573 if (value >= 0.5)
574 intpart++;
575 return intpart;
576}
577
578static void
579fmtfp(
580 char *buffer,
581 size_t *currlen,
582 size_t maxlen,
583 LDOUBLE fvalue,
584 int min,
585 int max,
586 int flags)
587{
588 int signvalue = 0;
589 LDOUBLE ufvalue;
590 char iconvert[20];
591 char fconvert[20];
592 int iplace = 0;
593 int fplace = 0;
594 int padlen = 0;
595 int zpadlen = 0;
596 int caps = 0;
597 long intpart;
598 long fracpart;
599
600 if (max < 0)
601 max = 6;
602 ufvalue = abs_val(fvalue);
603 if (fvalue < 0)
604 signvalue = '-';
605 else if (flags & DP_F_PLUS)
606 signvalue = '+';
607 else if (flags & DP_F_SPACE)
608 signvalue = ' ';
609
610 intpart = (long)ufvalue;
611
612 /* sorry, we only support 9 digits past the decimal because of our
613 conversion method */
614 if (max > 9)
615 max = 9;
616
617 /* we "cheat" by converting the fractional part to integer by
618 multiplying by a factor of 10 */
619 fracpart = round((pow10(max)) * (ufvalue - intpart));
620
621 if (fracpart >= pow10(max)) {
622 intpart++;
623 fracpart -= (long)pow10(max);
624 }
625
626 /* convert integer part */
627 do {
628 iconvert[iplace++] =
629 (caps ? "0123456789ABCDEF"
630 : "0123456789abcdef")[intpart % 10];
631 intpart = (intpart / 10);
632 } while (intpart && (iplace < 20));
633 if (iplace == 20)
634 iplace--;
635 iconvert[iplace] = 0;
636
637 /* convert fractional part */
638 do {
639 fconvert[fplace++] =
640 (caps ? "0123456789ABCDEF"
641 : "0123456789abcdef")[fracpart % 10];
642 fracpart = (fracpart / 10);
643 } while (fracpart && (fplace < 20));
644 if (fplace == 20)
645 fplace--;
646 fconvert[fplace] = 0;
647
648 /* -1 for decimal point, another -1 if we are printing a sign */
649 padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
650 zpadlen = max - fplace;
651 if (zpadlen < 0)
652 zpadlen = 0;
653 if (padlen < 0)
654 padlen = 0;
655 if (flags & DP_F_MINUS)
656 padlen = -padlen;
657
658 if ((flags & DP_F_ZERO) && (padlen > 0)) {
659 if (signvalue) {
660 dopr_outch(buffer, currlen, maxlen, signvalue);
661 --padlen;
662 signvalue = 0;
663 }
664 while (padlen > 0) {
665 dopr_outch(buffer, currlen, maxlen, '0');
666 --padlen;
667 }
668 }
669 while (padlen > 0) {
670 dopr_outch(buffer, currlen, maxlen, ' ');
671 --padlen;
672 }
673 if (signvalue)
674 dopr_outch(buffer, currlen, maxlen, signvalue);
675
676 while (iplace > 0)
677 dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
678
679 /*
680 * Decimal point. This should probably use locale to find the correct
681 * char to print out.
682 */
683 if (max > 0) {
684 dopr_outch(buffer, currlen, maxlen, '.');
685
686 while (fplace > 0)
687 dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
688 }
689 while (zpadlen > 0) {
690 dopr_outch(buffer, currlen, maxlen, '0');
691 --zpadlen;
692 }
693
694 while (padlen < 0) {
695 dopr_outch(buffer, currlen, maxlen, ' ');
696 ++padlen;
697 }
698}
699
700static void
701dopr_outch(
702 char *buffer,
703 size_t *currlen,
704 size_t maxlen,
705 int c)
706{
707 if (*currlen < maxlen)
708 buffer[(*currlen)++] = (char)c;
709 return;
710}
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index d29b29ff8b..6409f98f57 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -163,7 +163,14 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
163 else 163 else
164 { 164 {
165 CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME); 165 CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME);
166 s=getservbyname(str,"tcp"); 166 /* Note: under VMS with SOCKETSHR, it seems like the first
167 * parameter is 'char *', instead of 'const char *'
168 */
169 s=getservbyname(
170#ifndef CONST_STRICT
171 (char *)
172#endif
173 str,"tcp");
167 if(s != NULL) 174 if(s != NULL)
168 *port_ptr=ntohs((unsigned short)s->s_port); 175 *port_ptr=ntohs((unsigned short)s->s_port);
169 CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); 176 CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME);
@@ -282,12 +289,12 @@ static struct hostent *ghbn_dup(struct hostent *a)
282 289
283 j=strlen(a->h_name)+1; 290 j=strlen(a->h_name)+1;
284 if ((ret->h_name=Malloc(j)) == NULL) goto err; 291 if ((ret->h_name=Malloc(j)) == NULL) goto err;
285 memcpy((char *)ret->h_name,a->h_name,j+1); 292 memcpy((char *)ret->h_name,a->h_name,j);
286 for (i=0; a->h_aliases[i] != NULL; i++) 293 for (i=0; a->h_aliases[i] != NULL; i++)
287 { 294 {
288 j=strlen(a->h_aliases[i])+1; 295 j=strlen(a->h_aliases[i])+1;
289 if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err; 296 if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err;
290 memcpy(ret->h_aliases[i],a->h_aliases[i],j+1); 297 memcpy(ret->h_aliases[i],a->h_aliases[i],j);
291 } 298 }
292 ret->h_length=a->h_length; 299 ret->h_length=a->h_length;
293 ret->h_addrtype=a->h_addrtype; 300 ret->h_addrtype=a->h_addrtype;
@@ -327,7 +334,7 @@ static void ghbn_free(struct hostent *a)
327 Free(a->h_addr_list[i]); 334 Free(a->h_addr_list[i]);
328 Free(a->h_addr_list); 335 Free(a->h_addr_list);
329 } 336 }
330 if (a->h_name != NULL) Free((char *)a->h_name); 337 if (a->h_name != NULL) Free(a->h_name);
331 Free(a); 338 Free(a);
332 } 339 }
333 340
@@ -368,7 +375,14 @@ struct hostent *BIO_gethostbyname(const char *name)
368 if (i == GHBN_NUM) /* no hit*/ 375 if (i == GHBN_NUM) /* no hit*/
369 { 376 {
370 BIO_ghbn_miss++; 377 BIO_ghbn_miss++;
371 ret=gethostbyname(name); 378 /* Note: under VMS with SOCKETSHR, it seems like the first
379 * parameter is 'char *', instead of 'const char *'
380 */
381 ret=gethostbyname(
382#ifndef CONST_STRICT
383 (char *)
384#endif
385 name);
372 386
373 if (ret == NULL) 387 if (ret == NULL)
374 goto end; 388 goto end;
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index acd8148138..ff0c9070ae 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -69,6 +69,7 @@ static int buffer_gets(BIO *h,char *str,int size);
69static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int buffer_new(BIO *h); 70static int buffer_new(BIO *h);
71static int buffer_free(BIO *data); 71static int buffer_free(BIO *data);
72static long buffer_callback_ctrl(BIO *h,int cmd, void (*fp)());
72#define DEFAULT_BUFFER_SIZE 1024 73#define DEFAULT_BUFFER_SIZE 1024
73 74
74static BIO_METHOD methods_buffer= 75static BIO_METHOD methods_buffer=
@@ -82,6 +83,7 @@ static BIO_METHOD methods_buffer=
82 buffer_ctrl, 83 buffer_ctrl,
83 buffer_new, 84 buffer_new,
84 buffer_free, 85 buffer_free,
86 buffer_callback_ctrl,
85 }; 87 };
86 88
87BIO_METHOD *BIO_f_buffer(void) 89BIO_METHOD *BIO_f_buffer(void)
@@ -284,6 +286,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
284 ctx->ibuf_len=0; 286 ctx->ibuf_len=0;
285 ctx->obuf_off=0; 287 ctx->obuf_off=0;
286 ctx->obuf_len=0; 288 ctx->obuf_len=0;
289 if (b->next_bio == NULL) return(0);
287 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 290 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
288 break; 291 break;
289 case BIO_CTRL_INFO: 292 case BIO_CTRL_INFO:
@@ -300,12 +303,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
300 case BIO_CTRL_WPENDING: 303 case BIO_CTRL_WPENDING:
301 ret=(long)ctx->obuf_len; 304 ret=(long)ctx->obuf_len;
302 if (ret == 0) 305 if (ret == 0)
306 {
307 if (b->next_bio == NULL) return(0);
303 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 308 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
309 }
304 break; 310 break;
305 case BIO_CTRL_PENDING: 311 case BIO_CTRL_PENDING:
306 ret=(long)ctx->ibuf_len; 312 ret=(long)ctx->ibuf_len;
307 if (ret == 0) 313 if (ret == 0)
314 {
315 if (b->next_bio == NULL) return(0);
308 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 316 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
317 }
309 break; 318 break;
310 case BIO_C_SET_BUFF_READ_DATA: 319 case BIO_C_SET_BUFF_READ_DATA:
311 if (num > ctx->ibuf_size) 320 if (num > ctx->ibuf_size)
@@ -374,12 +383,14 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
374 } 383 }
375 break; 384 break;
376 case BIO_C_DO_STATE_MACHINE: 385 case BIO_C_DO_STATE_MACHINE:
386 if (b->next_bio == NULL) return(0);
377 BIO_clear_retry_flags(b); 387 BIO_clear_retry_flags(b);
378 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 388 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
379 BIO_copy_next_retry(b); 389 BIO_copy_next_retry(b);
380 break; 390 break;
381 391
382 case BIO_CTRL_FLUSH: 392 case BIO_CTRL_FLUSH:
393 if (b->next_bio == NULL) return(0);
383 if (ctx->obuf_len <= 0) 394 if (ctx->obuf_len <= 0)
384 { 395 {
385 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 396 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
@@ -418,6 +429,7 @@ fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_
418 ret=0; 429 ret=0;
419 break; 430 break;
420 default: 431 default:
432 if (b->next_bio == NULL) return(0);
421 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 433 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
422 break; 434 break;
423 } 435 }
@@ -427,6 +439,20 @@ malloc_error:
427 return(0); 439 return(0);
428 } 440 }
429 441
442static long buffer_callback_ctrl(BIO *b, int cmd, void (*fp)())
443 {
444 long ret=1;
445
446 if (b->next_bio == NULL) return(0);
447 switch (cmd)
448 {
449 default:
450 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
451 break;
452 }
453 return(ret);
454 }
455
430static int buffer_gets(BIO *b, char *buf, int size) 456static int buffer_gets(BIO *b, char *buf, int size)
431 { 457 {
432 BIO_F_BUFFER_CTX *ctx; 458 BIO_F_BUFFER_CTX *ctx;
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c
index cbec2bae29..5e574b7231 100644
--- a/src/lib/libcrypto/bio/bf_nbio.c
+++ b/src/lib/libcrypto/bio/bf_nbio.c
@@ -73,6 +73,7 @@ static int nbiof_gets(BIO *h,char *str,int size);
73static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2); 73static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2);
74static int nbiof_new(BIO *h); 74static int nbiof_new(BIO *h);
75static int nbiof_free(BIO *data); 75static int nbiof_free(BIO *data);
76static long nbiof_callback_ctrl(BIO *h,int cmd,void (*fp)());
76typedef struct nbio_test_st 77typedef struct nbio_test_st
77 { 78 {
78 /* only set if we sent a 'should retry' error */ 79 /* only set if we sent a 'should retry' error */
@@ -91,6 +92,7 @@ static BIO_METHOD methods_nbiof=
91 nbiof_ctrl, 92 nbiof_ctrl,
92 nbiof_new, 93 nbiof_new,
93 nbiof_free, 94 nbiof_free,
95 nbiof_callback_ctrl,
94 }; 96 };
95 97
96BIO_METHOD *BIO_f_nbio_test(void) 98BIO_METHOD *BIO_f_nbio_test(void)
@@ -137,7 +139,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
137 139
138 BIO_clear_retry_flags(b); 140 BIO_clear_retry_flags(b);
139#if 0 141#if 0
140 RAND_bytes(&n,1); 142 RAND_pseudo_bytes(&n,1);
141 num=(n&0x07); 143 num=(n&0x07);
142 144
143 if (outl > num) outl=num; 145 if (outl > num) outl=num;
@@ -178,7 +180,7 @@ static int nbiof_write(BIO *b, char *in, int inl)
178 } 180 }
179 else 181 else
180 { 182 {
181 RAND_bytes(&n,1); 183 RAND_pseudo_bytes(&n,1);
182 num=(n&7); 184 num=(n&7);
183 } 185 }
184 186
@@ -224,6 +226,20 @@ static long nbiof_ctrl(BIO *b, int cmd, long num, char *ptr)
224 return(ret); 226 return(ret);
225 } 227 }
226 228
229static long nbiof_callback_ctrl(BIO *b, int cmd, void (*fp)())
230 {
231 long ret=1;
232
233 if (b->next_bio == NULL) return(0);
234 switch (cmd)
235 {
236 default:
237 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
238 break;
239 }
240 return(ret);
241 }
242
227static int nbiof_gets(BIO *bp, char *buf, int size) 243static int nbiof_gets(BIO *bp, char *buf, int size)
228 { 244 {
229 if (bp->next_bio == NULL) return(0); 245 if (bp->next_bio == NULL) return(0);
diff --git a/src/lib/libcrypto/bio/bf_null.c b/src/lib/libcrypto/bio/bf_null.c
index 3254a55dce..0d183a6d9a 100644
--- a/src/lib/libcrypto/bio/bf_null.c
+++ b/src/lib/libcrypto/bio/bf_null.c
@@ -72,6 +72,7 @@ static int nullf_gets(BIO *h,char *str,int size);
72static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2); 72static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2);
73static int nullf_new(BIO *h); 73static int nullf_new(BIO *h);
74static int nullf_free(BIO *data); 74static int nullf_free(BIO *data);
75static long nullf_callback_ctrl(BIO *h,int cmd,void (*fp)());
75static BIO_METHOD methods_nullf= 76static BIO_METHOD methods_nullf=
76 { 77 {
77 BIO_TYPE_NULL_FILTER, 78 BIO_TYPE_NULL_FILTER,
@@ -83,6 +84,7 @@ static BIO_METHOD methods_nullf=
83 nullf_ctrl, 84 nullf_ctrl,
84 nullf_new, 85 nullf_new,
85 nullf_free, 86 nullf_free,
87 nullf_callback_ctrl,
86 }; 88 };
87 89
88BIO_METHOD *BIO_f_null(void) 90BIO_METHOD *BIO_f_null(void)
@@ -152,6 +154,20 @@ static long nullf_ctrl(BIO *b, int cmd, long num, char *ptr)
152 return(ret); 154 return(ret);
153 } 155 }
154 156
157static long nullf_callback_ctrl(BIO *b, int cmd, void (*fp)())
158 {
159 long ret=1;
160
161 if (b->next_bio == NULL) return(0);
162 switch (cmd)
163 {
164 default:
165 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
166 break;
167 }
168 return(ret);
169 }
170
155static int nullf_gets(BIO *bp, char *buf, int size) 171static int nullf_gets(BIO *bp, char *buf, int size)
156 { 172 {
157 if (bp->next_bio == NULL) return(0); 173 if (bp->next_bio == NULL) return(0);
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index 54bf622a3b..bc08401eeb 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -76,7 +76,7 @@ extern "C" {
76#define BIO_TYPE_SOCKET (5|0x0400|0x0100) 76#define BIO_TYPE_SOCKET (5|0x0400|0x0100)
77#define BIO_TYPE_NULL (6|0x0400) 77#define BIO_TYPE_NULL (6|0x0400)
78#define BIO_TYPE_SSL (7|0x0200) 78#define BIO_TYPE_SSL (7|0x0200)
79#define BIO_TYPE_MD (8|0x0200) /* pasive filter */ 79#define BIO_TYPE_MD (8|0x0200) /* passive filter */
80#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ 80#define BIO_TYPE_BUFFER (9|0x0200) /* filter */
81#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ 81#define BIO_TYPE_CIPHER (10|0x0200) /* filter */
82#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ 82#define BIO_TYPE_BASE64 (11|0x0200) /* filter */
@@ -147,6 +147,11 @@ extern "C" {
147 147
148#define BIO_FLAGS_BASE64_NO_NL 0x100 148#define BIO_FLAGS_BASE64_NO_NL 0x100
149 149
150/* This is used with memory BIOs: it means we shouldn't free up or change the
151 * data in any way.
152 */
153#define BIO_FLAGS_MEM_RDONLY 0x200
154
150#define BIO_set_flags(b,f) ((b)->flags|=(f)) 155#define BIO_set_flags(b,f) ((b)->flags|=(f))
151#define BIO_get_flags(b) ((b)->flags) 156#define BIO_get_flags(b) ((b)->flags)
152#define BIO_set_retry_special(b) \ 157#define BIO_set_retry_special(b) \
@@ -163,7 +168,7 @@ extern "C" {
163#define BIO_get_retry_flags(b) \ 168#define BIO_get_retry_flags(b) \
164 ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) 169 ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
165 170
166/* These shouldbe used by the application to tell why we should retry */ 171/* These should be used by the application to tell why we should retry */
167#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ) 172#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
168#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE) 173#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
169#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL) 174#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
@@ -214,6 +219,7 @@ typedef struct bio_method_st
214 long (*ctrl)(); 219 long (*ctrl)();
215 int (*create)(); 220 int (*create)();
216 int (*destroy)(); 221 int (*destroy)();
222 long (*callback_ctrl)();
217 } BIO_METHOD; 223 } BIO_METHOD;
218#else 224#else
219typedef struct bio_method_st 225typedef struct bio_method_st
@@ -227,6 +233,7 @@ typedef struct bio_method_st
227 long (_far *ctrl)(); 233 long (_far *ctrl)();
228 int (_far *create)(); 234 int (_far *create)();
229 int (_far *destroy)(); 235 int (_far *destroy)();
236 long (_fat *callback_ctrl)();
230 } BIO_METHOD; 237 } BIO_METHOD;
231#endif 238#endif
232 239
@@ -278,9 +285,6 @@ typedef struct bio_f_buffer_ctx_struct
278#define BIO_CONN_S_NBIO 8 285#define BIO_CONN_S_NBIO 8
279/*#define BIO_CONN_get_param_hostname BIO_ctrl */ 286/*#define BIO_CONN_get_param_hostname BIO_ctrl */
280 287
281#define BIO_number_read(b) ((b)->num_read)
282#define BIO_number_written(b) ((b)->num_write)
283
284#define BIO_C_SET_CONNECT 100 288#define BIO_C_SET_CONNECT 100
285#define BIO_C_DO_STATE_MACHINE 101 289#define BIO_C_DO_STATE_MACHINE 101
286#define BIO_C_SET_NBIO 102 290#define BIO_C_SET_NBIO 102
@@ -325,9 +329,14 @@ typedef struct bio_f_buffer_ctx_struct
325#define BIO_C_GET_WRITE_GUARANTEE 140 329#define BIO_C_GET_WRITE_GUARANTEE 140
326#define BIO_C_GET_READ_REQUEST 141 330#define BIO_C_GET_READ_REQUEST 141
327#define BIO_C_SHUTDOWN_WR 142 331#define BIO_C_SHUTDOWN_WR 142
332#define BIO_C_NREAD0 143
333#define BIO_C_NREAD 144
334#define BIO_C_NWRITE0 145
335#define BIO_C_NWRITE 146
336#define BIO_C_RESET_READ_REQUEST 147
328 337
329 338
330#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,(char *)arg) 339#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
331#define BIO_get_app_data(s) BIO_get_ex_data(s,0) 340#define BIO_get_app_data(s) BIO_get_ex_data(s,0)
332 341
333/* BIO_s_connect() and BIO_s_socks4a_connect() */ 342/* BIO_s_connect() and BIO_s_socks4a_connect() */
@@ -366,7 +375,7 @@ typedef struct bio_f_buffer_ctx_struct
366/* BIO_set_nbio(b,n) */ 375/* BIO_set_nbio(b,n) */
367#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) 376#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
368/* BIO *BIO_get_filter_bio(BIO *bio); */ 377/* BIO *BIO_get_filter_bio(BIO *bio); */
369#define BIO_set_proxy_cb(b,cb) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(char *)(cb)) 378#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
370#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) 379#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
371#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) 380#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
372 381
@@ -445,8 +454,8 @@ int BIO_read_filename(BIO *b,const char *name);
445size_t BIO_ctrl_pending(BIO *b); 454size_t BIO_ctrl_pending(BIO *b);
446size_t BIO_ctrl_wpending(BIO *b); 455size_t BIO_ctrl_wpending(BIO *b);
447#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) 456#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
448#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(char *)cbp) 457#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(void (**)())(cbp))
449#define BIO_set_info_callback(b,cb) (int)BIO_ctrl(b,BIO_CTRL_SET_CALLBACK,0,(char *)cb) 458#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(void (*)())(cb))
450 459
451/* For the BIO_f_buffer() type */ 460/* For the BIO_f_buffer() type */
452#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) 461#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
@@ -461,8 +470,7 @@ size_t BIO_ctrl_wpending(BIO *b);
461#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) 470#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
462size_t BIO_ctrl_get_write_guarantee(BIO *b); 471size_t BIO_ctrl_get_write_guarantee(BIO *b);
463size_t BIO_ctrl_get_read_request(BIO *b); 472size_t BIO_ctrl_get_read_request(BIO *b);
464 473int BIO_ctrl_reset_read_request(BIO *b);
465
466 474
467#ifdef NO_STDIO 475#ifdef NO_STDIO
468#define NO_FP_API 476#define NO_FP_API
@@ -472,10 +480,12 @@ size_t BIO_ctrl_get_read_request(BIO *b);
472/* These two aren't currently implemented */ 480/* These two aren't currently implemented */
473/* int BIO_get_ex_num(BIO *bio); */ 481/* int BIO_get_ex_num(BIO *bio); */
474/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ 482/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
475int BIO_set_ex_data(BIO *bio,int idx,char *data); 483int BIO_set_ex_data(BIO *bio,int idx,void *data);
476char *BIO_get_ex_data(BIO *bio,int idx); 484void *BIO_get_ex_data(BIO *bio,int idx);
477int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), 485int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
478 int (*dup_func)(), void (*free_func)()); 486 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
487unsigned long BIO_number_read(BIO *bio);
488unsigned long BIO_number_written(BIO *bio);
479 489
480# if defined(WIN16) && defined(_WINDLL) 490# if defined(WIN16) && defined(_WINDLL)
481BIO_METHOD *BIO_s_file_internal(void); 491BIO_METHOD *BIO_s_file_internal(void);
@@ -500,6 +510,7 @@ int BIO_gets(BIO *bp,char *buf, int size);
500int BIO_write(BIO *b, const char *data, int len); 510int BIO_write(BIO *b, const char *data, int len);
501int BIO_puts(BIO *bp,const char *buf); 511int BIO_puts(BIO *bp,const char *buf);
502long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); 512long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
513long BIO_callback_ctrl(BIO *bp,int cmd,void (*fp)());
503char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); 514char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
504long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); 515long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
505BIO * BIO_push(BIO *b,BIO *append); 516BIO * BIO_push(BIO *b,BIO *append);
@@ -510,6 +521,11 @@ BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
510int BIO_get_retry_reason(BIO *bio); 521int BIO_get_retry_reason(BIO *bio);
511BIO * BIO_dup_chain(BIO *in); 522BIO * BIO_dup_chain(BIO *in);
512 523
524int BIO_nread0(BIO *bio, char **buf);
525int BIO_nread(BIO *bio, char **buf, int num);
526int BIO_nwrite0(BIO *bio, char **buf);
527int BIO_nwrite(BIO *bio, char **buf, int num);
528
513#ifndef WIN16 529#ifndef WIN16
514long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, 530long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
515 long argl,long ret); 531 long argl,long ret);
@@ -519,6 +535,7 @@ long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
519#endif 535#endif
520 536
521BIO_METHOD *BIO_s_mem(void); 537BIO_METHOD *BIO_s_mem(void);
538BIO *BIO_new_mem_buf(void *buf, int len);
522BIO_METHOD *BIO_s_socket(void); 539BIO_METHOD *BIO_s_socket(void);
523BIO_METHOD *BIO_s_connect(void); 540BIO_METHOD *BIO_s_connect(void);
524BIO_METHOD *BIO_s_accept(void); 541BIO_METHOD *BIO_s_accept(void);
@@ -597,11 +614,17 @@ int BIO_printf(BIO *bio, ...);
597#define BIO_F_BIO_MAKE_PAIR 121 614#define BIO_F_BIO_MAKE_PAIR 121
598#define BIO_F_BIO_NEW 108 615#define BIO_F_BIO_NEW 108
599#define BIO_F_BIO_NEW_FILE 109 616#define BIO_F_BIO_NEW_FILE 109
617#define BIO_F_BIO_NEW_MEM_BUF 126
618#define BIO_F_BIO_NREAD 123
619#define BIO_F_BIO_NREAD0 124
620#define BIO_F_BIO_NWRITE 125
621#define BIO_F_BIO_NWRITE0 122
600#define BIO_F_BIO_PUTS 110 622#define BIO_F_BIO_PUTS 110
601#define BIO_F_BIO_READ 111 623#define BIO_F_BIO_READ 111
602#define BIO_F_BIO_SOCK_INIT 112 624#define BIO_F_BIO_SOCK_INIT 112
603#define BIO_F_BIO_WRITE 113 625#define BIO_F_BIO_WRITE 113
604#define BIO_F_BUFFER_CTRL 114 626#define BIO_F_BUFFER_CTRL 114
627#define BIO_F_CONN_CTRL 127
605#define BIO_F_CONN_STATE 115 628#define BIO_F_CONN_STATE 115
606#define BIO_F_FILE_CTRL 116 629#define BIO_F_FILE_CTRL 116
607#define BIO_F_MEM_WRITE 117 630#define BIO_F_MEM_WRITE 117
@@ -634,6 +657,7 @@ int BIO_printf(BIO *bio, ...);
634#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 657#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
635#define BIO_R_UNINITIALIZED 120 658#define BIO_R_UNINITIALIZED 120
636#define BIO_R_UNSUPPORTED_METHOD 121 659#define BIO_R_UNSUPPORTED_METHOD 121
660#define BIO_R_WRITE_TO_READ_ONLY_BIO 126
637#define BIO_R_WSASTARTUP 122 661#define BIO_R_WSASTARTUP 122
638 662
639#ifdef __cplusplus 663#ifdef __cplusplus
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c
index 712d98a3a1..b5f07de5a0 100644
--- a/src/lib/libcrypto/bio/bio_err.c
+++ b/src/lib/libcrypto/bio/bio_err.c
@@ -77,11 +77,17 @@ static ERR_STRING_DATA BIO_str_functs[]=
77{ERR_PACK(0,BIO_F_BIO_MAKE_PAIR,0), "BIO_MAKE_PAIR"}, 77{ERR_PACK(0,BIO_F_BIO_MAKE_PAIR,0), "BIO_MAKE_PAIR"},
78{ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"}, 78{ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"},
79{ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"}, 79{ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"},
80{ERR_PACK(0,BIO_F_BIO_NEW_MEM_BUF,0), "BIO_new_mem_buf"},
81{ERR_PACK(0,BIO_F_BIO_NREAD,0), "BIO_nread"},
82{ERR_PACK(0,BIO_F_BIO_NREAD0,0), "BIO_nread0"},
83{ERR_PACK(0,BIO_F_BIO_NWRITE,0), "BIO_nwrite"},
84{ERR_PACK(0,BIO_F_BIO_NWRITE0,0), "BIO_nwrite0"},
80{ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"}, 85{ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"},
81{ERR_PACK(0,BIO_F_BIO_READ,0), "BIO_read"}, 86{ERR_PACK(0,BIO_F_BIO_READ,0), "BIO_read"},
82{ERR_PACK(0,BIO_F_BIO_SOCK_INIT,0), "BIO_sock_init"}, 87{ERR_PACK(0,BIO_F_BIO_SOCK_INIT,0), "BIO_sock_init"},
83{ERR_PACK(0,BIO_F_BIO_WRITE,0), "BIO_write"}, 88{ERR_PACK(0,BIO_F_BIO_WRITE,0), "BIO_write"},
84{ERR_PACK(0,BIO_F_BUFFER_CTRL,0), "BUFFER_CTRL"}, 89{ERR_PACK(0,BIO_F_BUFFER_CTRL,0), "BUFFER_CTRL"},
90{ERR_PACK(0,BIO_F_CONN_CTRL,0), "CONN_CTRL"},
85{ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"}, 91{ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"},
86{ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"}, 92{ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"},
87{ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"}, 93{ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"},
@@ -117,6 +123,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
117{BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"}, 123{BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"},
118{BIO_R_UNINITIALIZED ,"uninitialized"}, 124{BIO_R_UNINITIALIZED ,"uninitialized"},
119{BIO_R_UNSUPPORTED_METHOD ,"unsupported method"}, 125{BIO_R_UNSUPPORTED_METHOD ,"unsupported method"},
126{BIO_R_WRITE_TO_READ_ONLY_BIO ,"write to read only bio"},
120{BIO_R_WSASTARTUP ,"wsastartup"}, 127{BIO_R_WSASTARTUP ,"wsastartup"},
121{0,NULL} 128{0,NULL}
122 }; 129 };
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index b72688ea90..cf8e6150fd 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -63,7 +63,7 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/stack.h> 64#include <openssl/stack.h>
65 65
66static STACK *bio_meth=NULL; 66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *bio_meth=NULL;
67static int bio_meth_num=0; 67static int bio_meth_num=0;
68 68
69BIO *BIO_new(BIO_METHOD *method) 69BIO *BIO_new(BIO_METHOD *method)
@@ -100,7 +100,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method)
100 bio->references=1; 100 bio->references=1;
101 bio->num_read=0L; 101 bio->num_read=0L;
102 bio->num_write=0L; 102 bio->num_write=0L;
103 CRYPTO_new_ex_data(bio_meth,(char *)bio,&bio->ex_data); 103 CRYPTO_new_ex_data(bio_meth,bio,&bio->ex_data);
104 if (method->create != NULL) 104 if (method->create != NULL)
105 if (!method->create(bio)) 105 if (!method->create(bio))
106 return(0); 106 return(0);
@@ -129,7 +129,7 @@ int BIO_free(BIO *a)
129 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) 129 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0))
130 return(i); 130 return(i);
131 131
132 CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); 132 CRYPTO_free_ex_data(bio_meth,a,&a->ex_data);
133 133
134 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); 134 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
135 ret=a->method->destroy(a); 135 ret=a->method->destroy(a);
@@ -317,16 +317,43 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
317 return(ret); 317 return(ret);
318 } 318 }
319 319
320long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)())
321 {
322 long ret;
323 long (*cb)();
324
325 if (b == NULL) return(0);
326
327 if ((b->method == NULL) || (b->method->callback_ctrl == NULL))
328 {
329 BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD);
330 return(-2);
331 }
332
333 cb=b->callback;
334
335 if ((cb != NULL) &&
336 ((ret=cb(b,BIO_CB_CTRL,(void *)&fp,cmd,0,1L)) <= 0))
337 return(ret);
338
339 ret=b->method->callback_ctrl(b,cmd,fp);
340
341 if (cb != NULL)
342 ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,(void *)&fp,cmd,
343 0,ret);
344 return(ret);
345 }
346
320/* It is unfortunate to duplicate in functions what the BIO_(w)pending macros 347/* It is unfortunate to duplicate in functions what the BIO_(w)pending macros
321 * do; but those macros have inappropriate return type, and for interfacing 348 * do; but those macros have inappropriate return type, and for interfacing
322 * from other programming languages, C macros aren't much of a help anyway. */ 349 * from other programming languages, C macros aren't much of a help anyway. */
323size_t BIO_ctrl_pending(BIO *bio) 350size_t BIO_ctrl_pending(BIO *bio)
324 { 351 {
325 return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); 352 return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL);
326 } 353 }
327 354
328size_t BIO_ctrl_wpending(BIO *bio) 355size_t BIO_ctrl_wpending(BIO *bio)
329 { 356 {
330 return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); 357 return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL);
331 } 358 }
332 359
@@ -476,21 +503,32 @@ void BIO_copy_next_retry(BIO *b)
476 b->retry_reason=b->next_bio->retry_reason; 503 b->retry_reason=b->next_bio->retry_reason;
477 } 504 }
478 505
479int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), 506int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
480 int (*dup_func)(), void (*free_func)()) 507 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
481 { 508 {
482 bio_meth_num++; 509 bio_meth_num++;
483 return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, 510 return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth,
484 argl,argp,new_func,dup_func,free_func)); 511 argl,argp,new_func,dup_func,free_func));
485 } 512 }
486 513
487int BIO_set_ex_data(BIO *bio, int idx, char *data) 514int BIO_set_ex_data(BIO *bio, int idx, void *data)
488 { 515 {
489 return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); 516 return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data));
490 } 517 }
491 518
492char *BIO_get_ex_data(BIO *bio, int idx) 519void *BIO_get_ex_data(BIO *bio, int idx)
493 { 520 {
494 return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); 521 return(CRYPTO_get_ex_data(&(bio->ex_data),idx));
495 } 522 }
496 523
524unsigned long BIO_number_read(BIO *bio)
525{
526 if(bio) return bio->num_read;
527 return 0;
528}
529
530unsigned long BIO_number_written(BIO *bio)
531{
532 if(bio) return bio->num_write;
533 return 0;
534}
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index 47af80f76d..9afa636406 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -118,6 +118,7 @@ static BIO_METHOD methods_acceptp=
118 acpt_ctrl, 118 acpt_ctrl,
119 acpt_new, 119 acpt_new,
120 acpt_free, 120 acpt_free,
121 NULL,
121 }; 122 };
122 123
123BIO_METHOD *BIO_s_accept(void) 124BIO_METHOD *BIO_s_accept(void)
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 562e9d8de2..0d0f9356f7 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -13,6 +13,7 @@
13#endif 13#endif
14 14
15#include <assert.h> 15#include <assert.h>
16#include <limits.h>
16#include <stdlib.h> 17#include <stdlib.h>
17#include <string.h> 18#include <string.h>
18 19
@@ -40,7 +41,8 @@ static BIO_METHOD methods_biop =
40 NULL /* no bio_gets */, 41 NULL /* no bio_gets */,
41 bio_ctrl, 42 bio_ctrl,
42 bio_new, 43 bio_new,
43 bio_free 44 bio_free,
45 NULL /* no bio_callback_ctrl */
44}; 46};
45 47
46BIO_METHOD *BIO_s_bio(void) 48BIO_METHOD *BIO_s_bio(void)
@@ -64,7 +66,7 @@ struct bio_bio_st
64 66
65 size_t request; /* valid iff peer != NULL; 0 if len != 0, 67 size_t request; /* valid iff peer != NULL; 0 if len != 0,
66 * otherwise set by peer to number of bytes 68 * otherwise set by peer to number of bytes
67 * it (unsuccesfully) tried to read, 69 * it (unsuccessfully) tried to read,
68 * never more than buffer space (size-len) warrants. */ 70 * never more than buffer space (size-len) warrants. */
69}; 71};
70 72
@@ -195,6 +197,81 @@ static int bio_read(BIO *bio, char *buf, int size_)
195 return size; 197 return size;
196 } 198 }
197 199
200/* non-copying interface: provide pointer to available data in buffer
201 * bio_nread0: return number of available bytes
202 * bio_nread: also advance index
203 * (example usage: bio_nread0(), read from buffer, bio_nread()
204 * or just bio_nread(), read from buffer)
205 */
206/* WARNING: The non-copying interface is largely untested as of yet
207 * and may contain bugs. */
208static size_t bio_nread0(BIO *bio, char **buf)
209 {
210 struct bio_bio_st *b, *peer_b;
211 size_t num;
212
213 BIO_clear_retry_flags(bio);
214
215 if (!bio->init)
216 return 0;
217
218 b = bio->ptr;
219 assert(b != NULL);
220 assert(b->peer != NULL);
221 peer_b = b->peer->ptr;
222 assert(peer_b != NULL);
223 assert(peer_b->buf != NULL);
224
225 peer_b->request = 0;
226
227 if (peer_b->len == 0)
228 {
229 char dummy;
230
231 /* avoid code duplication -- nothing available for reading */
232 return bio_read(bio, &dummy, 1); /* returns 0 or -1 */
233 }
234
235 num = peer_b->len;
236 if (peer_b->size < peer_b->offset + num)
237 /* no ring buffer wrap-around for non-copying interface */
238 num = peer_b->size - peer_b->offset;
239 assert(num > 0);
240
241 if (buf != NULL)
242 *buf = peer_b->buf + peer_b->offset;
243 return num;
244 }
245
246static size_t bio_nread(BIO *bio, char **buf, size_t num)
247 {
248 struct bio_bio_st *b, *peer_b;
249 size_t available;
250
251 available = bio_nread0(bio, buf);
252 if (num > available)
253 num = available;
254 if (num == 0)
255 return num;
256
257 b = bio->ptr;
258 peer_b = b->peer->ptr;
259
260 peer_b->len -= num;
261 if (peer_b->len)
262 {
263 peer_b->offset += num;
264 assert(peer_b->offset <= peer_b->size);
265 if (peer_b->offset == peer_b->size)
266 peer_b->offset = 0;
267 }
268 else
269 peer_b->offset = 0;
270
271 return num;
272 }
273
274
198static int bio_write(BIO *bio, char *buf, int num_) 275static int bio_write(BIO *bio, char *buf, int num_)
199 { 276 {
200 size_t num = num_; 277 size_t num = num_;
@@ -268,6 +345,78 @@ static int bio_write(BIO *bio, char *buf, int num_)
268 return num; 345 return num;
269 } 346 }
270 347
348/* non-copying interface: provide pointer to region to write to
349 * bio_nwrite0: check how much space is available
350 * bio_nwrite: also increase length
351 * (example usage: bio_nwrite0(), write to buffer, bio_nwrite()
352 * or just bio_nwrite(), write to buffer)
353 */
354static size_t bio_nwrite0(BIO *bio, char **buf)
355 {
356 struct bio_bio_st *b;
357 size_t num;
358 size_t write_offset;
359
360 BIO_clear_retry_flags(bio);
361
362 if (!bio->init)
363 return 0;
364
365 b = bio->ptr;
366 assert(b != NULL);
367 assert(b->peer != NULL);
368 assert(b->buf != NULL);
369
370 b->request = 0;
371 if (b->closed)
372 {
373 BIOerr(BIO_F_BIO_NWRITE0, BIO_R_BROKEN_PIPE);
374 return -1;
375 }
376
377 assert(b->len <= b->size);
378
379 if (b->len == b->size)
380 {
381 BIO_set_retry_write(bio);
382 return -1;
383 }
384
385 num = b->size - b->len;
386 write_offset = b->offset + b->len;
387 if (write_offset >= b->size)
388 write_offset -= b->size;
389 if (write_offset + num > b->size)
390 /* no ring buffer wrap-around for non-copying interface
391 * (to fulfil the promise by BIO_ctrl_get_write_guarantee,
392 * BIO_nwrite may have to be called twice) */
393 num = b->size - write_offset;
394
395 if (buf != NULL)
396 *buf = b->buf + write_offset;
397 assert(write_offset + num <= b->size);
398
399 return num;
400 }
401
402static size_t bio_nwrite(BIO *bio, char **buf, size_t num)
403 {
404 struct bio_bio_st *b;
405 size_t space;
406
407 space = bio_nwrite0(bio, buf);
408 if (num > space)
409 num = space;
410 if (num == 0)
411 return num;
412 b = bio->ptr;
413 assert(b != NULL);
414 b->len += num;
415 assert(b->len <= b->size);
416
417 return num;
418 }
419
271 420
272static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) 421static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
273 { 422 {
@@ -331,7 +480,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
331 480
332 case BIO_C_GET_WRITE_GUARANTEE: 481 case BIO_C_GET_WRITE_GUARANTEE:
333 /* How many bytes can the caller feed to the next write 482 /* How many bytes can the caller feed to the next write
334 * withouth having to keep any? */ 483 * without having to keep any? */
335 if (b->peer == NULL || b->closed) 484 if (b->peer == NULL || b->closed)
336 ret = 0; 485 ret = 0;
337 else 486 else
@@ -339,18 +488,42 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
339 break; 488 break;
340 489
341 case BIO_C_GET_READ_REQUEST: 490 case BIO_C_GET_READ_REQUEST:
342 /* If the peer unsuccesfully tried to read, how many bytes 491 /* If the peer unsuccessfully tried to read, how many bytes
343 * were requested? (As with BIO_CTRL_PENDING, that number 492 * were requested? (As with BIO_CTRL_PENDING, that number
344 * can usually be treated as boolean.) */ 493 * can usually be treated as boolean.) */
345 ret = (long) b->request; 494 ret = (long) b->request;
346 break; 495 break;
347 496
497 case BIO_C_RESET_READ_REQUEST:
498 /* Reset request. (Can be useful after read attempts
499 * at the other side that are meant to be non-blocking,
500 * e.g. when probing SSL_read to see if any data is
501 * available.) */
502 b->request = 0;
503 ret = 1;
504 break;
505
348 case BIO_C_SHUTDOWN_WR: 506 case BIO_C_SHUTDOWN_WR:
349 /* similar to shutdown(..., SHUT_WR) */ 507 /* similar to shutdown(..., SHUT_WR) */
350 b->closed = 1; 508 b->closed = 1;
351 ret = 1; 509 ret = 1;
352 break; 510 break;
353 511
512 case BIO_C_NREAD:
513 /* non-copying read */
514 ret = (long) bio_nread(bio, ptr, (size_t) num);
515 break;
516
517 case BIO_C_NWRITE0:
518 /* prepare for non-copying write */
519 ret = (long) bio_nwrite0(bio, ptr);
520 break;
521
522 case BIO_C_NWRITE:
523 /* non-copying write */
524 ret = (long) bio_nwrite(bio, ptr, (size_t) num);
525 break;
526
354 527
355 /* standard CTRL codes follow */ 528 /* standard CTRL codes follow */
356 529
@@ -586,3 +759,78 @@ size_t BIO_ctrl_get_read_request(BIO *bio)
586 { 759 {
587 return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL); 760 return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL);
588 } 761 }
762
763int BIO_ctrl_reset_read_request(BIO *bio)
764 {
765 return (BIO_ctrl(bio, BIO_C_RESET_READ_REQUEST, 0, NULL) != 0);
766 }
767
768
769/* BIO_nread0/nread/nwrite0/nwrite are available only for BIO pairs for now
770 * (conceivably some other BIOs could allow non-copying reads and writes too.)
771 */
772int BIO_nread0(BIO *bio, char **buf)
773 {
774 long ret;
775
776 if (!bio->init)
777 {
778 BIOerr(BIO_F_BIO_NREAD0, BIO_R_UNINITIALIZED);
779 return -2;
780 }
781
782 ret = BIO_ctrl(bio, BIO_C_NREAD0, 0, buf);
783 if (ret > INT_MAX)
784 return INT_MAX;
785 else
786 return (int) ret;
787 }
788
789int BIO_nread(BIO *bio, char **buf, int num)
790 {
791 int ret;
792
793 if (!bio->init)
794 {
795 BIOerr(BIO_F_BIO_NREAD, BIO_R_UNINITIALIZED);
796 return -2;
797 }
798
799 ret = (int) BIO_ctrl(bio, BIO_C_NREAD, num, buf);
800 if (ret > 0)
801 bio->num_read += ret;
802 return ret;
803 }
804
805int BIO_nwrite0(BIO *bio, char **buf)
806 {
807 long ret;
808
809 if (!bio->init)
810 {
811 BIOerr(BIO_F_BIO_NWRITE0, BIO_R_UNINITIALIZED);
812 return -2;
813 }
814
815 ret = BIO_ctrl(bio, BIO_C_NWRITE0, 0, buf);
816 if (ret > INT_MAX)
817 return INT_MAX;
818 else
819 return (int) ret;
820 }
821
822int BIO_nwrite(BIO *bio, char **buf, int num)
823 {
824 int ret;
825
826 if (!bio->init)
827 {
828 BIOerr(BIO_F_BIO_NWRITE, BIO_R_UNINITIALIZED);
829 return -2;
830 }
831
832 ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf);
833 if (ret > 0)
834 bio->num_read += ret;
835 return ret;
836 }
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index 68c46e3d69..22d00b369e 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -90,11 +90,11 @@ typedef struct bio_connect_st
90 struct sockaddr_in them; 90 struct sockaddr_in them;
91 91
92 /* int socket; this will be kept in bio->num so that it is 92 /* int socket; this will be kept in bio->num so that it is
93 * compatable with the bss_sock bio */ 93 * compatible with the bss_sock bio */
94 94
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 compatablity with the ssl info_callback */ 97 * 'ret'. state is for compatibility with the ssl info_callback */
98 int (*info_callback)(); 98 int (*info_callback)();
99 } BIO_CONNECT; 99 } BIO_CONNECT;
100 100
@@ -104,6 +104,7 @@ static int conn_puts(BIO *h,char *str);
104static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); 104static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2);
105static int conn_new(BIO *h); 105static int conn_new(BIO *h);
106static int conn_free(BIO *data); 106static int conn_free(BIO *data);
107static long conn_callback_ctrl(BIO *h,int cmd,void *(*fp)());
107 108
108static int conn_state(BIO *b, BIO_CONNECT *c); 109static int conn_state(BIO *b, BIO_CONNECT *c);
109static void conn_close_socket(BIO *data); 110static void conn_close_socket(BIO *data);
@@ -121,6 +122,7 @@ static BIO_METHOD methods_connectp=
121 conn_ctrl, 122 conn_ctrl,
122 conn_new, 123 conn_new,
123 conn_free, 124 conn_free,
125 conn_callback_ctrl,
124 }; 126 };
125 127
126static int conn_state(BIO *b, BIO_CONNECT *c) 128static int conn_state(BIO *b, BIO_CONNECT *c)
@@ -494,7 +496,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
494 *((int *)ptr)=data->port; 496 *((int *)ptr)=data->port;
495 } 497 }
496 if ((!b->init) || (ptr == NULL)) 498 if ((!b->init) || (ptr == NULL))
497 *pptr="not initalised"; 499 *pptr="not initialized";
498 ret=1; 500 ret=1;
499 } 501 }
500 break; 502 break;
@@ -564,16 +566,25 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
564 case BIO_CTRL_FLUSH: 566 case BIO_CTRL_FLUSH:
565 break; 567 break;
566 case BIO_CTRL_DUP: 568 case BIO_CTRL_DUP:
569 {
567 dbio=(BIO *)ptr; 570 dbio=(BIO *)ptr;
568 if (data->param_port) 571 if (data->param_port)
569 BIO_set_conn_port(dbio,data->param_port); 572 BIO_set_conn_port(dbio,data->param_port);
570 if (data->param_hostname) 573 if (data->param_hostname)
571 BIO_set_conn_hostname(dbio,data->param_hostname); 574 BIO_set_conn_hostname(dbio,data->param_hostname);
572 BIO_set_nbio(dbio,data->nbio); 575 BIO_set_nbio(dbio,data->nbio);
573 (void)BIO_set_info_callback(dbio,data->info_callback); 576 (void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback));
577 }
574 break; 578 break;
575 case BIO_CTRL_SET_CALLBACK: 579 case BIO_CTRL_SET_CALLBACK:
576 data->info_callback=(int (*)())ptr; 580 {
581#if 0 /* FIXME: Should this be used? -- Richard Levitte */
582 BIOerr(BIO_F_CONN_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
583 ret = -1;
584#else
585 ret=0;
586#endif
587 }
577 break; 588 break;
578 case BIO_CTRL_GET_CALLBACK: 589 case BIO_CTRL_GET_CALLBACK:
579 { 590 {
@@ -590,6 +601,27 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
590 return(ret); 601 return(ret);
591 } 602 }
592 603
604static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)())
605 {
606 long ret=1;
607 BIO_CONNECT *data;
608
609 data=(BIO_CONNECT *)b->ptr;
610
611 switch (cmd)
612 {
613 case BIO_CTRL_SET_CALLBACK:
614 {
615 data->info_callback=(int (*)())fp;
616 }
617 break;
618 default:
619 ret=0;
620 break;
621 }
622 return(ret);
623 }
624
593static int conn_puts(BIO *bp, char *str) 625static int conn_puts(BIO *bp, char *str)
594 { 626 {
595 int n,ret; 627 int n,ret;
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 52c0c39df0..0d44dc3889 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -91,6 +91,7 @@ static BIO_METHOD methods_filep=
91 file_ctrl, 91 file_ctrl,
92 file_new, 92 file_new,
93 file_free, 93 file_free,
94 NULL,
94 }; 95 };
95 96
96BIO *BIO_new_file(const char *filename, const char *mode) 97BIO *BIO_new_file(const char *filename, const char *mode)
@@ -171,7 +172,7 @@ static int MS_CALLBACK file_write(BIO *b, char *in, int inl)
171 if (fwrite(in,(int)inl,1,(FILE *)b->ptr)) 172 if (fwrite(in,(int)inl,1,(FILE *)b->ptr))
172 ret=inl; 173 ret=inl;
173 /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ 174 /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
174 /* acording to Tim Hudson <tjh@cryptsoft.com>, the commented 175 /* according to Tim Hudson <tjh@cryptsoft.com>, the commented
175 * out version above can cause 'inl' write calls under 176 * out version above can cause 'inl' write calls under
176 * some stupid stdio implementations (VMS) */ 177 * some stupid stdio implementations (VMS) */
177 } 178 }
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index db82e757e7..4308b19663 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -72,6 +72,8 @@
72#else 72#else
73#include <syslog.h> 73#include <syslog.h>
74#endif 74#endif
75#else
76#include <process.h>
75#endif 77#endif
76 78
77#include "cryptlib.h" 79#include "cryptlib.h"
@@ -98,6 +100,7 @@ static BIO_METHOD methods_slg=
98 slg_ctrl, 100 slg_ctrl,
99 slg_new, 101 slg_new,
100 slg_free, 102 slg_free,
103 NULL,
101 }; 104 };
102 105
103BIO_METHOD *BIO_s_log(void) 106BIO_METHOD *BIO_s_log(void)
@@ -131,8 +134,10 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl)
131 char* buf= in; 134 char* buf= in;
132 char* pp; 135 char* pp;
133#if defined(WIN32) 136#if defined(WIN32)
134 LPTSTR lpszStrings[1]; 137 LPCSTR lpszStrings[2];
135 WORD evtype= EVENTLOG_ERROR_TYPE; 138 WORD evtype= EVENTLOG_ERROR_TYPE;
139 int pid = _getpid();
140 char pidbuf[20];
136#else 141#else
137 int priority; 142 int priority;
138#endif 143#endif
@@ -156,10 +161,13 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl)
156 evtype= EVENTLOG_ERROR_TYPE; 161 evtype= EVENTLOG_ERROR_TYPE;
157 pp= buf; 162 pp= buf;
158 } 163 }
159 lpszStrings[0]= pp; 164
165 sprintf(pidbuf, "[%d] ", pid);
166 lpszStrings[0] = pidbuf;
167 lpszStrings[1] = pp;
160 168
161 if(b->ptr) 169 if(b->ptr)
162 ReportEvent(b->ptr, evtype, 0, 1024, NULL, 1, 0, 170 ReportEvent(b->ptr, evtype, 0, 1024, NULL, 2, 0,
163 lpszStrings, NULL); 171 lpszStrings, NULL);
164#else 172#else
165 if(strncmp(buf, "ERR ", 4) == 0){ 173 if(strncmp(buf, "ERR ", 4) == 0){
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index 7e749a503e..41eab92415 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -79,6 +79,7 @@ static BIO_METHOD mem_method=
79 mem_ctrl, 79 mem_ctrl,
80 mem_new, 80 mem_new,
81 mem_free, 81 mem_free,
82 NULL,
82 }; 83 };
83 84
84/* bio->num is used to hold the value to return on 'empty', if it is 85/* bio->num is used to hold the value to return on 'empty', if it is
@@ -89,6 +90,26 @@ BIO_METHOD *BIO_s_mem(void)
89 return(&mem_method); 90 return(&mem_method);
90 } 91 }
91 92
93BIO *BIO_new_mem_buf(void *buf, int len)
94{
95 BIO *ret;
96 BUF_MEM *b;
97 if (!buf) {
98 BIOerr(BIO_F_BIO_NEW_MEM_BUF,BIO_R_NULL_PARAMETER);
99 return NULL;
100 }
101 if(len == -1) len = strlen(buf);
102 if(!(ret = BIO_new(BIO_s_mem())) ) return NULL;
103 b = (BUF_MEM *)ret->ptr;
104 b->data = buf;
105 b->length = len;
106 b->max = len;
107 ret->flags |= BIO_FLAGS_MEM_RDONLY;
108 /* Since this is static data retrying wont help */
109 ret->num = 0;
110 return ret;
111}
112
92static int mem_new(BIO *bi) 113static int mem_new(BIO *bi)
93 { 114 {
94 BUF_MEM *b; 115 BUF_MEM *b;
@@ -109,7 +130,10 @@ static int mem_free(BIO *a)
109 { 130 {
110 if ((a->init) && (a->ptr != NULL)) 131 if ((a->init) && (a->ptr != NULL))
111 { 132 {
112 BUF_MEM_free((BUF_MEM *)a->ptr); 133 BUF_MEM *b;
134 b = (BUF_MEM *)a->ptr;
135 if(a->flags & BIO_FLAGS_MEM_RDONLY) b->data = NULL;
136 BUF_MEM_free(b);
113 a->ptr=NULL; 137 a->ptr=NULL;
114 } 138 }
115 } 139 }
@@ -126,17 +150,18 @@ static int mem_read(BIO *b, char *out, int outl)
126 bm=(BUF_MEM *)b->ptr; 150 bm=(BUF_MEM *)b->ptr;
127 BIO_clear_retry_flags(b); 151 BIO_clear_retry_flags(b);
128 ret=(outl > bm->length)?bm->length:outl; 152 ret=(outl > bm->length)?bm->length:outl;
129 if ((out != NULL) && (ret > 0)) 153 if ((out != NULL) && (ret > 0)) {
130 {
131 memcpy(out,bm->data,ret); 154 memcpy(out,bm->data,ret);
132 bm->length-=ret; 155 bm->length-=ret;
133 /* memmove(&(bm->data[0]),&(bm->data[ret]), bm->length); */ 156 /* memmove(&(bm->data[0]),&(bm->data[ret]), bm->length); */
134 from=(char *)&(bm->data[ret]); 157 if(b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret;
135 to=(char *)&(bm->data[0]); 158 else {
136 for (i=0; i<bm->length; i++) 159 from=(char *)&(bm->data[ret]);
137 to[i]=from[i]; 160 to=(char *)&(bm->data[0]);
161 for (i=0; i<bm->length; i++)
162 to[i]=from[i];
138 } 163 }
139 else if (bm->length == 0) 164 } else if (bm->length == 0)
140 { 165 {
141 if (b->num != 0) 166 if (b->num != 0)
142 BIO_set_retry_read(b); 167 BIO_set_retry_read(b);
@@ -158,6 +183,11 @@ static int mem_write(BIO *b, char *in, int inl)
158 goto end; 183 goto end;
159 } 184 }
160 185
186 if(b->flags & BIO_FLAGS_MEM_RDONLY) {
187 BIOerr(BIO_F_MEM_WRITE,BIO_R_WRITE_TO_READ_ONLY_BIO);
188 goto end;
189 }
190
161 BIO_clear_retry_flags(b); 191 BIO_clear_retry_flags(b);
162 blen=bm->length; 192 blen=bm->length;
163 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl)) 193 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl))
@@ -178,9 +208,15 @@ static long mem_ctrl(BIO *b, int cmd, long num, char *ptr)
178 switch (cmd) 208 switch (cmd)
179 { 209 {
180 case BIO_CTRL_RESET: 210 case BIO_CTRL_RESET:
181 if (bm->data != NULL) 211 if (bm->data != NULL) {
182 memset(bm->data,0,bm->max); 212 /* For read only case reset to the start again */
183 bm->length=0; 213 if(b->flags & BIO_FLAGS_MEM_RDONLY)
214 bm->data -= bm->max - bm->length;
215 else {
216 memset(bm->data,0,bm->max);
217 bm->length=0;
218 }
219 }
184 break; 220 break;
185 case BIO_CTRL_EOF: 221 case BIO_CTRL_EOF:
186 ret=(long)(bm->length == 0); 222 ret=(long)(bm->length == 0);
diff --git a/src/lib/libcrypto/bio/bss_null.c b/src/lib/libcrypto/bio/bss_null.c
index d04be888e5..aee18e3ada 100644
--- a/src/lib/libcrypto/bio/bss_null.c
+++ b/src/lib/libcrypto/bio/bss_null.c
@@ -79,6 +79,7 @@ static BIO_METHOD null_method=
79 null_ctrl, 79 null_ctrl,
80 null_new, 80 null_new,
81 null_free, 81 null_free,
82 NULL,
82 }; 83 };
83 84
84BIO_METHOD *BIO_s_null(void) 85BIO_METHOD *BIO_s_null(void)
diff --git a/src/lib/libcrypto/bio/bss_rtcp.c b/src/lib/libcrypto/bio/bss_rtcp.c
index 2ef040057e..4ad0739464 100644
--- a/src/lib/libcrypto/bio/bss_rtcp.c
+++ b/src/lib/libcrypto/bio/bss_rtcp.c
@@ -107,6 +107,7 @@ static BIO_METHOD rtcp_method=
107 rtcp_ctrl, 107 rtcp_ctrl,
108 rtcp_new, 108 rtcp_new,
109 rtcp_free, 109 rtcp_free,
110 NULL,
110 }; 111 };
111 112
112BIO_METHOD *BIO_s_rtcp(void) 113BIO_METHOD *BIO_s_rtcp(void)
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index d336b99fe8..8ce80ef68d 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -95,6 +95,7 @@ static BIO_METHOD methods_sockp=
95 sock_ctrl, 95 sock_ctrl,
96 sock_new, 96 sock_new,
97 sock_free, 97 sock_free,
98 NULL,
98 }; 99 };
99 100
100BIO_METHOD *BIO_s_socket(void) 101BIO_METHOD *BIO_s_socket(void)
@@ -112,6 +113,7 @@ static BIO_METHOD methods_fdp=
112 fd_ctrl, 113 fd_ctrl,
113 fd_new, 114 fd_new,
114 fd_free, 115 fd_free,
116 NULL,
115 }; 117 };
116 118
117BIO_METHOD *BIO_s_fd(void) 119BIO_METHOD *BIO_s_fd(void)
@@ -163,8 +165,7 @@ static int fd_free(BIO *a)
163 if (a->init) 165 if (a->init)
164 { 166 {
165#ifndef BIO_FD 167#ifndef BIO_FD
166 shutdown(a->num,2); 168 SHUTDOWN2(a->num);
167 closesocket(a->num);
168#else /* BIO_FD */ 169#else /* BIO_FD */
169 close(a->num); 170 close(a->num);
170#endif 171#endif
diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl
index cf77869fab..fa23a43fa0 100644
--- a/src/lib/libcrypto/bn/Makefile.ssl
+++ b/src/lib/libcrypto/bn/Makefile.ssl
@@ -20,6 +20,13 @@ BN_ASM= bn_asm.o
20#BN_ASM= bn86-elf.o 20#BN_ASM= bn86-elf.o
21 21
22CFLAGS= $(INCLUDES) $(CFLAG) 22CFLAGS= $(INCLUDES) $(CFLAG)
23
24# We let the C compiler driver to take care of .s files. This is done in
25# order to be excused from maintaining a separate set of architecture
26# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
27# gcc, then the driver will automatically translate it to -xarch=v8plus
28# and pass it down to assembler.
29AS=$(CC) -c
23ASFLAGS=$(CFLAGS) 30ASFLAGS=$(CFLAGS)
24 31
25GENERAL=Makefile 32GENERAL=Makefile
@@ -27,12 +34,12 @@ TEST=bntest.c exptest.c
27APPS= 34APPS=
28 35
29LIB=$(TOP)/libcrypto.a 36LIB=$(TOP)/libcrypto.a
30LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mul.c \ 37LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \
31 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ 38 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
32 bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c \ 39 bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c \
33 bn_mpi.c bn_exp2.c 40 bn_mpi.c bn_exp2.c
34 41
35LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mul.o \ 42LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o \
36 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ 43 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
37 bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) bn_recp.o bn_mont.o \ 44 bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) bn_recp.o bn_mont.o \
38 bn_mpi.o bn_exp2.o 45 bn_mpi.o bn_exp2.o
@@ -49,12 +56,14 @@ top:
49 56
50all: lib 57all: lib
51 58
52knuth: bn_knuth.c 59bn_prime.h: bn_prime.pl
53 cc -pg -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a 60 $(PERL) bn_prime.pl >bn_prime.h
54 61
55knuth.fast: bn_knuth.c 62divtest: divtest.c ../../libcrypto.a
56 cc -pg -fast -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a 63 cc -I../../include divtest.c -o divtest ../../libcrypto.a
57 64
65bnbug: bnbug.c ../../libcrypto.a top
66 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a
58 67
59lib: $(LIBOBJ) 68lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ) 69 $(AR) $(LIB) $(LIBOBJ)
@@ -113,13 +122,6 @@ asm/sparcv8plus-gcc27.o: asm/sparcv8plus.S
113 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \ 122 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \
114 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o 123 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o
115 124
116# MIPS 64 bit assember
117asm/mips3.o: asm/mips3.s
118
119# MIPS 32 bit assember
120asm/mips1.o: asm/mips1.s
121 /usr/bin/as -O2 -o asm/mips1.o asm/mips1.s
122
123files: 125files:
124 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 126 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
125 127
@@ -168,109 +170,117 @@ bn_add.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
168bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 170bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
169bn_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 171bn_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
170bn_add.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 172bn_add.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
171bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 173bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
172bn_add.o: ../cryptlib.h bn_lcl.h 174bn_add.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
173bn_asm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 175bn_asm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
174bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 176bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
175bn_asm.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 177bn_asm.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
176bn_asm.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 178bn_asm.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
177bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 179bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
178bn_asm.o: ../cryptlib.h bn_lcl.h 180bn_asm.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
179bn_blind.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 181bn_blind.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
180bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 182bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
181bn_blind.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 183bn_blind.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
182bn_blind.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 184bn_blind.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
183bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 185bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
184bn_blind.o: ../cryptlib.h bn_lcl.h 186bn_blind.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
187bn_ctx.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
188bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
189bn_ctx.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
190bn_ctx.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
191bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
192bn_ctx.o: ../../include/openssl/stack.h ../cryptlib.h
185bn_div.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 193bn_div.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
186bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 194bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
187bn_div.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 195bn_div.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
188bn_div.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 196bn_div.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
189bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 197bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
190bn_div.o: ../cryptlib.h bn_lcl.h 198bn_div.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
191bn_err.o: ../../include/openssl/bn.h ../../include/openssl/err.h 199bn_err.o: ../../include/openssl/bn.h ../../include/openssl/err.h
192bn_err.o: ../../include/openssl/opensslconf.h 200bn_err.o: ../../include/openssl/opensslconf.h
193bn_exp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 201bn_exp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
194bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 202bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
195bn_exp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 203bn_exp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
196bn_exp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 204bn_exp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
197bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 205bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
198bn_exp.o: ../cryptlib.h bn_lcl.h 206bn_exp.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
199bn_exp2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 207bn_exp2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
200bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 208bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
201bn_exp2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 209bn_exp2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
202bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 210bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
203bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 211bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
204bn_exp2.o: ../cryptlib.h bn_lcl.h 212bn_exp2.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
205bn_gcd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 213bn_gcd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
206bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 214bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
207bn_gcd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 215bn_gcd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
208bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 216bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
209bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 217bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
210bn_gcd.o: ../cryptlib.h bn_lcl.h 218bn_gcd.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
211bn_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 219bn_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
212bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 220bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
213bn_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 221bn_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
214bn_lib.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 222bn_lib.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
215bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 223bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
216bn_lib.o: ../cryptlib.h bn_lcl.h 224bn_lib.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
217bn_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 225bn_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
218bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 226bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
219bn_mont.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 227bn_mont.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
220bn_mont.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 228bn_mont.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
221bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 229bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
222bn_mont.o: ../cryptlib.h bn_lcl.h 230bn_mont.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
223bn_mpi.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 231bn_mpi.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
224bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 232bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
225bn_mpi.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 233bn_mpi.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
226bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 234bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
227bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 235bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
228bn_mpi.o: ../cryptlib.h bn_lcl.h 236bn_mpi.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
229bn_mul.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 237bn_mul.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
230bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 238bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
231bn_mul.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 239bn_mul.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
232bn_mul.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 240bn_mul.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
233bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 241bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
234bn_mul.o: ../cryptlib.h bn_lcl.h 242bn_mul.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
235bn_prime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 243bn_prime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
236bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 244bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
237bn_prime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 245bn_prime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
238bn_prime.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 246bn_prime.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
239bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 247bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
240bn_prime.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h bn_prime.h 248bn_prime.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
249bn_prime.o: ../cryptlib.h bn_lcl.h bn_prime.h
241bn_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 250bn_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
242bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 251bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
243bn_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 252bn_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
244bn_print.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 253bn_print.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
245bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 254bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
246bn_print.o: ../cryptlib.h bn_lcl.h 255bn_print.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
247bn_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 256bn_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
248bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 257bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
249bn_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 258bn_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
250bn_rand.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 259bn_rand.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
251bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 260bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
252bn_rand.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h 261bn_rand.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
262bn_rand.o: ../cryptlib.h bn_lcl.h
253bn_recp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 263bn_recp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
254bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 264bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
255bn_recp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 265bn_recp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
256bn_recp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 266bn_recp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
257bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 267bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
258bn_recp.o: ../cryptlib.h bn_lcl.h 268bn_recp.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
259bn_shift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 269bn_shift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
260bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 270bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
261bn_shift.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 271bn_shift.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
262bn_shift.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 272bn_shift.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
263bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 273bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
264bn_shift.o: ../cryptlib.h bn_lcl.h 274bn_shift.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
265bn_sqr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 275bn_sqr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
266bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 276bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
267bn_sqr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 277bn_sqr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
268bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 278bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
269bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 279bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
270bn_sqr.o: ../cryptlib.h bn_lcl.h 280bn_sqr.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
271bn_word.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 281bn_word.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
272bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 282bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
273bn_word.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 283bn_word.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
274bn_word.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 284bn_word.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
275bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 285bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
276bn_word.o: ../cryptlib.h bn_lcl.h 286bn_word.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
diff --git a/src/lib/libcrypto/bn/asm/README b/src/lib/libcrypto/bn/asm/README
index d93fbff77f..86bf64cfc2 100644
--- a/src/lib/libcrypto/bn/asm/README
+++ b/src/lib/libcrypto/bn/asm/README
@@ -1,5 +1,5 @@
1All assember in this directory are just version of the file 1All assember in this directory are just version of the file
2crypto/bn/bn_mulw.c. 2crypto/bn/bn_asm.c.
3 3
4Quite a few of these files are just the assember output from gcc since on 4Quite a few of these files are just the assember output from gcc since on
5quite a few machines they are 2 times faster than the system compiler. 5quite a few machines they are 2 times faster than the system compiler.
@@ -15,13 +15,6 @@ On the 2 alpha C compilers I had access to, it was not possible to do
15were 64 bits). So the hand assember gives access to the 128 bit result and 15were 64 bits). So the hand assember gives access to the 128 bit result and
16a 2 times speedup :-). 16a 2 times speedup :-).
17 17
18The x86xxxx.obj files are the assembled version of x86xxxx.asm files.
19I had such a hard time finding a macro assember for Microsoft, I decided to
20include the object file to save others the hassle :-).
21
22I have also included uu encoded versions of the .obj incase they get
23trashed.
24
25There are 2 versions of assember for the HP PA-RISC. 18There are 2 versions of assember for the HP PA-RISC.
26pa-risc.s is the origional one which works fine. 19pa-risc.s is the origional one which works fine.
27pa-risc2.s is a new version that often generates warnings but if the 20pa-risc2.s is a new version that often generates warnings but if the
diff --git a/src/lib/libcrypto/bn/asm/alpha.s b/src/lib/libcrypto/bn/asm/alpha.s
index a351694ca2..555ff0b92d 100644
--- a/src/lib/libcrypto/bn/asm/alpha.s
+++ b/src/lib/libcrypto/bn/asm/alpha.s
@@ -694,567 +694,1868 @@ bn_mul_comba8:
694bn_mul_comba8..ng: 694bn_mul_comba8..ng:
695 .frame $30,0,$26,0 695 .frame $30,0,$26,0
696 .prologue 0 696 .prologue 0
697 697 ldq $1, 0($17)
698 subq $30, 16, $30 698 ldq $2, 0($18)
699 ldq $0, 0($17) 699 zapnot $1, 15, $7
700 srl $2, 32, $8
701 mulq $8, $7, $22
702 srl $1, 32, $6
703 zapnot $2, 15, $5
704 mulq $5, $6, $4
705 mulq $7, $5, $24
706 addq $22, $4, $22
707 cmpult $22, $4, $1
708 mulq $6, $8, $3
709 beq $1, $173
710 bis $31, 1, $1
711 sll $1, 32, $1
712 addq $3, $1, $3
713$173:
714 sll $22, 32, $4
715 addq $24, $4, $24
716 stq $24, 0($16)
717 ldq $2, 0($17)
718 ldq $1, 8($18)
719 zapnot $2, 15, $7
720 srl $1, 32, $8
721 mulq $8, $7, $25
722 zapnot $1, 15, $5
723 mulq $7, $5, $0
724 srl $2, 32, $6
725 mulq $5, $6, $23
726 mulq $6, $8, $6
727 srl $22, 32, $1
728 cmpult $24, $4, $2
729 addq $3, $1, $3
730 addq $2, $3, $22
731 addq $25, $23, $25
732 cmpult $25, $23, $1
733 bis $31, 1, $2
734 beq $1, $177
735 sll $2, 32, $1
736 addq $6, $1, $6
737$177:
738 sll $25, 32, $23
700 ldq $1, 0($18) 739 ldq $1, 0($18)
701 stq $9, 0($30) 740 addq $0, $23, $0
702 stq $10, 8($30) 741 bis $0, $0, $7
703 ldq $2, 8($17) 742 ldq $3, 8($17)
704 ldq $3, 8($18) 743 addq $22, $7, $22
705 ldq $4, 16($17) 744 srl $1, 32, $8
706 ldq $5, 16($18) 745 cmpult $22, $7, $4
707 ldq $6, 24($17) 746 zapnot $3, 15, $7
708 ldq $7, 24($18) 747 mulq $8, $7, $28
709 ldq $8, 8($17) 748 zapnot $1, 15, $5
710 ldq $22, 8($18) 749 mulq $7, $5, $21
711 ldq $23, 8($17) 750 srl $25, 32, $1
712 ldq $24, 8($18) 751 cmpult $0, $23, $2
713 ldq $25, 8($17) 752 addq $6, $1, $6
714 ldq $27, 8($18) 753 addq $2, $6, $6
715 ldq $28, 8($17) 754 addq $4, $6, $24
716 ldq $21, 8($18) 755 srl $3, 32, $6
717 bis $31, $31, $9 756 mulq $5, $6, $2
718 mulq $0, $1, $20 757 mulq $6, $8, $6
719 umulh $0, $1, $19 758 addq $28, $2, $28
720 stq $20, 0($16) 759 cmpult $28, $2, $1
721 bis $31, $31, $20 760 bis $31, 1, $2
722 mulq $0, $3, $10 761 beq $1, $181
723 umulh $0, $3, $17 762 sll $2, 32, $1
724 addq $19, $10, $19 763 addq $6, $1, $6
725 cmpult $19, $10, $18 764$181:
726 addq $18, $17, $17 765 sll $28, 32, $2
727 addq $9, $17, $9 766 addq $21, $2, $21
728 cmpult $9, $17, $10 767 bis $21, $21, $7
729 addq $20, $10, $20 768 addq $22, $7, $22
730 mulq $2, $1, $18 769 stq $22, 8($16)
731 umulh $2, $1, $17 770 ldq $3, 16($17)
732 addq $19, $18, $19 771 ldq $1, 0($18)
733 cmpult $19, $18, $10 772 cmpult $22, $7, $4
734 addq $10, $17, $17 773 zapnot $3, 15, $7
735 addq $9, $17, $9 774 srl $1, 32, $8
736 cmpult $9, $17, $18 775 mulq $8, $7, $22
737 addq $20, $18, $20 776 zapnot $1, 15, $5
738 stq $19, 8($16) 777 mulq $7, $5, $20
739 bis $31, $31, $19 778 srl $28, 32, $1
740 mulq $0, $5, $10 779 cmpult $21, $2, $2
741 umulh $0, $5, $17 780 addq $6, $1, $6
742 addq $9, $10, $9 781 addq $2, $6, $6
743 cmpult $9, $10, $18 782 addq $4, $6, $6
744 addq $18, $17, $17 783 addq $24, $6, $24
745 addq $20, $17, $20 784 cmpult $24, $6, $23
746 cmpult $20, $17, $10 785 srl $3, 32, $6
747 addq $19, $10, $19 786 mulq $5, $6, $2
748 mulq $2, $3, $18 787 mulq $6, $8, $6
749 umulh $2, $3, $17 788 addq $22, $2, $22
750 addq $9, $18, $9 789 cmpult $22, $2, $1
751 cmpult $9, $18, $10 790 bis $31, 1, $2
752 addq $10, $17, $17 791 beq $1, $185
753 addq $20, $17, $20 792 sll $2, 32, $1
754 cmpult $20, $17, $18 793 addq $6, $1, $6
755 addq $19, $18, $19 794$185:
756 mulq $4, $1, $10 795 sll $22, 32, $2
757 umulh $4, $1, $17 796 ldq $1, 8($18)
758 addq $9, $10, $9
759 cmpult $9, $10, $18
760 addq $18, $17, $17
761 addq $20, $17, $20
762 cmpult $20, $17, $10
763 addq $19, $10, $19
764 stq $9, 16($16)
765 bis $31, $31, $9
766 mulq $0, $7, $18
767 umulh $0, $7, $17
768 addq $20, $18, $20
769 cmpult $20, $18, $10
770 addq $10, $17, $17
771 addq $19, $17, $19
772 cmpult $19, $17, $18
773 addq $9, $18, $9
774 mulq $2, $5, $10
775 umulh $2, $5, $17
776 addq $20, $10, $20
777 cmpult $20, $10, $18
778 addq $18, $17, $17
779 addq $19, $17, $19
780 cmpult $19, $17, $10
781 addq $9, $10, $9
782 mulq $4, $3, $18
783 umulh $4, $3, $17
784 addq $20, $18, $20
785 cmpult $20, $18, $10
786 addq $10, $17, $17
787 addq $19, $17, $19
788 cmpult $19, $17, $18
789 addq $9, $18, $9
790 mulq $6, $1, $10
791 umulh $6, $1, $17
792 addq $20, $10, $20
793 cmpult $20, $10, $18
794 addq $18, $17, $17
795 addq $19, $17, $19
796 cmpult $19, $17, $10
797 addq $9, $10, $9
798 stq $20, 24($16)
799 bis $31, $31, $20
800 mulq $0, $22, $18
801 umulh $0, $22, $17
802 addq $19, $18, $19
803 cmpult $19, $18, $10
804 addq $10, $17, $17
805 addq $9, $17, $9
806 cmpult $9, $17, $18
807 addq $20, $18, $20
808 mulq $2, $7, $10
809 umulh $2, $7, $17
810 addq $19, $10, $19
811 cmpult $19, $10, $18
812 addq $18, $17, $17
813 addq $9, $17, $9
814 cmpult $9, $17, $10
815 addq $20, $10, $20
816 mulq $4, $5, $18
817 umulh $4, $5, $17
818 addq $19, $18, $19
819 cmpult $19, $18, $10
820 addq $10, $17, $17
821 addq $9, $17, $9
822 cmpult $9, $17, $18
823 addq $20, $18, $20
824 mulq $6, $3, $10
825 umulh $6, $3, $17
826 addq $19, $10, $19
827 cmpult $19, $10, $18
828 addq $18, $17, $17
829 addq $9, $17, $9
830 cmpult $9, $17, $10
831 addq $20, $10, $20
832 mulq $8, $1, $18
833 umulh $8, $1, $17
834 addq $19, $18, $19
835 cmpult $19, $18, $10
836 addq $10, $17, $17
837 addq $9, $17, $9
838 cmpult $9, $17, $18
839 addq $20, $18, $20
840 stq $19, 32($16)
841 bis $31, $31, $19
842 mulq $0, $24, $10
843 umulh $0, $24, $17
844 addq $9, $10, $9
845 cmpult $9, $10, $18
846 addq $18, $17, $17
847 addq $20, $17, $20
848 cmpult $20, $17, $10
849 addq $19, $10, $19
850 mulq $2, $22, $18
851 umulh $2, $22, $17
852 addq $9, $18, $9
853 cmpult $9, $18, $10
854 addq $10, $17, $17
855 addq $20, $17, $20
856 cmpult $20, $17, $18
857 addq $19, $18, $19
858 mulq $4, $7, $10
859 umulh $4, $7, $17
860 addq $9, $10, $9
861 cmpult $9, $10, $18
862 addq $18, $17, $17
863 addq $20, $17, $20
864 cmpult $20, $17, $10
865 addq $19, $10, $19
866 mulq $6, $5, $18
867 umulh $6, $5, $17
868 addq $9, $18, $9
869 cmpult $9, $18, $10
870 addq $10, $17, $17
871 addq $20, $17, $20
872 cmpult $20, $17, $18
873 addq $19, $18, $19
874 mulq $8, $3, $10
875 umulh $8, $3, $17
876 addq $9, $10, $9
877 cmpult $9, $10, $18
878 addq $18, $17, $17
879 addq $20, $17, $20
880 cmpult $20, $17, $10
881 addq $19, $10, $19
882 mulq $23, $1, $18
883 umulh $23, $1, $17
884 addq $9, $18, $9
885 cmpult $9, $18, $10
886 addq $10, $17, $17
887 addq $20, $17, $20
888 cmpult $20, $17, $18
889 addq $19, $18, $19
890 stq $9, 40($16)
891 bis $31, $31, $9
892 mulq $0, $27, $10
893 umulh $0, $27, $17
894 addq $20, $10, $20
895 cmpult $20, $10, $18
896 addq $18, $17, $17
897 addq $19, $17, $19
898 cmpult $19, $17, $10
899 addq $9, $10, $9
900 mulq $2, $24, $18
901 umulh $2, $24, $17
902 addq $20, $18, $20
903 cmpult $20, $18, $10
904 addq $10, $17, $17
905 addq $19, $17, $19
906 cmpult $19, $17, $18
907 addq $9, $18, $9
908 mulq $4, $22, $10
909 umulh $4, $22, $17
910 addq $20, $10, $20
911 cmpult $20, $10, $18
912 addq $18, $17, $17
913 addq $19, $17, $19
914 cmpult $19, $17, $10
915 addq $9, $10, $9
916 mulq $6, $7, $18
917 umulh $6, $7, $17
918 addq $20, $18, $20
919 cmpult $20, $18, $10
920 addq $10, $17, $17
921 addq $19, $17, $19
922 cmpult $19, $17, $18
923 addq $9, $18, $9
924 mulq $8, $5, $10
925 umulh $8, $5, $17
926 addq $20, $10, $20
927 cmpult $20, $10, $18
928 addq $18, $17, $17
929 addq $19, $17, $19
930 cmpult $19, $17, $10
931 addq $9, $10, $9
932 mulq $23, $3, $18
933 umulh $23, $3, $17
934 addq $20, $18, $20
935 cmpult $20, $18, $10
936 addq $10, $17, $17
937 addq $19, $17, $19
938 cmpult $19, $17, $18
939 addq $9, $18, $9
940 mulq $25, $1, $10
941 umulh $25, $1, $17
942 addq $20, $10, $20
943 cmpult $20, $10, $18
944 addq $18, $17, $17
945 addq $19, $17, $19
946 cmpult $19, $17, $10
947 addq $9, $10, $9
948 stq $20, 48($16)
949 bis $31, $31, $20
950 mulq $0, $21, $18
951 umulh $0, $21, $17
952 addq $19, $18, $19
953 cmpult $19, $18, $10
954 addq $10, $17, $17
955 addq $9, $17, $9
956 cmpult $9, $17, $18
957 addq $20, $18, $20
958 mulq $2, $27, $10
959 umulh $2, $27, $17
960 addq $19, $10, $19
961 cmpult $19, $10, $18
962 addq $18, $17, $17
963 addq $9, $17, $9
964 cmpult $9, $17, $0
965 addq $20, $0, $20
966 mulq $4, $24, $10
967 umulh $4, $24, $18
968 addq $19, $10, $19
969 cmpult $19, $10, $17
970 addq $17, $18, $18
971 addq $9, $18, $9
972 cmpult $9, $18, $0
973 addq $20, $0, $20
974 mulq $6, $22, $10
975 umulh $6, $22, $17
976 addq $19, $10, $19
977 cmpult $19, $10, $18
978 addq $18, $17, $17
979 addq $9, $17, $9
980 cmpult $9, $17, $0
981 addq $20, $0, $20
982 mulq $8, $7, $10
983 umulh $8, $7, $18
984 addq $19, $10, $19
985 cmpult $19, $10, $17
986 addq $17, $18, $18
987 addq $9, $18, $9
988 cmpult $9, $18, $0
989 addq $20, $0, $20
990 mulq $23, $5, $10
991 umulh $23, $5, $17
992 addq $19, $10, $19
993 cmpult $19, $10, $18
994 addq $18, $17, $17
995 addq $9, $17, $9
996 cmpult $9, $17, $0
997 addq $20, $0, $20
998 mulq $25, $3, $10
999 umulh $25, $3, $18
1000 addq $19, $10, $19
1001 cmpult $19, $10, $17
1002 addq $17, $18, $18
1003 addq $9, $18, $9
1004 cmpult $9, $18, $0
1005 addq $20, $0, $20
1006 mulq $28, $1, $10
1007 umulh $28, $1, $17
1008 addq $19, $10, $19
1009 cmpult $19, $10, $18
1010 addq $18, $17, $17
1011 addq $9, $17, $9
1012 cmpult $9, $17, $0
1013 addq $20, $0, $20
1014 stq $19, 56($16)
1015 bis $31, $31, $19
1016 mulq $2, $21, $10
1017 umulh $2, $21, $18
1018 addq $9, $10, $9
1019 cmpult $9, $10, $17
1020 addq $17, $18, $18
1021 addq $20, $18, $20
1022 cmpult $20, $18, $0
1023 addq $19, $0, $19
1024 mulq $4, $27, $1
1025 umulh $4, $27, $10
1026 addq $9, $1, $9
1027 cmpult $9, $1, $17
1028 addq $17, $10, $10
1029 addq $20, $10, $20
1030 cmpult $20, $10, $18
1031 addq $19, $18, $19
1032 mulq $6, $24, $0
1033 umulh $6, $24, $2
1034 addq $9, $0, $9
1035 cmpult $9, $0, $1
1036 addq $1, $2, $2
1037 addq $20, $2, $20
1038 cmpult $20, $2, $17
1039 addq $19, $17, $19
1040 mulq $8, $22, $10
1041 umulh $8, $22, $18
1042 addq $9, $10, $9
1043 cmpult $9, $10, $0
1044 addq $0, $18, $18
1045 addq $20, $18, $20
1046 cmpult $20, $18, $1
1047 addq $19, $1, $19
1048 mulq $23, $7, $2
1049 umulh $23, $7, $17
1050 addq $9, $2, $9
1051 cmpult $9, $2, $10
1052 addq $10, $17, $17
1053 addq $20, $17, $20
1054 cmpult $20, $17, $0
1055 addq $19, $0, $19
1056 mulq $25, $5, $18
1057 umulh $25, $5, $1
1058 addq $9, $18, $9
1059 cmpult $9, $18, $2
1060 addq $2, $1, $1
1061 addq $20, $1, $20
1062 cmpult $20, $1, $10
1063 addq $19, $10, $19
1064 mulq $28, $3, $17
1065 umulh $28, $3, $0
1066 addq $9, $17, $9
1067 cmpult $9, $17, $18
1068 addq $18, $0, $0
1069 addq $20, $0, $20
1070 cmpult $20, $0, $2
1071 addq $19, $2, $19
1072 stq $9, 64($16)
1073 bis $31, $31, $9
1074 mulq $4, $21, $1
1075 umulh $4, $21, $10
1076 addq $20, $1, $20
1077 cmpult $20, $1, $17
1078 addq $17, $10, $10
1079 addq $19, $10, $19
1080 cmpult $19, $10, $18
1081 addq $9, $18, $9
1082 mulq $6, $27, $0
1083 umulh $6, $27, $2
1084 addq $20, $0, $20
1085 cmpult $20, $0, $3
1086 addq $3, $2, $2
1087 addq $19, $2, $19
1088 cmpult $19, $2, $1
1089 addq $9, $1, $9
1090 mulq $8, $24, $17
1091 umulh $8, $24, $10
1092 addq $20, $17, $20
1093 cmpult $20, $17, $18
1094 addq $18, $10, $10
1095 addq $19, $10, $19
1096 cmpult $19, $10, $4
1097 addq $9, $4, $9
1098 mulq $23, $22, $0
1099 umulh $23, $22, $3
1100 addq $20, $0, $20
1101 cmpult $20, $0, $2
1102 addq $2, $3, $3
1103 addq $19, $3, $19
1104 cmpult $19, $3, $1
1105 addq $9, $1, $9
1106 mulq $25, $7, $17
1107 umulh $25, $7, $18
1108 addq $20, $17, $20
1109 cmpult $20, $17, $10
1110 addq $10, $18, $18
1111 addq $19, $18, $19
1112 cmpult $19, $18, $4
1113 addq $9, $4, $9
1114 mulq $28, $5, $0
1115 umulh $28, $5, $2
1116 addq $20, $0, $20
1117 cmpult $20, $0, $3
1118 addq $3, $2, $2
1119 addq $19, $2, $19
1120 cmpult $19, $2, $1
1121 addq $9, $1, $9
1122 stq $20, 72($16)
1123 bis $31, $31, $20
1124 mulq $6, $21, $17
1125 umulh $6, $21, $10
1126 addq $19, $17, $19
1127 cmpult $19, $17, $18
1128 addq $18, $10, $10
1129 addq $9, $10, $9
1130 cmpult $9, $10, $4
1131 addq $20, $4, $20
1132 mulq $8, $27, $0
1133 umulh $8, $27, $3
1134 addq $19, $0, $19
1135 cmpult $19, $0, $2
1136 addq $2, $3, $3
1137 addq $9, $3, $9
1138 cmpult $9, $3, $1
1139 addq $20, $1, $20
1140 mulq $23, $24, $5
1141 umulh $23, $24, $17
1142 addq $19, $5, $19
1143 cmpult $19, $5, $18
1144 addq $18, $17, $17
1145 addq $9, $17, $9
1146 cmpult $9, $17, $10
1147 addq $20, $10, $20
1148 mulq $25, $22, $4
1149 umulh $25, $22, $6
1150 addq $19, $4, $19
1151 cmpult $19, $4, $0
1152 addq $0, $6, $6
1153 addq $9, $6, $9
1154 cmpult $9, $6, $2
1155 addq $20, $2, $20
1156 mulq $28, $7, $3
1157 umulh $28, $7, $1
1158 addq $19, $3, $19
1159 cmpult $19, $3, $5
1160 addq $5, $1, $1
1161 addq $9, $1, $9
1162 cmpult $9, $1, $18
1163 addq $20, $18, $20
1164 stq $19, 80($16)
1165 bis $31, $31, $19
1166 mulq $8, $21, $17
1167 umulh $8, $21, $10
1168 addq $9, $17, $9
1169 cmpult $9, $17, $4
1170 addq $4, $10, $10
1171 addq $20, $10, $20
1172 cmpult $20, $10, $0
1173 addq $19, $0, $19
1174 mulq $23, $27, $6
1175 umulh $23, $27, $2
1176 addq $9, $6, $9
1177 cmpult $9, $6, $3
1178 addq $3, $2, $2
1179 addq $20, $2, $20 797 addq $20, $2, $20
1180 cmpult $20, $2, $5 798 bis $20, $20, $7
1181 addq $19, $5, $19 799 ldq $4, 8($17)
1182 mulq $25, $24, $1 800 addq $24, $7, $24
1183 umulh $25, $24, $18 801 srl $1, 32, $8
1184 addq $9, $1, $9 802 cmpult $24, $7, $3
1185 cmpult $9, $1, $7 803 zapnot $4, 15, $7
1186 addq $7, $18, $18 804 mulq $8, $7, $25
1187 addq $20, $18, $20 805 zapnot $1, 15, $5
1188 cmpult $20, $18, $17 806 mulq $7, $5, $0
1189 addq $19, $17, $19 807 srl $22, 32, $1
1190 mulq $28, $22, $4 808 cmpult $20, $2, $2
1191 umulh $28, $22, $10 809 addq $6, $1, $6
1192 addq $9, $4, $9 810 addq $2, $6, $6
1193 cmpult $9, $4, $0 811 addq $3, $6, $6
1194 addq $0, $10, $10 812 addq $23, $6, $23
1195 addq $20, $10, $20 813 cmpult $23, $6, $22
1196 cmpult $20, $10, $8 814 srl $4, 32, $6
1197 addq $19, $8, $19 815 mulq $5, $6, $5
1198 stq $9, 88($16) 816 bis $31, 1, $21
1199 bis $31, $31, $9 817 addq $25, $5, $25
1200 mulq $23, $21, $6 818 cmpult $25, $5, $1
1201 umulh $23, $21, $3 819 mulq $6, $8, $6
1202 addq $20, $6, $20 820 beq $1, $189
1203 cmpult $20, $6, $2 821 sll $21, 32, $1
1204 addq $2, $3, $3 822 addq $6, $1, $6
1205 addq $19, $3, $19 823$189:
1206 cmpult $19, $3, $5 824 sll $25, 32, $5
1207 addq $9, $5, $9 825 ldq $2, 16($18)
1208 mulq $25, $27, $1 826 addq $0, $5, $0
1209 umulh $25, $27, $7 827 bis $0, $0, $7
1210 addq $20, $1, $20 828 ldq $4, 0($17)
1211 cmpult $20, $1, $18 829 addq $24, $7, $24
1212 addq $18, $7, $7 830 srl $2, 32, $8
1213 addq $19, $7, $19 831 cmpult $24, $7, $3
1214 cmpult $19, $7, $17 832 zapnot $4, 15, $7
1215 addq $9, $17, $9 833 mulq $8, $7, $28
1216 mulq $28, $24, $4 834 srl $25, 32, $1
1217 umulh $28, $24, $0 835 addq $6, $1, $6
1218 addq $20, $4, $20 836 cmpult $0, $5, $1
1219 cmpult $20, $4, $10 837 zapnot $2, 15, $5
1220 addq $10, $0, $0 838 addq $1, $6, $6
1221 addq $19, $0, $19 839 addq $3, $6, $6
1222 cmpult $19, $0, $8 840 addq $23, $6, $23
1223 addq $9, $8, $9 841 cmpult $23, $6, $1
1224 stq $20, 96($16) 842 srl $4, 32, $6
1225 bis $31, $31, $20 843 mulq $5, $6, $25
1226 mulq $25, $21, $22 844 mulq $7, $5, $2
1227 umulh $25, $21, $6 845 addq $1, $22, $22
1228 addq $19, $22, $19 846 addq $28, $25, $28
1229 cmpult $19, $22, $2 847 cmpult $28, $25, $1
848 mulq $6, $8, $6
849 beq $1, $193
850 sll $21, 32, $1
851 addq $6, $1, $6
852$193:
853 sll $28, 32, $25
854 addq $2, $25, $2
855 bis $2, $2, $7
856 addq $24, $7, $24
857 stq $24, 16($16)
858 ldq $4, 0($17)
859 ldq $5, 24($18)
860 cmpult $24, $7, $3
861 zapnot $4, 15, $7
862 srl $5, 32, $8
863 mulq $8, $7, $0
864 srl $28, 32, $1
865 cmpult $2, $25, $2
866 addq $6, $1, $6
867 addq $2, $6, $6
868 addq $3, $6, $6
869 addq $23, $6, $23
870 cmpult $23, $6, $1
871 srl $4, 32, $6
872 zapnot $5, 15, $5
873 mulq $5, $6, $24
874 mulq $7, $5, $2
875 addq $1, $22, $22
876 addq $0, $24, $0
877 cmpult $0, $24, $1
878 mulq $6, $8, $6
879 beq $1, $197
880 sll $21, 32, $1
881 addq $6, $1, $6
882$197:
883 sll $0, 32, $24
884 ldq $1, 16($18)
885 addq $2, $24, $2
886 bis $2, $2, $7
887 ldq $4, 8($17)
888 addq $23, $7, $23
889 srl $1, 32, $8
890 cmpult $23, $7, $3
891 zapnot $4, 15, $7
892 mulq $8, $7, $25
893 zapnot $1, 15, $5
894 mulq $7, $5, $21
895 srl $0, 32, $1
896 cmpult $2, $24, $2
897 addq $6, $1, $6
898 addq $2, $6, $6
899 addq $3, $6, $6
900 addq $22, $6, $22
901 cmpult $22, $6, $24
902 srl $4, 32, $6
903 mulq $5, $6, $5
904 bis $31, 1, $20
905 addq $25, $5, $25
906 cmpult $25, $5, $1
907 mulq $6, $8, $6
908 beq $1, $201
909 sll $20, 32, $1
910 addq $6, $1, $6
911$201:
912 sll $25, 32, $5
913 ldq $2, 8($18)
914 addq $21, $5, $21
915 bis $21, $21, $7
916 ldq $4, 16($17)
917 addq $23, $7, $23
918 srl $2, 32, $8
919 cmpult $23, $7, $3
920 zapnot $4, 15, $7
921 mulq $8, $7, $28
922 srl $25, 32, $1
923 addq $6, $1, $6
924 cmpult $21, $5, $1
925 zapnot $2, 15, $5
926 addq $1, $6, $6
927 addq $3, $6, $6
928 addq $22, $6, $22
929 cmpult $22, $6, $1
930 srl $4, 32, $6
931 mulq $5, $6, $25
932 mulq $7, $5, $5
933 addq $1, $24, $24
934 addq $28, $25, $28
935 cmpult $28, $25, $1
936 mulq $6, $8, $6
937 beq $1, $205
938 sll $20, 32, $1
939 addq $6, $1, $6
940$205:
941 sll $28, 32, $25
942 ldq $2, 0($18)
943 addq $5, $25, $5
944 bis $5, $5, $7
945 ldq $4, 24($17)
946 addq $23, $7, $23
947 srl $2, 32, $8
948 cmpult $23, $7, $3
949 zapnot $4, 15, $7
950 mulq $8, $7, $0
951 srl $28, 32, $1
952 addq $6, $1, $6
953 cmpult $5, $25, $1
954 zapnot $2, 15, $5
955 addq $1, $6, $6
956 addq $3, $6, $6
957 addq $22, $6, $22
958 cmpult $22, $6, $1
959 srl $4, 32, $6
960 mulq $5, $6, $25
961 mulq $7, $5, $2
962 addq $1, $24, $24
963 addq $0, $25, $0
964 cmpult $0, $25, $1
965 mulq $6, $8, $6
966 beq $1, $209
967 sll $20, 32, $1
968 addq $6, $1, $6
969$209:
970 sll $0, 32, $25
971 addq $2, $25, $2
972 bis $2, $2, $7
973 addq $23, $7, $23
974 stq $23, 24($16)
975 ldq $4, 32($17)
976 ldq $5, 0($18)
977 cmpult $23, $7, $3
978 zapnot $4, 15, $7
979 srl $5, 32, $8
980 mulq $8, $7, $28
981 srl $0, 32, $1
982 cmpult $2, $25, $2
983 addq $6, $1, $6
984 addq $2, $6, $6
985 addq $3, $6, $6
986 addq $22, $6, $22
987 cmpult $22, $6, $1
988 srl $4, 32, $6
989 zapnot $5, 15, $5
990 mulq $5, $6, $23
991 mulq $7, $5, $2
992 addq $1, $24, $24
993 addq $28, $23, $28
994 cmpult $28, $23, $1
995 mulq $6, $8, $6
996 beq $1, $213
997 sll $20, 32, $1
998 addq $6, $1, $6
999$213:
1000 sll $28, 32, $23
1001 ldq $1, 8($18)
1002 addq $2, $23, $2
1003 bis $2, $2, $7
1004 ldq $4, 24($17)
1005 addq $22, $7, $22
1006 srl $1, 32, $8
1007 cmpult $22, $7, $3
1008 zapnot $4, 15, $7
1009 mulq $8, $7, $25
1010 zapnot $1, 15, $5
1011 mulq $7, $5, $0
1012 srl $28, 32, $1
1013 cmpult $2, $23, $2
1014 addq $6, $1, $6
1230 addq $2, $6, $6 1015 addq $2, $6, $6
1231 addq $9, $6, $9 1016 addq $3, $6, $6
1232 cmpult $9, $6, $3 1017 addq $24, $6, $24
1233 addq $20, $3, $20 1018 cmpult $24, $6, $23
1234 mulq $28, $27, $5 1019 srl $4, 32, $6
1235 umulh $28, $27, $23 1020 mulq $5, $6, $5
1236 addq $19, $5, $19 1021 bis $31, 1, $21
1237 cmpult $19, $5, $1 1022 addq $25, $5, $25
1023 cmpult $25, $5, $1
1024 mulq $6, $8, $6
1025 beq $1, $217
1026 sll $21, 32, $1
1027 addq $6, $1, $6
1028$217:
1029 sll $25, 32, $5
1030 ldq $2, 16($18)
1031 addq $0, $5, $0
1032 bis $0, $0, $7
1033 ldq $4, 16($17)
1034 addq $22, $7, $22
1035 srl $2, 32, $8
1036 cmpult $22, $7, $3
1037 zapnot $4, 15, $7
1038 mulq $8, $7, $28
1039 srl $25, 32, $1
1040 addq $6, $1, $6
1041 cmpult $0, $5, $1
1042 zapnot $2, 15, $5
1043 addq $1, $6, $6
1044 addq $3, $6, $6
1045 addq $24, $6, $24
1046 cmpult $24, $6, $1
1047 srl $4, 32, $6
1048 mulq $5, $6, $25
1049 mulq $7, $5, $5
1238 addq $1, $23, $23 1050 addq $1, $23, $23
1239 addq $9, $23, $9 1051 addq $28, $25, $28
1240 cmpult $9, $23, $18 1052 cmpult $28, $25, $1
1241 addq $20, $18, $20 1053 mulq $6, $8, $6
1242 stq $19, 104($16) 1054 beq $1, $221
1243 bis $31, $31, $19 1055 sll $21, 32, $1
1244 mulq $28, $21, $7 1056 addq $6, $1, $6
1245 umulh $28, $21, $17 1057$221:
1246 addq $9, $7, $9 1058 sll $28, 32, $25
1247 cmpult $9, $7, $4 1059 ldq $2, 24($18)
1248 addq $4, $17, $17 1060 addq $5, $25, $5
1249 addq $20, $17, $20 1061 bis $5, $5, $7
1250 cmpult $20, $17, $10 1062 ldq $4, 8($17)
1251 addq $19, $10, $19 1063 addq $22, $7, $22
1252 stq $9, 112($16) 1064 srl $2, 32, $8
1253 stq $20, 120($16) 1065 cmpult $22, $7, $3
1254 ldq $9, 0($30) 1066 zapnot $4, 15, $7
1255 ldq $10, 8($30) 1067 mulq $8, $7, $0
1256 addq $30, 16, $30 1068 srl $28, 32, $1
1257 ret $31,($26),1 1069 addq $6, $1, $6
1070 cmpult $5, $25, $1
1071 zapnot $2, 15, $5
1072 addq $1, $6, $6
1073 addq $3, $6, $6
1074 addq $24, $6, $24
1075 cmpult $24, $6, $1
1076 srl $4, 32, $6
1077 mulq $5, $6, $25
1078 mulq $7, $5, $5
1079 addq $1, $23, $23
1080 addq $0, $25, $0
1081 cmpult $0, $25, $1
1082 mulq $6, $8, $6
1083 beq $1, $225
1084 sll $21, 32, $1
1085 addq $6, $1, $6
1086$225:
1087 sll $0, 32, $25
1088 ldq $2, 32($18)
1089 addq $5, $25, $5
1090 bis $5, $5, $7
1091 ldq $4, 0($17)
1092 addq $22, $7, $22
1093 srl $2, 32, $8
1094 cmpult $22, $7, $3
1095 zapnot $4, 15, $7
1096 mulq $8, $7, $28
1097 srl $0, 32, $1
1098 addq $6, $1, $6
1099 cmpult $5, $25, $1
1100 zapnot $2, 15, $5
1101 addq $1, $6, $6
1102 addq $3, $6, $6
1103 addq $24, $6, $24
1104 cmpult $24, $6, $1
1105 srl $4, 32, $6
1106 mulq $5, $6, $25
1107 mulq $7, $5, $2
1108 addq $1, $23, $23
1109 addq $28, $25, $28
1110 cmpult $28, $25, $1
1111 mulq $6, $8, $6
1112 beq $1, $229
1113 sll $21, 32, $1
1114 addq $6, $1, $6
1115$229:
1116 sll $28, 32, $25
1117 addq $2, $25, $2
1118 bis $2, $2, $7
1119 addq $22, $7, $22
1120 stq $22, 32($16)
1121 ldq $4, 0($17)
1122 ldq $5, 40($18)
1123 cmpult $22, $7, $3
1124 zapnot $4, 15, $7
1125 srl $5, 32, $8
1126 mulq $8, $7, $0
1127 srl $28, 32, $1
1128 cmpult $2, $25, $2
1129 addq $6, $1, $6
1130 addq $2, $6, $6
1131 addq $3, $6, $6
1132 addq $24, $6, $24
1133 cmpult $24, $6, $1
1134 srl $4, 32, $6
1135 zapnot $5, 15, $5
1136 mulq $5, $6, $22
1137 mulq $7, $5, $2
1138 addq $1, $23, $23
1139 addq $0, $22, $0
1140 cmpult $0, $22, $1
1141 mulq $6, $8, $6
1142 beq $1, $233
1143 sll $21, 32, $1
1144 addq $6, $1, $6
1145$233:
1146 sll $0, 32, $22
1147 ldq $1, 32($18)
1148 addq $2, $22, $2
1149 bis $2, $2, $7
1150 ldq $4, 8($17)
1151 addq $24, $7, $24
1152 srl $1, 32, $8
1153 cmpult $24, $7, $3
1154 zapnot $4, 15, $7
1155 mulq $8, $7, $25
1156 zapnot $1, 15, $5
1157 mulq $7, $5, $21
1158 srl $0, 32, $1
1159 cmpult $2, $22, $2
1160 addq $6, $1, $6
1161 addq $2, $6, $6
1162 addq $3, $6, $6
1163 addq $23, $6, $23
1164 cmpult $23, $6, $22
1165 srl $4, 32, $6
1166 mulq $5, $6, $5
1167 bis $31, 1, $20
1168 addq $25, $5, $25
1169 cmpult $25, $5, $1
1170 mulq $6, $8, $6
1171 beq $1, $237
1172 sll $20, 32, $1
1173 addq $6, $1, $6
1174$237:
1175 sll $25, 32, $5
1176 ldq $2, 24($18)
1177 addq $21, $5, $21
1178 bis $21, $21, $7
1179 ldq $4, 16($17)
1180 addq $24, $7, $24
1181 srl $2, 32, $8
1182 cmpult $24, $7, $3
1183 zapnot $4, 15, $7
1184 mulq $8, $7, $28
1185 srl $25, 32, $1
1186 addq $6, $1, $6
1187 cmpult $21, $5, $1
1188 zapnot $2, 15, $5
1189 addq $1, $6, $6
1190 addq $3, $6, $6
1191 addq $23, $6, $23
1192 cmpult $23, $6, $1
1193 srl $4, 32, $6
1194 mulq $5, $6, $25
1195 mulq $7, $5, $5
1196 addq $1, $22, $22
1197 addq $28, $25, $28
1198 cmpult $28, $25, $1
1199 mulq $6, $8, $6
1200 beq $1, $241
1201 sll $20, 32, $1
1202 addq $6, $1, $6
1203$241:
1204 sll $28, 32, $25
1205 ldq $2, 16($18)
1206 addq $5, $25, $5
1207 bis $5, $5, $7
1208 ldq $4, 24($17)
1209 addq $24, $7, $24
1210 srl $2, 32, $8
1211 cmpult $24, $7, $3
1212 zapnot $4, 15, $7
1213 mulq $8, $7, $0
1214 srl $28, 32, $1
1215 addq $6, $1, $6
1216 cmpult $5, $25, $1
1217 zapnot $2, 15, $5
1218 addq $1, $6, $6
1219 addq $3, $6, $6
1220 addq $23, $6, $23
1221 cmpult $23, $6, $1
1222 srl $4, 32, $6
1223 mulq $5, $6, $25
1224 mulq $7, $5, $5
1225 addq $1, $22, $22
1226 addq $0, $25, $0
1227 cmpult $0, $25, $1
1228 mulq $6, $8, $6
1229 beq $1, $245
1230 sll $20, 32, $1
1231 addq $6, $1, $6
1232$245:
1233 sll $0, 32, $25
1234 ldq $2, 8($18)
1235 addq $5, $25, $5
1236 bis $5, $5, $7
1237 ldq $4, 32($17)
1238 addq $24, $7, $24
1239 srl $2, 32, $8
1240 cmpult $24, $7, $3
1241 zapnot $4, 15, $7
1242 mulq $8, $7, $28
1243 srl $0, 32, $1
1244 addq $6, $1, $6
1245 cmpult $5, $25, $1
1246 zapnot $2, 15, $5
1247 addq $1, $6, $6
1248 addq $3, $6, $6
1249 addq $23, $6, $23
1250 cmpult $23, $6, $1
1251 srl $4, 32, $6
1252 mulq $5, $6, $25
1253 mulq $7, $5, $5
1254 addq $1, $22, $22
1255 addq $28, $25, $28
1256 cmpult $28, $25, $1
1257 mulq $6, $8, $6
1258 beq $1, $249
1259 sll $20, 32, $1
1260 addq $6, $1, $6
1261$249:
1262 sll $28, 32, $25
1263 ldq $2, 0($18)
1264 addq $5, $25, $5
1265 bis $5, $5, $7
1266 ldq $4, 40($17)
1267 addq $24, $7, $24
1268 srl $2, 32, $8
1269 cmpult $24, $7, $3
1270 zapnot $4, 15, $7
1271 mulq $8, $7, $0
1272 srl $28, 32, $1
1273 addq $6, $1, $6
1274 cmpult $5, $25, $1
1275 zapnot $2, 15, $5
1276 addq $1, $6, $6
1277 addq $3, $6, $6
1278 addq $23, $6, $23
1279 cmpult $23, $6, $1
1280 srl $4, 32, $6
1281 mulq $5, $6, $25
1282 mulq $7, $5, $2
1283 addq $1, $22, $22
1284 addq $0, $25, $0
1285 cmpult $0, $25, $1
1286 mulq $6, $8, $6
1287 beq $1, $253
1288 sll $20, 32, $1
1289 addq $6, $1, $6
1290$253:
1291 sll $0, 32, $25
1292 addq $2, $25, $2
1293 bis $2, $2, $7
1294 addq $24, $7, $24
1295 stq $24, 40($16)
1296 ldq $4, 48($17)
1297 ldq $5, 0($18)
1298 cmpult $24, $7, $3
1299 zapnot $4, 15, $7
1300 srl $5, 32, $8
1301 mulq $8, $7, $28
1302 srl $0, 32, $1
1303 cmpult $2, $25, $2
1304 addq $6, $1, $6
1305 addq $2, $6, $6
1306 addq $3, $6, $6
1307 addq $23, $6, $23
1308 cmpult $23, $6, $1
1309 srl $4, 32, $6
1310 zapnot $5, 15, $5
1311 mulq $5, $6, $24
1312 mulq $7, $5, $2
1313 addq $1, $22, $22
1314 addq $28, $24, $28
1315 cmpult $28, $24, $1
1316 mulq $6, $8, $6
1317 beq $1, $257
1318 sll $20, 32, $1
1319 addq $6, $1, $6
1320$257:
1321 sll $28, 32, $24
1322 ldq $1, 8($18)
1323 addq $2, $24, $2
1324 bis $2, $2, $7
1325 ldq $4, 40($17)
1326 addq $23, $7, $23
1327 srl $1, 32, $8
1328 cmpult $23, $7, $3
1329 zapnot $4, 15, $7
1330 mulq $8, $7, $25
1331 zapnot $1, 15, $5
1332 mulq $7, $5, $0
1333 srl $28, 32, $1
1334 cmpult $2, $24, $2
1335 addq $6, $1, $6
1336 addq $2, $6, $6
1337 addq $3, $6, $6
1338 addq $22, $6, $22
1339 cmpult $22, $6, $24
1340 srl $4, 32, $6
1341 mulq $5, $6, $5
1342 bis $31, 1, $21
1343 addq $25, $5, $25
1344 cmpult $25, $5, $1
1345 mulq $6, $8, $6
1346 beq $1, $261
1347 sll $21, 32, $1
1348 addq $6, $1, $6
1349$261:
1350 sll $25, 32, $5
1351 ldq $2, 16($18)
1352 addq $0, $5, $0
1353 bis $0, $0, $7
1354 ldq $4, 32($17)
1355 addq $23, $7, $23
1356 srl $2, 32, $8
1357 cmpult $23, $7, $3
1358 zapnot $4, 15, $7
1359 mulq $8, $7, $28
1360 srl $25, 32, $1
1361 addq $6, $1, $6
1362 cmpult $0, $5, $1
1363 zapnot $2, 15, $5
1364 addq $1, $6, $6
1365 addq $3, $6, $6
1366 addq $22, $6, $22
1367 cmpult $22, $6, $1
1368 srl $4, 32, $6
1369 mulq $5, $6, $25
1370 mulq $7, $5, $5
1371 addq $1, $24, $24
1372 addq $28, $25, $28
1373 cmpult $28, $25, $1
1374 mulq $6, $8, $6
1375 beq $1, $265
1376 sll $21, 32, $1
1377 addq $6, $1, $6
1378$265:
1379 sll $28, 32, $25
1380 ldq $2, 24($18)
1381 addq $5, $25, $5
1382 bis $5, $5, $7
1383 ldq $4, 24($17)
1384 addq $23, $7, $23
1385 srl $2, 32, $8
1386 cmpult $23, $7, $3
1387 zapnot $4, 15, $7
1388 mulq $8, $7, $0
1389 srl $28, 32, $1
1390 addq $6, $1, $6
1391 cmpult $5, $25, $1
1392 zapnot $2, 15, $5
1393 addq $1, $6, $6
1394 addq $3, $6, $6
1395 addq $22, $6, $22
1396 cmpult $22, $6, $1
1397 srl $4, 32, $6
1398 mulq $5, $6, $25
1399 mulq $7, $5, $5
1400 addq $1, $24, $24
1401 addq $0, $25, $0
1402 cmpult $0, $25, $1
1403 mulq $6, $8, $6
1404 beq $1, $269
1405 sll $21, 32, $1
1406 addq $6, $1, $6
1407$269:
1408 sll $0, 32, $25
1409 ldq $2, 32($18)
1410 addq $5, $25, $5
1411 bis $5, $5, $7
1412 ldq $4, 16($17)
1413 addq $23, $7, $23
1414 srl $2, 32, $8
1415 cmpult $23, $7, $3
1416 zapnot $4, 15, $7
1417 mulq $8, $7, $28
1418 srl $0, 32, $1
1419 addq $6, $1, $6
1420 cmpult $5, $25, $1
1421 zapnot $2, 15, $5
1422 addq $1, $6, $6
1423 addq $3, $6, $6
1424 addq $22, $6, $22
1425 cmpult $22, $6, $1
1426 srl $4, 32, $6
1427 mulq $5, $6, $25
1428 mulq $7, $5, $5
1429 addq $1, $24, $24
1430 addq $28, $25, $28
1431 cmpult $28, $25, $1
1432 mulq $6, $8, $6
1433 beq $1, $273
1434 sll $21, 32, $1
1435 addq $6, $1, $6
1436$273:
1437 sll $28, 32, $25
1438 ldq $2, 40($18)
1439 addq $5, $25, $5
1440 bis $5, $5, $7
1441 ldq $4, 8($17)
1442 addq $23, $7, $23
1443 srl $2, 32, $8
1444 cmpult $23, $7, $3
1445 zapnot $4, 15, $7
1446 mulq $8, $7, $0
1447 srl $28, 32, $1
1448 addq $6, $1, $6
1449 cmpult $5, $25, $1
1450 zapnot $2, 15, $5
1451 addq $1, $6, $6
1452 addq $3, $6, $6
1453 addq $22, $6, $22
1454 cmpult $22, $6, $1
1455 srl $4, 32, $6
1456 mulq $5, $6, $25
1457 mulq $7, $5, $5
1458 addq $1, $24, $24
1459 addq $0, $25, $0
1460 cmpult $0, $25, $1
1461 mulq $6, $8, $6
1462 beq $1, $277
1463 sll $21, 32, $1
1464 addq $6, $1, $6
1465$277:
1466 sll $0, 32, $25
1467 ldq $2, 48($18)
1468 addq $5, $25, $5
1469 bis $5, $5, $7
1470 ldq $4, 0($17)
1471 addq $23, $7, $23
1472 srl $2, 32, $8
1473 cmpult $23, $7, $3
1474 zapnot $4, 15, $7
1475 mulq $8, $7, $28
1476 srl $0, 32, $1
1477 addq $6, $1, $6
1478 cmpult $5, $25, $1
1479 zapnot $2, 15, $5
1480 addq $1, $6, $6
1481 addq $3, $6, $6
1482 addq $22, $6, $22
1483 cmpult $22, $6, $1
1484 srl $4, 32, $6
1485 mulq $5, $6, $25
1486 mulq $7, $5, $2
1487 addq $1, $24, $24
1488 addq $28, $25, $28
1489 cmpult $28, $25, $1
1490 mulq $6, $8, $6
1491 beq $1, $281
1492 sll $21, 32, $1
1493 addq $6, $1, $6
1494$281:
1495 sll $28, 32, $25
1496 addq $2, $25, $2
1497 bis $2, $2, $7
1498 addq $23, $7, $23
1499 stq $23, 48($16)
1500 ldq $4, 0($17)
1501 ldq $5, 56($18)
1502 cmpult $23, $7, $3
1503 zapnot $4, 15, $7
1504 srl $5, 32, $8
1505 mulq $8, $7, $0
1506 srl $28, 32, $1
1507 cmpult $2, $25, $2
1508 addq $6, $1, $6
1509 addq $2, $6, $6
1510 addq $3, $6, $6
1511 addq $22, $6, $22
1512 cmpult $22, $6, $1
1513 srl $4, 32, $6
1514 zapnot $5, 15, $5
1515 mulq $5, $6, $23
1516 mulq $7, $5, $2
1517 addq $1, $24, $24
1518 addq $0, $23, $0
1519 cmpult $0, $23, $1
1520 mulq $6, $8, $6
1521 beq $1, $285
1522 sll $21, 32, $1
1523 addq $6, $1, $6
1524$285:
1525 sll $0, 32, $23
1526 ldq $1, 48($18)
1527 addq $2, $23, $2
1528 bis $2, $2, $7
1529 ldq $4, 8($17)
1530 addq $22, $7, $22
1531 srl $1, 32, $8
1532 cmpult $22, $7, $3
1533 zapnot $4, 15, $7
1534 mulq $8, $7, $25
1535 zapnot $1, 15, $5
1536 mulq $7, $5, $21
1537 srl $0, 32, $1
1538 cmpult $2, $23, $2
1539 addq $6, $1, $6
1540 addq $2, $6, $6
1541 addq $3, $6, $6
1542 addq $24, $6, $24
1543 cmpult $24, $6, $23
1544 srl $4, 32, $6
1545 mulq $5, $6, $5
1546 bis $31, 1, $20
1547 addq $25, $5, $25
1548 cmpult $25, $5, $1
1549 mulq $6, $8, $6
1550 beq $1, $289
1551 sll $20, 32, $1
1552 addq $6, $1, $6
1553$289:
1554 sll $25, 32, $5
1555 ldq $2, 40($18)
1556 addq $21, $5, $21
1557 bis $21, $21, $7
1558 ldq $4, 16($17)
1559 addq $22, $7, $22
1560 srl $2, 32, $8
1561 cmpult $22, $7, $3
1562 zapnot $4, 15, $7
1563 mulq $8, $7, $28
1564 srl $25, 32, $1
1565 addq $6, $1, $6
1566 cmpult $21, $5, $1
1567 zapnot $2, 15, $5
1568 addq $1, $6, $6
1569 addq $3, $6, $6
1570 addq $24, $6, $24
1571 cmpult $24, $6, $1
1572 srl $4, 32, $6
1573 mulq $5, $6, $25
1574 mulq $7, $5, $5
1575 addq $1, $23, $23
1576 addq $28, $25, $28
1577 cmpult $28, $25, $1
1578 mulq $6, $8, $6
1579 beq $1, $293
1580 sll $20, 32, $1
1581 addq $6, $1, $6
1582$293:
1583 sll $28, 32, $25
1584 ldq $2, 32($18)
1585 addq $5, $25, $5
1586 bis $5, $5, $7
1587 ldq $4, 24($17)
1588 addq $22, $7, $22
1589 srl $2, 32, $8
1590 cmpult $22, $7, $3
1591 zapnot $4, 15, $7
1592 mulq $8, $7, $0
1593 srl $28, 32, $1
1594 addq $6, $1, $6
1595 cmpult $5, $25, $1
1596 zapnot $2, 15, $5
1597 addq $1, $6, $6
1598 addq $3, $6, $6
1599 addq $24, $6, $24
1600 cmpult $24, $6, $1
1601 srl $4, 32, $6
1602 mulq $5, $6, $25
1603 mulq $7, $5, $5
1604 addq $1, $23, $23
1605 addq $0, $25, $0
1606 cmpult $0, $25, $1
1607 mulq $6, $8, $6
1608 beq $1, $297
1609 sll $20, 32, $1
1610 addq $6, $1, $6
1611$297:
1612 sll $0, 32, $25
1613 ldq $2, 24($18)
1614 addq $5, $25, $5
1615 bis $5, $5, $7
1616 ldq $4, 32($17)
1617 addq $22, $7, $22
1618 srl $2, 32, $8
1619 cmpult $22, $7, $3
1620 zapnot $4, 15, $7
1621 mulq $8, $7, $28
1622 srl $0, 32, $1
1623 addq $6, $1, $6
1624 cmpult $5, $25, $1
1625 zapnot $2, 15, $5
1626 addq $1, $6, $6
1627 addq $3, $6, $6
1628 addq $24, $6, $24
1629 cmpult $24, $6, $1
1630 srl $4, 32, $6
1631 mulq $5, $6, $25
1632 mulq $7, $5, $5
1633 addq $1, $23, $23
1634 addq $28, $25, $28
1635 cmpult $28, $25, $1
1636 mulq $6, $8, $6
1637 beq $1, $301
1638 sll $20, 32, $1
1639 addq $6, $1, $6
1640$301:
1641 sll $28, 32, $25
1642 ldq $2, 16($18)
1643 addq $5, $25, $5
1644 bis $5, $5, $7
1645 ldq $4, 40($17)
1646 addq $22, $7, $22
1647 srl $2, 32, $8
1648 cmpult $22, $7, $3
1649 zapnot $4, 15, $7
1650 mulq $8, $7, $0
1651 srl $28, 32, $1
1652 addq $6, $1, $6
1653 cmpult $5, $25, $1
1654 zapnot $2, 15, $5
1655 addq $1, $6, $6
1656 addq $3, $6, $6
1657 addq $24, $6, $24
1658 cmpult $24, $6, $1
1659 srl $4, 32, $6
1660 mulq $5, $6, $25
1661 mulq $7, $5, $5
1662 addq $1, $23, $23
1663 addq $0, $25, $0
1664 cmpult $0, $25, $1
1665 mulq $6, $8, $6
1666 beq $1, $305
1667 sll $20, 32, $1
1668 addq $6, $1, $6
1669$305:
1670 sll $0, 32, $25
1671 ldq $2, 8($18)
1672 addq $5, $25, $5
1673 bis $5, $5, $7
1674 ldq $4, 48($17)
1675 addq $22, $7, $22
1676 srl $2, 32, $8
1677 cmpult $22, $7, $3
1678 zapnot $4, 15, $7
1679 mulq $8, $7, $28
1680 srl $0, 32, $1
1681 addq $6, $1, $6
1682 cmpult $5, $25, $1
1683 zapnot $2, 15, $5
1684 addq $1, $6, $6
1685 addq $3, $6, $6
1686 addq $24, $6, $24
1687 cmpult $24, $6, $1
1688 srl $4, 32, $6
1689 mulq $5, $6, $25
1690 mulq $7, $5, $5
1691 addq $1, $23, $23
1692 addq $28, $25, $28
1693 cmpult $28, $25, $1
1694 mulq $6, $8, $6
1695 beq $1, $309
1696 sll $20, 32, $1
1697 addq $6, $1, $6
1698$309:
1699 sll $28, 32, $25
1700 ldq $2, 0($18)
1701 addq $5, $25, $5
1702 bis $5, $5, $7
1703 ldq $4, 56($17)
1704 addq $22, $7, $22
1705 srl $2, 32, $8
1706 cmpult $22, $7, $3
1707 zapnot $4, 15, $7
1708 mulq $8, $7, $0
1709 srl $28, 32, $1
1710 addq $6, $1, $6
1711 cmpult $5, $25, $1
1712 zapnot $2, 15, $5
1713 addq $1, $6, $6
1714 addq $3, $6, $6
1715 addq $24, $6, $24
1716 cmpult $24, $6, $1
1717 srl $4, 32, $6
1718 mulq $5, $6, $25
1719 mulq $7, $5, $2
1720 addq $1, $23, $23
1721 addq $0, $25, $0
1722 cmpult $0, $25, $1
1723 mulq $6, $8, $6
1724 beq $1, $313
1725 sll $20, 32, $1
1726 addq $6, $1, $6
1727$313:
1728 sll $0, 32, $25
1729 addq $2, $25, $2
1730 bis $2, $2, $7
1731 addq $22, $7, $22
1732 stq $22, 56($16)
1733 ldq $4, 56($17)
1734 ldq $5, 8($18)
1735 cmpult $22, $7, $3
1736 zapnot $4, 15, $7
1737 srl $5, 32, $8
1738 mulq $8, $7, $28
1739 srl $0, 32, $1
1740 cmpult $2, $25, $2
1741 addq $6, $1, $6
1742 addq $2, $6, $6
1743 addq $3, $6, $6
1744 addq $24, $6, $24
1745 cmpult $24, $6, $1
1746 srl $4, 32, $6
1747 zapnot $5, 15, $5
1748 mulq $5, $6, $22
1749 mulq $7, $5, $2
1750 addq $1, $23, $23
1751 addq $28, $22, $28
1752 cmpult $28, $22, $1
1753 mulq $6, $8, $6
1754 beq $1, $317
1755 sll $20, 32, $1
1756 addq $6, $1, $6
1757$317:
1758 sll $28, 32, $22
1759 ldq $1, 16($18)
1760 addq $2, $22, $2
1761 bis $2, $2, $7
1762 ldq $4, 48($17)
1763 addq $24, $7, $24
1764 srl $1, 32, $8
1765 cmpult $24, $7, $3
1766 zapnot $4, 15, $7
1767 mulq $8, $7, $25
1768 zapnot $1, 15, $5
1769 mulq $7, $5, $0
1770 srl $28, 32, $1
1771 cmpult $2, $22, $2
1772 addq $6, $1, $6
1773 addq $2, $6, $6
1774 addq $3, $6, $6
1775 addq $23, $6, $23
1776 cmpult $23, $6, $22
1777 srl $4, 32, $6
1778 mulq $5, $6, $5
1779 bis $31, 1, $21
1780 addq $25, $5, $25
1781 cmpult $25, $5, $1
1782 mulq $6, $8, $6
1783 beq $1, $321
1784 sll $21, 32, $1
1785 addq $6, $1, $6
1786$321:
1787 sll $25, 32, $5
1788 ldq $2, 24($18)
1789 addq $0, $5, $0
1790 bis $0, $0, $7
1791 ldq $4, 40($17)
1792 addq $24, $7, $24
1793 srl $2, 32, $8
1794 cmpult $24, $7, $3
1795 zapnot $4, 15, $7
1796 mulq $8, $7, $28
1797 srl $25, 32, $1
1798 addq $6, $1, $6
1799 cmpult $0, $5, $1
1800 zapnot $2, 15, $5
1801 addq $1, $6, $6
1802 addq $3, $6, $6
1803 addq $23, $6, $23
1804 cmpult $23, $6, $1
1805 srl $4, 32, $6
1806 mulq $5, $6, $25
1807 mulq $7, $5, $5
1808 addq $1, $22, $22
1809 addq $28, $25, $28
1810 cmpult $28, $25, $1
1811 mulq $6, $8, $6
1812 beq $1, $325
1813 sll $21, 32, $1
1814 addq $6, $1, $6
1815$325:
1816 sll $28, 32, $25
1817 ldq $2, 32($18)
1818 addq $5, $25, $5
1819 bis $5, $5, $7
1820 ldq $4, 32($17)
1821 addq $24, $7, $24
1822 srl $2, 32, $8
1823 cmpult $24, $7, $3
1824 zapnot $4, 15, $7
1825 mulq $8, $7, $0
1826 srl $28, 32, $1
1827 addq $6, $1, $6
1828 cmpult $5, $25, $1
1829 zapnot $2, 15, $5
1830 addq $1, $6, $6
1831 addq $3, $6, $6
1832 addq $23, $6, $23
1833 cmpult $23, $6, $1
1834 srl $4, 32, $6
1835 mulq $5, $6, $25
1836 mulq $7, $5, $5
1837 addq $1, $22, $22
1838 addq $0, $25, $0
1839 cmpult $0, $25, $1
1840 mulq $6, $8, $6
1841 beq $1, $329
1842 sll $21, 32, $1
1843 addq $6, $1, $6
1844$329:
1845 sll $0, 32, $25
1846 ldq $2, 40($18)
1847 addq $5, $25, $5
1848 bis $5, $5, $7
1849 ldq $4, 24($17)
1850 addq $24, $7, $24
1851 srl $2, 32, $8
1852 cmpult $24, $7, $3
1853 zapnot $4, 15, $7
1854 mulq $8, $7, $28
1855 srl $0, 32, $1
1856 addq $6, $1, $6
1857 cmpult $5, $25, $1
1858 zapnot $2, 15, $5
1859 addq $1, $6, $6
1860 addq $3, $6, $6
1861 addq $23, $6, $23
1862 cmpult $23, $6, $1
1863 srl $4, 32, $6
1864 mulq $5, $6, $25
1865 mulq $7, $5, $5
1866 addq $1, $22, $22
1867 addq $28, $25, $28
1868 cmpult $28, $25, $1
1869 mulq $6, $8, $6
1870 beq $1, $333
1871 sll $21, 32, $1
1872 addq $6, $1, $6
1873$333:
1874 sll $28, 32, $25
1875 ldq $2, 48($18)
1876 addq $5, $25, $5
1877 bis $5, $5, $7
1878 ldq $4, 16($17)
1879 addq $24, $7, $24
1880 srl $2, 32, $8
1881 cmpult $24, $7, $3
1882 zapnot $4, 15, $7
1883 mulq $8, $7, $0
1884 srl $28, 32, $1
1885 addq $6, $1, $6
1886 cmpult $5, $25, $1
1887 zapnot $2, 15, $5
1888 addq $1, $6, $6
1889 addq $3, $6, $6
1890 addq $23, $6, $23
1891 cmpult $23, $6, $1
1892 srl $4, 32, $6
1893 mulq $5, $6, $25
1894 mulq $7, $5, $5
1895 addq $1, $22, $22
1896 addq $0, $25, $0
1897 cmpult $0, $25, $1
1898 mulq $6, $8, $6
1899 beq $1, $337
1900 sll $21, 32, $1
1901 addq $6, $1, $6
1902$337:
1903 sll $0, 32, $25
1904 ldq $2, 56($18)
1905 addq $5, $25, $5
1906 bis $5, $5, $7
1907 ldq $4, 8($17)
1908 addq $24, $7, $24
1909 srl $2, 32, $8
1910 cmpult $24, $7, $3
1911 zapnot $4, 15, $7
1912 mulq $8, $7, $28
1913 srl $0, 32, $1
1914 addq $6, $1, $6
1915 cmpult $5, $25, $1
1916 zapnot $2, 15, $5
1917 addq $1, $6, $6
1918 addq $3, $6, $6
1919 addq $23, $6, $23
1920 cmpult $23, $6, $1
1921 srl $4, 32, $6
1922 mulq $5, $6, $25
1923 mulq $7, $5, $2
1924 addq $1, $22, $22
1925 addq $28, $25, $28
1926 cmpult $28, $25, $1
1927 mulq $6, $8, $6
1928 beq $1, $341
1929 sll $21, 32, $1
1930 addq $6, $1, $6
1931$341:
1932 sll $28, 32, $25
1933 addq $2, $25, $2
1934 bis $2, $2, $7
1935 addq $24, $7, $24
1936 stq $24, 64($16)
1937 ldq $4, 16($17)
1938 ldq $5, 56($18)
1939 cmpult $24, $7, $3
1940 zapnot $4, 15, $7
1941 srl $5, 32, $8
1942 mulq $8, $7, $0
1943 srl $28, 32, $1
1944 cmpult $2, $25, $2
1945 addq $6, $1, $6
1946 addq $2, $6, $6
1947 addq $3, $6, $6
1948 addq $23, $6, $23
1949 cmpult $23, $6, $1
1950 srl $4, 32, $6
1951 zapnot $5, 15, $5
1952 mulq $5, $6, $24
1953 mulq $7, $5, $2
1954 addq $1, $22, $22
1955 addq $0, $24, $0
1956 cmpult $0, $24, $1
1957 mulq $6, $8, $6
1958 beq $1, $345
1959 sll $21, 32, $1
1960 addq $6, $1, $6
1961$345:
1962 sll $0, 32, $24
1963 ldq $1, 48($18)
1964 addq $2, $24, $2
1965 bis $2, $2, $7
1966 ldq $4, 24($17)
1967 addq $23, $7, $23
1968 srl $1, 32, $8
1969 cmpult $23, $7, $3
1970 zapnot $4, 15, $7
1971 mulq $8, $7, $25
1972 zapnot $1, 15, $5
1973 mulq $7, $5, $21
1974 srl $0, 32, $1
1975 cmpult $2, $24, $2
1976 addq $6, $1, $6
1977 addq $2, $6, $6
1978 addq $3, $6, $6
1979 addq $22, $6, $22
1980 cmpult $22, $6, $24
1981 srl $4, 32, $6
1982 mulq $5, $6, $5
1983 bis $31, 1, $20
1984 addq $25, $5, $25
1985 cmpult $25, $5, $1
1986 mulq $6, $8, $6
1987 beq $1, $349
1988 sll $20, 32, $1
1989 addq $6, $1, $6
1990$349:
1991 sll $25, 32, $5
1992 ldq $2, 40($18)
1993 addq $21, $5, $21
1994 bis $21, $21, $7
1995 ldq $4, 32($17)
1996 addq $23, $7, $23
1997 srl $2, 32, $8
1998 cmpult $23, $7, $3
1999 zapnot $4, 15, $7
2000 mulq $8, $7, $28
2001 srl $25, 32, $1
2002 addq $6, $1, $6
2003 cmpult $21, $5, $1
2004 zapnot $2, 15, $5
2005 addq $1, $6, $6
2006 addq $3, $6, $6
2007 addq $22, $6, $22
2008 cmpult $22, $6, $1
2009 srl $4, 32, $6
2010 mulq $5, $6, $25
2011 mulq $7, $5, $5
2012 addq $1, $24, $24
2013 addq $28, $25, $28
2014 cmpult $28, $25, $1
2015 mulq $6, $8, $6
2016 beq $1, $353
2017 sll $20, 32, $1
2018 addq $6, $1, $6
2019$353:
2020 sll $28, 32, $25
2021 ldq $2, 32($18)
2022 addq $5, $25, $5
2023 bis $5, $5, $7
2024 ldq $4, 40($17)
2025 addq $23, $7, $23
2026 srl $2, 32, $8
2027 cmpult $23, $7, $3
2028 zapnot $4, 15, $7
2029 mulq $8, $7, $0
2030 srl $28, 32, $1
2031 addq $6, $1, $6
2032 cmpult $5, $25, $1
2033 zapnot $2, 15, $5
2034 addq $1, $6, $6
2035 addq $3, $6, $6
2036 addq $22, $6, $22
2037 cmpult $22, $6, $1
2038 srl $4, 32, $6
2039 mulq $5, $6, $25
2040 mulq $7, $5, $5
2041 addq $1, $24, $24
2042 addq $0, $25, $0
2043 cmpult $0, $25, $1
2044 mulq $6, $8, $6
2045 beq $1, $357
2046 sll $20, 32, $1
2047 addq $6, $1, $6
2048$357:
2049 sll $0, 32, $25
2050 ldq $2, 24($18)
2051 addq $5, $25, $5
2052 bis $5, $5, $7
2053 ldq $4, 48($17)
2054 addq $23, $7, $23
2055 srl $2, 32, $8
2056 cmpult $23, $7, $3
2057 zapnot $4, 15, $7
2058 mulq $8, $7, $28
2059 srl $0, 32, $1
2060 addq $6, $1, $6
2061 cmpult $5, $25, $1
2062 zapnot $2, 15, $5
2063 addq $1, $6, $6
2064 addq $3, $6, $6
2065 addq $22, $6, $22
2066 cmpult $22, $6, $1
2067 srl $4, 32, $6
2068 mulq $5, $6, $25
2069 mulq $7, $5, $5
2070 addq $1, $24, $24
2071 addq $28, $25, $28
2072 cmpult $28, $25, $1
2073 mulq $6, $8, $6
2074 beq $1, $361
2075 sll $20, 32, $1
2076 addq $6, $1, $6
2077$361:
2078 sll $28, 32, $25
2079 ldq $2, 16($18)
2080 addq $5, $25, $5
2081 bis $5, $5, $7
2082 ldq $4, 56($17)
2083 addq $23, $7, $23
2084 srl $2, 32, $8
2085 cmpult $23, $7, $3
2086 zapnot $4, 15, $7
2087 mulq $8, $7, $0
2088 srl $28, 32, $1
2089 addq $6, $1, $6
2090 cmpult $5, $25, $1
2091 zapnot $2, 15, $5
2092 addq $1, $6, $6
2093 addq $3, $6, $6
2094 addq $22, $6, $22
2095 cmpult $22, $6, $1
2096 srl $4, 32, $6
2097 mulq $5, $6, $25
2098 mulq $7, $5, $2
2099 addq $1, $24, $24
2100 addq $0, $25, $0
2101 cmpult $0, $25, $1
2102 mulq $6, $8, $6
2103 beq $1, $365
2104 sll $20, 32, $1
2105 addq $6, $1, $6
2106$365:
2107 sll $0, 32, $25
2108 addq $2, $25, $2
2109 bis $2, $2, $7
2110 addq $23, $7, $23
2111 stq $23, 72($16)
2112 ldq $4, 56($17)
2113 ldq $5, 24($18)
2114 cmpult $23, $7, $3
2115 zapnot $4, 15, $7
2116 srl $5, 32, $8
2117 mulq $8, $7, $28
2118 srl $0, 32, $1
2119 cmpult $2, $25, $2
2120 addq $6, $1, $6
2121 addq $2, $6, $6
2122 addq $3, $6, $6
2123 addq $22, $6, $22
2124 cmpult $22, $6, $1
2125 srl $4, 32, $6
2126 zapnot $5, 15, $5
2127 mulq $5, $6, $23
2128 mulq $7, $5, $2
2129 addq $1, $24, $24
2130 addq $28, $23, $28
2131 cmpult $28, $23, $1
2132 mulq $6, $8, $6
2133 beq $1, $369
2134 sll $20, 32, $1
2135 addq $6, $1, $6
2136$369:
2137 sll $28, 32, $23
2138 ldq $1, 32($18)
2139 addq $2, $23, $2
2140 bis $2, $2, $7
2141 ldq $4, 48($17)
2142 addq $22, $7, $22
2143 srl $1, 32, $8
2144 cmpult $22, $7, $3
2145 zapnot $4, 15, $7
2146 mulq $8, $7, $25
2147 zapnot $1, 15, $5
2148 mulq $7, $5, $0
2149 srl $28, 32, $1
2150 cmpult $2, $23, $2
2151 addq $6, $1, $6
2152 addq $2, $6, $6
2153 addq $3, $6, $6
2154 addq $24, $6, $24
2155 cmpult $24, $6, $23
2156 srl $4, 32, $6
2157 mulq $5, $6, $5
2158 bis $31, 1, $21
2159 addq $25, $5, $25
2160 cmpult $25, $5, $1
2161 mulq $6, $8, $6
2162 beq $1, $373
2163 sll $21, 32, $1
2164 addq $6, $1, $6
2165$373:
2166 sll $25, 32, $5
2167 ldq $2, 40($18)
2168 addq $0, $5, $0
2169 bis $0, $0, $7
2170 ldq $4, 40($17)
2171 addq $22, $7, $22
2172 srl $2, 32, $8
2173 cmpult $22, $7, $3
2174 zapnot $4, 15, $7
2175 mulq $8, $7, $28
2176 srl $25, 32, $1
2177 addq $6, $1, $6
2178 cmpult $0, $5, $1
2179 zapnot $2, 15, $5
2180 addq $1, $6, $6
2181 addq $3, $6, $6
2182 addq $24, $6, $24
2183 cmpult $24, $6, $1
2184 srl $4, 32, $6
2185 mulq $5, $6, $25
2186 mulq $7, $5, $5
2187 addq $1, $23, $23
2188 addq $28, $25, $28
2189 cmpult $28, $25, $1
2190 mulq $6, $8, $6
2191 beq $1, $377
2192 sll $21, 32, $1
2193 addq $6, $1, $6
2194$377:
2195 sll $28, 32, $25
2196 ldq $2, 48($18)
2197 addq $5, $25, $5
2198 bis $5, $5, $7
2199 ldq $4, 32($17)
2200 addq $22, $7, $22
2201 srl $2, 32, $8
2202 cmpult $22, $7, $3
2203 zapnot $4, 15, $7
2204 mulq $8, $7, $0
2205 srl $28, 32, $1
2206 addq $6, $1, $6
2207 cmpult $5, $25, $1
2208 zapnot $2, 15, $5
2209 addq $1, $6, $6
2210 addq $3, $6, $6
2211 addq $24, $6, $24
2212 cmpult $24, $6, $1
2213 srl $4, 32, $6
2214 mulq $5, $6, $25
2215 mulq $7, $5, $5
2216 addq $1, $23, $23
2217 addq $0, $25, $0
2218 cmpult $0, $25, $1
2219 mulq $6, $8, $6
2220 beq $1, $381
2221 sll $21, 32, $1
2222 addq $6, $1, $6
2223$381:
2224 sll $0, 32, $25
2225 ldq $2, 56($18)
2226 addq $5, $25, $5
2227 bis $5, $5, $7
2228 ldq $4, 24($17)
2229 addq $22, $7, $22
2230 srl $2, 32, $8
2231 cmpult $22, $7, $3
2232 zapnot $4, 15, $7
2233 mulq $8, $7, $28
2234 srl $0, 32, $1
2235 addq $6, $1, $6
2236 cmpult $5, $25, $1
2237 zapnot $2, 15, $5
2238 addq $1, $6, $6
2239 addq $3, $6, $6
2240 addq $24, $6, $24
2241 cmpult $24, $6, $1
2242 srl $4, 32, $6
2243 mulq $5, $6, $25
2244 mulq $7, $5, $2
2245 addq $1, $23, $23
2246 addq $28, $25, $28
2247 cmpult $28, $25, $1
2248 mulq $6, $8, $6
2249 beq $1, $385
2250 sll $21, 32, $1
2251 addq $6, $1, $6
2252$385:
2253 sll $28, 32, $25
2254 addq $2, $25, $2
2255 bis $2, $2, $7
2256 addq $22, $7, $22
2257 stq $22, 80($16)
2258 ldq $4, 32($17)
2259 ldq $5, 56($18)
2260 cmpult $22, $7, $3
2261 zapnot $4, 15, $7
2262 srl $5, 32, $8
2263 mulq $8, $7, $0
2264 srl $28, 32, $1
2265 cmpult $2, $25, $2
2266 addq $6, $1, $6
2267 addq $2, $6, $6
2268 addq $3, $6, $6
2269 addq $24, $6, $24
2270 cmpult $24, $6, $1
2271 srl $4, 32, $6
2272 zapnot $5, 15, $5
2273 mulq $5, $6, $22
2274 mulq $7, $5, $2
2275 addq $1, $23, $23
2276 addq $0, $22, $0
2277 cmpult $0, $22, $1
2278 mulq $6, $8, $6
2279 beq $1, $389
2280 sll $21, 32, $1
2281 addq $6, $1, $6
2282$389:
2283 sll $0, 32, $22
2284 ldq $1, 48($18)
2285 addq $2, $22, $2
2286 bis $2, $2, $7
2287 ldq $4, 40($17)
2288 addq $24, $7, $24
2289 srl $1, 32, $8
2290 cmpult $24, $7, $3
2291 zapnot $4, 15, $7
2292 mulq $8, $7, $25
2293 zapnot $1, 15, $5
2294 mulq $7, $5, $21
2295 srl $0, 32, $1
2296 cmpult $2, $22, $2
2297 addq $6, $1, $6
2298 addq $2, $6, $6
2299 addq $3, $6, $6
2300 addq $23, $6, $23
2301 cmpult $23, $6, $22
2302 srl $4, 32, $6
2303 mulq $5, $6, $5
2304 bis $31, 1, $20
2305 addq $25, $5, $25
2306 cmpult $25, $5, $1
2307 mulq $6, $8, $6
2308 beq $1, $393
2309 sll $20, 32, $1
2310 addq $6, $1, $6
2311$393:
2312 sll $25, 32, $5
2313 ldq $2, 40($18)
2314 addq $21, $5, $21
2315 bis $21, $21, $7
2316 ldq $4, 48($17)
2317 addq $24, $7, $24
2318 srl $2, 32, $8
2319 cmpult $24, $7, $3
2320 zapnot $4, 15, $7
2321 mulq $8, $7, $28
2322 srl $25, 32, $1
2323 addq $6, $1, $6
2324 cmpult $21, $5, $1
2325 zapnot $2, 15, $5
2326 addq $1, $6, $6
2327 addq $3, $6, $6
2328 addq $23, $6, $23
2329 cmpult $23, $6, $1
2330 srl $4, 32, $6
2331 mulq $5, $6, $25
2332 mulq $7, $5, $5
2333 addq $1, $22, $22
2334 addq $28, $25, $28
2335 cmpult $28, $25, $1
2336 mulq $6, $8, $6
2337 beq $1, $397
2338 sll $20, 32, $1
2339 addq $6, $1, $6
2340$397:
2341 sll $28, 32, $25
2342 ldq $2, 32($18)
2343 addq $5, $25, $5
2344 bis $5, $5, $7
2345 ldq $4, 56($17)
2346 addq $24, $7, $24
2347 srl $2, 32, $8
2348 cmpult $24, $7, $3
2349 zapnot $4, 15, $7
2350 mulq $8, $7, $21
2351 srl $28, 32, $1
2352 addq $6, $1, $6
2353 cmpult $5, $25, $1
2354 zapnot $2, 15, $5
2355 addq $1, $6, $6
2356 addq $3, $6, $6
2357 addq $23, $6, $23
2358 cmpult $23, $6, $1
2359 srl $4, 32, $6
2360 mulq $5, $6, $25
2361 mulq $7, $5, $2
2362 addq $1, $22, $22
2363 addq $21, $25, $21
2364 cmpult $21, $25, $1
2365 mulq $6, $8, $6
2366 beq $1, $401
2367 sll $20, 32, $1
2368 addq $6, $1, $6
2369$401:
2370 sll $21, 32, $25
2371 addq $2, $25, $2
2372 bis $2, $2, $7
2373 addq $24, $7, $24
2374 stq $24, 88($16)
2375 ldq $4, 56($17)
2376 ldq $5, 40($18)
2377 cmpult $24, $7, $3
2378 zapnot $4, 15, $7
2379 srl $5, 32, $8
2380 mulq $8, $7, $0
2381 srl $21, 32, $1
2382 cmpult $2, $25, $2
2383 addq $6, $1, $6
2384 addq $2, $6, $6
2385 addq $3, $6, $6
2386 addq $23, $6, $23
2387 cmpult $23, $6, $1
2388 srl $4, 32, $6
2389 zapnot $5, 15, $5
2390 mulq $5, $6, $24
2391 mulq $7, $5, $5
2392 addq $1, $22, $22
2393 addq $0, $24, $0
2394 cmpult $0, $24, $1
2395 mulq $6, $8, $6
2396 beq $1, $405
2397 sll $20, 32, $1
2398 addq $6, $1, $6
2399$405:
2400 sll $0, 32, $24
2401 ldq $2, 48($18)
2402 addq $5, $24, $5
2403 bis $5, $5, $7
2404 ldq $4, 48($17)
2405 addq $23, $7, $23
2406 srl $2, 32, $8
2407 cmpult $23, $7, $3
2408 zapnot $4, 15, $7
2409 mulq $8, $7, $28
2410 srl $0, 32, $1
2411 addq $6, $1, $6
2412 cmpult $5, $24, $1
2413 zapnot $2, 15, $5
2414 addq $1, $6, $6
2415 addq $3, $6, $6
2416 addq $22, $6, $22
2417 cmpult $22, $6, $24
2418 srl $4, 32, $6
2419 mulq $5, $6, $25
2420 mulq $7, $5, $5
2421 addq $28, $25, $28
2422 cmpult $28, $25, $1
2423 mulq $6, $8, $6
2424 beq $1, $409
2425 sll $20, 32, $1
2426 addq $6, $1, $6
2427$409:
2428 sll $28, 32, $25
2429 ldq $2, 56($18)
2430 addq $5, $25, $5
2431 bis $5, $5, $7
2432 ldq $4, 40($17)
2433 addq $23, $7, $23
2434 srl $2, 32, $8
2435 cmpult $23, $7, $3
2436 zapnot $4, 15, $7
2437 mulq $8, $7, $0
2438 srl $28, 32, $1
2439 addq $6, $1, $6
2440 cmpult $5, $25, $1
2441 zapnot $2, 15, $5
2442 addq $1, $6, $6
2443 addq $3, $6, $6
2444 addq $22, $6, $22
2445 cmpult $22, $6, $1
2446 srl $4, 32, $6
2447 mulq $5, $6, $25
2448 mulq $7, $5, $2
2449 addq $1, $24, $24
2450 addq $0, $25, $0
2451 cmpult $0, $25, $1
2452 mulq $6, $8, $6
2453 beq $1, $413
2454 sll $20, 32, $1
2455 addq $6, $1, $6
2456$413:
2457 sll $0, 32, $25
2458 addq $2, $25, $2
2459 bis $2, $2, $7
2460 addq $23, $7, $23
2461 stq $23, 96($16)
2462 ldq $4, 48($17)
2463 ldq $5, 56($18)
2464 cmpult $23, $7, $3
2465 zapnot $4, 15, $7
2466 srl $5, 32, $8
2467 mulq $8, $7, $28
2468 srl $0, 32, $1
2469 cmpult $2, $25, $2
2470 addq $6, $1, $6
2471 addq $2, $6, $6
2472 addq $3, $6, $6
2473 addq $22, $6, $22
2474 cmpult $22, $6, $1
2475 srl $4, 32, $6
2476 zapnot $5, 15, $5
2477 mulq $5, $6, $23
2478 mulq $7, $5, $5
2479 addq $1, $24, $24
2480 addq $28, $23, $28
2481 cmpult $28, $23, $1
2482 mulq $6, $8, $6
2483 beq $1, $417
2484 sll $20, 32, $1
2485 addq $6, $1, $6
2486$417:
2487 sll $28, 32, $23
2488 ldq $2, 48($18)
2489 addq $5, $23, $5
2490 bis $5, $5, $7
2491 ldq $4, 56($17)
2492 addq $22, $7, $22
2493 srl $2, 32, $8
2494 cmpult $22, $7, $3
2495 zapnot $4, 15, $7
2496 mulq $8, $7, $0
2497 srl $28, 32, $1
2498 addq $6, $1, $6
2499 cmpult $5, $23, $1
2500 zapnot $2, 15, $5
2501 addq $1, $6, $6
2502 addq $3, $6, $6
2503 addq $24, $6, $24
2504 cmpult $24, $6, $23
2505 srl $4, 32, $6
2506 mulq $5, $6, $25
2507 mulq $7, $5, $2
2508 addq $0, $25, $0
2509 cmpult $0, $25, $1
2510 mulq $6, $8, $6
2511 beq $1, $421
2512 sll $20, 32, $1
2513 addq $6, $1, $6
2514$421:
2515 sll $0, 32, $25
2516 addq $2, $25, $2
2517 bis $2, $2, $7
2518 addq $22, $7, $22
2519 stq $22, 104($16)
2520 ldq $4, 56($17)
2521 ldq $5, 56($18)
2522 cmpult $22, $7, $3
2523 zapnot $4, 15, $7
2524 srl $5, 32, $8
2525 mulq $8, $7, $28
2526 srl $0, 32, $1
2527 cmpult $2, $25, $2
2528 addq $6, $1, $6
2529 addq $2, $6, $6
2530 addq $3, $6, $6
2531 addq $24, $6, $24
2532 cmpult $24, $6, $1
2533 srl $4, 32, $6
2534 zapnot $5, 15, $5
2535 mulq $5, $6, $22
2536 mulq $7, $5, $2
2537 addq $1, $23, $23
2538 addq $28, $22, $28
2539 cmpult $28, $22, $1
2540 mulq $6, $8, $3
2541 beq $1, $425
2542 sll $20, 32, $1
2543 addq $3, $1, $3
2544$425:
2545 sll $28, 32, $22
2546 srl $28, 32, $1
2547 addq $2, $22, $2
2548 addq $3, $1, $3
2549 bis $2, $2, $7
2550 addq $24, $7, $24
2551 cmpult $7, $22, $1
2552 cmpult $24, $7, $2
2553 addq $1, $3, $6
2554 addq $2, $6, $6
2555 stq $24, 112($16)
2556 addq $23, $6, $23
2557 stq $23, 120($16)
2558 ret $31, ($26), 1
1258 .end bn_mul_comba8 2559 .end bn_mul_comba8
1259 .text 2560 .text
1260 .align 3 2561 .align 3
diff --git a/src/lib/libcrypto/bn/asm/mips3.s b/src/lib/libcrypto/bn/asm/mips3.s
index 191345d920..2df4dcd4b0 100644
--- a/src/lib/libcrypto/bn/asm/mips3.s
+++ b/src/lib/libcrypto/bn/asm/mips3.s
@@ -395,32 +395,32 @@ LEAF(bn_add_words)
395 395
396.L_bn_add_words_loop: 396.L_bn_add_words_loop:
397 ld ta0,0(a2) 397 ld ta0,0(a2)
398 subu a3,4
398 ld t1,8(a1) 399 ld t1,8(a1)
399 ld ta1,8(a2) 400 and AT,a3,MINUS4
400 ld t2,16(a1) 401 ld t2,16(a1)
401 ld ta2,16(a2) 402 PTR_ADD a2,32
402 ld t3,24(a1) 403 ld t3,24(a1)
403 ld ta3,24(a2) 404 PTR_ADD a0,32
405 ld ta1,-24(a2)
406 PTR_ADD a1,32
407 ld ta2,-16(a2)
408 ld ta3,-8(a2)
404 daddu ta0,t0 409 daddu ta0,t0
405 subu a3,4
406 sltu t8,ta0,t0 410 sltu t8,ta0,t0
407 daddu t0,ta0,v0 411 daddu t0,ta0,v0
408 PTR_ADD a0,32
409 sltu v0,t0,ta0 412 sltu v0,t0,ta0
410 sd t0,-32(a0) 413 sd t0,-32(a0)
411 daddu v0,t8 414 daddu v0,t8
412 415
413 daddu ta1,t1 416 daddu ta1,t1
414 PTR_ADD a1,32
415 sltu t9,ta1,t1 417 sltu t9,ta1,t1
416 daddu t1,ta1,v0 418 daddu t1,ta1,v0
417 PTR_ADD a2,32
418 sltu v0,t1,ta1 419 sltu v0,t1,ta1
419 sd t1,-24(a0) 420 sd t1,-24(a0)
420 daddu v0,t9 421 daddu v0,t9
421 422
422 daddu ta2,t2 423 daddu ta2,t2
423 and AT,a3,MINUS4
424 sltu t8,ta2,t2 424 sltu t8,ta2,t2
425 daddu t2,ta2,v0 425 daddu t2,ta2,v0
426 sltu v0,t2,ta2 426 sltu v0,t2,ta2
@@ -495,25 +495,26 @@ LEAF(bn_sub_words)
495 495
496.L_bn_sub_words_loop: 496.L_bn_sub_words_loop:
497 ld ta0,0(a2) 497 ld ta0,0(a2)
498 subu a3,4
498 ld t1,8(a1) 499 ld t1,8(a1)
499 ld ta1,8(a2) 500 and AT,a3,MINUS4
500 ld t2,16(a1) 501 ld t2,16(a1)
501 ld ta2,16(a2) 502 PTR_ADD a2,32
502 ld t3,24(a1) 503 ld t3,24(a1)
503 ld ta3,24(a2) 504 PTR_ADD a0,32
505 ld ta1,-24(a2)
506 PTR_ADD a1,32
507 ld ta2,-16(a2)
508 ld ta3,-8(a2)
504 sltu t8,t0,ta0 509 sltu t8,t0,ta0
505 dsubu t0,ta0 510 dsubu t0,ta0
506 subu a3,4
507 dsubu ta0,t0,v0 511 dsubu ta0,t0,v0
508 and AT,a3,MINUS4 512 sd ta0,-32(a0)
509 sd ta0,0(a0)
510 MOVNZ (t0,v0,t8) 513 MOVNZ (t0,v0,t8)
511 514
512 sltu t9,t1,ta1 515 sltu t9,t1,ta1
513 dsubu t1,ta1 516 dsubu t1,ta1
514 PTR_ADD a0,32
515 dsubu ta1,t1,v0 517 dsubu ta1,t1,v0
516 PTR_ADD a1,32
517 sd ta1,-24(a0) 518 sd ta1,-24(a0)
518 MOVNZ (t1,v0,t9) 519 MOVNZ (t1,v0,t9)
519 520
@@ -521,7 +522,6 @@ LEAF(bn_sub_words)
521 sltu t8,t2,ta2 522 sltu t8,t2,ta2
522 dsubu t2,ta2 523 dsubu t2,ta2
523 dsubu ta2,t2,v0 524 dsubu ta2,t2,v0
524 PTR_ADD a2,32
525 sd ta2,-16(a0) 525 sd ta2,-16(a0)
526 MOVNZ (t2,v0,t8) 526 MOVNZ (t2,v0,t8)
527 527
@@ -574,6 +574,51 @@ END(bn_sub_words)
574 574
575#undef MINUS4 575#undef MINUS4
576 576
577.align 5
578LEAF(bn_div_3_words)
579 .set reorder
580 move a3,a0 /* we know that bn_div_words doesn't
581 * touch a3, ta2, ta3 and preserves a2
582 * so that we can save two arguments
583 * and return address in registers
584 * instead of stack:-)
585 */
586 ld a0,(a3)
587 move ta2,a1
588 ld a1,-8(a3)
589 move ta3,ra
590 move v1,zero
591 li v0,-1
592 beq a0,a2,.L_bn_div_3_words_skip_div
593 bal bn_div_words
594 move ra,ta3
595.L_bn_div_3_words_skip_div:
596 dmultu ta2,v0
597 ld t2,-16(a3)
598 move ta0,zero
599 mfhi t1
600 mflo t0
601 sltu t8,t1,v1
602.L_bn_div_3_words_inner_loop:
603 bnez t8,.L_bn_div_3_words_inner_loop_done
604 sgeu AT,t2,t0
605 seq t9,t1,v1
606 and AT,t9
607 sltu t3,t0,ta2
608 daddu v1,a2
609 dsubu t1,t3
610 dsubu t0,ta2
611 sltu t8,t1,v1
612 sltu ta0,v1,a2
613 or t8,ta0
614 .set noreorder
615 beqzl AT,.L_bn_div_3_words_inner_loop
616 dsubu v0,1
617 .set reorder
618.L_bn_div_3_words_inner_loop_done:
619 jr ra
620END(bn_div_3_words)
621
577.align 5 622.align 5
578LEAF(bn_div_words) 623LEAF(bn_div_words)
579 .set noreorder 624 .set noreorder
@@ -633,16 +678,16 @@ LEAF(bn_div_words)
633 seq t8,HH,t1 678 seq t8,HH,t1
634 sltu AT,HH,t1 679 sltu AT,HH,t1
635 and t2,t8 680 and t2,t8
681 sltu v0,t0,a2
636 or AT,t2 682 or AT,t2
637 .set noreorder 683 .set noreorder
638 beqz AT,.L_bn_div_words_inner_loop1_done 684 beqz AT,.L_bn_div_words_inner_loop1_done
639 sltu t2,t0,a2 685 dsubu t1,v0
640 .set reorder
641 dsubu QT,1
642 dsubu t0,a2 686 dsubu t0,a2
643 dsubu t1,t2
644 b .L_bn_div_words_inner_loop1 687 b .L_bn_div_words_inner_loop1
645.L_bn_div_words_inner_loop1_done: 688 dsubu QT,1
689 .set reorder
690.L_bn_div_words_inner_loop1_done:
646 691
647 dsll a1,32 692 dsll a1,32
648 dsubu a0,t3,t0 693 dsubu a0,t3,t0
@@ -655,6 +700,7 @@ LEAF(bn_div_words)
655 ddivu zero,a0,DH 700 ddivu zero,a0,DH
656 mflo QT 701 mflo QT
657.L_bn_div_words_skip_div2: 702.L_bn_div_words_skip_div2:
703#undef DH
658 dmultu a2,QT 704 dmultu a2,QT
659 dsll t3,a0,32 705 dsll t3,a0,32
660 dsrl AT,a1,32 706 dsrl AT,a1,32
@@ -666,69 +712,26 @@ LEAF(bn_div_words)
666 seq t8,HH,t1 712 seq t8,HH,t1
667 sltu AT,HH,t1 713 sltu AT,HH,t1
668 and t2,t8 714 and t2,t8
715 sltu v1,t0,a2
669 or AT,t2 716 or AT,t2
670 .set noreorder 717 .set noreorder
671 beqz AT,.L_bn_div_words_inner_loop2_done 718 beqz AT,.L_bn_div_words_inner_loop2_done
672 sltu t2,t0,a2 719 dsubu t1,v1
673 .set reorder
674 dsubu QT,1
675 dsubu t0,a2 720 dsubu t0,a2
676 dsubu t1,t2
677 b .L_bn_div_words_inner_loop2 721 b .L_bn_div_words_inner_loop2
722 dsubu QT,1
723 .set reorder
678.L_bn_div_words_inner_loop2_done: 724.L_bn_div_words_inner_loop2_done:
725#undef HH
679 726
680 dsubu a0,t3,t0 727 dsubu a0,t3,t0
681 or v0,QT 728 or v0,QT
682 dsrl v1,a0,t9 /* v1 contains remainder if anybody wants it */ 729 dsrl v1,a0,t9 /* v1 contains remainder if anybody wants it */
683 dsrl a2,t9 /* restore a2 */ 730 dsrl a2,t9 /* restore a2 */
684 jr ra 731 jr ra
685#undef HH
686#undef DH
687#undef QT 732#undef QT
688END(bn_div_words) 733END(bn_div_words)
689 734
690.align 5
691LEAF(bn_div_3_words)
692 .set reorder
693 move a3,a0 /* we know that bn_div_words doesn't
694 * touch a3, ta2, ta3 and preserves a2
695 * so that we can save two arguments
696 * and return address in registers
697 * instead of stack:-)
698 */
699 ld a0,(a3)
700 move ta2,a2
701 move a2,a1
702 ld a1,-8(a3)
703 move ta3,ra
704 move v1,zero
705 li v0,-1
706 beq a0,a2,.L_bn_div_3_words_skip_div
707 jal bn_div_words
708 move ra,ta3
709.L_bn_div_3_words_skip_div:
710 dmultu ta2,v0
711 ld t2,-16(a3)
712 mflo t0
713 mfhi t1
714.L_bn_div_3_words_inner_loop:
715 sgeu AT,t2,t0
716 seq t9,t1,v1
717 sltu t8,t1,v1
718 and AT,t9
719 or AT,t8
720 bnez AT,.L_bn_div_3_words_inner_loop_done
721 daddu v1,a2
722 sltu t3,t0,ta2
723 sltu AT,v1,a2
724 dsubu v0,1
725 dsubu t0,ta2
726 dsubu t1,t3
727 beqz AT,.L_bn_div_3_words_inner_loop
728.L_bn_div_3_words_inner_loop_done:
729 jr ra
730END(bn_div_3_words)
731
732#define a_0 t0 735#define a_0 t0
733#define a_1 t1 736#define a_1 t1
734#define a_2 t2 737#define a_2 t2
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index f935e1ca79..d8822610df 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -83,12 +83,12 @@ extern "C" {
83 * The reason for this flag is that when the particular C compiler 83 * The reason for this flag is that when the particular C compiler
84 * library routine is used, and the library is linked with a different 84 * library routine is used, and the library is linked with a different
85 * compiler, the library is missing. This mostly happens when the 85 * compiler, the library is missing. This mostly happens when the
86 * library is built with gcc and then linked using nornal cc. This would 86 * library is built with gcc and then linked using normal cc. This would
87 * be a common occurance because gcc normally produces code that is 87 * be a common occurrence because gcc normally produces code that is
88 * 2 times faster than system compilers for the big number stuff. 88 * 2 times faster than system compilers for the big number stuff.
89 * For machines with only one compiler (or shared libraries), this should 89 * For machines with only one compiler (or shared libraries), this should
90 * be on. Again this in only really a problem on machines 90 * be on. Again this in only really a problem on machines
91 * using "long long's", are 32bit, and are not using my assember code. */ 91 * using "long long's", are 32bit, and are not using my assembler code. */
92#if defined(MSDOS) || defined(WINDOWS) || defined(linux) 92#if defined(MSDOS) || defined(WINDOWS) || defined(linux)
93#define BN_DIV2W 93#define BN_DIV2W
94#endif 94#endif
@@ -118,8 +118,8 @@ extern "C" {
118 118
119/* This is where the long long data type is 64 bits, but long is 32. 119/* This is where the long long data type is 64 bits, but long is 32.
120 * For machines where there are 64bit registers, this is the mode to use. 120 * For machines where there are 64bit registers, this is the mode to use.
121 * IRIX, on R4000 and above should use this mode, along with the relevent 121 * IRIX, on R4000 and above should use this mode, along with the relevant
122 * assember code :-). Do NOT define BN_LLONG. 122 * assembler code :-). Do NOT define BN_LLONG.
123 */ 123 */
124#ifdef SIXTY_FOUR_BIT 124#ifdef SIXTY_FOUR_BIT
125#undef BN_LLONG 125#undef BN_LLONG
@@ -240,11 +240,15 @@ typedef struct bignum_st
240 240
241/* Used for temp variables */ 241/* Used for temp variables */
242#define BN_CTX_NUM 12 242#define BN_CTX_NUM 12
243#define BN_CTX_NUM_POS 12
243typedef struct bignum_ctx 244typedef struct bignum_ctx
244 { 245 {
245 int tos; 246 int tos;
246 BIGNUM bn[BN_CTX_NUM+1]; 247 BIGNUM bn[BN_CTX_NUM];
247 int flags; 248 int flags;
249 int depth;
250 int pos[BN_CTX_NUM_POS];
251 int too_many;
248 } BN_CTX; 252 } BN_CTX;
249 253
250typedef struct bn_blinding_st 254typedef struct bn_blinding_st
@@ -257,16 +261,15 @@ typedef struct bn_blinding_st
257 261
258/* Used for montgomery multiplication */ 262/* Used for montgomery multiplication */
259typedef struct bn_mont_ctx_st 263typedef struct bn_mont_ctx_st
260 { 264 {
261 int use_word; /* 0 for word form, 1 for long form */ 265 int ri; /* number of bits in R */
262 int ri; /* number of bits in R */ 266 BIGNUM RR; /* used to convert to montgomery form */
263 BIGNUM RR; /* used to convert to montgomery form */ 267 BIGNUM N; /* The modulus */
264 BIGNUM N; /* The modulus */ 268 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
265 BIGNUM Ni; /* The inverse of N */ 269 * (Ni is only stored for bignum algorithm) */
266 BN_ULONG n0; /* word form of inverse, normally only one of 270 BN_ULONG n0; /* least significant word of Ni */
267 * Ni or n0 is defined */
268 int flags; 271 int flags;
269 } BN_MONT_CTX; 272 } BN_MONT_CTX;
270 273
271/* Used for reciprocal division/mod functions 274/* Used for reciprocal division/mod functions
272 * It cannot be shared between threads 275 * It cannot be shared between threads
@@ -283,7 +286,26 @@ typedef struct bn_recp_ctx_st
283#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ 286#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
284 r,a,&((mont)->RR),(mont),ctx) 287 r,a,&((mont)->RR),(mont),ctx)
285 288
286#define BN_prime_checks (5) 289#define BN_prime_checks 0 /* default: select number of iterations
290 based on the size of the number */
291
292/* number of Miller-Rabin iterations for an error rate of less than 2^-80
293 * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
294 * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
295 * original paper: Damgaard, Landrock, Pomerance: Average case error estimates
296 * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
297#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
298 (b) >= 850 ? 3 : \
299 (b) >= 650 ? 4 : \
300 (b) >= 550 ? 5 : \
301 (b) >= 450 ? 6 : \
302 (b) >= 400 ? 7 : \
303 (b) >= 350 ? 8 : \
304 (b) >= 300 ? 9 : \
305 (b) >= 250 ? 12 : \
306 (b) >= 200 ? 15 : \
307 (b) >= 150 ? 18 : \
308 /* b >= 100 */ 27)
287 309
288#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) 310#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
289#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) 311#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
@@ -296,26 +318,16 @@ typedef struct bn_recp_ctx_st
296/*#define BN_ascii2bn(a) BN_hex2bn(a) */ 318/*#define BN_ascii2bn(a) BN_hex2bn(a) */
297/*#define BN_bn2ascii(a) BN_bn2hex(a) */ 319/*#define BN_bn2ascii(a) BN_bn2hex(a) */
298 320
299#define bn_expand(n,b) ((((((b+BN_BITS2-1))/BN_BITS2)) <= (n)->max)?\
300 (n):bn_expand2((n),(b)/BN_BITS2+1))
301#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b)))
302
303#define bn_fix_top(a) \
304 { \
305 BN_ULONG *ftl; \
306 if ((a)->top > 0) \
307 { \
308 for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
309 if (*(ftl--)) break; \
310 } \
311 }
312
313BIGNUM *BN_value_one(void); 321BIGNUM *BN_value_one(void);
314char * BN_options(void); 322char * BN_options(void);
315BN_CTX *BN_CTX_new(void); 323BN_CTX *BN_CTX_new(void);
316void BN_CTX_init(BN_CTX *c); 324void BN_CTX_init(BN_CTX *c);
317void BN_CTX_free(BN_CTX *c); 325void BN_CTX_free(BN_CTX *c);
326void BN_CTX_start(BN_CTX *ctx);
327BIGNUM *BN_CTX_get(BN_CTX *ctx);
328void BN_CTX_end(BN_CTX *ctx);
318int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); 329int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
330int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
319int BN_num_bits(const BIGNUM *a); 331int BN_num_bits(const BIGNUM *a);
320int BN_num_bits_word(BN_ULONG); 332int BN_num_bits_word(BN_ULONG);
321BIGNUM *BN_new(void); 333BIGNUM *BN_new(void);
@@ -329,13 +341,13 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
329int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 341int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
330int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 342int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
331int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 343int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
332int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); 344int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
333int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); 345int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
334int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, 346int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
335 BN_CTX *ctx); 347 BN_CTX *ctx);
336int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b,BN_CTX *ctx); 348int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
337int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); 349int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
338BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w); 350BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
339BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); 351BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
340int BN_mul_word(BIGNUM *a, BN_ULONG w); 352int BN_mul_word(BIGNUM *a, BN_ULONG w);
341int BN_add_word(BIGNUM *a, BN_ULONG w); 353int BN_add_word(BIGNUM *a, BN_ULONG w);
@@ -358,19 +370,18 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
358 BIGNUM *m,BN_CTX *ctx); 370 BIGNUM *m,BN_CTX *ctx);
359int BN_mask_bits(BIGNUM *a,int n); 371int BN_mask_bits(BIGNUM *a,int n);
360int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); 372int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
361#ifndef WIN16 373#ifndef NO_FP_API
362int BN_print_fp(FILE *fp, BIGNUM *a); 374int BN_print_fp(FILE *fp, const BIGNUM *a);
363#endif 375#endif
364#ifdef HEADER_BIO_H 376#ifdef HEADER_BIO_H
365int BN_print(BIO *fp, const BIGNUM *a); 377int BN_print(BIO *fp, const BIGNUM *a);
366#else 378#else
367int BN_print(char *fp, const BIGNUM *a); 379int BN_print(void *fp, const BIGNUM *a);
368#endif 380#endif
369int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx); 381int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx);
370int BN_rshift(BIGNUM *r, BIGNUM *a, int n); 382int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
371int BN_rshift1(BIGNUM *r, BIGNUM *a); 383int BN_rshift1(BIGNUM *r, BIGNUM *a);
372void BN_clear(BIGNUM *a); 384void BN_clear(BIGNUM *a);
373BIGNUM *bn_expand2(BIGNUM *b, int bits);
374BIGNUM *BN_dup(const BIGNUM *a); 385BIGNUM *BN_dup(const BIGNUM *a);
375int BN_ucmp(const BIGNUM *a, const BIGNUM *b); 386int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
376int BN_set_bit(BIGNUM *a, int n); 387int BN_set_bit(BIGNUM *a, int n);
@@ -381,19 +392,16 @@ int BN_hex2bn(BIGNUM **a, const char *str);
381int BN_dec2bn(BIGNUM **a, const char *str); 392int BN_dec2bn(BIGNUM **a, const char *str);
382int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); 393int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
383BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); 394BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
384BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int strong,BIGNUM *add, 395BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,BIGNUM *add,
385 BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg); 396 BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg);
386int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,void *), 397int BN_is_prime(const BIGNUM *p,int nchecks,
398 void (*callback)(int,int,void *),
387 BN_CTX *ctx,void *cb_arg); 399 BN_CTX *ctx,void *cb_arg);
400int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
401 void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
402 int do_trial_division);
388void ERR_load_BN_strings(void ); 403void ERR_load_BN_strings(void );
389 404
390BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
391BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
392void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
393BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
394BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
395BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
396
397BN_MONT_CTX *BN_MONT_CTX_new(void ); 405BN_MONT_CTX *BN_MONT_CTX_new(void );
398void BN_MONT_CTX_init(BN_MONT_CTX *ctx); 406void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
399int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont, 407int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
@@ -423,6 +431,39 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
423int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, 431int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
424 BN_RECP_CTX *recp, BN_CTX *ctx); 432 BN_RECP_CTX *recp, BN_CTX *ctx);
425 433
434/* library internal functions */
435
436#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->max)?\
437 (a):bn_expand2((a),(bits)/BN_BITS2+1))
438#define bn_wexpand(a,words) (((words) <= (a)->max)?(a):bn_expand2((a),(words)))
439BIGNUM *bn_expand2(BIGNUM *a, int words);
440
441#define bn_fix_top(a) \
442 { \
443 BN_ULONG *ftl; \
444 if ((a)->top > 0) \
445 { \
446 for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
447 if (*(ftl--)) break; \
448 } \
449 }
450
451BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
452BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
453void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
454BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
455BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
456BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
457
458#ifdef BN_DEBUG
459 void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n);
460# define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
461 fprintf(stderr,"\n");}
462# define bn_dump(a,n) bn_dump1(stderr,#a,a,n);
463#else
464# define bn_print(a)
465# define bn_dump(a,b)
466#endif
426 467
427/* BEGIN ERROR CODES */ 468/* BEGIN ERROR CODES */
428/* The following lines are auto generated by the script mkerr.pl. Any changes 469/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -438,6 +479,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
438#define BN_F_BN_BLINDING_UPDATE 103 479#define BN_F_BN_BLINDING_UPDATE 103
439#define BN_F_BN_BN2DEC 104 480#define BN_F_BN_BN2DEC 104
440#define BN_F_BN_BN2HEX 105 481#define BN_F_BN_BN2HEX 105
482#define BN_F_BN_CTX_GET 116
441#define BN_F_BN_CTX_NEW 106 483#define BN_F_BN_CTX_NEW 106
442#define BN_F_BN_DIV 107 484#define BN_F_BN_DIV 107
443#define BN_F_BN_EXPAND2 108 485#define BN_F_BN_EXPAND2 108
@@ -459,6 +501,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
459#define BN_R_INVALID_LENGTH 106 501#define BN_R_INVALID_LENGTH 106
460#define BN_R_NOT_INITIALIZED 107 502#define BN_R_NOT_INITIALIZED 107
461#define BN_R_NO_INVERSE 108 503#define BN_R_NO_INVERSE 108
504#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
462 505
463#ifdef __cplusplus 506#ifdef __cplusplus
464} 507}
diff --git a/src/lib/libcrypto/bn/bn_add.c b/src/lib/libcrypto/bn/bn_add.c
index c5ab066c9e..5d24691233 100644
--- a/src/lib/libcrypto/bn/bn_add.c
+++ b/src/lib/libcrypto/bn/bn_add.c
@@ -61,9 +61,9 @@
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62 62
63/* r can == a or b */ 63/* r can == a or b */
64int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b) 64int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
65 { 65 {
66 BIGNUM *tmp; 66 const BIGNUM *tmp;
67 67
68 bn_check_top(a); 68 bn_check_top(a);
69 bn_check_top(b); 69 bn_check_top(b);
diff --git a/src/lib/libcrypto/bn/bn_asm.c b/src/lib/libcrypto/bn/bn_asm.c
index 4d3da16a0c..3329cc18e6 100644
--- a/src/lib/libcrypto/bn/bn_asm.c
+++ b/src/lib/libcrypto/bn/bn_asm.c
@@ -56,31 +56,38 @@
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
63#ifdef BN_LLONG 69#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
64 70
65BN_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, BN_ULONG *ap, int num, BN_ULONG w)
66 { 72 {
67 BN_ULONG c1=0; 73 BN_ULONG c1=0;
68 74
69 bn_check_num(num); 75 assert(num >= 0);
70 if (num <= 0) return(c1); 76 if (num <= 0) return(c1);
71 77
72 for (;;) 78 while (num&~3)
73 { 79 {
74 mul_add(rp[0],ap[0],w,c1); 80 mul_add(rp[0],ap[0],w,c1);
75 if (--num == 0) break;
76 mul_add(rp[1],ap[1],w,c1); 81 mul_add(rp[1],ap[1],w,c1);
77 if (--num == 0) break;
78 mul_add(rp[2],ap[2],w,c1); 82 mul_add(rp[2],ap[2],w,c1);
79 if (--num == 0) break;
80 mul_add(rp[3],ap[3],w,c1); 83 mul_add(rp[3],ap[3],w,c1);
81 if (--num == 0) break; 84 ap+=4; rp+=4; num-=4;
82 ap+=4; 85 }
83 rp+=4; 86 if (num)
87 {
88 mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
89 mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
90 mul_add(rp[2],ap[2],w,c1); return c1;
84 } 91 }
85 92
86 return(c1); 93 return(c1);
@@ -90,63 +97,54 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
90 { 97 {
91 BN_ULONG c1=0; 98 BN_ULONG c1=0;
92 99
93 bn_check_num(num); 100 assert(num >= 0);
94 if (num <= 0) return(c1); 101 if (num <= 0) return(c1);
95 102
96 /* for (;;) */ 103 while (num&~3)
97 while (1) /* circumvent egcs-1.1.2 bug */
98 { 104 {
99 mul(rp[0],ap[0],w,c1); 105 mul(rp[0],ap[0],w,c1);
100 if (--num == 0) break;
101 mul(rp[1],ap[1],w,c1); 106 mul(rp[1],ap[1],w,c1);
102 if (--num == 0) break;
103 mul(rp[2],ap[2],w,c1); 107 mul(rp[2],ap[2],w,c1);
104 if (--num == 0) break;
105 mul(rp[3],ap[3],w,c1); 108 mul(rp[3],ap[3],w,c1);
106 if (--num == 0) break; 109 ap+=4; rp+=4; num-=4;
107 ap+=4; 110 }
108 rp+=4; 111 if (num)
112 {
113 mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
114 mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
115 mul(rp[2],ap[2],w,c1);
109 } 116 }
110 return(c1); 117 return(c1);
111 } 118 }
112 119
113void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) 120void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
114 { 121 {
115 bn_check_num(n); 122 assert(n >= 0);
116 if (n <= 0) return; 123 if (n <= 0) return;
117 for (;;) 124 while (n&~3)
118 { 125 {
119 BN_ULLONG t; 126 sqr(r[0],r[1],a[0]);
120 127 sqr(r[2],r[3],a[1]);
121 t=(BN_ULLONG)(a[0])*(a[0]); 128 sqr(r[4],r[5],a[2]);
122 r[0]=Lw(t); r[1]=Hw(t); 129 sqr(r[6],r[7],a[3]);
123 if (--n == 0) break; 130 a+=4; r+=8; n-=4;
124 131 }
125 t=(BN_ULLONG)(a[1])*(a[1]); 132 if (n)
126 r[2]=Lw(t); r[3]=Hw(t); 133 {
127 if (--n == 0) break; 134 sqr(r[0],r[1],a[0]); if (--n == 0) return;
128 135 sqr(r[2],r[3],a[1]); if (--n == 0) return;
129 t=(BN_ULLONG)(a[2])*(a[2]); 136 sqr(r[4],r[5],a[2]);
130 r[4]=Lw(t); r[5]=Hw(t);
131 if (--n == 0) break;
132
133 t=(BN_ULLONG)(a[3])*(a[3]);
134 r[6]=Lw(t); r[7]=Hw(t);
135 if (--n == 0) break;
136
137 a+=4;
138 r+=8;
139 } 137 }
140 } 138 }
141 139
142#else 140#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
143 141
144BN_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, BN_ULONG *ap, int num, BN_ULONG w)
145 { 143 {
146 BN_ULONG c=0; 144 BN_ULONG c=0;
147 BN_ULONG bl,bh; 145 BN_ULONG bl,bh;
148 146
149 bn_check_num(num); 147 assert(num >= 0);
150 if (num <= 0) return((BN_ULONG)0); 148 if (num <= 0) return((BN_ULONG)0);
151 149
152 bl=LBITS(w); 150 bl=LBITS(w);
@@ -173,7 +171,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
173 BN_ULONG carry=0; 171 BN_ULONG carry=0;
174 BN_ULONG bl,bh; 172 BN_ULONG bl,bh;
175 173
176 bn_check_num(num); 174 assert(num >= 0);
177 if (num <= 0) return((BN_ULONG)0); 175 if (num <= 0) return((BN_ULONG)0);
178 176
179 bl=LBITS(w); 177 bl=LBITS(w);
@@ -197,7 +195,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
197 195
198void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) 196void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
199 { 197 {
200 bn_check_num(n); 198 assert(n >= 0);
201 if (n <= 0) return; 199 if (n <= 0) return;
202 for (;;) 200 for (;;)
203 { 201 {
@@ -218,7 +216,7 @@ void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
218 } 216 }
219 } 217 }
220 218
221#endif 219#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
222 220
223#if defined(BN_LLONG) && defined(BN_DIV2W) 221#if defined(BN_LLONG) && defined(BN_DIV2W)
224 222
@@ -300,14 +298,14 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
300 ret|=q; 298 ret|=q;
301 return(ret); 299 return(ret);
302 } 300 }
303#endif 301#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */
304 302
305#ifdef BN_LLONG 303#ifdef BN_LLONG
306BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 304BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
307 { 305 {
308 BN_ULLONG ll=0; 306 BN_ULLONG ll=0;
309 307
310 bn_check_num(n); 308 assert(n >= 0);
311 if (n <= 0) return((BN_ULONG)0); 309 if (n <= 0) return((BN_ULONG)0);
312 310
313 for (;;) 311 for (;;)
@@ -338,12 +336,12 @@ BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
338 } 336 }
339 return((BN_ULONG)ll); 337 return((BN_ULONG)ll);
340 } 338 }
341#else 339#else /* !BN_LLONG */
342BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 340BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
343 { 341 {
344 BN_ULONG c,l,t; 342 BN_ULONG c,l,t;
345 343
346 bn_check_num(n); 344 assert(n >= 0);
347 if (n <= 0) return((BN_ULONG)0); 345 if (n <= 0) return((BN_ULONG)0);
348 346
349 c=0; 347 c=0;
@@ -387,14 +385,14 @@ BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
387 } 385 }
388 return((BN_ULONG)c); 386 return((BN_ULONG)c);
389 } 387 }
390#endif 388#endif /* !BN_LLONG */
391 389
392BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 390BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
393 { 391 {
394 BN_ULONG t1,t2; 392 BN_ULONG t1,t2;
395 int c=0; 393 int c=0;
396 394
397 bn_check_num(n); 395 assert(n >= 0);
398 if (n <= 0) return((BN_ULONG)0); 396 if (n <= 0) return((BN_ULONG)0);
399 397
400 for (;;) 398 for (;;)
@@ -433,6 +431,11 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
433#undef bn_sqr_comba8 431#undef bn_sqr_comba8
434#undef bn_sqr_comba4 432#undef bn_sqr_comba4
435 433
434/* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */
435/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */
436/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
437/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
438
436#ifdef BN_LLONG 439#ifdef BN_LLONG
437#define mul_add_c(a,b,c0,c1,c2) \ 440#define mul_add_c(a,b,c0,c1,c2) \
438 t=(BN_ULLONG)a*b; \ 441 t=(BN_ULLONG)a*b; \
@@ -460,7 +463,39 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
460 463
461#define sqr_add_c2(a,i,j,c0,c1,c2) \ 464#define sqr_add_c2(a,i,j,c0,c1,c2) \
462 mul_add_c2((a)[i],(a)[j],c0,c1,c2) 465 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
463#else 466
467#elif defined(BN_UMULT_HIGH)
468
469#define mul_add_c(a,b,c0,c1,c2) { \
470 BN_ULONG ta=(a),tb=(b); \
471 t1 = ta * tb; \
472 t2 = BN_UMULT_HIGH(ta,tb); \
473 c0 += t1; t2 += (c0<t1)?1:0; \
474 c1 += t2; c2 += (c1<t2)?1:0; \
475 }
476
477#define mul_add_c2(a,b,c0,c1,c2) { \
478 BN_ULONG ta=(a),tb=(b),t0; \
479 t1 = BN_UMULT_HIGH(ta,tb); \
480 t0 = ta * tb; \
481 t2 = t1+t1; c2 += (t2<t1)?1:0; \
482 t1 = t0+t0; t2 += (t1<t0)?1:0; \
483 c0 += t1; t2 += (c0<t1)?1:0; \
484 c1 += t2; c2 += (c1<t2)?1:0; \
485 }
486
487#define sqr_add_c(a,i,c0,c1,c2) { \
488 BN_ULONG ta=(a)[i]; \
489 t1 = ta * ta; \
490 t2 = BN_UMULT_HIGH(ta,ta); \
491 c0 += t1; t2 += (c0<t1)?1:0; \
492 c1 += t2; c2 += (c1<t2)?1:0; \
493 }
494
495#define sqr_add_c2(a,i,j,c0,c1,c2) \
496 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
497
498#else /* !BN_LLONG */
464#define mul_add_c(a,b,c0,c1,c2) \ 499#define mul_add_c(a,b,c0,c1,c2) \
465 t1=LBITS(a); t2=HBITS(a); \ 500 t1=LBITS(a); t2=HBITS(a); \
466 bl=LBITS(b); bh=HBITS(b); \ 501 bl=LBITS(b); bh=HBITS(b); \
@@ -487,7 +522,7 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
487 522
488#define sqr_add_c2(a,i,j,c0,c1,c2) \ 523#define sqr_add_c2(a,i,j,c0,c1,c2) \
489 mul_add_c2((a)[i],(a)[j],c0,c1,c2) 524 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
490#endif 525#endif /* !BN_LLONG */
491 526
492void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) 527void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
493 { 528 {
@@ -762,7 +797,7 @@ void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
762 r[6]=c1; 797 r[6]=c1;
763 r[7]=c2; 798 r[7]=c2;
764 } 799 }
765#else 800#else /* !BN_MUL_COMBA */
766 801
767/* hmm... is it faster just to do a multiply? */ 802/* hmm... is it faster just to do a multiply? */
768#undef bn_sqr_comba4 803#undef bn_sqr_comba4
@@ -799,4 +834,4 @@ void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
799 r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]); 834 r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]);
800 } 835 }
801 836
802#endif /* BN_COMBA */ 837#endif /* !BN_MUL_COMBA */
diff --git a/src/lib/libcrypto/bn/bn_comba.c b/src/lib/libcrypto/bn/bn_comba.c
index 7ad09b4a6d..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/bn_comba.c
+++ b/src/lib/libcrypto/bn/bn_comba.c
@@ -1,345 +0,0 @@
1/* crypto/bn/bn_comba.c */
2#include <stdio.h>
3#include "bn_lcl.h"
4/* Auto generated from crypto/bn/comba.pl
5 */
6
7#undef bn_mul_comba8
8#undef bn_mul_comba4
9#undef bn_sqr_comba8
10#undef bn_sqr_comba4
11
12#ifdef BN_LLONG
13#define mul_add_c(a,b,c0,c1,c2) \
14 t=(BN_ULLONG)a*b; \
15 t1=(BN_ULONG)Lw(t); \
16 t2=(BN_ULONG)Hw(t); \
17 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
18 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
19
20#define mul_add_c2(a,b,c0,c1,c2) \
21 t=(BN_ULLONG)a*b; \
22 tt=(t+t)&BN_MASK; \
23 if (tt < t) c2++; \
24 t1=(BN_ULONG)Lw(tt); \
25 t2=(BN_ULONG)Hw(tt); \
26 c0=(c0+t1)&BN_MASK2; \
27 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
28 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
29
30#define sqr_add_c(a,i,c0,c1,c2) \
31 t=(BN_ULLONG)a[i]*a[i]; \
32 t1=(BN_ULONG)Lw(t); \
33 t2=(BN_ULONG)Hw(t); \
34 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
35 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
36
37#define sqr_add_c2(a,i,j,c0,c1,c2) \
38 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
39#else
40#define mul_add_c(a,b,c0,c1,c2) \
41 t1=LBITS(a); t2=HBITS(a); \
42 bl=LBITS(b); bh=HBITS(b); \
43 mul64(t1,t2,bl,bh); \
44 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
45 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
46
47#define mul_add_c2(a,b,c0,c1,c2) \
48 t1=LBITS(a); t2=HBITS(a); \
49 bl=LBITS(b); bh=HBITS(b); \
50 mul64(t1,t2,bl,bh); \
51 if (t2 & BN_TBIT) c2++; \
52 t2=(t2+t2)&BN_MASK2; \
53 if (t1 & BN_TBIT) t2++; \
54 t1=(t1+t1)&BN_MASK2; \
55 c0=(c0+t1)&BN_MASK2; \
56 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
57 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
58
59#define sqr_add_c(a,i,c0,c1,c2) \
60 sqr64(t1,t2,(a)[i]); \
61 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
62 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
63
64#define sqr_add_c2(a,i,j,c0,c1,c2) \
65 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
66#endif
67
68void bn_mul_comba88(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
69void bn_mul_comba44(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
70void bn_sqr_comba88(BN_ULONG *r,BN_ULONG *a);
71void bn_sqr_comba44(BN_ULONG *r,BN_ULONG *a);
72
73void bn_mul_comba88(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
74 {
75#ifdef BN_LLONG
76 BN_ULLONG t;
77#else
78 BN_ULONG bl,bh;
79#endif
80 BN_ULONG t1,t2;
81 BN_ULONG c1,c2,c3;
82
83 c1=0;
84 c2=0;
85 c3=0;
86 mul_add_c(a[0],b[0],c1,c2,c3);
87 r[0]=c1;
88 c1=0;
89 mul_add_c(a[0],b[1],c2,c3,c1);
90 mul_add_c(a[1],b[0],c2,c3,c1);
91 r[1]=c2;
92 c2=0;
93 mul_add_c(a[2],b[0],c3,c1,c2);
94 mul_add_c(a[1],b[1],c3,c1,c2);
95 mul_add_c(a[0],b[2],c3,c1,c2);
96 r[2]=c3;
97 c3=0;
98 mul_add_c(a[0],b[3],c1,c2,c3);
99 mul_add_c(a[1],b[2],c1,c2,c3);
100 mul_add_c(a[2],b[1],c1,c2,c3);
101 mul_add_c(a[3],b[0],c1,c2,c3);
102 r[3]=c1;
103 c1=0;
104 mul_add_c(a[4],b[0],c2,c3,c1);
105 mul_add_c(a[3],b[1],c2,c3,c1);
106 mul_add_c(a[2],b[2],c2,c3,c1);
107 mul_add_c(a[1],b[3],c2,c3,c1);
108 mul_add_c(a[0],b[4],c2,c3,c1);
109 r[4]=c2;
110 c2=0;
111 mul_add_c(a[0],b[5],c3,c1,c2);
112 mul_add_c(a[1],b[4],c3,c1,c2);
113 mul_add_c(a[2],b[3],c3,c1,c2);
114 mul_add_c(a[3],b[2],c3,c1,c2);
115 mul_add_c(a[4],b[1],c3,c1,c2);
116 mul_add_c(a[5],b[0],c3,c1,c2);
117 r[5]=c3;
118 c3=0;
119 mul_add_c(a[6],b[0],c1,c2,c3);
120 mul_add_c(a[5],b[1],c1,c2,c3);
121 mul_add_c(a[4],b[2],c1,c2,c3);
122 mul_add_c(a[3],b[3],c1,c2,c3);
123 mul_add_c(a[2],b[4],c1,c2,c3);
124 mul_add_c(a[1],b[5],c1,c2,c3);
125 mul_add_c(a[0],b[6],c1,c2,c3);
126 r[6]=c1;
127 c1=0;
128 mul_add_c(a[0],b[7],c2,c3,c1);
129 mul_add_c(a[1],b[6],c2,c3,c1);
130 mul_add_c(a[2],b[5],c2,c3,c1);
131 mul_add_c(a[3],b[4],c2,c3,c1);
132 mul_add_c(a[4],b[3],c2,c3,c1);
133 mul_add_c(a[5],b[2],c2,c3,c1);
134 mul_add_c(a[6],b[1],c2,c3,c1);
135 mul_add_c(a[7],b[0],c2,c3,c1);
136 r[7]=c2;
137 c2=0;
138 mul_add_c(a[7],b[1],c3,c1,c2);
139 mul_add_c(a[6],b[2],c3,c1,c2);
140 mul_add_c(a[5],b[3],c3,c1,c2);
141 mul_add_c(a[4],b[4],c3,c1,c2);
142 mul_add_c(a[3],b[5],c3,c1,c2);
143 mul_add_c(a[2],b[6],c3,c1,c2);
144 mul_add_c(a[1],b[7],c3,c1,c2);
145 r[8]=c3;
146 c3=0;
147 mul_add_c(a[2],b[7],c1,c2,c3);
148 mul_add_c(a[3],b[6],c1,c2,c3);
149 mul_add_c(a[4],b[5],c1,c2,c3);
150 mul_add_c(a[5],b[4],c1,c2,c3);
151 mul_add_c(a[6],b[3],c1,c2,c3);
152 mul_add_c(a[7],b[2],c1,c2,c3);
153 r[9]=c1;
154 c1=0;
155 mul_add_c(a[7],b[3],c2,c3,c1);
156 mul_add_c(a[6],b[4],c2,c3,c1);
157 mul_add_c(a[5],b[5],c2,c3,c1);
158 mul_add_c(a[4],b[6],c2,c3,c1);
159 mul_add_c(a[3],b[7],c2,c3,c1);
160 r[10]=c2;
161 c2=0;
162 mul_add_c(a[4],b[7],c3,c1,c2);
163 mul_add_c(a[5],b[6],c3,c1,c2);
164 mul_add_c(a[6],b[5],c3,c1,c2);
165 mul_add_c(a[7],b[4],c3,c1,c2);
166 r[11]=c3;
167 c3=0;
168 mul_add_c(a[7],b[5],c1,c2,c3);
169 mul_add_c(a[6],b[6],c1,c2,c3);
170 mul_add_c(a[5],b[7],c1,c2,c3);
171 r[12]=c1;
172 c1=0;
173 mul_add_c(a[6],b[7],c2,c3,c1);
174 mul_add_c(a[7],b[6],c2,c3,c1);
175 r[13]=c2;
176 c2=0;
177 mul_add_c(a[7],b[7],c3,c1,c2);
178 r[14]=c3;
179 r[15]=c1;
180 }
181
182void bn_mul_comba44(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
183 {
184#ifdef BN_LLONG
185 BN_ULLONG t;
186#else
187 BN_ULONG bl,bh;
188#endif
189 BN_ULONG t1,t2;
190 BN_ULONG c1,c2,c3;
191
192 c1=0;
193 c2=0;
194 c3=0;
195 mul_add_c(a[0],b[0],c1,c2,c3);
196 r[0]=c1;
197 c1=0;
198 mul_add_c(a[0],b[1],c2,c3,c1);
199 mul_add_c(a[1],b[0],c2,c3,c1);
200 r[1]=c2;
201 c2=0;
202 mul_add_c(a[2],b[0],c3,c1,c2);
203 mul_add_c(a[1],b[1],c3,c1,c2);
204 mul_add_c(a[0],b[2],c3,c1,c2);
205 r[2]=c3;
206 c3=0;
207 mul_add_c(a[0],b[3],c1,c2,c3);
208 mul_add_c(a[1],b[2],c1,c2,c3);
209 mul_add_c(a[2],b[1],c1,c2,c3);
210 mul_add_c(a[3],b[0],c1,c2,c3);
211 r[3]=c1;
212 c1=0;
213 mul_add_c(a[3],b[1],c2,c3,c1);
214 mul_add_c(a[2],b[2],c2,c3,c1);
215 mul_add_c(a[1],b[3],c2,c3,c1);
216 r[4]=c2;
217 c2=0;
218 mul_add_c(a[2],b[3],c3,c1,c2);
219 mul_add_c(a[3],b[2],c3,c1,c2);
220 r[5]=c3;
221 c3=0;
222 mul_add_c(a[3],b[3],c1,c2,c3);
223 r[6]=c1;
224 r[7]=c2;
225 }
226
227void bn_sqr_comba88(BN_ULONG *r, BN_ULONG *a)
228 {
229#ifdef BN_LLONG
230 BN_ULLONG t,tt;
231#else
232 BN_ULONG bl,bh;
233#endif
234 BN_ULONG t1,t2;
235 BN_ULONG c1,c2,c3;
236
237 c1=0;
238 c2=0;
239 c3=0;
240 sqr_add_c(a,0,c1,c2,c3);
241 r[0]=c1;
242 c1=0;
243 sqr_add_c2(a,1,0,c2,c3,c1);
244 r[1]=c2;
245 c2=0;
246 sqr_add_c(a,1,c3,c1,c2);
247 sqr_add_c2(a,2,0,c3,c1,c2);
248 r[2]=c3;
249 c3=0;
250 sqr_add_c2(a,3,0,c1,c2,c3);
251 sqr_add_c2(a,2,1,c1,c2,c3);
252 r[3]=c1;
253 c1=0;
254 sqr_add_c(a,2,c2,c3,c1);
255 sqr_add_c2(a,3,1,c2,c3,c1);
256 sqr_add_c2(a,4,0,c2,c3,c1);
257 r[4]=c2;
258 c2=0;
259 sqr_add_c2(a,5,0,c3,c1,c2);
260 sqr_add_c2(a,4,1,c3,c1,c2);
261 sqr_add_c2(a,3,2,c3,c1,c2);
262 r[5]=c3;
263 c3=0;
264 sqr_add_c(a,3,c1,c2,c3);
265 sqr_add_c2(a,4,2,c1,c2,c3);
266 sqr_add_c2(a,5,1,c1,c2,c3);
267 sqr_add_c2(a,6,0,c1,c2,c3);
268 r[6]=c1;
269 c1=0;
270 sqr_add_c2(a,7,0,c2,c3,c1);
271 sqr_add_c2(a,6,1,c2,c3,c1);
272 sqr_add_c2(a,5,2,c2,c3,c1);
273 sqr_add_c2(a,4,3,c2,c3,c1);
274 r[7]=c2;
275 c2=0;
276 sqr_add_c(a,4,c3,c1,c2);
277 sqr_add_c2(a,5,3,c3,c1,c2);
278 sqr_add_c2(a,6,2,c3,c1,c2);
279 sqr_add_c2(a,7,1,c3,c1,c2);
280 r[8]=c3;
281 c3=0;
282 sqr_add_c2(a,7,2,c1,c2,c3);
283 sqr_add_c2(a,6,3,c1,c2,c3);
284 sqr_add_c2(a,5,4,c1,c2,c3);
285 r[9]=c1;
286 c1=0;
287 sqr_add_c(a,5,c2,c3,c1);
288 sqr_add_c2(a,6,4,c2,c3,c1);
289 sqr_add_c2(a,7,3,c2,c3,c1);
290 r[10]=c2;
291 c2=0;
292 sqr_add_c2(a,7,4,c3,c1,c2);
293 sqr_add_c2(a,6,5,c3,c1,c2);
294 r[11]=c3;
295 c3=0;
296 sqr_add_c(a,6,c1,c2,c3);
297 sqr_add_c2(a,7,5,c1,c2,c3);
298 r[12]=c1;
299 c1=0;
300 sqr_add_c2(a,7,6,c2,c3,c1);
301 r[13]=c2;
302 c2=0;
303 sqr_add_c(a,7,c3,c1,c2);
304 r[14]=c3;
305 r[15]=c1;
306 }
307
308void bn_sqr_comba44(BN_ULONG *r, BN_ULONG *a)
309 {
310#ifdef BN_LLONG
311 BN_ULLONG t,tt;
312#else
313 BN_ULONG bl,bh;
314#endif
315 BN_ULONG t1,t2;
316 BN_ULONG c1,c2,c3;
317
318 c1=0;
319 c2=0;
320 c3=0;
321 sqr_add_c(a,0,c1,c2,c3);
322 r[0]=c1;
323 c1=0;
324 sqr_add_c2(a,1,0,c2,c3,c1);
325 r[1]=c2;
326 c2=0;
327 sqr_add_c(a,1,c3,c1,c2);
328 sqr_add_c2(a,2,0,c3,c1,c2);
329 r[2]=c3;
330 c3=0;
331 sqr_add_c2(a,3,0,c1,c2,c3);
332 sqr_add_c2(a,2,1,c1,c2,c3);
333 r[3]=c1;
334 c1=0;
335 sqr_add_c(a,2,c2,c3,c1);
336 sqr_add_c2(a,3,1,c2,c3,c1);
337 r[4]=c2;
338 c2=0;
339 sqr_add_c2(a,3,2,c3,c1,c2);
340 r[5]=c3;
341 c3=0;
342 sqr_add_c(a,3,c1,c2,c3);
343 r[6]=c1;
344 r[7]=c2;
345 }
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c
new file mode 100644
index 0000000000..46132fd180
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_ctx.c
@@ -0,0 +1,144 @@
1/* crypto/bn/bn_ctx.c */
2/* Written by Ulf Moeller for the OpenSSL project. */
3/* ====================================================================
4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
22 *
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * openssl-core@openssl.org.
27 *
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
31 *
32 * 6. Redistributions of any form whatsoever must retain the following
33 * acknowledgment:
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This product includes cryptographic software written by Eric Young
52 * (eay@cryptsoft.com). This product includes software written by Tim
53 * Hudson (tjh@cryptsoft.com).
54 *
55 */
56
57#ifndef BN_CTX_DEBUG
58# undef NDEBUG /* avoid conflicting definitions */
59# define NDEBUG
60#endif
61
62#include <stdio.h>
63#include <assert.h>
64#include "cryptlib.h"
65#include <openssl/bn.h>
66
67
68BN_CTX *BN_CTX_new(void)
69 {
70 BN_CTX *ret;
71
72 ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
73 if (ret == NULL)
74 {
75 BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
76 return(NULL);
77 }
78
79 BN_CTX_init(ret);
80 ret->flags=BN_FLG_MALLOCED;
81 return(ret);
82 }
83
84void BN_CTX_init(BN_CTX *ctx)
85 {
86 int i;
87 ctx->tos = 0;
88 ctx->flags = 0;
89 ctx->depth = 0;
90 ctx->too_many = 0;
91 for (i = 0; i < BN_CTX_NUM; i++)
92 BN_init(&(ctx->bn[i]));
93 }
94
95void BN_CTX_free(BN_CTX *ctx)
96 {
97 int i;
98
99 if (ctx == NULL) return;
100 assert(ctx->depth == 0);
101
102 for (i=0; i < BN_CTX_NUM; i++)
103 BN_clear_free(&(ctx->bn[i]));
104 if (ctx->flags & BN_FLG_MALLOCED)
105 Free(ctx);
106 }
107
108void BN_CTX_start(BN_CTX *ctx)
109 {
110 if (ctx->depth < BN_CTX_NUM_POS)
111 ctx->pos[ctx->depth] = ctx->tos;
112 ctx->depth++;
113 }
114
115BIGNUM *BN_CTX_get(BN_CTX *ctx)
116 {
117 if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)
118 {
119 if (!ctx->too_many)
120 {
121 BNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);
122 /* disable error code until BN_CTX_end is called: */
123 ctx->too_many = 1;
124 }
125 return NULL;
126 }
127 return (&(ctx->bn[ctx->tos++]));
128 }
129
130void BN_CTX_end(BN_CTX *ctx)
131 {
132 if (ctx == NULL) return;
133 assert(ctx->depth > 0);
134 if (ctx->depth == 0)
135 /* should never happen, but we can tolerate it if not in
136 * debug mode (could be a 'goto err' in the calling function
137 * before BN_CTX_start was reached) */
138 BN_CTX_start(ctx);
139
140 ctx->too_many = 0;
141 ctx->depth--;
142 if (ctx->depth < BN_CTX_NUM_POS)
143 ctx->tos = ctx->pos[ctx->depth];
144 }
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index 150dd289a5..07af1d3b44 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -63,9 +63,11 @@
63 63
64/* The old slow way */ 64/* The old slow way */
65#if 0 65#if 0
66int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx) 66int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
67 BN_CTX *ctx)
67 { 68 {
68 int i,nm,nd; 69 int i,nm,nd;
70 int ret = 0;
69 BIGNUM *D; 71 BIGNUM *D;
70 72
71 bn_check_top(m); 73 bn_check_top(m);
@@ -84,14 +86,17 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
84 return(1); 86 return(1);
85 } 87 }
86 88
87 D= &(ctx->bn[ctx->tos]); 89 BN_CTX_start(ctx);
88 if (dv == NULL) dv= &(ctx->bn[ctx->tos+1]); 90 D = BN_CTX_get(ctx);
89 if (rem == NULL) rem= &(ctx->bn[ctx->tos+2]); 91 if (dv == NULL) dv = BN_CTX_get(ctx);
92 if (rem == NULL) rem = BN_CTX_get(ctx);
93 if (D == NULL || dv == NULL || rem == NULL)
94 goto end;
90 95
91 nd=BN_num_bits(d); 96 nd=BN_num_bits(d);
92 nm=BN_num_bits(m); 97 nm=BN_num_bits(m);
93 if (BN_copy(D,d) == NULL) return(0); 98 if (BN_copy(D,d) == NULL) goto end;
94 if (BN_copy(rem,m) == NULL) return(0); 99 if (BN_copy(rem,m) == NULL) goto end;
95 100
96 /* The next 2 are needed so we can do a dv->d[0]|=1 later 101 /* The next 2 are needed so we can do a dv->d[0]|=1 later
97 * since BN_lshift1 will only work once there is a value :-) */ 102 * since BN_lshift1 will only work once there is a value :-) */
@@ -99,25 +104,54 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
99 bn_wexpand(dv,1); 104 bn_wexpand(dv,1);
100 dv->top=1; 105 dv->top=1;
101 106
102 if (!BN_lshift(D,D,nm-nd)) return(0); 107 if (!BN_lshift(D,D,nm-nd)) goto end;
103 for (i=nm-nd; i>=0; i--) 108 for (i=nm-nd; i>=0; i--)
104 { 109 {
105 if (!BN_lshift1(dv,dv)) return(0); 110 if (!BN_lshift1(dv,dv)) goto end;
106 if (BN_ucmp(rem,D) >= 0) 111 if (BN_ucmp(rem,D) >= 0)
107 { 112 {
108 dv->d[0]|=1; 113 dv->d[0]|=1;
109 if (!BN_usub(rem,rem,D)) return(0); 114 if (!BN_usub(rem,rem,D)) goto end;
110 } 115 }
111/* CAN IMPROVE (and have now :=) */ 116/* CAN IMPROVE (and have now :=) */
112 if (!BN_rshift1(D,D)) return(0); 117 if (!BN_rshift1(D,D)) goto end;
113 } 118 }
114 rem->neg=BN_is_zero(rem)?0:m->neg; 119 rem->neg=BN_is_zero(rem)?0:m->neg;
115 dv->neg=m->neg^d->neg; 120 dv->neg=m->neg^d->neg;
116 return(1); 121 ret = 1;
122 end:
123 BN_CTX_end(ctx);
124 return(ret);
117 } 125 }
118 126
119#else 127#else
120 128
129#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC) && !defined(BN_DIV3W)
130# if defined(__GNUC__) && __GNUC__>=2
131# if defined(__i386)
132 /*
133 * There were two reasons for implementing this template:
134 * - GNU C generates a call to a function (__udivdi3 to be exact)
135 * in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
136 * understand why...);
137 * - divl doesn't only calculate quotient, but also leaves
138 * remainder in %edx which we can definitely use here:-)
139 *
140 * <appro@fy.chalmers.se>
141 */
142# define bn_div_words(n0,n1,d0) \
143 ({ asm volatile ( \
144 "divl %4" \
145 : "=a"(q), "=d"(rem) \
146 : "a"(n1), "d"(n0), "g"(d0) \
147 : "cc"); \
148 q; \
149 })
150# define REMAINDER_IS_ALREADY_CALCULATED
151# endif /* __<cpu> */
152# endif /* __GNUC__ */
153#endif /* NO_ASM */
154
121int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, 155int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
122 BN_CTX *ctx) 156 BN_CTX *ctx)
123 { 157 {
@@ -144,13 +178,15 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
144 return(1); 178 return(1);
145 } 179 }
146 180
147 tmp= &(ctx->bn[ctx->tos]); 181 BN_CTX_start(ctx);
182 tmp=BN_CTX_get(ctx);
148 tmp->neg=0; 183 tmp->neg=0;
149 snum= &(ctx->bn[ctx->tos+1]); 184 snum=BN_CTX_get(ctx);
150 sdiv= &(ctx->bn[ctx->tos+2]); 185 sdiv=BN_CTX_get(ctx);
151 if (dv == NULL) 186 if (dv == NULL)
152 res= &(ctx->bn[ctx->tos+3]); 187 res=BN_CTX_get(ctx);
153 else res=dv; 188 else res=dv;
189 if (res == NULL) goto err;
154 190
155 /* First we normalise the numbers */ 191 /* First we normalise the numbers */
156 norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); 192 norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
@@ -202,97 +238,76 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
202 { 238 {
203 BN_ULONG q,l0; 239 BN_ULONG q,l0;
204#ifdef BN_DIV3W 240#ifdef BN_DIV3W
205 q=bn_div_3_words(wnump,d0,d1); 241 q=bn_div_3_words(wnump,d1,d0);
206#else 242#else
207
208#if !defined(NO_ASM) && !defined(PEDANTIC)
209# if defined(__GNUC__) && __GNUC__>=2
210# if defined(__i386)
211 /*
212 * There were two reasons for implementing this template:
213 * - GNU C generates a call to a function (__udivdi3 to be exact)
214 * in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
215 * understand why...);
216 * - divl doesn't only calculate quotient, but also leaves
217 * remainder in %edx which we can definitely use here:-)
218 *
219 * <appro@fy.chalmers.se>
220 */
221# define bn_div_words(n0,n1,d0) \
222 ({ asm volatile ( \
223 "divl %4" \
224 : "=a"(q), "=d"(rem) \
225 : "a"(n1), "d"(n0), "g"(d0) \
226 : "cc"); \
227 q; \
228 })
229# define REMINDER_IS_ALREADY_CALCULATED
230# endif /* __<cpu> */
231# endif /* __GNUC__ */
232#endif /* NO_ASM */
233 BN_ULONG n0,n1,rem=0; 243 BN_ULONG n0,n1,rem=0;
234 244
235 n0=wnump[0]; 245 n0=wnump[0];
236 n1=wnump[-1]; 246 n1=wnump[-1];
237 if (n0 == d0) 247 if (n0 == d0)
238 q=BN_MASK2; 248 q=BN_MASK2;
239 else 249 else /* n0 < d0 */
250 {
251#ifdef BN_LLONG
252 BN_ULLONG t2;
253
240#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words) 254#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
241 q=((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0; 255 q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
242#else 256#else
243 q=bn_div_words(n0,n1,d0); 257 q=bn_div_words(n0,n1,d0);
244#endif 258#endif
245 { 259
246#ifdef BN_LLONG 260#ifndef REMAINDER_IS_ALREADY_CALCULATED
247 BN_ULLONG t2; 261 /*
248 262 * rem doesn't have to be BN_ULLONG. The least we
249#ifndef REMINDER_IS_ALREADY_CALCULATED 263 * know it's less that d0, isn't it?
250 /* 264 */
251 * rem doesn't have to be BN_ULLONG. The least we 265 rem=(n1-q*d0)&BN_MASK2;
252 * know it's less that d0, isn't it?
253 */
254 rem=(n1-q*d0)&BN_MASK2;
255#endif 266#endif
256 t2=(BN_ULLONG)d1*q; 267 t2=(BN_ULLONG)d1*q;
268
269 for (;;)
270 {
271 if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))
272 break;
273 q--;
274 rem += d0;
275 if (rem < d0) break; /* don't let rem overflow */
276 t2 -= d1;
277 }
278#else /* !BN_LLONG */
279 BN_ULONG t2l,t2h,ql,qh;
257 280
258 for (;;) 281 q=bn_div_words(n0,n1,d0);
259 { 282#ifndef REMAINDER_IS_ALREADY_CALCULATED
260 if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2])) 283 rem=(n1-q*d0)&BN_MASK2;
261 break; 284#endif
262 q--; 285
263 rem += d0; 286#ifdef BN_UMULT_HIGH
264 if (rem < d0) break; /* don't let rem overflow */ 287 t2l = d1 * q;
265 t2 -= d1; 288 t2h = BN_UMULT_HIGH(d1,q);
266 }
267#else 289#else
268 BN_ULONG t2l,t2h,ql,qh; 290 t2l=LBITS(d1); t2h=HBITS(d1);
269 291 ql =LBITS(q); qh =HBITS(q);
270#ifndef REMINDER_IS_ALREADY_CALCULATED 292 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
271 /*
272 * It's more than enough with the only multiplication.
273 * See the comment above in BN_LLONG section...
274 */
275 rem=(n1-q*d0)&BN_MASK2;
276#endif 293#endif
277 t2l=LBITS(d1); t2h=HBITS(d1);
278 ql =LBITS(q); qh =HBITS(q);
279 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
280 294
281 for (;;) 295 for (;;)
282 { 296 {
283 if ((t2h < rem) || 297 if ((t2h < rem) ||
284 ((t2h == rem) && (t2l <= wnump[-2]))) 298 ((t2h == rem) && (t2l <= wnump[-2])))
285 break; 299 break;
286 q--; 300 q--;
287 rem += d0; 301 rem += d0;
288 if (rem < d0) break; /* don't let rem overflow */ 302 if (rem < d0) break; /* don't let rem overflow */
289 if (t2l < d1) t2h--; t2l -= d1; 303 if (t2l < d1) t2h--; t2l -= d1;
304 }
305#endif /* !BN_LLONG */
290 } 306 }
291#endif
292 }
293#endif /* !BN_DIV3W */ 307#endif /* !BN_DIV3W */
294 wnum.d--; wnum.top++; 308
295 l0=bn_mul_words(tmp->d,sdiv->d,div_n,q); 309 l0=bn_mul_words(tmp->d,sdiv->d,div_n,q);
310 wnum.d--; wnum.top++;
296 tmp->d[div_n]=l0; 311 tmp->d[div_n]=l0;
297 for (j=div_n+1; j>0; j--) 312 for (j=div_n+1; j>0; j--)
298 if (tmp->d[j-1]) break; 313 if (tmp->d[j-1]) break;
@@ -318,8 +333,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
318 BN_rshift(rm,snum,norm_shift); 333 BN_rshift(rm,snum,norm_shift);
319 rm->neg=num->neg; 334 rm->neg=num->neg;
320 } 335 }
336 BN_CTX_end(ctx);
321 return(1); 337 return(1);
322err: 338err:
339 BN_CTX_end(ctx);
323 return(0); 340 return(0);
324 } 341 }
325 342
@@ -335,22 +352,27 @@ int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
335 if (BN_ucmp(m,d) < 0) 352 if (BN_ucmp(m,d) < 0)
336 return((BN_copy(rem,m) == NULL)?0:1); 353 return((BN_copy(rem,m) == NULL)?0:1);
337 354
338 dv= &(ctx->bn[ctx->tos]); 355 BN_CTX_start(ctx);
356 dv=BN_CTX_get(ctx);
339 357
340 if (!BN_copy(rem,m)) return(0); 358 if (!BN_copy(rem,m)) goto err;
341 359
342 nm=BN_num_bits(rem); 360 nm=BN_num_bits(rem);
343 nd=BN_num_bits(d); 361 nd=BN_num_bits(d);
344 if (!BN_lshift(dv,d,nm-nd)) return(0); 362 if (!BN_lshift(dv,d,nm-nd)) goto err;
345 for (i=nm-nd; i>=0; i--) 363 for (i=nm-nd; i>=0; i--)
346 { 364 {
347 if (BN_cmp(rem,dv) >= 0) 365 if (BN_cmp(rem,dv) >= 0)
348 { 366 {
349 if (!BN_sub(rem,rem,dv)) return(0); 367 if (!BN_sub(rem,rem,dv)) goto err;
350 } 368 }
351 if (!BN_rshift1(dv,dv)) return(0); 369 if (!BN_rshift1(dv,dv)) goto err;
352 } 370 }
371 BN_CTX_end(ctx);
353 return(1); 372 return(1);
373 err:
374 BN_CTX_end(ctx);
375 return(0);
354#else 376#else
355 return(BN_div(NULL,rem,m,d,ctx)); 377 return(BN_div(NULL,rem,m,d,ctx));
356#endif 378#endif
diff --git a/src/lib/libcrypto/bn/bn_err.c b/src/lib/libcrypto/bn/bn_err.c
index 73e80774e5..f3b9497dca 100644
--- a/src/lib/libcrypto/bn/bn_err.c
+++ b/src/lib/libcrypto/bn/bn_err.c
@@ -71,6 +71,7 @@ static ERR_STRING_DATA BN_str_functs[]=
71{ERR_PACK(0,BN_F_BN_BLINDING_UPDATE,0), "BN_BLINDING_update"}, 71{ERR_PACK(0,BN_F_BN_BLINDING_UPDATE,0), "BN_BLINDING_update"},
72{ERR_PACK(0,BN_F_BN_BN2DEC,0), "BN_bn2dec"}, 72{ERR_PACK(0,BN_F_BN_BN2DEC,0), "BN_bn2dec"},
73{ERR_PACK(0,BN_F_BN_BN2HEX,0), "BN_bn2hex"}, 73{ERR_PACK(0,BN_F_BN_BN2HEX,0), "BN_bn2hex"},
74{ERR_PACK(0,BN_F_BN_CTX_GET,0), "BN_CTX_get"},
74{ERR_PACK(0,BN_F_BN_CTX_NEW,0), "BN_CTX_new"}, 75{ERR_PACK(0,BN_F_BN_CTX_NEW,0), "BN_CTX_new"},
75{ERR_PACK(0,BN_F_BN_DIV,0), "BN_div"}, 76{ERR_PACK(0,BN_F_BN_DIV,0), "BN_div"},
76{ERR_PACK(0,BN_F_BN_EXPAND2,0), "bn_expand2"}, 77{ERR_PACK(0,BN_F_BN_EXPAND2,0), "bn_expand2"},
@@ -95,6 +96,7 @@ static ERR_STRING_DATA BN_str_reasons[]=
95{BN_R_INVALID_LENGTH ,"invalid length"}, 96{BN_R_INVALID_LENGTH ,"invalid length"},
96{BN_R_NOT_INITIALIZED ,"not initialized"}, 97{BN_R_NOT_INITIALIZED ,"not initialized"},
97{BN_R_NO_INVERSE ,"no inverse"}, 98{BN_R_NO_INVERSE ,"no inverse"},
99{BN_R_TOO_MANY_TEMPORARY_VARIABLES ,"too many temporary variables"},
98{0,NULL} 100{0,NULL}
99 }; 101 };
100 102
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index 2df1614ada..0c11601675 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -59,6 +59,12 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62#ifdef ATALLA
63# include <alloca.h>
64# include <atasi.h>
65# include <assert.h>
66# include <dlfcn.h>
67#endif
62 68
63#define TABLE_SIZE 16 69#define TABLE_SIZE 16
64 70
@@ -72,7 +78,8 @@ int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
72 bn_check_top(b); 78 bn_check_top(b);
73 bn_check_top(m); 79 bn_check_top(m);
74 80
75 t= &(ctx->bn[ctx->tos++]); 81 BN_CTX_start(ctx);
82 if ((t = BN_CTX_get(ctx)) == NULL) goto err;
76 if (a == b) 83 if (a == b)
77 { if (!BN_sqr(t,a,ctx)) goto err; } 84 { if (!BN_sqr(t,a,ctx)) goto err; }
78 else 85 else
@@ -80,7 +87,7 @@ int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
80 if (!BN_mod(ret,t,m,ctx)) goto err; 87 if (!BN_mod(ret,t,m,ctx)) goto err;
81 r=1; 88 r=1;
82err: 89err:
83 ctx->tos--; 90 BN_CTX_end(ctx);
84 return(r); 91 return(r);
85 } 92 }
86 93
@@ -91,8 +98,10 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx)
91 int i,bits,ret=0; 98 int i,bits,ret=0;
92 BIGNUM *v,*tmp; 99 BIGNUM *v,*tmp;
93 100
94 v= &(ctx->bn[ctx->tos++]); 101 BN_CTX_start(ctx);
95 tmp= &(ctx->bn[ctx->tos++]); 102 v = BN_CTX_get(ctx);
103 tmp = BN_CTX_get(ctx);
104 if (v == NULL || tmp == NULL) goto err;
96 105
97 if (BN_copy(v,a) == NULL) goto err; 106 if (BN_copy(v,a) == NULL) goto err;
98 bits=BN_num_bits(p); 107 bits=BN_num_bits(p);
@@ -113,7 +122,7 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx)
113 } 122 }
114 ret=1; 123 ret=1;
115err: 124err:
116 ctx->tos-=2; 125 BN_CTX_end(ctx);
117 return(ret); 126 return(ret);
118 } 127 }
119 128
@@ -122,15 +131,15 @@ err:
122/* this one works - simple but works */ 131/* this one works - simple but works */
123int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx) 132int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx)
124 { 133 {
125 int i,bits,ret=0,tos; 134 int i,bits,ret=0;
126 BIGNUM *v,*rr; 135 BIGNUM *v,*rr;
127 136
128 tos=ctx->tos; 137 BN_CTX_start(ctx);
129 v= &(ctx->bn[ctx->tos++]);
130 if ((r == a) || (r == p)) 138 if ((r == a) || (r == p))
131 rr= &(ctx->bn[ctx->tos++]); 139 rr = BN_CTX_get(ctx);
132 else 140 else
133 rr=r; 141 rr = r;
142 if ((v = BN_CTX_get(ctx)) == NULL) goto err;
134 143
135 if (BN_copy(v,a) == NULL) goto err; 144 if (BN_copy(v,a) == NULL) goto err;
136 bits=BN_num_bits(p); 145 bits=BN_num_bits(p);
@@ -149,11 +158,178 @@ int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx)
149 } 158 }
150 ret=1; 159 ret=1;
151err: 160err:
152 ctx->tos=tos;
153 if (r != rr) BN_copy(r,rr); 161 if (r != rr) BN_copy(r,rr);
162 BN_CTX_end(ctx);
154 return(ret); 163 return(ret);
155 } 164 }
156 165
166#ifdef ATALLA
167
168/*
169 * This routine will dynamically check for the existance of an Atalla AXL-200
170 * SSL accelerator module. If one is found, the variable
171 * asi_accelerator_present is set to 1 and the function pointers
172 * ptr_ASI_xxxxxx above will be initialized to corresponding ASI API calls.
173 */
174typedef int tfnASI_GetPerformanceStatistics(int reset_flag,
175 unsigned int *ret_buf);
176typedef int tfnASI_GetHardwareConfig(long card_num, unsigned int *ret_buf);
177typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey,
178 unsigned char *output,
179 unsigned char *input,
180 unsigned int modulus_len);
181
182static tfnASI_GetHardwareConfig *ptr_ASI_GetHardwareConfig;
183static tfnASI_RSAPrivateKeyOpFn *ptr_ASI_RSAPrivateKeyOpFn;
184static tfnASI_GetPerformanceStatistics *ptr_ASI_GetPerformanceStatistics;
185static int asi_accelerator_present;
186static int tried_atalla;
187
188void atalla_initialize_accelerator_handle(void)
189 {
190 void *dl_handle;
191 int status;
192 unsigned int config_buf[1024];
193 static int tested;
194
195 if(tested)
196 return;
197
198 tested=1;
199
200 bzero((void *)config_buf, 1024);
201
202 /*
203 * Check to see if the library is present on the system
204 */
205 dl_handle = dlopen("atasi.so", RTLD_NOW);
206 if (dl_handle == (void *) NULL)
207 {
208/* printf("atasi.so library is not present on the system\n");
209 printf("No HW acceleration available\n");*/
210 return;
211 }
212
213 /*
214 * The library is present. Now we'll check to insure that the
215 * LDM is up and running. First we'll get the address of the
216 * function in the atasi library that we need to see if the
217 * LDM is operating.
218 */
219
220 ptr_ASI_GetHardwareConfig =
221 (tfnASI_GetHardwareConfig *)dlsym(dl_handle,"ASI_GetHardwareConfig");
222
223 if (ptr_ASI_GetHardwareConfig)
224 {
225 /*
226 * We found the call, now we'll get our config
227 * status. If we get a non 0 result, the LDM is not
228 * running and we cannot use the Atalla ASI *
229 * library.
230 */
231 status = (*ptr_ASI_GetHardwareConfig)(0L, config_buf);
232 if (status != 0)
233 {
234 printf("atasi.so library is present but not initialized\n");
235 printf("No HW acceleration available\n");
236 return;
237 }
238 }
239 else
240 {
241/* printf("We found the library, but not the function. Very Strange!\n");*/
242 return ;
243 }
244
245 /*
246 * It looks like we have acceleration capabilities. Load up the
247 * pointers to our ASI API calls.
248 */
249 ptr_ASI_RSAPrivateKeyOpFn=
250 (tfnASI_RSAPrivateKeyOpFn *)dlsym(dl_handle, "ASI_RSAPrivateKeyOpFn");
251 if (ptr_ASI_RSAPrivateKeyOpFn == NULL)
252 {
253/* printf("We found the library, but no RSA function. Very Strange!\n");*/
254 return;
255 }
256
257 ptr_ASI_GetPerformanceStatistics =
258 (tfnASI_GetPerformanceStatistics *)dlsym(dl_handle, "ASI_GetPerformanceStatistics");
259 if (ptr_ASI_GetPerformanceStatistics == NULL)
260 {
261/* printf("We found the library, but no stat function. Very Strange!\n");*/
262 return;
263 }
264
265 /*
266 * Indicate that acceleration is available
267 */
268 asi_accelerator_present = 1;
269
270/* printf("This system has acceleration!\n");*/
271
272 return;
273 }
274
275/* make sure this only gets called once when bn_mod_exp calls bn_mod_exp_mont */
276int BN_mod_exp_atalla(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m)
277 {
278 unsigned char *abin;
279 unsigned char *pbin;
280 unsigned char *mbin;
281 unsigned char *rbin;
282 int an,pn,mn,ret;
283 RSAPrivateKey keydata;
284
285 atalla_initialize_accelerator_handle();
286 if(!asi_accelerator_present)
287 return 0;
288
289
290/* We should be able to run without size testing */
291# define ASIZE 128
292 an=BN_num_bytes(a);
293 pn=BN_num_bytes(p);
294 mn=BN_num_bytes(m);
295
296 if(an <= ASIZE && pn <= ASIZE && mn <= ASIZE)
297 {
298 int size=mn;
299
300 assert(an <= mn);
301 abin=alloca(size);
302 memset(abin,'\0',mn);
303 BN_bn2bin(a,abin+size-an);
304
305 pbin=alloca(pn);
306 BN_bn2bin(p,pbin);
307
308 mbin=alloca(size);
309 memset(mbin,'\0',mn);
310 BN_bn2bin(m,mbin+size-mn);
311
312 rbin=alloca(size);
313
314 memset(&keydata,'\0',sizeof keydata);
315 keydata.privateExponent.data=pbin;
316 keydata.privateExponent.len=pn;
317 keydata.modulus.data=mbin;
318 keydata.modulus.len=size;
319
320 ret=(*ptr_ASI_RSAPrivateKeyOpFn)(&keydata,rbin,abin,keydata.modulus.len);
321/*fprintf(stderr,"!%s\n",BN_bn2hex(a));*/
322 if(!ret)
323 {
324 BN_bin2bn(rbin,keydata.modulus.len,r);
325/*fprintf(stderr,"?%s\n",BN_bn2hex(r));*/
326 return 1;
327 }
328 }
329 return 0;
330 }
331#endif /* def ATALLA */
332
157int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, 333int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
158 BN_CTX *ctx) 334 BN_CTX *ctx)
159 { 335 {
@@ -163,6 +339,13 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
163 bn_check_top(p); 339 bn_check_top(p);
164 bn_check_top(m); 340 bn_check_top(m);
165 341
342#ifdef ATALLA
343 if(BN_mod_exp_atalla(r,a,p,m))
344 return 1;
345/* If it fails, try the other methods (but don't try atalla again) */
346 tried_atalla=1;
347#endif
348
166#ifdef MONT_MUL_MOD 349#ifdef MONT_MUL_MOD
167 /* I have finally been able to take out this pre-condition of 350 /* I have finally been able to take out this pre-condition of
168 * the top bit being set. It was caused by an error in BN_div 351 * the top bit being set. It was caused by an error in BN_div
@@ -180,6 +363,10 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
180 { ret=BN_mod_exp_simple(r,a,p,m,ctx); } 363 { ret=BN_mod_exp_simple(r,a,p,m,ctx); }
181#endif 364#endif
182 365
366#ifdef ATALLA
367 tried_atalla=0;
368#endif
369
183 return(ret); 370 return(ret);
184 } 371 }
185 372
@@ -193,7 +380,6 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
193 BIGNUM val[TABLE_SIZE]; 380 BIGNUM val[TABLE_SIZE];
194 BN_RECP_CTX recp; 381 BN_RECP_CTX recp;
195 382
196 aa= &(ctx->bn[ctx->tos++]);
197 bits=BN_num_bits(p); 383 bits=BN_num_bits(p);
198 384
199 if (bits == 0) 385 if (bits == 0)
@@ -201,6 +387,10 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
201 BN_one(r); 387 BN_one(r);
202 return(1); 388 return(1);
203 } 389 }
390
391 BN_CTX_start(ctx);
392 if ((aa = BN_CTX_get(ctx)) == NULL) goto err;
393
204 BN_RECP_CTX_init(&recp); 394 BN_RECP_CTX_init(&recp);
205 if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err; 395 if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;
206 396
@@ -289,7 +479,7 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
289 } 479 }
290 ret=1; 480 ret=1;
291err: 481err:
292 ctx->tos--; 482 BN_CTX_end(ctx);
293 for (i=0; i<ts; i++) 483 for (i=0; i<ts; i++)
294 BN_clear_free(&(val[i])); 484 BN_clear_free(&(val[i]));
295 BN_RECP_CTX_free(&recp); 485 BN_RECP_CTX_free(&recp);
@@ -312,19 +502,27 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
312 bn_check_top(p); 502 bn_check_top(p);
313 bn_check_top(m); 503 bn_check_top(m);
314 504
505#ifdef ATALLA
506 if(!tried_atalla && BN_mod_exp_atalla(rr,a,p,m))
507 return 1;
508/* If it fails, try the other methods */
509#endif
510
315 if (!(m->d[0] & 1)) 511 if (!(m->d[0] & 1))
316 { 512 {
317 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); 513 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);
318 return(0); 514 return(0);
319 } 515 }
320 d= &(ctx->bn[ctx->tos++]);
321 r= &(ctx->bn[ctx->tos++]);
322 bits=BN_num_bits(p); 516 bits=BN_num_bits(p);
323 if (bits == 0) 517 if (bits == 0)
324 { 518 {
325 BN_one(r); 519 BN_one(rr);
326 return(1); 520 return(1);
327 } 521 }
522 BN_CTX_start(ctx);
523 d = BN_CTX_get(ctx);
524 r = BN_CTX_get(ctx);
525 if (d == NULL || r == NULL) goto err;
328 526
329 /* If this is not done, things will break in the montgomery 527 /* If this is not done, things will break in the montgomery
330 * part */ 528 * part */
@@ -432,7 +630,7 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
432 ret=1; 630 ret=1;
433err: 631err:
434 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); 632 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
435 ctx->tos-=2; 633 BN_CTX_end(ctx);
436 for (i=0; i<ts; i++) 634 for (i=0; i<ts; i++)
437 BN_clear_free(&(val[i])); 635 BN_clear_free(&(val[i]));
438 return(ret); 636 return(ret);
@@ -448,7 +646,6 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
448 BIGNUM *d; 646 BIGNUM *d;
449 BIGNUM val[TABLE_SIZE]; 647 BIGNUM val[TABLE_SIZE];
450 648
451 d= &(ctx->bn[ctx->tos++]);
452 bits=BN_num_bits(p); 649 bits=BN_num_bits(p);
453 650
454 if (bits == 0) 651 if (bits == 0)
@@ -457,6 +654,9 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
457 return(1); 654 return(1);
458 } 655 }
459 656
657 BN_CTX_start(ctx);
658 if ((d = BN_CTX_get(ctx)) == NULL) goto err;
659
460 BN_init(&(val[0])); 660 BN_init(&(val[0]));
461 ts=1; 661 ts=1;
462 if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */ 662 if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */
@@ -541,7 +741,7 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
541 } 741 }
542 ret=1; 742 ret=1;
543err: 743err:
544 ctx->tos--; 744 BN_CTX_end(ctx);
545 for (i=0; i<ts; i++) 745 for (i=0; i<ts; i++)
546 BN_clear_free(&(val[i])); 746 BN_clear_free(&(val[i]));
547 return(ret); 747 return(ret);
diff --git a/src/lib/libcrypto/bn/bn_exp2.c b/src/lib/libcrypto/bn/bn_exp2.c
index 1132d53365..4f4e9e3299 100644
--- a/src/lib/libcrypto/bn/bn_exp2.c
+++ b/src/lib/libcrypto/bn/bn_exp2.c
@@ -9,7 +9,7 @@
9 * bits=1 75.4% 79.4% 9 * bits=1 75.4% 79.4%
10 * bits=2 61.2% 62.4% 10 * bits=2 61.2% 62.4%
11 * bits=3 61.3% 59.3% 11 * bits=3 61.3% 59.3%
12 * The lack of speed improvment is also a function of the pre-calculation 12 * The lack of speed improvement is also a function of the pre-calculation
13 * which could be removed. 13 * which could be removed.
14 */ 14 */
15#define EXP2_TABLE_BITS 2 /* 1 2 3 4 5 */ 15#define EXP2_TABLE_BITS 2 /* 1 2 3 4 5 */
@@ -35,15 +35,19 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
35 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); 35 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);
36 return(0); 36 return(0);
37 } 37 }
38 d= &(ctx->bn[ctx->tos++]);
39 r= &(ctx->bn[ctx->tos++]);
40 bits1=BN_num_bits(p1); 38 bits1=BN_num_bits(p1);
41 bits2=BN_num_bits(p2); 39 bits2=BN_num_bits(p2);
42 if ((bits1 == 0) && (bits2 == 0)) 40 if ((bits1 == 0) && (bits2 == 0))
43 { 41 {
44 BN_one(r); 42 BN_one(rr);
45 return(1); 43 return(1);
46 } 44 }
45
46 BN_CTX_start(ctx);
47 d = BN_CTX_get(ctx);
48 r = BN_CTX_get(ctx);
49 if (d == NULL || r == NULL) goto err;
50
47 bits=(bits1 > bits2)?bits1:bits2; 51 bits=(bits1 > bits2)?bits1:bits2;
48 52
49 /* If this is not done, things will break in the montgomery 53 /* If this is not done, things will break in the montgomery
@@ -183,7 +187,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
183 ret=1; 187 ret=1;
184err: 188err:
185 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); 189 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
186 ctx->tos-=2; 190 BN_CTX_end(ctx);
187 for (i=0; i<ts; i++) 191 for (i=0; i<ts; i++)
188 { 192 {
189 for (j=0; j<ts; j++) 193 for (j=0; j<ts; j++)
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c
index 64a76f4498..398207196b 100644
--- a/src/lib/libcrypto/bn/bn_gcd.c
+++ b/src/lib/libcrypto/bn/bn_gcd.c
@@ -61,6 +61,7 @@
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62 62
63static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); 63static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
64
64int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx) 65int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
65 { 66 {
66 BIGNUM *a,*b,*t; 67 BIGNUM *a,*b,*t;
@@ -69,8 +70,10 @@ int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
69 bn_check_top(in_a); 70 bn_check_top(in_a);
70 bn_check_top(in_b); 71 bn_check_top(in_b);
71 72
72 a= &(ctx->bn[ctx->tos]); 73 BN_CTX_start(ctx);
73 b= &(ctx->bn[ctx->tos+1]); 74 a = BN_CTX_get(ctx);
75 b = BN_CTX_get(ctx);
76 if (a == NULL || b == NULL) goto err;
74 77
75 if (BN_copy(a,in_a) == NULL) goto err; 78 if (BN_copy(a,in_a) == NULL) goto err;
76 if (BN_copy(b,in_b) == NULL) goto err; 79 if (BN_copy(b,in_b) == NULL) goto err;
@@ -82,6 +85,7 @@ int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
82 if (BN_copy(r,t) == NULL) goto err; 85 if (BN_copy(r,t) == NULL) goto err;
83 ret=1; 86 ret=1;
84err: 87err:
88 BN_CTX_end(ctx);
85 return(ret); 89 return(ret);
86 } 90 }
87 91
@@ -142,20 +146,22 @@ err:
142/* solves ax == 1 (mod n) */ 146/* solves ax == 1 (mod n) */
143BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) 147BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
144 { 148 {
145 BIGNUM *A,*B,*X,*Y,*M,*D,*R; 149 BIGNUM *A,*B,*X,*Y,*M,*D,*R=NULL;
146 BIGNUM *T,*ret=NULL; 150 BIGNUM *T,*ret=NULL;
147 int sign; 151 int sign;
148 152
149 bn_check_top(a); 153 bn_check_top(a);
150 bn_check_top(n); 154 bn_check_top(n);
151 155
152 A= &(ctx->bn[ctx->tos]); 156 BN_CTX_start(ctx);
153 B= &(ctx->bn[ctx->tos+1]); 157 A = BN_CTX_get(ctx);
154 X= &(ctx->bn[ctx->tos+2]); 158 B = BN_CTX_get(ctx);
155 D= &(ctx->bn[ctx->tos+3]); 159 X = BN_CTX_get(ctx);
156 M= &(ctx->bn[ctx->tos+4]); 160 D = BN_CTX_get(ctx);
157 Y= &(ctx->bn[ctx->tos+5]); 161 M = BN_CTX_get(ctx);
158 ctx->tos+=6; 162 Y = BN_CTX_get(ctx);
163 if (Y == NULL) goto err;
164
159 if (in == NULL) 165 if (in == NULL)
160 R=BN_new(); 166 R=BN_new();
161 else 167 else
@@ -198,7 +204,7 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
198 ret=R; 204 ret=R;
199err: 205err:
200 if ((ret == NULL) && (in == NULL)) BN_free(R); 206 if ((ret == NULL) && (in == NULL)) BN_free(R);
201 ctx->tos-=6; 207 BN_CTX_end(ctx);
202 return(ret); 208 return(ret);
203 } 209 }
204 210
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h
index 85a372695b..e36ccbc4c2 100644
--- a/src/lib/libcrypto/bn/bn_lcl.h
+++ b/src/lib/libcrypto/bn/bn_lcl.h
@@ -73,18 +73,53 @@ extern "C" {
73#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ 73#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
74#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ 74#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
75 75
76#if 0 76#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC)
77#ifndef BN_MUL_COMBA 77/*
78/* #define bn_mul_comba8(r,a,b) bn_mul_normal(r,a,8,b,8) */ 78 * BN_UMULT_HIGH section.
79/* #define bn_mul_comba4(r,a,b) bn_mul_normal(r,a,4,b,4) */ 79 *
80#endif 80 * No, I'm not trying to overwhelm you when stating that the
81 81 * product of N-bit numbers is 2*N bits wide:-) No, I don't expect
82#ifndef BN_SQR_COMBA 82 * you to be impressed when I say that if the compiler doesn't
83/* This is probably faster than using the C code - I need to check */ 83 * support 2*N integer type, then you have to replace every N*N
84#define bn_sqr_comba8(r,a) bn_mul_normal(r,a,8,a,8) 84 * multiplication with 4 (N/2)*(N/2) accompanied by some shifts
85#define bn_sqr_comba4(r,a) bn_mul_normal(r,a,4,a,4) 85 * and additions which unavoidably results in severe performance
86#endif 86 * penalties. Of course provided that the hardware is capable of
87#endif 87 * producing 2*N result... That's when you normally start
88 * considering assembler implementation. However! It should be
89 * pointed out that some CPUs (most notably Alpha, PowerPC and
90 * upcoming IA-64 family:-) provide *separate* instruction
91 * calculating the upper half of the product placing the result
92 * into a general purpose register. Now *if* the compiler supports
93 * inline assembler, then it's not impossible to implement the
94 * "bignum" routines (and have the compiler optimize 'em)
95 * exhibiting "native" performance in C. That's what BN_UMULT_HIGH
96 * macro is about:-)
97 *
98 * <appro@fy.chalmers.se>
99 */
100# if defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
101# if defined(__DECC)
102# include <c_asm.h>
103# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
104# elif defined(__GNUC__)
105# define BN_UMULT_HIGH(a,b) ({ \
106 register BN_ULONG ret; \
107 asm ("umulh %1,%2,%0" \
108 : "=r"(ret) \
109 : "r"(a), "r"(b)); \
110 ret; })
111# endif /* compiler */
112# elif defined(_ARCH_PPC) && defined(__64BIT__) && defined(SIXTY_FOUR_BIT_LONG)
113# if defined(__GNUC__)
114# define BN_UMULT_HIGH(a,b) ({ \
115 register BN_ULONG ret; \
116 asm ("mulhdu %0,%1,%2" \
117 : "=r"(ret) \
118 : "r"(a), "r"(b)); \
119 ret; })
120# endif /* compiler */
121# endif /* cpu */
122#endif /* NO_ASM */
88 123
89/************************************************************* 124/*************************************************************
90 * Using the long long type 125 * Using the long long type
@@ -92,15 +127,12 @@ extern "C" {
92#define Lw(t) (((BN_ULONG)(t))&BN_MASK2) 127#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
93#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) 128#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
94 129
95/* These are used for internal error checking and are not normally used */ 130/* This is used for internal error checking and is not normally used */
96#ifdef BN_DEBUG 131#ifdef BN_DEBUG
97#define bn_check_top(a) \ 132# include <assert.h>
98 { if (((a)->top < 0) || ((a)->top > (a)->max)) \ 133# define bn_check_top(a) assert ((a)->top >= 0 && (a)->top <= (a)->max);
99 { char *nullp=NULL; *nullp='z'; } }
100#define bn_check_num(a) if ((a) < 0) { char *nullp=NULL; *nullp='z'; }
101#else 134#else
102#define bn_check_top(a) 135# define bn_check_top(a)
103#define bn_check_num(a)
104#endif 136#endif
105 137
106/* This macro is to add extra stuff for development checking */ 138/* This macro is to add extra stuff for development checking */
@@ -134,8 +166,6 @@ extern "C" {
134 bn_set_max(r); \ 166 bn_set_max(r); \
135 } 167 }
136 168
137/* #define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?(n):bn_expand2((n),(b))) */
138
139#ifdef BN_LLONG 169#ifdef BN_LLONG
140#define mul_add(r,a,w,c) { \ 170#define mul_add(r,a,w,c) { \
141 BN_ULLONG t; \ 171 BN_ULLONG t; \
@@ -151,6 +181,43 @@ extern "C" {
151 (c)= Hw(t); \ 181 (c)= Hw(t); \
152 } 182 }
153 183
184#define sqr(r0,r1,a) { \
185 BN_ULLONG t; \
186 t=(BN_ULLONG)(a)*(a); \
187 (r0)=Lw(t); \
188 (r1)=Hw(t); \
189 }
190
191#elif defined(BN_UMULT_HIGH)
192#define mul_add(r,a,w,c) { \
193 BN_ULONG high,low,ret,tmp=(a); \
194 ret = (r); \
195 high= BN_UMULT_HIGH(w,tmp); \
196 ret += (c); \
197 low = (w) * tmp; \
198 (c) = (ret<(c))?1:0; \
199 (c) += high; \
200 ret += low; \
201 (c) += (ret<low)?1:0; \
202 (r) = ret; \
203 }
204
205#define mul(r,a,w,c) { \
206 BN_ULONG high,low,ret,ta=(a); \
207 low = (w) * ta; \
208 high= BN_UMULT_HIGH(w,ta); \
209 ret = low + (c); \
210 (c) = high; \
211 (c) += (ret<low)?1:0; \
212 (r) = ret; \
213 }
214
215#define sqr(r0,r1,a) { \
216 BN_ULONG tmp=(a); \
217 (r0) = tmp * tmp; \
218 (r1) = BN_UMULT_HIGH(tmp,tmp); \
219 }
220
154#else 221#else
155/************************************************************* 222/*************************************************************
156 * No long long type 223 * No long long type
@@ -228,21 +295,7 @@ extern "C" {
228 (c)=h&BN_MASK2; \ 295 (c)=h&BN_MASK2; \
229 (r)=l&BN_MASK2; \ 296 (r)=l&BN_MASK2; \
230 } 297 }
231 298#endif /* !BN_LLONG */
232#endif
233
234OPENSSL_EXTERN int bn_limit_bits;
235OPENSSL_EXTERN int bn_limit_num; /* (1<<bn_limit_bits) */
236/* Recursive 'low' limit */
237OPENSSL_EXTERN int bn_limit_bits_low;
238OPENSSL_EXTERN int bn_limit_num_low; /* (1<<bn_limit_bits_low) */
239/* Do modified 'high' part calculation' */
240OPENSSL_EXTERN int bn_limit_bits_high;
241OPENSSL_EXTERN int bn_limit_num_high; /* (1<<bn_limit_bits_high) */
242OPENSSL_EXTERN int bn_limit_bits_mont;
243OPENSSL_EXTERN int bn_limit_num_mont; /* (1<<bn_limit_bits_mont) */
244
245BIGNUM *bn_expand2(BIGNUM *b, int bits);
246 299
247void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb); 300void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
248void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); 301void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 5d62d88e8b..0e6b12d9c3 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -71,14 +71,14 @@ const char *BN_version="Big Number" OPENSSL_VERSION_PTEXT;
71 * 7 - 128 == 4096 71 * 7 - 128 == 4096
72 * 8 - 256 == 8192 72 * 8 - 256 == 8192
73 */ 73 */
74OPENSSL_GLOBAL int bn_limit_bits=0; 74static int bn_limit_bits=0;
75OPENSSL_GLOBAL int bn_limit_num=8; /* (1<<bn_limit_bits) */ 75static int bn_limit_num=8; /* (1<<bn_limit_bits) */
76OPENSSL_GLOBAL int bn_limit_bits_low=0; 76static int bn_limit_bits_low=0;
77OPENSSL_GLOBAL int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */ 77static int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */
78OPENSSL_GLOBAL int bn_limit_bits_high=0; 78static int bn_limit_bits_high=0;
79OPENSSL_GLOBAL int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */ 79static int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */
80OPENSSL_GLOBAL int bn_limit_bits_mont=0; 80static int bn_limit_bits_mont=0;
81OPENSSL_GLOBAL int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */ 81static int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */
82 82
83void BN_set_params(int mult, int high, int low, int mont) 83void BN_set_params(int mult, int high, int low, int mont)
84 { 84 {
@@ -304,42 +304,10 @@ BIGNUM *BN_new(void)
304 return(ret); 304 return(ret);
305 } 305 }
306 306
307 307/* This is an internal function that should not be used in applications.
308BN_CTX *BN_CTX_new(void) 308 * It ensures that 'b' has enough room for a 'words' word number number.
309 { 309 * It is mostly used by the various BIGNUM routines. If there is an error,
310 BN_CTX *ret; 310 * NULL is returned. If not, 'b' is returned. */
311
312 ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
313 if (ret == NULL)
314 {
315 BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
316 return(NULL);
317 }
318
319 BN_CTX_init(ret);
320 ret->flags=BN_FLG_MALLOCED;
321 return(ret);
322 }
323
324void BN_CTX_init(BN_CTX *ctx)
325 {
326 memset(ctx,0,sizeof(BN_CTX));
327 ctx->tos=0;
328 ctx->flags=0;
329 }
330
331void BN_CTX_free(BN_CTX *c)
332 {
333 int i;
334
335 if(c == NULL)
336 return;
337
338 for (i=0; i<BN_CTX_NUM; i++)
339 BN_clear_free(&(c->bn[i]));
340 if (c->flags & BN_FLG_MALLOCED)
341 Free(c);
342 }
343 311
344BIGNUM *bn_expand2(BIGNUM *b, int words) 312BIGNUM *bn_expand2(BIGNUM *b, int words)
345 { 313 {
@@ -389,7 +357,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
389 * if A and B happen to share same cache line such code is going to 357 * if A and B happen to share same cache line such code is going to
390 * cause severe cache trashing. Both factors have severe impact on 358 * cause severe cache trashing. Both factors have severe impact on
391 * performance of modern CPUs and this is the reason why this 359 * performance of modern CPUs and this is the reason why this
392 * particulare piece of code is #ifdefed away and replaced by more 360 * particular piece of code is #ifdefed away and replaced by more
393 * "friendly" version found in #else section below. This comment 361 * "friendly" version found in #else section below. This comment
394 * also applies to BN_copy function. 362 * also applies to BN_copy function.
395 * 363 *
@@ -420,7 +388,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
420 A[0]=B[0]; 388 A[0]=B[0];
421 case 0: 389 case 0:
422 /* I need the 'case 0' entry for utrix cc. 390 /* I need the 'case 0' entry for utrix cc.
423 * If the optimiser is turned on, it does the 391 * If the optimizer is turned on, it does the
424 * switch table by doing 392 * switch table by doing
425 * a=top&7 393 * a=top&7
426 * a--; 394 * a--;
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index ee0f410c22..7bb0b91223 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -57,25 +57,27 @@
57 */ 57 */
58 58
59/* 59/*
60 * Details about Montgomery multiplication algorithms can be found at: 60 * Details about Montgomery multiplication algorithms can be found at
61 * http://www.ece.orst.edu/ISL/Publications.html 61 * http://security.ece.orst.edu/publications.html, e.g.
62 * http://www.ece.orst.edu/ISL/Koc/papers/j37acmon.pdf 62 * http://security.ece.orst.edu/koc/papers/j37acmon.pdf and
63 * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf
63 */ 64 */
64 65
65#include <stdio.h> 66#include <stdio.h>
66#include "cryptlib.h" 67#include "cryptlib.h"
67#include "bn_lcl.h" 68#include "bn_lcl.h"
68 69
69#define MONT_WORD 70#define MONT_WORD /* use the faster word-based algorithm */
70 71
71int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, 72int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
72 BN_MONT_CTX *mont, BN_CTX *ctx) 73 BN_MONT_CTX *mont, BN_CTX *ctx)
73 { 74 {
74 BIGNUM *tmp,*tmp2; 75 BIGNUM *tmp,*tmp2;
75 76
76 tmp= &(ctx->bn[ctx->tos]); 77 BN_CTX_start(ctx);
77 tmp2= &(ctx->bn[ctx->tos]); 78 tmp = BN_CTX_get(ctx);
78 ctx->tos+=2; 79 tmp2 = BN_CTX_get(ctx);
80 if (tmp == NULL || tmp2 == NULL) goto err;
79 81
80 bn_check_top(tmp); 82 bn_check_top(tmp);
81 bn_check_top(tmp2); 83 bn_check_top(tmp2);
@@ -99,7 +101,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
99 } 101 }
100 /* reduce from aRR to aR */ 102 /* reduce from aRR to aR */
101 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err; 103 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
102 ctx->tos-=2; 104 BN_CTX_end(ctx);
103 return(1); 105 return(1);
104err: 106err:
105 return(0); 107 return(0);
@@ -108,160 +110,123 @@ err:
108int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont, 110int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
109 BN_CTX *ctx) 111 BN_CTX *ctx)
110 { 112 {
111#ifdef BN_RECURSION_MONT 113 int retn=0;
112 if (mont->use_word)
113#endif
114 {
115 BIGNUM *n,*r;
116 BN_ULONG *ap,*np,*rp,n0,v,*nrp;
117 int al,nl,max,i,x,ri;
118 int retn=0;
119 114
120 r= &(ctx->bn[ctx->tos]); 115#ifdef MONT_WORD
116 BIGNUM *n,*r;
117 BN_ULONG *ap,*np,*rp,n0,v,*nrp;
118 int al,nl,max,i,x,ri;
121 119
122 if (!BN_copy(r,a)) goto err1; 120 BN_CTX_start(ctx);
123 n= &(mont->N); 121 if ((r = BN_CTX_get(ctx)) == NULL) goto err;
124 122
125 ap=a->d; 123 if (!BN_copy(r,a)) goto err;
126 /* mont->ri is the size of mont->N in bits/words */ 124 n= &(mont->N);
127 al=ri=mont->ri/BN_BITS2;
128 125
129 nl=n->top; 126 ap=a->d;
130 if ((al == 0) || (nl == 0)) { r->top=0; return(1); } 127 /* mont->ri is the size of mont->N in bits (rounded up
128 to the word size) */
129 al=ri=mont->ri/BN_BITS2;
130
131 nl=n->top;
132 if ((al == 0) || (nl == 0)) { r->top=0; return(1); }
131 133
132 max=(nl+al+1); /* allow for overflow (no?) XXX */ 134 max=(nl+al+1); /* allow for overflow (no?) XXX */
133 if (bn_wexpand(r,max) == NULL) goto err1; 135 if (bn_wexpand(r,max) == NULL) goto err;
134 if (bn_wexpand(ret,max) == NULL) goto err1; 136 if (bn_wexpand(ret,max) == NULL) goto err;
135 137
136 r->neg=a->neg^n->neg; 138 r->neg=a->neg^n->neg;
137 np=n->d; 139 np=n->d;
138 rp=r->d; 140 rp=r->d;
139 nrp= &(r->d[nl]); 141 nrp= &(r->d[nl]);
140 142
141 /* clear the top words of T */ 143 /* clear the top words of T */
142#if 1 144#if 1
143 for (i=r->top; i<max; i++) /* memset? XXX */ 145 for (i=r->top; i<max; i++) /* memset? XXX */
144 r->d[i]=0; 146 r->d[i]=0;
145#else 147#else
146 memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG)); 148 memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG));
147#endif 149#endif
148 150
149 r->top=max; 151 r->top=max;
150 n0=mont->n0; 152 n0=mont->n0;
151 153
152#ifdef BN_COUNT 154#ifdef BN_COUNT
153printf("word BN_from_montgomery %d * %d\n",nl,nl); 155 printf("word BN_from_montgomery %d * %d\n",nl,nl);
154#endif 156#endif
155 for (i=0; i<nl; i++) 157 for (i=0; i<nl; i++)
156 { 158 {
157 v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2); 159 v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
158 nrp++; 160 nrp++;
159 rp++; 161 rp++;
160 if (((nrp[-1]+=v)&BN_MASK2) >= v) 162 if (((nrp[-1]+=v)&BN_MASK2) >= v)
161 continue; 163 continue;
162 else
163 {
164 if (((++nrp[0])&BN_MASK2) != 0) continue;
165 if (((++nrp[1])&BN_MASK2) != 0) continue;
166 for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
167 }
168 }
169 bn_fix_top(r);
170
171 /* mont->ri will be a multiple of the word size */
172#if 0
173 BN_rshift(ret,r,mont->ri);
174#else
175 x=ri;
176 rp=ret->d;
177 ap= &(r->d[x]);
178 if (r->top < x)
179 al=0;
180 else 164 else
181 al=r->top-x;
182 ret->top=al;
183 al-=4;
184 for (i=0; i<al; i+=4)
185 { 165 {
186 BN_ULONG t1,t2,t3,t4; 166 if (((++nrp[0])&BN_MASK2) != 0) continue;
187 167 if (((++nrp[1])&BN_MASK2) != 0) continue;
188 t1=ap[i+0]; 168 for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
189 t2=ap[i+1];
190 t3=ap[i+2];
191 t4=ap[i+3];
192 rp[i+0]=t1;
193 rp[i+1]=t2;
194 rp[i+2]=t3;
195 rp[i+3]=t4;
196 } 169 }
197 al+=4;
198 for (; i<al; i++)
199 rp[i]=ap[i];
200#endif
201
202 if (BN_ucmp(ret, &(mont->N)) >= 0)
203 {
204 BN_usub(ret,ret,&(mont->N)); /* XXX */
205 }
206 retn=1;
207err1:
208 return(retn);
209 } 170 }
210#ifdef BN_RECURSION_MONT 171 bn_fix_top(r);
211 else /* bignum version */ 172
173 /* mont->ri will be a multiple of the word size */
174#if 0
175 BN_rshift(ret,r,mont->ri);
176#else
177 x=ri;
178 rp=ret->d;
179 ap= &(r->d[x]);
180 if (r->top < x)
181 al=0;
182 else
183 al=r->top-x;
184 ret->top=al;
185 al-=4;
186 for (i=0; i<al; i+=4)
212 { 187 {
213 BIGNUM *t1,*t2,*t3; 188 BN_ULONG t1,t2,t3,t4;
214 int j,i; 189
215 190 t1=ap[i+0];
216#ifdef BN_COUNT 191 t2=ap[i+1];
217printf("number BN_from_montgomery\n"); 192 t3=ap[i+2];
218#endif 193 t4=ap[i+3];
219 194 rp[i+0]=t1;
220 t1= &(ctx->bn[ctx->tos]); 195 rp[i+1]=t2;
221 t2= &(ctx->bn[ctx->tos+1]); 196 rp[i+2]=t3;
222 t3= &(ctx->bn[ctx->tos+2]); 197 rp[i+3]=t4;
223
224 i=mont->Ni.top;
225 bn_wexpand(ret,i); /* perhaps only i*2 */
226 bn_wexpand(t1,i*4); /* perhaps only i*2 */
227 bn_wexpand(t2,i*2); /* perhaps only i */
228
229 bn_mul_low_recursive(t2->d,a->d,mont->Ni.d,i,t1->d);
230
231 BN_zero(t3);
232 BN_set_bit(t3,mont->N.top*BN_BITS2);
233 bn_sub_words(t3->d,t3->d,a->d,i);
234 bn_mul_high(ret->d,t2->d,mont->N.d,t3->d,i,t1->d);
235
236 /* hmm... if a is between i and 2*i, things are bad */
237 if (a->top > i)
238 {
239 j=(int)(bn_add_words(ret->d,ret->d,&(a->d[i]),i));
240 if (j) /* overflow */
241 bn_sub_words(ret->d,ret->d,mont->N.d,i);
242 }
243 ret->top=i;
244 bn_fix_top(ret);
245 if (a->d[0])
246 BN_add_word(ret,1); /* Always? */
247 else /* Very very rare */
248 {
249 for (i=1; i<mont->N.top-1; i++)
250 {
251 if (a->d[i])
252 {
253 BN_add_word(ret,1); /* Always? */
254 break;
255 }
256 }
257 }
258
259 if (BN_ucmp(ret,&(mont->N)) >= 0)
260 BN_usub(ret,ret,&(mont->N));
261
262 return(1);
263 } 198 }
199 al+=4;
200 for (; i<al; i++)
201 rp[i]=ap[i];
264#endif 202#endif
203#else /* !MONT_WORD */
204 BIGNUM *t1,*t2;
205
206 BN_CTX_start(ctx);
207 t1 = BN_CTX_get(ctx);
208 t2 = BN_CTX_get(ctx);
209 if (t1 == NULL || t2 == NULL) goto err;
210
211 if (!BN_copy(t1,a)) goto err;
212 BN_mask_bits(t1,mont->ri);
213
214 if (!BN_mul(t2,t1,&mont->Ni,ctx)) goto err;
215 BN_mask_bits(t2,mont->ri);
216
217 if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
218 if (!BN_add(t2,a,t1)) goto err;
219 BN_rshift(ret,t2,mont->ri);
220#endif /* MONT_WORD */
221
222 if (BN_ucmp(ret, &(mont->N)) >= 0)
223 {
224 BN_usub(ret,ret,&(mont->N));
225 }
226 retn=1;
227 err:
228 BN_CTX_end(ctx);
229 return(retn);
265 } 230 }
266 231
267BN_MONT_CTX *BN_MONT_CTX_new(void) 232BN_MONT_CTX *BN_MONT_CTX_new(void)
@@ -278,7 +243,6 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
278 243
279void BN_MONT_CTX_init(BN_MONT_CTX *ctx) 244void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
280 { 245 {
281 ctx->use_word=0;
282 ctx->ri=0; 246 ctx->ri=0;
283 BN_init(&(ctx->RR)); 247 BN_init(&(ctx->RR));
284 BN_init(&(ctx->N)); 248 BN_init(&(ctx->N));
@@ -306,85 +270,53 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
306 R= &(mont->RR); /* grab RR as a temp */ 270 R= &(mont->RR); /* grab RR as a temp */
307 BN_copy(&(mont->N),mod); /* Set N */ 271 BN_copy(&(mont->N),mod); /* Set N */
308 272
309#ifdef BN_RECURSION_MONT 273#ifdef MONT_WORD
310 if (mont->N.top < BN_MONT_CTX_SET_SIZE_WORD)
311#endif
312 { 274 {
313 BIGNUM tmod; 275 BIGNUM tmod;
314 BN_ULONG buf[2]; 276 BN_ULONG buf[2];
315 277
316 mont->use_word=1;
317
318 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2; 278 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
319 BN_zero(R); 279 BN_zero(R);
320 BN_set_bit(R,BN_BITS2); 280 BN_set_bit(R,BN_BITS2); /* R */
321 /* I was bad, this modification of a passed variable was
322 * breaking the multithreaded stuff :-(
323 * z=mod->top;
324 * mod->top=1; */
325 281
326 buf[0]=mod->d[0]; 282 buf[0]=mod->d[0]; /* tmod = N mod word size */
327 buf[1]=0; 283 buf[1]=0;
328 tmod.d=buf; 284 tmod.d=buf;
329 tmod.top=1; 285 tmod.top=1;
330 tmod.max=mod->max; 286 tmod.max=2;
331 tmod.neg=mod->neg; 287 tmod.neg=mod->neg;
332 288 /* Ri = R^-1 mod N*/
333 if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL) 289 if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)
334 goto err; 290 goto err;
335 BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */ 291 BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */
336 if (!BN_is_zero(&Ri)) 292 if (!BN_is_zero(&Ri))
337 {
338#if 1
339 BN_sub_word(&Ri,1); 293 BN_sub_word(&Ri,1);
340#else 294 else /* if N mod word size == 1 */
341 BN_usub(&Ri,&Ri,BN_value_one()); /* R*Ri - 1 */ 295 BN_set_word(&Ri,BN_MASK2); /* Ri-- (mod word size) */
342#endif 296 BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N,
343 } 297 * keep only least significant word: */
344 else
345 {
346 /* This is not common..., 1 in BN_MASK2,
347 * It happens when buf[0] was == 1. So for 8 bit,
348 * this is 1/256, 16bit, 1 in 2^16 etc.
349 */
350 BN_set_word(&Ri,BN_MASK2);
351 }
352 BN_div(&Ri,NULL,&Ri,&tmod,ctx);
353 mont->n0=Ri.d[0]; 298 mont->n0=Ri.d[0];
354 BN_free(&Ri); 299 BN_free(&Ri);
355 /* mod->top=z; */
356 } 300 }
357#ifdef BN_RECURSION_MONT 301#else /* !MONT_WORD */
358 else 302 { /* bignum version */
359 { 303 mont->ri=BN_num_bits(mod);
360 mont->use_word=0;
361 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
362#if 1
363 BN_zero(R); 304 BN_zero(R);
364 BN_set_bit(R,mont->ri); 305 BN_set_bit(R,mont->ri); /* R = 2^ri */
365#else 306 /* Ri = R^-1 mod N*/
366 BN_lshift(R,BN_value_one(),mont->ri); /* R */
367#endif
368 if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL) 307 if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL)
369 goto err; 308 goto err;
370 BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */ 309 BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */
371#if 1
372 BN_sub_word(&Ri,1); 310 BN_sub_word(&Ri,1);
373#else 311 /* Ni = (R*Ri-1) / N */
374 BN_usub(&Ri,&Ri,BN_value_one()); /* R*Ri - 1 */
375#endif
376 BN_div(&(mont->Ni),NULL,&Ri,mod,ctx); 312 BN_div(&(mont->Ni),NULL,&Ri,mod,ctx);
377 BN_free(&Ri); 313 BN_free(&Ri);
378 } 314 }
379#endif 315#endif
380 316
381 /* setup RR for conversions */ 317 /* setup RR for conversions */
382#if 1
383 BN_zero(&(mont->RR)); 318 BN_zero(&(mont->RR));
384 BN_set_bit(&(mont->RR),mont->ri*2); 319 BN_set_bit(&(mont->RR),mont->ri*2);
385#else
386 BN_lshift(mont->RR,BN_value_one(),mont->ri*2);
387#endif
388 BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx); 320 BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx);
389 321
390 return(1); 322 return(1);
@@ -399,7 +331,6 @@ BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
399 BN_copy(&(to->RR),&(from->RR)); 331 BN_copy(&(to->RR),&(from->RR));
400 BN_copy(&(to->N),&(from->N)); 332 BN_copy(&(to->N),&(from->N));
401 BN_copy(&(to->Ni),&(from->Ni)); 333 BN_copy(&(to->Ni),&(from->Ni));
402 to->use_word=from->use_word;
403 to->ri=from->ri; 334 to->ri=from->ri;
404 to->n0=from->n0; 335 to->n0=from->n0;
405 return(to); 336 return(to);
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index 38c47f3d1f..eb007e19e9 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -66,7 +66,7 @@
66 * n2 must be a power of 2. 66 * n2 must be a power of 2.
67 * We multiply and return the result. 67 * We multiply and return the result.
68 * t must be 2*n2 words in size 68 * t must be 2*n2 words in size
69 * We calulate 69 * We calculate
70 * a[0]*b[0] 70 * a[0]*b[0]
71 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) 71 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
72 * a[1]*b[1] 72 * a[1]*b[1]
@@ -78,21 +78,23 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
78 unsigned int neg,zero; 78 unsigned int neg,zero;
79 BN_ULONG ln,lo,*p; 79 BN_ULONG ln,lo,*p;
80 80
81#ifdef BN_COUNT 81# ifdef BN_COUNT
82printf(" bn_mul_recursive %d * %d\n",n2,n2); 82 printf(" bn_mul_recursive %d * %d\n",n2,n2);
83#endif 83# endif
84#ifdef BN_MUL_COMBA 84# ifdef BN_MUL_COMBA
85/* if (n2 == 4) 85# if 0
86 if (n2 == 4)
86 { 87 {
87 bn_mul_comba4(r,a,b); 88 bn_mul_comba4(r,a,b);
88 return; 89 return;
89 } 90 }
90 else */ if (n2 == 8) 91# endif
92 if (n2 == 8)
91 { 93 {
92 bn_mul_comba8(r,a,b); 94 bn_mul_comba8(r,a,b);
93 return; 95 return;
94 } 96 }
95#endif 97# endif /* BN_MUL_COMBA */
96 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) 98 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
97 { 99 {
98 /* This should not happen */ 100 /* This should not happen */
@@ -136,7 +138,7 @@ printf(" bn_mul_recursive %d * %d\n",n2,n2);
136 break; 138 break;
137 } 139 }
138 140
139#ifdef BN_MUL_COMBA 141# ifdef BN_MUL_COMBA
140 if (n == 4) 142 if (n == 4)
141 { 143 {
142 if (!zero) 144 if (!zero)
@@ -158,7 +160,7 @@ printf(" bn_mul_recursive %d * %d\n",n2,n2);
158 bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n])); 160 bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n]));
159 } 161 }
160 else 162 else
161#endif 163# endif /* BN_MUL_COMBA */
162 { 164 {
163 p= &(t[n2*2]); 165 p= &(t[n2*2]);
164 if (!zero) 166 if (!zero)
@@ -219,12 +221,12 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
219 int n, BN_ULONG *t) 221 int n, BN_ULONG *t)
220 { 222 {
221 int i,j,n2=n*2; 223 int i,j,n2=n*2;
222 unsigned int c1; 224 unsigned int c1,c2,neg,zero;
223 BN_ULONG ln,lo,*p; 225 BN_ULONG ln,lo,*p;
224 226
225#ifdef BN_COUNT 227# ifdef BN_COUNT
226printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); 228 printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
227#endif 229# endif
228 if (n < 8) 230 if (n < 8)
229 { 231 {
230 i=tn+n; 232 i=tn+n;
@@ -233,17 +235,54 @@ printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
233 } 235 }
234 236
235 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 237 /* r=(a[0]-a[1])*(b[1]-b[0]) */
236 bn_sub_words(t, a, &(a[n]),n); /* + */ 238 c1=bn_cmp_words(a,&(a[n]),n);
237 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 239 c2=bn_cmp_words(&(b[n]),b,n);
238 240 zero=neg=0;
239/* if (n == 4) 241 switch (c1*3+c2)
242 {
243 case -4:
244 bn_sub_words(t, &(a[n]),a, n); /* - */
245 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
246 break;
247 case -3:
248 zero=1;
249 /* break; */
250 case -2:
251 bn_sub_words(t, &(a[n]),a, n); /* - */
252 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */
253 neg=1;
254 break;
255 case -1:
256 case 0:
257 case 1:
258 zero=1;
259 /* break; */
260 case 2:
261 bn_sub_words(t, a, &(a[n]),n); /* + */
262 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
263 neg=1;
264 break;
265 case 3:
266 zero=1;
267 /* break; */
268 case 4:
269 bn_sub_words(t, a, &(a[n]),n);
270 bn_sub_words(&(t[n]),&(b[n]),b, n);
271 break;
272 }
273 /* The zero case isn't yet implemented here. The speedup
274 would probably be negligible. */
275# if 0
276 if (n == 4)
240 { 277 {
241 bn_mul_comba4(&(t[n2]),t,&(t[n])); 278 bn_mul_comba4(&(t[n2]),t,&(t[n]));
242 bn_mul_comba4(r,a,b); 279 bn_mul_comba4(r,a,b);
243 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); 280 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
244 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2)); 281 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2));
245 } 282 }
246 else */ if (n == 8) 283 else
284# endif
285 if (n == 8)
247 { 286 {
248 bn_mul_comba8(&(t[n2]),t,&(t[n])); 287 bn_mul_comba8(&(t[n2]),t,&(t[n]));
249 bn_mul_comba8(r,a,b); 288 bn_mul_comba8(r,a,b);
@@ -308,7 +347,16 @@ printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
308 */ 347 */
309 348
310 c1=(int)(bn_add_words(t,r,&(r[n2]),n2)); 349 c1=(int)(bn_add_words(t,r,&(r[n2]),n2));
311 c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2)); 350
351 if (neg) /* if t[32] is negative */
352 {
353 c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2));
354 }
355 else
356 {
357 /* Might have a carry */
358 c1+=(int)(bn_add_words(&(t[n2]),&(t[n2]),t,n2));
359 }
312 360
313 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1]) 361 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
314 * r[10] holds (a[0]*b[0]) 362 * r[10] holds (a[0]*b[0])
@@ -345,9 +393,9 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
345 { 393 {
346 int n=n2/2; 394 int n=n2/2;
347 395
348#ifdef BN_COUNT 396# ifdef BN_COUNT
349printf(" bn_mul_low_recursive %d * %d\n",n2,n2); 397 printf(" bn_mul_low_recursive %d * %d\n",n2,n2);
350#endif 398# endif
351 399
352 bn_mul_recursive(r,a,b,n,&(t[0])); 400 bn_mul_recursive(r,a,b,n,&(t[0]));
353 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) 401 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
@@ -379,9 +427,9 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
379 int neg,oneg,zero; 427 int neg,oneg,zero;
380 BN_ULONG ll,lc,*lp,*mp; 428 BN_ULONG ll,lc,*lp,*mp;
381 429
382#ifdef BN_COUNT 430# ifdef BN_COUNT
383printf(" bn_mul_high %d * %d\n",n2,n2); 431 printf(" bn_mul_high %d * %d\n",n2,n2);
384#endif 432# endif
385 n=n2/2; 433 n=n2/2;
386 434
387 /* Calculate (al-ah)*(bh-bl) */ 435 /* Calculate (al-ah)*(bh-bl) */
@@ -424,14 +472,14 @@ printf(" bn_mul_high %d * %d\n",n2,n2);
424 oneg=neg; 472 oneg=neg;
425 /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */ 473 /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */
426 /* r[10] = (a[1]*b[1]) */ 474 /* r[10] = (a[1]*b[1]) */
427#ifdef BN_MUL_COMBA 475# ifdef BN_MUL_COMBA
428 if (n == 8) 476 if (n == 8)
429 { 477 {
430 bn_mul_comba8(&(t[0]),&(r[0]),&(r[n])); 478 bn_mul_comba8(&(t[0]),&(r[0]),&(r[n]));
431 bn_mul_comba8(r,&(a[n]),&(b[n])); 479 bn_mul_comba8(r,&(a[n]),&(b[n]));
432 } 480 }
433 else 481 else
434#endif 482# endif
435 { 483 {
436 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2])); 484 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2]));
437 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2])); 485 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2]));
@@ -555,19 +603,23 @@ printf(" bn_mul_high %d * %d\n",n2,n2);
555 } 603 }
556 } 604 }
557 } 605 }
558#endif 606#endif /* BN_RECURSION */
559 607
560int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) 608int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
561 { 609 {
562 int top,al,bl; 610 int top,al,bl;
563 BIGNUM *rr; 611 BIGNUM *rr;
612 int ret = 0;
613#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
614 int i;
615#endif
564#ifdef BN_RECURSION 616#ifdef BN_RECURSION
565 BIGNUM *t; 617 BIGNUM *t;
566 int i,j,k; 618 int j,k;
567#endif 619#endif
568 620
569#ifdef BN_COUNT 621#ifdef BN_COUNT
570printf("BN_mul %d * %d\n",a->top,b->top); 622 printf("BN_mul %d * %d\n",a->top,b->top);
571#endif 623#endif
572 624
573 bn_check_top(a); 625 bn_check_top(a);
@@ -585,115 +637,99 @@ printf("BN_mul %d * %d\n",a->top,b->top);
585 } 637 }
586 top=al+bl; 638 top=al+bl;
587 639
640 BN_CTX_start(ctx);
588 if ((r == a) || (r == b)) 641 if ((r == a) || (r == b))
589 rr= &(ctx->bn[ctx->tos+1]); 642 {
643 if ((rr = BN_CTX_get(ctx)) == NULL) goto err;
644 }
590 else 645 else
591 rr=r; 646 rr = r;
592 647
593#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 648#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
594 if (al == bl) 649 i = al-bl;
650#endif
651#ifdef BN_MUL_COMBA
652 if (i == 0)
595 { 653 {
596# ifdef BN_MUL_COMBA 654# if 0
597/* if (al == 4) 655 if (al == 4)
598 { 656 {
599 if (bn_wexpand(rr,8) == NULL) return(0); 657 if (bn_wexpand(rr,8) == NULL) goto err;
600 rr->top=8; 658 rr->top=8;
601 bn_mul_comba4(rr->d,a->d,b->d); 659 bn_mul_comba4(rr->d,a->d,b->d);
602 goto end; 660 goto end;
603 } 661 }
604 else */ if (al == 8) 662# endif
663 if (al == 8)
605 { 664 {
606 if (bn_wexpand(rr,16) == NULL) return(0); 665 if (bn_wexpand(rr,16) == NULL) goto err;
607 rr->top=16; 666 rr->top=16;
608 bn_mul_comba8(rr->d,a->d,b->d); 667 bn_mul_comba8(rr->d,a->d,b->d);
609 goto end; 668 goto end;
610 } 669 }
611 else
612# endif
613#ifdef BN_RECURSION
614 if (al < BN_MULL_SIZE_NORMAL)
615#endif
616 {
617 if (bn_wexpand(rr,top) == NULL) return(0);
618 rr->top=top;
619 bn_mul_normal(rr->d,a->d,al,b->d,bl);
620 goto end;
621 }
622# ifdef BN_RECURSION
623 goto symetric;
624# endif
625 } 670 }
626#endif 671#endif /* BN_MUL_COMBA */
627#ifdef BN_RECURSION 672#ifdef BN_RECURSION
628 else if ((al < BN_MULL_SIZE_NORMAL) || (bl < BN_MULL_SIZE_NORMAL)) 673 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))
629 { 674 {
630 if (bn_wexpand(rr,top) == NULL) return(0); 675 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
631 rr->top=top;
632 bn_mul_normal(rr->d,a->d,al,b->d,bl);
633 goto end;
634 }
635 else
636 {
637 i=(al-bl);
638 if ((i == 1) && !BN_get_flags(b,BN_FLG_STATIC_DATA))
639 { 676 {
640 bn_wexpand(b,al); 677 bn_wexpand(b,al);
641 b->d[bl]=0; 678 b->d[bl]=0;
642 bl++; 679 bl++;
643 goto symetric; 680 i--;
644 } 681 }
645 else if ((i == -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA)) 682 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))
646 { 683 {
647 bn_wexpand(a,bl); 684 bn_wexpand(a,bl);
648 a->d[al]=0; 685 a->d[al]=0;
649 al++; 686 al++;
650 goto symetric; 687 i++;
688 }
689 if (i == 0)
690 {
691 /* symmetric and > 4 */
692 /* 16 or larger */
693 j=BN_num_bits_word((BN_ULONG)al);
694 j=1<<(j-1);
695 k=j+j;
696 t = BN_CTX_get(ctx);
697 if (al == j) /* exact multiple */
698 {
699 bn_wexpand(t,k*2);
700 bn_wexpand(rr,k*2);
701 bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
702 }
703 else
704 {
705 bn_wexpand(a,k);
706 bn_wexpand(b,k);
707 bn_wexpand(t,k*4);
708 bn_wexpand(rr,k*4);
709 for (i=a->top; i<k; i++)
710 a->d[i]=0;
711 for (i=b->top; i<k; i++)
712 b->d[i]=0;
713 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
714 }
715 rr->top=top;
716 goto end;
651 } 717 }
652 } 718 }
653#endif 719#endif /* BN_RECURSION */
654 720 if (bn_wexpand(rr,top) == NULL) goto err;
655 /* asymetric and >= 4 */
656 if (bn_wexpand(rr,top) == NULL) return(0);
657 rr->top=top; 721 rr->top=top;
658 bn_mul_normal(rr->d,a->d,al,b->d,bl); 722 bn_mul_normal(rr->d,a->d,al,b->d,bl);
659 723
660#ifdef BN_RECURSION
661 if (0)
662 {
663symetric:
664 /* symetric and > 4 */
665 /* 16 or larger */
666 j=BN_num_bits_word((BN_ULONG)al);
667 j=1<<(j-1);
668 k=j+j;
669 t= &(ctx->bn[ctx->tos]);
670 if (al == j) /* exact multiple */
671 {
672 bn_wexpand(t,k*2);
673 bn_wexpand(rr,k*2);
674 bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
675 }
676 else
677 {
678 bn_wexpand(a,k);
679 bn_wexpand(b,k);
680 bn_wexpand(t,k*4);
681 bn_wexpand(rr,k*4);
682 for (i=a->top; i<k; i++)
683 a->d[i]=0;
684 for (i=b->top; i<k; i++)
685 b->d[i]=0;
686 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
687 }
688 rr->top=top;
689 }
690#endif
691#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 724#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
692end: 725end:
693#endif 726#endif
694 bn_fix_top(rr); 727 bn_fix_top(rr);
695 if (r != rr) BN_copy(r,rr); 728 if (r != rr) BN_copy(r,rr);
696 return(1); 729 ret=1;
730err:
731 BN_CTX_end(ctx);
732 return(ret);
697 } 733 }
698 734
699void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) 735void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
@@ -701,7 +737,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
701 BN_ULONG *rr; 737 BN_ULONG *rr;
702 738
703#ifdef BN_COUNT 739#ifdef BN_COUNT
704printf(" bn_mul_normal %d * %d\n",na,nb); 740 printf(" bn_mul_normal %d * %d\n",na,nb);
705#endif 741#endif
706 742
707 if (na < nb) 743 if (na < nb)
@@ -735,7 +771,7 @@ printf(" bn_mul_normal %d * %d\n",na,nb);
735void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 771void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
736 { 772 {
737#ifdef BN_COUNT 773#ifdef BN_COUNT
738printf(" bn_mul_low_normal %d * %d\n",n,n); 774 printf(" bn_mul_low_normal %d * %d\n",n,n);
739#endif 775#endif
740 bn_mul_words(r,a,n,b[0]); 776 bn_mul_words(r,a,n,b[0]);
741 777
@@ -753,4 +789,3 @@ printf(" bn_mul_low_normal %d * %d\n",n,n);
753 b+=4; 789 b+=4;
754 } 790 }
755 } 791 }
756
diff --git a/src/lib/libcrypto/bn/bn_opts.c b/src/lib/libcrypto/bn/bn_opts.c
index 381be529b2..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/bn_opts.c
+++ b/src/lib/libcrypto/bn/bn_opts.c
@@ -1,324 +0,0 @@
1/* crypto/bn/expspeed.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/* most of this code has been pilfered from my libdes speed.c program */
60
61#include <stdio.h>
62#include <stdlib.h>
63#include <signal.h>
64#include <string.h>
65#include <openssl/crypto.h>
66#include <openssl/tmdiff.h>
67#include <openssl/bn.h>
68#include <openssl/err.h>
69
70#define DEFAULT_SIZE 512
71#define DEFAULT_TIME 3
72
73int verbose=1;
74
75typedef struct parms_st
76 {
77 char *name;
78 void (*func)();
79 BIGNUM r;
80 BIGNUM a;
81 BIGNUM b;
82 BIGNUM c;
83 BIGNUM low;
84 BN_CTX *ctx;
85 BN_MONT_CTX *mont;
86 int w;
87 } PARMS;
88
89void do_mul_exp(int num,PARMS *p);
90void do_mul(int num,PARMS *p);
91void do_sqr(int num,PARMS *p);
92void do_mul_low(int num,PARMS *p);
93void do_mul_high(int num,PARMS *p);
94void do_from_montgomery(int num,PARMS *p);
95int time_it(int sec, PARMS *p);
96void do_it(int sec, PARMS *p);
97
98#define P_EXP 1
99#define P_MUL 2
100#define P_SQR 3
101#define P_MULL 4
102#define P_MULH 5
103#define P_MRED 6
104
105int main(int argc, char **argv)
106 {
107 PARMS p;
108 BN_MONT_CTX *mont;
109 int size=0,num;
110 char *name;
111 int type=P_EXP;
112
113 mont=BN_MONT_CTX_new();
114 p.mont=NULL;
115 p.ctx=BN_CTX_new();
116 BN_init(&p.r);
117 BN_init(&p.a);
118 BN_init(&p.b);
119 BN_init(&p.c);
120 BN_init(&p.low);
121 p.w=0;
122
123 for (;;)
124 {
125 if (argc > 1)
126 {
127 if (argv[1][0] == '-')
128 {
129 switch(argv[1][1])
130 {
131 case 'e': type=P_EXP; break;
132 case 'm': type=P_MUL; break;
133 case 's': type=P_SQR; break;
134 case 'l': type=P_MULL; break;
135 case 'h': type=P_MULH; break;
136 case 'r': type=P_MRED; break;
137 default:
138 fprintf(stderr,"options: -[emslhr]\n");
139 exit(1);
140 }
141 }
142 else
143 {
144 size=atoi(argv[1]);
145 }
146 argc--;
147 argv++;
148 }
149 else
150 break;
151 }
152 if (size == 0)
153 size=DEFAULT_SIZE;
154
155 printf("bit size:%5d\n",size);
156
157 BN_rand(&p.a,size,1,0);
158 BN_rand(&p.b,size,1,0);
159 BN_rand(&p.c,size,1,1);
160 BN_mod(&p.a,&p.a,&p.c,p.ctx);
161 BN_mod(&p.b,&p.b,&p.c,p.ctx);
162 p.w=(p.a.top+1)/2;
163
164 BN_mul(&p.low,&p.a,&p.b,p.ctx);
165 p.low.top=p.a.top;
166
167 switch(type)
168 {
169 case P_EXP:
170 p.name="r=a^b%c";
171 p.func=do_mul_exp;
172 p.mont=mont;
173 break;
174 case P_MUL:
175 p.name="r=a*b";
176 p.func=do_mul;
177 break;
178 case P_SQR:
179 p.name="r=a*a";
180 p.func=do_sqr;
181 break;
182 case P_MULL:
183 p.name="r=low(a*b)";
184 p.func=do_mul_low;
185 break;
186 case P_MULH:
187 p.name="r=high(a*b)";
188 p.func=do_mul_high;
189 break;
190 case P_MRED:
191 p.name="r=montgomery_reduction(a)";
192 p.func=do_from_montgomery;
193 p.mont=mont;
194 break;
195 default:
196 fprintf(stderr,"options: -[emslhr]\n");
197 exit(1);
198 }
199
200 num=time_it(DEFAULT_TIME,&p);
201 do_it(num,&p);
202 }
203
204void do_it(int num, PARMS *p)
205 {
206 char *start,*end;
207 int i,j,number;
208 double d;
209
210 start=ms_time_new();
211 end=ms_time_new();
212
213 number=BN_num_bits_word((BN_ULONG)BN_num_bits(&(p->c)))-
214 BN_num_bits_word(BN_BITS2)+2;
215 for (i=number-1; i >=0; i--)
216 {
217 if (i == 1) continue;
218 BN_set_params(i,i,i,1);
219 if (p->mont != NULL)
220 BN_MONT_CTX_set(p->mont,&(p->c),p->ctx);
221
222 printf("Timing %5d (%2d bit) %2d %2d %2d %2d :",
223 (1<<i)*BN_BITS2,i,
224 BN_get_params(0),
225 BN_get_params(1),
226 BN_get_params(2),
227 BN_get_params(3));
228 fflush(stdout);
229
230 ms_time_get(start);
231 p->func(num,p);
232 ms_time_get(end);
233 d=ms_time_diff(start,end);
234 printf("%6.6f sec, or %d in %.4f seconds\n",
235 (double)d/num,num,d);
236 }
237 }
238
239int time_it(int sec, PARMS *p)
240 {
241 char *start,*end;
242 int i,j;
243 double d;
244
245 if (p->mont != NULL)
246 BN_MONT_CTX_set(p->mont,&(p->c),p->ctx);
247
248 start=ms_time_new();
249 end=ms_time_new();
250
251 i=1;
252 for (;;)
253 {
254 if (verbose)
255 printf("timing %s for %d interations\n",p->name,i);
256
257 ms_time_get(start);
258 p->func(i,p);
259 ms_time_get(end);
260 d=ms_time_diff(start,end);
261
262 if (d < 0.01) i*=100;
263 else if (d < 0.1 ) i*=10;
264 else if (d > (double)sec) break;
265 else
266 {
267 i=(int)(1.0*i*sec/d);
268 break;
269 }
270 }
271 if (verbose)
272 printf("using %d interations\n",i);
273 return(i);
274 }
275
276void do_mul_exp(int num, PARMS *p)
277 {
278 int i;
279
280 for (i=0; i<num; i++)
281 BN_mod_exp_mont(&(p->r),&(p->a),&(p->b),&(p->c),
282 p->ctx,p->mont);
283 }
284
285void do_mul(int num, PARMS *p)
286 {
287 int i;
288
289 for (i=0; i<num; i++)
290 BN_mul(&(p->r),&(p->a),&(p->b),p->ctx);
291 }
292
293void do_sqr(int num, PARMS *p)
294 {
295 int i;
296
297 for (i=0; i<num; i++)
298 BN_sqr(&(p->r),&(p->a),p->ctx);
299 }
300
301void do_mul_low(int num, PARMS *p)
302 {
303 int i;
304
305 for (i=0; i<num; i++)
306 BN_mul_low(&(p->r),&(p->a),&(p->b),p->w,p->ctx);
307 }
308
309void do_mul_high(int num, PARMS *p)
310 {
311 int i;
312
313 for (i=0; i<num; i++)
314 BN_mul_low(&(p->r),&(p->a),&(p->b),&(p->low),p->w,p->ctx);
315 }
316
317void do_from_montgomery(int num, PARMS *p)
318 {
319 int i;
320
321 for (i=0; i<num; i++)
322 BN_from_montgomery(&(p->r),&(p->a),p->mont,p->ctx);
323 }
324
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index 6fa0f9be1e..a5f01b92eb 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.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-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 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <time.h> 113#include <time.h>
@@ -62,26 +115,29 @@
62#include "bn_lcl.h" 115#include "bn_lcl.h"
63#include <openssl/rand.h> 116#include <openssl/rand.h>
64 117
65/* The quick seive algorithm approach to weeding out primes is 118/* The quick sieve algorithm approach to weeding out primes is
66 * Philip Zimmermann's, as implemented in PGP. I have had a read of 119 * Philip Zimmermann's, as implemented in PGP. I have had a read of
67 * his comments and implemented my own version. 120 * his comments and implemented my own version.
68 */ 121 */
69#include "bn_prime.h" 122#include "bn_prime.h"
70 123
71static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx,BN_CTX *ctx2, 124static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
72 BN_MONT_CTX *mont); 125 const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont);
73static int probable_prime(BIGNUM *rnd, int bits); 126static int probable_prime(BIGNUM *rnd, int bits);
74static int probable_prime_dh(BIGNUM *rnd, int bits, 127static int probable_prime_dh(BIGNUM *rnd, int bits,
75 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); 128 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx);
76static int probable_prime_dh_strong(BIGNUM *rnd, int bits, 129static int probable_prime_dh_safe(BIGNUM *rnd, int bits,
77 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); 130 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx);
78BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int strong, BIGNUM *add, 131
132BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, BIGNUM *add,
79 BIGNUM *rem, void (*callback)(int,int,void *), void *cb_arg) 133 BIGNUM *rem, void (*callback)(int,int,void *), void *cb_arg)
80 { 134 {
81 BIGNUM *rnd=NULL; 135 BIGNUM *rnd=NULL;
82 BIGNUM t; 136 BIGNUM t;
137 int found=0;
83 int i,j,c1=0; 138 int i,j,c1=0;
84 BN_CTX *ctx; 139 BN_CTX *ctx;
140 int checks = BN_prime_checks_for_size(bits);
85 141
86 ctx=BN_CTX_new(); 142 ctx=BN_CTX_new();
87 if (ctx == NULL) goto err; 143 if (ctx == NULL) goto err;
@@ -100,9 +156,9 @@ loop:
100 } 156 }
101 else 157 else
102 { 158 {
103 if (strong) 159 if (safe)
104 { 160 {
105 if (!probable_prime_dh_strong(rnd,bits,add,rem,ctx)) 161 if (!probable_prime_dh_safe(rnd,bits,add,rem,ctx))
106 goto err; 162 goto err;
107 } 163 }
108 else 164 else
@@ -114,160 +170,185 @@ loop:
114 /* if (BN_mod_word(rnd,(BN_ULONG)3) == 1) goto loop; */ 170 /* if (BN_mod_word(rnd,(BN_ULONG)3) == 1) goto loop; */
115 if (callback != NULL) callback(0,c1++,cb_arg); 171 if (callback != NULL) callback(0,c1++,cb_arg);
116 172
117 if (!strong) 173 if (!safe)
118 { 174 {
119 i=BN_is_prime(rnd,BN_prime_checks,callback,ctx,cb_arg); 175 i=BN_is_prime_fasttest(rnd,checks,callback,ctx,cb_arg,0);
120 if (i == -1) goto err; 176 if (i == -1) goto err;
121 if (i == 0) goto loop; 177 if (i == 0) goto loop;
122 } 178 }
123 else 179 else
124 { 180 {
125 /* for a strong prime generation, 181 /* for "safe prime" generation,
126 * check that (p-1)/2 is prime. 182 * check that (p-1)/2 is prime.
127 * Since a prime is odd, We just 183 * Since a prime is odd, We just
128 * need to divide by 2 */ 184 * need to divide by 2 */
129 if (!BN_rshift1(&t,rnd)) goto err; 185 if (!BN_rshift1(&t,rnd)) goto err;
130 186
131 for (i=0; i<BN_prime_checks; i++) 187 for (i=0; i<checks; i++)
132 { 188 {
133 j=BN_is_prime(rnd,1,callback,ctx,cb_arg); 189 j=BN_is_prime_fasttest(rnd,1,callback,ctx,cb_arg,0);
134 if (j == -1) goto err; 190 if (j == -1) goto err;
135 if (j == 0) goto loop; 191 if (j == 0) goto loop;
136 192
137 j=BN_is_prime(&t,1,callback,ctx,cb_arg); 193 j=BN_is_prime_fasttest(&t,1,callback,ctx,cb_arg,0);
138 if (j == -1) goto err; 194 if (j == -1) goto err;
139 if (j == 0) goto loop; 195 if (j == 0) goto loop;
140 196
141 if (callback != NULL) callback(2,c1-1,cb_arg); 197 if (callback != NULL) callback(2,c1-1,cb_arg);
142 /* We have a strong prime test pass */ 198 /* We have a safe prime test pass */
143 } 199 }
144 } 200 }
145 /* we have a prime :-) */ 201 /* we have a prime :-) */
146 ret=rnd; 202 found = 1;
147err: 203err:
148 if ((ret == NULL) && (rnd != NULL)) BN_free(rnd); 204 if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd);
149 BN_free(&t); 205 BN_free(&t);
150 if (ctx != NULL) BN_CTX_free(ctx); 206 if (ctx != NULL) BN_CTX_free(ctx);
151 return(ret); 207 return(found ? rnd : NULL);
152 } 208 }
153 209
154int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *), 210int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
155 BN_CTX *ctx_passed, void *cb_arg) 211 BN_CTX *ctx_passed, void *cb_arg)
156 { 212 {
157 int i,j,c2=0,ret= -1; 213 return BN_is_prime_fasttest(a, checks, callback, ctx_passed, cb_arg, 0);
158 BIGNUM *check; 214 }
159 BN_CTX *ctx=NULL,*ctx2=NULL;
160 BN_MONT_CTX *mont=NULL;
161 215
216int BN_is_prime_fasttest(const BIGNUM *a, int checks,
217 void (*callback)(int,int,void *),
218 BN_CTX *ctx_passed, void *cb_arg,
219 int do_trial_division)
220 {
221 int i, j, ret = -1;
222 int k;
223 BN_CTX *ctx = NULL;
224 BIGNUM *A1, *A1_odd, *check; /* taken from ctx */
225 BN_MONT_CTX *mont = NULL;
226 const BIGNUM *A = NULL;
227
228 if (checks == BN_prime_checks)
229 checks = BN_prime_checks_for_size(BN_num_bits(a));
230
231 /* first look for small factors */
162 if (!BN_is_odd(a)) 232 if (!BN_is_odd(a))
163 return(0); 233 return(0);
234 if (do_trial_division)
235 {
236 for (i = 1; i < NUMPRIMES; i++)
237 if (BN_mod_word(a, primes[i]) == 0)
238 return 0;
239 if (callback != NULL) callback(1, -1, cb_arg);
240 }
241
164 if (ctx_passed != NULL) 242 if (ctx_passed != NULL)
165 ctx=ctx_passed; 243 ctx = ctx_passed;
166 else 244 else
167 if ((ctx=BN_CTX_new()) == NULL) goto err; 245 if ((ctx=BN_CTX_new()) == NULL)
168 246 goto err;
169 if ((ctx2=BN_CTX_new()) == NULL) goto err; 247 BN_CTX_start(ctx);
170 if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
171
172 check= &(ctx->bn[ctx->tos++]);
173 248
174 /* Setup the montgomery structure */ 249 /* A := abs(a) */
175 if (!BN_MONT_CTX_set(mont,a,ctx2)) goto err; 250 if (a->neg)
251 {
252 BIGNUM *t;
253 if ((t = BN_CTX_get(ctx)) == NULL) goto err;
254 BN_copy(t, a);
255 t->neg = 0;
256 A = t;
257 }
258 else
259 A = a;
260 A1 = BN_CTX_get(ctx);
261 A1_odd = BN_CTX_get(ctx);
262 check = BN_CTX_get(ctx);
263 if (check == NULL) goto err;
264
265 /* compute A1 := A - 1 */
266 if (!BN_copy(A1, A))
267 goto err;
268 if (!BN_sub_word(A1, 1))
269 goto err;
270 if (BN_is_zero(A1))
271 {
272 ret = 0;
273 goto err;
274 }
176 275
177 for (i=0; i<checks; i++) 276 /* write A1 as A1_odd * 2^k */
277 k = 1;
278 while (!BN_is_bit_set(A1, k))
279 k++;
280 if (!BN_rshift(A1_odd, A1, k))
281 goto err;
282
283 /* Montgomery setup for computations mod A */
284 mont = BN_MONT_CTX_new();
285 if (mont == NULL)
286 goto err;
287 if (!BN_MONT_CTX_set(mont, A, ctx))
288 goto err;
289
290 for (i = 0; i < checks; i++)
178 { 291 {
179 if (!BN_rand(check,BN_num_bits(a)-1,0,0)) goto err; 292 if (!BN_pseudo_rand(check, BN_num_bits(A1), 0, 0))
180 j=witness(check,a,ctx,ctx2,mont); 293 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 goto err;
299 /* now 1 <= check < A */
300
301 j = witness(check, A, A1, A1_odd, k, ctx, mont);
181 if (j == -1) goto err; 302 if (j == -1) goto err;
182 if (j) 303 if (j)
183 { 304 {
184 ret=0; 305 ret=0;
185 goto err; 306 goto err;
186 } 307 }
187 if (callback != NULL) callback(1,c2++,cb_arg); 308 if (callback != NULL) callback(1,i,cb_arg);
188 } 309 }
189 ret=1; 310 ret=1;
190err: 311err:
191 ctx->tos--; 312 if (ctx != NULL)
192 if ((ctx_passed == NULL) && (ctx != NULL)) 313 {
193 BN_CTX_free(ctx); 314 BN_CTX_end(ctx);
194 if (ctx2 != NULL) 315 if (ctx_passed == NULL)
195 BN_CTX_free(ctx2); 316 BN_CTX_free(ctx);
196 if (mont != NULL) BN_MONT_CTX_free(mont); 317 }
197 318 if (mont != NULL)
319 BN_MONT_CTX_free(mont);
320
198 return(ret); 321 return(ret);
199 } 322 }
200 323
201#define RECP_MUL_MOD 324static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
202 325 const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont)
203static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *ctx2,
204 BN_MONT_CTX *mont)
205 { 326 {
206 int k,i,ret= -1,good; 327 if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */
207 BIGNUM *d,*dd,*tmp,*d1,*d2,*n1; 328 return -1;
208 BIGNUM *mont_one,*mont_n1,*mont_a; 329 if (BN_is_one(w))
209 330 return 0; /* probably prime */
210 d1= &(ctx->bn[ctx->tos]); 331 if (BN_cmp(w, a1) == 0)
211 d2= &(ctx->bn[ctx->tos+1]); 332 return 0; /* w == -1 (mod a), 'a' is probably prime */
212 n1= &(ctx->bn[ctx->tos+2]); 333 while (--k)
213 ctx->tos+=3;
214
215 mont_one= &(ctx2->bn[ctx2->tos]);
216 mont_n1= &(ctx2->bn[ctx2->tos+1]);
217 mont_a= &(ctx2->bn[ctx2->tos+2]);
218 ctx2->tos+=3;
219
220 d=d1;
221 dd=d2;
222 if (!BN_one(d)) goto err;
223 if (!BN_sub(n1,n,d)) goto err; /* n1=n-1; */
224 k=BN_num_bits(n1);
225
226 if (!BN_to_montgomery(mont_one,BN_value_one(),mont,ctx2)) goto err;
227 if (!BN_to_montgomery(mont_n1,n1,mont,ctx2)) goto err;
228 if (!BN_to_montgomery(mont_a,a,mont,ctx2)) goto err;
229
230 BN_copy(d,mont_one);
231 for (i=k-1; i>=0; i--)
232 { 334 {
233 if ( (BN_cmp(d,mont_one) != 0) && 335 if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */
234 (BN_cmp(d,mont_n1) != 0)) 336 return -1;
235 good=1; 337 if (BN_is_one(w))
236 else 338 return 1; /* 'a' is composite, otherwise a previous 'w' would
237 good=0; 339 * have been == -1 (mod 'a') */
238 340 if (BN_cmp(w, a1) == 0)
239 BN_mod_mul_montgomery(dd,d,d,mont,ctx2); 341 return 0; /* w == -1 (mod a), 'a' is probably prime */
240
241 if (good && (BN_cmp(dd,mont_one) == 0))
242 {
243 ret=1;
244 goto err;
245 }
246 if (BN_is_bit_set(n1,i))
247 {
248 BN_mod_mul_montgomery(d,dd,mont_a,mont,ctx2);
249 }
250 else
251 {
252 tmp=d;
253 d=dd;
254 dd=tmp;
255 }
256 } 342 }
257 if (BN_cmp(d,mont_one) == 0) 343 /* If we get here, 'w' is the (a-1)/2-th power of the original 'w',
258 i=0; 344 * and it is neither -1 nor +1 -- so 'a' cannot be prime */
259 else i=1; 345 return 1;
260 ret=i;
261err:
262 ctx->tos-=3;
263 ctx2->tos-=3;
264 return(ret);
265 } 346 }
266 347
267static int probable_prime(BIGNUM *rnd, int bits) 348static int probable_prime(BIGNUM *rnd, int bits)
268 { 349 {
269 int i; 350 int i;
270 MS_STATIC BN_ULONG mods[NUMPRIMES]; 351 BN_ULONG mods[NUMPRIMES];
271 BN_ULONG delta,d; 352 BN_ULONG delta,d;
272 353
273again: 354again:
@@ -285,7 +366,7 @@ again:
285 d=delta; 366 d=delta;
286 delta+=2; 367 delta+=2;
287 /* perhaps need to check for overflow of 368 /* perhaps need to check for overflow of
288 * delta (but delta can be upto 2^32) 369 * delta (but delta can be up to 2^32)
289 * 21-May-98 eay - added overflow check */ 370 * 21-May-98 eay - added overflow check */
290 if (delta < d) goto again; 371 if (delta < d) goto again;
291 goto loop; 372 goto loop;
@@ -301,7 +382,8 @@ static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem,
301 int i,ret=0; 382 int i,ret=0;
302 BIGNUM *t1; 383 BIGNUM *t1;
303 384
304 t1= &(ctx->bn[ctx->tos++]); 385 BN_CTX_start(ctx);
386 if ((t1 = BN_CTX_get(ctx)) == NULL) goto err;
305 387
306 if (!BN_rand(rnd,bits,0,1)) goto err; 388 if (!BN_rand(rnd,bits,0,1)) goto err;
307 389
@@ -327,20 +409,22 @@ static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem,
327 } 409 }
328 ret=1; 410 ret=1;
329err: 411err:
330 ctx->tos--; 412 BN_CTX_end(ctx);
331 return(ret); 413 return(ret);
332 } 414 }
333 415
334static int probable_prime_dh_strong(BIGNUM *p, int bits, BIGNUM *padd, 416static int probable_prime_dh_safe(BIGNUM *p, int bits, BIGNUM *padd,
335 BIGNUM *rem, BN_CTX *ctx) 417 BIGNUM *rem, BN_CTX *ctx)
336 { 418 {
337 int i,ret=0; 419 int i,ret=0;
338 BIGNUM *t1,*qadd=NULL,*q=NULL; 420 BIGNUM *t1,*qadd,*q;
339 421
340 bits--; 422 bits--;
341 t1= &(ctx->bn[ctx->tos++]); 423 BN_CTX_start(ctx);
342 q= &(ctx->bn[ctx->tos++]); 424 t1 = BN_CTX_get(ctx);
343 qadd= &(ctx->bn[ctx->tos++]); 425 q = BN_CTX_get(ctx);
426 qadd = BN_CTX_get(ctx);
427 if (qadd == NULL) goto err;
344 428
345 if (!BN_rshift1(qadd,padd)) goto err; 429 if (!BN_rshift1(qadd,padd)) goto err;
346 430
@@ -376,72 +460,6 @@ static int probable_prime_dh_strong(BIGNUM *p, int bits, BIGNUM *padd,
376 } 460 }
377 ret=1; 461 ret=1;
378err: 462err:
379 ctx->tos-=3; 463 BN_CTX_end(ctx);
380 return(ret);
381 }
382
383#if 0
384static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx)
385 {
386 int k,i,nb,ret= -1;
387 BIGNUM *d,*dd,*tmp;
388 BIGNUM *d1,*d2,*x,*n1,*inv;
389
390 d1= &(ctx->bn[ctx->tos]);
391 d2= &(ctx->bn[ctx->tos+1]);
392 x= &(ctx->bn[ctx->tos+2]);
393 n1= &(ctx->bn[ctx->tos+3]);
394 inv=&(ctx->bn[ctx->tos+4]);
395 ctx->tos+=5;
396
397 d=d1;
398 dd=d2;
399 if (!BN_one(d)) goto err;
400 if (!BN_sub(n1,n,d)) goto err; /* n1=n-1; */
401 k=BN_num_bits(n1);
402
403 /* i=BN_num_bits(n); */
404#ifdef RECP_MUL_MOD
405 nb=BN_reciprocal(inv,n,ctx); /**/
406 if (nb == -1) goto err;
407#endif
408
409 for (i=k-1; i>=0; i--)
410 {
411 if (BN_copy(x,d) == NULL) goto err;
412#ifndef RECP_MUL_MOD
413 if (!BN_mod_mul(dd,d,d,n,ctx)) goto err;
414#else
415 if (!BN_mod_mul_reciprocal(dd,d,d,n,inv,nb,ctx)) goto err;
416#endif
417 if ( BN_is_one(dd) &&
418 !BN_is_one(x) &&
419 (BN_cmp(x,n1) != 0))
420 {
421 ret=1;
422 goto err;
423 }
424 if (BN_is_bit_set(n1,i))
425 {
426#ifndef RECP_MUL_MOD
427 if (!BN_mod_mul(d,dd,a,n,ctx)) goto err;
428#else
429 if (!BN_mod_mul_reciprocal(d,dd,a,n,inv,nb,ctx)) goto err;
430#endif
431 }
432 else
433 {
434 tmp=d;
435 d=dd;
436 dd=tmp;
437 }
438 }
439 if (BN_is_one(d))
440 i=0;
441 else i=1;
442 ret=i;
443err:
444 ctx->tos-=5;
445 return(ret); 464 return(ret);
446 } 465 }
447#endif
diff --git a/src/lib/libcrypto/bn/bn_prime.h b/src/lib/libcrypto/bn/bn_prime.h
index 6fce0210cd..b7cf9a9bfe 100644
--- a/src/lib/libcrypto/bn/bn_prime.h
+++ b/src/lib/libcrypto/bn/bn_prime.h
@@ -1,4 +1,4 @@
1/* crypto/bn/bn_prime.h */ 1/* Auto generated by bn_prime.pl */
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 *
@@ -61,7 +61,7 @@
61#else 61#else
62#define NUMPRIMES 54 62#define NUMPRIMES 54
63#endif 63#endif
64static unsigned int primes[NUMPRIMES]= 64static const unsigned int primes[NUMPRIMES]=
65 { 65 {
66 2, 3, 5, 7, 11, 13, 17, 19, 66 2, 3, 5, 7, 11, 13, 17, 19,
67 23, 29, 31, 37, 41, 43, 47, 53, 67 23, 29, 31, 37, 41, 43, 47, 53,
diff --git a/src/lib/libcrypto/bn/bn_prime.pl b/src/lib/libcrypto/bn/bn_prime.pl
index 979385a334..9fc3765486 100644
--- a/src/lib/libcrypto/bn/bn_prime.pl
+++ b/src/lib/libcrypto/bn/bn_prime.pl
@@ -18,13 +18,74 @@ loop: while ($#primes < $num-1)
18 push(@primes,$p); 18 push(@primes,$p);
19 } 19 }
20 20
21print <<"EOF"; 21# print <<"EOF";
22# /* Auto generated by bn_prime.pl */
23# /* Copyright (C) 1995-1997 Eric Young (eay\@mincom.oz.au).
24# * All rights reserved.
25# * Copyright remains Eric Young's, and as such any Copyright notices in
26# * the code are not to be removed.
27# * See the COPYRIGHT file in the SSLeay distribution for more details.
28# */
29#
30# EOF
31
32print <<\EOF;
22/* Auto generated by bn_prime.pl */ 33/* Auto generated by bn_prime.pl */
23/* Copyright (C) 1995-1997 Eric Young (eay\@mincom.oz.au). 34/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
24 * All rights reserved. 35 * All rights reserved.
36 *
37 * This package is an SSL implementation written
38 * by Eric Young (eay@cryptsoft.com).
39 * The implementation was written so as to conform with Netscapes SSL.
40 *
41 * This library is free for commercial and non-commercial use as long as
42 * the following conditions are aheared to. The following conditions
43 * apply to all code found in this distribution, be it the RC4, RSA,
44 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
45 * included with this distribution is covered by the same copyright terms
46 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
47 *
25 * Copyright remains Eric Young's, and as such any Copyright notices in 48 * Copyright remains Eric Young's, and as such any Copyright notices in
26 * the code are not to be removed. 49 * the code are not to be removed.
27 * See the COPYRIGHT file in the SSLeay distribution for more details. 50 * If this package is used in a product, Eric Young should be given attribution
51 * as the author of the parts of the library used.
52 * This can be in the form of a textual message at program startup or
53 * in documentation (online or textual) provided with the package.
54 *
55 * Redistribution and use in source and binary forms, with or without
56 * modification, are permitted provided that the following conditions
57 * are met:
58 * 1. Redistributions of source code must retain the copyright
59 * notice, this list of conditions and the following disclaimer.
60 * 2. Redistributions in binary form must reproduce the above copyright
61 * notice, this list of conditions and the following disclaimer in the
62 * documentation and/or other materials provided with the distribution.
63 * 3. All advertising materials mentioning features or use of this software
64 * must display the following acknowledgement:
65 * "This product includes cryptographic software written by
66 * Eric Young (eay@cryptsoft.com)"
67 * The word 'cryptographic' can be left out if the rouines from the library
68 * being used are not cryptographic related :-).
69 * 4. If you include any Windows specific code (or a derivative thereof) from
70 * the apps directory (application code) you must include an acknowledgement:
71 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
72 *
73 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
74 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
77 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
78 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
79 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
80 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
81 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
82 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
83 * SUCH DAMAGE.
84 *
85 * The licence and distribution terms for any publically available version or
86 * derivative of this code cannot be changed. i.e. this code cannot simply be
87 * copied and put under another distribution licence
88 * [including the GNU Public Licence.]
28 */ 89 */
29 90
30EOF 91EOF
@@ -43,7 +104,7 @@ printf "#define NUMPRIMES %d\n",$num;
43printf "#else\n"; 104printf "#else\n";
44printf "#define NUMPRIMES %d\n",$eight; 105printf "#define NUMPRIMES %d\n",$eight;
45printf "#endif\n"; 106printf "#endif\n";
46print "static unsigned int primes[NUMPRIMES]=\n\t{\n\t"; 107print "static const unsigned int primes[NUMPRIMES]=\n\t{\n\t";
47$init=0; 108$init=0;
48for ($i=0; $i <= $#primes; $i++) 109for ($i=0; $i <= $#primes; $i++)
49 { 110 {
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 2f5ab2617b..782a96e7e0 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -137,7 +137,7 @@ char *BN_bn2dec(const BIGNUM *a)
137 } 137 }
138 lp--; 138 lp--;
139 /* We now have a series of blocks, BN_DEC_NUM chars 139 /* We now have a series of blocks, BN_DEC_NUM chars
140 * in length, where the last one needs trucation. 140 * in length, where the last one needs truncation.
141 * The blocks need to be reversed in order. */ 141 * The blocks need to be reversed in order. */
142 sprintf(p,BN_DEC_FMT1,*lp); 142 sprintf(p,BN_DEC_FMT1,*lp);
143 while (*p) p++; 143 while (*p) p++;
@@ -171,7 +171,7 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
171 num=i+neg; 171 num=i+neg;
172 if (bn == NULL) return(num); 172 if (bn == NULL) return(num);
173 173
174 /* a is the start of the hex digets, and it is 'i' long */ 174 /* a is the start of the hex digits, and it is 'i' long */
175 if (*bn == NULL) 175 if (*bn == NULL)
176 { 176 {
177 if ((ret=BN_new()) == NULL) return(0); 177 if ((ret=BN_new()) == NULL) return(0);
@@ -185,7 +185,7 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
185 /* i is the number of hex digests; */ 185 /* i is the number of hex digests; */
186 if (bn_expand(ret,i*4) == NULL) goto err; 186 if (bn_expand(ret,i*4) == NULL) goto err;
187 187
188 j=i; /* least significate 'hex' */ 188 j=i; /* least significant 'hex' */
189 m=0; 189 m=0;
190 h=0; 190 h=0;
191 while (j > 0) 191 while (j > 0)
@@ -236,8 +236,8 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
236 num=i+neg; 236 num=i+neg;
237 if (bn == NULL) return(num); 237 if (bn == NULL) return(num);
238 238
239 /* a is the start of the digets, and it is 'i' long. 239 /* a is the start of the digits, and it is 'i' long.
240 * We chop it into BN_DEC_NUM digets at a time */ 240 * We chop it into BN_DEC_NUM digits at a time */
241 if (*bn == NULL) 241 if (*bn == NULL)
242 { 242 {
243 if ((ret=BN_new()) == NULL) return(0); 243 if ((ret=BN_new()) == NULL) return(0);
@@ -278,9 +278,8 @@ err:
278 } 278 }
279 279
280#ifndef NO_BIO 280#ifndef NO_BIO
281
282#ifndef NO_FP_API 281#ifndef NO_FP_API
283int BN_print_fp(FILE *fp, BIGNUM *a) 282int BN_print_fp(FILE *fp, const BIGNUM *a)
284 { 283 {
285 BIO *b; 284 BIO *b;
286 int ret; 285 int ret;
@@ -319,5 +318,15 @@ int BN_print(BIO *bp, const BIGNUM *a)
319end: 318end:
320 return(ret); 319 return(ret);
321 } 320 }
321#endif
322 322
323#ifdef BN_DEBUG
324void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n)
325 {
326 int i;
327 fprintf(o, "%s=", a);
328 for (i=n-1;i>=0;i--)
329 fprintf(o, "%08lX", b[i]); /* assumes 32-bit BN_ULONG */
330 fprintf(o, "\n");
331 }
323#endif 332#endif
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index 91b8e34ae6..943712c15b 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -62,7 +62,7 @@
62#include "bn_lcl.h" 62#include "bn_lcl.h"
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) 65static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
66 { 66 {
67 unsigned char *buf=NULL; 67 unsigned char *buf=NULL;
68 int ret=0,bit,bytes,mask; 68 int ret=0,bit,bytes,mask;
@@ -81,9 +81,19 @@ int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
81 81
82 /* make a random number and set the top and bottom bits */ 82 /* make a random number and set the top and bottom bits */
83 time(&tim); 83 time(&tim);
84 RAND_seed(&tim,sizeof(tim)); 84 RAND_add(&tim,sizeof(tim),0);
85
86 if (pseudorand)
87 {
88 if (RAND_pseudo_bytes(buf, bytes) == -1)
89 goto err;
90 }
91 else
92 {
93 if (RAND_bytes(buf, bytes) <= 0)
94 goto err;
95 }
85 96
86 RAND_bytes(buf,(int)bytes);
87 if (top) 97 if (top)
88 { 98 {
89 if (bit == 0) 99 if (bit == 0)
@@ -115,3 +125,12 @@ err:
115 return(ret); 125 return(ret);
116 } 126 }
117 127
128int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
129 {
130 return bnrand(0, rnd, bits, top, bottom);
131 }
132
133int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
134 {
135 return bnrand(1, rnd, bits, top, bottom);
136 }
diff --git a/src/lib/libcrypto/bn/bn_recp.c b/src/lib/libcrypto/bn/bn_recp.c
index c1b0e230ea..a8796bd0aa 100644
--- a/src/lib/libcrypto/bn/bn_recp.c
+++ b/src/lib/libcrypto/bn/bn_recp.c
@@ -106,7 +106,8 @@ int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
106 int ret=0; 106 int ret=0;
107 BIGNUM *a; 107 BIGNUM *a;
108 108
109 a= &(ctx->bn[ctx->tos++]); 109 BN_CTX_start(ctx);
110 if ((a = BN_CTX_get(ctx)) == NULL) goto err;
110 if (y != NULL) 111 if (y != NULL)
111 { 112 {
112 if (x == y) 113 if (x == y)
@@ -120,33 +121,34 @@ int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
120 BN_div_recp(NULL,r,a,recp,ctx); 121 BN_div_recp(NULL,r,a,recp,ctx);
121 ret=1; 122 ret=1;
122err: 123err:
123 ctx->tos--; 124 BN_CTX_end(ctx);
124 return(ret); 125 return(ret);
125 } 126 }
126 127
127int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp, 128int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
128 BN_CTX *ctx) 129 BN_CTX *ctx)
129 { 130 {
130 int i,j,tos,ret=0,ex; 131 int i,j,ret=0;
131 BIGNUM *a,*b,*d,*r; 132 BIGNUM *a,*b,*d,*r;
132 133
133 tos=ctx->tos; 134 BN_CTX_start(ctx);
134 a= &(ctx->bn[ctx->tos++]); 135 a=BN_CTX_get(ctx);
135 b= &(ctx->bn[ctx->tos++]); 136 b=BN_CTX_get(ctx);
136 if (dv != NULL) 137 if (dv != NULL)
137 d=dv; 138 d=dv;
138 else 139 else
139 d= &(ctx->bn[ctx->tos++]); 140 d=BN_CTX_get(ctx);
140 if (rem != NULL) 141 if (rem != NULL)
141 r=rem; 142 r=rem;
142 else 143 else
143 r= &(ctx->bn[ctx->tos++]); 144 r=BN_CTX_get(ctx);
145 if (a == NULL || b == NULL || d == NULL || r == NULL) goto err;
144 146
145 if (BN_ucmp(m,&(recp->N)) < 0) 147 if (BN_ucmp(m,&(recp->N)) < 0)
146 { 148 {
147 BN_zero(d); 149 BN_zero(d);
148 BN_copy(r,m); 150 BN_copy(r,m);
149 ctx->tos=tos; 151 BN_CTX_end(ctx);
150 return(1); 152 return(1);
151 } 153 }
152 154
@@ -157,33 +159,24 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
157 */ 159 */
158 i=BN_num_bits(m); 160 i=BN_num_bits(m);
159 161
160 j=recp->num_bits*2; 162 j=recp->num_bits<<1;
161 if (j > i) 163 if (j>i) i=j;
162 { 164 j>>=1;
163 i=j;
164 ex=0;
165 }
166 else
167 {
168 ex=(i-j)/2;
169 }
170
171 j=i/2;
172 165
173 if (i != recp->shift) 166 if (i != recp->shift)
174 recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N), 167 recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N),
175 i,ctx); 168 i,ctx);
176 169
177 if (!BN_rshift(a,m,j-ex)) goto err; 170 if (!BN_rshift(a,m,j)) goto err;
178 if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err; 171 if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err;
179 if (!BN_rshift(d,b,j+ex)) goto err; 172 if (!BN_rshift(d,b,i-j)) goto err;
180 d->neg=0; 173 d->neg=0;
181 if (!BN_mul(b,&(recp->N),d,ctx)) goto err; 174 if (!BN_mul(b,&(recp->N),d,ctx)) goto err;
182 if (!BN_usub(r,m,b)) goto err; 175 if (!BN_usub(r,m,b)) goto err;
183 r->neg=0; 176 r->neg=0;
184 177
185 j=0;
186#if 1 178#if 1
179 j=0;
187 while (BN_ucmp(r,&(recp->N)) >= 0) 180 while (BN_ucmp(r,&(recp->N)) >= 0)
188 { 181 {
189 if (j++ > 2) 182 if (j++ > 2)
@@ -200,7 +193,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
200 d->neg=m->neg^recp->N.neg; 193 d->neg=m->neg^recp->N.neg;
201 ret=1; 194 ret=1;
202err: 195err:
203 ctx->tos=tos; 196 BN_CTX_end(ctx);
204 return(ret); 197 return(ret);
205 } 198 }
206 199
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index 12cce4d7ce..fe00c5f69a 100644
--- a/src/lib/libcrypto/bn/bn_sqr.c
+++ b/src/lib/libcrypto/bn/bn_sqr.c
@@ -65,14 +65,13 @@
65int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx) 65int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)
66 { 66 {
67 int max,al; 67 int max,al;
68 int ret = 0;
68 BIGNUM *tmp,*rr; 69 BIGNUM *tmp,*rr;
69 70
70#ifdef BN_COUNT 71#ifdef BN_COUNT
71printf("BN_sqr %d * %d\n",a->top,a->top); 72printf("BN_sqr %d * %d\n",a->top,a->top);
72#endif 73#endif
73 bn_check_top(a); 74 bn_check_top(a);
74 tmp= &(ctx->bn[ctx->tos]);
75 rr=(a != r)?r: (&ctx->bn[ctx->tos+1]);
76 75
77 al=a->top; 76 al=a->top;
78 if (al <= 0) 77 if (al <= 0)
@@ -81,8 +80,13 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
81 return(1); 80 return(1);
82 } 81 }
83 82
83 BN_CTX_start(ctx);
84 rr=(a != r) ? r : BN_CTX_get(ctx);
85 tmp=BN_CTX_get(ctx);
86 if (tmp == NULL) goto err;
87
84 max=(al+al); 88 max=(al+al);
85 if (bn_wexpand(rr,max+1) == NULL) return(0); 89 if (bn_wexpand(rr,max+1) == NULL) goto err;
86 90
87 r->neg=0; 91 r->neg=0;
88 if (al == 4) 92 if (al == 4)
@@ -120,18 +124,18 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
120 k=j+j; 124 k=j+j;
121 if (al == j) 125 if (al == j)
122 { 126 {
123 if (bn_wexpand(a,k*2) == NULL) return(0); 127 if (bn_wexpand(a,k*2) == NULL) goto err;
124 if (bn_wexpand(tmp,k*2) == NULL) return(0); 128 if (bn_wexpand(tmp,k*2) == NULL) goto err;
125 bn_sqr_recursive(rr->d,a->d,al,tmp->d); 129 bn_sqr_recursive(rr->d,a->d,al,tmp->d);
126 } 130 }
127 else 131 else
128 { 132 {
129 if (bn_wexpand(tmp,max) == NULL) return(0); 133 if (bn_wexpand(tmp,max) == NULL) goto err;
130 bn_sqr_normal(rr->d,a->d,al,tmp->d); 134 bn_sqr_normal(rr->d,a->d,al,tmp->d);
131 } 135 }
132 } 136 }
133#else 137#else
134 if (bn_wexpand(tmp,max) == NULL) return(0); 138 if (bn_wexpand(tmp,max) == NULL) goto err;
135 bn_sqr_normal(rr->d,a->d,al,tmp->d); 139 bn_sqr_normal(rr->d,a->d,al,tmp->d);
136#endif 140#endif
137 } 141 }
@@ -139,7 +143,10 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
139 rr->top=max; 143 rr->top=max;
140 if ((max > 0) && (rr->d[max-1] == 0)) rr->top--; 144 if ((max > 0) && (rr->d[max-1] == 0)) rr->top--;
141 if (rr != r) BN_copy(r,rr); 145 if (rr != r) BN_copy(r,rr);
142 return(1); 146 ret = 1;
147 err:
148 BN_CTX_end(ctx);
149 return(ret);
143 } 150 }
144 151
145/* tmp must have 2*n words */ 152/* tmp must have 2*n words */
@@ -185,7 +192,7 @@ void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)
185 * n must be a power of 2. 192 * n must be a power of 2.
186 * We multiply and return the result. 193 * We multiply and return the result.
187 * t must be 2*n words in size 194 * t must be 2*n words in size
188 * We calulate 195 * We calculate
189 * a[0]*b[0] 196 * a[0]*b[0]
190 * 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])
191 * a[1]*b[1] 198 * a[1]*b[1]
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c
index c0cfbc6797..73157a7d43 100644
--- a/src/lib/libcrypto/bn/bn_word.c
+++ b/src/lib/libcrypto/bn/bn_word.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
63BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w) 63BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
64 { 64 {
65#ifndef BN_LLONG 65#ifndef BN_LLONG
66 BN_ULONG ret=0; 66 BN_ULONG ret=0;
diff --git a/src/lib/libcrypto/bn/bnspeed.c b/src/lib/libcrypto/bn/bnspeed.c
index 0922aa3e16..20fc7e08ff 100644
--- a/src/lib/libcrypto/bn/bnspeed.c
+++ b/src/lib/libcrypto/bn/bnspeed.c
@@ -1,3 +1,5 @@
1/* unused */
2
1/* crypto/bn/bnspeed.c */ 3/* crypto/bn/bnspeed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 4/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 5 * All rights reserved.
diff --git a/src/lib/libcrypto/bn/bntest.c b/src/lib/libcrypto/bn/bntest.c
index df4b81f5b2..41c22f5954 100644
--- a/src/lib/libcrypto/bn/bntest.c
+++ b/src/lib/libcrypto/bn/bntest.c
@@ -72,6 +72,10 @@
72#include "../bio/bss_file.c" 72#include "../bio/bss_file.c"
73#endif 73#endif
74 74
75const int num0 = 100; /* number of tests */
76const int num1 = 50; /* additional tests for some functions */
77const int num2 = 5; /* number of tests for slow functions */
78
75int test_add(BIO *bp); 79int test_add(BIO *bp);
76int test_sub(BIO *bp); 80int test_sub(BIO *bp);
77int test_lshift1(BIO *bp); 81int test_lshift1(BIO *bp);
@@ -95,15 +99,33 @@ static int results=0;
95#include "bss_file.c" 99#include "bss_file.c"
96#endif 100#endif
97 101
98static unsigned char lst1[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9" 102static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9"
99"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0"; 103"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0";
100 104
105static const char rnd_seed[] = "string to make the random number generator think it has entropy";
106
107static void message(BIO *out, char *m)
108 {
109 fprintf(stderr, "test %s\n", m);
110#if defined(linux) || defined(__FreeBSD__) /* can we use GNU bc features? */
111 BIO_puts(out, "print \"test ");
112 BIO_puts(out, m);
113 BIO_puts(out, "\\n\"\n");
114#endif
115 }
116
101int main(int argc, char *argv[]) 117int main(int argc, char *argv[])
102 { 118 {
103 BN_CTX *ctx; 119 BN_CTX *ctx;
104 BIO *out; 120 BIO *out;
105 char *outfile=NULL; 121 char *outfile=NULL;
106 122
123 results = 0;
124
125 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
126 * even check its return value
127 * (which we should) */
128
107 argc--; 129 argc--;
108 argv++; 130 argv++;
109 while (argc >= 1) 131 while (argc >= 1)
@@ -141,78 +163,81 @@ int main(int argc, char *argv[])
141 if (!results) 163 if (!results)
142 BIO_puts(out,"obase=16\nibase=16\n"); 164 BIO_puts(out,"obase=16\nibase=16\n");
143 165
144 fprintf(stderr,"test BN_add\n"); 166 message(out,"BN_add");
145 if (!test_add(out)) goto err; 167 if (!test_add(out)) goto err;
146 fflush(stdout); 168 BIO_flush(out);
147 169
148 fprintf(stderr,"test BN_sub\n"); 170 message(out,"BN_sub");
149 if (!test_sub(out)) goto err; 171 if (!test_sub(out)) goto err;
150 fflush(stdout); 172 BIO_flush(out);
151 173
152 fprintf(stderr,"test BN_lshift1\n"); 174 message(out,"BN_lshift1");
153 if (!test_lshift1(out)) goto err; 175 if (!test_lshift1(out)) goto err;
154 fflush(stdout); 176 BIO_flush(out);
155 177
156 fprintf(stderr,"test BN_lshift (fixed)\n"); 178 message(out,"BN_lshift (fixed)");
157 if (!test_lshift(out,ctx,BN_bin2bn(lst1,sizeof(lst1)-1,NULL))) 179 if (!test_lshift(out,ctx,BN_bin2bn(lst,sizeof(lst)-1,NULL)))
158 goto err; 180 goto err;
159 fflush(stdout); 181 BIO_flush(out);
160 182
161 fprintf(stderr,"test BN_lshift\n"); 183 message(out,"BN_lshift");
162 if (!test_lshift(out,ctx,NULL)) goto err; 184 if (!test_lshift(out,ctx,NULL)) goto err;
163 fflush(stdout); 185 BIO_flush(out);
164 186
165 fprintf(stderr,"test BN_rshift1\n"); 187 message(out,"BN_rshift1");
166 if (!test_rshift1(out)) goto err; 188 if (!test_rshift1(out)) goto err;
167 fflush(stdout); 189 BIO_flush(out);
168 190
169 fprintf(stderr,"test BN_rshift\n"); 191 message(out,"BN_rshift");
170 if (!test_rshift(out,ctx)) goto err; 192 if (!test_rshift(out,ctx)) goto err;
171 fflush(stdout); 193 BIO_flush(out);
172 194
173 fprintf(stderr,"test BN_sqr\n"); 195 message(out,"BN_sqr");
174 if (!test_sqr(out,ctx)) goto err; 196 if (!test_sqr(out,ctx)) goto err;
175 fflush(stdout); 197 BIO_flush(out);
176 198
177 fprintf(stderr,"test BN_mul\n"); 199 message(out,"BN_mul");
178 if (!test_mul(out)) goto err; 200 if (!test_mul(out)) goto err;
179 fflush(stdout); 201 BIO_flush(out);
180 202
181 fprintf(stderr,"test BN_div\n"); 203 message(out,"BN_div");
182 if (!test_div(out,ctx)) goto err; 204 if (!test_div(out,ctx)) goto err;
183 fflush(stdout); 205 BIO_flush(out);
184 206
185 fprintf(stderr,"test BN_div_recp\n"); 207 message(out,"BN_div_recp");
186 if (!test_div_recp(out,ctx)) goto err; 208 if (!test_div_recp(out,ctx)) goto err;
187 fflush(stdout); 209 BIO_flush(out);
188 210
189 fprintf(stderr,"test BN_mod\n"); 211 message(out,"BN_mod");
190 if (!test_mod(out,ctx)) goto err; 212 if (!test_mod(out,ctx)) goto err;
191 fflush(stdout); 213 BIO_flush(out);
192 214
193 fprintf(stderr,"test BN_mod_mul\n"); 215 message(out,"BN_mod_mul");
194 if (!test_mod_mul(out,ctx)) goto err; 216 if (!test_mod_mul(out,ctx)) goto err;
195 fflush(stdout); 217 BIO_flush(out);
196 218
197/* 219 message(out,"BN_mont");
198 fprintf(stderr,"test BN_mont\n");
199 if (!test_mont(out,ctx)) goto err; 220 if (!test_mont(out,ctx)) goto err;
200 fflush(stdout); 221 BIO_flush(out);
201*/ 222
202 fprintf(stderr,"test BN_mod_exp\n"); 223 message(out,"BN_mod_exp");
203 if (!test_mod_exp(out,ctx)) goto err; 224 if (!test_mod_exp(out,ctx)) goto err;
204 fflush(stdout); 225 BIO_flush(out);
205 226
206 fprintf(stderr,"test BN_exp\n"); 227 message(out,"BN_exp");
207 if (!test_exp(out,ctx)) goto err; 228 if (!test_exp(out,ctx)) goto err;
208 fflush(stdout); 229 BIO_flush(out);
230
231 BN_CTX_free(ctx);
232 BIO_free(out);
209 233
210/**/ 234/**/
211 exit(0); 235 exit(0);
212err: 236err:
213 BIO_puts(out,"1\n"); /* make sure bc fails if we are piping to it */ 237 BIO_puts(out,"1\n"); /* make sure bc fails if we are piping to it */
238 BIO_flush(out);
214 ERR_load_crypto_strings(); 239 ERR_load_crypto_strings();
215 ERR_print_errors(out); 240 ERR_print_errors_fp(stderr);
216 exit(1); 241 exit(1);
217 return(1); 242 return(1);
218 } 243 }
@@ -228,7 +253,7 @@ int test_add(BIO *bp)
228 BN_init(&c); 253 BN_init(&c);
229 254
230 BN_rand(&a,512,0,0); 255 BN_rand(&a,512,0,0);
231 for (i=0; i<100; i++) 256 for (i=0; i<num0; i++)
232 { 257 {
233 BN_rand(&b,450+i,0,0); 258 BN_rand(&b,450+i,0,0);
234 a.neg=rand_neg(); 259 a.neg=rand_neg();
@@ -255,7 +280,7 @@ int test_add(BIO *bp)
255 BN_add(&c,&c,&a); 280 BN_add(&c,&c,&a);
256 if(!BN_is_zero(&c)) 281 if(!BN_is_zero(&c))
257 { 282 {
258 BIO_puts(bp,"Add test failed!\n"); 283 fprintf(stderr,"Add test failed!\n");
259 return 0; 284 return 0;
260 } 285 }
261 } 286 }
@@ -275,12 +300,21 @@ int test_sub(BIO *bp)
275 BN_init(&b); 300 BN_init(&b);
276 BN_init(&c); 301 BN_init(&c);
277 302
278 BN_rand(&a,512,0,0); 303 for (i=0; i<num0+num1; i++)
279 for (i=0; i<100; i++)
280 { 304 {
281 BN_rand(&b,400+i,0,0); 305 if (i < num1)
282 a.neg=rand_neg(); 306 {
283 b.neg=rand_neg(); 307 BN_rand(&a,512,0,0);
308 BN_copy(&b,&a);
309 if (BN_set_bit(&a,i)==0) return(0);
310 BN_add_word(&b,i);
311 }
312 else
313 {
314 BN_rand(&b,400+i-num1,0,0);
315 a.neg=rand_neg();
316 b.neg=rand_neg();
317 }
284 if (bp == NULL) 318 if (bp == NULL)
285 for (j=0; j<10000; j++) 319 for (j=0; j<10000; j++)
286 BN_sub(&c,&a,&b); 320 BN_sub(&c,&a,&b);
@@ -301,7 +335,7 @@ int test_sub(BIO *bp)
301 BN_sub(&c,&c,&a); 335 BN_sub(&c,&c,&a);
302 if(!BN_is_zero(&c)) 336 if(!BN_is_zero(&c))
303 { 337 {
304 BIO_puts(bp,"Subtract test failed!\n"); 338 fprintf(stderr,"Subtract test failed!\n");
305 return 0; 339 return 0;
306 } 340 }
307 } 341 }
@@ -323,10 +357,17 @@ int test_div(BIO *bp, BN_CTX *ctx)
323 BN_init(&d); 357 BN_init(&d);
324 BN_init(&e); 358 BN_init(&e);
325 359
326 BN_rand(&a,400,0,0); 360 for (i=0; i<num0+num1; i++)
327 for (i=0; i<100; i++)
328 { 361 {
329 BN_rand(&b,50+i,0,0); 362 if (i < num1)
363 {
364 BN_rand(&a,400,0,0);
365 BN_copy(&b,&a);
366 BN_lshift(&a,&a,i);
367 BN_add_word(&a,i);
368 }
369 else
370 BN_rand(&b,50+3*(i-num1),0,0);
330 a.neg=rand_neg(); 371 a.neg=rand_neg();
331 b.neg=rand_neg(); 372 b.neg=rand_neg();
332 if (bp == NULL) 373 if (bp == NULL)
@@ -360,7 +401,7 @@ int test_div(BIO *bp, BN_CTX *ctx)
360 BN_sub(&d,&d,&a); 401 BN_sub(&d,&d,&a);
361 if(!BN_is_zero(&d)) 402 if(!BN_is_zero(&d))
362 { 403 {
363 BIO_puts(bp,"Division test failed!\n"); 404 fprintf(stderr,"Division test failed!\n");
364 return 0; 405 return 0;
365 } 406 }
366 } 407 }
@@ -386,10 +427,17 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
386 BN_init(&d); 427 BN_init(&d);
387 BN_init(&e); 428 BN_init(&e);
388 429
389 BN_rand(&a,400,0,0); 430 for (i=0; i<num0+num1; i++)
390 for (i=0; i<100; i++)
391 { 431 {
392 BN_rand(&b,50+i,0,0); 432 if (i < num1)
433 {
434 BN_rand(&a,400,0,0);
435 BN_copy(&b,&a);
436 BN_lshift(&a,&a,i);
437 BN_add_word(&a,i);
438 }
439 else
440 BN_rand(&b,50+3*(i-num1),0,0);
393 a.neg=rand_neg(); 441 a.neg=rand_neg();
394 b.neg=rand_neg(); 442 b.neg=rand_neg();
395 BN_RECP_CTX_set(&recp,&b,ctx); 443 BN_RECP_CTX_set(&recp,&b,ctx);
@@ -424,7 +472,12 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
424 BN_sub(&d,&d,&a); 472 BN_sub(&d,&d,&a);
425 if(!BN_is_zero(&d)) 473 if(!BN_is_zero(&d))
426 { 474 {
427 BIO_puts(bp,"Reciprocal division test failed!\n"); 475 fprintf(stderr,"Reciprocal division test failed!\n");
476 fprintf(stderr,"a=");
477 BN_print_fp(stderr,&a);
478 fprintf(stderr,"\nb=");
479 BN_print_fp(stderr,&b);
480 fprintf(stderr,"\n");
428 return 0; 481 return 0;
429 } 482 }
430 } 483 }
@@ -451,11 +504,15 @@ int test_mul(BIO *bp)
451 BN_init(&d); 504 BN_init(&d);
452 BN_init(&e); 505 BN_init(&e);
453 506
454 BN_rand(&a,200,0,0); 507 for (i=0; i<num0+num1; i++)
455 for (i=0; i<100; i++)
456 { 508 {
457 BN_rand(&b,250+i,0,0); 509 if (i <= num1)
458 BN_rand(&b,200,0,0); 510 {
511 BN_rand(&a,100,0,0);
512 BN_rand(&b,100,0,0);
513 }
514 else
515 BN_rand(&b,i-num1,0,0);
459 a.neg=rand_neg(); 516 a.neg=rand_neg();
460 b.neg=rand_neg(); 517 b.neg=rand_neg();
461 if (bp == NULL) 518 if (bp == NULL)
@@ -478,7 +535,7 @@ int test_mul(BIO *bp)
478 BN_sub(&d,&d,&b); 535 BN_sub(&d,&d,&b);
479 if(!BN_is_zero(&d) || !BN_is_zero(&e)) 536 if(!BN_is_zero(&d) || !BN_is_zero(&e))
480 { 537 {
481 BIO_puts(bp,"Multiplication test failed!\n"); 538 fprintf(stderr,"Multiplication test failed!\n");
482 return 0; 539 return 0;
483 } 540 }
484 } 541 }
@@ -502,7 +559,7 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
502 BN_init(&d); 559 BN_init(&d);
503 BN_init(&e); 560 BN_init(&e);
504 561
505 for (i=0; i<40; i++) 562 for (i=0; i<num0; i++)
506 { 563 {
507 BN_rand(&a,40+i*10,0,0); 564 BN_rand(&a,40+i*10,0,0);
508 a.neg=rand_neg(); 565 a.neg=rand_neg();
@@ -526,7 +583,7 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
526 BN_sub(&d,&d,&a); 583 BN_sub(&d,&d,&a);
527 if(!BN_is_zero(&d) || !BN_is_zero(&e)) 584 if(!BN_is_zero(&d) || !BN_is_zero(&e))
528 { 585 {
529 BIO_puts(bp,"Square test failed!\n"); 586 fprintf(stderr,"Square test failed!\n");
530 return 0; 587 return 0;
531 } 588 }
532 } 589 }
@@ -557,9 +614,13 @@ int test_mont(BIO *bp, BN_CTX *ctx)
557 614
558 BN_rand(&a,100,0,0); /**/ 615 BN_rand(&a,100,0,0); /**/
559 BN_rand(&b,100,0,0); /**/ 616 BN_rand(&b,100,0,0); /**/
560 for (i=0; i<10; i++) 617 for (i=0; i<num2; i++)
561 { 618 {
562 BN_rand(&n,(100%BN_BITS2+1)*BN_BITS2*i*BN_BITS2,0,1); /**/ 619 int bits = (200*(i+1))/num2;
620
621 if (bits == 0)
622 continue;
623 BN_rand(&n,bits,0,1);
563 BN_MONT_CTX_set(mont,&n,ctx); 624 BN_MONT_CTX_set(mont,&n,ctx);
564 625
565 BN_to_montgomery(&A,&a,mont,ctx); 626 BN_to_montgomery(&A,&a,mont,ctx);
@@ -594,7 +655,7 @@ BN_num_bits(mont->N));
594 BN_sub(&d,&d,&A); 655 BN_sub(&d,&d,&A);
595 if(!BN_is_zero(&d)) 656 if(!BN_is_zero(&d))
596 { 657 {
597 BIO_puts(bp,"Montgomery multiplication test failed!\n"); 658 fprintf(stderr,"Montgomery multiplication test failed!\n");
598 return 0; 659 return 0;
599 } 660 }
600 } 661 }
@@ -622,7 +683,7 @@ int test_mod(BIO *bp, BN_CTX *ctx)
622 e=BN_new(); 683 e=BN_new();
623 684
624 BN_rand(a,1024,0,0); /**/ 685 BN_rand(a,1024,0,0); /**/
625 for (i=0; i<20; i++) 686 for (i=0; i<num0; i++)
626 { 687 {
627 BN_rand(b,450+i*10,0,0); /**/ 688 BN_rand(b,450+i*10,0,0); /**/
628 a->neg=rand_neg(); 689 a->neg=rand_neg();
@@ -647,7 +708,7 @@ int test_mod(BIO *bp, BN_CTX *ctx)
647 BN_sub(e,e,c); 708 BN_sub(e,e,c);
648 if(!BN_is_zero(e)) 709 if(!BN_is_zero(e))
649 { 710 {
650 BIO_puts(bp,"Modulo test failed!\n"); 711 fprintf(stderr,"Modulo test failed!\n");
651 return 0; 712 return 0;
652 } 713 }
653 } 714 }
@@ -671,10 +732,10 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
671 e=BN_new(); 732 e=BN_new();
672 733
673 BN_rand(c,1024,0,0); /**/ 734 BN_rand(c,1024,0,0); /**/
674 for (i=0; i<10; i++) 735 for (i=0; i<num0; i++)
675 { 736 {
676 BN_rand(a,475+i*10,0,0); /**/ 737 BN_rand(a,475+i*10,0,0); /**/
677 BN_rand(b,425+i*10,0,0); /**/ 738 BN_rand(b,425+i*11,0,0); /**/
678 a->neg=rand_neg(); 739 a->neg=rand_neg();
679 b->neg=rand_neg(); 740 b->neg=rand_neg();
680 /* if (bp == NULL) 741 /* if (bp == NULL)
@@ -709,7 +770,7 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
709 BN_div(a,b,d,c,ctx); 770 BN_div(a,b,d,c,ctx);
710 if(!BN_is_zero(b)) 771 if(!BN_is_zero(b))
711 { 772 {
712 BIO_puts(bp,"Modulo multiply test failed!\n"); 773 fprintf(stderr,"Modulo multiply test failed!\n");
713 return 0; 774 return 0;
714 } 775 }
715 } 776 }
@@ -733,7 +794,7 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx)
733 e=BN_new(); 794 e=BN_new();
734 795
735 BN_rand(c,30,0,1); /* must be odd for montgomery */ 796 BN_rand(c,30,0,1); /* must be odd for montgomery */
736 for (i=0; i<6; i++) 797 for (i=0; i<num2; i++)
737 { 798 {
738 BN_rand(a,20+i*5,0,0); /**/ 799 BN_rand(a,20+i*5,0,0); /**/
739 BN_rand(b,2+i,0,0); /**/ 800 BN_rand(b,2+i,0,0); /**/
@@ -760,7 +821,7 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx)
760 BN_div(a,b,e,c,ctx); 821 BN_div(a,b,e,c,ctx);
761 if(!BN_is_zero(b)) 822 if(!BN_is_zero(b))
762 { 823 {
763 BIO_puts(bp,"Modulo exponentiation test failed!\n"); 824 fprintf(stderr,"Modulo exponentiation test failed!\n");
764 return 0; 825 return 0;
765 } 826 }
766 } 827 }
@@ -784,7 +845,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
784 one=BN_new(); 845 one=BN_new();
785 BN_one(one); 846 BN_one(one);
786 847
787 for (i=0; i<6; i++) 848 for (i=0; i<num2; i++)
788 { 849 {
789 BN_rand(a,20+i*5,0,0); /**/ 850 BN_rand(a,20+i*5,0,0); /**/
790 BN_rand(b,2+i,0,0); /**/ 851 BN_rand(b,2+i,0,0); /**/
@@ -810,7 +871,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
810 BN_sub(e,e,d); 871 BN_sub(e,e,d);
811 if(!BN_is_zero(e)) 872 if(!BN_is_zero(e))
812 { 873 {
813 BIO_puts(bp,"Exponentiation test failed!\n"); 874 fprintf(stderr,"Exponentiation test failed!\n");
814 return 0; 875 return 0;
815 } 876 }
816 } 877 }
@@ -840,7 +901,7 @@ int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
840 BN_rand(a,200,0,0); /**/ 901 BN_rand(a,200,0,0); /**/
841 a->neg=rand_neg(); 902 a->neg=rand_neg();
842 } 903 }
843 for (i=0; i<70; i++) 904 for (i=0; i<num0; i++)
844 { 905 {
845 BN_lshift(b,a,i+1); 906 BN_lshift(b,a,i+1);
846 BN_add(c,c,c); 907 BN_add(c,c,c);
@@ -860,16 +921,16 @@ int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
860 BN_sub(d,d,b); 921 BN_sub(d,d,b);
861 if(!BN_is_zero(d)) 922 if(!BN_is_zero(d))
862 { 923 {
863 BIO_puts(bp,"Left shift test failed!\n"); 924 fprintf(stderr,"Left shift test failed!\n");
864 BIO_puts(bp,"a="); 925 fprintf(stderr,"a=");
865 BN_print(bp,a); 926 BN_print_fp(stderr,a);
866 BIO_puts(bp,"\nb="); 927 fprintf(stderr,"\nb=");
867 BN_print(bp,b); 928 BN_print_fp(stderr,b);
868 BIO_puts(bp,"\nc="); 929 fprintf(stderr,"\nc=");
869 BN_print(bp,c); 930 BN_print_fp(stderr,c);
870 BIO_puts(bp,"\nd="); 931 fprintf(stderr,"\nd=");
871 BN_print(bp,d); 932 BN_print_fp(stderr,d);
872 BIO_puts(bp,"\n"); 933 fprintf(stderr,"\n");
873 return 0; 934 return 0;
874 } 935 }
875 } 936 }
@@ -891,7 +952,7 @@ int test_lshift1(BIO *bp)
891 952
892 BN_rand(a,200,0,0); /**/ 953 BN_rand(a,200,0,0); /**/
893 a->neg=rand_neg(); 954 a->neg=rand_neg();
894 for (i=0; i<70; i++) 955 for (i=0; i<num0; i++)
895 { 956 {
896 BN_lshift1(b,a); 957 BN_lshift1(b,a);
897 if (bp != NULL) 958 if (bp != NULL)
@@ -909,7 +970,7 @@ int test_lshift1(BIO *bp)
909 BN_sub(a,b,c); 970 BN_sub(a,b,c);
910 if(!BN_is_zero(a)) 971 if(!BN_is_zero(a))
911 { 972 {
912 BIO_puts(bp,"Left shift one test failed!\n"); 973 fprintf(stderr,"Left shift one test failed!\n");
913 return 0; 974 return 0;
914 } 975 }
915 976
@@ -935,7 +996,7 @@ int test_rshift(BIO *bp,BN_CTX *ctx)
935 996
936 BN_rand(a,200,0,0); /**/ 997 BN_rand(a,200,0,0); /**/
937 a->neg=rand_neg(); 998 a->neg=rand_neg();
938 for (i=0; i<70; i++) 999 for (i=0; i<num0; i++)
939 { 1000 {
940 BN_rshift(b,a,i+1); 1001 BN_rshift(b,a,i+1);
941 BN_add(c,c,c); 1002 BN_add(c,c,c);
@@ -955,7 +1016,7 @@ int test_rshift(BIO *bp,BN_CTX *ctx)
955 BN_sub(d,d,b); 1016 BN_sub(d,d,b);
956 if(!BN_is_zero(d)) 1017 if(!BN_is_zero(d))
957 { 1018 {
958 BIO_puts(bp,"Right shift test failed!\n"); 1019 fprintf(stderr,"Right shift test failed!\n");
959 return 0; 1020 return 0;
960 } 1021 }
961 } 1022 }
@@ -978,7 +1039,7 @@ int test_rshift1(BIO *bp)
978 1039
979 BN_rand(a,200,0,0); /**/ 1040 BN_rand(a,200,0,0); /**/
980 a->neg=rand_neg(); 1041 a->neg=rand_neg();
981 for (i=0; i<70; i++) 1042 for (i=0; i<num0; i++)
982 { 1043 {
983 BN_rshift1(b,a); 1044 BN_rshift1(b,a);
984 if (bp != NULL) 1045 if (bp != NULL)
@@ -996,7 +1057,7 @@ int test_rshift1(BIO *bp)
996 BN_sub(c,c,b); 1057 BN_sub(c,c,b);
997 if(!BN_is_zero(c) && !BN_is_one(c)) 1058 if(!BN_is_zero(c) && !BN_is_one(c))
998 { 1059 {
999 BIO_puts(bp,"Right shift one test failed!\n"); 1060 fprintf(stderr,"Right shift one test failed!\n");
1000 return 0; 1061 return 0;
1001 } 1062 }
1002 BN_copy(a,b); 1063 BN_copy(a,b);
diff --git a/src/lib/libcrypto/bn/comba.pl b/src/lib/libcrypto/bn/comba.pl
index 211a8b45c7..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/comba.pl
+++ b/src/lib/libcrypto/bn/comba.pl
@@ -1,285 +0,0 @@
1#!/usr/local/bin/perl
2
3$num=8;
4$num2=8/2;
5
6print <<"EOF";
7/* crypto/bn/bn_comba.c */
8#include <stdio.h>
9#include "bn_lcl.h"
10/* Auto generated from crypto/bn/comba.pl
11 */
12
13#undef bn_mul_comba8
14#undef bn_mul_comba4
15#undef bn_sqr_comba8
16#undef bn_sqr_comba4
17
18#ifdef BN_LLONG
19#define mul_add_c(a,b,c0,c1,c2) \\
20 t=(BN_ULLONG)a*b; \\
21 t1=(BN_ULONG)Lw(t); \\
22 t2=(BN_ULONG)Hw(t); \\
23 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
24 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
25
26#define mul_add_c2(a,b,c0,c1,c2) \\
27 t=(BN_ULLONG)a*b; \\
28 tt=(t+t)&BN_MASK; \\
29 if (tt < t) c2++; \\
30 t1=(BN_ULONG)Lw(tt); \\
31 t2=(BN_ULONG)Hw(tt); \\
32 c0=(c0+t1)&BN_MASK2; \\
33 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \\
34 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
35
36#define sqr_add_c(a,i,c0,c1,c2) \\
37 t=(BN_ULLONG)a[i]*a[i]; \\
38 t1=(BN_ULONG)Lw(t); \\
39 t2=(BN_ULONG)Hw(t); \\
40 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
41 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
42
43#define sqr_add_c2(a,i,j,c0,c1,c2) \\
44 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
45#else
46#define mul_add_c(a,b,c0,c1,c2) \\
47 t1=LBITS(a); t2=HBITS(a); \\
48 bl=LBITS(b); bh=HBITS(b); \\
49 mul64(t1,t2,bl,bh); \\
50 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
51 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
52
53#define mul_add_c2(a,b,c0,c1,c2) \\
54 t1=LBITS(a); t2=HBITS(a); \\
55 bl=LBITS(b); bh=HBITS(b); \\
56 mul64(t1,t2,bl,bh); \\
57 if (t2 & BN_TBIT) c2++; \\
58 t2=(t2+t2)&BN_MASK2; \\
59 if (t1 & BN_TBIT) t2++; \\
60 t1=(t1+t1)&BN_MASK2; \\
61 c0=(c0+t1)&BN_MASK2; \\
62 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \\
63 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
64
65#define sqr_add_c(a,i,c0,c1,c2) \\
66 sqr64(t1,t2,(a)[i]); \\
67 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
68 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
69
70#define sqr_add_c2(a,i,j,c0,c1,c2) \\
71 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
72#endif
73
74void bn_mul_comba${num}(r,a,b)
75BN_ULONG *r,*a,*b;
76 {
77#ifdef BN_LLONG
78 BN_ULLONG t;
79#else
80 BN_ULONG bl,bh;
81#endif
82 BN_ULONG t1,t2;
83 BN_ULONG c1,c2,c3;
84
85EOF
86$ret=&combas_mul("r","a","b",$num,"c1","c2","c3");
87printf <<"EOF";
88 }
89
90void bn_mul_comba${num2}(r,a,b)
91BN_ULONG *r,*a,*b;
92 {
93#ifdef BN_LLONG
94 BN_ULLONG t;
95#else
96 BN_ULONG bl,bh;
97#endif
98 BN_ULONG t1,t2;
99 BN_ULONG c1,c2,c3;
100
101EOF
102$ret=&combas_mul("r","a","b",$num2,"c1","c2","c3");
103printf <<"EOF";
104 }
105
106void bn_sqr_comba${num}(r,a)
107BN_ULONG *r,*a;
108 {
109#ifdef BN_LLONG
110 BN_ULLONG t,tt;
111#else
112 BN_ULONG bl,bh;
113#endif
114 BN_ULONG t1,t2;
115 BN_ULONG c1,c2,c3;
116
117EOF
118$ret=&combas_sqr("r","a",$num,"c1","c2","c3");
119printf <<"EOF";
120 }
121
122void bn_sqr_comba${num2}(r,a)
123BN_ULONG *r,*a;
124 {
125#ifdef BN_LLONG
126 BN_ULLONG t,tt;
127#else
128 BN_ULONG bl,bh;
129#endif
130 BN_ULONG t1,t2;
131 BN_ULONG c1,c2,c3;
132
133EOF
134$ret=&combas_sqr("r","a",$num2,"c1","c2","c3");
135printf <<"EOF";
136 }
137EOF
138
139sub bn_str
140 {
141 local($var,$val)=@_;
142 print "\t$var=$val;\n";
143 }
144
145sub bn_ary
146 {
147 local($var,$idx)=@_;
148 return("${var}[$idx]");
149 }
150
151sub bn_clr
152 {
153 local($var)=@_;
154
155 print "\t$var=0;\n";
156 }
157
158sub bn_mad
159 {
160 local($a,$b,$c0,$c1,$c2,$num)=@_;
161
162 if ($num == 2)
163 { printf("\tmul_add_c2($a,$b,$c0,$c1,$c2);\n"); }
164 else
165 { printf("\tmul_add_c($a,$b,$c0,$c1,$c2);\n"); }
166 }
167
168sub bn_sad
169 {
170 local($a,$i,$j,$c0,$c1,$c2,$num)=@_;
171
172 if ($num == 2)
173 { printf("\tsqr_add_c2($a,$i,$j,$c0,$c1,$c2);\n"); }
174 else
175 { printf("\tsqr_add_c($a,$i,$c0,$c1,$c2);\n"); }
176 }
177
178sub combas_mul
179 {
180 local($r,$a,$b,$num,$c0,$c1,$c2)=@_;
181 local($i,$as,$ae,$bs,$be,$ai,$bi);
182 local($tot,$end);
183
184 $as=0;
185 $ae=0;
186 $bs=0;
187 $be=0;
188 $tot=$num+$num-1;
189 &bn_clr($c0);
190 &bn_clr($c1);
191 for ($i=0; $i<$tot; $i++)
192 {
193 $ai=$as;
194 $bi=$bs;
195 $end=$be+1;
196 @numa=@numb=();
197
198#print "($as $ae) ($bs $be) $bs -> $end [$i $num]\n";
199 for ($j=$bs; $j<$end; $j++)
200 {
201 push(@numa,$ai);
202 push(@numb,$bi);
203 $ai--;
204 $bi++;
205 }
206
207 if ($i & 1)
208 {
209 @numa=reverse(@numa);
210 @numb=reverse(@numb);
211 }
212
213 &bn_clr($c2);
214 for ($j=0; $j<=$#numa; $j++)
215 {
216 &bn_mad(&bn_ary($a,$numa[$j]),
217 &bn_ary($b,$numb[$j]),$c0,$c1,$c2,1);
218 }
219 &bn_str(&bn_ary($r,$i),$c0);
220 ($c0,$c1,$c2)=($c1,$c2,$c0);
221
222 $as++ if ($i < ($num-1));
223 $ae++ if ($i >= ($num-1));
224
225 $bs++ if ($i >= ($num-1));
226 $be++ if ($i < ($num-1));
227 }
228 &bn_str(&bn_ary($r,$i),$c0);
229 }
230
231sub combas_sqr
232 {
233 local($r,$a,$num,$c0,$c1,$c2)=@_;
234 local($i,$as,$ae,$bs,$be,$ai,$bi);
235 local($b,$tot,$end,$half);
236
237 $b=$a;
238 $as=0;
239 $ae=0;
240 $bs=0;
241 $be=0;
242 $tot=$num+$num-1;
243 &bn_clr($c0);
244 &bn_clr($c1);
245 for ($i=0; $i<$tot; $i++)
246 {
247 $ai=$as;
248 $bi=$bs;
249 $end=$be+1;
250 @numa=@numb=();
251
252#print "($as $ae) ($bs $be) $bs -> $end [$i $num]\n";
253 for ($j=$bs; $j<$end; $j++)
254 {
255 push(@numa,$ai);
256 push(@numb,$bi);
257 $ai--;
258 $bi++;
259 last if ($ai < $bi);
260 }
261 if (!($i & 1))
262 {
263 @numa=reverse(@numa);
264 @numb=reverse(@numb);
265 }
266
267 &bn_clr($c2);
268 for ($j=0; $j <= $#numa; $j++)
269 {
270 if ($numa[$j] == $numb[$j])
271 {&bn_sad($a,$numa[$j],$numb[$j],$c0,$c1,$c2,1);}
272 else
273 {&bn_sad($a,$numa[$j],$numb[$j],$c0,$c1,$c2,2);}
274 }
275 &bn_str(&bn_ary($r,$i),$c0);
276 ($c0,$c1,$c2)=($c1,$c2,$c0);
277
278 $as++ if ($i < ($num-1));
279 $ae++ if ($i >= ($num-1));
280
281 $bs++ if ($i >= ($num-1));
282 $be++ if ($i < ($num-1));
283 }
284 &bn_str(&bn_ary($r,$i),$c0);
285 }
diff --git a/src/lib/libcrypto/bn/d.c b/src/lib/libcrypto/bn/d.c
index ced2291b25..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/d.c
+++ b/src/lib/libcrypto/bn/d.c
@@ -1,72 +0,0 @@
1#include <stdio.h>
2#include <openssl/bio.h>
3#include "bn_lcl.h"
4
5#define SIZE_A (100*4+4)
6#define SIZE_B (13*4)
7
8main(argc,argv)
9int argc;
10char *argv[];
11 {
12 BN_CTX ctx;
13 BN_RECP_CTX recp;
14 BIGNUM a,b,dd,d,r,rr,t,l;
15 int i;
16
17 MemCheck_start();
18 MemCheck_on();
19 BN_CTX_init(&ctx);
20 BN_RECP_CTX_init(&recp);
21
22 BN_init(&r);
23 BN_init(&rr);
24 BN_init(&d);
25 BN_init(&dd);
26 BN_init(&a);
27 BN_init(&b);
28
29 {
30 BN_rand(&a,SIZE_A,0,0);
31 BN_rand(&b,SIZE_B,0,0);
32
33 a.neg=1;
34 BN_RECP_CTX_set(&recp,&b,&ctx);
35
36 BN_print_fp(stdout,&a); printf(" a\n");
37 BN_print_fp(stdout,&b); printf(" b\n");
38
39 BN_print_fp(stdout,&recp.N); printf(" N\n");
40 BN_print_fp(stdout,&recp.Nr); printf(" Nr num_bits=%d\n",recp.num_bits);
41
42 BN_div_recp(&r,&d,&a,&recp,&ctx);
43
44for (i=0; i<300; i++)
45 BN_div(&rr,&dd,&a,&b,&ctx);
46
47 BN_print_fp(stdout,&r); printf(" div recp\n");
48 BN_print_fp(stdout,&rr); printf(" div\n");
49 BN_print_fp(stdout,&d); printf(" rem recp\n");
50 BN_print_fp(stdout,&dd); printf(" rem\n");
51 }
52 BN_CTX_free(&ctx);
53 BN_RECP_CTX_free(&recp);
54
55 BN_free(&r);
56 BN_free(&rr);
57 BN_free(&d);
58 BN_free(&dd);
59 BN_free(&a);
60 BN_free(&b);
61
62 {
63 BIO *out;
64
65 if ((out=BIO_new(BIO_s_file())) != NULL)
66 BIO_set_fp(out,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
67
68 CRYPTO_mem_leaks(out);
69 BIO_free(out);
70 }
71
72 }
diff --git a/src/lib/libcrypto/bn/divtest.c b/src/lib/libcrypto/bn/divtest.c
new file mode 100644
index 0000000000..13ba86e3c4
--- /dev/null
+++ b/src/lib/libcrypto/bn/divtest.c
@@ -0,0 +1,41 @@
1#include <openssl/bn.h>
2#include <openssl/rand.h>
3
4static int rand(n)
5{
6 unsigned char x[2];
7 RAND_pseudo_bytes(x,2);
8 return (x[0] + 2*x[1]);
9}
10
11static void bug(char *m, BIGNUM *a, BIGNUM *b)
12{
13 printf("%s!\na=",m);
14 BN_print_fp(stdout, a);
15 printf("\nb=");
16 BN_print_fp(stdout, b);
17 printf("\n");
18 fflush(stdout);
19}
20
21main()
22{
23 BIGNUM *a=BN_new(), *b=BN_new(), *c=BN_new(), *d=BN_new(),
24 *C=BN_new(), *D=BN_new();
25 BN_RECP_CTX *recp=BN_RECP_CTX_new();
26 BN_CTX *ctx=BN_CTX_new();
27
28 for(;;) {
29 BN_pseudo_rand(a,rand(),0,0);
30 BN_pseudo_rand(b,rand(),0,0);
31 if (BN_is_zero(b)) continue;
32
33 BN_RECP_CTX_set(recp,b,ctx);
34 if (BN_div(C,D,a,b,ctx) != 1)
35 bug("BN_div failed",a,b);
36 if (BN_div_recp(c,d,a,recp,ctx) != 1)
37 bug("BN_div_recp failed",a,b);
38 else if (BN_cmp(c,C) != 0 || BN_cmp(c,C) != 0)
39 bug("mismatch",a,b);
40 }
41}
diff --git a/src/lib/libcrypto/bn/exp.c b/src/lib/libcrypto/bn/exp.c
index ec443459d8..4865b0ef74 100644
--- a/src/lib/libcrypto/bn/exp.c
+++ b/src/lib/libcrypto/bn/exp.c
@@ -1,3 +1,5 @@
1/* unused */
2
1#include <stdio.h> 3#include <stdio.h>
2#include <openssl/tmdiff.h> 4#include <openssl/tmdiff.h>
3#include "bn_lcl.h" 5#include "bn_lcl.h"
diff --git a/src/lib/libcrypto/bn/expspeed.c b/src/lib/libcrypto/bn/expspeed.c
index 3656d5bb4c..2044ab9bff 100644
--- a/src/lib/libcrypto/bn/expspeed.c
+++ b/src/lib/libcrypto/bn/expspeed.c
@@ -1,3 +1,5 @@
1/* unused */
2
1/* crypto/bn/expspeed.c */ 3/* crypto/bn/expspeed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 4/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 5 * All rights reserved.
diff --git a/src/lib/libcrypto/bn/exptest.c b/src/lib/libcrypto/bn/exptest.c
index 9e4ae91d20..3e86f2ea0e 100644
--- a/src/lib/libcrypto/bn/exptest.c
+++ b/src/lib/libcrypto/bn/exptest.c
@@ -69,6 +69,8 @@
69 69
70#define NUM_BITS (BN_BITS*2) 70#define NUM_BITS (BN_BITS*2)
71 71
72static const char rnd_seed[] = "string to make the random number generator think it has entropy";
73
72int main(int argc, char *argv[]) 74int main(int argc, char *argv[])
73 { 75 {
74 BN_CTX *ctx; 76 BN_CTX *ctx;
@@ -77,6 +79,10 @@ int main(int argc, char *argv[])
77 unsigned char c; 79 unsigned char c;
78 BIGNUM *r_mont,*r_recp,*r_simple,*a,*b,*m; 80 BIGNUM *r_mont,*r_recp,*r_simple,*a,*b,*m;
79 81
82 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
83 * even check its return value
84 * (which we should) */
85
80 ERR_load_BN_strings(); 86 ERR_load_BN_strings();
81 87
82 ctx=BN_CTX_new(); 88 ctx=BN_CTX_new();
@@ -160,7 +166,16 @@ int main(int argc, char *argv[])
160 exit(1); 166 exit(1);
161 } 167 }
162 } 168 }
169 BN_free(r_mont);
170 BN_free(r_recp);
171 BN_free(r_simple);
172 BN_free(a);
173 BN_free(b);
174 BN_free(m);
175 BN_CTX_free(ctx);
176 ERR_remove_state(0);
163 CRYPTO_mem_leaks(out); 177 CRYPTO_mem_leaks(out);
178 BIO_free(out);
164 printf(" done\n"); 179 printf(" done\n");
165 exit(0); 180 exit(0);
166err: 181err:
diff --git a/src/lib/libcrypto/bn/new b/src/lib/libcrypto/bn/new
index 285d506f19..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/new
+++ b/src/lib/libcrypto/bn/new
@@ -1,23 +0,0 @@
1void BN_RECP_CTX_init(BN_RECP_CTX *recp);
2BN_RECP_CTX *BN_RECP_CTX_new();
3void BN_RECP_CTX_free(BN_RECP_CTX *recp);
4int BN_RECP_CTX_set(BN_RECP_CTX *recp,BIGNUM *div,BN_CTX *ctx);
5
6int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
7 BN_RECP_CTX *recp,BN_CTX *ctx);
8
9int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d,
10 BN_RECP_CTX *recp, BN_CTX *ctx);
11int BN_mod_recp(BIGNUM *rem, BIGNUM *m, BIGNUM *d,
12 BN_RECP_CTX *recp, BN_CTX *ctx);
13int BN_mod_mul_recp(BIGNUM *ret,BIGNUM *a,BIGNUM *b,BIGNUM *m
14
15int BN_mod_exp_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *p,
16 BN_MONT_CTX *m_ctx,BN_CTX *ctx);
17int BN_mod_exp2_montgomery(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2,
18 BIGNUM *p2,BN_MONT_CTX *m_ctx,BN_CTX *ctx);
19
20
21bn_div64 -> bn_div_words
22
23
diff --git a/src/lib/libcrypto/bn/old/b_sqr.c b/src/lib/libcrypto/bn/old/b_sqr.c
index 715cb1c8ab..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/b_sqr.c
+++ b/src/lib/libcrypto/bn/old/b_sqr.c
@@ -1,199 +0,0 @@
1/* crypto/bn/bn_mul.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 "bn_lcl.h"
62
63static int bn_mm(BIGNUM *m,BIGNUM *A,BIGNUM *B, BIGNUM *sk,BN_CTX *ctx);
64
65/* r must be different to a and b */
66/* int BN_mmul(r, a, b) */
67int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b)
68 {
69 BN_ULONG *ap,*bp,*rp;
70 BIGNUM *sk;
71 int i,n,ret;
72 int max,al,bl;
73 BN_CTX ctx;
74
75 bn_check_top(a);
76 bn_check_top(b);
77
78 al=a->top;
79 bl=b->top;
80 if ((al == 0) || (bl == 0))
81 {
82 r->top=0;
83 return(1);
84 }
85#ifdef BN_MUL_DEBUG
86printf("BN_mul(%d,%d)\n",a->top,b->top);
87#endif
88
89 if ( (bn_limit_bits > 0) &&
90 (bl > bn_limit_num) && (al > bn_limit_num))
91 {
92 n=(BN_num_bits_word(al|bl)-bn_limit_bits);
93 n*=2;
94 sk=(BIGNUM *)Malloc(sizeof(BIGNUM)*n);
95 memset(sk,0,sizeof(BIGNUM)*n);
96 memset(&ctx,0,sizeof(ctx));
97
98 ret=bn_mm(r,a,b,&(sk[0]),&ctx);
99 for (i=0; i<n; i+=2)
100 {
101 BN_clear_free(&sk[i]);
102 BN_clear_free(&sk[i+1]);
103 }
104 Free(sk);
105 return(ret);
106 }
107
108 max=(al+bl);
109 if (bn_wexpand(r,max) == NULL) return(0);
110 r->top=max;
111 r->neg=a->neg^b->neg;
112 ap=a->d;
113 bp=b->d;
114 rp=r->d;
115
116 rp[al]=bn_mul_words(rp,ap,al,*(bp++));
117 rp++;
118 for (i=1; i<bl; i++)
119 {
120 rp[al]=bn_mul_add_words(rp,ap,al,*(bp++));
121 rp++;
122 }
123 if ((max > 0) && (r->d[max-1] == 0)) r->top--;
124 return(1);
125 }
126
127
128#define ahal (sk[0])
129#define blbh (sk[1])
130
131/* r must be different to a and b */
132int bn_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BIGNUM *sk, BN_CTX *ctx)
133 {
134 int n,num,sqr=0;
135 int an,bn;
136 BIGNUM ah,al,bh,bl;
137
138 an=A->top;
139 bn=B->top;
140#ifdef BN_MUL_DEBUG
141printf("bn_mm(%d,%d)\n",A->top,B->top);
142#endif
143
144 if (A == B) sqr=1;
145 num=(an>bn)?an:bn;
146 n=(num+1)/2;
147 /* Are going to now chop things into 'num' word chunks. */
148
149 BN_init(&ah);
150 BN_init(&al);
151 BN_init(&bh);
152 BN_init(&bl);
153
154 bn_set_low (&al,A,n);
155 bn_set_high(&ah,A,n);
156 bn_set_low (&bl,B,n);
157 bn_set_high(&bh,B,n);
158
159 BN_sub(&ahal,&ah,&al);
160 BN_sub(&blbh,&bl,&bh);
161
162 if (num <= (bn_limit_num+bn_limit_num))
163 {
164 BN_mul(m,&ahal,&blbh);
165 if (sqr)
166 {
167 BN_sqr(&ahal,&al,ctx);
168 BN_sqr(&blbh,&ah,ctx);
169 }
170 else
171 {
172 BN_mul(&ahal,&al,&bl);
173 BN_mul(&blbh,&ah,&bh);
174 }
175 }
176 else
177 {
178 bn_mm(m,&ahal,&blbh,&(sk[2]),ctx);
179 bn_mm(&ahal,&al,&bl,&(sk[2]),ctx);
180 bn_mm(&blbh,&ah,&bh,&(sk[2]),ctx);
181 }
182
183 BN_add(m,m,&ahal);
184 BN_add(m,m,&blbh);
185
186 BN_lshift(m,m,n*BN_BITS2);
187 BN_lshift(&blbh,&blbh,n*BN_BITS2*2);
188
189 BN_add(m,m,&ahal);
190 BN_add(m,m,&blbh);
191
192 m->neg=A->neg^B->neg;
193 return(1);
194 }
195#undef ahal (sk[0])
196#undef blbh (sk[1])
197
198#include "bn_low.c"
199#include "bn_high.c"
diff --git a/src/lib/libcrypto/bn/old/bn_com.c b/src/lib/libcrypto/bn/old/bn_com.c
index 7666b2304c..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_com.c
+++ b/src/lib/libcrypto/bn/old/bn_com.c
@@ -1,90 +0,0 @@
1/* crypto/bn/bn_mulw.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 "bn_lcl.h"
62
63#ifdef BN_LLONG
64
65ab
6612
67 a2 b2
68a1 b1
69
70abc
71123
72 a3 b3 c3
73 a2 b2 c2
74a1 b1 c1
75
76abcd
771234
78 a4 b4 c4 d4
79 a3 b3 c3 d3
80 a2 b2 c2 d2
81a1 b1 c1 d1
82
83abcde
8401234
85 a5 b5 c5 d5 e5
86 a4 b4 c4 d4 e4
87 a3 b3 c3 d3 e3
88 a2 b2 c2 d2 e2
89 a1 b1 c1 d1 e1
90a0 b0 c0 d0 e0
diff --git a/src/lib/libcrypto/bn/old/bn_high.c b/src/lib/libcrypto/bn/old/bn_high.c
index 763bcb605b..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_high.c
+++ b/src/lib/libcrypto/bn/old/bn_high.c
@@ -1,135 +0,0 @@
1#include <stdio.h>
2#include "cryptlib.h"
3#include "bn_lcl.h"
4
5#undef BN_MUL_HIGH_DEBUG
6
7#ifdef BN_MUL_HIGH_DEBUG
8#define debug_BN_print(a,b,c) BN_print_fp(a,b); printf(c);
9#else
10#define debug_BN_print(a,b,c)
11#endif
12
13int BN_mul_high(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *low, int words);
14
15#undef t1
16#undef t2
17
18int BN_mul_high(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *low, int words)
19 {
20 int w2,borrow=0,full=0;
21 BIGNUM t1,t2,t3,h,ah,al,bh,bl,m,s0,s1;
22 BN_ULONG ul1,ul2;
23
24 BN_mul(r,a,b);
25 BN_rshift(r,r,words*BN_BITS2);
26 return(1);
27
28 w2=(words+1)/2;
29
30#ifdef BN_MUL_HIGH_DEBUG
31fprintf(stdout,"words=%d w2=%d\n",words,w2);
32#endif
33debug_BN_print(stdout,a," a\n");
34debug_BN_print(stdout,b," b\n");
35debug_BN_print(stdout,low," low\n");
36 BN_init(&al); BN_init(&ah);
37 BN_init(&bl); BN_init(&bh);
38 BN_init(&t1); BN_init(&t2); BN_init(&t3);
39 BN_init(&s0); BN_init(&s1);
40 BN_init(&h); BN_init(&m);
41
42 bn_set_low (&al,a,w2);
43 bn_set_high(&ah,a,w2);
44 bn_set_low (&bl,b,w2);
45 bn_set_high(&bh,b,w2);
46
47 bn_set_low(&s0,low,w2);
48 bn_set_high(&s1,low,w2);
49
50debug_BN_print(stdout,&al," al\n");
51debug_BN_print(stdout,&ah," ah\n");
52debug_BN_print(stdout,&bl," bl\n");
53debug_BN_print(stdout,&bh," bh\n");
54debug_BN_print(stdout,&s0," s0\n");
55debug_BN_print(stdout,&s1," s1\n");
56
57 /* Calculate (al-ah)*(bh-bl) */
58 BN_sub(&t1,&al,&ah);
59 BN_sub(&t2,&bh,&bl);
60 BN_mul(&m,&t1,&t2);
61
62 /* Calculate ah*bh */
63 BN_mul(&h,&ah,&bh);
64
65 /* s0 == low(al*bl)
66 * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl)
67 * We know s0 and s1 so the only unknown is high(al*bl)
68 * high(al*bl) == s1 - low(ah*bh+(al-ah)*(bh-bl)+s0)
69 */
70 BN_add(&m,&m,&h);
71 BN_add(&t2,&m,&s0);
72
73debug_BN_print(stdout,&t2," middle value\n");
74
75 /* Quick and dirty mask off of high words */
76 if (w2 < t2.top) t2.top=w2;
77#if 0
78 bn_set_low(&t3,&t2,w2);
79#endif
80
81debug_BN_print(stdout,&t2," low middle value\n");
82 BN_sub(&t1,&s1,&t2);
83
84 if (t1.neg)
85 {
86debug_BN_print(stdout,&t1," before\n");
87 BN_zero(&t2);
88 BN_set_bit(&t2,w2*BN_BITS2);
89 BN_add(&t1,&t2,&t1);
90 /* BN_mask_bits(&t1,w2*BN_BITS2); */
91 /* if (words < t1.top) t1.top=words; */
92debug_BN_print(stdout,&t1," after\n");
93 borrow=1;
94 }
95
96/* XXXXX SPEED THIS UP */
97 /* al*bl == high(al*bl)<<words+s0 */
98 BN_lshift(&t1,&t1,w2*BN_BITS2);
99 BN_add(&t1,&t1,&s0);
100 if (w2*2 < t1.top) t1.top=w2*2; /* This should not happen? */
101
102 /* We now have
103 * al*bl - t1
104 * (al-ah)*(bh-bl)+ah*bh - m
105 * ah*bh - h
106 */
107#if 0
108 BN_add(&m,&m,&t1);
109debug_BN_print(stdout,&t1," s10\n");
110debug_BN_print(stdout,&m," s21\n");
111debug_BN_print(stdout,&h," s32\n");
112 BN_lshift(&m,&m,w2*BN_BITS2);
113 BN_lshift(&h,&h,w2*2*BN_BITS2);
114 BN_add(r,&m,&t1);
115 BN_add(r,r,&h);
116 BN_rshift(r,r,w2*2*BN_BITS2);
117#else
118 BN_add(&m,&m,&t1); /* Do a cmp then +1 if needed? */
119 bn_set_high(&t3,&t1,w2);
120 BN_add(&m,&m,&t3);
121 bn_set_high(&t3,&m,w2);
122 BN_add(r,&h,&t3);
123#endif
124
125#ifdef BN_MUL_HIGH_DEBUG
126printf("carry=%d\n",borrow);
127#endif
128debug_BN_print(stdout,r," ret\n");
129 BN_free(&t1); BN_free(&t2);
130 BN_free(&m); BN_free(&h);
131 return(1);
132 }
133
134
135
diff --git a/src/lib/libcrypto/bn/old/bn_ka.c b/src/lib/libcrypto/bn/old/bn_ka.c
index 378c94dc5a..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_ka.c
+++ b/src/lib/libcrypto/bn/old/bn_ka.c
@@ -1,567 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <strings.h>
4#include "bn_lcl.h"
5
6/* r is 2*n2 words in size,
7 * a and b are both n2 words in size.
8 * n2 must be a power of 2.
9 * We multiply and return the result.
10 * t must be 2*n2 words in size
11 * We calulate
12 * a[0]*b[0]
13 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
14 * a[1]*b[1]
15 */
16void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
17 BN_ULONG *t)
18 {
19 int n=n2/2;
20 int neg,zero,c1,c2;
21 BN_ULONG ln,lo,*p;
22
23#ifdef BN_COUNT
24printf(" bn_mul_recursive %d * %d\n",n2,n2);
25#endif
26 if (n2 <= 8)
27 {
28 if (n2 == 8)
29 bn_mul_comba8(r,a,b);
30 else
31 bn_mul_normal(r,a,n2,b,n2);
32 return;
33 }
34
35 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
36 {
37 /* This should not happen */
38 /*abort(); */
39 bn_mul_normal(r,a,n2,b,n2);
40 return;
41 }
42 /* r=(a[0]-a[1])*(b[1]-b[0]) */
43 c1=bn_cmp_words(a,&(a[n]),n);
44 c2=bn_cmp_words(&(b[n]),b,n);
45 zero=neg=0;
46 switch (c1*3+c2)
47 {
48 case -4:
49 bn_sub_words(t, &(a[n]),a, n); /* - */
50 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
51 break;
52 case -3:
53 zero=1;
54 break;
55 case -2:
56 bn_sub_words(t, &(a[n]),a, n); /* - */
57 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */
58 neg=1;
59 break;
60 case -1:
61 case 0:
62 case 1:
63 zero=1;
64 break;
65 case 2:
66 bn_sub_words(t, a, &(a[n]),n); /* + */
67 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
68 neg=1;
69 break;
70 case 3:
71 zero=1;
72 break;
73 case 4:
74 bn_sub_words(t, a, &(a[n]),n);
75 bn_sub_words(&(t[n]),&(b[n]),b, n);
76 break;
77 }
78
79 if (n == 8)
80 {
81 if (!zero)
82 bn_mul_comba8(&(t[n2]),t,&(t[n]));
83 else
84 memset(&(t[n2]),0,8*sizeof(BN_ULONG));
85
86 bn_mul_comba8(r,a,b);
87 bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n]));
88 }
89 else
90 {
91 p= &(t[n2*2]);
92 if (!zero)
93 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
94 else
95 memset(&(t[n2]),0,n*sizeof(BN_ULONG));
96 bn_mul_recursive(r,a,b,n,p);
97 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p);
98 }
99
100 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
101 * r[10] holds (a[0]*b[0])
102 * r[32] holds (b[1]*b[1])
103 */
104
105 c1=bn_add_words(t,r,&(r[n2]),n2);
106
107 if (neg) /* if t[32] is negative */
108 {
109 c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
110 }
111 else
112 {
113 /* Might have a carry */
114 c1+=bn_add_words(&(t[n2]),&(t[n2]),t,n2);
115 }
116
117 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
118 * r[10] holds (a[0]*b[0])
119 * r[32] holds (b[1]*b[1])
120 * c1 holds the carry bits
121 */
122 c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
123 if (c1)
124 {
125 p= &(r[n+n2]);
126 lo= *p;
127 ln=(lo+c1)&BN_MASK2;
128 *p=ln;
129
130 /* The overflow will stop before we over write
131 * words we should not overwrite */
132 if (ln < c1)
133 {
134 do {
135 p++;
136 lo= *p;
137 ln=(lo+1)&BN_MASK2;
138 *p=ln;
139 } while (ln == 0);
140 }
141 }
142 }
143
144/* n+tn is the word length
145 * t needs to be n*4 is size, as does r */
146void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
147 int n, BN_ULONG *t)
148 {
149 int n2=n*2,i,j;
150 int c1;
151 BN_ULONG ln,lo,*p;
152
153#ifdef BN_COUNT
154printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
155#endif
156 if (n < 8)
157 {
158 i=tn+n;
159 bn_mul_normal(r,a,i,b,i);
160 return;
161 }
162
163 /* r=(a[0]-a[1])*(b[1]-b[0]) */
164 bn_sub_words(t, a, &(a[n]),n); /* + */
165 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
166
167 if (n == 8)
168 {
169 bn_mul_comba8(&(t[n2]),t,&(t[n]));
170 bn_mul_comba8(r,a,b);
171 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
172 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2));
173 }
174 else
175 {
176 p= &(t[n2*2]);
177 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
178 bn_mul_recursive(r,a,b,n,p);
179 i=n/2;
180 /* If there is only a bottom half to the number,
181 * just do it */
182 j=tn-i;
183 if (j == 0)
184 {
185 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p);
186 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2));
187 }
188 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */
189 {
190 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]),
191 j,i,p);
192 memset(&(r[n2+tn*2]),0,
193 sizeof(BN_ULONG)*(n2-tn*2));
194 }
195 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */
196 {
197 memset(&(r[n2]),0,sizeof(BN_ULONG)*(tn*2));
198 for (;;)
199 {
200 i/=2;
201 if (i < tn)
202 {
203 bn_mul_part_recursive(&(r[n2]),
204 &(a[n]),&(b[n]),
205 tn-i,i,p);
206 break;
207 }
208 else if (i == tn)
209 {
210 bn_mul_recursive(&(r[n2]),
211 &(a[n]),&(b[n]),
212 i,p);
213 break;
214 }
215 }
216 }
217 }
218
219 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
220 * r[10] holds (a[0]*b[0])
221 * r[32] holds (b[1]*b[1])
222 */
223
224 c1=bn_add_words(t,r,&(r[n2]),n2);
225 c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
226
227 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
228 * r[10] holds (a[0]*b[0])
229 * r[32] holds (b[1]*b[1])
230 * c1 holds the carry bits
231 */
232 c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
233 if (c1)
234 {
235 p= &(r[n+n2]);
236 lo= *p;
237 ln=(lo+c1)&BN_MASK2;
238 *p=ln;
239
240 /* The overflow will stop before we over write
241 * words we should not overwrite */
242 if (ln < c1)
243 {
244 do {
245 p++;
246 lo= *p;
247 ln=(lo+1)&BN_MASK2;
248 *p=ln;
249 } while (ln == 0);
250 }
251 }
252 }
253
254/* r is 2*n words in size,
255 * a and b are both n words in size.
256 * n must be a power of 2.
257 * We multiply and return the result.
258 * t must be 2*n words in size
259 * We calulate
260 * a[0]*b[0]
261 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
262 * a[1]*b[1]
263 */
264void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *t)
265 {
266 int n=n2/2;
267 int zero,c1;
268 BN_ULONG ln,lo,*p;
269
270#ifdef BN_COUNT
271printf(" bn_sqr_recursive %d * %d\n",n2,n2);
272#endif
273 if (n2 == 4)
274 {
275 bn_sqr_comba4(r,a);
276 return;
277 }
278 else if (n2 == 8)
279 {
280 bn_sqr_comba8(r,a);
281 return;
282 }
283 if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL)
284 {
285 bn_sqr_normal(r,a,n2,t);
286 return;
287 abort();
288 }
289 /* r=(a[0]-a[1])*(a[1]-a[0]) */
290 c1=bn_cmp_words(a,&(a[n]),n);
291 zero=0;
292 if (c1 > 0)
293 bn_sub_words(t,a,&(a[n]),n);
294 else if (c1 < 0)
295 bn_sub_words(t,&(a[n]),a,n);
296 else
297 zero=1;
298
299 /* The result will always be negative unless it is zero */
300
301 if (n == 8)
302 {
303 if (!zero)
304 bn_sqr_comba8(&(t[n2]),t);
305 else
306 memset(&(t[n2]),0,8*sizeof(BN_ULONG));
307
308 bn_sqr_comba8(r,a);
309 bn_sqr_comba8(&(r[n2]),&(a[n]));
310 }
311 else
312 {
313 p= &(t[n2*2]);
314 if (!zero)
315 bn_sqr_recursive(&(t[n2]),t,n,p);
316 else
317 memset(&(t[n2]),0,n*sizeof(BN_ULONG));
318 bn_sqr_recursive(r,a,n,p);
319 bn_sqr_recursive(&(r[n2]),&(a[n]),n,p);
320 }
321
322 /* t[32] holds (a[0]-a[1])*(a[1]-a[0]), it is negative or zero
323 * r[10] holds (a[0]*b[0])
324 * r[32] holds (b[1]*b[1])
325 */
326
327 c1=bn_add_words(t,r,&(r[n2]),n2);
328
329 /* t[32] is negative */
330 c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
331
332 /* t[32] holds (a[0]-a[1])*(a[1]-a[0])+(a[0]*a[0])+(a[1]*a[1])
333 * r[10] holds (a[0]*a[0])
334 * r[32] holds (a[1]*a[1])
335 * c1 holds the carry bits
336 */
337 c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
338 if (c1)
339 {
340 p= &(r[n+n2]);
341 lo= *p;
342 ln=(lo+c1)&BN_MASK2;
343 *p=ln;
344
345 /* The overflow will stop before we over write
346 * words we should not overwrite */
347 if (ln < c1)
348 {
349 do {
350 p++;
351 lo= *p;
352 ln=(lo+1)&BN_MASK2;
353 *p=ln;
354 } while (ln == 0);
355 }
356 }
357 }
358
359#if 1
360/* a and b must be the same size, which is n2.
361 * r needs to be n2 words and t needs to be n2*2
362 */
363void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
364 BN_ULONG *t)
365 {
366 int n=n2/2;
367
368#ifdef BN_COUNT
369printf(" bn_mul_low_recursive %d * %d\n",n2,n2);
370#endif
371
372 bn_mul_recursive(r,a,b,n,&(t[0]));
373 if (n > BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
374 {
375 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2]));
376 bn_add_words(&(r[n]),&(r[n]),&(t[0]),n);
377 bn_mul_low_recursive(&(t[0]),&(a[n]),&(b[0]),n,&(t[n2]));
378 bn_add_words(&(r[n]),&(r[n]),&(t[0]),n);
379 }
380 else
381 {
382 bn_mul_low_normal(&(t[0]),&(a[0]),&(b[n]),n);
383 bn_mul_low_normal(&(t[n]),&(a[n]),&(b[0]),n);
384 bn_add_words(&(r[n]),&(r[n]),&(t[0]),n);
385 bn_add_words(&(r[n]),&(r[n]),&(t[n]),n);
386 }
387 }
388
389/* a and b must be the same size, which is n2.
390 * r needs to be n2 words and t needs to be n2*2
391 * l is the low words of the output.
392 * t needs to be n2*3
393 */
394void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
395 BN_ULONG *t)
396 {
397 int j,i,n,c1,c2;
398 int neg,oneg,zero;
399 BN_ULONG ll,lc,*lp,*mp;
400
401#ifdef BN_COUNT
402printf(" bn_mul_high %d * %d\n",n2,n2);
403#endif
404 n=(n2+1)/2;
405
406 /* Calculate (al-ah)*(bh-bl) */
407 neg=zero=0;
408 c1=bn_cmp_words(&(a[0]),&(a[n]),n);
409 c2=bn_cmp_words(&(b[n]),&(b[0]),n);
410 switch (c1*3+c2)
411 {
412 case -4:
413 bn_sub_words(&(r[0]),&(a[n]),&(a[0]),n);
414 bn_sub_words(&(r[n]),&(b[0]),&(b[n]),n);
415 break;
416 case -3:
417 zero=1;
418 break;
419 case -2:
420 bn_sub_words(&(r[0]),&(a[n]),&(a[0]),n);
421 bn_sub_words(&(r[n]),&(b[n]),&(b[0]),n);
422 neg=1;
423 break;
424 case -1:
425 case 0:
426 case 1:
427 zero=1;
428 break;
429 case 2:
430 bn_sub_words(&(r[0]),&(a[0]),&(a[n]),n);
431 bn_sub_words(&(r[n]),&(b[0]),&(b[n]),n);
432 neg=1;
433 break;
434 case 3:
435 zero=1;
436 break;
437 case 4:
438 bn_sub_words(&(r[0]),&(a[0]),&(a[n]),n);
439 bn_sub_words(&(r[n]),&(b[n]),&(b[0]),n);
440 break;
441 }
442
443 oneg=neg;
444 /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */
445 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2]));
446 /* r[10] = (a[1]*b[1]) */
447 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2]));
448
449 /* s0 == low(al*bl)
450 * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl)
451 * We know s0 and s1 so the only unknown is high(al*bl)
452 * high(al*bl) == s1 - low(ah*bh+s0+(al-ah)*(bh-bl))
453 * high(al*bl) == s1 - (r[0]+l[0]+t[0])
454 */
455 if (l != NULL)
456 {
457 lp= &(t[n2+n]);
458 c1=bn_add_words(lp,&(r[0]),&(l[0]),n);
459 }
460 else
461 {
462 c1=0;
463 lp= &(r[0]);
464 }
465
466 if (neg)
467 neg=bn_sub_words(&(t[n2]),lp,&(t[0]),n);
468 else
469 {
470 bn_add_words(&(t[n2]),lp,&(t[0]),n);
471 neg=0;
472 }
473
474 if (l != NULL)
475 {
476 bn_sub_words(&(t[n2+n]),&(l[n]),&(t[n2]),n);
477 }
478 else
479 {
480 lp= &(t[n2+n]);
481 mp= &(t[n2]);
482 for (i=0; i<n; i++)
483 lp[i]=((~mp[i])+1)&BN_MASK2;
484 }
485
486 /* s[0] = low(al*bl)
487 * t[3] = high(al*bl)
488 * t[10] = (a[0]-a[1])*(b[1]-b[0]) neg is the sign
489 * r[10] = (a[1]*b[1])
490 */
491 /* R[10] = al*bl
492 * R[21] = al*bl + ah*bh + (a[0]-a[1])*(b[1]-b[0])
493 * R[32] = ah*bh
494 */
495 /* R[1]=t[3]+l[0]+r[0](+-)t[0] (have carry/borrow)
496 * R[2]=r[0]+t[3]+r[1](+-)t[1] (have carry/borrow)
497 * R[3]=r[1]+(carry/borrow)
498 */
499 if (l != NULL)
500 {
501 lp= &(t[n2]);
502 c1= bn_add_words(lp,&(t[n2+n]),&(l[0]),n);
503 }
504 else
505 {
506 lp= &(t[n2+n]);
507 c1=0;
508 }
509 c1+=bn_add_words(&(t[n2]),lp, &(r[0]),n);
510 if (oneg)
511 c1-=bn_sub_words(&(t[n2]),&(t[n2]),&(t[0]),n);
512 else
513 c1+=bn_add_words(&(t[n2]),&(t[n2]),&(t[0]),n);
514
515 c2 =bn_add_words(&(r[0]),&(r[0]),&(t[n2+n]),n);
516 c2+=bn_add_words(&(r[0]),&(r[0]),&(r[n]),n);
517 if (oneg)
518 c2-=bn_sub_words(&(r[0]),&(r[0]),&(t[n]),n);
519 else
520 c2+=bn_add_words(&(r[0]),&(r[0]),&(t[n]),n);
521
522 if (c1 != 0) /* Add starting at r[0], could be +ve or -ve */
523 {
524 i=0;
525 if (c1 > 0)
526 {
527 lc=c1;
528 do {
529 ll=(r[i]+lc)&BN_MASK2;
530 r[i++]=ll;
531 lc=(lc > ll);
532 } while (lc);
533 }
534 else
535 {
536 lc= -c1;
537 do {
538 ll=r[i];
539 r[i++]=(ll-lc)&BN_MASK2;
540 lc=(lc > ll);
541 } while (lc);
542 }
543 }
544 if (c2 != 0) /* Add starting at r[1] */
545 {
546 i=n;
547 if (c2 > 0)
548 {
549 lc=c2;
550 do {
551 ll=(r[i]+lc)&BN_MASK2;
552 r[i++]=ll;
553 lc=(lc > ll);
554 } while (lc);
555 }
556 else
557 {
558 lc= -c2;
559 do {
560 ll=r[i];
561 r[i++]=(ll-lc)&BN_MASK2;
562 lc=(lc > ll);
563 } while (lc);
564 }
565 }
566 }
567#endif
diff --git a/src/lib/libcrypto/bn/old/bn_low.c b/src/lib/libcrypto/bn/old/bn_low.c
index cbc406751c..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_low.c
+++ b/src/lib/libcrypto/bn/old/bn_low.c
@@ -1,194 +0,0 @@
1/* crypto/bn/bn_mul.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 "bn_lcl.h"
62
63static int bn_mm_low(BIGNUM *m,BIGNUM *A,BIGNUM *B, int num,
64 BIGNUM *sk,BN_CTX *ctx);
65int BN_mul_low(BIGNUM *r, BIGNUM *a, BIGNUM *b,int words);
66
67/* r must be different to a and b */
68int BN_mul_low(BIGNUM *r, BIGNUM *a, BIGNUM *b, int num)
69 {
70 BN_ULONG *ap,*bp,*rp;
71 BIGNUM *sk;
72 int j,i,n,ret;
73 int max,al,bl;
74 BN_CTX ctx;
75
76 bn_check_top(a);
77 bn_check_top(b);
78
79#ifdef BN_MUL_DEBUG
80printf("BN_mul_low(%d,%d,%d)\n",a->top,b->top,num);
81#endif
82
83 al=a->top;
84 bl=b->top;
85 if ((al == 0) || (bl == 0))
86 {
87 r->top=0;
88 return(1);
89 }
90
91 if ((bn_limit_bits_low > 0) && (num > bn_limit_num_low))
92 {
93 n=BN_num_bits_word(num*2)-bn_limit_bits_low;
94 n*=2;
95 sk=(BIGNUM *)Malloc(sizeof(BIGNUM)*n);
96 memset(sk,0,sizeof(BIGNUM)*n);
97 memset(&ctx,0,sizeof(ctx));
98
99 ret=bn_mm_low(r,a,b,num,&(sk[0]),&ctx);
100 for (i=0; i<n; i+=2)
101 {
102 BN_clear_free(&sk[i]);
103 BN_clear_free(&sk[i+1]);
104 }
105 Free(sk);
106 return(ret);
107 }
108
109 max=(al+bl);
110 if (bn_wexpand(r,max) == NULL) return(0);
111 r->neg=a->neg^b->neg;
112 ap=a->d;
113 bp=b->d;
114 rp=r->d;
115 r->top=(max > num)?num:max;
116
117 rp[al]=bn_mul_words(rp,ap,al,*(bp++));
118 rp++;
119 j=bl;
120 for (i=1; i<j; i++)
121 {
122 if (al >= num--)
123 {
124 al--;
125 if (al <= 0) break;
126 }
127 rp[al]=bn_mul_add_words(rp,ap,al,*(bp++));
128 rp++;
129 }
130
131 while ((r->top > 0) && (r->d[r->top-1] == 0))
132 r->top--;
133 return(1);
134 }
135
136
137#define t1 (sk[0])
138#define t2 (sk[1])
139
140/* r must be different to a and b */
141int bn_mm_low(BIGNUM *m, BIGNUM *A, BIGNUM *B, int num, BIGNUM *sk,
142 BN_CTX *ctx)
143 {
144 int n; /* ,sqr=0; */
145 int an,bn;
146 BIGNUM ah,al,bh,bl;
147
148 bn_wexpand(m,num+3);
149 an=A->top;
150 bn=B->top;
151
152#ifdef BN_MUL_DEBUG
153printf("bn_mm_low(%d,%d,%d)\n",A->top,B->top,num);
154#endif
155
156 n=(num+1)/2;
157
158 BN_init(&ah); BN_init(&al); BN_init(&bh); BN_init(&bl);
159
160 bn_set_low( &al,A,n);
161 bn_set_high(&ah,A,n);
162 bn_set_low( &bl,B,n);
163 bn_set_high(&bh,B,n);
164
165 if (num <= (bn_limit_num_low+bn_limit_num_low))
166 {
167 BN_mul(m,&al,&bl);
168 BN_mul_low(&t1,&al,&bh,n);
169 BN_mul_low(&t2,&ah,&bl,n);
170 }
171 else
172 {
173 bn_mm(m ,&al,&bl,&(sk[2]),ctx);
174 bn_mm_low(&t1,&al,&bh,n,&(sk[2]),ctx);
175 bn_mm_low(&t2,&ah,&bl,n,&(sk[2]),ctx);
176 }
177
178 BN_add(&t1,&t1,&t2);
179
180 /* We will now do an evil hack instead of
181 * BN_lshift(&t1,&t1,n*BN_BITS2);
182 * BN_add(m,m,&t1);
183 * BN_mask_bits(m,num*BN_BITS2);
184 */
185 bn_set_high(&ah,m,n); ah.max=num+2;
186 BN_add(&ah,&ah,&t1);
187 m->top=num;
188
189 m->neg=A->neg^B->neg;
190 return(1);
191 }
192
193#undef t1 (sk[0])
194#undef t2 (sk[1])
diff --git a/src/lib/libcrypto/bn/old/bn_m.c b/src/lib/libcrypto/bn/old/bn_m.c
index 522beb02bc..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_m.c
+++ b/src/lib/libcrypto/bn/old/bn_m.c
@@ -1,139 +0,0 @@
1/* crypto/bn/bn_m.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 "bn_lcl.h"
62
63#define limit_bits 5 /* 2^5, or 32 words */
64#define limit_num (1<<limit_bits)
65
66int BN_m(BIGNUM *r, BIGNUM *a, BIGNUM *b)
67 {
68 BIGNUM *sk;
69 int i,n;
70
71 n=(BN_num_bits_word(a->top|b->top)-limit_bits);
72 n*=2;
73 sk=(BIGNUM *)malloc(sizeof(BIGNUM)*n);
74 for (i=0; i<n; i++)
75 BN_init(&(sk[i]));
76
77 return(BN_mm(r,a,b,&(sk[0])));
78 }
79
80#define ahal (sk[0])
81#define blbh (sk[1])
82
83/* r must be different to a and b */
84int BN_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BIGNUM *sk)
85 {
86 int i,num,anum,bnum;
87 int an,bn;
88 BIGNUM ah,al,bh,bl;
89
90 an=A->top;
91 bn=B->top;
92 if ((an <= limit_num) || (bn <= limit_num))
93 {
94 return(BN_mul(m,A,B));
95 }
96
97 anum=(an>bn)?an:bn;
98 num=(anum)/2;
99
100 /* Are going to now chop things into 'num' word chunks. */
101 bnum=num*BN_BITS2;
102
103 BN_init(&ahal);
104 BN_init(&blbh);
105 BN_init(&ah);
106 BN_init(&al);
107 BN_init(&bh);
108 BN_init(&bl);
109
110 al.top=num;
111 al.d=A->d;
112 ah.top=A->top-num;
113 ah.d= &(A->d[num]);
114
115 bl.top=num;
116 bl.d=B->d;
117 bh.top=B->top-num;
118 bh.d= &(B->d[num]);
119
120 BN_sub(&ahal,&ah,&al);
121 BN_sub(&blbh,&bl,&bh);
122
123 BN_mm(m,&ahal,&blbh,&(sk[2]));
124 BN_mm(&ahal,&al,&bl,&(sk[2]));
125 BN_mm(&blbh,&ah,&bh,&(sk[2]));
126
127 BN_add(m,m,&ahal);
128 BN_add(m,m,&blbh);
129
130 BN_lshift(m,m,bnum);
131 BN_add(m,m,&ahal);
132
133 BN_lshift(&blbh,&blbh,bnum*2);
134 BN_add(m,m,&blbh);
135
136 m->neg=A->neg^B->neg;
137 return(1);
138 }
139
diff --git a/src/lib/libcrypto/bn/old/bn_mul.c.works b/src/lib/libcrypto/bn/old/bn_mul.c.works
index 6d565d44a2..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_mul.c.works
+++ b/src/lib/libcrypto/bn/old/bn_mul.c.works
@@ -1,219 +0,0 @@
1/* crypto/bn/bn_mul.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 "bn_lcl.h"
62
63int bn_mm(BIGNUM *m,BIGNUM *A,BIGNUM *B, BIGNUM *sk,BN_CTX *ctx);
64
65/* r must be different to a and b */
66int BN_mul(r, a, b)
67BIGNUM *r;
68BIGNUM *a;
69BIGNUM *b;
70 {
71 BN_ULONG *ap,*bp,*rp;
72 BIGNUM *sk;
73 int i,n,ret;
74 int max,al,bl;
75 BN_CTX ctx;
76
77 bn_check_top(a);
78 bn_check_top(b);
79
80 al=a->top;
81 bl=b->top;
82 if ((al == 0) || (bl == 0))
83 {
84 r->top=0;
85 return(1);
86 }
87#ifdef BN_MUL_DEBUG
88printf("BN_mul(%d,%d)\n",a->top,b->top);
89#endif
90
91#ifdef BN_RECURSION
92 if ( (bn_limit_bits > 0) &&
93 (bl > bn_limit_num) && (al > bn_limit_num))
94 {
95 n=(BN_num_bits_word(al|bl)-bn_limit_bits);
96 n*=2;
97 sk=(BIGNUM *)Malloc(sizeof(BIGNUM)*n);
98 memset(sk,0,sizeof(BIGNUM)*n);
99 memset(&ctx,0,sizeof(ctx));
100
101 ret=bn_mm(r,a,b,&(sk[0]),&ctx);
102 for (i=0; i<n; i+=2)
103 {
104 BN_clear_free(&sk[i]);
105 BN_clear_free(&sk[i+1]);
106 }
107 Free(sk);
108 return(ret);
109 }
110#endif
111
112 max=(al+bl);
113 if (bn_wexpand(r,max) == NULL) return(0);
114 r->top=max;
115 r->neg=a->neg^b->neg;
116 ap=a->d;
117 bp=b->d;
118 rp=r->d;
119
120#ifdef BN_RECURSION
121 if ((al == bl) && (al == 8))
122 {
123 bn_mul_comba8(rp,ap,bp);
124 }
125 else
126#endif
127 {
128 rp[al]=bn_mul_words(rp,ap,al,*(bp++));
129 rp++;
130 for (i=1; i<bl; i++)
131 {
132 rp[al]=bn_mul_add_words(rp,ap,al,*(bp++));
133 rp++;
134 }
135 }
136 if ((max > 0) && (r->d[max-1] == 0)) r->top--;
137 return(1);
138 }
139
140#ifdef BN_RECURSION
141
142#define ahal (sk[0])
143#define blbh (sk[1])
144
145/* r must be different to a and b */
146int bn_mm(m, A, B, sk,ctx)
147BIGNUM *m,*A,*B;
148BIGNUM *sk;
149BN_CTX *ctx;
150 {
151 int n,num,sqr=0;
152 int an,bn;
153 BIGNUM ah,al,bh,bl;
154
155 an=A->top;
156 bn=B->top;
157#ifdef BN_MUL_DEBUG
158printf("bn_mm(%d,%d)\n",A->top,B->top);
159#endif
160
161 if (A == B) sqr=1;
162 num=(an>bn)?an:bn;
163 n=(num+1)/2;
164 /* Are going to now chop things into 'num' word chunks. */
165
166 BN_init(&ah);
167 BN_init(&al);
168 BN_init(&bh);
169 BN_init(&bl);
170
171 bn_set_low (&al,A,n);
172 bn_set_high(&ah,A,n);
173 bn_set_low (&bl,B,n);
174 bn_set_high(&bh,B,n);
175
176 BN_sub(&ahal,&ah,&al);
177 BN_sub(&blbh,&bl,&bh);
178
179 if (num <= (bn_limit_num+bn_limit_num))
180 {
181 BN_mul(m,&ahal,&blbh);
182 if (sqr)
183 {
184 BN_sqr(&ahal,&al,ctx);
185 BN_sqr(&blbh,&ah,ctx);
186 }
187 else
188 {
189 BN_mul(&ahal,&al,&bl);
190 BN_mul(&blbh,&ah,&bh);
191 }
192 }
193 else
194 {
195 bn_mm(m,&ahal,&blbh,&(sk[2]),ctx);
196 bn_mm(&ahal,&al,&bl,&(sk[2]),ctx);
197 bn_mm(&blbh,&ah,&bh,&(sk[2]),ctx);
198 }
199
200 BN_add(m,m,&ahal);
201 BN_add(m,m,&blbh);
202
203 BN_lshift(m,m,n*BN_BITS2);
204 BN_lshift(&blbh,&blbh,n*BN_BITS2*2);
205
206 BN_add(m,m,&ahal);
207 BN_add(m,m,&blbh);
208
209 m->neg=A->neg^B->neg;
210 return(1);
211 }
212#undef ahal (sk[0])
213#undef blbh (sk[1])
214
215#include "bn_low.c"
216#include "bn_high.c"
217#include "f.c"
218
219#endif
diff --git a/src/lib/libcrypto/bn/old/bn_wmul.c b/src/lib/libcrypto/bn/old/bn_wmul.c
index a467b2f17a..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/bn_wmul.c
+++ b/src/lib/libcrypto/bn/old/bn_wmul.c
@@ -1,173 +0,0 @@
1#include <stdio.h>
2#include "bn_lcl.h"
3
4#if 1
5
6int bn_mull(BIGNUM *r,BIGNUM *a,BIGNUM *b, BN_CTX *ctx);
7
8int bn_mull(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
9 {
10 int top,i,j,k,al,bl;
11 BIGNUM *t;
12
13#ifdef BN_COUNT
14printf("bn_mull %d * %d\n",a->top,b->top);
15#endif
16
17 bn_check_top(a);
18 bn_check_top(b);
19 bn_check_top(r);
20
21 al=a->top;
22 bl=b->top;
23 r->neg=a->neg^b->neg;
24
25 top=al+bl;
26 if ((al < 4) || (bl < 4))
27 {
28 if (bn_wexpand(r,top) == NULL) return(0);
29 r->top=top;
30 bn_mul_normal(r->d,a->d,al,b->d,bl);
31 goto end;
32 }
33 else if (al == bl) /* A good start, they are the same size */
34 goto symetric;
35 else
36 {
37 i=(al-bl);
38 if ((i == 1) && !BN_get_flags(b,BN_FLG_STATIC_DATA))
39 {
40 bn_wexpand(b,al);
41 b->d[bl]=0;
42 bl++;
43 goto symetric;
44 }
45 else if ((i == -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA))
46 {
47 bn_wexpand(a,bl);
48 a->d[al]=0;
49 al++;
50 goto symetric;
51 }
52 }
53
54 /* asymetric and >= 4 */
55 if (bn_wexpand(r,top) == NULL) return(0);
56 r->top=top;
57 bn_mul_normal(r->d,a->d,al,b->d,bl);
58
59 if (0)
60 {
61 /* symetric and > 4 */
62symetric:
63 if (al == 4)
64 {
65 if (bn_wexpand(r,al*2) == NULL) return(0);
66 r->top=top;
67 bn_mul_comba4(r->d,a->d,b->d);
68 goto end;
69 }
70 if (al == 8)
71 {
72 if (bn_wexpand(r,al*2) == NULL) return(0);
73 r->top=top;
74 bn_mul_comba8(r->d,a->d,b->d);
75 goto end;
76 }
77 if (al <= BN_MULL_NORMAL_SIZE)
78 {
79 if (bn_wexpand(r,al*2) == NULL) return(0);
80 r->top=top;
81 bn_mul_normal(r->d,a->d,al,b->d,bl);
82 goto end;
83 }
84 /* 16 or larger */
85 j=BN_num_bits_word((BN_ULONG)al);
86 j=1<<(j-1);
87 k=j+j;
88 t= &(ctx->bn[ctx->tos]);
89 if (al == j) /* exact multiple */
90 {
91 bn_wexpand(t,k*2);
92 bn_wexpand(r,k*2);
93 bn_mul_recursive(r->d,a->d,b->d,al,t->d);
94 }
95 else
96 {
97 bn_wexpand(a,k);
98 bn_wexpand(b,k);
99 bn_wexpand(t,k*4);
100 bn_wexpand(r,k*4);
101 for (i=a->top; i<k; i++)
102 a->d[i]=0;
103 for (i=b->top; i<k; i++)
104 b->d[i]=0;
105 bn_mul_part_recursive(r->d,a->d,b->d,al-j,j,t->d);
106 }
107 r->top=top;
108 }
109end:
110 bn_fix_top(r);
111 return(1);
112 }
113#endif
114
115void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
116 {
117 BN_ULONG *rr;
118
119#ifdef BN_COUNT
120printf(" bn_mul_normal %d * %d\n",na,nb);
121#endif
122
123 if (na < nb)
124 {
125 int itmp;
126 BN_ULONG *ltmp;
127
128 itmp=na; na=nb; nb=itmp;
129 ltmp=a; a=b; b=ltmp;
130
131 }
132 rr= &(r[na]);
133 rr[0]=bn_mul_words(r,a,na,b[0]);
134
135 for (;;)
136 {
137 if (--nb <= 0) return;
138 rr[1]=bn_mul_add_words(&(r[1]),a,na,b[1]);
139 if (--nb <= 0) return;
140 rr[2]=bn_mul_add_words(&(r[2]),a,na,b[2]);
141 if (--nb <= 0) return;
142 rr[3]=bn_mul_add_words(&(r[3]),a,na,b[3]);
143 if (--nb <= 0) return;
144 rr[4]=bn_mul_add_words(&(r[4]),a,na,b[4]);
145 rr+=4;
146 r+=4;
147 b+=4;
148 }
149 }
150
151#if 1
152void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
153 {
154#ifdef BN_COUNT
155printf(" bn_mul_low_normal %d * %d\n",n,n);
156#endif
157 bn_mul_words(r,a,n,b[0]);
158
159 for (;;)
160 {
161 if (--n <= 0) return;
162 bn_mul_add_words(&(r[1]),a,n,b[1]);
163 if (--n <= 0) return;
164 bn_mul_add_words(&(r[2]),a,n,b[2]);
165 if (--n <= 0) return;
166 bn_mul_add_words(&(r[3]),a,n,b[3]);
167 if (--n <= 0) return;
168 bn_mul_add_words(&(r[4]),a,n,b[4]);
169 r+=4;
170 b+=4;
171 }
172 }
173#endif
diff --git a/src/lib/libcrypto/bn/old/build b/src/lib/libcrypto/bn/old/build
index 8cd99e5f17..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/build
+++ b/src/lib/libcrypto/bn/old/build
@@ -1,3 +0,0 @@
1#!/bin/sh -x
2
3gcc -g -I../../include test.c -L../.. -lcrypto
diff --git a/src/lib/libcrypto/bn/old/info b/src/lib/libcrypto/bn/old/info
index 5ac99c3b23..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/info
+++ b/src/lib/libcrypto/bn/old/info
@@ -1,22 +0,0 @@
1Given A1A0 * B1B0 == S3S2S1S0
2
3S0= low(A0*B0)
4S1= low( (A1-A0)*(B0-B1)) +low( A1*B1) +high(A0*B0)
5S2= high((A1-A0)*(B0-B1)) +high(A1*B1) +low( A1*B1)
6S3= high(A1*B1);
7
8Assume we know S1 and S0, and can calulate A1*B1 and high((A1-A0)*(B0-B1))
9
10k0= S0 == low(A0*B0)
11k1= S1
12k2= low( A1*B1)
13k3= high(A1*B1)
14k4= high((A1-A0)*(B0-B1))
15
16k1= low((A1-A0)*(B0-B1)) +k2 +high(A0*B0)
17S2= k4 +k3 +k2
18S3= k3
19
20S1-k2= low((A1-A0)*(B0-B1)) +high(A0*B0)
21
22We potentially have a carry or a borrow from S1
diff --git a/src/lib/libcrypto/bn/old/test.works b/src/lib/libcrypto/bn/old/test.works
index 127c7b415d..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/old/test.works
+++ b/src/lib/libcrypto/bn/old/test.works
@@ -1,205 +0,0 @@
1#include <stdio.h>
2#include "cryptlib.h"
3#include "bn_lcl.h"
4
5#define SIZE 128
6
7#define BN_MONT_CTX_set bn_mcs
8#define BN_from_montgomery bn_fm
9#define BN_mod_mul_montgomery bn_mmm
10#undef BN_to_montgomery
11#define BN_to_montgomery(r,a,mont,ctx) bn_mmm(\
12 r,a,(mont)->RR,(mont),ctx)
13
14main()
15 {
16 BIGNUM prime,a,b,r,A,B,R;
17 BN_MONT_CTX *mont;
18 BN_CTX *ctx;
19 int i;
20
21 ctx=BN_CTX_new();
22 BN_init(&prime);
23 BN_init(&a); BN_init(&b); BN_init(&r);
24 BN_init(&A); BN_init(&B); BN_init(&R);
25
26 BN_generate_prime(&prime,SIZE,0,NULL,NULL,NULL,NULL);
27 BN_rand(&A,SIZE,1,0);
28 BN_rand(&B,SIZE,1,0);
29 BN_mod(&A,&A,&prime,ctx);
30 BN_mod(&B,&B,&prime,ctx);
31
32 mont=BN_MONT_CTX_new();
33 BN_MONT_CTX_set(mont,&prime,ctx);
34
35 BN_to_montgomery(&a,&A,mont,ctx);
36 BN_to_montgomery(&b,&B,mont,ctx);
37
38 BN_mul(&r,&a,&b);
39 BN_print_fp(stdout,&r); printf("\n");
40 BN_from_montgomery(&r,&r,mont,ctx);
41 BN_print_fp(stdout,&r); printf("\n");
42 BN_from_montgomery(&r,&r,mont,ctx);
43 BN_print_fp(stdout,&r); printf("\n");
44
45 BN_mod_mul(&R,&A,&B,&prime,ctx);
46
47 BN_print_fp(stdout,&a); printf("\n");
48 BN_print_fp(stdout,&b); printf("\n");
49 BN_print_fp(stdout,&prime); printf("\n");
50 BN_print_fp(stdout,&r); printf("\n\n");
51
52 BN_print_fp(stdout,&A); printf("\n");
53 BN_print_fp(stdout,&B); printf("\n");
54 BN_print_fp(stdout,&prime); printf("\n");
55 BN_print_fp(stdout,&R); printf("\n\n");
56
57 BN_mul(&r,&a,&b);
58 BN_print_fp(stdout,&r); printf(" <- BA*DC\n");
59 BN_copy(&A,&r);
60 i=SIZE/2;
61 BN_mask_bits(&A,i*2);
62// BN_print_fp(stdout,&A); printf(" <- low(BA*DC)\n");
63 bn_do_lower(&r,&a,&b,&A,i);
64// BN_print_fp(stdout,&r); printf(" <- low(BA*DC)\n");
65 }
66
67int bn_mul_low(r,a,b,low,i)
68BIGNUM *r,*a,*b,*low;
69int i;
70 {
71 int w;
72 BIGNUM Kh,Km,t1,t2,h,ah,al,bh,bl,l,m,s0,s1;
73
74 BN_init(&Kh); BN_init(&Km); BN_init(&t1); BN_init(&t2); BN_init(&l);
75 BN_init(&ah); BN_init(&al); BN_init(&bh); BN_init(&bl); BN_init(&h);
76 BN_init(&m); BN_init(&s0); BN_init(&s1);
77
78 BN_copy(&al,a); BN_mask_bits(&al,i); BN_rshift(&ah,a,i);
79 BN_copy(&bl,b); BN_mask_bits(&bl,i); BN_rshift(&bh,b,i);
80
81
82 BN_sub(&t1,&al,&ah);
83 BN_sub(&t2,&bh,&bl);
84 BN_mul(&m,&t1,&t2);
85 BN_mul(&h,&ah,&bh);
86
87 BN_copy(&s0,low); BN_mask_bits(&s0,i);
88 BN_rshift(&s1,low,i);
89
90 BN_add(&t1,&h,&m);
91 BN_add(&t1,&t1,&s0);
92
93 BN_copy(&t2,&t1); BN_mask_bits(&t2,i);
94 BN_sub(&t1,&s1,&t2);
95 BN_lshift(&t1,&t1,i);
96 BN_add(&t1,&t1,&s0);
97 if (t1.neg)
98 {
99 BN_lshift(&t2,BN_value_one(),i*2);
100 BN_add(&t1,&t2,&t1);
101 BN_mask_bits(&t1,i*2);
102 }
103
104 BN_free(&Kh); BN_free(&Km); BN_free(&t1); BN_free(&t2);
105 BN_free(&ah); BN_free(&al); BN_free(&bh); BN_free(&bl);
106 }
107
108int BN_mod_mul_montgomery(r,a,b,mont,ctx)
109BIGNUM *r,*a,*b;
110BN_MONT_CTX *mont;
111BN_CTX *ctx;
112 {
113 BIGNUM *tmp;
114
115 tmp= &(ctx->bn[ctx->tos++]);
116
117 if (a == b)
118 {
119 if (!BN_sqr(tmp,a,ctx)) goto err;
120 }
121 else
122 {
123 if (!BN_mul(tmp,a,b)) goto err;
124 }
125 /* reduce from aRR to aR */
126 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
127 ctx->tos--;
128 return(1);
129err:
130 return(0);
131 }
132
133int BN_from_montgomery(r,a,mont,ctx)
134BIGNUM *r;
135BIGNUM *a;
136BN_MONT_CTX *mont;
137BN_CTX *ctx;
138 {
139 BIGNUM z1;
140 BIGNUM *t1,*t2;
141 BN_ULONG *ap,*bp,*rp;
142 int j,i,bl,al;
143
144 BN_init(&z1);
145 t1= &(ctx->bn[ctx->tos]);
146 t2= &(ctx->bn[ctx->tos+1]);
147
148 if (!BN_copy(t1,a)) goto err;
149 /* can cheat */
150 BN_mask_bits(t1,mont->ri);
151 if (!BN_mul(t2,t1,mont->Ni)) goto err;
152 BN_mask_bits(t2,mont->ri);
153
154 if (!BN_mul(t1,t2,mont->N)) goto err;
155 if (!BN_add(t2,t1,a)) goto err;
156
157 /* At this point, t2 has the bottom ri bits set to zero.
158 * This means that the bottom ri bits == the 1^ri minus the bottom
159 * ri bits of a.
160 * This means that only the bits above 'ri' in a need to be added,
161 * and XXXXXXXXXXXXXXXXXXXXXXXX
162 */
163BN_print_fp(stdout,t2); printf("\n");
164 BN_rshift(r,t2,mont->ri);
165
166 if (BN_ucmp(r,mont->N) >= 0)
167 bn_qsub(r,r,mont->N);
168
169 return(1);
170err:
171 return(0);
172 }
173
174int BN_MONT_CTX_set(mont,mod,ctx)
175BN_MONT_CTX *mont;
176BIGNUM *mod;
177BN_CTX *ctx;
178 {
179 BIGNUM *Ri=NULL,*R=NULL;
180
181 if (mont->RR == NULL) mont->RR=BN_new();
182 if (mont->N == NULL) mont->N=BN_new();
183
184 R=mont->RR; /* grab RR as a temp */
185 BN_copy(mont->N,mod); /* Set N */
186
187 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
188 BN_lshift(R,BN_value_one(),mont->ri); /* R */
189 if ((Ri=BN_mod_inverse(NULL,R,mod,ctx)) == NULL) goto err;/* Ri */
190 BN_lshift(Ri,Ri,mont->ri); /* R*Ri */
191 bn_qsub(Ri,Ri,BN_value_one()); /* R*Ri - 1 */
192 BN_div(Ri,NULL,Ri,mod,ctx);
193 if (mont->Ni != NULL) BN_free(mont->Ni);
194 mont->Ni=Ri; /* Ni=(R*Ri-1)/N */
195
196 /* setup RR for conversions */
197 BN_lshift(mont->RR,BN_value_one(),mont->ri*2);
198 BN_mod(mont->RR,mont->RR,mont->N,ctx);
199
200 return(1);
201err:
202 return(0);
203 }
204
205
diff --git a/src/lib/libcrypto/bn/test.c b/src/lib/libcrypto/bn/test.c
index a048b9f878..e69de29bb2 100644
--- a/src/lib/libcrypto/bn/test.c
+++ b/src/lib/libcrypto/bn/test.c
@@ -1,241 +0,0 @@
1#include <stdio.h>
2#include "cryptlib.h"
3#include "bn_lcl.h"
4
5#define SIZE 32
6
7#define BN_MONT_CTX_set bn_mcs
8#define BN_from_montgomery bn_fm
9#define BN_mod_mul_montgomery bn_mmm
10#undef BN_to_montgomery
11#define BN_to_montgomery(r,a,mont,ctx) bn_mmm(\
12 r,a,(mont)->RR,(mont),ctx)
13
14main()
15 {
16 BIGNUM prime,a,b,r,A,B,R;
17 BN_MONT_CTX *mont;
18 BN_CTX *ctx;
19 int i;
20
21 ctx=BN_CTX_new();
22 BN_init(&prime);
23 BN_init(&a); BN_init(&b); BN_init(&r);
24 BN_init(&A); BN_init(&B); BN_init(&R);
25
26 BN_generate_prime(&prime,SIZE,0,NULL,NULL,NULL,NULL);
27 BN_rand(&A,SIZE,1,0);
28 BN_rand(&B,SIZE,1,0);
29 BN_mod(&A,&A,&prime,ctx);
30 BN_mod(&B,&B,&prime,ctx);
31
32 i=A.top;
33 BN_mul(&R,&A,&B,ctx);
34 BN_mask_bits(&R,i*BN_BITS2);
35
36
37 BN_print_fp(stdout,&A); printf(" <- a\n");
38 BN_print_fp(stdout,&B); printf(" <- b\n");
39 BN_mul_high(&r,&A,&B,&R,i);
40 BN_print_fp(stdout,&r); printf(" <- high(BA*DC)\n");
41
42 BN_mask_bits(&A,i*32);
43 BN_mask_bits(&B,i*32);
44
45 BN_mul(&R,&A,&B);
46 BN_rshift(&R,&R,i*32);
47 BN_print_fp(stdout,&R); printf(" <- norm BA*DC\n");
48 BN_sub(&R,&R,&r);
49 BN_print_fp(stdout,&R); printf(" <- diff\n");
50 }
51
52#if 0
53int bn_mul_high(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *low, int words)
54 {
55 int i;
56 BIGNUM t1,t2,t3,h,ah,al,bh,bl,m,s0,s1;
57
58 BN_init(&al); BN_init(&ah);
59 BN_init(&bl); BN_init(&bh);
60 BN_init(&t1); BN_init(&t2); BN_init(&t3);
61 BN_init(&s0); BN_init(&s1);
62 BN_init(&h); BN_init(&m);
63
64 i=a->top;
65 if (i >= words)
66 {
67 al.top=words;
68 ah.top=a->top-words;
69 ah.d= &(a->d[ah.top]);
70 }
71 else
72 al.top=i;
73 al.d=a->d;
74
75 i=b->top;
76 if (i >= words)
77 {
78 bl.top=words;
79 bh.top=i-words;
80 bh.d= &(b->d[bh.top]);
81 }
82 else
83 bl.top=i;
84 bl.d=b->d;
85
86 i=low->top;
87 if (i >= words)
88 {
89 s0.top=words;
90 s1.top=i-words;
91 s1.d= &(low->d[s1.top]);
92 }
93 else
94 s0.top=i;
95 s0.d=low->d;
96
97al.max=al.top; ah.max=ah.top;
98bl.max=bl.top; bh.max=bh.top;
99s0.max=bl.top; s1.max=bh.top;
100
101 /* Calculate (al-ah)*(bh-bl) */
102 BN_sub(&t1,&al,&ah);
103 BN_sub(&t2,&bh,&bl);
104 BN_mul(&m,&t1,&t2);
105
106 /* Calculate ah*bh */
107 BN_mul(&h,&ah,&bh);
108
109 /* s0 == low(al*bl)
110 * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl)
111 * We know s0 and s1 so the only unknown is high(al*bl)
112 * high(al*bl) == s1 - low(ah*bh+(al-ah)*(bh-bl)+s0)
113 */
114 BN_add(&m,&m,&h);
115 BN_add(&t2,&m,&s0);
116 /* Quick and dirty mask off of high words */
117 t3.d=t2.d;
118 t3.top=(t2.top > words)?words:t2.top;
119 t3.neg=t2.neg;
120t3.max=t3.top;
121/* BN_print_fp(stdout,&s1); printf(" s1\n"); */
122/* BN_print_fp(stdout,&t2); printf(" middle value\n"); */
123/* BN_print_fp(stdout,&t3); printf(" low middle value\n"); */
124 BN_sub(&t1,&s1,&t3);
125
126 if (t1.neg)
127 {
128/*printf("neg fixup\n"); BN_print_fp(stdout,&t1); printf(" before\n"); */
129 BN_lshift(&t2,BN_value_one(),words*32);
130 BN_add(&t1,&t2,&t1);
131 BN_mask_bits(&t1,words*32);
132/* BN_print_fp(stdout,&t1); printf(" after\n"); */
133 }
134 /* al*bl == high(al*bl)<<words+s0 */
135 BN_lshift(&t1,&t1,words*32);
136 BN_add(&t1,&t1,&s0);
137
138 /* We now have
139 * al*bl - t1
140 * (al-ah)*(bh-bl)+ah*bh - m
141 * ah*bh - h
142 */
143 BN_copy(r,&t1);
144 BN_mask_bits(r,words*32*2);
145
146 /*BN_lshift(&m,&m,words*/
147
148 BN_free(&t1); BN_free(&t2);
149 BN_free(&m); BN_free(&h);
150 }
151
152int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_MONT_CTX *mont,
153 BN_CTX *ctx)
154 {
155 BIGNUM *tmp;
156
157 tmp= &(ctx->bn[ctx->tos++]);
158
159 if (a == b)
160 {
161 if (!BN_sqr(tmp,a,ctx)) goto err;
162 }
163 else
164 {
165 if (!BN_mul(tmp,a,b)) goto err;
166 }
167 /* reduce from aRR to aR */
168 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
169 ctx->tos--;
170 return(1);
171err:
172 return(0);
173 }
174
175int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx)
176 {
177 BIGNUM z1;
178 BIGNUM *t1,*t2;
179 BN_ULONG *ap,*bp,*rp;
180 int j,i,bl,al;
181
182 BN_init(&z1);
183 t1= &(ctx->bn[ctx->tos]);
184 t2= &(ctx->bn[ctx->tos+1]);
185
186 if (!BN_copy(t1,a)) goto err;
187 /* can cheat */
188 BN_mask_bits(t1,mont->ri);
189 if (!BN_mul(t2,t1,mont->Ni)) goto err;
190 BN_mask_bits(t2,mont->ri);
191
192 if (!BN_mul(t1,t2,mont->N)) goto err;
193 if (!BN_add(t2,t1,a)) goto err;
194
195 /* At this point, t2 has the bottom ri bits set to zero.
196 * This means that the bottom ri bits == the 1^ri minus the bottom
197 * ri bits of a.
198 * This means that only the bits above 'ri' in a need to be added,
199 * and XXXXXXXXXXXXXXXXXXXXXXXX
200 */
201BN_print_fp(stdout,t2); printf("\n");
202 BN_rshift(r,t2,mont->ri);
203
204 if (BN_ucmp(r,mont->N) >= 0)
205 BN_usub(r,r,mont->N);
206
207 return(1);
208err:
209 return(0);
210 }
211
212int BN_MONT_CTX_set(BN_MONT_CTX *mont, BIGNUM *mod, BN_CTX *ctx)
213 {
214 BIGNUM *Ri=NULL,*R=NULL;
215
216 if (mont->RR == NULL) mont->RR=BN_new();
217 if (mont->N == NULL) mont->N=BN_new();
218
219 R=mont->RR; /* grab RR as a temp */
220 BN_copy(mont->N,mod); /* Set N */
221
222 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
223 BN_lshift(R,BN_value_one(),mont->ri); /* R */
224 if ((Ri=BN_mod_inverse(NULL,R,mod,ctx)) == NULL) goto err;/* Ri */
225 BN_lshift(Ri,Ri,mont->ri); /* R*Ri */
226 BN_usub(Ri,Ri,BN_value_one()); /* R*Ri - 1 */
227 BN_div(Ri,NULL,Ri,mod,ctx);
228 if (mont->Ni != NULL) BN_free(mont->Ni);
229 mont->Ni=Ri; /* Ni=(R*Ri-1)/N */
230
231 /* setup RR for conversions */
232 BN_lshift(mont->RR,BN_value_one(),mont->ri*2);
233 BN_mod(mont->RR,mont->RR,mont->N,ctx);
234
235 return(1);
236err:
237 return(0);
238 }
239
240
241#endif
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl
index f23de89e33..506708c37f 100644
--- a/src/lib/libcrypto/buffer/Makefile.ssl
+++ b/src/lib/libcrypto/buffer/Makefile.ssl
@@ -83,4 +83,5 @@ buffer.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
83buffer.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 83buffer.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
84buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85buffer.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 85buffer.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
86buffer.o: ../../include/openssl/stack.h ../cryptlib.h 86buffer.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87buffer.o: ../cryptlib.h
diff --git a/src/lib/libcrypto/cast/c_ecb.c b/src/lib/libcrypto/cast/c_ecb.c
index 33182f2b71..0b3da9ad87 100644
--- a/src/lib/libcrypto/cast/c_ecb.c
+++ b/src/lib/libcrypto/cast/c_ecb.c
@@ -60,7 +60,7 @@
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63char *CAST_version="CAST" OPENSSL_VERSION_PTEXT; 63const char *CAST_version="CAST" OPENSSL_VERSION_PTEXT;
64 64
65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, 65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
66 CAST_KEY *ks, int enc) 66 CAST_KEY *ks, int enc)
diff --git a/src/lib/libcrypto/cast/cast_lcl.h b/src/lib/libcrypto/cast/cast_lcl.h
index 83cf382a91..cfe3842e91 100644
--- a/src/lib/libcrypto/cast/cast_lcl.h
+++ b/src/lib/libcrypto/cast/cast_lcl.h
@@ -216,11 +216,11 @@
216 } 216 }
217#endif 217#endif
218 218
219OPENSSL_EXTERN CAST_LONG CAST_S_table0[256]; 219OPENSSL_EXTERN const CAST_LONG CAST_S_table0[256];
220OPENSSL_EXTERN CAST_LONG CAST_S_table1[256]; 220OPENSSL_EXTERN const CAST_LONG CAST_S_table1[256];
221OPENSSL_EXTERN CAST_LONG CAST_S_table2[256]; 221OPENSSL_EXTERN const CAST_LONG CAST_S_table2[256];
222OPENSSL_EXTERN CAST_LONG CAST_S_table3[256]; 222OPENSSL_EXTERN const CAST_LONG CAST_S_table3[256];
223OPENSSL_EXTERN CAST_LONG CAST_S_table4[256]; 223OPENSSL_EXTERN const CAST_LONG CAST_S_table4[256];
224OPENSSL_EXTERN CAST_LONG CAST_S_table5[256]; 224OPENSSL_EXTERN const CAST_LONG CAST_S_table5[256];
225OPENSSL_EXTERN CAST_LONG CAST_S_table6[256]; 225OPENSSL_EXTERN const CAST_LONG CAST_S_table6[256];
226OPENSSL_EXTERN CAST_LONG CAST_S_table7[256]; 226OPENSSL_EXTERN const CAST_LONG CAST_S_table7[256];
diff --git a/src/lib/libcrypto/cast/cast_s.h b/src/lib/libcrypto/cast/cast_s.h
index 9af28972c5..c483fd5e43 100644
--- a/src/lib/libcrypto/cast/cast_s.h
+++ b/src/lib/libcrypto/cast/cast_s.h
@@ -55,7 +55,7 @@
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 */
58OPENSSL_GLOBAL CAST_LONG CAST_S_table0[256]={ 58OPENSSL_GLOBAL const CAST_LONG CAST_S_table0[256]={
59 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a, 59 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a,
60 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949, 60 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949,
61 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675, 61 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675,
@@ -121,7 +121,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table0[256]={
121 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d, 121 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d,
122 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf, 122 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf,
123 }; 123 };
124OPENSSL_GLOBAL CAST_LONG CAST_S_table1[256]={ 124OPENSSL_GLOBAL const CAST_LONG CAST_S_table1[256]={
125 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380, 125 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380,
126 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651, 126 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651,
127 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba, 127 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba,
@@ -187,7 +187,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table1[256]={
187 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef, 187 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef,
188 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1, 188 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1,
189 }; 189 };
190OPENSSL_GLOBAL CAST_LONG CAST_S_table2[256]={ 190OPENSSL_GLOBAL const CAST_LONG CAST_S_table2[256]={
191 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907, 191 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907,
192 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90, 192 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90,
193 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae, 193 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae,
@@ -253,7 +253,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table2[256]={
253 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5, 253 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5,
254 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783, 254 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783,
255 }; 255 };
256OPENSSL_GLOBAL CAST_LONG CAST_S_table3[256]={ 256OPENSSL_GLOBAL const CAST_LONG CAST_S_table3[256]={
257 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298, 257 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298,
258 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1, 258 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1,
259 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120, 259 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120,
@@ -319,7 +319,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table3[256]={
319 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e, 319 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e,
320 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2, 320 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2,
321 }; 321 };
322OPENSSL_GLOBAL CAST_LONG CAST_S_table4[256]={ 322OPENSSL_GLOBAL const CAST_LONG CAST_S_table4[256]={
323 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911, 323 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911,
324 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f, 324 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f,
325 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00, 325 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00,
@@ -385,7 +385,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table4[256]={
385 0xe822fe15,0x88570983,0x750e6249,0xda627e55, 385 0xe822fe15,0x88570983,0x750e6249,0xda627e55,
386 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4, 386 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4,
387 }; 387 };
388OPENSSL_GLOBAL CAST_LONG CAST_S_table5[256]={ 388OPENSSL_GLOBAL const CAST_LONG CAST_S_table5[256]={
389 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c, 389 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c,
390 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac, 390 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac,
391 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9, 391 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9,
@@ -451,7 +451,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table5[256]={
451 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454, 451 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454,
452 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f, 452 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f,
453 }; 453 };
454OPENSSL_GLOBAL CAST_LONG CAST_S_table6[256]={ 454OPENSSL_GLOBAL const CAST_LONG CAST_S_table6[256]={
455 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693, 455 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693,
456 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f, 456 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f,
457 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82, 457 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82,
@@ -517,7 +517,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table6[256]={
517 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada, 517 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada,
518 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3, 518 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3,
519 }; 519 };
520OPENSSL_GLOBAL CAST_LONG CAST_S_table7[256]={ 520OPENSSL_GLOBAL const CAST_LONG CAST_S_table7[256]={
521 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095, 521 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095,
522 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5, 522 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5,
523 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174, 523 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174,
diff --git a/src/lib/libcrypto/cast/cast_spd.c b/src/lib/libcrypto/cast/cast_spd.c
index c0726906c2..0af915cf20 100644
--- a/src/lib/libcrypto/cast/cast_spd.c
+++ b/src/lib/libcrypto/cast/cast_spd.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libcrypto/cast/castopts.c b/src/lib/libcrypto/cast/castopts.c
index 642e9725af..c783796610 100644
--- a/src/lib/libcrypto/cast/castopts.c
+++ b/src/lib/libcrypto/cast/castopts.c
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
252 } 252 }
253 253
254#ifndef TIMES 254#ifndef TIMES
255 fprintf(stderr,"To get the most acurate results, try to run this\n"); 255 fprintf(stderr,"To get the most accurate results, try to run this\n");
256 fprintf(stderr,"program when this computer is idle.\n"); 256 fprintf(stderr,"program when this computer is idle.\n");
257#endif 257#endif
258 258
diff --git a/src/lib/libcrypto/cast/casttest.c b/src/lib/libcrypto/cast/casttest.c
index 3244b119e9..ab2aeac606 100644
--- a/src/lib/libcrypto/cast/casttest.c
+++ b/src/lib/libcrypto/cast/casttest.c
@@ -71,32 +71,32 @@ int main(int argc, char *argv[])
71 71
72#define FULL_TEST 72#define FULL_TEST
73 73
74unsigned char k[16]={ 74static unsigned char k[16]={
75 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 75 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
76 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A 76 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A
77 }; 77 };
78 78
79unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; 79static unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
80 80
81int k_len[3]={16,10,5}; 81static int k_len[3]={16,10,5};
82unsigned char c[3][8]={ 82static unsigned char c[3][8]={
83 {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2}, 83 {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2},
84 {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B}, 84 {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B},
85 {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}, 85 {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E},
86 }; 86 };
87unsigned char out[80]; 87static unsigned char out[80];
88 88
89unsigned char in_a[16]={ 89static unsigned char in_a[16]={
90 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 90 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
91 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; 91 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
92unsigned char in_b[16]={ 92static unsigned char in_b[16]={
93 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 93 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
94 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; 94 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
95 95
96unsigned char c_a[16]={ 96static unsigned char c_a[16]={
97 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6, 97 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6,
98 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92}; 98 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92};
99unsigned char c_b[16]={ 99static unsigned char c_b[16]={
100 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71, 100 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71,
101 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E}; 101 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E};
102 102
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h
index 93bd9c34c8..811cb5833d 100644
--- a/src/lib/libcrypto/comp/comp.h
+++ b/src/lib/libcrypto/comp/comp.h
@@ -17,6 +17,7 @@ typedef struct comp_method_st
17 int (*compress)(); 17 int (*compress)();
18 int (*expand)(); 18 int (*expand)();
19 long (*ctrl)(); 19 long (*ctrl)();
20 long (*callback_ctrl)();
20 } COMP_METHOD; 21 } COMP_METHOD;
21 22
22typedef struct comp_ctx_st 23typedef struct comp_ctx_st
diff --git a/src/lib/libcrypto/conf/conf.c b/src/lib/libcrypto/conf/conf.c
index 7d8b89168a..3031fa3b44 100644
--- a/src/lib/libcrypto/conf/conf.c
+++ b/src/lib/libcrypto/conf/conf.c
@@ -86,28 +86,25 @@ const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
86LHASH *CONF_load(LHASH *h, const char *file, long *line) 86LHASH *CONF_load(LHASH *h, const char *file, long *line)
87 { 87 {
88 LHASH *ltmp; 88 LHASH *ltmp;
89 FILE *in=NULL; 89 BIO *in=NULL;
90 90
91#ifdef VMS 91#ifdef VMS
92 in=fopen(file,"r"); 92 in=BIO_new_file(file, "r");
93#else 93#else
94 in=fopen(file,"rb"); 94 in=BIO_new_file(file, "rb");
95#endif 95#endif
96 if (in == NULL) 96 if (in == NULL)
97 { 97 {
98 SYSerr(SYS_F_FOPEN,get_last_sys_error());
99 ERR_set_error_data(BUF_strdup(file),
100 ERR_TXT_MALLOCED|ERR_TXT_STRING);
101 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); 98 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
102 return NULL; 99 return NULL;
103 } 100 }
104 101
105 ltmp = CONF_load_fp(h, in, line); 102 ltmp = CONF_load_bio(h, in, line);
106 fclose(in); 103 BIO_free(in);
107 104
108 return ltmp; 105 return ltmp;
109} 106}
110 107#ifndef NO_FP_API
111LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line) 108LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
112{ 109{
113 BIO *btmp; 110 BIO *btmp;
@@ -120,6 +117,7 @@ LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
120 BIO_free(btmp); 117 BIO_free(btmp);
121 return ltmp; 118 return ltmp;
122} 119}
120#endif
123 121
124LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line) 122LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line)
125 { 123 {
@@ -338,7 +336,7 @@ again:
338 ERR_R_MALLOC_FAILURE); 336 ERR_R_MALLOC_FAILURE);
339 goto err; 337 goto err;
340 } 338 }
341 vv=(CONF_VALUE *)lh_insert(ret,(char *)v); 339 vv=(CONF_VALUE *)lh_insert(ret,v);
342 if (vv != NULL) 340 if (vv != NULL)
343 { 341 {
344 sk_CONF_VALUE_delete_ptr(ts,vv); 342 sk_CONF_VALUE_delete_ptr(ts,vv);
@@ -380,7 +378,7 @@ char *CONF_get_string(LHASH *conf, char *section, char *name)
380 { 378 {
381 vv.name=name; 379 vv.name=name;
382 vv.section=section; 380 vv.section=section;
383 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); 381 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
384 if (v != NULL) return(v->value); 382 if (v != NULL) return(v->value);
385 if (strcmp(section,"ENV") == 0) 383 if (strcmp(section,"ENV") == 0)
386 { 384 {
@@ -390,7 +388,7 @@ char *CONF_get_string(LHASH *conf, char *section, char *name)
390 } 388 }
391 vv.section="default"; 389 vv.section="default";
392 vv.name=name; 390 vv.name=name;
393 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); 391 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
394 if (v != NULL) 392 if (v != NULL)
395 return(v->value); 393 return(v->value);
396 else 394 else
@@ -407,7 +405,7 @@ static CONF_VALUE *get_section(LHASH *conf, char *section)
407 if ((conf == NULL) || (section == NULL)) return(NULL); 405 if ((conf == NULL) || (section == NULL)) return(NULL);
408 vv.name=NULL; 406 vv.name=NULL;
409 vv.section=section; 407 vv.section=section;
410 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); 408 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
411 return(v); 409 return(v);
412 } 410 }
413 411
@@ -445,12 +443,12 @@ void CONF_free(LHASH *conf)
445 443
446 conf->down_load=0; /* evil thing to make sure the 'Free()' 444 conf->down_load=0; /* evil thing to make sure the 'Free()'
447 * works as expected */ 445 * works as expected */
448 lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf); 446 lh_doall_arg(conf,(void (*)())value_free_hash,conf);
449 447
450 /* We now have only 'section' entries in the hash table. 448 /* We now have only 'section' entries in the hash table.
451 * Due to problems with */ 449 * Due to problems with */
452 450
453 lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf); 451 lh_doall_arg(conf,(void (*)())value_free_stack,conf);
454 lh_free(conf); 452 lh_free(conf);
455 } 453 }
456 454
@@ -458,7 +456,7 @@ static void value_free_hash(CONF_VALUE *a, LHASH *conf)
458 { 456 {
459 if (a->name != NULL) 457 if (a->name != NULL)
460 { 458 {
461 a=(CONF_VALUE *)lh_delete(conf,(char *)a); 459 a=(CONF_VALUE *)lh_delete(conf,a);
462 } 460 }
463 } 461 }
464 462
@@ -710,7 +708,7 @@ static CONF_VALUE *new_section(LHASH *conf, char *section)
710 v->name=NULL; 708 v->name=NULL;
711 v->value=(char *)sk; 709 v->value=(char *)sk;
712 710
713 vv=(CONF_VALUE *)lh_insert(conf,(char *)v); 711 vv=(CONF_VALUE *)lh_insert(conf,v);
714 if (vv != NULL) 712 if (vv != NULL)
715 { 713 {
716#if !defined(NO_STDIO) && !defined(WIN16) 714#if !defined(NO_STDIO) && !defined(WIN16)
diff --git a/src/lib/libcrypto/conf/conf.h b/src/lib/libcrypto/conf/conf.h
index e7c5150097..21831a92a3 100644
--- a/src/lib/libcrypto/conf/conf.h
+++ b/src/lib/libcrypto/conf/conf.h
@@ -78,7 +78,9 @@ typedef struct
78DECLARE_STACK_OF(CONF_VALUE) 78DECLARE_STACK_OF(CONF_VALUE)
79 79
80LHASH *CONF_load(LHASH *conf,const char *file,long *eline); 80LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
81#ifndef NO_FP_API
81LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); 82LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
83#endif
82LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); 84LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
83STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section); 85STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section);
84char *CONF_get_string(LHASH *conf,char *group,char *name); 86char *CONF_get_string(LHASH *conf,char *group,char *name);
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 356c476a99..a8f29f1e65 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -92,7 +92,9 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
92 "getservbyname", 92 "getservbyname",
93 "readdir", 93 "readdir",
94 "RSA_blinding", 94 "RSA_blinding",
95#if CRYPTO_NUM_LOCKS != 24 95 "dh",
96 "debug_malloc2",
97#if CRYPTO_NUM_LOCKS != 26
96# error "Inconsistency between crypto.h and cryptlib.c" 98# error "Inconsistency between crypto.h and cryptlib.c"
97#endif 99#endif
98 }; 100 };
@@ -181,7 +183,7 @@ unsigned long CRYPTO_thread_id(void)
181 ret=(unsigned long)GetCurrentTask(); 183 ret=(unsigned long)GetCurrentTask();
182#elif defined(WIN32) 184#elif defined(WIN32)
183 ret=(unsigned long)GetCurrentThreadId(); 185 ret=(unsigned long)GetCurrentThreadId();
184#elif defined(MSDOS) 186#elif defined(GETPID_IS_MEANINGLESS)
185 ret=1L; 187 ret=1L;
186#else 188#else
187 ret=(unsigned long)getpid(); 189 ret=(unsigned long)getpid();
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
index bf916528eb..79d86771e8 100644
--- a/src/lib/libcrypto/crypto-lib.com
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -14,7 +14,14 @@ $!
14$! It was re-written so it would try to determine what "C" compiler to use 14$! It was re-written so it would try to determine what "C" compiler to use
15$! or you can specify which "C" compiler to use. 15$! or you can specify which "C" compiler to use.
16$! 16$!
17$! Specify RSAREF as P1 to compile with the RSAREF library instead of 17$! Specify the following as P1 to build just that part or ALL to just
18$! build everything.
19$!
20$! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
21$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE
22$! ALL To do both LIBRARY and APPS
23$!
24$! Specify RSAREF as P2 to compile with the RSAREF library instead of
18$! the regular one. If you specify NORSAREF it will compile with the 25$! the regular one. If you specify NORSAREF it will compile with the
19$! regular RSAREF routines. (Note: If you are in the United States 26$! regular RSAREF routines. (Note: If you are in the United States
20$! you MUST compile with RSAREF unless you have a license from RSA). 27$! you MUST compile with RSAREF unless you have a license from RSA).
@@ -26,10 +33,10 @@ $! directory structure stored. You have to extract the file
26$! into the [.RSAREF] directory under the root directory as that 33$! into the [.RSAREF] directory under the root directory as that
27$! is where the scripts will look for the files. 34$! is where the scripts will look for the files.
28$! 35$!
29$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger 36$! Specify DEBUG or NODEBUG as P3 to compile with or without debugger
30$! information. 37$! information.
31$! 38$!
32$! Specify which compiler at P3 to try to compile under. 39$! Specify which compiler at P4 to try to compile under.
33$! 40$!
34$! VAXC For VAX C. 41$! VAXC For VAX C.
35$! DECC For DEC C. 42$! DECC For DEC C.
@@ -38,15 +45,15 @@ $!
38$! If you don't speficy a compiler, it will try to determine which 45$! If you don't speficy a compiler, it will try to determine which
39$! "C" compiler to use. 46$! "C" compiler to use.
40$! 47$!
41$! P4, if defined, sets a TCP/IP library to use, through one of the following 48$! P5, if defined, sets a TCP/IP library to use, through one of the following
42$! keywords: 49$! keywords:
43$! 50$!
44$! UCX for UCX 51$! UCX for UCX
45$! SOCKETSHR for SOCKETSHR+NETLIB 52$! SOCKETSHR for SOCKETSHR+NETLIB
46$! 53$!
47$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 54$! P6, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
48$! 55$!
49$! P6, if defined, sets a choice of crypto methods to compile. 56$! P7, if defined, sets a choice of crypto methods to compile.
50$! WARNING: this should only be done to recompile some part of an already 57$! WARNING: this should only be done to recompile some part of an already
51$! fully compiled library. 58$! fully compiled library.
52$! 59$!
@@ -79,12 +86,13 @@ $ ENDIF
79$! 86$!
80$! Define The Different Encryption Types. 87$! Define The Different Encryption Types.
81$! 88$!
82$ ENCRYPT_TYPES = ",MD2,MD5,SHA,MDC2,HMAC,RIPEMD,"+ - 89$ ENCRYPT_TYPES = "Basic,MD2,MD5,SHA,MDC2,HMAC,RIPEMD,"+ -
83 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ - 90 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ -
84 "BN,RSA,DSA,DH,"+ - 91 "BN,RSA,DSA,DH,"+ -
85 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ - 92 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ -
86 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - 93 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
87 "CONF,TXT_DB,PKCS7,PKCS12,COMP" 94 "CONF,TXT_DB,PKCS7,PKCS12,COMP"
95$ ENCRYPT_PROGRAMS = "DES,PKCS7"
88$! 96$!
89$! Check To Make Sure We Have Valid Command Line Parameters. 97$! Check To Make Sure We Have Valid Command Line Parameters.
90$! 98$!
@@ -136,6 +144,14 @@ $! Define The Library Name.
136$! 144$!
137$ LIB_NAME := 'EXE_DIR'LIBCRYPTO.OLB 145$ LIB_NAME := 'EXE_DIR'LIBCRYPTO.OLB
138$! 146$!
147$! Define The CRYPTO-LIB We Are To Use.
148$!
149$ CRYPTO_LIB := 'EXE_DIR'LIBCRYPTO.OLB
150$!
151$! Define The RSAREF-LIB We Are To Use.
152$!
153$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
154$!
139$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library... 155$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library...
140$! 156$!
141$ IF (F$SEARCH(LIB_NAME).EQS."") 157$ IF (F$SEARCH(LIB_NAME).EQS."")
@@ -149,9 +165,16 @@ $! End The Library Check.
149$! 165$!
150$ ENDIF 166$ ENDIF
151$! 167$!
168$! Build our options file for the application
169$!
170$ GOSUB CHECK_OPT_FILE
171$!
152$! Define The Different Encryption "library" Strings. 172$! Define The Different Encryption "library" Strings.
153$! 173$!
154$ LIB_ = "cryptlib,mem,cversion,ex_data,tmdiff,cpt_err" 174$ APPS_DES = "DES/DES,CBC3_ENC"
175$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
176$
177$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,tmdiff,cpt_err"
155$ LIB_MD2 = "md2_dgst,md2_one" 178$ LIB_MD2 = "md2_dgst,md2_one"
156$ LIB_MD5 = "md5_dgst,md5_one" 179$ LIB_MD5 = "md5_dgst,md5_one"
157$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one" 180$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one"
@@ -171,14 +194,14 @@ $ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey"
171$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64" 194$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
172$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64" 195$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
173$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper" 196$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
174$ IF F$TRNLNM("OPENSSL_NO_ASM") .NES. "" THEN LIB_BN_ASM = "bn_asm" 197$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm"
175$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_mul,"+ - 198$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,"+ -
176 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ - 199 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ -
177 "bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+",bn_recp,bn_mont,"+ - 200 "bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+",bn_recp,bn_mont,"+ -
178 "bn_mpi,bn_exp2" 201 "bn_mpi,bn_exp2"
179$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ - 202$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
180 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk" 203 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null"
181$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err" 204$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err,dsa_ossl"
182$ LIB_DH = "dh_gen,dh_key,dh_lib,dh_check,dh_err" 205$ LIB_DH = "dh_gen,dh_key,dh_lib,dh_check,dh_err"
183$ LIB_BUFFER = "buffer,buf_err" 206$ LIB_BUFFER = "buffer,buf_err"
184$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - 207$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
@@ -188,7 +211,7 @@ $ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
188 "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio" ! + ",bss_log" for syslog 211 "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio" ! + ",bss_log" for syslog
189$ LIB_STACK = "stack" 212$ LIB_STACK = "stack"
190$ LIB_LHASH = "lhash,lh_stats" 213$ LIB_LHASH = "lhash,lh_stats"
191$ LIB_RAND = "md_rand,randfile,rand_lib" 214$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd"
192$ LIB_ERR = "err,err_all,err_prn" 215$ LIB_ERR = "err,err_all,err_prn"
193$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err" 216$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
194$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ - 217$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ -
@@ -204,38 +227,39 @@ $ LIB_EVP_2 = "e_ecb_c,e_cbc_c,e_cfb_c,e_ofb_c,"+ -
204 "m_ripemd,"+ - 227 "m_ripemd,"+ -
205 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ - 228 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ -
206 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ - 229 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ -
207 "c_all,evp_lib,bio_ok,evp_pkey,evp_pbe,p5_crpt,p5_crpt2" 230 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
231 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
208$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ - 232$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
209 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,a_bmp,"+ - 233 "a_null,a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,a_bmp,"+ -
210 "a_enum,a_vis,a_utf8,a_sign,a_digest,a_verify,"+ - 234 "a_enum,a_vis,a_utf8,a_sign,a_digest,a_verify,a_mbstr,"+ -
211 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,"+ - 235 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,"+ -
212 "x_name,x_cinf,x_x509,x_crl,x_info,x_spki,nsseq,"+ - 236 "x_name,x_cinf,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ -
213 "d2i_r_pr,i2d_r_pr,d2i_r_pu,i2d_r_pu,"+ - 237 "d2i_r_pr,i2d_r_pr,d2i_r_pu,i2d_r_pu,"+ -
214 "d2i_s_pr,i2d_s_pr,d2i_s_pu,i2d_s_pu,"+ - 238 "d2i_s_pr,i2d_s_pr,d2i_s_pu,i2d_s_pu,"+ -
215 "d2i_pu,d2i_pr,i2d_pu,i2d_pr" 239 "d2i_pu,d2i_pr,i2d_pu,i2d_pr"
216$ LIB_ASN1_2 = "t_req,t_x509,t_crl,t_pkey,"+ - 240$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
217 "p7_i_s,p7_signi,p7_signd,p7_recip,p7_enc_c,p7_evp,"+ - 241 "p7_i_s,p7_signi,p7_signd,p7_recip,p7_enc_c,p7_evp,"+ -
218 "p7_dgst,p7_s_e,p7_enc,p7_lib,"+ - 242 "p7_dgst,p7_s_e,p7_enc,p7_lib,"+ -
219 "f_int,f_string,i2d_dhp,i2d_dsap,d2i_dhp,d2i_dsap,n_pkey,"+ - 243 "f_int,f_string,i2d_dhp,i2d_dsap,d2i_dhp,d2i_dsap,n_pkey,"+ -
220 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ - 244 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ -
221 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,"+ - 245 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ -
222 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey" 246 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey"
223$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err" 247$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err"
224$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ - 248$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ -
225 "x509_obj,x509_req,x509_vfy,"+ - 249 "x509_obj,x509_req,x509spki,x509_vfy,"+ -
226 "x509_set,x509rset,x509_err,"+ - 250 "x509_set,x509rset,x509_err,"+ -
227 "x509name,x509_v3,x509_ext,"+ - 251 "x509name,x509_v3,x509_ext,x509_att,"+ -
228 "x509type,x509_lu,x_all,x509_txt,"+ - 252 "x509type,x509_lu,x_all,x509_txt,"+ -
229 "by_file,by_dir" 253 "x509_trs,by_file,by_dir"
230$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ - 254$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
231 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ - 255 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
232 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld" 256 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info"
233$ LIB_CONF = "conf,conf_err" 257$ LIB_CONF = "conf,conf_err"
234$ LIB_TXT_DB = "txt_db" 258$ LIB_TXT_DB = "txt_db"
235$ LIB_PKCS7 = "pk7_lib,pkcs7err,pk7_doit" 259$ LIB_PKCS7 = "pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,pk7_mime"
236$ LIB_PKCS12 = "p12_add,p12_attr,p12_bags,p12_crpt,p12_crt,p12_decr,"+ - 260$ LIB_PKCS12 = "p12_add,p12_attr,p12_bags,p12_crpt,p12_crt,p12_decr,"+ -
237 "p12_init,p12_key,p12_kiss,p12_lib,p12_mac,p12_mutl,"+ - 261 "p12_init,p12_key,p12_kiss,p12_lib,p12_mac,p12_mutl,"+ -
238 "p12_sbag,p12_utl,pk12err" 262 "p12_sbag,p12_utl,p12_npas,pk12err"
239$ LIB_COMP = "comp_lib,"+ - 263$ LIB_COMP = "comp_lib,"+ -
240 "c_rle,c_zlib" 264 "c_rle,c_zlib"
241$! 265$!
@@ -248,7 +272,8 @@ $ COMPILEWITH_CC5 = ",md2_dgst,md5_dgst,mdc2dgst,sha_dgst,sha1dgst," + -
248$! 272$!
249$! Check To See If We Are Going To Use RSAREF. 273$! Check To See If We Are Going To Use RSAREF.
250$! 274$!
251$ IF (RSAREF.EQS."TRUE" .AND. ENCRYPT_TYPES - "RSA".NES.ENCRYPT_TYPES) 275$ IF (RSAREF.EQS."TRUE" .AND. ENCRYPT_TYPES - "RSA".NES.ENCRYPT_TYPES -
276 .AND. (BUILDALL .EQS. "TRUE" .OR. BUILDALL .EQS. "LIBRARY"))
252$ THEN 277$ THEN
253$! 278$!
254$! Check To See If The File [-.RSAREF]RSAREF.C Is Actually There. 279$! Check To See If The File [-.RSAREF]RSAREF.C Is Actually There.
@@ -340,6 +365,8 @@ $!
340$! Extract The Module Name From The Encryption List. 365$! Extract The Module Name From The Encryption List.
341$! 366$!
342$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES) 367$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES)
368$ IF MODULE_NAME.EQS."Basic" THEN MODULE_NAME = ""
369$ MODULE_NAME1 = MODULE_NAME
343$! 370$!
344$! Check To See If We Are At The End Of The Module List. 371$! Check To See If We Are At The End Of The Module List.
345$! 372$!
@@ -358,20 +385,10 @@ $! Increment The Moudle Counter.
358$! 385$!
359$ MODULE_COUNTER = MODULE_COUNTER + 1 386$ MODULE_COUNTER = MODULE_COUNTER + 1
360$! 387$!
361$! Tell The User What Module We Are Building. 388$! Create The Library and Apps Module Names.
362$!
363$ IF (MODULE_NAME.NES."")
364$ THEN
365$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME," Files."
366$ ENDIF
367$!
368$! Define A File Counter And Set It To "0".
369$!
370$ FILE_COUNTER = 0
371$!
372$! Create The Library Module Name.
373$! 389$!
374$ LIB_MODULE = "LIB_" + MODULE_NAME 390$ LIB_MODULE = "LIB_" + MODULE_NAME
391$ APPS_MODULE = "APPS_" + MODULE_NAME
375$ IF (MODULE_NAME.EQS."ASN1_2") 392$ IF (MODULE_NAME.EQS."ASN1_2")
376$ THEN 393$ THEN
377$ MODULE_NAME = "ASN1" 394$ MODULE_NAME = "ASN1"
@@ -381,6 +398,11 @@ $ THEN
381$ MODULE_NAME = "EVP" 398$ MODULE_NAME = "EVP"
382$ ENDIF 399$ ENDIF
383$! 400$!
401$! Set state (can be LIB and APPS)
402$!
403$ STATE = "LIB"
404$ IF BUILDALL .EQS. "APPS" THEN STATE = "APPS"
405$!
384$! Check if the library module name actually is defined 406$! Check if the library module name actually is defined
385$! 407$!
386$ IF F$TYPE('LIB_MODULE') .EQS. "" 408$ IF F$TYPE('LIB_MODULE') .EQS. ""
@@ -391,22 +413,92 @@ $ WRITE SYS$ERROR ""
391$ GOTO MODULE_NEXT 413$ GOTO MODULE_NEXT
392$ ENDIF 414$ ENDIF
393$! 415$!
416$! Top Of The Module Loop.
417$!
418$ MODULE_AGAIN:
419$!
420$! Tell The User What Module We Are Building.
421$!
422$ IF (MODULE_NAME1.NES."")
423$ THEN
424$ IF STATE .EQS. "LIB"
425$ THEN
426$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Library Files. (",BUILDALL,",",STATE,")"
427$ ELSE IF F$TYPE('APPS_MODULE') .NES. ""
428$ THEN
429$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Applications. (",BUILDALL,",",STATE,")"
430$ ENDIF
431$ ENDIF
432$ ENDIF
433$!
434$! Define A File Counter And Set It To "0".
435$!
436$ FILE_COUNTER = 0
437$ APPLICATION = ""
438$ APPLICATION_COUNTER = 0
439$!
394$! Top Of The File Loop. 440$! Top Of The File Loop.
395$! 441$!
396$ NEXT_FILE: 442$ NEXT_FILE:
397$! 443$!
398$! O.K, Extract The File Name From The File List. 444$! Look in the LIB_MODULE is we're in state LIB
445$!
446$ IF STATE .EQS. "LIB"
447$ THEN
448$!
449$! O.K, Extract The File Name From The File List.
450$!
451$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE')
452$!
453$! else
454$!
455$ ELSE
456$ FILE_NAME = ","
457$!
458$ IF F$TYPE('APPS_MODULE') .NES. ""
459$ THEN
460$!
461$! Extract The File Name From The File List.
462$! This part is a bit more complicated.
399$! 463$!
400$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE') 464$ IF APPLICATION .EQS. ""
465$ THEN
466$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
467$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
468$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
469$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
470$ FILE_COUNTER = 0
471$ ENDIF
472$
473$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
474$! SHOW SYMBOL APPLICATION*
475$!
476$ IF APPLICATION .NES. ";"
477$ THEN
478$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS)
479$ IF FILE_NAME .EQS. ","
480$ THEN
481$ APPLICATION = ""
482$ GOTO NEXT_FILE
483$ ENDIF
484$ ENDIF
485$ ENDIF
486$ ENDIF
401$! 487$!
402$! Check To See If We Are At The End Of The File List. 488$! Check To See If We Are At The End Of The File List.
403$! 489$!
404$ IF (FILE_NAME.EQS.",") 490$ IF (FILE_NAME.EQS.",")
405$ THEN 491$ THEN
406$! 492$!
407$! We Are At The End Of The File List, Goto FILE_DONE. 493$! We Are At The End Of The File List, Change State Or Goto FILE_DONE.
408$! 494$!
409$ GOTO FILE_DONE 495$ IF STATE .EQS. "LIB" .AND. BUILDALL .NES. "LIBRARY"
496$ THEN
497$ STATE = "APPS"
498$ GOTO MODULE_AGAIN
499$ ELSE
500$ GOTO FILE_DONE
501$ ENDIF
410$! 502$!
411$! End The File List Check. 503$! End The File List Check.
412$! 504$!
@@ -458,7 +550,7 @@ $! Tell The User We Are Compiling The File.
458$! 550$!
459$ IF (MODULE_NAME.EQS."") 551$ IF (MODULE_NAME.EQS."")
460$ THEN 552$ THEN
461 WRITE SYS$OUTPUT "Compiling The ",FILE_NAME," File." 553$ WRITE SYS$OUTPUT "Compiling The ",FILE_NAME," File. (",BUILDALL,",",STATE,")"
462$ ENDIF 554$ ENDIF
463$ IF (MODULE_NAME.NES."") 555$ IF (MODULE_NAME.NES."")
464$ THEN 556$ THEN
@@ -490,14 +582,17 @@ $ ENDIF
490$ ENDIF 582$ ENDIF
491$ ENDIF 583$ ENDIF
492$ ENDIF 584$ ENDIF
585$ IF STATE .EQS. "LIB"
586$ THEN
493$! 587$!
494$! Add It To The Library. 588$! Add It To The Library.
495$! 589$!
496$ LIBRARY/REPLACE 'LIB_NAME' 'OBJECT_FILE' 590$ LIBRARY/REPLACE 'LIB_NAME' 'OBJECT_FILE'
497$! 591$!
498$! Time To Clean Up The Object File. 592$! Time To Clean Up The Object File.
499$! 593$!
500$ DELETE 'OBJECT_FILE';* 594$ DELETE 'OBJECT_FILE';*
595$ ENDIF
501$! 596$!
502$! Go Back And Do It Again. 597$! Go Back And Do It Again.
503$! 598$!
@@ -507,6 +602,99 @@ $! All Done With This Library Part.
507$! 602$!
508$ FILE_DONE: 603$ FILE_DONE:
509$! 604$!
605$! Time To Build Some Applications
606$!
607$ IF F$TYPE('APPS_MODULE') .NES. "" .AND. BUILDALL .NES. "LIBRARY"
608$ THEN
609$ APPLICATION_COUNTER = 0
610$ NEXT_APPLICATION:
611$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
612$ IF APPLICATION .EQS. ";" THEN GOTO APPLICATION_DONE
613$
614$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
615$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
616$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
617$
618$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
619$! SHOW SYMBOL APPLICATION*
620$!
621$! Tell the user what happens
622$!
623$ WRITE SYS$OUTPUT " ",APPLICATION,".exe"
624$!
625$! Link The Program, Check To See If We Need To Link With RSAREF Or Not.
626$!
627$ IF (RSAREF.EQS."TRUE")
628$ THEN
629$!
630$! Check To See If We Are To Link With A Specific TCP/IP Library.
631$!
632$ IF (TCPIP_LIB.NES."")
633$ THEN
634$!
635$! Link With The RSAREF Library And A Specific TCP/IP Library.
636$!
637$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
638 'OBJ_DIR''APPLICATION_OBJECTS', -
639 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
640 'TCPIP_LIB','OPT_FILE'/OPTION
641$!
642$! Else...
643$!
644$ ELSE
645$!
646$! Link With The RSAREF Library And NO TCP/IP Library.
647$!
648$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
649 'OBJ_DIR''APPLICATION_OBJECTS', -
650 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
651 'OPT_FILE'/OPTION
652$!
653$! End The TCP/IP Library Check.
654$!
655$ ENDIF
656$!
657$! Else...
658$!
659$ ELSE
660$!
661$! Don't Link With The RSAREF Routines.
662$!
663$!
664$! Check To See If We Are To Link With A Specific TCP/IP Library.
665$!
666$ IF (TCPIP_LIB.NES."")
667$ THEN
668$!
669$! Don't Link With The RSAREF Routines And TCP/IP Library.
670$!
671$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
672 'OBJ_DIR''APPLICATION_OBJECTS', -
673 'CRYPTO_LIB'/LIBRARY, -
674 'TCPIP_LIB','OPT_FILE'/OPTION
675$!
676$! Else...
677$!
678$ ELSE
679$!
680$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
681$!
682$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
683 'OBJ_DIR''APPLICATION_OBJECTS',-
684 'CRYPTO_LIB'/LIBRARY, -
685 'OPT_FILE'/OPTION
686$!
687$! End The TCP/IP Library Check.
688$!
689$ ENDIF
690$!
691$! End The RSAREF Link Check.
692$!
693$ ENDIF
694$ GOTO NEXT_APPLICATION
695$ APPLICATION_DONE:
696$ ENDIF
697$!
510$! Go Back And Get The Next Module. 698$! Go Back And Get The Next Module.
511$! 699$!
512$ GOTO MODULE_NEXT 700$ GOTO MODULE_NEXT
@@ -653,17 +841,70 @@ $ CHECK_OPTIONS:
653$! 841$!
654$! Check To See If P1 Is Blank. 842$! Check To See If P1 Is Blank.
655$! 843$!
656$ IF (P1.EQS."NORSAREF") 844$ IF (P1.EQS."ALL")
657$ THEN 845$ THEN
658$! 846$!
659$! P1 Is NORSAREF, So Compile With The Regular RSA Libraries. 847$! P1 Is Blank, So Build Everything.
848$!
849$ BUILDALL = "TRUE"
850$!
851$! Else...
852$!
853$ ELSE
854$!
855$! Else, Check To See If P1 Has A Valid Arguement.
856$!
857$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."APPS")
858$ THEN
859$!
860$! A Valid Arguement.
861$!
862$ BUILDALL = P1
863$!
864$! Else...
865$!
866$ ELSE
867$!
868$! Tell The User We Don't Know What They Want.
869$!
870$ WRITE SYS$OUTPUT ""
871$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
872$ WRITE SYS$OUTPUT ""
873$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
874$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.SSL]LIBCRYPTO.OLB Library."
875$ WRITE SYS$OUTPUT " APPS : To Compile Just The [.xxx.EXE.SSL]*.EXE Programs."
876$ WRITE SYS$OUTPUT ""
877$ WRITE SYS$OUTPUT " Where 'xxx' Stands For:"
878$ WRITE SYS$OUTPUT ""
879$ WRITE SYS$OUTPUT " AXP : Alpha Architecture."
880$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
881$ WRITE SYS$OUTPUT ""
882$!
883$! Time To EXIT.
884$!
885$ EXIT
886$!
887$! End The Valid Arguement Check.
888$!
889$ ENDIF
890$!
891$! End The P1 Check.
892$!
893$ ENDIF
894$!
895$! Check To See If P2 Is Blank.
896$!
897$ IF (P2.EQS."NORSAREF")
898$ THEN
899$!
900$! P2 Is NORSAREF, So Compile With The Regular RSA Libraries.
660$! 901$!
661$ RSAREF = "FALSE" 902$ RSAREF = "FALSE"
662$ ELSE 903$ ELSE
663$! 904$!
664$! Check To See If We Are To Use The RSAREF Library. 905$! Check To See If We Are To Use The RSAREF Library.
665$! 906$!
666$ IF (P1.EQS."RSAREF") 907$ IF (P2.EQS."RSAREF")
667$ THEN 908$ THEN
668$! 909$!
669$! Check To Make Sure We Have The RSAREF Source Code Directory. 910$! Check To Make Sure We Have The RSAREF Source Code Directory.
@@ -697,7 +938,7 @@ $!
697$! They Entered An Invalid Option.. 938$! They Entered An Invalid Option..
698$! 939$!
699$ WRITE SYS$OUTPUT "" 940$ WRITE SYS$OUTPUT ""
700$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:" 941$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
701$ WRITE SYS$OUTPUT "" 942$ WRITE SYS$OUTPUT ""
702$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library." 943$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
703$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library." 944$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
@@ -711,16 +952,16 @@ $! End The Valid Arguement Check.
711$! 952$!
712$ ENDIF 953$ ENDIF
713$! 954$!
714$! End The P1 Check. 955$! End The P2 Check.
715$! 956$!
716$ ENDIF 957$ ENDIF
717$! 958$!
718$! Check To See If P2 Is Blank. 959$! Check To See If P3 Is Blank.
719$! 960$!
720$ IF (P2.EQS."NODEBUG") 961$ IF (P3.EQS."NODEBUG")
721$ THEN 962$ THEN
722$! 963$!
723$! P2 Is NODEBUG, So Compile Without The Debugger Information. 964$! P3 Is NODEBUG, So Compile Without The Debugger Information.
724$! 965$!
725$ DEBUGGER = "NODEBUG" 966$ DEBUGGER = "NODEBUG"
726$ TRACEBACK = "NOTRACEBACK" 967$ TRACEBACK = "NOTRACEBACK"
@@ -733,7 +974,7 @@ $ ELSE
733$! 974$!
734$! Check To See If We Are To Compile With Debugger Information. 975$! Check To See If We Are To Compile With Debugger Information.
735$! 976$!
736$ IF (P2.EQS."DEBUG") 977$ IF (P3.EQS."DEBUG")
737$ THEN 978$ THEN
738$! 979$!
739$! Compile With Debugger Information. 980$! Compile With Debugger Information.
@@ -750,7 +991,7 @@ $!
750$! They Entered An Invalid Option.. 991$! They Entered An Invalid Option..
751$! 992$!
752$ WRITE SYS$OUTPUT "" 993$ WRITE SYS$OUTPUT ""
753$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:" 994$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
754$ WRITE SYS$OUTPUT "" 995$ WRITE SYS$OUTPUT ""
755$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information." 996$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
756$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information." 997$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
@@ -764,7 +1005,7 @@ $! End The Valid Arguement Check.
764$! 1005$!
765$ ENDIF 1006$ ENDIF
766$! 1007$!
767$! End The P2 Check. 1008$! End The P3 Check.
768$! 1009$!
769$ ENDIF 1010$ ENDIF
770$! 1011$!
@@ -774,9 +1015,9 @@ $! Written By: Richard Levitte
774$! richard@levitte.org 1015$! richard@levitte.org
775$! 1016$!
776$! 1017$!
777$! Check To See If We Have A Option For P5. 1018$! Check To See If We Have A Option For P6.
778$! 1019$!
779$ IF (P5.EQS."") 1020$ IF (P6.EQS."")
780$ THEN 1021$ THEN
781$! 1022$!
782$! Get The Version Of VMS We Are Using. 1023$! Get The Version Of VMS We Are Using.
@@ -798,13 +1039,13 @@ $! End The VMS Version Check.
798$! 1039$!
799$ ENDIF 1040$ ENDIF
800$! 1041$!
801$! End The P5 Check. 1042$! End The P6 Check.
802$! 1043$!
803$ ENDIF 1044$ ENDIF
804$! 1045$!
805$! Check To See If P3 Is Blank. 1046$! Check To See If P4 Is Blank.
806$! 1047$!
807$ IF (P3.EQS."") 1048$ IF (P4.EQS."")
808$ THEN 1049$ THEN
809$! 1050$!
810$! O.K., The User Didn't Specify A Compiler, Let's Try To 1051$! O.K., The User Didn't Specify A Compiler, Let's Try To
@@ -817,7 +1058,7 @@ $ THEN
817$! 1058$!
818$! Looks Like GNUC, Set To Use GNUC. 1059$! Looks Like GNUC, Set To Use GNUC.
819$! 1060$!
820$ P3 = "GNUC" 1061$ P4 = "GNUC"
821$! 1062$!
822$! Else... 1063$! Else...
823$! 1064$!
@@ -830,7 +1071,7 @@ $ THEN
830$! 1071$!
831$! Looks Like DECC, Set To Use DECC. 1072$! Looks Like DECC, Set To Use DECC.
832$! 1073$!
833$ P3 = "DECC" 1074$ P4 = "DECC"
834$! 1075$!
835$! Else... 1076$! Else...
836$! 1077$!
@@ -838,7 +1079,7 @@ $ ELSE
838$! 1079$!
839$! Looks Like VAXC, Set To Use VAXC. 1080$! Looks Like VAXC, Set To Use VAXC.
840$! 1081$!
841$ P3 = "VAXC" 1082$ P4 = "VAXC"
842$! 1083$!
843$! End The VAXC Compiler Check. 1084$! End The VAXC Compiler Check.
844$! 1085$!
@@ -852,9 +1093,9 @@ $! End The Compiler Check.
852$! 1093$!
853$ ENDIF 1094$ ENDIF
854$! 1095$!
855$! Check To See If We Have A Option For P4. 1096$! Check To See If We Have A Option For P5.
856$! 1097$!
857$ IF (P4.EQS."") 1098$ IF (P5.EQS."")
858$ THEN 1099$ THEN
859$! 1100$!
860$! Find out what socket library we have available 1101$! Find out what socket library we have available
@@ -864,7 +1105,7 @@ $ THEN
864$! 1105$!
865$! We have SOCKETSHR, and it is my opinion that it's the best to use. 1106$! We have SOCKETSHR, and it is my opinion that it's the best to use.
866$! 1107$!
867$ P4 = "SOCKETSHR" 1108$ P5 = "SOCKETSHR"
868$! 1109$!
869$! Tell the user 1110$! Tell the user
870$! 1111$!
@@ -884,7 +1125,7 @@ $ THEN
884$! 1125$!
885$! Last resort: a UCX or UCX-compatible library 1126$! Last resort: a UCX or UCX-compatible library
886$! 1127$!
887$ P4 = "UCX" 1128$ P5 = "UCX"
888$! 1129$!
889$! Tell the user 1130$! Tell the user
890$! 1131$!
@@ -898,22 +1139,46 @@ $ ENDIF
898$! 1139$!
899$! Set Up Initial CC Definitions, Possibly With User Ones 1140$! Set Up Initial CC Definitions, Possibly With User Ones
900$! 1141$!
901$ CCDEFS = "VMS=1,TCPIP_TYPE_''P4'" 1142$ CCDEFS = "VMS=1,TCPIP_TYPE_''P5'"
1143$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
1144$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
1145$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
1146$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
1147$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
1148$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
1149$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
1150$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
1151$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
1152$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
1153$ IF F$TRNLNM("OPENSSL_NO_DES")
1154$ THEN
1155$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
1156$ ELSE
1157$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
1158$ ENDIF
1159$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
1160$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
1161$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
1162$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
1163$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
1164$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
1165$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
1166$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
902$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 1167$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
903$ CCEXTRAFLAGS = "" 1168$ CCEXTRAFLAGS = ""
904$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 1169$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
905$ CCDISABLEWARNINGS = "" 1170$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
906$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - 1171$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
907 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS 1172 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
908$! 1173$!
909$! Check To See If The User Entered A Valid Paramter. 1174$! Check To See If The User Entered A Valid Paramter.
910$! 1175$!
911$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC") 1176$ IF (P4.EQS."VAXC").OR.(P4.EQS."DECC").OR.(P4.EQS."GNUC")
912$ THEN 1177$ THEN
913$! 1178$!
914$! Check To See If The User Wanted DECC. 1179$! Check To See If The User Wanted DECC.
915$! 1180$!
916$ IF (P3.EQS."DECC") 1181$ IF (P4.EQS."DECC")
917$ THEN 1182$ THEN
918$! 1183$!
919$! Looks Like DECC, Set To Use DECC. 1184$! Looks Like DECC, Set To Use DECC.
@@ -942,7 +1207,7 @@ $ ENDIF
942$! 1207$!
943$! Check To See If We Are To Use VAXC. 1208$! Check To See If We Are To Use VAXC.
944$! 1209$!
945$ IF (P3.EQS."VAXC") 1210$ IF (P4.EQS."VAXC")
946$ THEN 1211$ THEN
947$! 1212$!
948$! Looks Like VAXC, Set To Use VAXC. 1213$! Looks Like VAXC, Set To Use VAXC.
@@ -980,7 +1245,7 @@ $ ENDIF
980$! 1245$!
981$! Check To See If We Are To Use GNU C. 1246$! Check To See If We Are To Use GNU C.
982$! 1247$!
983$ IF (P3.EQS."GNUC") 1248$ IF (P4.EQS."GNUC")
984$ THEN 1249$ THEN
985$! 1250$!
986$! Looks Like GNUC, Set To Use GNUC. 1251$! Looks Like GNUC, Set To Use GNUC.
@@ -1051,7 +1316,7 @@ $ CC4DISABLEWARNINGS = ""
1051$ ENDIF 1316$ ENDIF
1052$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS 1317$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS
1053$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS 1318$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
1054$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P2 .NES. "DEBUG" 1319$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P3 .NES. "DEBUG"
1055$ THEN 1320$ THEN
1056$ CC5 = CC + "/OPTIMIZE=NODISJOINT" 1321$ CC5 = CC + "/OPTIMIZE=NODISJOINT"
1057$ ELSE 1322$ ELSE
@@ -1070,7 +1335,7 @@ $!
1070$! Tell The User We Don't Know What They Want. 1335$! Tell The User We Don't Know What They Want.
1071$! 1336$!
1072$ WRITE SYS$OUTPUT "" 1337$ WRITE SYS$OUTPUT ""
1073$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:" 1338$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:"
1074$ WRITE SYS$OUTPUT "" 1339$ WRITE SYS$OUTPUT ""
1075$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C." 1340$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
1076$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C." 1341$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
@@ -1096,12 +1361,12 @@ $ WRITE SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO
1096$! 1361$!
1097$! Time to check the contents, and to make sure we get the correct library. 1362$! Time to check the contents, and to make sure we get the correct library.
1098$! 1363$!
1099$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" 1364$ IF P5.EQS."SOCKETSHR" .OR. P5.EQS."MULTINET" .OR. P5.EQS."UCX"
1100$ THEN 1365$ THEN
1101$! 1366$!
1102$! Check to see if SOCKETSHR was chosen 1367$! Check to see if SOCKETSHR was chosen
1103$! 1368$!
1104$ IF P4.EQS."SOCKETSHR" 1369$ IF P5.EQS."SOCKETSHR"
1105$ THEN 1370$ THEN
1106$! 1371$!
1107$! Set the library to use SOCKETSHR 1372$! Set the library to use SOCKETSHR
@@ -1114,12 +1379,12 @@ $ ENDIF
1114$! 1379$!
1115$! Check to see if MULTINET was chosen 1380$! Check to see if MULTINET was chosen
1116$! 1381$!
1117$ IF P4.EQS."MULTINET" 1382$ IF P5.EQS."MULTINET"
1118$ THEN 1383$ THEN
1119$! 1384$!
1120$! Set the library to use UCX emulation. 1385$! Set the library to use UCX emulation.
1121$! 1386$!
1122$ P4 = "UCX" 1387$ P5 = "UCX"
1123$! 1388$!
1124$! Done with MULTINET 1389$! Done with MULTINET
1125$! 1390$!
@@ -1127,7 +1392,7 @@ $ ENDIF
1127$! 1392$!
1128$! Check to see if UCX was chosen 1393$! Check to see if UCX was chosen
1129$! 1394$!
1130$ IF P4.EQS."UCX" 1395$ IF P5.EQS."UCX"
1131$ THEN 1396$ THEN
1132$! 1397$!
1133$! Set the library to use UCX. 1398$! Set the library to use UCX.
@@ -1156,7 +1421,7 @@ $!
1156$! Tell The User We Don't Know What They Want. 1421$! Tell The User We Don't Know What They Want.
1157$! 1422$!
1158$ WRITE SYS$OUTPUT "" 1423$ WRITE SYS$OUTPUT ""
1159$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:" 1424$ WRITE SYS$OUTPUT "The Option ",P5," Is Invalid. The Valid Options Are:"
1160$ WRITE SYS$OUTPUT "" 1425$ WRITE SYS$OUTPUT ""
1161$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library." 1426$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1162$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library." 1427$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
@@ -1173,9 +1438,9 @@ $!
1173$! Check if the user wanted to compile just a subset of all the encryption 1438$! Check if the user wanted to compile just a subset of all the encryption
1174$! methods. 1439$! methods.
1175$! 1440$!
1176$ IF P6 .NES. "" 1441$ IF P7 .NES. ""
1177$ THEN 1442$ THEN
1178$ ENCRYPT_TYPES = P6 1443$ ENCRYPT_TYPES = P7
1179$ ENDIF 1444$ ENDIF
1180$! 1445$!
1181$! Time To RETURN... 1446$! Time To RETURN...
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 8ad8c25e5a..41c937966e 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -63,17 +63,25 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#include <stdlib.h>
67
66#ifndef NO_FP_API 68#ifndef NO_FP_API
67#include <stdio.h> 69#include <stdio.h>
68#endif 70#endif
69 71
70#include <openssl/stack.h> 72#include <openssl/stack.h>
73#include <openssl/safestack.h>
71#include <openssl/opensslv.h> 74#include <openssl/opensslv.h>
72 75
73#ifdef CHARSET_EBCDIC 76#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h> 77#include <openssl/ebcdic.h>
75#endif 78#endif
76 79
80#if defined(VMS) || defined(__VMS)
81#include "vms_idhacks.h"
82#endif
83
84
77/* Backward compatibility to SSLeay */ 85/* Backward compatibility to SSLeay */
78/* This is more to be used to check the correct DLL is being used 86/* This is more to be used to check the correct DLL is being used
79 * in the MS world. */ 87 * in the MS world. */
@@ -111,7 +119,9 @@ extern "C" {
111#define CRYPTO_LOCK_GETSERVBYNAME 21 119#define CRYPTO_LOCK_GETSERVBYNAME 21
112#define CRYPTO_LOCK_READDIR 22 120#define CRYPTO_LOCK_READDIR 22
113#define CRYPTO_LOCK_RSA_BLINDING 23 121#define CRYPTO_LOCK_RSA_BLINDING 23
114#define CRYPTO_NUM_LOCKS 24 122#define CRYPTO_LOCK_DH 24
123#define CRYPTO_LOCK_MALLOC2 25
124#define CRYPTO_NUM_LOCKS 26
115 125
116#define CRYPTO_LOCK 1 126#define CRYPTO_LOCK 1
117#define CRYPTO_UNLOCK 2 127#define CRYPTO_UNLOCK 2
@@ -147,14 +157,16 @@ extern "C" {
147#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ 157#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
148#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ 158#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
149 159
150/* 160/* The following are bit values to turn on or off options connected to the
151typedef struct crypto_mem_st 161 * malloc checking functionality */
152 { 162
153 char *(*malloc_func)(); 163/* Adds time to the memory checking information */
154 char *(*realloc_func)(); 164#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
155 void (*free_func)(); 165/* Adds thread number to the memory checking information */
156 } CRYPTO_MEM_FUNC; 166#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
157*/ 167
168#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
169
158 170
159/* predec of the BIO type */ 171/* predec of the BIO type */
160typedef struct bio_st BIO_dummy; 172typedef struct bio_st BIO_dummy;
@@ -165,24 +177,30 @@ typedef struct crypto_ex_data_st
165 int dummy; /* gcc is screwing up this data structure :-( */ 177 int dummy; /* gcc is screwing up this data structure :-( */
166 } CRYPTO_EX_DATA; 178 } CRYPTO_EX_DATA;
167 179
180/* Called when a new object is created */
181typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
182 int idx, long argl, void *argp);
183/* Called when an object is free()ed */
184typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
185 int idx, long argl, void *argp);
186/* Called when we need to dup an object */
187typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
188 int idx, long argl, void *argp);
189
168/* This stuff is basically class callback functions 190/* This stuff is basically class callback functions
169 * The current classes are SSL_CTX, SSL, SSL_SESION, and a few more */ 191 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
192
170typedef struct crypto_ex_data_func_st 193typedef struct crypto_ex_data_func_st
171 { 194 {
172 long argl; /* Arbitary long */ 195 long argl; /* Arbitary long */
173 char *argp; /* Arbitary char * */ 196 void *argp; /* Arbitary void * */
174 /* Called when a new object is created */ 197 CRYPTO_EX_new *new_func;
175 int (*new_func)(/*char *obj, 198 CRYPTO_EX_free *free_func;
176 char *item,int index,long argl,char *argp*/); 199 CRYPTO_EX_dup *dup_func;
177 /* Called when this object is free()ed */
178 void (*free_func)(/*char *obj,
179 char *item,int index,long argl,char *argp*/);
180
181 /* Called when we need to dup this one */
182 int (*dup_func)(/*char *obj_to,char *obj_from,
183 char **new,int index,long argl,char *argp*/);
184 } CRYPTO_EX_DATA_FUNCS; 200 } CRYPTO_EX_DATA_FUNCS;
185 201
202DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
203
186/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA 204/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
187 * entry. 205 * entry.
188 */ 206 */
@@ -194,63 +212,54 @@ typedef struct crypto_ex_data_func_st
194#define CRYPTO_EX_INDEX_X509_STORE 4 212#define CRYPTO_EX_INDEX_X509_STORE 4
195#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 213#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
196 214
197/* Use this for win32 DLL's */
198#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
199 (char *(*)())malloc,\
200 (char *(*)())realloc,\
201 (void (*)())free)
202 215
203#ifdef CRYPTO_MDEBUG_ALL 216/* This is the default callbacks, but we can have others as well:
204# ifndef CRYPTO_MDEBUG_TIME 217 * this is needed in Win32 where the application malloc and the
205# define CRYPTO_MDEBUG_TIME 218 * library malloc may not be the same.
206# endif 219 */
207# ifndef CRYPTO_MDEBUG_THREAD 220#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
208# define CRYPTO_MDEBUG_THREAD 221 malloc, realloc, free)
209# endif
210#endif
211 222
212#if defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD 223#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
213# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ 224# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
214# define CRYPTO_MDEBUG 225# define CRYPTO_MDEBUG
215# endif 226# endif
216#endif 227#endif
217 228
218#ifdef CRYPTO_MDEBUG 229/* Set standard debugging functions (not done by default
230 * unless CRYPTO_MDEBUG is defined) */
231#define CRYPTO_malloc_debug_init() do {\
232 CRYPTO_set_mem_debug_functions(\
233 (void (*)())CRYPTO_dbg_malloc,\
234 (void (*)())CRYPTO_dbg_realloc,\
235 (void (*)())CRYPTO_dbg_free,\
236 (void (*)())CRYPTO_dbg_set_options,\
237 (long (*)())CRYPTO_dbg_get_options);\
238 } while(0)
239
240int CRYPTO_mem_ctrl(int mode);
241int CRYPTO_is_mem_check_on(void);
242
243/* for applications */
219#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) 244#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
220#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) 245#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
246
247/* for library-internal use */
221#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) 248#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
222#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) 249#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
223#define Malloc(num) CRYPTO_dbg_malloc((int)num,__FILE__,__LINE__) 250#define is_MemCheck_on() CRYPTO_is_mem_check_on()
251
252#define Malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
224#define Realloc(addr,num) \ 253#define Realloc(addr,num) \
225 CRYPTO_dbg_realloc((char *)addr,(int)num,__FILE__,__LINE__) 254 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
226#define Remalloc(addr,num) \ 255#define Remalloc(addr,num) \
227 CRYPTO_dbg_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 256 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
228#define FreeFunc CRYPTO_dbg_free
229#define Free(addr) CRYPTO_dbg_free(addr)
230#define Malloc_locked(num) CRYPTO_malloc_locked((int)num)
231#define Free_locked(addr) CRYPTO_free_locked(addr)
232#else
233#define MemCheck_start()
234#define MemCheck_stop()
235#define MemCheck_on()
236#define MemCheck_off()
237#define Remalloc CRYPTO_remalloc
238#if defined(WIN32) || defined(MFUNC)
239#define Malloc CRYPTO_malloc
240#define Realloc(a,n) CRYPTO_realloc(a,(n))
241#define FreeFunc CRYPTO_free 257#define FreeFunc CRYPTO_free
242#define Free(addr) CRYPTO_free(addr) 258#define Free(addr) CRYPTO_free(addr)
243#define Malloc_locked CRYPTO_malloc_locked 259
260#define Malloc_locked(num) CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
244#define Free_locked(addr) CRYPTO_free_locked(addr) 261#define Free_locked(addr) CRYPTO_free_locked(addr)
245#else 262
246#define Malloc malloc
247#define Realloc realloc
248#define FreeFunc free
249#define Free(addr) free(addr)
250#define Malloc_locked malloc
251#define Free_locked(addr) free(addr)
252#endif /* WIN32 || MFUNC */
253#endif /* MDEBUG */
254 263
255/* Case insensiteve linking causes problems.... */ 264/* Case insensiteve linking causes problems.... */
256#if defined(WIN16) || defined(VMS) 265#if defined(WIN16) || defined(VMS)
@@ -261,15 +270,15 @@ typedef struct crypto_ex_data_func_st
261const char *SSLeay_version(int type); 270const char *SSLeay_version(int type);
262unsigned long SSLeay(void); 271unsigned long SSLeay(void);
263 272
264int CRYPTO_get_ex_new_index(int idx,STACK **sk,long argl,char *argp, 273int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
265 int (*new_func)(),int (*dup_func)(),void (*free_func)()); 274 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
266int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad,int idx,char *val); 275int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
267char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx); 276void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx);
268int CRYPTO_dup_ex_data(STACK *meth,CRYPTO_EX_DATA *from,CRYPTO_EX_DATA *to); 277int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to,
269void CRYPTO_free_ex_data(STACK *meth,char *obj,CRYPTO_EX_DATA *ad); 278 CRYPTO_EX_DATA *from);
270void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad); 279void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
280void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
271 281
272int CRYPTO_mem_ctrl(int mode);
273int CRYPTO_get_new_lockid(char *name); 282int CRYPTO_get_new_lockid(char *name);
274 283
275int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ 284int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
@@ -289,22 +298,51 @@ const char *CRYPTO_get_lock_name(int type);
289int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 298int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
290 int line); 299 int line);
291 300
292void CRYPTO_set_mem_functions(char *(*m)(),char *(*r)(), void (*free_func)()); 301/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
293void CRYPTO_get_mem_functions(char *(**m)(),char *(**r)(), void (**f)()); 302 * call the latter last if you need different functions */
294void CRYPTO_set_locked_mem_functions(char *(*m)(), void (*free_func)()); 303int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
295void CRYPTO_get_locked_mem_functions(char *(**m)(), void (**f)()); 304int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
305int CRYPTO_set_mem_debug_functions(void (*m)(),void (*r)(),void (*f)(),void (*so)(),long (*go)());
306void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
307void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
308void CRYPTO_get_mem_debug_functions(void (**m)(),void (**r)(),void (**f)(),void (**so)(),long (**go)());
296 309
297void *CRYPTO_malloc_locked(int num); 310void *CRYPTO_malloc_locked(int num, const char *file, int line);
298void CRYPTO_free_locked(void *); 311void CRYPTO_free_locked(void *);
299void *CRYPTO_malloc(int num); 312void *CRYPTO_malloc(int num, const char *file, int line);
300void CRYPTO_free(void *); 313void CRYPTO_free(void *);
301void *CRYPTO_realloc(void *addr,int num); 314void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
302void *CRYPTO_remalloc(void *addr,int num); 315void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
316
317void CRYPTO_set_mem_debug_options(long bits);
318long CRYPTO_get_mem_debug_options(void);
319
320#define CRYPTO_push_info(info) \
321 CRYPTO_push_info_(info, __FILE__, __LINE__);
322int CRYPTO_push_info_(const char *info, const char *file, int line);
323int CRYPTO_pop_info(void);
324int CRYPTO_remove_all_info(void);
325
326/* The last argument has the following significance:
327 *
328 * 0: called before the actual memory allocation has taken place
329 * 1: called after the actual memory allocation has taken place
330 */
331void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
332void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
333void CRYPTO_dbg_free(void *addr,int before_p);
334
335/* Tell the debugging code about options. By default, the following values
336 * apply:
337 *
338 * 0: Clear all options.
339 * 1: Set the "Show Time" option.
340 * 2: Set the "Show Thread Number" option.
341 * 3: 1 + 2
342 */
343void CRYPTO_dbg_set_options(long bits);
344long CRYPTO_dbg_get_options(void);
303 345
304void *CRYPTO_dbg_malloc(int num,const char *file,int line);
305void *CRYPTO_dbg_realloc(void *addr,int num,const char *file,int line);
306void CRYPTO_dbg_free(void *);
307void *CRYPTO_dbg_remalloc(void *addr,int num,const char *file,int line);
308#ifndef NO_FP_API 346#ifndef NO_FP_API
309void CRYPTO_mem_leaks_fp(FILE *); 347void CRYPTO_mem_leaks_fp(FILE *);
310#endif 348#endif
@@ -312,7 +350,7 @@ void CRYPTO_mem_leaks(struct bio_st *bio);
312/* unsigned long order, char *file, int line, int num_bytes, char *addr */ 350/* unsigned long order, char *file, int line, int num_bytes, char *addr */
313void CRYPTO_mem_leaks_cb(void (*cb)()); 351void CRYPTO_mem_leaks_cb(void (*cb)());
314 352
315void ERR_load_CRYPTO_strings(void ); 353void ERR_load_CRYPTO_strings(void);
316 354
317/* BEGIN ERROR CODES */ 355/* BEGIN ERROR CODES */
318/* The following lines are auto generated by the script mkerr.pl. Any changes 356/* The following lines are auto generated by the script mkerr.pl. Any changes
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
index 7f9600cf02..41976655e9 100644
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -15,6 +15,7 @@ MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
16MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
17AR= ar r 17AR= ar r
18RANLIB= ranlib
18DES_ENC= des_enc.o fcrypt_b.o 19DES_ENC= des_enc.o fcrypt_b.o
19# or use 20# or use
20#DES_ENC= dx86-elf.o yx86-elf.o 21#DES_ENC= dx86-elf.o yx86-elf.o
@@ -162,14 +163,15 @@ enc_read.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
162enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 163enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
163enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 164enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
164enc_read.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 165enc_read.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
165enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 166enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
166enc_read.o: ../cryptlib.h des_locl.h 167enc_read.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
167enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
168enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 169enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
169enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 170enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
170enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 171enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
171enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 172enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
172enc_writ.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h 173enc_writ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
174enc_writ.o: ../cryptlib.h des_locl.h
173fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h 175fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h
174fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h 176fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h
175fcrypt.o: ../../include/openssl/opensslconf.h 177fcrypt.o: ../../include/openssl/opensslconf.h
@@ -187,15 +189,15 @@ pcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h
187qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 189qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
188qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h 190qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h
189rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 191rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
190rand_key.o: ../../include/openssl/opensslconf.h des_locl.h 192rand_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h
191read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 193read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
192read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h 194read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h
193read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 195read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
194read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 196read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
195read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 197read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
196read_pwd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 198read_pwd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
197read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 199read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
198read_pwd.o: ../cryptlib.h des_locl.h 200read_pwd.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
199rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 201rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
200rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h 202rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h
201set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 203set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
diff --git a/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c
index 3863a676d4..527e74f3de 100644
--- a/src/lib/libcrypto/des/cbc3_enc.c
+++ b/src/lib/libcrypto/des/cbc3_enc.c
@@ -58,7 +58,7 @@
58 58
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)
@@ -69,11 +69,14 @@ void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
69 69
70 if (enc == DES_ENCRYPT) 70 if (enc == DES_ENCRYPT)
71 { 71 {
72 des_cbc_encrypt(input,output,length,ks1,iv1,enc); 72 des_cbc_encrypt((unsigned char*)input,
73 (unsigned char*)output,length,ks1,iv1,enc);
73 if (length >= sizeof(des_cblock)) 74 if (length >= sizeof(des_cblock))
74 memcpy(niv1,output[off],sizeof(des_cblock)); 75 memcpy(niv1,output[off],sizeof(des_cblock));
75 des_cbc_encrypt(output,output,l8,ks2,iv1,!enc); 76 des_cbc_encrypt((unsigned char*)output,
76 des_cbc_encrypt(output,output,l8,ks1,iv2, enc); 77 (unsigned char*)output,l8,ks2,iv1,!enc);
78 des_cbc_encrypt((unsigned char*)output,
79 (unsigned char*)output,l8,ks1,iv2,enc);
77 if (length >= sizeof(des_cblock)) 80 if (length >= sizeof(des_cblock))
78 memcpy(niv2,output[off],sizeof(des_cblock)); 81 memcpy(niv2,output[off],sizeof(des_cblock));
79 } 82 }
@@ -81,11 +84,14 @@ void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
81 { 84 {
82 if (length >= sizeof(des_cblock)) 85 if (length >= sizeof(des_cblock))
83 memcpy(niv2,input[off],sizeof(des_cblock)); 86 memcpy(niv2,input[off],sizeof(des_cblock));
84 des_cbc_encrypt(input,output,l8,ks1,iv2,enc); 87 des_cbc_encrypt((unsigned char*)input,
85 des_cbc_encrypt(output,output,l8,ks2,iv1,!enc); 88 (unsigned char*)output,l8,ks1,iv2,enc);
89 des_cbc_encrypt((unsigned char*)output,
90 (unsigned char*)output,l8,ks2,iv1,!enc);
86 if (length >= sizeof(des_cblock)) 91 if (length >= sizeof(des_cblock))
87 memcpy(niv1,output[off],sizeof(des_cblock)); 92 memcpy(niv1,output[off],sizeof(des_cblock));
88 des_cbc_encrypt(output,output,length,ks1,iv1, enc); 93 des_cbc_encrypt((unsigned char*)output,
94 (unsigned char*)output,length,ks1,iv1,enc);
89 } 95 }
90 memcpy(*iv1,niv1,sizeof(des_cblock)); 96 memcpy(*iv1,niv1,sizeof(des_cblock));
91 memcpy(*iv2,niv2,sizeof(des_cblock)); 97 memcpy(*iv2,niv2,sizeof(des_cblock));
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
index b2d7f0da78..91d7153b34 100644
--- a/src/lib/libcrypto/des/des.c
+++ b/src/lib/libcrypto/des/des.c
@@ -325,25 +325,25 @@ void usage(void)
325"des <options> [input-file [output-file]]", 325"des <options> [input-file [output-file]]",
326"options:", 326"options:",
327"-v : des(1) version number", 327"-v : des(1) version number",
328"-e : encrypt using sunOS compatible user key to DES key conversion.", 328"-e : encrypt using SunOS compatible user key to DES key conversion.",
329"-E : encrypt ", 329"-E : encrypt ",
330"-d : decrypt using sunOS compatible user key to DES key conversion.", 330"-d : decrypt using SunOS compatible user key to DES key conversion.",
331"-D : decrypt ", 331"-D : decrypt ",
332"-c[ckname] : generate a cbc_cksum using sunOS compatible user key to", 332"-c[ckname] : generate a cbc_cksum using SunOS compatible user key to",
333" DES key conversion and output to ckname (stdout default,", 333" DES key conversion and output to ckname (stdout default,",
334" stderr if data being output on stdout). The checksum is", 334" stderr if data being output on stdout). The checksum is",
335" generated before encryption and after decryption if used", 335" generated before encryption and after decryption if used",
336" in conjunction with -[eEdD].", 336" in conjunction with -[eEdD].",
337"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].", 337"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].",
338"-k key : use key 'key'", 338"-k key : use key 'key'",
339"-h : the key that is entered will be a hexidecimal number", 339"-h : the key that is entered will be a hexadecimal number",
340" that is used directly as the des key", 340" that is used directly as the des key",
341"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]", 341"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]",
342" (uuname is the filename to put in the uuencode header).", 342" (uuname is the filename to put in the uuencode header).",
343"-b : encrypt using DES in ecb encryption mode, the defaut is cbc mode.", 343"-b : encrypt using DES in ecb encryption mode, the default is cbc mode.",
344"-3 : encrypt using tripple DES encryption. This uses 2 keys", 344"-3 : encrypt using triple DES encryption. This uses 2 keys",
345" generated from the input key. If the input key is less", 345" generated from the input key. If the input key is less",
346" than 8 characters long, this is equivelent to normal", 346" than 8 characters long, this is equivalent to normal",
347" encryption. Default is triple cbc, -b makes it triple ecb.", 347" encryption. Default is triple cbc, -b makes it triple ecb.",
348NULL 348NULL
349}; 349};
@@ -425,7 +425,7 @@ void doencryption(void)
425 else 425 else
426 k2[i-8]=k; 426 k2[i-8]=k;
427 } 427 }
428 des_set_key(&k2,ks2); 428 des_set_key_unchecked(&k2,ks2);
429 memset(k2,0,sizeof(k2)); 429 memset(k2,0,sizeof(k2));
430 } 430 }
431 else if (longk || flag3) 431 else if (longk || flag3)
@@ -433,7 +433,7 @@ void doencryption(void)
433 if (flag3) 433 if (flag3)
434 { 434 {
435 des_string_to_2keys(key,&kk,&k2); 435 des_string_to_2keys(key,&kk,&k2);
436 des_set_key(&k2,ks2); 436 des_set_key_unchecked(&k2,ks2);
437 memset(k2,0,sizeof(k2)); 437 memset(k2,0,sizeof(k2));
438 } 438 }
439 else 439 else
@@ -455,7 +455,7 @@ void doencryption(void)
455 kk[i]=key[i]|0x80; 455 kk[i]=key[i]|0x80;
456 } 456 }
457 457
458 des_set_key(&kk,ks); 458 des_set_key_unchecked(&kk,ks);
459 memset(key,0,sizeof(key)); 459 memset(key,0,sizeof(key));
460 memset(kk,0,sizeof(kk)); 460 memset(kk,0,sizeof(kk));
461 /* woops - A bug that does not showup under unix :-( */ 461 /* woops - A bug that does not showup under unix :-( */
@@ -484,7 +484,7 @@ void doencryption(void)
484 if (feof(DES_IN)) 484 if (feof(DES_IN))
485 { 485 {
486 for (i=7-rem; i>0; i--) 486 for (i=7-rem; i>0; i--)
487 RAND_bytes(buf + l++, 1); 487 RAND_pseudo_bytes(buf + l++, 1);
488 buf[l++]=rem; 488 buf[l++]=rem;
489 ex=1; 489 ex=1;
490 len+=rem; 490 len+=rem;
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
index 67f90aaf17..98a9c4127c 100644
--- a/src/lib/libcrypto/des/des.h
+++ b/src/lib/libcrypto/des/des.h
@@ -186,15 +186,20 @@ void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
186DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[], 186DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[],
187 long length,int out_count,des_cblock *seed); 187 long length,int out_count,des_cblock *seed);
188void des_random_seed(des_cblock *key); 188void des_random_seed(des_cblock *key);
189void des_random_key(des_cblock *ret); 189int des_random_key(des_cblock *ret);
190int des_read_password(des_cblock *key,const char *prompt,int verify); 190int des_read_password(des_cblock *key,const char *prompt,int verify);
191int des_read_2passwords(des_cblock *key1,des_cblock *key2, 191int des_read_2passwords(des_cblock *key1,des_cblock *key2,
192 const char *prompt,int verify); 192 const char *prompt,int verify);
193int des_read_pw_string(char *buf,int length,const char *prompt,int verify); 193int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
194void des_set_odd_parity(des_cblock *key); 194void des_set_odd_parity(des_cblock *key);
195int des_is_weak_key(const_des_cblock *key); 195int des_is_weak_key(const_des_cblock *key);
196/* des_set_key (= set_key = des_key_sched = key_sched) calls
197 * des_set_key_checked if global variable des_check_key is set,
198 * des_set_key_unchecked otherwise. */
196int des_set_key(const_des_cblock *key,des_key_schedule schedule); 199int des_set_key(const_des_cblock *key,des_key_schedule schedule);
197int des_key_sched(const_des_cblock *key,des_key_schedule schedule); 200int des_key_sched(const_des_cblock *key,des_key_schedule schedule);
201int des_set_key_checked(const_des_cblock *key,des_key_schedule schedule);
202void des_set_key_unchecked(const_des_cblock *key,des_key_schedule schedule);
198void des_string_to_key(const char *str,des_cblock *key); 203void des_string_to_key(const char *str,des_cblock *key);
199void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2); 204void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2);
200void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, 205void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index d6ea17cb68..4dfed199a7 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -72,7 +72,11 @@
72 72
73#ifndef MSDOS 73#ifndef MSDOS
74#if !defined(VMS) || defined(__DECC) 74#if !defined(VMS) || defined(__DECC)
75#include OPENSSL_UNISTD 75#ifdef OPENSSL_UNISTD
76# include OPENSSL_UNISTD
77#else
78# include <unistd.h>
79#endif
76#include <math.h> 80#include <math.h>
77#endif 81#endif
78#endif 82#endif
@@ -178,14 +182,14 @@
178#endif 182#endif
179 183
180/* The changes to this macro may help or hinder, depending on the 184/* The changes to this macro may help or hinder, depending on the
181 * compiler and the achitecture. gcc2 always seems to do well :-). 185 * compiler and the architecture. gcc2 always seems to do well :-).
182 * Inspired by Dana How <how@isl.stanford.edu> 186 * Inspired by Dana How <how@isl.stanford.edu>
183 * DO NOT use the alternative version on machines with 8 byte longs. 187 * DO NOT use the alternative version on machines with 8 byte longs.
184 * It does not seem to work on the Alpha, even when DES_LONG is 4 188 * It does not seem to work on the Alpha, even when DES_LONG is 4
185 * bytes, probably an issue of accessing non-word aligned objects :-( */ 189 * bytes, probably an issue of accessing non-word aligned objects :-( */
186#ifdef DES_PTR 190#ifdef DES_PTR
187 191
188/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there 192/* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there
189 * is no reason to not xor all the sub items together. This potentially 193 * is no reason to not xor all the sub items together. This potentially
190 * saves a register since things can be xored directly into L */ 194 * saves a register since things can be xored directly into L */
191 195
diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c
index 746c456f8f..b2ca7ac31d 100644
--- a/src/lib/libcrypto/des/des_opts.c
+++ b/src/lib/libcrypto/des/des_opts.c
@@ -434,17 +434,17 @@ int main(int argc, char **argv)
434 } 434 }
435 435
436#ifndef TIMES 436#ifndef TIMES
437 fprintf(stderr,"To get the most acurate results, try to run this\n"); 437 fprintf(stderr,"To get the most accurate results, try to run this\n");
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(&key,sch); 441 des_set_key_unchecked(&key,sch);
442 des_set_key(&key2,sch2); 442 des_set_key_unchecked(&key2,sch2);
443 des_set_key(&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(&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;
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index 5a04fc9298..9ad4ecb072 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -234,7 +234,7 @@ static unsigned char cipher_ecb2[NUM_TESTS-1][8]={
234 {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}}; 234 {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}};
235 235
236static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; 236static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
237static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; 237static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86};
238static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; 238static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
239static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; 239static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
240/* Changed the following text constant to binary so it will work on ebcdic 240/* Changed the following text constant to binary so it will work on ebcdic
@@ -254,12 +254,24 @@ static unsigned char cbc_ok[32]={
254 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68, 254 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68,
255 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 255 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
256 256
257#ifdef SCREW_THE_PARITY
258#error "SCREW_THE_PARITY is not ment to be defined."
259#error "Original vectors are preserved for reference only."
260static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
257static unsigned char xcbc_ok[32]={ 261static unsigned char xcbc_ok[32]={
258 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48, 262 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48,
259 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD, 263 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD,
260 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76, 264 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76,
261 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2, 265 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2,
262 }; 266 };
267#else
268static unsigned char xcbc_ok[32]={
269 0x84,0x6B,0x29,0x14,0x85,0x1E,0x9A,0x29,
270 0x54,0x73,0x2F,0x8A,0xA0,0xA6,0x11,0xC1,
271 0x15,0xCD,0xC2,0xD7,0x95,0x1B,0x10,0x53,
272 0xA6,0x3C,0x5E,0x03,0xB2,0x1A,0xA3,0xC4,
273 };
274#endif
263 275
264static unsigned char cbc3_ok[32]={ 276static unsigned char cbc3_ok[32]={
265 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0, 277 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0,
@@ -309,8 +321,8 @@ static unsigned char ofb_cipher[24]=
309 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 321 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
310 }; 322 };
311 323
312DES_LONG cbc_cksum_ret=0xB462FEF7L; 324static DES_LONG cbc_cksum_ret=0xB462FEF7L;
313unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 325static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
314 326
315static char *pt(unsigned char *p); 327static char *pt(unsigned char *p);
316static int cfb_test(int bits, unsigned char *cfb_cipher); 328static int cfb_test(int bits, unsigned char *cfb_cipher);
@@ -331,17 +343,17 @@ int main(int argc, char *argv[])
331 343
332#ifndef NO_DESCBCM 344#ifndef NO_DESCBCM
333 printf("Doing cbcm\n"); 345 printf("Doing cbcm\n");
334 if ((j=des_key_sched(&cbc_key,ks)) != 0) 346 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
335 { 347 {
336 printf("Key error %d\n",j); 348 printf("Key error %d\n",j);
337 err=1; 349 err=1;
338 } 350 }
339 if ((j=des_key_sched(&cbc2_key,ks2)) != 0) 351 if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0)
340 { 352 {
341 printf("Key error %d\n",j); 353 printf("Key error %d\n",j);
342 err=1; 354 err=1;
343 } 355 }
344 if ((j=des_key_sched(&cbc3_key,ks3)) != 0) 356 if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0)
345 { 357 {
346 printf("Key error %d\n",j); 358 printf("Key error %d\n",j);
347 err=1; 359 err=1;
@@ -385,11 +397,7 @@ int main(int argc, char *argv[])
385 printf("Doing ecb\n"); 397 printf("Doing ecb\n");
386 for (i=0; i<NUM_TESTS; i++) 398 for (i=0; i<NUM_TESTS; i++)
387 { 399 {
388 if ((j=des_key_sched(&key_data[i],ks)) != 0) 400 des_set_key_unchecked(&key_data[i],ks);
389 {
390 printf("Key error %2d:%d\n",i+1,j);
391 err=1;
392 }
393 memcpy(in,plain_data[i],8); 401 memcpy(in,plain_data[i],8);
394 memset(out,0,8); 402 memset(out,0,8);
395 memset(outin,0,8); 403 memset(outin,0,8);
@@ -415,21 +423,9 @@ int main(int argc, char *argv[])
415 printf("Doing ede ecb\n"); 423 printf("Doing ede ecb\n");
416 for (i=0; i<(NUM_TESTS-1); i++) 424 for (i=0; i<(NUM_TESTS-1); i++)
417 { 425 {
418 if ((j=des_key_sched(&key_data[i],ks)) != 0) 426 des_set_key_unchecked(&key_data[i],ks);
419 { 427 des_set_key_unchecked(&key_data[i+1],ks2);
420 err=1; 428 des_set_key_unchecked(&key_data[i+2],ks3);
421 printf("Key error %2d:%d\n",i+1,j);
422 }
423 if ((j=des_key_sched(&key_data[i+1],ks2)) != 0)
424 {
425 printf("Key error %2d:%d\n",i+2,j);
426 err=1;
427 }
428 if ((j=des_key_sched(&key_data[i+2],ks3)) != 0)
429 {
430 printf("Key error %2d:%d\n",i+3,j);
431 err=1;
432 }
433 memcpy(in,plain_data[i],8); 429 memcpy(in,plain_data[i],8);
434 memset(out,0,8); 430 memset(out,0,8);
435 memset(outin,0,8); 431 memset(outin,0,8);
@@ -453,7 +449,7 @@ int main(int argc, char *argv[])
453#endif 449#endif
454 450
455 printf("Doing cbc\n"); 451 printf("Doing cbc\n");
456 if ((j=des_key_sched(&cbc_key,ks)) != 0) 452 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
457 { 453 {
458 printf("Key error %d\n",j); 454 printf("Key error %d\n",j);
459 err=1; 455 err=1;
@@ -464,7 +460,10 @@ int main(int argc, char *argv[])
464 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, 460 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
465 &iv3,DES_ENCRYPT); 461 &iv3,DES_ENCRYPT);
466 if (memcmp(cbc_out,cbc_ok,32) != 0) 462 if (memcmp(cbc_out,cbc_ok,32) != 0)
463 {
467 printf("cbc_encrypt encrypt error\n"); 464 printf("cbc_encrypt encrypt error\n");
465 err=1;
466 }
468 467
469 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 468 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
470 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, 469 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
@@ -477,7 +476,7 @@ int main(int argc, char *argv[])
477 476
478#ifndef LIBDES_LIT 477#ifndef LIBDES_LIT
479 printf("Doing desx cbc\n"); 478 printf("Doing desx cbc\n");
480 if ((j=des_key_sched(&cbc_key,ks)) != 0) 479 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
481 { 480 {
482 printf("Key error %d\n",j); 481 printf("Key error %d\n",j);
483 err=1; 482 err=1;
@@ -490,6 +489,7 @@ int main(int argc, char *argv[])
490 if (memcmp(cbc_out,xcbc_ok,32) != 0) 489 if (memcmp(cbc_out,xcbc_ok,32) != 0)
491 { 490 {
492 printf("des_xcbc_encrypt encrypt error\n"); 491 printf("des_xcbc_encrypt encrypt error\n");
492 err=1;
493 } 493 }
494 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 494 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
495 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, 495 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
@@ -502,17 +502,17 @@ int main(int argc, char *argv[])
502#endif 502#endif
503 503
504 printf("Doing ede cbc\n"); 504 printf("Doing ede cbc\n");
505 if ((j=des_key_sched(&cbc_key,ks)) != 0) 505 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
506 { 506 {
507 printf("Key error %d\n",j); 507 printf("Key error %d\n",j);
508 err=1; 508 err=1;
509 } 509 }
510 if ((j=des_key_sched(&cbc2_key,ks2)) != 0) 510 if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0)
511 { 511 {
512 printf("Key error %d\n",j); 512 printf("Key error %d\n",j);
513 err=1; 513 err=1;
514 } 514 }
515 if ((j=des_key_sched(&cbc3_key,ks3)) != 0) 515 if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0)
516 { 516 {
517 printf("Key error %d\n",j); 517 printf("Key error %d\n",j);
518 err=1; 518 err=1;
@@ -543,7 +543,7 @@ int main(int argc, char *argv[])
543 543
544#ifndef LIBDES_LIT 544#ifndef LIBDES_LIT
545 printf("Doing pcbc\n"); 545 printf("Doing pcbc\n");
546 if ((j=des_key_sched(&cbc_key,ks)) != 0) 546 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
547 { 547 {
548 printf("Key error %d\n",j); 548 printf("Key error %d\n",j);
549 err=1; 549 err=1;
@@ -606,7 +606,7 @@ int main(int argc, char *argv[])
606 printf("done\n"); 606 printf("done\n");
607 607
608 printf("Doing ofb\n"); 608 printf("Doing ofb\n");
609 des_key_sched(&ofb_key,ks); 609 des_set_key_checked(&ofb_key,ks);
610 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 610 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
611 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp); 611 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
612 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 612 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
@@ -635,7 +635,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
635 } 635 }
636 636
637 printf("Doing ofb64\n"); 637 printf("Doing ofb64\n");
638 des_key_sched(&ofb_key,ks); 638 des_set_key_checked(&ofb_key,ks);
639 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 639 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
640 memset(ofb_buf1,0,sizeof(ofb_buf1)); 640 memset(ofb_buf1,0,sizeof(ofb_buf1));
641 memset(ofb_buf2,0,sizeof(ofb_buf1)); 641 memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -660,7 +660,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
660 } 660 }
661 661
662 printf("Doing ede_ofb64\n"); 662 printf("Doing ede_ofb64\n");
663 des_key_sched(&ofb_key,ks); 663 des_set_key_checked(&ofb_key,ks);
664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
665 memset(ofb_buf1,0,sizeof(ofb_buf1)); 665 memset(ofb_buf1,0,sizeof(ofb_buf1));
666 memset(ofb_buf2,0,sizeof(ofb_buf1)); 666 memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -686,7 +686,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
686 } 686 }
687 687
688 printf("Doing cbc_cksum\n"); 688 printf("Doing cbc_cksum\n");
689 des_key_sched(&cbc_key,ks); 689 des_set_key_checked(&cbc_key,ks);
690 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv); 690 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
691 if (cs != cbc_cksum_ret) 691 if (cs != cbc_cksum_ret)
692 { 692 {
@@ -795,8 +795,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
795 err=1; 795 err=1;
796 } 796 }
797 printf("\n"); 797 printf("\n");
798 exit(err); 798 return(err);
799 return(0);
800 } 799 }
801 800
802static char *pt(unsigned char *p) 801static char *pt(unsigned char *p)
@@ -825,7 +824,7 @@ static int cfb_test(int bits, unsigned char *cfb_cipher)
825 des_key_schedule ks; 824 des_key_schedule ks;
826 int i,err=0; 825 int i,err=0;
827 826
828 des_key_sched(&cfb_key,ks); 827 des_set_key_checked(&cfb_key,ks);
829 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 828 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
830 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp, 829 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
831 DES_ENCRYPT); 830 DES_ENCRYPT);
@@ -854,7 +853,7 @@ static int cfb64_test(unsigned char *cfb_cipher)
854 des_key_schedule ks; 853 des_key_schedule ks;
855 int err=0,i,n; 854 int err=0,i,n;
856 855
857 des_key_sched(&cfb_key,ks); 856 des_set_key_checked(&cfb_key,ks);
858 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 857 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
859 n=0; 858 n=0;
860 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT); 859 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
@@ -887,7 +886,7 @@ static int ede_cfb64_test(unsigned char *cfb_cipher)
887 des_key_schedule ks; 886 des_key_schedule ks;
888 int err=0,i,n; 887 int err=0,i,n;
889 888
890 des_key_sched(&cfb_key,ks); 889 des_set_key_checked(&cfb_key,ks);
891 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 890 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
892 n=0; 891 n=0;
893 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n, 892 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
index 694970ccd2..7399ff7269 100644
--- a/src/lib/libcrypto/des/enc_read.c
+++ b/src/lib/libcrypto/des/enc_read.c
@@ -147,7 +147,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
147 /* first - get the length */ 147 /* first - get the length */
148 while (net_num < HDRSIZE) 148 while (net_num < HDRSIZE)
149 { 149 {
150 i=read(fd,&(net[net_num]),HDRSIZE-net_num); 150 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
151#ifdef EINTR 151#ifdef EINTR
152 if ((i == -1) && (errno == EINTR)) continue; 152 if ((i == -1) && (errno == EINTR)) continue;
153#endif 153#endif
@@ -169,7 +169,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
169 net_num=0; 169 net_num=0;
170 while (net_num < rnum) 170 while (net_num < rnum)
171 { 171 {
172 i=read(fd,&(net[net_num]),rnum-net_num); 172 i=read(fd,(void *)&(net[net_num]),rnum-net_num);
173#ifdef EINTR 173#ifdef EINTR
174 if ((i == -1) && (errno == EINTR)) continue; 174 if ((i == -1) && (errno == EINTR)) continue;
175#endif 175#endif
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
index ba3f0822ef..4d3452724e 100644
--- a/src/lib/libcrypto/des/enc_writ.c
+++ b/src/lib/libcrypto/des/enc_writ.c
@@ -130,12 +130,12 @@ int des_enc_write(int fd, const void *_buf, int len,
130 { 130 {
131 cp=shortbuf; 131 cp=shortbuf;
132 memcpy(shortbuf,buf,len); 132 memcpy(shortbuf,buf,len);
133 RAND_bytes(shortbuf+len, 8-len); 133 RAND_pseudo_bytes(shortbuf+len, 8-len);
134 rnum=8; 134 rnum=8;
135 } 135 }
136 else 136 else
137 { 137 {
138 cp=(unsigned char*)buf; 138 cp=buf;
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
@@ -152,13 +152,16 @@ int des_enc_write(int fd, const void *_buf, int len,
152 for (j=0; j<outnum; j+=i) 152 for (j=0; j<outnum; j+=i)
153 { 153 {
154 /* eay 26/08/92 I was not doing writing from where we 154 /* eay 26/08/92 I was not doing writing from where we
155 * got upto. */ 155 * got up to. */
156 i=write(fd,&(outbuf[j]),outnum-j); 156 i=write(fd,(void *)&(outbuf[j]),outnum-j);
157 if (i == -1) 157 if (i == -1)
158 { 158 {
159#ifdef EINTR
159 if (errno == EINTR) 160 if (errno == EINTR)
160 i=0; 161 i=0;
161 else /* This is really a bad error - very bad 162 else
163#endif
164 /* This is really a bad error - very bad
162 * It will stuff-up both ends. */ 165 * It will stuff-up both ends. */
163 return(-1); 166 return(-1);
164 } 167 }
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c
index f36746b376..fa1b8aa34a 100644
--- a/src/lib/libcrypto/des/fcrypt.c
+++ b/src/lib/libcrypto/des/fcrypt.c
@@ -1,7 +1,7 @@
1/* NOCW */ 1/* NOCW */
2#include <stdio.h> 2#include <stdio.h>
3 3
4/* This version of crypt has been developed from my MIT compatable 4/* This version of crypt has been developed from my MIT compatible
5 * DES library. 5 * DES library.
6 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au 6 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
7 * Eric Young (eay@cryptsoft.com) 7 * Eric Young (eay@cryptsoft.com)
@@ -11,7 +11,7 @@
11 * I have included directive PARA for shared memory computers. 11 * I have included directive PARA for shared memory computers.
12 * I have included a directive LONGCRYPT to using this routine to cipher 12 * I have included a directive LONGCRYPT to using this routine to cipher
13 * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN 13 * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN
14 * definition is the maximum of lenght of password and can changed. I have 14 * definition is the maximum of length of password and can changed. I have
15 * defined 24. 15 * defined 24.
16 */ 16 */
17 17
@@ -103,8 +103,8 @@ char *ret;
103 * returns *\0XXXXXXXXX 103 * returns *\0XXXXXXXXX
104 * The \0 makes the string look like * so the pwd "*" would 104 * The \0 makes the string look like * so the pwd "*" would
105 * crypt to "*". This was found when replacing the crypt in 105 * crypt to "*". This was found when replacing the crypt in
106 * our shared libraries. People found that the disbled 106 * our shared libraries. People found that the disabled
107 * accounts effectivly had no passwd :-(. */ 107 * accounts effectively had no passwd :-(. */
108 x=ret[0]=((salt[0] == '\0')?'A':salt[0]); 108 x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
109 Eswap0=con_salt[x]<<2; 109 Eswap0=con_salt[x]<<2;
110 x=ret[1]=((salt[1] == '\0')?'A':salt[1]); 110 x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
@@ -123,7 +123,7 @@ r=(r+7)/8;
123 for (; i<8; i++) 123 for (; i<8; i++)
124 key[i]=0; 124 key[i]=0;
125 125
126 des_set_key((des_cblock *)(key),ks); 126 des_set_key_unchecked(&key,ks);
127 fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); 127 fcrypt_body(&(out[0]),ks,Eswap0,Eswap1);
128 128
129 ll=out[0]; l2c(ll,b); 129 ll=out[0]; l2c(ll,b);
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index 9cbea97c1f..83c94054e3 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -58,7 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61/* This version of crypt has been developed from my MIT compatable 61/* This version of crypt has been developed from my MIT compatible
62 * DES library. 62 * DES library.
63 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au 63 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
64 * Eric Young (eay@cryptsoft.com) 64 * Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c
index fc11792cda..7816a8f25c 100644
--- a/src/lib/libcrypto/des/rand_key.c
+++ b/src/lib/libcrypto/des/rand_key.c
@@ -1,114 +1,69 @@
1/* crypto/des/rand_key.c */ 1/* crypto/des/rand_key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* ====================================================================
3 * All rights reserved. 3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
4 * 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 5 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
25 * are met: 7 * are met:
26 * 1. Redistributions of source code must retain the copyright 8 *
27 * notice, this list of conditions and the following disclaimer. 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
28 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in
30 * documentation and/or other materials provided with the distribution. 14 * the documentation and/or other materials provided with the
31 * 3. All advertising materials mentioning features or use of this software 15 * distribution.
32 * must display the following acknowledgement: 16 *
33 * "This product includes cryptographic software written by 17 * 3. All advertising materials mentioning features or use of this
34 * Eric Young (eay@cryptsoft.com)" 18 * software must display the following acknowledgment:
35 * The word 'cryptographic' can be left out if the rouines from the library 19 * "This product includes software developed by the OpenSSL Project
36 * being used are not cryptographic related :-). 20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
37 * 4. If you include any Windows specific code (or a derivative thereof) from 21 *
38 * the apps directory (application code) you must include an acknowledgement: 22 * 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)" 23 * endorse or promote products derived from this software without
40 * 24 * prior written permission. For written permission, please contact
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 25 * openssl-core@openssl.org.
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 *
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * 5. Products derived from this software may not be called "OpenSSL"
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 28 * nor may "OpenSSL" appear in their names without prior written
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * permission of the OpenSSL Project.
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 *
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * 6. Redistributions of any form whatsoever must retain the following
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * acknowledgment:
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * "This product includes software developed by the OpenSSL Project
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
51 * SUCH DAMAGE. 35 *
52 * 36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
53 * The licence and distribution terms for any publically available version or 37 * 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 38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * copied and put under another distribution licence 39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
56 * [including the GNU Public Licence.] 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 *
57 */ 54 */
58 55
59#include "des_locl.h" 56#include <openssl/des.h>
60#include <time.h> 57#include <openssl/rand.h>
61
62static int seed=0;
63static des_cblock init;
64 58
65void des_random_seed(des_cblock *key) 59void des_random_seed(des_cblock *key)
66 { 60 {
67 memcpy(&init,key,sizeof(des_cblock)); 61 RAND_seed(key, sizeof(des_cblock));
68 seed=1;
69 } 62 }
70 63
71void des_random_key(des_cblock *ret) 64int des_random_key(des_cblock *ret)
72 { 65 {
73 des_key_schedule ks; 66 int r = RAND_bytes((unsigned char *)ret, sizeof(des_cblock));
74 static DES_LONG c=0; 67 des_set_odd_parity(ret);
75 static unsigned short pid=0; 68 return r;
76 static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
77 des_cblock key;
78 unsigned char *p;
79 DES_LONG t;
80 int i;
81
82#ifdef MSDOS
83 pid=1;
84#else
85 if (!pid) pid=getpid();
86#endif
87 p=key;
88 if (seed)
89 {
90 for (i=0; i<8; i++)
91 {
92 data[i] ^= init[i];
93 init[i]=0;
94 }
95 seed=0;
96 }
97 t=(DES_LONG)time(NULL);
98 l2c(t,p);
99 t=(DES_LONG)((pid)|((c++)<<16));
100 l2c(t,p);
101
102 des_set_odd_parity(&data);
103 des_set_key(&data,ks);
104 des_cbc_cksum(key,&key,sizeof(key),ks,&data);
105
106 des_set_odd_parity(&key);
107 des_set_key(&key,ks);
108 des_cbc_cksum(key,&data,sizeof(key),ks,&key);
109
110 memcpy(ret,data,sizeof(key));
111 memset(key,0,sizeof(key));
112 memset(ks,0,sizeof(ks));
113 t=0;
114 } 69 }
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
index fed49652c0..fa2d67da64 100644
--- a/src/lib/libcrypto/des/read_pwd.c
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -58,7 +58,11 @@
58 58
59#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) 59#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
60#include <openssl/opensslconf.h> 60#include <openssl/opensslconf.h>
61#include OPENSSL_UNISTD 61#ifdef OPENSSL_UNISTD
62# include OPENSSL_UNISTD
63#else
64# include <unistd.h>
65#endif
62/* If unistd.h defines _POSIX_VERSION, we conclude that we 66/* If unistd.h defines _POSIX_VERSION, we conclude that we
63 * are on a POSIX system and have sigaction and termios. */ 67 * are on a POSIX system and have sigaction and termios. */
64#if defined(_POSIX_VERSION) 68#if defined(_POSIX_VERSION)
@@ -123,7 +127,7 @@
123#undef SGTTY 127#undef SGTTY
124#endif 128#endif
125 129
126#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) 130#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE)
127#undef TERMIOS 131#undef TERMIOS
128#undef TERMIO 132#undef TERMIO
129#define SGTTY 133#define SGTTY
@@ -153,7 +157,7 @@
153#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) 157#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
154#endif 158#endif
155 159
156#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) 160#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) && !defined(MAC_OS_pre_X)
157#include <sys/ioctl.h> 161#include <sys/ioctl.h>
158#endif 162#endif
159 163
@@ -174,6 +178,15 @@ struct IOSB {
174 }; 178 };
175#endif 179#endif
176 180
181#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
182/*
183 * This one needs work. As a matter of fact the code is unoperational
184 * and this is only a trick to get it compiled.
185 * <appro@fy.chalmers.se>
186 */
187#define TTY_STRUCT int
188#endif
189
177#ifndef NX509_SIG 190#ifndef NX509_SIG
178#define NX509_SIG 32 191#define NX509_SIG 32
179#endif 192#endif
diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c
index c96c204147..32d96d5cae 100644
--- a/src/lib/libcrypto/des/rpc_enc.c
+++ b/src/lib/libcrypto/des/rpc_enc.c
@@ -66,7 +66,7 @@ int _des_crypt(char *buf, int len, struct desparams *desp)
66 des_key_schedule ks; 66 des_key_schedule ks;
67 int enc; 67 int enc;
68 68
69 des_set_key(&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)
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index 52553a4c16..bbdc71ba6b 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -125,7 +125,7 @@ int des_is_weak_key(const_des_cblock *key)
125 int i; 125 int i;
126 126
127 for (i=0; i<NUM_WEAK_KEY; i++) 127 for (i=0; i<NUM_WEAK_KEY; i++)
128 /* Added == 0 to comparision, I obviously don't run 128 /* Added == 0 to comparison, I obviously don't run
129 * this section very often :-(, thanks to 129 * this section very often :-(, thanks to
130 * engineering@MorningStar.Com for the fix 130 * engineering@MorningStar.Com for the fix
131 * eay 93/06/29 131 * eay 93/06/29
@@ -145,11 +145,34 @@ int des_is_weak_key(const_des_cblock *key)
145#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ 145#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
146 (a)=(a)^(t)^(t>>(16-(n)))) 146 (a)=(a)^(t)^(t>>(16-(n))))
147 147
148int des_set_key(const_des_cblock *key, des_key_schedule schedule)
149 {
150 if (des_check_key)
151 {
152 return des_set_key_checked(key, schedule);
153 }
154 else
155 {
156 des_set_key_unchecked(key, schedule);
157 return 0;
158 }
159 }
160
148/* return 0 if key parity is odd (correct), 161/* return 0 if key parity is odd (correct),
149 * return -1 if key parity error, 162 * return -1 if key parity error,
150 * return -2 if illegal weak key. 163 * return -2 if illegal weak key.
151 */ 164 */
152int des_set_key(const_des_cblock *key, des_key_schedule schedule) 165int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule)
166 {
167 if (!check_parity(key))
168 return(-1);
169 if (des_is_weak_key(key))
170 return(-2);
171 des_set_key_unchecked(key, schedule);
172 return 0;
173 }
174
175void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
153 { 176 {
154 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 177 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
155 register DES_LONG c,d,t,s,t2; 178 register DES_LONG c,d,t,s,t2;
@@ -157,15 +180,6 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
157 register DES_LONG *k; 180 register DES_LONG *k;
158 register int i; 181 register int i;
159 182
160 if (des_check_key)
161 {
162 if (!check_parity(key))
163 return(-1);
164
165 if (des_is_weak_key(key))
166 return(-2);
167 }
168
169 k = &schedule->ks.deslong[0]; 183 k = &schedule->ks.deslong[0];
170 in = &(*key)[0]; 184 in = &(*key)[0];
171 185
@@ -225,7 +239,6 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
225 t2=((s>>16L)|(t&0xffff0000L)); 239 t2=((s>>16L)|(t&0xffff0000L));
226 *(k++)=ROTATE(t2,26)&0xffffffffL; 240 *(k++)=ROTATE(t2,26)&0xffffffffL;
227 } 241 }
228 return(0);
229 } 242 }
230 243
231int des_key_sched(const_des_cblock *key, des_key_schedule schedule) 244int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c
index da41abcb03..814b86f4ae 100644
--- a/src/lib/libcrypto/des/speed.c
+++ b/src/lib/libcrypto/des/speed.c
@@ -186,16 +186,16 @@ int main(int argc, char **argv)
186#endif 186#endif
187 187
188#ifndef TIMES 188#ifndef TIMES
189 printf("To get the most acurate results, try to run this\n"); 189 printf("To get the most accurate results, try to run this\n");
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(&key2,sch2); 193 des_set_key_unchecked(&key2,sch2);
194 des_set_key(&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(&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;
@@ -225,7 +225,7 @@ 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(&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;
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c
index 24841452f1..c6abb87201 100644
--- a/src/lib/libcrypto/des/str2key.c
+++ b/src/lib/libcrypto/des/str2key.c
@@ -58,8 +58,6 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61OPENSSL_EXTERN int des_check_key;
62
63void des_string_to_key(const char *str, des_cblock *key) 61void des_string_to_key(const char *str, des_cblock *key)
64 { 62 {
65 des_key_schedule ks; 63 des_key_schedule ks;
@@ -88,11 +86,8 @@ void des_string_to_key(const char *str, des_cblock *key)
88 } 86 }
89#endif 87#endif
90 des_set_odd_parity(key); 88 des_set_odd_parity(key);
91 i=des_check_key; 89 des_set_key_unchecked(key,ks);
92 des_check_key=0; 90 des_cbc_cksum((const unsigned char*)str,key,length,ks,key);
93 des_set_key(key,ks);
94 des_check_key=i;
95 des_cbc_cksum((unsigned char*)str,key,length,ks,key);
96 memset(ks,0,sizeof(ks)); 91 memset(ks,0,sizeof(ks));
97 des_set_odd_parity(key); 92 des_set_odd_parity(key);
98 } 93 }
@@ -150,13 +145,10 @@ void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2)
150#endif 145#endif
151 des_set_odd_parity(key1); 146 des_set_odd_parity(key1);
152 des_set_odd_parity(key2); 147 des_set_odd_parity(key2);
153 i=des_check_key; 148 des_set_key_unchecked(key1,ks);
154 des_check_key=0; 149 des_cbc_cksum((const unsigned char*)str,key1,length,ks,key1);
155 des_set_key(key1,ks); 150 des_set_key_unchecked(key2,ks);
156 des_cbc_cksum((unsigned char*)str,key1,length,ks,key1); 151 des_cbc_cksum((const unsigned char*)str,key2,length,ks,key2);
157 des_set_key(key2,ks);
158 des_cbc_cksum((unsigned char*)str,key2,length,ks,key2);
159 des_check_key=i;
160 memset(ks,0,sizeof(ks)); 152 memset(ks,0,sizeof(ks));
161 des_set_odd_parity(key1); 153 des_set_odd_parity(key1);
162 des_set_odd_parity(key2); 154 des_set_odd_parity(key2);
diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl
index 3b5ec0e115..8df60872ef 100644
--- a/src/lib/libcrypto/dh/Makefile.ssl
+++ b/src/lib/libcrypto/dh/Makefile.ssl
@@ -83,26 +83,30 @@ dh_check.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
83dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 83dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
84dh_check.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84dh_check.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85dh_check.o: ../../include/openssl/opensslconf.h 85dh_check.o: ../../include/openssl/opensslconf.h
86dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 86dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87dh_check.o: ../cryptlib.h 87dh_check.o: ../../include/openssl/stack.h ../cryptlib.h
88dh_err.o: ../../include/openssl/bn.h ../../include/openssl/dh.h 88dh_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
89dh_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 89dh_err.o: ../../include/openssl/dh.h ../../include/openssl/err.h
90dh_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
91dh_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90dh_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 92dh_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
91dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 93dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
92dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 94dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
93dh_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 95dh_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
94dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 96dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
95dh_gen.o: ../../include/openssl/stack.h ../cryptlib.h 97dh_gen.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
98dh_gen.o: ../cryptlib.h
96dh_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 99dh_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
97dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 100dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
98dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 101dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
99dh_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 102dh_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
100dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 103dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
101dh_key.o: ../../include/openssl/rand.h ../../include/openssl/stack.h 104dh_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
102dh_key.o: ../cryptlib.h 105dh_key.o: ../../include/openssl/stack.h ../cryptlib.h
103dh_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 106dh_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
104dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 107dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
105dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 108dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
106dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 109dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
107dh_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 110dh_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
108dh_lib.o: ../../include/openssl/stack.h ../cryptlib.h 111dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
112dh_lib.o: ../cryptlib.h
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 2cc3797a94..c15b2ad483 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -68,10 +68,28 @@ extern "C" {
68#endif 68#endif
69 69
70#include <openssl/bn.h> 70#include <openssl/bn.h>
71#include <openssl/crypto.h>
71 72
72#define DH_FLAG_CACHE_MONT_P 0x01 73#define DH_FLAG_CACHE_MONT_P 0x01
73 74
74typedef struct dh_st 75typedef struct dh_st DH;
76
77typedef struct dh_method {
78 const char *name;
79 /* Methods here */
80 int (*generate_key)(DH *dh);
81 int (*compute_key)(unsigned char *key,BIGNUM *pub_key,DH *dh);
82 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
83 const BIGNUM *m, BN_CTX *ctx,
84 BN_MONT_CTX *m_ctx); /* Can be null */
85
86 int (*init)(DH *dh);
87 int (*finish)(DH *dh);
88 int flags;
89 char *app_data;
90} DH_METHOD;
91
92struct dh_st
75 { 93 {
76 /* This first argument is used to pick up errors when 94 /* This first argument is used to pick up errors when
77 * a DH is passed instead of a EVP_PKEY */ 95 * a DH is passed instead of a EVP_PKEY */
@@ -80,12 +98,22 @@ typedef struct dh_st
80 BIGNUM *p; 98 BIGNUM *p;
81 BIGNUM *g; 99 BIGNUM *g;
82 int length; /* optional */ 100 int length; /* optional */
83 BIGNUM *pub_key; /* y */ 101 BIGNUM *pub_key; /* g^x */
84 BIGNUM *priv_key; /* x */ 102 BIGNUM *priv_key; /* x */
85 103
86 int flags; 104 int flags;
87 char *method_mont_p; 105 char *method_mont_p;
88 } DH; 106 /* Place holders if we want to do X9.42 DH */
107 BIGNUM *q;
108 BIGNUM *j;
109 unsigned char *seed;
110 int seedlen;
111 BIGNUM *counter;
112
113 int references;
114 CRYPTO_EX_DATA ex_data;
115 DH_METHOD *meth;
116 };
89 117
90#define DH_GENERATOR_2 2 118#define DH_GENERATOR_2 2
91/* #define DH_GENERATOR_3 3 */ 119/* #define DH_GENERATOR_3 3 */
@@ -93,10 +121,14 @@ typedef struct dh_st
93 121
94/* DH_check error codes */ 122/* DH_check error codes */
95#define DH_CHECK_P_NOT_PRIME 0x01 123#define DH_CHECK_P_NOT_PRIME 0x01
96#define DH_CHECK_P_NOT_STRONG_PRIME 0x02 124#define DH_CHECK_P_NOT_SAFE_PRIME 0x02
97#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 125#define DH_UNABLE_TO_CHECK_GENERATOR 0x04
98#define DH_NOT_SUITABLE_GENERATOR 0x08 126#define DH_NOT_SUITABLE_GENERATOR 0x08
99 127
128/* primes p where (p-1)/2 is prime too are called "safe"; we define
129 this for backward compatibility: */
130#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
131
100#define DHparams_dup(x) (DH *)ASN1_dup((int (*)())i2d_DHparams, \ 132#define DHparams_dup(x) (DH *)ASN1_dup((int (*)())i2d_DHparams, \
101 (char *(*)())d2i_DHparams,(char *)(x)) 133 (char *(*)())d2i_DHparams,(char *)(x))
102#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ 134#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
@@ -113,9 +145,20 @@ typedef struct dh_st
113 (unsigned char *)(x)) 145 (unsigned char *)(x))
114#endif 146#endif
115 147
148DH_METHOD *DH_OpenSSL(void);
149
150void DH_set_default_method(DH_METHOD *meth);
151DH_METHOD *DH_get_default_method(void);
152DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
153DH *DH_new_method(DH_METHOD *meth);
154
116DH * DH_new(void); 155DH * DH_new(void);
117void DH_free(DH *dh); 156void DH_free(DH *dh);
118int DH_size(DH *dh); 157int DH_size(DH *dh);
158int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
159 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
160int DH_set_ex_data(DH *d, int idx, void *arg);
161void *DH_get_ex_data(DH *d, int idx);
119DH * DH_generate_parameters(int prime_len,int generator, 162DH * DH_generate_parameters(int prime_len,int generator,
120 void (*callback)(int,int,void *),void *cb_arg); 163 void (*callback)(int,int,void *),void *cb_arg);
121int DH_check(DH *dh,int *codes); 164int DH_check(DH *dh,int *codes);
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c
index 95ce9cfad0..7e5cfd8bfc 100644
--- a/src/lib/libcrypto/dh/dh_check.c
+++ b/src/lib/libcrypto/dh/dh_check.c
@@ -61,7 +61,7 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63 63
64/* Check that p is a strong prime and 64/* Check that p is a safe prime and
65 * if g is 2, 3 or 5, check that is is a suitable generator 65 * if g is 2, 3 or 5, check that is is a suitable generator
66 * where 66 * where
67 * for 2, p mod 24 == 11 67 * for 2, p mod 24 == 11
@@ -88,11 +88,13 @@ int DH_check(DH *dh, int *ret)
88 l=BN_mod_word(dh->p,24); 88 l=BN_mod_word(dh->p,24);
89 if (l != 11) *ret|=DH_NOT_SUITABLE_GENERATOR; 89 if (l != 11) *ret|=DH_NOT_SUITABLE_GENERATOR;
90 } 90 }
91/* else if (BN_is_word(dh->g,DH_GENERATOR_3)) 91#if 0
92 else if (BN_is_word(dh->g,DH_GENERATOR_3))
92 { 93 {
93 l=BN_mod_word(dh->p,12); 94 l=BN_mod_word(dh->p,12);
94 if (l != 5) *ret|=DH_NOT_SUITABLE_GENERATOR; 95 if (l != 5) *ret|=DH_NOT_SUITABLE_GENERATOR;
95 }*/ 96 }
97#endif
96 else if (BN_is_word(dh->g,DH_GENERATOR_5)) 98 else if (BN_is_word(dh->g,DH_GENERATOR_5))
97 { 99 {
98 l=BN_mod_word(dh->p,10); 100 l=BN_mod_word(dh->p,10);
@@ -108,7 +110,7 @@ int DH_check(DH *dh, int *ret)
108 { 110 {
109 if (!BN_rshift1(q,dh->p)) goto err; 111 if (!BN_rshift1(q,dh->p)) goto err;
110 if (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL)) 112 if (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL))
111 *ret|=DH_CHECK_P_NOT_STRONG_PRIME; 113 *ret|=DH_CHECK_P_NOT_SAFE_PRIME;
112 } 114 }
113 ok=1; 115 ok=1;
114err: 116err:
diff --git a/src/lib/libcrypto/dh/dh_gen.c b/src/lib/libcrypto/dh/dh_gen.c
index b7bcd2c7a4..7a6a38fbb4 100644
--- a/src/lib/libcrypto/dh/dh_gen.c
+++ b/src/lib/libcrypto/dh/dh_gen.c
@@ -72,14 +72,14 @@
72 * Having said all that, 72 * Having said all that,
73 * there is another special case method for the generators 2, 3 and 5. 73 * there is another special case method for the generators 2, 3 and 5.
74 * for 2, p mod 24 == 11 74 * for 2, p mod 24 == 11
75 * for 3, p mod 12 == 5 <<<<< does not work for strong primes. 75 * for 3, p mod 12 == 5 <<<<< does not work for safe primes.
76 * for 5, p mod 10 == 3 or 7 76 * for 5, p mod 10 == 3 or 7
77 * 77 *
78 * Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the 78 * Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the
79 * special generators and for answering some of my questions. 79 * special generators and for answering some of my questions.
80 * 80 *
81 * I've implemented the second simple method :-). 81 * I've implemented the second simple method :-).
82 * Since DH should be using a strong 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
@@ -95,9 +95,10 @@ DH *DH_generate_parameters(int prime_len, int generator,
95 if (ret == NULL) goto err; 95 if (ret == NULL) goto err;
96 ctx=BN_CTX_new(); 96 ctx=BN_CTX_new();
97 if (ctx == NULL) goto err; 97 if (ctx == NULL) goto err;
98 t1= &(ctx->bn[0]); 98 BN_CTX_start(ctx);
99 t2= &(ctx->bn[1]); 99 t1 = BN_CTX_get(ctx);
100 ctx->tos=2; 100 t2 = BN_CTX_get(ctx);
101 if (t1 == NULL || t2 == NULL) goto err;
101 102
102 if (generator == DH_GENERATOR_2) 103 if (generator == DH_GENERATOR_2)
103 { 104 {
@@ -105,7 +106,7 @@ DH *DH_generate_parameters(int prime_len, int generator,
105 BN_set_word(t2,11); 106 BN_set_word(t2,11);
106 g=2; 107 g=2;
107 } 108 }
108#ifdef undef /* does not work for strong primes */ 109#ifdef undef /* does not work for safe primes */
109 else if (generator == DH_GENERATOR_3) 110 else if (generator == DH_GENERATOR_3)
110 { 111 {
111 BN_set_word(t1,12); 112 BN_set_word(t1,12);
@@ -138,7 +139,11 @@ err:
138 ok=0; 139 ok=0;
139 } 140 }
140 141
141 if (ctx != NULL) BN_CTX_free(ctx); 142 if (ctx != NULL)
143 {
144 BN_CTX_end(ctx);
145 BN_CTX_free(ctx);
146 }
142 if (!ok && (ret != NULL)) 147 if (!ok && (ret != NULL))
143 { 148 {
144 DH_free(ret); 149 DH_free(ret);
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index cede53bfc1..0c7eeaf260 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -62,8 +62,42 @@
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64 64
65static int generate_key(DH *dh);
66static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
67static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
68 const BIGNUM *m, BN_CTX *ctx,
69 BN_MONT_CTX *m_ctx);
70static int dh_init(DH *dh);
71static int dh_finish(DH *dh);
72
65int DH_generate_key(DH *dh) 73int DH_generate_key(DH *dh)
66 { 74 {
75 return dh->meth->generate_key(dh);
76 }
77
78int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
79 {
80 return dh->meth->compute_key(key, pub_key, dh);
81 }
82
83static DH_METHOD dh_ossl = {
84"OpenSSL DH Method",
85generate_key,
86compute_key,
87dh_bn_mod_exp,
88dh_init,
89dh_finish,
900,
91NULL
92};
93
94DH_METHOD *DH_OpenSSL(void)
95{
96 return &dh_ossl;
97}
98
99static int generate_key(DH *dh)
100 {
67 int ok=0; 101 int ok=0;
68 unsigned int i; 102 unsigned int i;
69 BN_CTX ctx; 103 BN_CTX ctx;
@@ -103,7 +137,8 @@ int DH_generate_key(DH *dh)
103 } 137 }
104 mont=(BN_MONT_CTX *)dh->method_mont_p; 138 mont=(BN_MONT_CTX *)dh->method_mont_p;
105 139
106 if (!BN_mod_exp_mont(pub_key,dh->g,priv_key,dh->p,&ctx,mont)) goto err; 140 if (!dh->meth->bn_mod_exp(dh, pub_key,dh->g,priv_key,dh->p,&ctx,mont))
141 goto err;
107 142
108 dh->pub_key=pub_key; 143 dh->pub_key=pub_key;
109 dh->priv_key=priv_key; 144 dh->priv_key=priv_key;
@@ -118,7 +153,7 @@ err:
118 return(ok); 153 return(ok);
119 } 154 }
120 155
121int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) 156static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
122 { 157 {
123 BN_CTX ctx; 158 BN_CTX ctx;
124 BN_MONT_CTX *mont; 159 BN_MONT_CTX *mont;
@@ -126,7 +161,8 @@ int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
126 int ret= -1; 161 int ret= -1;
127 162
128 BN_CTX_init(&ctx); 163 BN_CTX_init(&ctx);
129 tmp= &(ctx.bn[ctx.tos++]); 164 BN_CTX_start(&ctx);
165 tmp = BN_CTX_get(&ctx);
130 166
131 if (dh->priv_key == NULL) 167 if (dh->priv_key == NULL)
132 { 168 {
@@ -141,7 +177,7 @@ int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
141 } 177 }
142 178
143 mont=(BN_MONT_CTX *)dh->method_mont_p; 179 mont=(BN_MONT_CTX *)dh->method_mont_p;
144 if (!BN_mod_exp_mont(tmp,pub_key,dh->priv_key,dh->p,&ctx,mont)) 180 if (!dh->meth->bn_mod_exp(dh, tmp,pub_key,dh->priv_key,dh->p,&ctx,mont))
145 { 181 {
146 DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB); 182 DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB);
147 goto err; 183 goto err;
@@ -149,6 +185,27 @@ int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
149 185
150 ret=BN_bn2bin(tmp,key); 186 ret=BN_bn2bin(tmp,key);
151err: 187err:
188 BN_CTX_end(&ctx);
152 BN_CTX_free(&ctx); 189 BN_CTX_free(&ctx);
153 return(ret); 190 return(ret);
154 } 191 }
192
193static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
194 const BIGNUM *m, BN_CTX *ctx,
195 BN_MONT_CTX *m_ctx)
196{
197 return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
198}
199
200static int dh_init(DH *dh)
201{
202 dh->flags |= DH_FLAG_CACHE_MONT_P;
203 return(1);
204}
205
206static int dh_finish(DH *dh)
207{
208 if(dh->method_mont_p)
209 BN_MONT_CTX_free((BN_MONT_CTX *)dh->method_mont_p);
210 return(1);
211}
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 61e0720e8a..6c21463028 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -63,16 +63,49 @@
63 63
64const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; 64const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
65 65
66static DH_METHOD *default_DH_method;
67static int dh_meth_num = 0;
68static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dh_meth = NULL;
69
70void DH_set_default_method(DH_METHOD *meth)
71{
72 default_DH_method = meth;
73}
74
75DH_METHOD *DH_get_default_method(void)
76{
77 if(!default_DH_method) default_DH_method = DH_OpenSSL();
78 return default_DH_method;
79}
80
81DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth)
82{
83 DH_METHOD *mtmp;
84 mtmp = dh->meth;
85 if (mtmp->finish) mtmp->finish(dh);
86 dh->meth = meth;
87 if (meth->init) meth->init(dh);
88 return mtmp;
89}
90
66DH *DH_new(void) 91DH *DH_new(void)
92{
93 return DH_new_method(NULL);
94}
95
96DH *DH_new_method(DH_METHOD *meth)
67 { 97 {
68 DH *ret; 98 DH *ret;
69
70 ret=(DH *)Malloc(sizeof(DH)); 99 ret=(DH *)Malloc(sizeof(DH));
100
71 if (ret == NULL) 101 if (ret == NULL)
72 { 102 {
73 DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE); 103 DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE);
74 return(NULL); 104 return(NULL);
75 } 105 }
106 if(!default_DH_method) default_DH_method = DH_OpenSSL();
107 if(meth) ret->meth = meth;
108 else ret->meth = default_DH_method;
76 ret->pad=0; 109 ret->pad=0;
77 ret->version=0; 110 ret->version=0;
78 ret->p=NULL; 111 ret->p=NULL;
@@ -80,23 +113,74 @@ DH *DH_new(void)
80 ret->length=0; 113 ret->length=0;
81 ret->pub_key=NULL; 114 ret->pub_key=NULL;
82 ret->priv_key=NULL; 115 ret->priv_key=NULL;
83 ret->flags=DH_FLAG_CACHE_MONT_P; 116 ret->q=NULL;
117 ret->j=NULL;
118 ret->seed = NULL;
119 ret->seedlen = 0;
120 ret->counter = NULL;
84 ret->method_mont_p=NULL; 121 ret->method_mont_p=NULL;
122 ret->references = 1;
123 ret->flags=ret->meth->flags;
124 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
125 {
126 Free(ret);
127 ret=NULL;
128 }
129 else
130 CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data);
85 return(ret); 131 return(ret);
86 } 132 }
87 133
88void DH_free(DH *r) 134void DH_free(DH *r)
89 { 135 {
136 int i;
90 if(r == NULL) return; 137 if(r == NULL) return;
138 i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH);
139#ifdef REF_PRINT
140 REF_PRINT("DH",r);
141#endif
142 if (i > 0) return;
143#ifdef REF_CHECK
144 if (i < 0)
145 {
146 fprintf(stderr,"DH_free, bad reference count\n");
147 abort();
148 }
149#endif
150
151 CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
152
153 if(r->meth->finish) r->meth->finish(r);
154
91 if (r->p != NULL) BN_clear_free(r->p); 155 if (r->p != NULL) BN_clear_free(r->p);
92 if (r->g != NULL) BN_clear_free(r->g); 156 if (r->g != NULL) BN_clear_free(r->g);
157 if (r->q != NULL) BN_clear_free(r->q);
158 if (r->j != NULL) BN_clear_free(r->j);
159 if (r->seed) Free(r->seed);
160 if (r->counter != NULL) BN_clear_free(r->counter);
93 if (r->pub_key != NULL) BN_clear_free(r->pub_key); 161 if (r->pub_key != NULL) BN_clear_free(r->pub_key);
94 if (r->priv_key != NULL) BN_clear_free(r->priv_key); 162 if (r->priv_key != NULL) BN_clear_free(r->priv_key);
95 if (r->method_mont_p != NULL)
96 BN_MONT_CTX_free((BN_MONT_CTX *)r->method_mont_p);
97 Free(r); 163 Free(r);
98 } 164 }
99 165
166int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
167 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
168 {
169 dh_meth_num++;
170 return(CRYPTO_get_ex_new_index(dh_meth_num-1,
171 &dh_meth,argl,argp,new_func,dup_func,free_func));
172 }
173
174int DH_set_ex_data(DH *d, int idx, void *arg)
175 {
176 return(CRYPTO_set_ex_data(&d->ex_data,idx,arg));
177 }
178
179void *DH_get_ex_data(DH *d, int idx)
180 {
181 return(CRYPTO_get_ex_data(&d->ex_data,idx));
182 }
183
100int DH_size(DH *dh) 184int DH_size(DH *dh)
101 { 185 {
102 return(BN_num_bytes(dh->p)); 186 return(BN_num_bytes(dh->p));
diff --git a/src/lib/libcrypto/dh/dhtest.c b/src/lib/libcrypto/dh/dhtest.c
index 770331971f..d66c28455e 100644
--- a/src/lib/libcrypto/dh/dhtest.c
+++ b/src/lib/libcrypto/dh/dhtest.c
@@ -65,6 +65,7 @@
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 69
69#ifdef NO_DH 70#ifdef NO_DH
70int main(int argc, char *argv[]) 71int main(int argc, char *argv[])
@@ -87,19 +88,23 @@ static void MS_CALLBACK cb(int p, int n, void *arg);
87#include "bss_file.c" 88#include "bss_file.c"
88#endif 89#endif
89 90
90BIO *out=NULL; 91static const char rnd_seed[] = "string to make the random number generator think it has entropy";
91 92
92int main(int argc, char *argv[]) 93int main(int argc, char *argv[])
93 { 94 {
94 DH *a,*b; 95 DH *a;
96 DH *b=NULL;
95 char buf[12]; 97 char buf[12];
96 unsigned char *abuf=NULL,*bbuf=NULL; 98 unsigned char *abuf=NULL,*bbuf=NULL;
97 int i,alen,blen,aout,bout,ret=1; 99 int i,alen,blen,aout,bout,ret=1;
100 BIO *out;
98 101
99#ifdef WIN32 102#ifdef WIN32
100 CRYPTO_malloc_init(); 103 CRYPTO_malloc_init();
101#endif 104#endif
102 105
106 RAND_seed(rnd_seed, sizeof rnd_seed);
107
103 out=BIO_new(BIO_s_file()); 108 out=BIO_new(BIO_s_file());
104 if (out == NULL) exit(1); 109 if (out == NULL) exit(1);
105 BIO_set_fp(out,stdout,BIO_NOCLOSE); 110 BIO_set_fp(out,stdout,BIO_NOCLOSE);
@@ -167,6 +172,9 @@ int main(int argc, char *argv[])
167err: 172err:
168 if (abuf != NULL) Free(abuf); 173 if (abuf != NULL) Free(abuf);
169 if (bbuf != NULL) Free(bbuf); 174 if (bbuf != NULL) Free(bbuf);
175 if(b != NULL) DH_free(b);
176 if(a != NULL) DH_free(a);
177 BIO_free(out);
170 exit(ret); 178 exit(ret);
171 return(ret); 179 return(ret);
172 } 180 }
diff --git a/src/lib/libcrypto/doc/DH_generate_key.pod b/src/lib/libcrypto/doc/DH_generate_key.pod
new file mode 100644
index 0000000000..920995b2e5
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_generate_key.pod
@@ -0,0 +1,50 @@
1=pod
2
3=head1 NAME
4
5DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 int DH_generate_key(DH *dh);
12
13 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
14
15=head1 DESCRIPTION
16
17DH_generate_key() performs the first step of a Diffie-Hellman key
18exchange by generating private and public DH values. By calling
19DH_compute_key(), these are combined with the other party's public
20value to compute the shared key.
21
22DH_generate_key() expects B<dh> to contain the shared parameters
23B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value
24unless B<dh-E<gt>priv_key> is already set, and computes the
25corresponding public value B<dh-E<gt>pub_key>, which can then be
26published.
27
28DH_compute_key() computes the shared secret from the private DH value
29in B<dh> and the other party's public value in B<pub_key> and stores
30it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory.
31
32=head1 RETURN VALUES
33
34DH_generate_key() returns 1 on success, 0 otherwise.
35
36DH_compute_key() returns the size of the shared secret on success, -1
37on error.
38
39The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
40
41=head1 SEE ALSO
42
43L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DH_size(3)|DH_size(3)>
44
45=head1 HISTORY
46
47DH_generate_key() and DH_compute_key() are available in all versions
48of SSLeay and OpenSSL.
49
50=cut
diff --git a/src/lib/libcrypto/doc/DH_generate_parameters.pod b/src/lib/libcrypto/doc/DH_generate_parameters.pod
new file mode 100644
index 0000000000..a7d0c75f0c
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_generate_parameters.pod
@@ -0,0 +1,72 @@
1=pod
2
3=head1 NAME
4
5DH_generate_parameters, DH_check - generate and check Diffie-Hellman parameters
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH *DH_generate_parameters(int prime_len, int generator,
12 void (*callback)(int, int, void *), void *cb_arg);
13
14 int DH_check(DH *dh, int *codes);
15
16=head1 DESCRIPTION
17
18DH_generate_parameters() generates Diffie-Hellman parameters that can
19be shared among a group of users, and returns them in a newly
20allocated B<DH> structure. The pseudo-random number generator must be
21seeded prior to calling DH_generate_parameters().
22
23B<prime_len> is the length in bits of the safe prime to be generated.
24B<generator> is a small number E<gt> 1, typically 2 or 5.
25
26A callback function may be used to provide feedback about the progress
27of the key generation. If B<callback> is not B<NULL>, it will be
28called as described in L<BN_generate_prime(3)|BN_generate_prime(3)> while a random prime
29number is generated, and when a prime has been found, B<callback(3,
300, cb_arg)> is called.
31
32DH_check() validates Diffie-Hellman parameters. It checks that B<p> is
33a safe prime, and that B<g> is a suitable generator. In the case of an
34error, the bit flags DH_CHECK_P_NOT_SAFE_PRIME or
35DH_NOT_SUITABLE_GENERATOR are set in B<*codes>.
36DH_UNABLE_TO_CHECK_GENERATOR is set if the generator cannot be
37checked, i.e. it does not equal 2 or 5.
38
39=head1 RETURN VALUES
40
41DH_generate_parameters() returns a pointer to the DH structure, or
42NULL if the parameter generation fails. The error codes can be
43obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
44
45DH_check() returns 1 if the check could be performed, 0 otherwise.
46
47=head1 NOTES
48
49DH_generate_parameters() may run for several hours before finding a
50suitable prime.
51
52The parameters generated by DH_generate_parameters() are not to be
53used in signature schemes.
54
55=head1 BUGS
56
57If B<generator> is not 2 or 5, B<dh-E<gt>g>=B<generator> is not
58a usable generator.
59
60=head1 SEE ALSO
61
62L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DH_free(3)|DH_free(3)>
63
64=head1 HISTORY
65
66DH_check() is available in all versions of SSLeay and OpenSSL.
67The B<cb_arg> argument to DH_generate_parameters() was added in SSLeay 0.9.0.
68
69In versions before OpenSSL 0.9.5, DH_CHECK_P_NOT_STRONG_PRIME is used
70instead of DH_CHECK_P_NOT_SAFE_PRIME.
71
72=cut
diff --git a/src/lib/libcrypto/doc/DH_get_ex_new_index.pod b/src/lib/libcrypto/doc/DH_get_ex_new_index.pod
new file mode 100644
index 0000000000..82e2548bcd
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_get_ex_new_index.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5DH_get_ex_new_index, DH_set_ex_data, DH_get_ex_data - add application specific data to DH structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 int DH_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func,
13 CRYPTO_EX_dup *dup_func,
14 CRYPTO_EX_free *free_func);
15
16 int DH_set_ex_data(DH *d, int idx, void *arg);
17
18 char *DH_get_ex_data(DH *d, int idx);
19
20=head1 DESCRIPTION
21
22These functions handle application specific data in DH
23structures. Their usage is identical to that of
24RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data()
25as described in L<RSA_get_ex_new_index(3)>.
26
27=head1 SEE ALSO
28
29L<RSA_get_ex_new_index()|RSA_get_ex_new_index()>, L<dh(3)|dh(3)>
30
31=head1 HISTORY
32
33DH_get_ex_new_index(), DH_set_ex_data() and DH_get_ex_data() are
34available since OpenSSL 0.9.5.
35
36=cut
diff --git a/src/lib/libcrypto/doc/DH_new.pod b/src/lib/libcrypto/doc/DH_new.pod
new file mode 100644
index 0000000000..64624b9d15
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_new.pod
@@ -0,0 +1,40 @@
1=pod
2
3=head1 NAME
4
5DH_new, DH_free - allocate and free DH objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH* DH_new(void);
12
13 void DH_free(DH *dh);
14
15=head1 DESCRIPTION
16
17DH_new() allocates and initializes a B<DH> structure.
18
19DH_free() frees the B<DH> structure and its components. The values are
20erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, DH_new() returns B<NULL> and sets an error
25code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns
26a pointer to the newly allocated structure.
27
28DH_free() returns no value.
29
30=head1 SEE ALSO
31
32L<dh(3)|dh(3)>, L<err(3)|err(3)>,
33L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
34L<DH_generate_key(3)|DH_generate_key(3)>
35
36=head1 HISTORY
37
38DH_new() and DH_free() are available in all versions of SSLeay and OpenSSL.
39
40=cut
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod
new file mode 100644
index 0000000000..dca41d8dbc
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_set_method.pod
@@ -0,0 +1,99 @@
1=pod
2
3=head1 NAME
4
5DH_set_default_method, DH_get_default_method, DH_set_method,
6DH_new_method, DH_OpenSSL - select DH method
7
8=head1 SYNOPSIS
9
10 #include <openssl/dh.h>
11
12 void DH_set_default_method(DH_METHOD *meth);
13
14 DH_METHOD *DH_get_default_method(void);
15
16 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
17
18 DH *DH_new_method(DH_METHOD *meth);
19
20 DH_METHOD *DH_OpenSSL(void);
21
22=head1 DESCRIPTION
23
24A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman
25operations. By modifying the method, alternative implementations
26such as hardware accelerators may be used.
27
28Initially, the default is to use the OpenSSL internal implementation.
29DH_OpenSSL() returns a pointer to that method.
30
31DH_set_default_method() makes B<meth> the default method for all B<DH>
32structures created later.
33
34DH_get_default_method() returns a pointer to the current default
35method.
36
37DH_set_method() selects B<meth> for all operations using the structure B<dh>.
38
39DH_get_method() returns a pointer to the method currently selected
40for B<dh>.
41
42DH_new_method() allocates and initializes a B<DH> structure so that
43B<method> will be used for the DH operations. If B<method> is B<NULL>,
44the default method is used.
45
46=head1 THE DH_METHOD STRUCTURE
47
48 typedef struct dh_meth_st
49 {
50 /* name of the implementation */
51 const char *name;
52
53 /* generate private and public DH values for key agreement */
54 int (*generate_key)(DH *dh);
55
56 /* compute shared secret */
57 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
58
59 /* compute r = a ^ p mod m. May be NULL */
60 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
61 const BIGNUM *m, BN_CTX *ctx,
62 BN_MONT_CTX *m_ctx);
63
64 /* called at DH_new */
65 int (*init)(DH *dh);
66
67 /* called at DH_free */
68 int (*finish)(DH *dh);
69
70 int flags;
71
72 char *app_data; /* ?? */
73
74 } DH_METHOD;
75
76=head1 RETURN VALUES
77
78DH_OpenSSL(), DH_get_default_method() and DH_get_method() return
79pointers to the respective B<DH_METHOD>s.
80
81DH_set_default_method() returns no value.
82
83DH_set_method() returns a pointer to the B<DH_METHOD> previously
84associated with B<dh>.
85
86DH_new_method() returns B<NULL> and sets an error code that can be
87obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
88returns a pointer to the newly allocated structure.
89
90=head1 SEE ALSO
91
92L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
93
94=head1 HISTORY
95
96DH_set_default_method(), DH_get_default_method(), DH_set_method(),
97DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.
98
99=cut
diff --git a/src/lib/libcrypto/doc/DH_size.pod b/src/lib/libcrypto/doc/DH_size.pod
new file mode 100644
index 0000000000..97f26fda78
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_size.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5DH_size - get Diffie-Hellman prime size
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 int DH_size(DH *dh);
12
13=head1 DESCRIPTION
14
15This function returns the Diffie-Hellman size in bytes. It can be used
16to determine how much memory must be allocated for the shared secret
17computed by DH_compute_key().
18
19B<dh-E<gt>p> must not be B<NULL>.
20
21=head1 RETURN VALUE
22
23The size in bytes.
24
25=head1 SEE ALSO
26
27L<dh(3)|dh(3)>, L<DH_generate_key(3)|DH_generate_key(3)>
28
29=head1 HISTORY
30
31DH_size() is available in all versions of SSLeay and OpenSSL.
32
33=cut
diff --git a/src/lib/libcrypto/doc/DSA_SIG_new.pod b/src/lib/libcrypto/doc/DSA_SIG_new.pod
new file mode 100644
index 0000000000..671655554a
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_SIG_new.pod
@@ -0,0 +1,39 @@
1=pod
2
3=head1 NAME
4
5DSA_SIG_new, DSA_SIG_free - allocate and free DSA signature objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA_SIG *DSA_SIG_new(void);
12
13 void DSA_SIG_free(DSA_SIG *a);
14
15=head1 DESCRIPTION
16
17DSA_SIG_new() allocates and initializes a B<DSA_SIG> structure.
18
19DSA_SIG_free() frees the B<DSA_SIG> structure and its components. The
20values are erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, DSA_SIG_new() returns B<NULL> and sets an
25error code that can be obtained by
26L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns a pointer
27to the newly allocated structure.
28
29DSA_SIG_free() returns no value.
30
31=head1 SEE ALSO
32
33L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<DSA_do_sign(3)|DSA_do_sign(3)>
34
35=head1 HISTORY
36
37DSA_SIG_new() and DSA_SIG_free() were added in OpenSSL 0.9.3.
38
39=cut
diff --git a/src/lib/libcrypto/doc/DSA_do_sign.pod b/src/lib/libcrypto/doc/DSA_do_sign.pod
new file mode 100644
index 0000000000..a24fd5714e
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_do_sign.pod
@@ -0,0 +1,47 @@
1=pod
2
3=head1 NAME
4
5DSA_do_sign, DSA_do_verify - raw DSA signature operations
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
12
13 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
14 DSA_SIG *sig, DSA *dsa);
15
16=head1 DESCRIPTION
17
18DSA_do_sign() computes a digital signature on the B<len> byte message
19digest B<dgst> using the private key B<dsa> and returns it in a
20newly allocated B<DSA_SIG> structure.
21
22L<DSA_sign_setup(3)|DSA_sign_setup(3)> may be used to precompute part
23of the signing operation in case signature generation is
24time-critical.
25
26DSA_do_verify() verifies that the signature B<sig> matches a given
27message digest B<dgst> of size B<len>. B<dsa> is the signer's public
28key.
29
30=head1 RETURN VALUES
31
32DSA_do_sign() returns the signature, NULL on error. DSA_do_verify()
33returns 1 for a valid signature, 0 for an incorrect signature and -1
34on error. The error codes can be obtained by
35L<ERR_get_error(3)|ERR_get_error(3)>.
36
37=head1 SEE ALSO
38
39L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
40L<DSA_SIG_new(3)|DSA_SIG_new(3)>,
41L<DSA_sign(3)|DSA_sign(3)>
42
43=head1 HISTORY
44
45DSA_do_sign() and DSA_do_verify() were added in OpenSSL 0.9.3.
46
47=cut
diff --git a/src/lib/libcrypto/doc/DSA_dup_DH.pod b/src/lib/libcrypto/doc/DSA_dup_DH.pod
new file mode 100644
index 0000000000..29cb1075d1
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_dup_DH.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5DSA_dup_DH - create a DH structure out of DSA structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DH * DSA_dup_DH(DSA *r);
12
13=head1 DESCRIPTION
14
15DSA_dup_DH() duplicates DSA parameters/keys as DH parameters/keys. q
16is lost during that conversion, but the resulting DH parameters
17contain its length.
18
19=head1 RETURN VALUE
20
21DSA_dup_DH() returns the new B<DH> structure, and NULL on error. The
22error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
23
24=head1 NOTE
25
26Be careful to avoid small subgroup attacks when using this.
27
28=head1 SEE ALSO
29
30L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>
31
32=head1 HISTORY
33
34DSA_dup_DH() was added in OpenSSL 0.9.4.
35
36=cut
diff --git a/src/lib/libcrypto/doc/DSA_generate_key.pod b/src/lib/libcrypto/doc/DSA_generate_key.pod
new file mode 100644
index 0000000000..52890db5be
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_generate_key.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5DSA_generate_key - generate DSA key pair
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 int DSA_generate_key(DSA *a);
12
13=head1 DESCRIPTION
14
15DSA_generate_key() expects B<a> to contain DSA parameters. It generates
16a new key pair and stores it in B<a-E<gt>pub_key> and B<a-E<gt>priv_key>.
17
18The PRNG must be seeded prior to calling DSA_generate_key().
19
20=head1 RETURN VALUE
21
22DSA_generate_key() returns 1 on success, 0 otherwise.
23The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
24
25=head1 SEE ALSO
26
27L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>
28
29=head1 HISTORY
30
31DSA_generate_key() is available since SSLeay 0.8.
32
33=cut
diff --git a/src/lib/libcrypto/doc/DSA_generate_parameters.pod b/src/lib/libcrypto/doc/DSA_generate_parameters.pod
new file mode 100644
index 0000000000..43f60b0eb9
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_generate_parameters.pod
@@ -0,0 +1,105 @@
1=pod
2
3=head1 NAME
4
5DSA_generate_parameters - generate DSA parameters
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA *DSA_generate_parameters(int bits, unsigned char *seed,
12 int seed_len, int *counter_ret, unsigned long *h_ret,
13 void (*callback)(int, int, void *), void *cb_arg);
14
15=head1 DESCRIPTION
16
17DSA_generate_parameters() generates primes p and q and a generator g
18for use in the DSA.
19
20B<bits> is the length of the prime to be generated; the DSS allows a
21maximum of 1024 bits.
22
23If B<seed> is B<NULL> or B<seed_len> E<lt> 20, the primes will be
24generated at random. Otherwise, the seed is used to generate
25them. If the given seed does not yield a prime q, a new random
26seed is chosen and placed at B<seed>.
27
28DSA_generate_parameters() places the iteration count in
29*B<counter_ret> and a counter used for finding a generator in
30*B<h_ret>, unless these are B<NULL>.
31
32A callback function may be used to provide feedback about the progress
33of the key generation. If B<callback> is not B<NULL>, it will be
34called as follows:
35
36=over 4
37
38=item *
39
40When a candidate for q is generated, B<callback(0, m++, cb_arg)> is called
41(m is 0 for the first candidate).
42
43=item *
44
45When a candidate for q has passed a test by trial division,
46B<callback(1, -1, cb_arg)> is called.
47While a candidate for q is tested by Miller-Rabin primality tests,
48B<callback(1, i, cb_arg)> is called in the outer loop
49(once for each witness that confirms that the candidate may be prime);
50i is the loop counter (starting at 0).
51
52=item *
53
54When a prime q has been found, B<callback(2, 0, cb_arg)> and
55B<callback(3, 0, cb_arg)> are called.
56
57=item *
58
59Before a candidate for p (other than the first) is generated and tested,
60B<callback(0, counter, cb_arg)> is called.
61
62=item *
63
64When a candidate for p has passed the test by trial division,
65B<callback(1, -1, cb_arg)> is called.
66While it is tested by the Miller-Rabin primality test,
67B<callback(1, i, cb_arg)> is called in the outer loop
68(once for each witness that confirms that the candidate may be prime).
69i is the loop counter (starting at 0).
70
71=item *
72
73When p has been found, B<callback(2, 1, cb_arg)> is called.
74
75=item *
76
77When the generator has been found, B<callback(3, 1, cb_arg)> is called.
78
79=back
80
81=head1 RETURN VALUE
82
83DSA_generate_parameters() returns a pointer to the DSA structure, or
84B<NULL> if the parameter generation fails. The error codes can be
85obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
86
87=head1 BUGS
88
89Seed lengths E<gt> 20 are not supported.
90
91=head1 SEE ALSO
92
93L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
94L<DSA_free(3)|DSA_free(3)>
95
96=head1 HISTORY
97
98DSA_generate_parameters() appeared in SSLeay 0.8. The B<cb_arg>
99argument was added in SSLeay 0.9.0.
100In versions up to OpenSSL 0.9.4, B<callback(1, ...)> was called
101in the inner loop of the Miller-Rabin test whenever it reached the
102squaring step (the parameters to B<callback> did not reveal how many
103witnesses had been tested); since OpenSSL 0.9.5, B<callback(1, ...)>
104is called as in BN_is_prime(3), i.e. once for each witness.
105=cut
diff --git a/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod b/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod
new file mode 100644
index 0000000000..4612e708ec
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_get_ex_new_index.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5DSA_get_ex_new_index, DSA_set_ex_data, DSA_get_ex_data - add application specific data to DSA structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/DSA.h>
10
11 int DSA_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func,
13 CRYPTO_EX_dup *dup_func,
14 CRYPTO_EX_free *free_func);
15
16 int DSA_set_ex_data(DSA *d, int idx, void *arg);
17
18 char *DSA_get_ex_data(DSA *d, int idx);
19
20=head1 DESCRIPTION
21
22These functions handle application specific data in DSA
23structures. Their usage is identical to that of
24RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data()
25as described in L<RSA_get_ex_new_index(3)>.
26
27=head1 SEE ALSO
28
29L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>, L<dsa(3)|dsa(3)>
30
31=head1 HISTORY
32
33DSA_get_ex_new_index(), DSA_set_ex_data() and DSA_get_ex_data() are
34available since OpenSSL 0.9.5.
35
36=cut
diff --git a/src/lib/libcrypto/doc/DSA_new.pod b/src/lib/libcrypto/doc/DSA_new.pod
new file mode 100644
index 0000000000..7dde54445b
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_new.pod
@@ -0,0 +1,41 @@
1=pod
2
3=head1 NAME
4
5DSA_new, DSA_free - allocate and free DSA objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA* DSA_new(void);
12
13 void DSA_free(DSA *dsa);
14
15=head1 DESCRIPTION
16
17DSA_new() allocates and initializes a B<DSA> structure.
18
19DSA_free() frees the B<DSA> structure and its components. The values are
20erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, DSA_new() returns B<NULL> and sets an error
25code that can be obtained by
26L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns a pointer
27to the newly allocated structure.
28
29DSA_free() returns no value.
30
31=head1 SEE ALSO
32
33L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
34L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
35L<DSA_generate_key(3)|DSA_generate_key(3)>
36
37=head1 HISTORY
38
39DSA_new() and DSA_free() are available in all versions of SSLeay and OpenSSL.
40
41=cut
diff --git a/src/lib/libcrypto/doc/DSA_set_method.pod b/src/lib/libcrypto/doc/DSA_set_method.pod
new file mode 100644
index 0000000000..0b13ec9237
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_set_method.pod
@@ -0,0 +1,111 @@
1=pod
2
3=head1 NAME
4
5DSA_set_default_method, DSA_get_default_method, DSA_set_method,
6DSA_new_method, DSA_OpenSSL - select RSA method
7
8=head1 SYNOPSIS
9
10 #include <openssl/DSA.h>
11
12 void DSA_set_default_method(DSA_METHOD *meth);
13
14 DSA_METHOD *DSA_get_default_method(void);
15
16 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth);
17
18 DSA *DSA_new_method(DSA_METHOD *meth);
19
20 DSA_METHOD *DSA_OpenSSL(void);
21
22=head1 DESCRIPTION
23
24A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA
25operations. By modifying the method, alternative implementations
26such as hardware accelerators may be used.
27
28Initially, the default is to use the OpenSSL internal implementation.
29DSA_OpenSSL() returns a pointer to that method.
30
31DSA_set_default_method() makes B<meth> the default method for all B<DSA>
32structures created later.
33
34DSA_get_default_method() returns a pointer to the current default
35method.
36
37DSA_set_method() selects B<meth> for all operations using the structure B<DSA>.
38
39DSA_get_method() returns a pointer to the method currently selected
40for B<DSA>.
41
42DSA_new_method() allocates and initializes a B<DSA> structure so that
43B<method> will be used for the DSA operations. If B<method> is B<NULL>,
44the default method is used.
45
46=head1 THE DSA_METHOD STRUCTURE
47
48struct
49 {
50 /* name of the implementation */
51 const char *name;
52
53 /* sign */
54 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
55 DSA *dsa);
56
57 /* pre-compute k^-1 and r */
58 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
59 BIGNUM **rp);
60
61 /* verify */
62 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
63 DSA_SIG *sig, DSA *dsa);
64
65 /* compute rr = a1^p1 * a2^p2 mod m. May be NULL */
66 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
67 BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
68 BN_CTX *ctx, BN_MONT_CTX *in_mont);
69
70 /* compute r = a ^ p mod m. May be NULL */
71 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
72 const BIGNUM *p, const BIGNUM *m,
73 BN_CTX *ctx, BN_MONT_CTX *m_ctx);
74
75 /* called at DSA_new */
76 int (*init)(DSA *DSA);
77
78 /* called at DSA_free */
79 int (*finish)(DSA *DSA);
80
81 int flags;
82
83 char *app_data; /* ?? */
84
85 } DSA_METHOD;
86
87=head1 RETURN VALUES
88
89DSA_OpenSSL(), DSA_get_default_method() and DSA_get_method() return
90pointers to the respective B<DSA_METHOD>s.
91
92DSA_set_default_method() returns no value.
93
94DSA_set_method() returns a pointer to the B<DSA_METHOD> previously
95associated with B<dsa>.
96
97DSA_new_method() returns B<NULL> and sets an error code that can be
98obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
99fails. Otherwise it returns a pointer to the newly allocated
100structure.
101
102=head1 SEE ALSO
103
104L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
105
106=head1 HISTORY
107
108DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
109DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
110
111=cut
diff --git a/src/lib/libcrypto/doc/DSA_sign.pod b/src/lib/libcrypto/doc/DSA_sign.pod
new file mode 100644
index 0000000000..f6e60a8ca3
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_sign.pod
@@ -0,0 +1,66 @@
1=pod
2
3=head1 NAME
4
5DSA_sign, DSA_sign_setup, DSA_verify - DSA signatures
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 int DSA_sign(int type, const unsigned char *dgst, int len,
12 unsigned char *sigret, unsigned int *siglen, DSA *dsa);
13
14 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
15 BIGNUM **rp);
16
17 int DSA_verify(int type, const unsigned char *dgst, int len,
18 unsigned char *sigbuf, int siglen, DSA *dsa);
19
20=head1 DESCRIPTION
21
22DSA_sign() computes a digital signature on the B<len> byte message
23digest B<dgst> using the private key B<dsa> and places its ASN.1 DER
24encoding at B<sigret>. The length of the signature is places in
25*B<siglen>. B<sigret> must point to DSA_size(B<dsa>) bytes of memory.
26
27DSA_sign_setup() may be used to precompute part of the signing
28operation in case signature generation is time-critical. It expects
29B<dsa> to contain DSA parameters. It places the precomputed values
30in newly allocated B<BIGNUM>s at *B<kinvp> and *B<rp>, after freeing
31the old ones unless *B<kinvp> and *B<rp> are NULL. These values may
32be passed to DSA_sign() in B<dsa-E<gt>kinv> and B<dsa-E<gt>r>.
33B<ctx> is a pre-allocated B<BN_CTX> or NULL.
34
35DSA_verify() verifies that the signature B<sigbuf> of size B<siglen>
36matches a given message digest B<dgst> of size B<len>.
37B<dsa> is the signer's public key.
38
39The B<type> parameter is ignored.
40
41The PRNG must be seeded before DSA_sign() (or DSA_sign_setup())
42is called.
43
44=head1 RETURN VALUES
45
46DSA_sign() and DSA_sign_setup() return 1 on success, 0 on error.
47DSA_verify() returns 1 for a valid signature, 0 for an incorrect
48signature and -1 on error. The error codes can be obtained by
49L<ERR_get_error(3)|ERR_get_error(3)>.
50
51=head1 CONFORMING TO
52
53US Federal Information Processing Standard FIPS 186 (Digital Signature
54Standard, DSS), ANSI X9.30
55
56=head1 SEE ALSO
57
58L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
59L<DSA_do_sign(3)|DSA_do_sign(3)>
60
61=head1 HISTORY
62
63DSA_sign() and DSA_verify() are available in all versions of SSLeay.
64DSA_sign_setup() was added in SSLeay 0.8.
65
66=cut
diff --git a/src/lib/libcrypto/doc/DSA_size.pod b/src/lib/libcrypto/doc/DSA_size.pod
new file mode 100644
index 0000000000..23b6320a4d
--- /dev/null
+++ b/src/lib/libcrypto/doc/DSA_size.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5DSA_size - get DSA signature size
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 int DSA_size(DSA *dsa);
12
13=head1 DESCRIPTION
14
15This function returns the size of an ASN.1 encoded DSA signature in
16bytes. It can be used to determine how much memory must be allocated
17for a DSA signature.
18
19B<dsa-E<gt>q> must not be B<NULL>.
20
21=head1 RETURN VALUE
22
23The size in bytes.
24
25=head1 SEE ALSO
26
27L<dsa(3)|dsa(3)>, L<DSA_sign(3)|DSA_sign(3)>
28
29=head1 HISTORY
30
31DSA_size() is available in all versions of SSLeay and OpenSSL.
32
33=cut
diff --git a/src/lib/libcrypto/doc/ERR_GET_LIB.pod b/src/lib/libcrypto/doc/ERR_GET_LIB.pod
new file mode 100644
index 0000000000..2a129da036
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_GET_LIB.pod
@@ -0,0 +1,51 @@
1=pod
2
3=head1 NAME
4
5ERR_GET_LIB, ERR_GET_FUNC, ERR_GET_REASON - get library, function and
6reason code
7
8=head1 SYNOPSIS
9
10 #include <openssl/err.h>
11
12 int ERR_GET_LIB(unsigned long e);
13
14 int ERR_GET_FUNC(unsigned long e);
15
16 int ERR_GET_REASON(unsigned long e);
17
18=head1 DESCRIPTION
19
20The error code returned by ERR_get_error() consists of a library
21number, function code and reason code. ERR_GET_LIB(), ERR_GET_FUNC()
22and ERR_GET_REASON() can be used to extract these.
23
24The library number and function code describe where the error
25occurred, the reason code is the information about what went wrong.
26
27Each sub-library of OpenSSL has a unique library number; function and
28reason codes are unique within each sub-library. Note that different
29libraries may use the same value to signal different functions and
30reasons.
31
32B<ERR_R_...> reason codes such as B<ERR_R_MALLOC_FAILURE> are globally
33unique. However, when checking for sub-library specific reason codes,
34be sure to also compare the library number.
35
36ERR_GET_LIB(), ERR_GET_FUNC() and ERR_GET_REASON() are macros.
37
38=head1 RETURN VALUES
39
40The library number, function code and reason code respectively.
41
42=head1 SEE ALSO
43
44L<err(3)|err(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
45
46=head1 HISTORY
47
48ERR_GET_LIB(), ERR_GET_FUNC() and ERR_GET_REASON() are available in
49all versions of SSLeay and OpenSSL.
50
51=cut
diff --git a/src/lib/libcrypto/doc/ERR_clear_error.pod b/src/lib/libcrypto/doc/ERR_clear_error.pod
new file mode 100644
index 0000000000..566e1f4e31
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_clear_error.pod
@@ -0,0 +1,29 @@
1=pod
2
3=head1 NAME
4
5ERR_clear_error - clear the error queue
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_clear_error(void);
12
13=head1 DESCRIPTION
14
15ERR_clear_error() empties the current thread's error queue.
16
17=head1 RETURN VALUES
18
19ERR_clear_error() has no return value.
20
21=head1 SEE ALSO
22
23L<err(3)|err(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
24
25=head1 HISTORY
26
27ERR_clear_error() is available in all versions of SSLeay and OpenSSL.
28
29=cut
diff --git a/src/lib/libcrypto/doc/ERR_error_string.pod b/src/lib/libcrypto/doc/ERR_error_string.pod
new file mode 100644
index 0000000000..0d2417599c
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_error_string.pod
@@ -0,0 +1,65 @@
1=pod
2
3=head1 NAME
4
5ERR_error_string - obtain human-readable error message
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 char *ERR_error_string(unsigned long e, char *buf);
12
13 const char *ERR_lib_error_string(unsigned long e);
14 const char *ERR_func_error_string(unsigned long e);
15 const char *ERR_reason_error_string(unsigned long e);
16
17=head1 DESCRIPTION
18
19ERR_error_string() generates a human-readable string representing the
20error code B<e>, and places it at B<buf>. B<buf> must be at least 120
21bytes long. If B<buf> is B<NULL>, the error string is placed in a
22static buffer.
23
24The string will have the following format:
25
26 error:[error code]:[library name]:[function name]:[reason string]
27
28I<error code> is an 8 digit hexadecimal number, I<library name>,
29I<function name> and I<reason string> are ASCII text.
30
31ERR_lib_error_string(), ERR_func_error_string() and
32ERR_reason_error_string() return the library name, function
33name and reason string respectively.
34
35The OpenSSL error strings should be loaded by calling
36L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)> or, for SSL
37applications, L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>
38first.
39If there is no text string registered for the given error code,
40the error string will contain the numeric code.
41
42L<ERR_print_errors(3)|ERR_print_errors(3)> can be used to print
43all error codes currently in the queue.
44
45=head1 RETURN VALUES
46
47ERR_error_string() returns a pointer to a static buffer containing the
48string if B<buf == NULL>, B<buf> otherwise.
49
50ERR_lib_error_string(), ERR_func_error_string() and
51ERR_reason_error_string() return the strings, and B<NULL> if
52none is registered for the error code.
53
54=head1 SEE ALSO
55
56L<err(3)|err(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
57L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)>,
58L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>
59L<ERR_print_errors(3)|ERR_print_errors(3)>
60
61=head1 HISTORY
62
63ERR_error_string() is available in all versions of SSLeay and OpenSSL.
64
65=cut
diff --git a/src/lib/libcrypto/doc/ERR_get_error.pod b/src/lib/libcrypto/doc/ERR_get_error.pod
new file mode 100644
index 0000000000..75ece00d97
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_get_error.pod
@@ -0,0 +1,62 @@
1=pod
2
3=head1 NAME
4
5ERR_get_error, ERR_peek_error - obtain error code
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 unsigned long ERR_get_error(void);
12 unsigned long ERR_peek_error(void);
13
14 unsigned long ERR_get_error_line(const char **file, int *line);
15 unsigned long ERR_peek_error_line(const char **file, int *line);
16
17 unsigned long ERR_get_error_line_data(const char **file, int *line,
18 const char **data, int *flags);
19 unsigned long ERR_peek_error_line_data(const char **file, int *line,
20 const char **data, int *flags);
21
22=head1 DESCRIPTION
23
24ERR_get_error() returns the last error code from the thread's error
25queue and removes the entry. This function can be called repeatedly
26until there are no more error codes to return.
27
28ERR_peek_error() returns the last error code from the thread's
29error queue without modifying it.
30
31See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about
32location and reason of the error, and
33L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error
34messages.
35
36ERR_get_error_line() and ERR_peek_error_line() are the same as the
37above, but they additionally store the file name and line number where
38the error occurred in *B<file> and *B<line>, unless these are B<NULL>.
39
40ERR_get_error_line_data() and ERR_peek_error_line_data() store
41additional data and flags associated with the error code in *B<data>
42and *B<flags>, unless these are B<NULL>. *B<data> contains a string
43if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by Malloc(),
44*B<flags>&B<ERR_TXT_MALLOCED> is true.
45
46=head1 RETURN VALUES
47
48The error code, or 0 if there is no error in the queue.
49
50=head1 SEE ALSO
51
52L<err(3)|err(3)>, L<ERR_error_string(3)|ERR_error_string(3)>,
53L<ERR_GET_LIB(3)|ERR_GET_LIB(3)>
54
55=head1 HISTORY
56
57ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and
58ERR_peek_error_line() are available in all versions of SSLeay and
59OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data()
60were added in SSLeay 0.9.0.
61
62=cut
diff --git a/src/lib/libcrypto/doc/ERR_load_crypto_strings.pod b/src/lib/libcrypto/doc/ERR_load_crypto_strings.pod
new file mode 100644
index 0000000000..9bdec75a46
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_load_crypto_strings.pod
@@ -0,0 +1,46 @@
1=pod
2
3=head1 NAME
4
5ERR_load_crypto_strings, SSL_load_error_strings, ERR_free_strings -
6load and free error strings
7
8=head1 SYNOPSIS
9
10 #include <openssl/err.h>
11
12 void ERR_load_crypto_strings(void);
13 void ERR_free_strings(void);
14
15 #include <openssl/ssl.h>
16
17 void SSL_load_error_strings(void);
18
19=head1 DESCRIPTION
20
21ERR_load_crypto_strings() registers the error strings for all
22B<libcrypto> functions. SSL_load_error_strings() does the same,
23but also registers the B<libssl> error strings.
24
25One of these functions should be called before generating
26textual error messages. However, this is not required when memory
27usage is an issue.
28
29ERR_free_strings() frees all previously loaded error strings.
30
31=head1 RETURN VALUES
32
33ERR_load_crypto_strings(), SSL_load_error_strings() and
34ERR_free_strings() return no values.
35
36=head1 SEE ALSO
37
38L<err(3)|err(3)>, L<ERR_error_string(3)|ERR_error_string(3)>
39
40=head1 HISTORY
41
42ERR_load_error_strings(), SSL_load_error_strings() and
43ERR_free_strings() are available in all versions of SSLeay and
44OpenSSL.
45
46=cut
diff --git a/src/lib/libcrypto/doc/ERR_load_strings.pod b/src/lib/libcrypto/doc/ERR_load_strings.pod
new file mode 100644
index 0000000000..5acdd0edbc
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_load_strings.pod
@@ -0,0 +1,54 @@
1=pod
2
3=head1 NAME
4
5ERR_load_strings, ERR_PACK, ERR_get_next_error_library - load
6arbitrary error strings
7
8=head1 SYNOPSIS
9
10 #include <openssl/err.h>
11
12 void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
13
14 int ERR_get_next_error_library(void);
15
16 unsigned long ERR_PACK(int lib, int func, int reason);
17
18=head1 DESCRIPTION
19
20ERR_load_strings() registers error strings for library number B<lib>.
21
22B<str> is an array of error string data:
23
24 typedef struct ERR_string_data_st
25 {
26 unsigned long error;
27 char *string;
28 } ERR_STRING_DATA;
29
30The error code is generated from the library number and a function and
31reason code: B<error> = ERR_PACK(B<lib>, B<func>, B<reason>).
32ERR_PACK() is a macro.
33
34The last entry in the array is {0,0}.
35
36ERR_get_next_error_library() can be used to assign library numbers
37to user libraries at runtime.
38
39=head1 RETURN VALUE
40
41ERR_load_strings() returns no value. ERR_PACK() return the error code.
42ERR_get_next_error_library() returns a new library number.
43
44=head1 SEE ALSO
45
46L<err(3)|err(3)>, L<ERR_load_strings(3)|ERR_load_strings(3)>
47
48=head1 HISTORY
49
50ERR_load_error_strings() and ERR_PACK() are available in all versions
51of SSLeay and OpenSSL. ERR_get_next_error_library() was added in
52SSLeay 0.9.0.
53
54=cut
diff --git a/src/lib/libcrypto/doc/ERR_print_errors.pod b/src/lib/libcrypto/doc/ERR_print_errors.pod
new file mode 100644
index 0000000000..b100a5fa2b
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_print_errors.pod
@@ -0,0 +1,51 @@
1=pod
2
3=head1 NAME
4
5ERR_print_errors, ERR_print_errors_fp - print error messages
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_print_errors(BIO *bp);
12 void ERR_print_errors_fp(FILE *fp);
13
14=head1 DESCRIPTION
15
16ERR_print_errors() is a convenience function that prints the error
17strings for all errors that OpenSSL has recorded to B<bp>, thus
18emptying the error queue.
19
20ERR_print_errors_fp() is the same, except that the output goes to a
21B<FILE>.
22
23
24The error strings will have the following format:
25
26 [pid]:error:[error code]:[library name]:[function name]:[reason string]:[file name]:[line]:[optional text message]
27
28I<error code> is an 8 digit hexadecimal number. I<library name>,
29I<function name> and I<reason string> are ASCII text, as is I<optional
30text message> if one was set for the respective error code.
31
32If there is no text string registered for the given error code,
33the error string will contain the numeric code.
34
35=head1 RETURN VALUES
36
37ERR_print_errors() and ERR_print_errors_fp() return no values.
38
39=head1 SEE ALSO
40
41L<err(3)|err(3)>, L<ERR_error_string(3)|ERR_error_string(3)>,
42L<ERR_get_error(3)|ERR_get_error(3)>,
43L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)>,
44L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>
45
46=head1 HISTORY
47
48ERR_print_errors() and ERR_print_errors_fp()
49are available in all versions of SSLeay and OpenSSL.
50
51=cut
diff --git a/src/lib/libcrypto/doc/ERR_put_error.pod b/src/lib/libcrypto/doc/ERR_put_error.pod
new file mode 100644
index 0000000000..acd241fbe4
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_put_error.pod
@@ -0,0 +1,44 @@
1=pod
2
3=head1 NAME
4
5ERR_put_error, ERR_add_error_data - record an error
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_put_error(int lib, int func, int reason, const char *file,
12 int line);
13
14 void ERR_add_error_data(int num, ...);
15
16=head1 DESCRIPTION
17
18ERR_put_error() adds an error code to the thread's error queue. It
19signals that the error of reason code B<reason> occurred in function
20B<func> of library B<lib>, in line number B<line> of B<file>.
21This function is usually called by a macro.
22
23ERR_add_error_data() associates the concatenation of its B<num> string
24arguments with the error code added last.
25
26L<ERR_load_strings(3)|ERR_load_strings(3)> can be used to register
27error strings so that the application can a generate human-readable
28error messages for the error code.
29
30=head1 RETURN VALUES
31
32ERR_put_error() and ERR_add_error_data() return
33no values.
34
35=head1 SEE ALSO
36
37L<err(3)|err(3)>, L<ERR_load_strings(3)|ERR_load_strings(3)>
38
39=head1 HISTORY
40
41ERR_put_error() is available in all versions of SSLeay and OpenSSL.
42ERR_add_error_data() was added in SSLeay 0.9.0.
43
44=cut
diff --git a/src/lib/libcrypto/doc/ERR_remove_state.pod b/src/lib/libcrypto/doc/ERR_remove_state.pod
new file mode 100644
index 0000000000..ebcdc0f5a5
--- /dev/null
+++ b/src/lib/libcrypto/doc/ERR_remove_state.pod
@@ -0,0 +1,34 @@
1=pod
2
3=head1 NAME
4
5ERR_remove_state - free a thread's error queue
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_remove_state(unsigned long pid);
12
13=head1 DESCRIPTION
14
15ERR_remove_state() frees the error queue associated with thread B<pid>.
16If B<pid> == 0, the current thread will have its error queue removed.
17
18Since error queue data structures are allocated automatically for new
19threads, they must be freed when threads are terminated in oder to
20avoid memory leaks.
21
22=head1 RETURN VALUE
23
24ERR_remove_state() returns no value.
25
26=head1 SEE ALSO
27
28L<err(3)|err(3)>
29
30=head1 HISTORY
31
32ERR_remove_state() is available in all versions of SSLeay and OpenSSL.
33
34=cut
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod
new file mode 100644
index 0000000000..345b1ddfa7
--- /dev/null
+++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod
@@ -0,0 +1,197 @@
1=pod
2
3=head1 NAME
4
5EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal - EVP digest routines
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
12 void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
13 void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
14 unsigned int *s);
15
16 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
17
18 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
19
20 #define EVP_MD_type(e) ((e)->type)
21 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
22 #define EVP_MD_size(e) ((e)->md_size)
23 #define EVP_MD_block_size(e) ((e)->block_size)
24
25 #define EVP_MD_CTX_md(e) (e)->digest)
26 #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
27 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
28 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
29
30 EVP_MD *EVP_md_null(void);
31 EVP_MD *EVP_md2(void);
32 EVP_MD *EVP_md5(void);
33 EVP_MD *EVP_sha(void);
34 EVP_MD *EVP_sha1(void);
35 EVP_MD *EVP_dss(void);
36 EVP_MD *EVP_dss1(void);
37 EVP_MD *EVP_mdc2(void);
38 EVP_MD *EVP_ripemd160(void);
39
40 const EVP_MD *EVP_get_digestbyname(const char *name);
41 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
42 #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
43
44=head1 DESCRIPTION
45
46The EVP digest routines are a high level interface to message digests.
47
48EVP_DigestInit() initialises a digest context B<ctx> to use a digest
49B<type>: this will typically be supplied by a function such as
50EVP_sha1().
51
52EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the
53digest context B<ctx>. This funtion can be called several times on the
54same B<ctx> to hash additional data.
55
56EVP_DigestFinal() retrieves the digest value from B<ctx> and places
57it in B<md>. If the B<s> parameter is not NULL then the number of
58bytes of data written (i.e. the length of the digest) will be written
59to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written.
60After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate()
61can be made, but EVP_DigestInit() can be called to initialiase a new
62digest operation.
63
64EVP_MD_CTX_copy() can be used to copy the message digest state from
65B<in> to B<out>. This is useful if large amounts of data are to be
66hashed which only differ in the last few bytes.
67
68EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest
69when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the
70hash.
71
72EVP_MD_block_size() and EVP_MD_CTX_block_size() return the block size of the
73message digest when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure.
74
75EVP_MD_type() and EVP_MD_CTX_type() return the NID of the OBJECT IDENTIFIER
76representing the given message digest when passed an B<EVP_MD> structure.
77For example EVP_MD_type(EVP_sha1()) returns B<NID_sha1>. This function is
78normally used when setting ASN1 OIDs.
79
80EVP_MD_CTX_md() returns the B<EVP_MD> structure corresponding to the passed
81B<EVP_MD_CTX>.
82
83EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated
84with this digest. For example EVP_sha1() is associated with RSA so this will
85return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature
86algorithms may not be retained in future versions of OpenSSL.
87
88EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160()
89return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest
90algorithms respectively. The associated signature algorithm is RSA in each case.
91
92EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
93algorithms but using DSS (DSA) for the signature algorithm.
94
95EVP_md_null() is a "null" message digest that does nothing: i.e. the hash it
96returns is of zero length.
97
98EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
99return an B<EVP_MD> structure when passed a digest name, a digest NID or
100an ASN1_OBJECT structure respectively. The digest table must be initialised
101using, for example, OpenSSL_add_all_digests() for these functions to work.
102
103=head1 RETURN VALUES
104
105EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values.
106
107EVP_MD_CTX_copy() returns 1 if successful or 0 for failure.
108
109EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the
110corresponding OBJECT IDENTIFIER or NID_undef if none exists.
111
112EVP_MD_size(), EVP_MD_block_size(), EVP_MD_CTX_size(e), EVP_MD_size(),
113EVP_MD_CTX_block_size() and EVP_MD_block_size() return the digest or block
114size in bytes.
115
116EVP_md_null(), EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_dss(),
117EVP_dss1(), EVP_mdc2() and EVP_ripemd160() return pointers to the
118corresponding EVP_MD structures.
119
120EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
121return either an B<EVP_MD> structure or NULL if an error occurs.
122
123=head1 NOTES
124
125The B<EVP> interface to message digests should almost always be used in
126preference to the low level interfaces. This is because the code then becomes
127transparent to the digest used and much more flexible.
128
129SHA1 is the digest of choice for new applications. The other digest algorithms
130are still in common use.
131
132=head1 EXAMPLE
133
134This example digests the data "Test Message\n" and "Hello World\n", using the
135digest name passed on the command line.
136
137 #include <stdio.h>
138 #include <openssl/evp.h>
139
140 main(int argc, char *argv[])
141 {
142 EVP_MD_CTX mdctx;
143 const EVP_MD *md;
144 char mess1[] = "Test Message\n";
145 char mess2[] = "Hello World\n";
146 unsigned char md_value[EVP_MAX_MD_SIZE];
147 int md_len, i;
148
149 OpenSSL_add_all_digests();
150
151 if(!argv[1]) {
152 printf("Usage: mdtest digestname\n");
153 exit(1);
154 }
155
156 md = EVP_get_digestbyname(argv[1]);
157
158 if(!md) {
159 printf("Unknown message digest %s\n", argv[1]);
160 exit(1);
161 }
162
163 EVP_DigestInit(&mdctx, md);
164 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
165 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
166 EVP_DigestFinal(&mdctx, md_value, &md_len);
167
168 printf("Digest is: ");
169 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
170 printf("\n");
171 }
172
173=head1 BUGS
174
175Several of the functions do not return values: maybe they should. Although the
176internal digest operations will never fail some future hardware based operations
177might.
178
179The link between digests and signing algorithms results in a situation where
180EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
181even though they are identical digests.
182
183The size of an B<EVP_MD_CTX> structure is determined at compile time: this results
184in code that must be recompiled if the size of B<EVP_MD_CTX> increases.
185
186=head1 SEE ALSO
187
188L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>,
189L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>,
190L<sha(3)|sha(3)>, L<digest(1)|digest(1)>
191
192=head1 HISTORY
193
194EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are
195available in all versions of SSLeay and OpenSSL.
196
197=cut
diff --git a/src/lib/libcrypto/doc/EVP_EncryptInit.pod b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
new file mode 100644
index 0000000000..77ed4ccdba
--- /dev/null
+++ b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
@@ -0,0 +1,224 @@
1=pod
2
3=head1 NAME
4
5EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal - EVP cipher routines
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 void EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
12 unsigned char *key, unsigned char *iv);
13 void EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
14 int *outl, unsigned char *in, int inl);
15 void EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
16 int *outl);
17
18 void EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
19 unsigned char *key, unsigned char *iv);
20 void EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
21 int *outl, unsigned char *in, int inl);
22 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
23 int *outl);
24
25 void EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
26 unsigned char *key, unsigned char *iv, int enc);
27 void EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
28 int *outl, unsigned char *in, int inl);
29 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
30 int *outl);
31
32 void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
33
34 const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
35 #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
36 #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
37
38 #define EVP_CIPHER_nid(e) ((e)->nid)
39 #define EVP_CIPHER_block_size(e) ((e)->block_size)
40 #define EVP_CIPHER_key_length(e) ((e)->key_len)
41 #define EVP_CIPHER_iv_length(e) ((e)->iv_len)
42
43 int EVP_CIPHER_type(const EVP_CIPHER *ctx);
44 #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
45 #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
46 #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
47 #define EVP_CIPHER_CTX_key_length(e) ((e)->cipher->key_len)
48 #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
49 #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
50
51 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
52 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
53
54=head1 DESCRIPTION
55
56The EVP cipher routines are a high level interface to certain
57symmetric ciphers.
58
59EVP_EncryptInit() initialises a cipher context B<ctx> for encryption
60with cipher B<type>. B<type> is normally supplied by a function such
61as EVP_des_cbc() . B<key> is the symmetric key to use and B<iv> is the
62IV to use (if necessary), the actual number of bytes used for the
63key and IV depends on the cipher. It is possible to set all parameters
64to NULL except B<type> in an initial call and supply the remaining
65parameters in subsequent calls. This is normally done when the
66EVP_CIPHER_asn1_to_param() function is called to set the cipher
67parameters from an ASN1 AlgorithmIdentifier and the key from a
68different source.
69
70EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and
71writes the encrypted version to B<out>. This function can be called
72multiple times to encrypt successive blocks of data. The amount
73of data written depends on the block alignment of the encrypted data:
74as a result the amount of data written may be anything from zero bytes
75to (inl + cipher_block_size - 1) so B<outl> should contain sufficient
76room. The actual number of bytes written is placed in B<outl>.
77
78EVP_EncryptFinal() encrypts the "final" data, that is any data that
79remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS
80padding). The encrypted final data is written to B<out> which should
81have sufficient space for one cipher block. The number of bytes written
82is placed in B<outl>. After this function is called the encryption operation
83is finished and no further calls to EVP_EncryptUpdate() should be made.
84
85EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the
86corresponding decryption operations. EVP_DecryptFinal() will return an
87error code if the final block is not correctly formatted. The parameters
88and restrictions are identical to the encryption operations except that
89the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should
90have sufficient room for (B<inl> + cipher_block_size) bytes unless the
91cipher block size is 1 in which case B<inl> bytes is sufficient.
92
93EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions
94that can be used for decryption or encryption. The operation performed
95depends on the value of the B<enc> parameter. It should be set to 1 for
96encryption and 0 for decryption.
97
98EVP_CIPHER_CTX_cleanup() clears all information from a cipher context.
99It should be called after all operations using a cipher are complete
100so sensitive information does not remain in memory.
101
102EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
103return an EVP_CIPHER structure when passed a cipher name, a NID or an
104ASN1_OBJECT structure.
105
106EVP_CIPHER_nid() and EVP_CIPHER_CTX_nid() return the NID of a cipher when
107passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> structure. The actual NID
108value is an internal value which may not have a corresponding OBJECT
109IDENTIFIER.
110
111EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
112length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>
113structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length
114for all ciphers.
115
116EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
117length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>.
118It will return zero if the cipher does not use an IV. The constant
119B<EVP_MAX_IV_LENGTH> is the maximum IV length for all ciphers.
120
121EVP_CIPHER_block_size() and EVP_CIPHER_CTX_block_size() return the block
122size of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>
123structure. The constant B<EVP_MAX_IV_LENGTH> is also the maximum block
124length for all ciphers.
125
126EVP_CIPHER_type() and EVP_CIPHER_CTX_type() return the type of the passed
127cipher or context. This "type" is the actual NID of the cipher OBJECT
128IDENTIFIER as such it ignores the cipher parameters and 40 bit RC2 and
129128 bit RC2 have the same NID. If the cipher does not have an object
130identifier or does not have ASN1 support this function will return
131B<NID_undef>.
132
133EVP_CIPHER_CTX_cipher() returns the B<EVP_CIPHER> structure when passed
134an B<EVP_CIPHER_CTX> structure.
135
136EVP_CIPHER_param_to_asn1() sets the AlgorithmIdentifier "parameter" based
137on the passed cipher. This will typically include any parameters and an
138IV. The cipher IV (if any) must be set when this call is made. This call
139should be made before the cipher is actually "used" (before any
140EVP_EncryptUpdate(), EVP_DecryptUpdate() calls for example). This function
141may fail if the cipher does not have any ASN1 support.
142
143EVP_CIPHER_asn1_to_param() sets the cipher parameters based on an ASN1
144AlgorithmIdentifier "parameter". The precise effect depends on the cipher
145In the case of RC2, for example, it will set the IV and effective key length.
146This function should be called after the base cipher type is set but before
147the key is set. For example EVP_CipherInit() will be called with the IV and
148key set to NULL, EVP_CIPHER_asn1_to_param() will be called and finally
149EVP_CipherInit() again with all parameters except the key set to NULL. It is
150possible for this function to fail if the cipher does not have any ASN1 support
151or the parameters cannot be set (for example the RC2 effective key length
152does not have an B<EVP_CIPHER> structure).
153
154=head1 RETURN VALUES
155
156EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() do not return
157values.
158
159EVP_DecryptInit() and EVP_DecryptUpdate() do not return values.
160EVP_DecryptFinal() returns 0 if the decrypt failed or 1 for success.
161
162EVP_CipherInit() and EVP_CipherUpdate() do not return values.
163EVP_CipherFinal() returns 1 for a decryption failure or 1 for success, if
164the operation is encryption then it always returns 1.
165
166EVP_CIPHER_CTX_cleanup() does not return a value.
167
168EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
169return an B<EVP_CIPHER> structure or NULL on error.
170
171EVP_CIPHER_nid() and EVP_CIPHER_CTX_nid() return a NID.
172
173EVP_CIPHER_block_size() and EVP_CIPHER_CTX_block_size() return the block
174size.
175
176EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
177length.
178
179EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
180length or zero if the cipher does not use an IV.
181
182EVP_CIPHER_type() and EVP_CIPHER_CTX_type() return the NID of the cipher's
183OBJECT IDENTIFIER or NID_undef if it has no defined OBJECT IDENTIFIER.
184
185EVP_CIPHER_CTX_cipher() returns an B<EVP_CIPHER> structure.
186
187EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return 1 for
188success or zero for failure.
189
190=head1 NOTES
191
192Where possible the B<EVP> interface to symmetric ciphers should be used in
193preference to the low level interfaces. This is because the code then becomes
194transparent to the cipher used and much more flexible.
195
196PKCS padding works by adding B<n> padding bytes of value B<n> to make the total
197length of the encrypted data a multiple of the block size. Padding is always
198added so if the data is already a multiple of the block size B<n> will equal
199the block size. For example if the block size is 8 and 11 bytes are to be
200encrypted then 5 padding bytes of value 5 will be added.
201
202When decrypting the final block is checked to see if it has the correct form.
203
204Although the decryption operation can produce an error, it is not a strong
205test that the input data or key is correct. A random block has better than
2061 in 256 chance of being of the correct format and problems with the
207input data earlier on will not produce a final decrypt error.
208
209=head1 BUGS
210
211The current B<EVP> cipher interface is not as flexible as it should be. Only
212certain "spot" encryption algorithms can be used for ciphers which have various
213parameters associated with them (RC2, RC5 for example) this is inadequate.
214
215Several of the functions do not return error codes because the software versions
216can never fail. This is not true of hardware versions.
217
218=head1 SEE ALSO
219
220L<evp(3)|evp(3)>
221
222=head1 HISTORY
223
224=cut
diff --git a/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
new file mode 100644
index 0000000000..b0b1058d19
--- /dev/null
+++ b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
@@ -0,0 +1,46 @@
1=pod
2
3=head1 NAME
4
5OPENSSL_VERSION_NUMBER, SSLeay - get OpenSSL version number
6
7=head1 SYNOPSIS
8
9 #include <openssl/opensslv.h>
10 #define OPENSSL_VERSION_NUMBER 0xnnnnnnnnnL
11
12 #include <openssl/crypto.h>
13 long SSLeay(void);
14
15=head1 DESCRIPTION
16
17OPENSSL_VERSION_NUMBER is a numeric release version identifier:
18
19 MMNNFFRBB major minor fix final beta/patch
20
21for example
22
23 0x000904100 == 0.9.4 release
24 0x000905000 == 0.9.5 dev
25
26Versions prior to 0.9.3 have identifiers E<lt> 0x0930.
27For backward compatibility, SSLEAY_VERSION_NUMBER is also defined.
28
29SSLeay() returns this number. The return value can be compared to the
30macro to make sure that the correct version of the library has been
31loaded, especially when using DLLs on Windows systems.
32
33=head1 RETURN VALUE
34
35The version number.
36
37=head1 SEE ALSO
38
39L<crypto(3)|crypto(3)>
40
41=head1 HISTORY
42
43SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL.
44OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL.
45
46=cut
diff --git a/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod b/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
new file mode 100644
index 0000000000..1300fe190c
--- /dev/null
+++ b/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
@@ -0,0 +1,65 @@
1=pod
2
3=head1 NAME
4
5OpenSSL_add_all_algorithms() - add algorithms to internal table
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 void OpenSSL_add_all_algorithms(void);
12 void OpenSSL_add_all_ciphers(void);
13 void OpenSSL_add_all_digests(void);
14
15 void EVP_cleanup(void);
16
17=head1 DESCRIPTION
18
19OpenSSL keeps an internal table of digest algorithms and ciphers. It uses
20this table to lookup ciphers via functions such as EVP_get_cipher_byname().
21
22OpenSSL_add_all_digests() adds all digest algorithms to the table.
23
24OpenSSL_add_all_algorithms() adds all algorithms to the table (digests and
25ciphers).
26
27OpenSSL_add_all_ciphers() adds all encryption algorithms to the table including
28password based encryption algorithms.
29
30EVP_cleanup() removes all ciphers and digests from the table.
31
32=head1 RETURN VALUES
33
34None of the functions return a value.
35
36=head1 NOTES
37
38A typical application will will call OpenSSL_add_all_algorithms() initially and
39EVP_cleanup() before exiting.
40
41An application does not need to add algorithms to use them explicitly, for example
42by EVP_sha1(). It just needs to add them if it (or any of the functions it calls)
43needs to lookup algorithms.
44
45The cipher and digest lookup functions are used in many parts of the library. If
46the table is not initialised several functions will misbehave and complain they
47cannot find algorithms. This includes the PEM, PKCS#12, SSL and S/MIME libraries.
48This is a common query in the OpenSSL mailing lists.
49
50Calling OpenSSL_add_all_algorithms() links in all algorithms: as a result a
51statically linked executable can be quite large. If this is important it is possible
52to just add the required ciphers and digests.
53
54=head1 BUGS
55
56Although the functions do not return error codes it is possible for them to fail.
57This will only happen as a result of a memory allocation failure so this is not
58too much of a problem in practice.
59
60=head1 SEE ALSO
61
62L<evp(3)|evp(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>,
63L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>
64
65=cut
diff --git a/src/lib/libcrypto/doc/RAND_add.pod b/src/lib/libcrypto/doc/RAND_add.pod
new file mode 100644
index 0000000000..0a13ec2a92
--- /dev/null
+++ b/src/lib/libcrypto/doc/RAND_add.pod
@@ -0,0 +1,68 @@
1=pod
2
3=head1 NAME
4
5RAND_add, RAND_seed, RAND_screen - add entropy to the PRNG
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_seed(const void *buf, int num);
12
13 void RAND_add(const void *buf, int num, double entropy);
14
15 int RAND_status(void);
16
17 void RAND_screen(void);
18
19=head1 DESCRIPTION
20
21RAND_add() mixes the B<num> bytes at B<buf> into the PRNG state. Thus,
22if the data at B<buf> are unpredictable to an adversary, this
23increases the uncertainty about the state and makes the PRNG output
24less predictable. Suitable input comes from user interaction (random
25key presses, mouse movements) and certain hardware events. The
26B<entropy> argument is (the lower bound of) an estimate of how much
27randomness is contained in B<buf>, measured in bytes. Details about
28sources of randomness and how to estimate their entropy can be found
29in the literature, e.g. RFC 1750.
30
31RAND_add() may be called with sensitive data such as user entered
32passwords. The seed values cannot be recovered from the PRNG output.
33
34OpenSSL makes sure that the PRNG state is unique for each thread. On
35systems that provide C</dev/urandom>, the randomness device is used
36to seed the PRNG transparently. However, on all other systems, the
37application is responsible for seeding the PRNG by calling RAND_add(),
38L<RAND_egd(3)|RAND_egd(3)>
39or L<RAND_load_file(3)|RAND_load_file(3)>.
40
41RAND_seed() is equivalent to RAND_add() when B<num == entropy>.
42
43The RAND_screen() function is available for the convenience of Windows
44programmers. It adds the current contents of the screen to the PRNG.
45For applications that can catch Windows events, seeding the PRNG with
46the parameters of B<WM_MOUSEMOVE> events is a significantly better
47source of randomness. It should be noted that both methods cannot be
48used on servers that run without user interaction.
49
50=head1 RETURN VALUES
51
52RAND_status() returns 1 if the PRNG has been seeded with enough data,
530 otherwise.
54
55The other functions do not return values.
56
57=head1 SEE ALSO
58
59L<rand(3)|rand(3)>, L<RAND_egd(3)|RAND_egd(3)>,
60L<RAND_load_file(3)|RAND_load_file(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
61
62=head1 HISTORY
63
64RAND_seed() and RAND_screen() are available in all versions of SSLeay
65and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL
660.9.5.
67
68=cut
diff --git a/src/lib/libcrypto/doc/RAND_bytes.pod b/src/lib/libcrypto/doc/RAND_bytes.pod
new file mode 100644
index 0000000000..b6ebd50527
--- /dev/null
+++ b/src/lib/libcrypto/doc/RAND_bytes.pod
@@ -0,0 +1,46 @@
1=pod
2
3=head1 NAME
4
5RAND_bytes, RAND_pseudo_bytes - generate random data
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 int RAND_bytes(unsigned char *buf, int num);
12
13 int RAND_pseudo_bytes(unsigned char *buf, int num);
14
15=head1 DESCRIPTION
16
17RAND_bytes() puts B<num> cryptographically strong pseudo-random bytes
18into B<buf>. An error occurs if the PRNG has not been seeded with
19enough randomness to ensure an unpredictable byte sequence.
20
21RAND_pseudo_bytes() puts B<num> pseudo-random bytes into B<buf>.
22Pseudo-random byte sequences generated by RAND_pseudo_bytes() will be
23unique if they are of sufficient length, but are not necessarily
24unpredictable. They can be used for non-cryptographic purposes and for
25certain purposes in cryptographic protocols, but usually not for key
26generation etc.
27
28=head1 RETURN VALUES
29
30RAND_bytes() returns 1 on success, 0 otherwise. The error code can be
31obtained by L<ERR_get_error(3)|ERR_get_error(3)>. RAND_pseudo_bytes() returns 1 if the
32bytes generated are cryptographically strong, 0 otherwise. Both
33functions return -1 if they are not supported by the current RAND
34method.
35
36=head1 SEE ALSO
37
38L<rand(3)|rand(3)>, L<err(3)|err(3)>, L<RAND_add(3)|RAND_add(3)>
39
40=head1 HISTORY
41
42RAND_bytes() is available in all versions of SSLeay and OpenSSL. It
43has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
44in OpenSSL 0.9.5.
45
46=cut
diff --git a/src/lib/libcrypto/doc/RAND_cleanup.pod b/src/lib/libcrypto/doc/RAND_cleanup.pod
new file mode 100644
index 0000000000..3a8f0749a8
--- /dev/null
+++ b/src/lib/libcrypto/doc/RAND_cleanup.pod
@@ -0,0 +1,29 @@
1=pod
2
3=head1 NAME
4
5RAND_cleanup - erase the PRNG state
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_cleanup(void);
12
13=head1 DESCRIPTION
14
15RAND_cleanup() erases the memory used by the PRNG.
16
17=head1 RETURN VALUE
18
19RAND_cleanup() returns no value.
20
21=head1 SEE ALSO
22
23L<rand(3)|rand(3)>
24
25=head1 HISTORY
26
27RAND_cleanup() is available in all versions of SSLeay and OpenSSL.
28
29=cut
diff --git a/src/lib/libcrypto/doc/RAND_load_file.pod b/src/lib/libcrypto/doc/RAND_load_file.pod
new file mode 100644
index 0000000000..8dd700ca3d
--- /dev/null
+++ b/src/lib/libcrypto/doc/RAND_load_file.pod
@@ -0,0 +1,53 @@
1=pod
2
3=head1 NAME
4
5RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 const char *RAND_file_name(char *buf, int num);
12
13 int RAND_load_file(const char *filename, long max_bytes);
14
15 int RAND_write_file(const char *filename);
16
17=head1 DESCRIPTION
18
19RAND_file_name() generates a default path for the random seed
20file. B<buf> points to a buffer of size B<num> in which to store the
21filename. The seed file is $RANDFILE if that environment variable is
22set, $HOME/.rnd otherwise. If $HOME is not set either, or B<num> is
23too small for the path name, an error occurs.
24
25RAND_load_file() reads a number of bytes from file B<filename> and
26adds them to the PRNG. If B<max_bytes> is non-negative,
27up to to B<max_bytes> are read; starting with OpenSSL 0.9.5,
28if B<max_bytes> is -1, the complete file is read.
29
30RAND_write_file() writes a number of random bytes (currently 1024) to
31file B<filename> which can be used to initialize the PRNG by calling
32RAND_load_file() in a later session.
33
34=head1 RETURN VALUES
35
36RAND_load_file() returns the number of bytes read.
37
38RAND_write_file() returns the number of bytes written, and -1 if the
39bytes written were generated without appropriate seed.
40
41RAND_file_name() returns a pointer to B<buf> on success, and NULL on
42error.
43
44=head1 SEE ALSO
45
46L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
47
48=head1 HISTORY
49
50RAND_load_file(), RAND_write_file() and RAND_file_name() are available in
51all versions of SSLeay and OpenSSL.
52
53=cut
diff --git a/src/lib/libcrypto/doc/RAND_set_rand_method.pod b/src/lib/libcrypto/doc/RAND_set_rand_method.pod
new file mode 100644
index 0000000000..466e9b8767
--- /dev/null
+++ b/src/lib/libcrypto/doc/RAND_set_rand_method.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_set_rand_method(RAND_METHOD *meth);
12
13 RAND_METHOD *RAND_get_rand_method(void);
14
15 RAND_METHOD *RAND_SSLeay(void);
16
17=head1 DESCRIPTION
18
19A B<RAND_METHOD> specifies the functions that OpenSSL uses for random
20number generation. By modifying the method, alternative
21implementations such as hardware RNGs may be used. Initially, the
22default is to use the OpenSSL internal implementation. RAND_SSLeay()
23returns a pointer to that method.
24
25RAND_set_rand_method() sets the RAND method to B<meth>.
26RAND_get_rand_method() returns a pointer to the current method.
27
28=head1 THE RAND_METHOD STRUCTURE
29
30 typedef struct rand_meth_st
31 {
32 void (*seed)(const void *buf, int num);
33 int (*bytes)(unsigned char *buf, int num);
34 void (*cleanup)(void);
35 void (*add)(const void *buf, int num, int entropy);
36 int (*pseudorand)(unsigned char *buf, int num);
37 } RAND_METHOD;
38
39The components point to the implementation of RAND_seed(),
40RAND_bytes(), RAND_cleanup(), RAND_add() and RAND_pseudo_rand().
41Each component may be NULL if the function is not implemented.
42
43=head1 RETURN VALUES
44
45RAND_set_rand_method() returns no value. RAND_get_rand_method() and
46RAND_SSLeay() return pointers to the respective methods.
47
48=head1 SEE ALSO
49
50L<rand(3)|rand(3)>
51
52=head1 HISTORY
53
54RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are
55available in all versions of OpenSSL.
56
57=cut
diff --git a/src/lib/libcrypto/doc/RSA_blinding_on.pod b/src/lib/libcrypto/doc/RSA_blinding_on.pod
new file mode 100644
index 0000000000..fd2c69abd8
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_blinding_on.pod
@@ -0,0 +1,43 @@
1=pod
2
3=head1 NAME
4
5RSA_blinding_on, RSA_blinding_off - protect the RSA operation from timing attacks
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
12
13 void RSA_blinding_off(RSA *rsa);
14
15=head1 DESCRIPTION
16
17RSA is vulnerable to timing attacks. In a setup where attackers can
18measure the time of RSA decryption or signature operations, blinding
19must be used to protect the RSA operation from that attack.
20
21RSA_blinding_on() turns blinding on for key B<rsa> and generates a
22random blinding factor. B<ctx> is B<NULL> or a pre-allocated and
23initialized B<BN_CTX>. The random number generator must be seeded
24prior to calling RSA_blinding_on().
25
26RSA_blinding_off() turns blinding off and frees the memory used for
27the blinding factor.
28
29=head1 RETURN VALUES
30
31RSA_blinding_on() returns 1 on success, and 0 if an error occurred.
32
33RSA_blinding_off() returns no value.
34
35=head1 SEE ALSO
36
37L<rsa(3)|rsa(3)>, L<rand(3)|rand(3)>
38
39=head1 HISTORY
40
41RSA_blinding_on() and RSA_blinding_off() appeared in SSLeay 0.9.0.
42
43=cut
diff --git a/src/lib/libcrypto/doc/RSA_check_key.pod b/src/lib/libcrypto/doc/RSA_check_key.pod
new file mode 100644
index 0000000000..79fed753ad
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_check_key.pod
@@ -0,0 +1,39 @@
1=pod
2
3=head1 NAME
4
5RSA_check_key - validate private RSA keys
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_check_key(RSA *rsa);
12
13=head1 DESCRIPTION
14
15This function validates RSA keys. It checks that B<p> and B<q> are
16in fact prime, and that B<n = p*q>.
17
18It also checks that B<d*e = 1 mod (p-1*q-1)>,
19and that B<dmp1>, B<dmq1> and B<iqmp> are set correctly or are B<NULL>.
20
21The key's public components may not be B<NULL>.
22
23=head1 RETURN VALUE
24
25RSA_check_key() returns 1 if B<rsa> is a valid RSA key, and 0 otherwise.
26-1 is returned if an error occurs while checking the key.
27
28If the key is invalid or an error occurred, the reason code can be
29obtained using L<ERR_get_error(3)|ERR_get_error(3)>.
30
31=head1 SEE ALSO
32
33L<rsa(3)|rsa(3)>, L<err(3)|err(3)>
34
35=head1 HISTORY
36
37RSA_check() appeared in OpenSSL 0.9.4.
38
39=cut
diff --git a/src/lib/libcrypto/doc/RSA_generate_key.pod b/src/lib/libcrypto/doc/RSA_generate_key.pod
new file mode 100644
index 0000000000..fdaddbcb13
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_generate_key.pod
@@ -0,0 +1,68 @@
1=pod
2
3=head1 NAME
4
5RSA_generate_key - generate RSA key pair
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA *RSA_generate_key(int num, unsigned long e,
12 void (*callback)(int,int,void *), void *cb_arg);
13
14=head1 DESCRIPTION
15
16RSA_generate_key() generates a key pair and returns it in a newly
17allocated B<RSA> structure. The pseudo-random number generator must
18be seeded prior to calling RSA_generate_key().
19
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.
22The exponent is an odd number, typically 3 or 65535.
23
24A callback function may be used to provide feedback about the
25progress of the key generation. If B<callback> is not B<NULL>, it
26will be called as follows:
27
28=over 4
29
30=item *
31
32While a random prime number is generated, it is called as
33described in L<BN_generate_prime(3)|BN_generate_prime(3)>.
34
35=item *
36
37When the n-th randomly generated prime is rejected as not
38suitable for the key, B<callback(2, n, cb_arg)> is called.
39
40=item *
41
42When a random p has been found with p-1 relatively prime to B<e>,
43it is called as B<callback(3, 0, cb_arg)>.
44
45=back
46
47The process is then repeated for prime q with B<callback(3, 1, cb_arg)>.
48
49=head1 RETURN VALUE
50
51If key generation fails, RSA_generate_key() returns B<NULL>; the
52error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
53
54=head1 BUGS
55
56B<callback(2, x, cb_arg)> is used with two different meanings.
57
58RSA_generate_key() goes into an infinite loop for illegal input values.
59
60=head1 SEE ALSO
61
62L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_free(3)|RSA_free(3)>
63
64=head1 HISTORY
65
66The B<cb_arg> argument was added in SSLeay 0.9.0.
67
68=cut
diff --git a/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod b/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod
new file mode 100644
index 0000000000..920dc76325
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod
@@ -0,0 +1,122 @@
1=pod
2
3=head1 NAME
4
5RSA_get_ex_new_index, RSA_set_ex_data, RSA_get_ex_data - add application specific data to RSA structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func,
13 CRYPTO_EX_dup *dup_func,
14 CRYPTO_EX_free *free_func);
15
16 int RSA_set_ex_data(RSA *r, int idx, void *arg);
17
18 void *RSA_get_ex_data(RSA *r, int idx);
19
20 int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
21 int idx, long argl, void *argp);
22
23 void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
24 int idx, long argl, void *argp);
25
26 int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
27 int idx, long argl, void *argp);
28
29=head1 DESCRIPTION
30
31Several OpenSSL structures can have application specific data attached to them.
32This has several potential uses, it can be used to cache data associated with
33a structure (for example the hash of some part of the structure) or some
34additional data (for example a handle to the data in an external library).
35
36Since the application data can be anything at all it is passed and retrieved
37as a B<void *> type.
38
39The B<RSA_get_ex_new_index()> function is initially called to "register" some
40new application specific data. It takes three optional function pointers which
41are called when the parent structure (in this case an RSA structure) is
42initially created, when it is copied and when it is freed up. If any or all of
43these function pointer arguments are not used they should be set to NULL. The
44precise manner in which these function pointers are called is described in more
45detail below. B<RSA_get_ex_new_index()> also takes additional long and pointer
46parameters which will be passed to the supplied functions but which otherwise
47have no special meaning. It returns an B<index> which should be stored
48(typically in a static variable) and passed used in the B<idx> parameter in
49the remaining functions. Each successful call to B<RSA_get_ex_new_index()>
50will return an index greater than any previously returned, this is important
51because the optional functions are called in order of increasing index value.
52
53B<RSA_set_ex_data()> is used to set application specific data, the data is
54supplied in the B<arg> parameter and its precise meaning is up to the
55application.
56
57B<RSA_get_ex_data()> is used to retrieve application specific data. The data
58is returned to the application, this will be the same value as supplied to
59a previous B<RSA_set_ex_data()> call.
60
61B<new_func()> is called when a structure is initially allocated (for example
62with B<RSA_new()>. The parent structure members will not have any meaningful
63values at this point. This function will typically be used to allocate any
64application specific structure.
65
66B<free_func()> is called when a structure is being freed up. The dynamic parent
67structure members should not be accessed because they will be freed up when
68this function is called.
69
70B<new_func()> and B<free_func()> take the same parameters. B<parent> is a
71pointer to the parent RSA structure. B<ptr> is a the application specific data
72(this wont be of much use in B<new_func()>. B<ad> is a pointer to the
73B<CRYPTO_EX_DATA> structure from the parent RSA structure: the functions
74B<CRYPTO_get_ex_data()> and B<CRYPTO_set_ex_data()> can be called to manipulate
75it. The B<idx> parameter is the index: this will be the same value returned by
76B<RSA_get_ex_new_index()> when the functions were initially registered. Finally
77the B<argl> and B<argp> parameters are the values originally passed to the same
78corresponding parameters when B<RSA_get_ex_new_index()> was called.
79
80B<dup_func()> is called when a structure is being copied. Pointers to the
81destination and source B<CRYPTO_EX_DATA> structures are passed in the B<to> and
82B<from> parameters respectively. The B<from_d> parameter is passed a pointer to
83the source application data when the function is called, when the function returns
84the value is copied to the destination: the application can thus modify the data
85pointed to by B<from_d> and have different values in the source and destination.
86The B<idx>, B<argl> and B<argp> parameters are the same as those in B<new_func()>
87and B<free_func()>.
88
89=head1 RETURN VALUES
90
91B<RSA_get_ex_new_index()> returns a new index or -1 on failure (note 0 is a valid
92index value).
93
94B<RSA_set_ex_data()> returns 1 on success or 0 on failure.
95
96B<RSA_get_ex_data()> returns the application data or 0 on failure. 0 may also
97be valid application data but currently it can only fail if given an invalid B<idx>
98parameter.
99
100B<new_func()> and B<dup_func()> should return 0 for failure and 1 for success.
101
102On failure an error code can be obtained from L<ERR_get_error(3)|ERR_get_error(3)>.
103
104=head1 BUGS
105
106B<dup_func()> is currently never called.
107
108The return value of B<new_func()> is ignored.
109
110The B<new_func()> function isn't very useful because no meaningful values are
111present in the parent RSA structure when it is called.
112
113=head1 SEE ALSO
114
115L<rsa(3)|rsa(3)>, L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>
116
117=head1 HISTORY
118
119RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data() are
120available since SSLeay 0.9.0.
121
122=cut
diff --git a/src/lib/libcrypto/doc/RSA_new.pod b/src/lib/libcrypto/doc/RSA_new.pod
new file mode 100644
index 0000000000..f16490ea6a
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_new.pod
@@ -0,0 +1,38 @@
1=pod
2
3=head1 NAME
4
5RSA_new, RSA_free - allocate and free RSA objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA * RSA_new(void);
12
13 void RSA_free(RSA *rsa);
14
15=head1 DESCRIPTION
16
17RSA_new() allocates and initializes an B<RSA> structure.
18
19RSA_free() frees the B<RSA> structure and its components. The key is
20erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, RSA_new() returns B<NULL> and sets an error
25code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns
26a pointer to the newly allocated structure.
27
28RSA_free() returns no value.
29
30=head1 SEE ALSO
31
32L<err(3)|err(3)>, L<rsa(3)|rsa(3)>, L<RSA_generate_key(3)|RSA_generate_key(3)>
33
34=head1 HISTORY
35
36RSA_new() and RSA_free() are available in all versions of SSLeay and OpenSSL.
37
38=cut
diff --git a/src/lib/libcrypto/doc/RSA_padding_add_PKCS1_type_1.pod b/src/lib/libcrypto/doc/RSA_padding_add_PKCS1_type_1.pod
new file mode 100644
index 0000000000..b8f678fe72
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_padding_add_PKCS1_type_1.pod
@@ -0,0 +1,124 @@
1=pod
2
3=head1 NAME
4
5RSA_padding_add_PKCS1_type_1, RSA_padding_check_PKCS1_type_1,
6RSA_padding_add_PKCS1_type_2, RSA_padding_check_PKCS1_type_2,
7RSA_padding_add_PKCS1_OAEP, RSA_padding_check_PKCS1_OAEP,
8RSA_padding_add_SSLv23, RSA_padding_check_SSLv23,
9RSA_padding_add_none, RSA_padding_check_none - asymmetric encryption
10padding
11
12=head1 SYNOPSIS
13
14 #include <openssl/rsa.h>
15
16 int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
17 unsigned char *f, int fl);
18
19 int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
20 unsigned char *f, int fl, int rsa_len);
21
22 int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
23 unsigned char *f, int fl);
24
25 int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
26 unsigned char *f, int fl, int rsa_len);
27
28 int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
29 unsigned char *f, int fl, unsigned char *p, int pl);
30
31 int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
32 unsigned char *f, int fl, int rsa_len, unsigned char *p, int pl);
33
34 int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
35 unsigned char *f, int fl);
36
37 int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
38 unsigned char *f, int fl, int rsa_len);
39
40 int RSA_padding_add_none(unsigned char *to, int tlen,
41 unsigned char *f, int fl);
42
43 int RSA_padding_check_none(unsigned char *to, int tlen,
44 unsigned char *f, int fl, int rsa_len);
45
46=head1 DESCRIPTION
47
48The RSA_padding_xxx_xxx() functions are called from the RSA encrypt,
49decrypt, sign and verify functions. Normally they should not be called
50from application programs.
51
52However, they can also be called directly to implement padding for other
53asymmetric ciphers. RSA_padding_add_PKCS1_OAEP() and
54RSA_padding_check_PKCS1_OAEP() may be used in an application combined
55with B<RSA_NO_PADDING> in order to implement OAEP with an encoding
56parameter.
57
58RSA_padding_add_xxx() encodes B<fl> bytes from B<f> so as to fit into
59B<tlen> bytes and stores the result at B<to>. An error occurs if B<fl>
60does not meet the size requirements of the encoding method.
61
62The following encoding methods are implemented:
63
64=over 4
65
66=item PKCS1_type_1
67
68PKCS #1 v2.0 EMSA-PKCS1-v1_5 (PKCS #1 v1.5 block type 1); used for signatures
69
70=item PKCS1_type_2
71
72PKCS #1 v2.0 EME-PKCS1-v1_5 (PKCS #1 v1.5 block type 2)
73
74=item PKCS1_OAEP
75
76PKCS #1 v2.0 EME-OAEP
77
78=item SSLv23
79
80PKCS #1 EME-PKCS1-v1_5 with SSL-specific modification
81
82=item none
83
84simply copy the data
85
86=back
87
88The random number generator must be seeded prior to calling
89RSA_padding_add_xxx().
90
91RSA_padding_check_xxx() verifies that the B<fl> bytes at B<f> contain
92a valid encoding for a B<rsa_len> byte RSA key in the respective
93encoding method and stores the recovered data of at most B<tlen> bytes
94(for B<RSA_NO_PADDING>: of size B<tlen>)
95at B<to>.
96
97For RSA_padding_xxx_OAEP(), B<p> points to the encoding parameter
98of length B<pl>. B<p> may be B<NULL> if B<pl> is 0.
99
100=head1 RETURN VALUES
101
102The RSA_padding_add_xxx() functions return 1 on success, 0 on error.
103The RSA_padding_check_xxx() functions return the length of the
104recovered data, -1 on error. Error codes can be obtained by calling
105L<ERR_get_error(3)|ERR_get_error(3)>.
106
107=head1 SEE ALSO
108
109L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>,
110L<RSA_private_decrypt(3)|RSA_private_decrypt(3)>,
111L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)>
112
113=head1 HISTORY
114
115RSA_padding_add_PKCS1_type_1(), RSA_padding_check_PKCS1_type_1(),
116RSA_padding_add_PKCS1_type_2(), RSA_padding_check_PKCS1_type_2(),
117RSA_padding_add_SSLv23(), RSA_padding_check_SSLv23(),
118RSA_padding_add_none() and RSA_padding_check_none() appeared in
119SSLeay 0.9.0.
120
121RSA_padding_add_PKCS1_OAEP() and RSA_padding_check_PKCS1_OAEP() were
122added in OpenSSL 0.9.2b.
123
124=cut
diff --git a/src/lib/libcrypto/doc/RSA_print.pod b/src/lib/libcrypto/doc/RSA_print.pod
new file mode 100644
index 0000000000..dd968a5274
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_print.pod
@@ -0,0 +1,48 @@
1=pod
2
3=head1 NAME
4
5RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp - print
6cryptographic parameters
7
8=head1 SYNOPSIS
9
10 #include <openssl/rsa.h>
11
12 int RSA_print(BIO *bp, RSA *x, int offset);
13 int RSA_print_fp(FILE *fp, RSA *x, int offset);
14
15 #include <openssl/dsa.h>
16
17 int DSAparams_print(BIO *bp, DSA *x);
18 int DSAparams_print_fp(FILE *fp, DSA *x);
19 int DSA_print(BIO *bp, DSA *x, int offset);
20 int DSA_print_fp(FILE *fp, DSA *x, int offset);
21
22 #include <openssl/dh.h>
23
24 int DHparams_print(BIO *bp, DH *x);
25 int DHparams_print_fp(FILE *fp, DH *x);
26
27=head1 DESCRIPTION
28
29A human-readable hexadecimal output of the components of the RSA
30key, DSA parameters or key or DH parameters is printed to B<bp> or B<fp>.
31
32The output lines are indented by B<offset> spaces.
33
34=head1 RETURN VALUES
35
36These functions return 1 on success, 0 on error.
37
38=head1 SEE ALSO
39
40L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<rsa(3)|rsa(3)>, L<BN_bn2bin(3)|BN_bn2bin(3)>
41
42=head1 HISTORY
43
44RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(),
45DH_print_fp() are available in all versions of SSLeay and OpenSSL.
46DSAparams_print() and DSAparams_print_pf() were added in SSLeay 0.8.
47
48=cut
diff --git a/src/lib/libcrypto/doc/RSA_private_encrypt.pod b/src/lib/libcrypto/doc/RSA_private_encrypt.pod
new file mode 100644
index 0000000000..6861a98a10
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_private_encrypt.pod
@@ -0,0 +1,69 @@
1=pod
2
3=head1 NAME
4
5RSA_private_encrypt, RSA_public_decrypt - low level signature operations
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_private_encrypt(int flen, unsigned char *from,
12 unsigned char *to, RSA *rsa, int padding);
13
14 int RSA_public_decrypt(int flen, unsigned char *from,
15 unsigned char *to, RSA *rsa, int padding);
16
17=head1 DESCRIPTION
18
19These functions handle RSA signatures at a low level.
20
21RSA_private_encrypt() signs the B<flen> bytes at B<from> (usually a
22message digest with an algorithm identifier) using the private key
23B<rsa> and stores the signature in B<to>. B<to> must point to
24B<RSA_size(rsa)> bytes of memory.
25
26B<padding> denotes one of the following modes:
27
28=over 4
29
30=item RSA_PKCS1_PADDING
31
32PKCS #1 v1.5 padding. This function does not handle the
33B<algorithmIdentifier> specified in PKCS #1. When generating or
34verifying PKCS #1 signatures, L<RSA_sign(3)|RSA_sign(3)> and L<RSA_verify(3)|RSA_verify(3)> should be
35used.
36
37=item RSA_NO_PADDING
38
39Raw RSA signature. This mode should I<only> be used to implement
40cryptographically sound padding modes in the application code.
41Signing user data directly with RSA is insecure.
42
43=back
44
45RSA_public_decrypt() recovers the message digest from the B<flen>
46bytes long signature at B<from> using the signer's public key
47B<rsa>. B<to> must point to a memory section large enough to hold the
48message digest (which is smaller than B<RSA_size(rsa) -
4911>). B<padding> is the padding mode that was used to sign the data.
50
51=head1 RETURN VALUES
52
53RSA_private_encrypt() returns the size of the signature (i.e.,
54RSA_size(rsa)). RSA_public_decrypt() returns the size of the
55recovered message digest.
56
57On error, -1 is returned; the error codes can be
58obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
59
60=head1 SEE ALSO
61
62L<err(3)|err(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)>
63
64=head1 HISTORY
65
66The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is
67available since SSLeay 0.9.0.
68
69=cut
diff --git a/src/lib/libcrypto/doc/RSA_public_encrypt.pod b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
new file mode 100644
index 0000000000..910c4752b8
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
@@ -0,0 +1,86 @@
1=pod
2
3=head1 NAME
4
5RSA_public_encrypt, RSA_private_decrypt - RSA public key cryptography
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_public_encrypt(int flen, unsigned char *from,
12 unsigned char *to, RSA *rsa, int padding);
13
14 int RSA_private_decrypt(int flen, unsigned char *from,
15 unsigned char *to, RSA *rsa, int padding);
16
17=head1 DESCRIPTION
18
19RSA_public_encrypt() encrypts the B<flen> bytes at B<from> (usually a
20session key) using the public key B<rsa> and stores the ciphertext in
21B<to>. B<to> must point to RSA_size(B<rsa>) bytes of memory.
22
23B<padding> denotes one of the following modes:
24
25=over 4
26
27=item RSA_PKCS1_PADDING
28
29PKCS #1 v1.5 padding. This currently is the most widely used mode.
30
31=item RSA_PKCS1_OAEP_PADDING
32
33EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty
34encoding parameter. This mode is recommended for all new applications.
35
36=item RSA_SSLV23_PADDING
37
38PKCS #1 v1.5 padding with an SSL-specific modification that denotes
39that the server is SSL3 capable.
40
41=item RSA_NO_PADDING
42
43Raw RSA encryption. This mode should I<only> be used to implement
44cryptographically sound padding modes in the application code.
45Encrypting user data directly with RSA is insecure.
46
47=back
48
49B<flen> must be less than RSA_size(B<rsa>) - 11 for the PKCS #1 v1.5
50based padding modes, and less than RSA_size(B<rsa>) - 21 for
51RSA_PKCS1_OAEP_PADDING. The random number generator must be seeded
52prior to calling RSA_public_encrypt().
53
54RSA_private_decrypt() decrypts the B<flen> bytes at B<from> using the
55private key B<rsa> and stores the plaintext in B<to>. B<to> must point
56to a memory section large enough to hold the decrypted data (which is
57smaller than RSA_size(B<rsa>)). B<padding> is the padding mode that
58was used to encrypt the data.
59
60=head1 RETURN VALUES
61
62RSA_public_encrypt() returns the size of the encrypted data (i.e.,
63RSA_size(B<rsa>)). RSA_private_decrypt() returns the size of the
64recovered plaintext.
65
66On error, -1 is returned; the error codes can be
67obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
68
69=head1 CONFORMING TO
70
71SSL, PKCS #1 v2.0
72
73=head1 SEE ALSO
74
75L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)>
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
82
83The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is
84available since SSLeay 0.9.0, OAEP was added in OpenSSL 0.9.2b.
85
86=cut
diff --git a/src/lib/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod
new file mode 100644
index 0000000000..deb1183a23
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_set_method.pod
@@ -0,0 +1,153 @@
1=pod
2
3=head1 NAME
4
5RSA_set_default_method, RSA_get_default_method, RSA_set_method,
6RSA_get_method, RSA_PKCS1_SSLeay, RSA_PKCS1_RSAref,
7RSA_PKCS1_null_method, RSA_flags, RSA_new_method - select RSA method
8
9=head1 SYNOPSIS
10
11 #include <openssl/rsa.h>
12
13 void RSA_set_default_method(RSA_METHOD *meth);
14
15 RSA_METHOD *RSA_get_default_method(void);
16
17 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
18
19 RSA_METHOD *RSA_get_method(RSA *rsa);
20
21 RSA_METHOD *RSA_PKCS1_SSLeay(void);
22
23 RSA_METHOD *RSA_PKCS1_RSAref(void);
24
25 RSA_METHOD *RSA_null_method(void);
26
27 int RSA_flags(RSA *rsa);
28
29 RSA *RSA_new_method(RSA_METHOD *method);
30
31=head1 DESCRIPTION
32
33An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
34operations. By modifying the method, alternative implementations
35such as hardware accelerators may be used.
36
37Initially, the default is to use the OpenSSL internal implementation,
38unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL>
39options. RSA_PKCS1_SSLeay() returns a pointer to that method.
40
41RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref
42library. This is the default method in the C<rsaref> configuration;
43the function is not available in other configurations.
44RSA_null_method() returns a pointer to a method that does not support
45the RSA transformation. It is the default if OpenSSL is compiled with
46C<-DRSA_NULL>. These methods may be useful in the USA because of a
47patent on the RSA cryptosystem.
48
49RSA_set_default_method() makes B<meth> the default method for all B<RSA>
50structures created later.
51
52RSA_get_default_method() returns a pointer to the current default
53method.
54
55RSA_set_method() selects B<meth> for all operations using the key
56B<rsa>.
57
58RSA_get_method() returns a pointer to the method currently selected
59for B<rsa>.
60
61RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
62
63RSA_new_method() allocates and initializes an B<RSA> structure so that
64B<method> will be used for the RSA operations. If B<method> is B<NULL>,
65the default method is used.
66
67=head1 THE RSA_METHOD STRUCTURE
68
69 typedef struct rsa_meth_st
70 {
71 /* name of the implementation */
72 const char *name;
73
74 /* encrypt */
75 int (*rsa_pub_enc)(int flen, unsigned char *from,
76 unsigned char *to, RSA *rsa, int padding);
77
78 /* verify arbitrary data */
79 int (*rsa_pub_dec)(int flen, unsigned char *from,
80 unsigned char *to, RSA *rsa, int padding);
81
82 /* sign arbitrary data */
83 int (*rsa_priv_enc)(int flen, unsigned char *from,
84 unsigned char *to, RSA *rsa, int padding);
85
86 /* decrypt */
87 int (*rsa_priv_dec)(int flen, unsigned char *from,
88 unsigned char *to, RSA *rsa, int padding);
89
90 /* compute r0 = r0 ^ I mod rsa->n. May be NULL */
91 int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
92
93 /* compute r = a ^ p mod m. May be NULL */
94 int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
95 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
96
97 /* called at RSA_new */
98 int (*init)(RSA *rsa);
99
100 /* called at RSA_free */
101 int (*finish)(RSA *rsa);
102
103 /* RSA_FLAG_EXT_PKEY - rsa_mod_exp is called for private key
104 * operations, even if p,q,dmp1,dmq1,iqmp
105 * are NULL
106 * RSA_FLAG_SIGN_VER - enable rsa_sign and rsa_verify
107 * RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match
108 */
109 int flags;
110
111 char *app_data; /* ?? */
112
113 /* sign. For backward compatibility, this is used only
114 * if (flags & RSA_FLAG_SIGN_VER)
115 */
116 int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len,
117 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
118
119 /* verify. For backward compatibility, this is used only
120 * if (flags & RSA_FLAG_SIGN_VER)
121 */
122 int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len,
123 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
124
125 } RSA_METHOD;
126
127=head1 RETURN VALUES
128
129RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(),
130RSA_get_default_method() and RSA_get_method() return pointers to the
131respective B<RSA_METHOD>s.
132
133RSA_set_default_method() returns no value.
134
135RSA_set_method() returns a pointer to the B<RSA_METHOD> previously
136associated with B<rsa>.
137
138RSA_new_method() returns B<NULL> and sets an error code that can be
139obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
140returns a pointer to the newly allocated structure.
141
142=head1 SEE ALSO
143
144L<rsa(3)|rsa(3)>, L<RSA_new(3)|RSA_new(3)>
145
146=head1 HISTORY
147
148RSA_new_method() and RSA_set_default_method() appeared in SSLeay 0.8.
149RSA_get_default_method(), RSA_set_method() and RSA_get_method() as
150well as the rsa_sign and rsa_verify components of RSA_METHOD were
151added in OpenSSL 0.9.4.
152
153=cut
diff --git a/src/lib/libcrypto/doc/RSA_sign.pod b/src/lib/libcrypto/doc/RSA_sign.pod
new file mode 100644
index 0000000000..f0bf6eea1b
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_sign.pod
@@ -0,0 +1,62 @@
1=pod
2
3=head1 NAME
4
5RSA_sign, RSA_verify - RSA signatures
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_sign(int type, unsigned char *m, unsigned int m_len,
12 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
13
14 int RSA_verify(int type, unsigned char *m, unsigned int m_len,
15 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
16
17=head1 DESCRIPTION
18
19RSA_sign() signs the message digest B<m> of size B<m_len> using the
20private key B<rsa> as specified in PKCS #1 v2.0. It stores the
21signature in B<sigret> and the signature size in B<siglen>. B<sigret>
22must point to RSA_size(B<rsa>) bytes of memory.
23
24B<type> denotes the message digest algorithm that was used to generate
25B<m>. It usually is one of B<NID_sha1>, B<NID_ripemd160> and B<NID_md5>;
26see L<objects(3)|objects(3)> for details. If B<type> is B<NID_md5_sha1>,
27an SSL signature (MD5 and SHA1 message digests with PKCS #1 padding
28and no algorithm identifier) is created.
29
30RSA_verify() verifies that the signature B<sigbuf> of size B<siglen>
31matches a given message digest B<m> of size B<m_len>. B<type> denotes
32the message digest algorithm that was used to generate the signature.
33B<rsa> is the signer's public key.
34
35=head1 RETURN VALUES
36
37RSA_sign() returns 1 on success, 0 otherwise. RSA_verify() returns 1
38on successful verification, 0 otherwise.
39
40The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
41
42=head1 BUGS
43
44Certain signatures with an improper algorithm identifier are accepted
45for compatibility with SSLeay 0.4.5 :-)
46
47=head1 CONFORMING TO
48
49SSL, PKCS #1 v2.0
50
51=head1 SEE ALSO
52
53L<err(3)|err(3)>, L<objects(3)|objects(3)>, L<rsa(3)|rsa(3)>,
54L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>,
55L<RSA_public_decrypt(3)|RSA_public_decrypt(3)>
56
57=head1 HISTORY
58
59RSA_sign() and RSA_verify() are available in all versions of SSLeay
60and OpenSSL.
61
62=cut
diff --git a/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod b/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
new file mode 100644
index 0000000000..df9ceb339a
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
@@ -0,0 +1,59 @@
1=pod
2
3=head1 NAME
4
5RSA_sign_ASN1_OCTET_STRING, RSA_verify_ASN1_OCTET_STRING - RSA signatures
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m,
12 unsigned int m_len, unsigned char *sigret, unsigned int *siglen,
13 RSA *rsa);
14
15 int RSA_verify_ASN1_OCTET_STRING(int dummy, unsigned char *m,
16 unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
17 RSA *rsa);
18
19=head1 DESCRIPTION
20
21RSA_sign_ASN1_OCTET_STRING() signs the octet string B<m> of size
22B<m_len> using the private key B<rsa> represented in DER using PKCS #1
23padding. It stores the signature in B<sigret> and the signature size
24in B<siglen>. B<sigret> must point to B<RSA_size(rsa)> bytes of
25memory.
26
27B<dummy> is ignored.
28
29The random number generator must be seeded prior to calling RSA_sign_ASN1_OCTET_STRING().
30
31RSA_verify_ASN1_OCTET_STRING() verifies that the signature B<sigbuf>
32of size B<siglen> is the DER representation of a given octet string
33B<m> of size B<m_len>. B<dummy> is ignored. B<rsa> is the signer's
34public key.
35
36=head1 RETURN VALUES
37
38RSA_sign_ASN1_OCTET_STRING() returns 1 on success, 0 otherwise.
39RSA_verify_ASN1_OCTET_STRING() returns 1 on successful verification, 0
40otherwise.
41
42The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
43
44=head1 BUGS
45
46These functions serve no recognizable purpose.
47
48=head1 SEE ALSO
49
50L<err(3)|err(3)>, L<objects(3)|objects(3)>, L<rand(3)|rand(3)>,
51L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>,
52L<RSA_verify(3)|RSA_verify(3)>
53
54=head1 HISTORY
55
56RSA_sign_ASN1_OCTET_STRING() and RSA_verify_ASN1_OCTET_STRING() were
57added in SSLeay 0.8.
58
59=cut
diff --git a/src/lib/libcrypto/doc/RSA_size.pod b/src/lib/libcrypto/doc/RSA_size.pod
new file mode 100644
index 0000000000..b36b4d58d5
--- /dev/null
+++ b/src/lib/libcrypto/doc/RSA_size.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5RSA_size - get RSA modulus size
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_size(RSA *rsa);
12
13=head1 DESCRIPTION
14
15This function returns the RSA modulus size in bytes. It can be used to
16determine how much memory must be allocated for an RSA encrypted
17value.
18
19B<rsa-E<gt>n> must not be B<NULL>.
20
21=head1 RETURN VALUE
22
23The size in bytes.
24
25=head1 SEE ALSO
26
27L<rsa(3)|rsa(3)>
28
29=head1 HISTORY
30
31RSA_size() is available in all versions of SSLeay and OpenSSL.
32
33=cut
diff --git a/src/lib/libcrypto/doc/bn.pod b/src/lib/libcrypto/doc/bn.pod
new file mode 100644
index 0000000000..1504a1c92d
--- /dev/null
+++ b/src/lib/libcrypto/doc/bn.pod
@@ -0,0 +1,148 @@
1=pod
2
3=head1 NAME
4
5bn - multiprecision integer arithmetics
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_new(void);
12 void BN_free(BIGNUM *a);
13 void BN_init(BIGNUM *);
14 void BN_clear(BIGNUM *a);
15 void BN_clear_free(BIGNUM *a);
16
17 BN_CTX *BN_CTX_new(void);
18 void BN_CTX_init(BN_CTX *c);
19 void BN_CTX_free(BN_CTX *c);
20
21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
22 BIGNUM *BN_dup(const BIGNUM *a);
23
24 int BN_num_bytes(const BIGNUM *a);
25 int BN_num_bits(const BIGNUM *a);
26 int BN_num_bits_word(BN_ULONG w);
27
28 int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b);
29 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
30 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
31 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
32 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);
35 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
36 BN_CTX *ctx);
37 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
38 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
39 const BIGNUM *m, BN_CTX *ctx);
40 int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
41
42 int BN_add_word(BIGNUM *a, BN_ULONG w);
43 int BN_sub_word(BIGNUM *a, BN_ULONG w);
44 int BN_mul_word(BIGNUM *a, BN_ULONG w);
45 BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
46 BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
47
48 int BN_cmp(BIGNUM *a, BIGNUM *b);
49 int BN_ucmp(BIGNUM *a, BIGNUM *b);
50 int BN_is_zero(BIGNUM *a);
51 int BN_is_one(BIGNUM *a);
52 int BN_is_word(BIGNUM *a, BN_ULONG w);
53 int BN_is_odd(BIGNUM *a);
54
55 int BN_zero(BIGNUM *a);
56 int BN_one(BIGNUM *a);
57 BIGNUM *BN_value_one(void);
58 int BN_set_word(BIGNUM *a, unsigned long w);
59 unsigned long BN_get_word(BIGNUM *a);
60
61 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
62 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
63
64 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add,
65 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
66 int BN_is_prime(const BIGNUM *p, int nchecks,
67 void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg);
68
69 int BN_set_bit(BIGNUM *a, int n);
70 int BN_clear_bit(BIGNUM *a, int n);
71 int BN_is_bit_set(const BIGNUM *a, int n);
72 int BN_mask_bits(BIGNUM *a, int n);
73 int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
74 int BN_lshift1(BIGNUM *r, BIGNUM *a);
75 int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
76 int BN_rshift1(BIGNUM *r, BIGNUM *a);
77
78 int BN_bn2bin(const BIGNUM *a, unsigned char *to);
79 BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
80 char *BN_bn2hex(const BIGNUM *a);
81 char *BN_bn2dec(const BIGNUM *a);
82 int BN_hex2bn(BIGNUM **a, const char *str);
83 int BN_dec2bn(BIGNUM **a, const char *str);
84 int BN_print(BIO *fp, const BIGNUM *a);
85 int BN_print_fp(FILE *fp, const BIGNUM *a);
86 int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
87 BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret);
88
89 BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n,
90 BN_CTX *ctx);
91
92 BN_RECP_CTX *BN_RECP_CTX_new(void);
93 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
94 void BN_RECP_CTX_free(BN_RECP_CTX *recp);
95 int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
96 int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
97 BN_RECP_CTX *recp, BN_CTX *ctx);
98
99 BN_MONT_CTX *BN_MONT_CTX_new(void);
100 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
101 void BN_MONT_CTX_free(BN_MONT_CTX *mont);
102 int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
103 BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
104 int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
105 BN_MONT_CTX *mont, BN_CTX *ctx);
106 int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
107 BN_CTX *ctx);
108 int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
109 BN_CTX *ctx);
110
111
112=head1 DESCRIPTION
113
114This library performs arithmetic operations on integers of arbitrary
115size. It was written for use in public key cryptography, such as RSA
116and Diffie-Hellman.
117
118It uses dynamic memory allocation for storing its data structures.
119That means that there is no limit on the size of the numbers
120manipulated by these functions, but return values must always be
121checked in case a memory allocation error has occurred.
122
123The basic object in this library is a B<BIGNUM>. It is used to hold a
124single large integer. This type should be considered opaque and fields
125should not be modified or accessed directly.
126
127The creation of B<BIGNUM> objects is described in L<BN_new(3)|BN_new(3)>;
128L<BN_add(3)|BN_add(3)> describes most of the arithmetic operations.
129Comparison is described in L<BN_cmp(3)|BN_cmp(3)>; L<BN_zero(3)|BN_zero(3)>
130describes certain assignments, L<BN_rand(3)|BN_rand(3)> the generation of
131random numbers, L<BN_generate_prime(3)|BN_generate_prime(3)> deals with prime
132numbers and L<BN_set_bit(3)|BN_set_bit(3)> with bit operations. The conversion
133of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>.
134
135=head1 SEE ALSO
136
137L<bn_internal(3)|bn_internal(3)>,
138L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
139L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>,
140L<BN_copy(3)|BN_copy(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>,
141L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>,
142L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>,
143L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>,
144L<BN_bn2bin(3)|BN_bn2bin(3)>, L<BN_mod_inverse(3)|BN_mod_inverse(3)>,
145L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>,
146L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)>
147
148=cut
diff --git a/src/lib/libcrypto/doc/d2i_DHparams.pod b/src/lib/libcrypto/doc/d2i_DHparams.pod
new file mode 100644
index 0000000000..a6d1743d39
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_DHparams.pod
@@ -0,0 +1,30 @@
1=pod
2
3=head1 NAME
4
5d2i_DHparams, i2d_DHparams - ...
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH *d2i_DHparams(DH **a, unsigned char **pp, long length);
12 int i2d_DHparams(DH *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16...
17
18=head1 RETURN VALUES
19
20...
21
22=head1 SEE ALSO
23
24...
25
26=head1 HISTORY
27
28...
29
30=cut
diff --git a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
new file mode 100644
index 0000000000..ff4d0d57db
--- /dev/null
+++ b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
@@ -0,0 +1,39 @@
1=pod
2
3=head1 NAME
4
5d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, i2d_Netscape_RSA, d2i_Netscape_RSA - ...
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length);
12
13 int i2d_RSAPublicKey(RSA *a, unsigned char **pp);
14
15 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
16
17 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp);
18
19 int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)());
20
21 RSA * d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)());
22
23=head1 DESCRIPTION
24
25...
26
27=head1 RETURN VALUES
28
29...
30
31=head1 SEE ALSO
32
33...
34
35=head1 HISTORY
36
37...
38
39=cut
diff --git a/src/lib/libcrypto/doc/dh.pod b/src/lib/libcrypto/doc/dh.pod
new file mode 100644
index 0000000000..0a9b7c03a2
--- /dev/null
+++ b/src/lib/libcrypto/doc/dh.pod
@@ -0,0 +1,68 @@
1=pod
2
3=head1 NAME
4
5dh - Diffie-Hellman key agreement
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH * DH_new(void);
12 void DH_free(DH *dh);
13
14 int DH_size(DH *dh);
15
16 DH * DH_generate_parameters(int prime_len, int generator,
17 void (*callback)(int, int, void *), void *cb_arg);
18 int DH_check(DH *dh, int *codes);
19
20 int DH_generate_key(DH *dh);
21 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
22
23 void DH_set_default_method(DH_METHOD *meth);
24 DH_METHOD *DH_get_default_method(void);
25 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
26 DH *DH_new_method(DH_METHOD *meth);
27 DH_METHOD *DH_OpenSSL(void);
28
29 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(),
30 int (*dup_func)(), void (*free_func)());
31 int DH_set_ex_data(DH *d, int idx, char *arg);
32 char *DH_get_ex_data(DH *d, int idx);
33
34 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
35 int i2d_DHparams(DH *a, unsigned char **pp);
36
37 int DHparams_print_fp(FILE *fp, DH *x);
38 int DHparams_print(BIO *bp, DH *x);
39
40=head1 DESCRIPTION
41
42These functions implement the Diffie-Hellman key agreement protocol.
43The generation of shared DH parameters is described in
44L<DH_generate_parameters(3)|DH_generate_parameters(3)>; L<DH_generate_key(3)|DH_generate_key(3)> describes how
45to perform a key agreement.
46
47The B<DH> structure consists of several BIGNUM components.
48
49 struct
50 {
51 BIGNUM *p; // prime number (shared)
52 BIGNUM *g; // generator of Z_p (shared)
53 BIGNUM *priv_key; // private DH value x
54 BIGNUM *pub_key; // public DH value g^x
55 // ...
56 };
57 DH
58
59=head1 SEE ALSO
60
61L<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
62L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<DH_set_method(3)|DH_set_method(3)>,
63L<DH_new(3)|DH_new(3)>, L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>,
64L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
65L<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>,
66L<RSA_print(3)|RSA_print(3)>
67
68=cut
diff --git a/src/lib/libcrypto/doc/dsa.pod b/src/lib/libcrypto/doc/dsa.pod
new file mode 100644
index 0000000000..2c09244899
--- /dev/null
+++ b/src/lib/libcrypto/doc/dsa.pod
@@ -0,0 +1,104 @@
1=pod
2
3=head1 NAME
4
5dsa - Digital Signature Algorithm
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA * DSA_new(void);
12 void DSA_free(DSA *dsa);
13
14 int DSA_size(DSA *dsa);
15
16 DSA * DSA_generate_parameters(int bits, unsigned char *seed,
17 int seed_len, int *counter_ret, unsigned long *h_ret,
18 void (*callback)(int, int, void *), void *cb_arg);
19
20 DH * DSA_dup_DH(DSA *r);
21
22 int DSA_generate_key(DSA *dsa);
23
24 int DSA_sign(int dummy, const unsigned char *dgst, int len,
25 unsigned char *sigret, unsigned int *siglen, DSA *dsa);
26 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
27 BIGNUM **rp);
28 int DSA_verify(int dummy, const unsigned char *dgst, int len,
29 unsigned char *sigbuf, int siglen, DSA *dsa);
30
31 void DSA_set_default_method(DSA_METHOD *meth);
32 DSA_METHOD *DSA_get_default_method(void);
33 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth);
34 DSA *DSA_new_method(DSA_METHOD *meth);
35 DSA_METHOD *DSA_OpenSSL(void);
36
37 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
38 int (*dup_func)(), void (*free_func)());
39 int DSA_set_ex_data(DSA *d, int idx, char *arg);
40 char *DSA_get_ex_data(DSA *d, int idx);
41
42 DSA_SIG *DSA_SIG_new(void);
43 void DSA_SIG_free(DSA_SIG *a);
44 int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp);
45 DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length);
46
47 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
48 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
49 DSA_SIG *sig, DSA *dsa);
50
51 DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
52 DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
53 DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
54 int i2d_DSAPublicKey(DSA *a, unsigned char **pp);
55 int i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
56 int i2d_DSAparams(DSA *a,unsigned char **pp);
57
58 int DSAparams_print(BIO *bp, DSA *x);
59 int DSAparams_print_fp(FILE *fp, DSA *x);
60 int DSA_print(BIO *bp, DSA *x, int off);
61 int DSA_print_fp(FILE *bp, DSA *x, int off);
62
63=head1 DESCRIPTION
64
65These functions implement the Digital Signature Algorithm (DSA). The
66generation of shared DSA parameters is described in
67L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>;
68L<DSA_generate_key(3)|DSA_generate_key(3)> describes how to
69generate a signature key. Signature generation and verification are
70described in L<DSA_sign(3)|DSA_sign(3)>.
71
72The B<DSA> structure consists of several BIGNUM components.
73
74 struct
75 {
76 BIGNUM *p; // prime number (public)
77 BIGNUM *q; // 160-bit subprime, q | p-1 (public)
78 BIGNUM *g; // generator of subgroup (public)
79 BIGNUM *priv_key; // private key x
80 BIGNUM *pub_key; // public key y = g^x
81 // ...
82 }
83 DSA;
84
85In public keys, B<priv_key> is NULL.
86
87=head1 CONFORMING TO
88
89US Federal Information Processing Standard FIPS 186 (Digital Signature
90Standard, DSS), ANSI X9.30
91
92=head1 SEE ALSO
93
94L<bn(3)|bn(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
95L<rsa(3)|rsa(3)>, L<sha(3)|sha(3)>, L<DSA_new(3)|DSA_new(3)>,
96L<DSA_size(3)|DSA_size(3)>,
97L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
98L<DSA_dup_DH(3)|DSA_dup_DH(3)>,
99L<DSA_generate_key(3)|DSA_generate_key(3)>,
100L<DSA_sign(3)|DSA_sign(3)>, L<DSA_set_method(3)|DSA_set_method(3)>,
101L<DSA_get_ex_new_index(3)|DSA_get_ex_new_index(3)>,
102L<RSA_print(3)|RSA_print(3)>
103
104=cut
diff --git a/src/lib/libcrypto/doc/lh_stats.pod b/src/lib/libcrypto/doc/lh_stats.pod
new file mode 100644
index 0000000000..3eeaa72e52
--- /dev/null
+++ b/src/lib/libcrypto/doc/lh_stats.pod
@@ -0,0 +1,60 @@
1=pod
2
3=head1 NAME
4
5lh_stats, lh_node_stats, lh_node_usage_stats, lh_stats_bio,
6lh_node_stats_bio, lh_node_usage_stats_bio - LHASH statistics
7
8=head1 SYNOPSIS
9
10 #include <openssl/lhash.h>
11
12 void lh_stats(LHASH *table, FILE *out);
13 void lh_node_stats(LHASH *table, FILE *out);
14 void lh_node_usage_stats(LHASH *table, FILE *out);
15
16 void lh_stats_bio(LHASH *table, BIO *out);
17 void lh_node_stats_bio(LHASH *table, BIO *out);
18 void lh_node_usage_stats_bio(LHASH *table, BIO *out);
19
20=head1 DESCRIPTION
21
22The B<LHASH> structure records statistics about most aspects of
23accessing the hash table. This is mostly a legacy of Eric Young
24writing this library for the reasons of implementing what looked like
25a nice algorithm rather than for a particular software product.
26
27lh_stats() prints out statistics on the size of the hash table, how
28many entries are in it, and the number and result of calls to the
29routines in this library.
30
31lh_node_stats() prints the number of entries for each 'bucket' in the
32hash table.
33
34lh_node_usage_stats() prints out a short summary of the state of the
35hash table. It prints the 'load' and the 'actual load'. The load is
36the average number of data items per 'bucket' in the hash table. The
37'actual load' is the average number of items per 'bucket', but only
38for buckets which contain entries. So the 'actual load' is the
39average number of searches that will need to find an item in the hash
40table, while the 'load' is the average number that will be done to
41record a miss.
42
43lh_stats_bio(), lh_node_stats_bio() and lh_node_usage_stats_bio()
44are the same as the above, except that the output goes to a B<BIO>.
45
46=head1 RETURN VALUES
47
48These functions do not return values.
49
50=head1 SEE ALSO
51
52L<bio(3)|bio(3)>, L<lhash(3)|lhash(3)>
53
54=head1 HISTORY
55
56These functions are available in all versions of SSLeay and OpenSSL.
57
58This manpage is derived from the SSLeay documentation.
59
60=cut
diff --git a/src/lib/libcrypto/doc/rsa.pod b/src/lib/libcrypto/doc/rsa.pod
new file mode 100644
index 0000000000..0486c044a6
--- /dev/null
+++ b/src/lib/libcrypto/doc/rsa.pod
@@ -0,0 +1,115 @@
1=pod
2
3=head1 NAME
4
5rsa - RSA public key cryptosystem
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA * RSA_new(void);
12 void RSA_free(RSA *rsa);
13
14 int RSA_public_encrypt(int flen, unsigned char *from,
15 unsigned char *to, RSA *rsa, int padding);
16 int RSA_private_decrypt(int flen, unsigned char *from,
17 unsigned char *to, RSA *rsa, int padding);
18
19 int RSA_sign(int type, unsigned char *m, unsigned int m_len,
20 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
21 int RSA_verify(int type, unsigned char *m, unsigned int m_len,
22 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
23
24 int RSA_size(RSA *rsa);
25
26 RSA *RSA_generate_key(int num, unsigned long e,
27 void (*callback)(int,int,void *), void *cb_arg);
28
29 int RSA_check_key(RSA *rsa);
30
31 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
32 void RSA_blinding_off(RSA *rsa);
33
34 void RSA_set_default_method(RSA_METHOD *meth);
35 RSA_METHOD *RSA_get_default_method(void);
36 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
37 RSA_METHOD *RSA_get_method(RSA *rsa);
38 RSA_METHOD *RSA_PKCS1_SSLeay(void);
39 RSA_METHOD *RSA_PKCS1_RSAref(void);
40 RSA_METHOD *RSA_null_method(void);
41 int RSA_flags(RSA *rsa);
42 RSA *RSA_new_method(RSA_METHOD *method);
43
44 int RSA_print(BIO *bp, RSA *x, int offset);
45 int RSA_print_fp(FILE *fp, RSA *x, int offset);
46
47 int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
48 int (*dup_func)(), void (*free_func)());
49 int RSA_set_ex_data(RSA *r,int idx,char *arg);
50 char *RSA_get_ex_data(RSA *r, int idx);
51
52 int RSA_private_encrypt(int flen, unsigned char *from,
53 unsigned char *to, RSA *rsa,int padding);
54 int RSA_public_decrypt(int flen, unsigned char *from,
55 unsigned char *to, RSA *rsa,int padding);
56
57 int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m,
58 unsigned int m_len, unsigned char *sigret, unsigned int *siglen,
59 RSA *rsa);
60 int RSA_verify_ASN1_OCTET_STRING(int dummy, unsigned char *m,
61 unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
62 RSA *rsa);
63
64=head1 DESCRIPTION
65
66These functions implement RSA public key encryption and signatures
67as defined in PKCS #1 v2.0 [RFC 2437].
68
69The B<RSA> structure consists of several BIGNUM components. It can
70contain public as well as private RSA keys:
71
72 struct
73 {
74 BIGNUM *n; // public modulus
75 BIGNUM *e; // public exponent
76 BIGNUM *d; // private exponent
77 BIGNUM *p; // secret prime factor
78 BIGNUM *q; // secret prime factor
79 BIGNUM *dmp1; // d mod (p-1)
80 BIGNUM *dmq1; // d mod (q-1)
81 BIGNUM *iqmp; // q^-1 mod p
82 // ...
83 };
84 RSA
85
86In public keys, the private exponent and the related secret values are
87B<NULL>.
88
89B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private keys, but the
90RSA operations are much faster when these values are available.
91
92=head1 CONFORMING TO
93
94SSL, PKCS #1 v2.0
95
96=head1 PATENTS
97
98RSA is covered by a US patent which expires in September 2000.
99
100=head1 SEE ALSO
101
102L<rsa(1)|rsa(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>,
103L<rand(3)|rand(3)>, L<RSA_new(3)|RSA_new(3)>,
104L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>,
105L<RSA_sign(3)|RSA_sign(3)>, L<RSA_size(3)|RSA_size(3)>,
106L<RSA_generate_key(3)|RSA_generate_key(3)>,
107L<RSA_check_key(3)|RSA_check_key(3)>,
108L<RSA_blinding_on(3)|RSA_blinding_on(3)>,
109L<RSA_set_method(3)|RSA_set_method(3)>, L<RSA_print(3)|RSA_print(3)>,
110L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>,
111L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>,
112L<RSA_sign_ASN_OCTET_STRING(3)|RSA_sign_ASN_OCTET_STRING(3)>,
113L<RSA_padding_add_PKCS1_type_1(3)|RSA_padding_add_PKCS1_type_1(3)>
114
115=cut
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
index 4bc74a2f7c..b0bcf974fb 100644
--- a/src/lib/libcrypto/dsa/Makefile.ssl
+++ b/src/lib/libcrypto/dsa/Makefile.ssl
@@ -22,8 +22,10 @@ TEST=dsatest.c
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c dsa_err.c 25LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \
26LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o dsa_err.o 26 dsa_err.c dsa_ossl.c
27LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \
28 dsa_err.o dsa_ossl.o
27 29
28SRC= $(LIBSRC) 30SRC= $(LIBSRC)
29 31
@@ -86,25 +88,27 @@ dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
86dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 88dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
87dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 89dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
88dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h 90dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h
89dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/dh.h 91dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
90dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h 92dsa_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
91dsa_err.o: ../../include/openssl/opensslconf.h 93dsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
94dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
95dsa_err.o: ../../include/openssl/stack.h
92dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 96dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
93dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 97dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 98dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
95dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 99dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
96dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 100dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
97dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 101dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
98dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 102dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
99dsa_gen.o: ../cryptlib.h 103dsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h
100dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 104dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
101dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 105dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
102dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 106dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
103dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 107dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
104dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 108dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
105dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 109dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
106dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 110dsa_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
107dsa_key.o: ../cryptlib.h 111dsa_key.o: ../../include/openssl/stack.h ../cryptlib.h
108dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 112dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
109dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 113dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
110dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 114dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
@@ -113,6 +117,15 @@ dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
113dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 117dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 118dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
115dsa_lib.o: ../cryptlib.h 119dsa_lib.o: ../cryptlib.h
120dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
121dsa_ossl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
122dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
123dsa_ossl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
124dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
125dsa_ossl.o: ../../include/openssl/opensslconf.h
126dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
127dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
128dsa_ossl.o: ../cryptlib.h
116dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 129dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
117dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 130dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
118dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 131dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index 20b3f8d90a..68d9912cbc 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -74,13 +74,41 @@ extern "C" {
74#endif 74#endif
75 75
76#include <openssl/bn.h> 76#include <openssl/bn.h>
77#include <openssl/crypto.h>
77#ifndef NO_DH 78#ifndef NO_DH
78# include <openssl/dh.h> 79# include <openssl/dh.h>
79#endif 80#endif
80 81
81#define DSA_FLAG_CACHE_MONT_P 0x01 82#define DSA_FLAG_CACHE_MONT_P 0x01
82 83
83typedef struct dsa_st 84typedef struct dsa_st DSA;
85
86typedef struct DSA_SIG_st
87 {
88 BIGNUM *r;
89 BIGNUM *s;
90 } DSA_SIG;
91
92typedef struct dsa_method {
93 const char *name;
94 DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
95 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
96 BIGNUM **rp);
97 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
98 DSA_SIG *sig, DSA *dsa);
99 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
100 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
101 BN_MONT_CTX *in_mont);
102 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
103 const BIGNUM *m, BN_CTX *ctx,
104 BN_MONT_CTX *m_ctx); /* Can be null */
105 int (*init)(DSA *dsa);
106 int (*finish)(DSA *dsa);
107 int flags;
108 char *app_data;
109} DSA_METHOD;
110
111struct dsa_st
84 { 112 {
85 /* This first variable is used to pick up errors where 113 /* This first variable is used to pick up errors where
86 * a DSA is passed instead of of a EVP_PKEY */ 114 * a DSA is passed instead of of a EVP_PKEY */
@@ -100,15 +128,10 @@ typedef struct dsa_st
100 int flags; 128 int flags;
101 /* Normally used to cache montgomery values */ 129 /* Normally used to cache montgomery values */
102 char *method_mont_p; 130 char *method_mont_p;
103
104 int references; 131 int references;
105 } DSA; 132 CRYPTO_EX_DATA ex_data;
106 133 DSA_METHOD *meth;
107typedef struct DSA_SIG_st 134 };
108 {
109 BIGNUM *r;
110 BIGNUM *s;
111 } DSA_SIG;
112 135
113#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ 136#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \
114 (char *(*)())d2i_DSAparams,(char *)(x)) 137 (char *(*)())d2i_DSAparams,(char *)(x))
@@ -131,7 +154,14 @@ DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
131int DSA_do_verify(const unsigned char *dgst,int dgst_len, 154int DSA_do_verify(const unsigned char *dgst,int dgst_len,
132 DSA_SIG *sig,DSA *dsa); 155 DSA_SIG *sig,DSA *dsa);
133 156
157DSA_METHOD *DSA_OpenSSL(void);
158
159void DSA_set_default_method(DSA_METHOD *);
160DSA_METHOD *DSA_get_default_method(void);
161DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *);
162
134DSA * DSA_new(void); 163DSA * DSA_new(void);
164DSA * DSA_new_method(DSA_METHOD *meth);
135int DSA_size(DSA *); 165int DSA_size(DSA *);
136 /* next 4 return -1 on error */ 166 /* next 4 return -1 on error */
137int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); 167int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
@@ -140,6 +170,10 @@ int DSA_sign(int type,const unsigned char *dgst,int dlen,
140int DSA_verify(int type,const unsigned char *dgst,int dgst_len, 170int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
141 unsigned char *sigbuf, int siglen, DSA *dsa); 171 unsigned char *sigbuf, int siglen, DSA *dsa);
142void DSA_free (DSA *r); 172void DSA_free (DSA *r);
173int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
174 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
175int DSA_set_ex_data(DSA *d, int idx, void *arg);
176void *DSA_get_ex_data(DSA *d, int idx);
143 177
144void ERR_load_DSA_strings(void ); 178void ERR_load_DSA_strings(void );
145 179
@@ -148,7 +182,7 @@ DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
148DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); 182DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
149DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len, 183DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len,
150 int *counter_ret, unsigned long *h_ret,void 184 int *counter_ret, unsigned long *h_ret,void
151 (*callback)(),char *cb_arg); 185 (*callback)(int, int, void *),void *cb_arg);
152int DSA_generate_key(DSA *a); 186int DSA_generate_key(DSA *a);
153int i2d_DSAPublicKey(DSA *a, unsigned char **pp); 187int i2d_DSAPublicKey(DSA *a, unsigned char **pp);
154int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); 188int i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
@@ -163,7 +197,11 @@ int DSAparams_print_fp(FILE *fp, DSA *x);
163int DSA_print_fp(FILE *bp, DSA *x, int off); 197int DSA_print_fp(FILE *bp, DSA *x, int off);
164#endif 198#endif
165 199
166int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg); 200#define DSS_prime_checks 50
201/* Primality test according to FIPS PUB 186[-1], Appendix 2.1:
202 * 50 rounds of Rabin-Miller */
203#define DSA_is_prime(n, callback, cb_arg) \
204 BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
167 205
168#ifndef NO_DH 206#ifndef NO_DH
169/* Convert DSA structure (key or just parameters) into DH structure 207/* Convert DSA structure (key or just parameters) into DH structure
@@ -184,7 +222,6 @@ DH *DSA_dup_DH(DSA *r);
184#define DSA_F_DSAPARAMS_PRINT_FP 101 222#define DSA_F_DSAPARAMS_PRINT_FP 101
185#define DSA_F_DSA_DO_SIGN 112 223#define DSA_F_DSA_DO_SIGN 112
186#define DSA_F_DSA_DO_VERIFY 113 224#define DSA_F_DSA_DO_VERIFY 113
187#define DSA_F_DSA_IS_PRIME 102
188#define DSA_F_DSA_NEW 103 225#define DSA_F_DSA_NEW 103
189#define DSA_F_DSA_PRINT 104 226#define DSA_F_DSA_PRINT 104
190#define DSA_F_DSA_PRINT_FP 105 227#define DSA_F_DSA_PRINT_FP 105
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index 7523b21654..c9b32b4db7 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -83,7 +83,7 @@ DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, unsigned char **pp, long length)
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL) 84 if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL)
85 goto err_bn; 85 goto err_bn;
86 ASN1_BIT_STRING_free(bs); 86 M_ASN1_BIT_STRING_free(bs);
87 M_ASN1_D2I_Finish_2(a); 87 M_ASN1_D2I_Finish_2(a);
88 88
89err_bn: 89err_bn:
@@ -91,6 +91,6 @@ err_bn:
91err: 91err:
92 DSAerr(DSA_F_D2I_DSA_SIG,i); 92 DSAerr(DSA_F_D2I_DSA_SIG,i);
93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret); 93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret);
94 if (bs != NULL) ASN1_BIT_STRING_free(bs); 94 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
95 return(NULL); 95 return(NULL);
96} 96}
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c
index 33a8270afd..38e4af968c 100644
--- a/src/lib/libcrypto/dsa/dsa_err.c
+++ b/src/lib/libcrypto/dsa/dsa_err.c
@@ -70,7 +70,6 @@ static ERR_STRING_DATA DSA_str_functs[]=
70{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"}, 70{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"},
71{ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, 71{ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"},
72{ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, 72{ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"},
73{ERR_PACK(0,DSA_F_DSA_IS_PRIME,0), "DSA_is_prime"},
74{ERR_PACK(0,DSA_F_DSA_NEW,0), "DSA_new"}, 73{ERR_PACK(0,DSA_F_DSA_NEW,0), "DSA_new"},
75{ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"}, 74{ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"},
76{ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"}, 75{ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"},
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c
index b5e5ec06e5..2294a362d9 100644
--- a/src/lib/libcrypto/dsa/dsa_gen.c
+++ b/src/lib/libcrypto/dsa/dsa_gen.c
@@ -59,12 +59,18 @@
59#undef GENUINE_DSA 59#undef GENUINE_DSA
60 60
61#ifdef GENUINE_DSA 61#ifdef GENUINE_DSA
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) */
62#define HASH SHA 64#define HASH SHA
63#else 65#else
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
68 * FIPS PUB 180-1) */
64#define HASH SHA1 69#define HASH SHA1
65#endif 70#endif
66 71
67#ifndef NO_SHA 72#ifndef NO_SHA
73
68#include <stdio.h> 74#include <stdio.h>
69#include <time.h> 75#include <time.h>
70#include "cryptlib.h" 76#include "cryptlib.h"
@@ -74,8 +80,9 @@
74#include <openssl/rand.h> 80#include <openssl/rand.h>
75 81
76DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, 82DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
77 int *counter_ret, unsigned long *h_ret, void (*callback)(), 83 int *counter_ret, unsigned long *h_ret,
78 char *cb_arg) 84 void (*callback)(int, int, void *),
85 void *cb_arg)
79 { 86 {
80 int ok=0; 87 int ok=0;
81 unsigned char seed[SHA_DIGEST_LENGTH]; 88 unsigned char seed[SHA_DIGEST_LENGTH];
@@ -86,47 +93,63 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
86 BN_MONT_CTX *mont=NULL; 93 BN_MONT_CTX *mont=NULL;
87 int k,n=0,i,b,m=0; 94 int k,n=0,i,b,m=0;
88 int counter=0; 95 int counter=0;
89 BN_CTX *ctx=NULL,*ctx2=NULL; 96 int r=0;
97 BN_CTX *ctx=NULL,*ctx2=NULL,*ctx3=NULL;
90 unsigned int h=2; 98 unsigned int h=2;
91 DSA *ret=NULL; 99 DSA *ret=NULL;
92 100
93 if (bits < 512) bits=512; 101 if (bits < 512) bits=512;
94 bits=(bits+63)/64*64; 102 bits=(bits+63)/64*64;
95 103
104 if (seed_len < 20)
105 seed_in = NULL; /* seed buffer too small -- ignore */
106 if (seed_len > 20)
107 seed_len = 20; /* App. 2.2 of FIPS PUB 186 allows larger SEED,
108 * but our internal buffers are restricted to 160 bits*/
96 if ((seed_in != NULL) && (seed_len == 20)) 109 if ((seed_in != NULL) && (seed_len == 20))
97 memcpy(seed,seed_in,seed_len); 110 memcpy(seed,seed_in,seed_len);
98 111
99 if ((ctx=BN_CTX_new()) == NULL) goto err; 112 if ((ctx=BN_CTX_new()) == NULL) goto err;
100 if ((ctx2=BN_CTX_new()) == NULL) goto err; 113 if ((ctx2=BN_CTX_new()) == NULL) goto err;
114 if ((ctx3=BN_CTX_new()) == NULL) goto err;
101 if ((ret=DSA_new()) == NULL) goto err; 115 if ((ret=DSA_new()) == NULL) goto err;
102 116
103 if ((mont=BN_MONT_CTX_new()) == NULL) goto err; 117 if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
104 118
105 r0= &(ctx2->bn[0]); 119 BN_CTX_start(ctx2);
106 g= &(ctx2->bn[1]); 120 r0 = BN_CTX_get(ctx2);
107 W= &(ctx2->bn[2]); 121 g = BN_CTX_get(ctx2);
108 q= &(ctx2->bn[3]); 122 W = BN_CTX_get(ctx2);
109 X= &(ctx2->bn[4]); 123 q = BN_CTX_get(ctx2);
110 c= &(ctx2->bn[5]); 124 X = BN_CTX_get(ctx2);
111 p= &(ctx2->bn[6]); 125 c = BN_CTX_get(ctx2);
112 test= &(ctx2->bn[7]); 126 p = BN_CTX_get(ctx2);
127 test = BN_CTX_get(ctx2);
113 128
114 BN_lshift(test,BN_value_one(),bits-1); 129 BN_lshift(test,BN_value_one(),bits-1);
115 130
116 for (;;) 131 for (;;)
117 { 132 {
118 for (;;) 133 for (;;) /* find q */
119 { 134 {
135 int seed_is_random;
136
120 /* step 1 */ 137 /* step 1 */
121 if (callback != NULL) callback(0,m++,cb_arg); 138 if (callback != NULL) callback(0,m++,cb_arg);
122 139
123 if (!seed_len) 140 if (!seed_len)
124 RAND_bytes(seed,SHA_DIGEST_LENGTH); 141 {
142 RAND_pseudo_bytes(seed,SHA_DIGEST_LENGTH);
143 seed_is_random = 1;
144 }
125 else 145 else
126 seed_len=0; 146 {
127 147 seed_is_random = 0;
148 seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/
149 }
128 memcpy(buf,seed,SHA_DIGEST_LENGTH); 150 memcpy(buf,seed,SHA_DIGEST_LENGTH);
129 memcpy(buf2,seed,SHA_DIGEST_LENGTH); 151 memcpy(buf2,seed,SHA_DIGEST_LENGTH);
152 /* precompute "SEED + 1" for step 7: */
130 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) 153 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--)
131 { 154 {
132 buf[i]++; 155 buf[i]++;
@@ -142,10 +165,15 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
142 /* step 3 */ 165 /* step 3 */
143 md[0]|=0x80; 166 md[0]|=0x80;
144 md[SHA_DIGEST_LENGTH-1]|=0x01; 167 md[SHA_DIGEST_LENGTH-1]|=0x01;
145 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) abort(); 168 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) goto err;
146 169
147 /* step 4 */ 170 /* step 4 */
148 if (DSA_is_prime(q,callback,cb_arg) > 0) break; 171 r = BN_is_prime_fasttest(q, DSS_prime_checks, callback, ctx3, cb_arg, seed_is_random);
172 if (r > 0)
173 break;
174 if (r != 0)
175 goto err;
176
149 /* do a callback call */ 177 /* do a callback call */
150 /* step 5 */ 178 /* step 5 */
151 } 179 }
@@ -155,16 +183,22 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
155 183
156 /* step 6 */ 184 /* step 6 */
157 counter=0; 185 counter=0;
186 /* "offset = 2" */
158 187
159 n=(bits-1)/160; 188 n=(bits-1)/160;
160 b=(bits-1)-n*160; 189 b=(bits-1)-n*160;
161 190
162 for (;;) 191 for (;;)
163 { 192 {
193 if (callback != NULL && counter != 0)
194 callback(0,counter,cb_arg);
195
164 /* step 7 */ 196 /* step 7 */
165 BN_zero(W); 197 BN_zero(W);
198 /* now 'buf' contains "SEED + offset - 1" */
166 for (k=0; k<=n; k++) 199 for (k=0; k<=n; k++)
167 { 200 {
201 /* obtain "SEED + offset + k" by incrementing: */
168 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) 202 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--)
169 { 203 {
170 buf[i]++; 204 buf[i]++;
@@ -174,7 +208,8 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
174 HASH(buf,SHA_DIGEST_LENGTH,md); 208 HASH(buf,SHA_DIGEST_LENGTH,md);
175 209
176 /* step 8 */ 210 /* step 8 */
177 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) abort(); 211 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0))
212 goto err;
178 BN_lshift(r0,r0,160*k); 213 BN_lshift(r0,r0,160*k);
179 BN_add(W,W,r0); 214 BN_add(W,W,r0);
180 } 215 }
@@ -194,23 +229,25 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
194 if (BN_cmp(p,test) >= 0) 229 if (BN_cmp(p,test) >= 0)
195 { 230 {
196 /* step 11 */ 231 /* step 11 */
197 if (DSA_is_prime(p,callback,cb_arg) > 0) 232 r = BN_is_prime_fasttest(p, DSS_prime_checks, callback, ctx3, cb_arg, 1);
198 goto end; 233 if (r > 0)
234 goto end; /* found it */
235 if (r != 0)
236 goto err;
199 } 237 }
200 238
201 /* step 13 */ 239 /* step 13 */
202 counter++; 240 counter++;
241 /* "offset = offset + n + 1" */
203 242
204 /* step 14 */ 243 /* step 14 */
205 if (counter >= 4096) break; 244 if (counter >= 4096) break;
206
207 if (callback != NULL) callback(0,counter,cb_arg);
208 } 245 }
209 } 246 }
210end: 247end:
211 if (callback != NULL) callback(2,1,cb_arg); 248 if (callback != NULL) callback(2,1,cb_arg);
212 249
213 /* We now need to gernerate g */ 250 /* We now need to generate g */
214 /* Set r0=(p-1)/q */ 251 /* Set r0=(p-1)/q */
215 BN_sub(test,p,BN_value_one()); 252 BN_sub(test,p,BN_value_one());
216 BN_div(r0,NULL,test,q,ctx); 253 BN_div(r0,NULL,test,q,ctx);
@@ -245,89 +282,13 @@ err:
245 if (h_ret != NULL) *h_ret=h; 282 if (h_ret != NULL) *h_ret=h;
246 } 283 }
247 if (ctx != NULL) BN_CTX_free(ctx); 284 if (ctx != NULL) BN_CTX_free(ctx);
248 if (ctx != NULL) BN_CTX_free(ctx2); 285 if (ctx2 != NULL)
249 if (mont != NULL) BN_MONT_CTX_free(mont);
250 return(ok?ret:NULL);
251 }
252
253int DSA_is_prime(BIGNUM *w, void (*callback)(), char *cb_arg)
254 {
255 int ok= -1,j,i,n;
256 BN_CTX *ctx=NULL,*ctx2=NULL;
257 BIGNUM *w_1,*b,*m,*z,*tmp,*mont_1;
258 int a;
259 BN_MONT_CTX *mont=NULL;
260
261 if (!BN_is_bit_set(w,0)) return(0);
262
263 if ((ctx=BN_CTX_new()) == NULL) goto err;
264 if ((ctx2=BN_CTX_new()) == NULL) goto err;
265 if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
266
267 m= &(ctx2->bn[2]);
268 b= &(ctx2->bn[3]);
269 z= &(ctx2->bn[4]);
270 w_1= &(ctx2->bn[5]);
271 tmp= &(ctx2->bn[6]);
272 mont_1= &(ctx2->bn[7]);
273
274 /* step 1 */
275 n=50;
276
277 /* step 2 */
278 if (!BN_sub(w_1,w,BN_value_one())) goto err;
279 for (a=1; !BN_is_bit_set(w_1,a); a++)
280 ;
281 if (!BN_rshift(m,w_1,a)) goto err;
282
283 BN_MONT_CTX_set(mont,w,ctx);
284 BN_to_montgomery(mont_1,BN_value_one(),mont,ctx);
285 BN_to_montgomery(w_1,w_1,mont,ctx);
286 for (i=1; i < n; i++)
287 { 286 {
288 /* step 3 */ 287 BN_CTX_end(ctx2);
289 BN_rand(b,BN_num_bits(w)-2/*-1*/,0,0); 288 BN_CTX_free(ctx2);
290 /* BN_set_word(b,0x10001L); */
291
292 /* step 4 */
293 j=0;
294 if (!BN_mod_exp_mont(z,b,m,w,ctx,mont)) goto err;
295
296 if (!BN_to_montgomery(z,z,mont,ctx)) goto err;
297
298 /* step 5 */
299 for (;;)
300 {
301 if (((j == 0) && (BN_cmp(z,mont_1) == 0)) ||
302 (BN_cmp(z,w_1) == 0))
303 break;
304
305 /* step 6 */
306 if ((j > 0) && (BN_cmp(z,mont_1) == 0))
307 {
308 ok=0;
309 goto err;
310 }
311
312 j++;
313 if (j >= a)
314 {
315 ok=0;
316 goto err;
317 }
318
319 if (!BN_mod_mul_montgomery(z,z,z,mont,ctx)) goto err;
320 if (callback != NULL) callback(1,j,cb_arg);
321 }
322 } 289 }
323 290 if (ctx3 != NULL) BN_CTX_free(ctx3);
324 ok=1; 291 if (mont != NULL) BN_MONT_CTX_free(mont);
325err: 292 return(ok?ret:NULL);
326 if (ok == -1) DSAerr(DSA_F_DSA_IS_PRIME,ERR_R_BN_LIB);
327 BN_CTX_free(ctx);
328 BN_CTX_free(ctx2);
329 BN_MONT_CTX_free(mont);
330
331 return(ok);
332 } 293 }
333#endif 294#endif
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index ce8e204f7e..224e412afc 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -66,7 +66,38 @@
66 66
67const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; 67const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
68 68
69static DSA_METHOD *default_DSA_method;
70static int dsa_meth_num = 0;
71static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL;
72
73void DSA_set_default_method(DSA_METHOD *meth)
74{
75 default_DSA_method = meth;
76}
77
78DSA_METHOD *DSA_get_default_method(void)
79{
80 if(!default_DSA_method) default_DSA_method = DSA_OpenSSL();
81 return default_DSA_method;
82}
83
69DSA *DSA_new(void) 84DSA *DSA_new(void)
85{
86 return DSA_new_method(NULL);
87}
88
89DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth)
90{
91 DSA_METHOD *mtmp;
92 mtmp = dsa->meth;
93 if (mtmp->finish) mtmp->finish(dsa);
94 dsa->meth = meth;
95 if (meth->init) meth->init(dsa);
96 return mtmp;
97}
98
99
100DSA *DSA_new_method(DSA_METHOD *meth)
70 { 101 {
71 DSA *ret; 102 DSA *ret;
72 103
@@ -76,13 +107,15 @@ DSA *DSA_new(void)
76 DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); 107 DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE);
77 return(NULL); 108 return(NULL);
78 } 109 }
110 if(!default_DSA_method) default_DSA_method = DSA_OpenSSL();
111 if(meth) ret->meth = meth;
112 else ret->meth = default_DSA_method;
79 ret->pad=0; 113 ret->pad=0;
80 ret->version=0; 114 ret->version=0;
81 ret->write_params=1; 115 ret->write_params=1;
82 ret->p=NULL; 116 ret->p=NULL;
83 ret->q=NULL; 117 ret->q=NULL;
84 ret->g=NULL; 118 ret->g=NULL;
85 ret->flags=DSA_FLAG_CACHE_MONT_P;
86 119
87 ret->pub_key=NULL; 120 ret->pub_key=NULL;
88 ret->priv_key=NULL; 121 ret->priv_key=NULL;
@@ -92,6 +125,15 @@ DSA *DSA_new(void)
92 ret->method_mont_p=NULL; 125 ret->method_mont_p=NULL;
93 126
94 ret->references=1; 127 ret->references=1;
128 ret->flags=ret->meth->flags;
129 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
130 {
131 Free(ret);
132 ret=NULL;
133 }
134 else
135 CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data);
136
95 return(ret); 137 return(ret);
96 } 138 }
97 139
@@ -114,6 +156,10 @@ void DSA_free(DSA *r)
114 } 156 }
115#endif 157#endif
116 158
159 CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
160
161 if(r->meth->finish) r->meth->finish(r);
162
117 if (r->p != NULL) BN_clear_free(r->p); 163 if (r->p != NULL) BN_clear_free(r->p);
118 if (r->q != NULL) BN_clear_free(r->q); 164 if (r->q != NULL) BN_clear_free(r->q);
119 if (r->g != NULL) BN_clear_free(r->g); 165 if (r->g != NULL) BN_clear_free(r->g);
@@ -121,8 +167,6 @@ void DSA_free(DSA *r)
121 if (r->priv_key != NULL) BN_clear_free(r->priv_key); 167 if (r->priv_key != NULL) BN_clear_free(r->priv_key);
122 if (r->kinv != NULL) BN_clear_free(r->kinv); 168 if (r->kinv != NULL) BN_clear_free(r->kinv);
123 if (r->r != NULL) BN_clear_free(r->r); 169 if (r->r != NULL) BN_clear_free(r->r);
124 if (r->method_mont_p != NULL)
125 BN_MONT_CTX_free((BN_MONT_CTX *)r->method_mont_p);
126 Free(r); 170 Free(r);
127 } 171 }
128 172
@@ -145,6 +189,24 @@ int DSA_size(DSA *r)
145 return(ret); 189 return(ret);
146 } 190 }
147 191
192int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
193 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
194 {
195 dsa_meth_num++;
196 return(CRYPTO_get_ex_new_index(dsa_meth_num-1,
197 &dsa_meth,argl,argp,new_func,dup_func,free_func));
198 }
199
200int DSA_set_ex_data(DSA *d, int idx, void *arg)
201 {
202 return(CRYPTO_set_ex_data(&d->ex_data,idx,arg));
203 }
204
205void *DSA_get_ex_data(DSA *d, int idx)
206 {
207 return(CRYPTO_get_ex_data(&d->ex_data,idx));
208 }
209
148#ifndef NO_DH 210#ifndef NO_DH
149DH *DSA_dup_DH(DSA *r) 211DH *DSA_dup_DH(DSA *r)
150 { 212 {
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
new file mode 100644
index 0000000000..b51cf6ad8d
--- /dev/null
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -0,0 +1,321 @@
1/* crypto/dsa/dsa_ossl.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/bn.h>
64#include <openssl/dsa.h>
65#include <openssl/rand.h>
66#include <openssl/asn1.h>
67
68static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
69static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
70static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
71 DSA *dsa);
72static int dsa_init(DSA *dsa);
73static int dsa_finish(DSA *dsa);
74static int dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
75 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
76 BN_MONT_CTX *in_mont);
77static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
78 const BIGNUM *m, BN_CTX *ctx,
79 BN_MONT_CTX *m_ctx);
80
81static DSA_METHOD openssl_dsa_meth = {
82"OpenSSL DSA method",
83dsa_do_sign,
84dsa_sign_setup,
85dsa_do_verify,
86dsa_mod_exp,
87dsa_bn_mod_exp,
88dsa_init,
89dsa_finish,
900,
91NULL
92};
93
94DSA_METHOD *DSA_OpenSSL(void)
95{
96 return &openssl_dsa_meth;
97}
98
99static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
100 {
101 BIGNUM *kinv=NULL,*r=NULL,*s=NULL;
102 BIGNUM m;
103 BIGNUM xr;
104 BN_CTX *ctx=NULL;
105 int i,reason=ERR_R_BN_LIB;
106 DSA_SIG *ret=NULL;
107
108 BN_init(&m);
109 BN_init(&xr);
110 s=BN_new();
111 if (s == NULL) goto err;
112
113 i=BN_num_bytes(dsa->q); /* should be 20 */
114 if ((dlen > i) || (dlen > 50))
115 {
116 reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;
117 goto err;
118 }
119
120 ctx=BN_CTX_new();
121 if (ctx == NULL) goto err;
122
123 if ((dsa->kinv == NULL) || (dsa->r == NULL))
124 {
125 if (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err;
126 }
127 else
128 {
129 kinv=dsa->kinv;
130 dsa->kinv=NULL;
131 r=dsa->r;
132 dsa->r=NULL;
133 }
134
135 if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err;
136
137 /* Compute s = inv(k) (m + xr) mod q */
138 if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */
139 if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */
140 if (BN_cmp(s,dsa->q) > 0)
141 BN_sub(s,s,dsa->q);
142 if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
143
144 ret=DSA_SIG_new();
145 if (ret == NULL) goto err;
146 ret->r = r;
147 ret->s = s;
148
149err:
150 if (!ret)
151 {
152 DSAerr(DSA_F_DSA_DO_SIGN,reason);
153 BN_free(r);
154 BN_free(s);
155 }
156 if (ctx != NULL) BN_CTX_free(ctx);
157 BN_clear_free(&m);
158 BN_clear_free(&xr);
159 if (kinv != NULL) /* dsa->kinv is NULL now if we used it */
160 BN_clear_free(kinv);
161 return(ret);
162 }
163
164static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
165 {
166 BN_CTX *ctx;
167 BIGNUM k,*kinv=NULL,*r=NULL;
168 int ret=0;
169
170 if (ctx_in == NULL)
171 {
172 if ((ctx=BN_CTX_new()) == NULL) goto err;
173 }
174 else
175 ctx=ctx_in;
176
177 BN_init(&k);
178 if ((r=BN_new()) == NULL) goto err;
179 kinv=NULL;
180
181 /* Get random k */
182 for (;;)
183 {
184 if (!BN_rand(&k, BN_num_bits(dsa->q), 1, 0)) goto err;
185 if (BN_cmp(&k,dsa->q) >= 0)
186 BN_sub(&k,&k,dsa->q);
187 if (!BN_is_zero(&k)) break;
188 }
189
190 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
191 {
192 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
193 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
194 dsa->p,ctx)) goto err;
195 }
196
197 /* Compute r = (g^k mod p) mod q */
198 if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx,
199 (BN_MONT_CTX *)dsa->method_mont_p)) goto err;
200 if (!BN_mod(r,r,dsa->q,ctx)) goto err;
201
202 /* Compute part of 's = inv(k) (m + xr) mod q' */
203 if ((kinv=BN_mod_inverse(NULL,&k,dsa->q,ctx)) == NULL) goto err;
204
205 if (*kinvp != NULL) BN_clear_free(*kinvp);
206 *kinvp=kinv;
207 kinv=NULL;
208 if (*rp != NULL) BN_clear_free(*rp);
209 *rp=r;
210 ret=1;
211err:
212 if (!ret)
213 {
214 DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
215 if (kinv != NULL) BN_clear_free(kinv);
216 if (r != NULL) BN_clear_free(r);
217 }
218 if (ctx_in == NULL) BN_CTX_free(ctx);
219 if (kinv != NULL) BN_clear_free(kinv);
220 BN_clear_free(&k);
221 return(ret);
222 }
223
224static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
225 DSA *dsa)
226 {
227 BN_CTX *ctx;
228 BIGNUM u1,u2,t1;
229 BN_MONT_CTX *mont=NULL;
230 int ret = -1;
231
232 if ((ctx=BN_CTX_new()) == NULL) goto err;
233 BN_init(&u1);
234 BN_init(&u2);
235 BN_init(&t1);
236
237 /* Calculate W = inv(S) mod Q
238 * save W in u2 */
239 if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;
240
241 /* save M in u1 */
242 if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err;
243
244 /* u1 = M * w mod q */
245 if (!BN_mod_mul(&u1,&u1,&u2,dsa->q,ctx)) goto err;
246
247 /* u2 = r * w mod q */
248 if (!BN_mod_mul(&u2,sig->r,&u2,dsa->q,ctx)) goto err;
249
250 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
251 {
252 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
253 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
254 dsa->p,ctx)) goto err;
255 }
256 mont=(BN_MONT_CTX *)dsa->method_mont_p;
257
258#if 0
259 {
260 BIGNUM t2;
261
262 BN_init(&t2);
263 /* v = ( g^u1 * y^u2 mod p ) mod q */
264 /* let t1 = g ^ u1 mod p */
265 if (!BN_mod_exp_mont(&t1,dsa->g,&u1,dsa->p,ctx,mont)) goto err;
266 /* let t2 = y ^ u2 mod p */
267 if (!BN_mod_exp_mont(&t2,dsa->pub_key,&u2,dsa->p,ctx,mont)) goto err;
268 /* let u1 = t1 * t2 mod p */
269 if (!BN_mod_mul(&u1,&t1,&t2,dsa->p,ctx)) goto err_bn;
270 BN_free(&t2);
271 }
272 /* let u1 = u1 mod q */
273 if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err;
274#else
275 {
276 if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2,
277 dsa->p,ctx,mont)) goto err;
278 /* BN_copy(&u1,&t1); */
279 /* let u1 = u1 mod q */
280 if (!BN_mod(&u1,&t1,dsa->q,ctx)) goto err;
281 }
282#endif
283 /* V is now in u1. If the signature is correct, it will be
284 * equal to R. */
285 ret=(BN_ucmp(&u1, sig->r) == 0);
286
287 err:
288 if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY,ERR_R_BN_LIB);
289 if (ctx != NULL) BN_CTX_free(ctx);
290 BN_free(&u1);
291 BN_free(&u2);
292 BN_free(&t1);
293 return(ret);
294 }
295
296static int dsa_init(DSA *dsa)
297{
298 dsa->flags|=DSA_FLAG_CACHE_MONT_P;
299 return(1);
300}
301
302static int dsa_finish(DSA *dsa)
303{
304 if(dsa->method_mont_p)
305 BN_MONT_CTX_free((BN_MONT_CTX *)dsa->method_mont_p);
306 return(1);
307}
308
309static int dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
310 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
311 BN_MONT_CTX *in_mont)
312{
313 return BN_mod_exp2_mont(rr, a1, p1, a2, p2, m, ctx, in_mont);
314}
315
316static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
317 const BIGNUM *m, BN_CTX *ctx,
318 BN_MONT_CTX *m_ctx)
319{
320 return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
321}
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index 774c161964..89205026f0 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -67,73 +67,9 @@
67 67
68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
69 { 69 {
70 BIGNUM *kinv=NULL,*r=NULL,*s=NULL; 70 return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
71 BIGNUM m;
72 BIGNUM xr;
73 BN_CTX *ctx=NULL;
74 int i,reason=ERR_R_BN_LIB;
75 DSA_SIG *ret=NULL;
76
77 BN_init(&m);
78 BN_init(&xr);
79 s=BN_new();
80 if (s == NULL) goto err;
81
82 i=BN_num_bytes(dsa->q); /* should be 20 */
83 if ((dlen > i) || (dlen > 50))
84 {
85 reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;
86 goto err;
87 }
88
89 ctx=BN_CTX_new();
90 if (ctx == NULL) goto err;
91
92 if ((dsa->kinv == NULL) || (dsa->r == NULL))
93 {
94 if (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err;
95 }
96 else
97 {
98 kinv=dsa->kinv;
99 dsa->kinv=NULL;
100 r=dsa->r;
101 dsa->r=NULL;
102 }
103
104 if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err;
105
106 /* Compute s = inv(k) (m + xr) mod q */
107 if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */
108 if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */
109 if (BN_cmp(s,dsa->q) > 0)
110 BN_sub(s,s,dsa->q);
111 if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
112
113 ret=DSA_SIG_new();
114 if (ret == NULL) goto err;
115 ret->r = r;
116 ret->s = s;
117
118err:
119 if (!ret)
120 {
121 DSAerr(DSA_F_DSA_DO_SIGN,reason);
122 BN_free(r);
123 BN_free(s);
124 }
125 if (ctx != NULL) BN_CTX_free(ctx);
126 BN_clear_free(&m);
127 BN_clear_free(&xr);
128 if (kinv != NULL) /* dsa->kinv is NULL now if we used it */
129 BN_clear_free(kinv);
130 return(ret);
131 } 71 }
132 72
133/* data has already been hashed (probably with SHA or SHA-1). */
134
135/* unsigned char *sig: out */
136/* unsigned int *siglen: out */
137int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, 73int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
138 unsigned int *siglen, DSA *dsa) 74 unsigned int *siglen, DSA *dsa)
139 { 75 {
@@ -151,61 +87,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
151 87
152int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 88int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
153 { 89 {
154 BN_CTX *ctx; 90 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
155 BIGNUM k,*kinv=NULL,*r=NULL;
156 int ret=0;
157
158 if (ctx_in == NULL)
159 {
160 if ((ctx=BN_CTX_new()) == NULL) goto err;
161 }
162 else
163 ctx=ctx_in;
164
165 BN_init(&k);
166 if ((r=BN_new()) == NULL) goto err;
167 kinv=NULL;
168
169 /* Get random k */
170 for (;;)
171 {
172 if (!BN_rand(&k, BN_num_bits(dsa->q), 1, 0)) goto err;
173 if (BN_cmp(&k,dsa->q) >= 0)
174 BN_sub(&k,&k,dsa->q);
175 if (!BN_is_zero(&k)) break;
176 }
177
178 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
179 {
180 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
181 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
182 dsa->p,ctx)) goto err;
183 }
184
185 /* Compute r = (g^k mod p) mod q */
186 if (!BN_mod_exp_mont(r,dsa->g,&k,dsa->p,ctx,
187 (BN_MONT_CTX *)dsa->method_mont_p)) goto err;
188 if (!BN_mod(r,r,dsa->q,ctx)) goto err;
189
190 /* Compute part of 's = inv(k) (m + xr) mod q' */
191 if ((kinv=BN_mod_inverse(NULL,&k,dsa->q,ctx)) == NULL) goto err;
192
193 if (*kinvp != NULL) BN_clear_free(*kinvp);
194 *kinvp=kinv;
195 kinv=NULL;
196 if (*rp != NULL) BN_clear_free(*rp);
197 *rp=r;
198 ret=1;
199err:
200 if (!ret)
201 {
202 DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
203 if (kinv != NULL) BN_clear_free(kinv);
204 if (r != NULL) BN_clear_free(r);
205 }
206 if (ctx_in == NULL) BN_CTX_free(ctx);
207 if (kinv != NULL) BN_clear_free(kinv);
208 BN_clear_free(&k);
209 return(ret);
210 } 91 }
211 92
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index ff552208aa..03277f80fd 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -69,73 +69,7 @@
69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
70 DSA *dsa) 70 DSA *dsa)
71 { 71 {
72 BN_CTX *ctx; 72 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
73 BIGNUM u1,u2,t1;
74 BN_MONT_CTX *mont=NULL;
75 int ret = -1;
76
77 if ((ctx=BN_CTX_new()) == NULL) goto err;
78 BN_init(&u1);
79 BN_init(&u2);
80 BN_init(&t1);
81
82 /* Calculate W = inv(S) mod Q
83 * save W in u2 */
84 if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;
85
86 /* save M in u1 */
87 if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err;
88
89 /* u1 = M * w mod q */
90 if (!BN_mod_mul(&u1,&u1,&u2,dsa->q,ctx)) goto err;
91
92 /* u2 = r * w mod q */
93 if (!BN_mod_mul(&u2,sig->r,&u2,dsa->q,ctx)) goto err;
94
95 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
96 {
97 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
98 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
99 dsa->p,ctx)) goto err;
100 }
101 mont=(BN_MONT_CTX *)dsa->method_mont_p;
102
103#if 0
104 {
105 BIGNUM t2;
106
107 BN_init(&t2);
108 /* v = ( g^u1 * y^u2 mod p ) mod q */
109 /* let t1 = g ^ u1 mod p */
110 if (!BN_mod_exp_mont(&t1,dsa->g,&u1,dsa->p,ctx,mont)) goto err;
111 /* let t2 = y ^ u2 mod p */
112 if (!BN_mod_exp_mont(&t2,dsa->pub_key,&u2,dsa->p,ctx,mont)) goto err;
113 /* let u1 = t1 * t2 mod p */
114 if (!BN_mod_mul(&u1,&t1,&t2,dsa->p,ctx)) goto err_bn;
115 BN_free(&t2);
116 }
117 /* let u1 = u1 mod q */
118 if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err;
119#else
120 {
121 if (!BN_mod_exp2_mont(&t1,dsa->g,&u1,dsa->pub_key,&u2,dsa->p,ctx,mont))
122 goto err;
123 /* BN_copy(&u1,&t1); */
124 /* let u1 = u1 mod q */
125 if (!BN_mod(&u1,&t1,dsa->q,ctx)) goto err;
126 }
127#endif
128 /* V is now in u1. If the signature is correct, it will be
129 * equal to R. */
130 ret=(BN_ucmp(&u1, sig->r) == 0);
131
132 err:
133 if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY,ERR_R_BN_LIB);
134 if (ctx != NULL) BN_CTX_free(ctx);
135 BN_free(&u1);
136 BN_free(&u2);
137 BN_free(&t1);
138 return(ret);
139 } 73 }
140 74
141/* data has already been hashed (probably with SHA or SHA-1). */ 75/* data has already been hashed (probably with SHA or SHA-1). */
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
index fc25c9a1b7..309a7cda89 100644
--- a/src/lib/libcrypto/dsa/dsatest.c
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -84,7 +84,10 @@ int main(int argc, char *argv[])
84#define MS_CALLBACK 84#define MS_CALLBACK
85#endif 85#endif
86 86
87static void MS_CALLBACK dsa_cb(int p, int n, char *arg); 87static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
88
89/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
90 * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
88static unsigned char seed[20]={ 91static unsigned char seed[20]={
89 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, 92 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40,
90 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, 93 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3,
@@ -120,6 +123,8 @@ static unsigned char out_g[]={
120 123
121static const unsigned char str1[]="12345678901234567890"; 124static const unsigned char str1[]="12345678901234567890";
122 125
126static const char rnd_seed[] = "string to make the random number generator think it has entropy";
127
123static BIO *bio_err=NULL; 128static BIO *bio_err=NULL;
124 129
125int main(int argc, char **argv) 130int main(int argc, char **argv)
@@ -131,15 +136,17 @@ int main(int argc, char **argv)
131 unsigned char sig[256]; 136 unsigned char sig[256];
132 unsigned int siglen; 137 unsigned int siglen;
133 138
139 ERR_load_crypto_strings();
140 RAND_seed(rnd_seed, sizeof rnd_seed);
141
134 if (bio_err == NULL) 142 if (bio_err == NULL)
135 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 143 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
136 144
137 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 145 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
138 146
139 BIO_printf(bio_err,"test generation of DSA parameters\n"); 147 BIO_printf(bio_err,"test generation of DSA parameters\n");
140 BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n"); 148
141 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb, 149 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
142 (char *)bio_err);
143 150
144 BIO_printf(bio_err,"seed\n"); 151 BIO_printf(bio_err,"seed\n");
145 for (i=0; i<20; i+=4) 152 for (i=0; i<20; i+=4)
@@ -193,13 +200,18 @@ end:
193 if (!ret) 200 if (!ret)
194 ERR_print_errors(bio_err); 201 ERR_print_errors(bio_err);
195 if (dsa != NULL) DSA_free(dsa); 202 if (dsa != NULL) DSA_free(dsa);
203 ERR_remove_state(0);
196 CRYPTO_mem_leaks(bio_err); 204 CRYPTO_mem_leaks(bio_err);
197 if (bio_err != NULL) BIO_free(bio_err); 205 if (bio_err != NULL)
206 {
207 BIO_free(bio_err);
208 bio_err = NULL;
209 }
198 exit(!ret); 210 exit(!ret);
199 return(0); 211 return(0);
200 } 212 }
201 213
202static void MS_CALLBACK dsa_cb(int p, int n, char *arg) 214static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
203 { 215 {
204 char c='*'; 216 char c='*';
205 static int ok=0,num=0; 217 static int ok=0,num=0;
@@ -208,8 +220,8 @@ static void MS_CALLBACK dsa_cb(int p, int n, char *arg)
208 if (p == 1) c='+'; 220 if (p == 1) c='+';
209 if (p == 2) { c='*'; ok++; } 221 if (p == 2) { c='*'; ok++; }
210 if (p == 3) c='\n'; 222 if (p == 3) c='\n';
211 BIO_write((BIO *)arg,&c,1); 223 BIO_write(arg,&c,1);
212 (void)BIO_flush((BIO *)arg); 224 (void)BIO_flush(arg);
213 225
214 if (!ok && (p == 0) && (num > 1)) 226 if (!ok && (p == 0) && (num > 1))
215 { 227 {
diff --git a/src/lib/libcrypto/ebcdic.c b/src/lib/libcrypto/ebcdic.c
new file mode 100644
index 0000000000..31397b2add
--- /dev/null
+++ b/src/lib/libcrypto/ebcdic.c
@@ -0,0 +1,217 @@
1/* crypto/ebcdic.c */
2
3#ifdef CHARSET_EBCDIC
4#include "ebcdic.h"
5/* Initial Port for Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>
6 * Adapted for OpenSSL-0.9.4 by <Martin.Kraemer@Mch.SNI.De>
7 */
8
9#ifdef _OSD_POSIX
10/*
11 "BS2000 OSD" is a POSIX subsystem on a main frame.
12 It is made by Siemens AG, Germany, for their BS2000 mainframe machines.
13 Within the POSIX subsystem, the same character set was chosen as in
14 "native BS2000", namely EBCDIC. (EDF04)
15
16 The name "ASCII" in these routines is misleading: actually, conversion
17 is not between EBCDIC and ASCII, but EBCDIC(EDF04) and ISO-8859.1;
18 that means that (western european) national characters are preserved.
19
20 This table is identical to the one used by rsh/rcp/ftp and other POSIX tools.
21*/
22
23/* Here's the bijective ebcdic-to-ascii table: */
24const unsigned char os_toascii[256] = {
25/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
26 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
27/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
28 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
29/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
30 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
31/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
32 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
33/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
34 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
35/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
36 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
37/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
38 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
39/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
40 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
41/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
42 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
43/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
44 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
45/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
46 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
47/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
48 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
49/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
50 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
51/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
52 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
53/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
54 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
55/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
56 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
57};
58
59
60/* The ascii-to-ebcdic table: */
61const unsigned char os_toebcdic[256] = {
62/*00*/ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
63 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
64/*10*/ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
65 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
66/*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
67 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
68/*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
69 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /*0123456789:;<=>?*/
70/*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
71 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /*@ABCDEFGHIJKLMNO*/
72/*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
73 0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d, /*PQRSTUVWXYZ[\]^_*/
74/*60*/ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
75 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /*`abcdefghijklmno*/
76/*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
77 0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07, /*pqrstuvwxyz{|}~.*/
78/*80*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
79 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /*................*/
80/*90*/ 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
81 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f, /*................*/
82/*a0*/ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
83 0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1, /*................*/
84/*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
85 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /*................*/
86/*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
87 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /*................*/
88/*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
89 0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59, /*................*/
90/*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
91 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /*................*/
92/*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
93 0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /*................*/
94};
95
96#else /*_OSD_POSIX*/
97
98/*
99This code does basic character mapping for IBM's TPF and OS/390 operating systems.
100It is a modified version of the BS2000 table.
101
102Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
103This table is bijective - there are no ambigous or duplicate characters.
104*/
105const unsigned char os_toascii[256] = {
106 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
107 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
108 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
109 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
110 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
111 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
112 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
113 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
114 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
115 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
116 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
117 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
118 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
119 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
120 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
121 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
122 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
123 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
124 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
125 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
126 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
127 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
128 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
129 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
130 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
131 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
132 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
133 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
134 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
135 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
136 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
137 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
138};
139
140
141/*
142The US-ASCII to EBCDIC (character set IBM-1047) table:
143This table is bijective (no ambiguous or duplicate characters)
144*/
145const unsigned char os_toebcdic[256] = {
146 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f: */
147 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
148 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f: */
149 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
150 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f: */
151 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
152 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f: */
153 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
154 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f: */
155 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
156 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f: */
157 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
158 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f: */
159 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
160 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f: */
161 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
162 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f: */
163 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
164 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f: */
165 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
166 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af: */
167 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
168 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf: */
169 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
170 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf: */
171 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
172 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df: */
173 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
174 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef: */
175 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
176 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */
177 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */
178};
179#endif /*_OSD_POSIX*/
180
181/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
182 * dest and srce may be identical, or separate memory blocks, but
183 * should not overlap. These functions intentionally have an interface
184 * compatible to memcpy(3).
185 */
186
187void *
188ebcdic2ascii(void *dest, const void *srce, size_t count)
189{
190 unsigned char *udest = dest;
191 const unsigned char *usrce = srce;
192
193 while (count-- != 0) {
194 *udest++ = os_toascii[*usrce++];
195 }
196
197 return dest;
198}
199
200void *
201ascii2ebcdic(void *dest, const void *srce, size_t count)
202{
203 unsigned char *udest = dest;
204 const unsigned char *usrce = srce;
205
206 while (count-- != 0) {
207 *udest++ = os_toebcdic[*usrce++];
208 }
209
210 return dest;
211}
212
213#else /*CHARSET_EBCDIC*/
214#ifdef PEDANTIC
215static void *dummy=&dummy;
216#endif
217#endif
diff --git a/src/lib/libcrypto/ebcdic.h b/src/lib/libcrypto/ebcdic.h
index d3b4e98b12..6d65afcf9e 100644
--- a/src/lib/libcrypto/ebcdic.h
+++ b/src/lib/libcrypto/ebcdic.h
@@ -1,17 +1,19 @@
1/* crypto/ebcdic.h */
2
1#ifndef HEADER_EBCDIC_H 3#ifndef HEADER_EBCDIC_H
2#define HEADER_EBCDIC_H 4#define HEADER_EBCDIC_H
3 5
4#include <sys/types.h> 6#include <sys/types.h>
5 7
6/* Avoid name clashes with other applications */ 8/* Avoid name clashes with other applications */
7#define os_toascii _eay2000_os_toascii 9#define os_toascii _openssl_os_toascii
8#define os_toebcdic _eay2000_os_toebcdic 10#define os_toebcdic _openssl_os_toebcdic
9#define ebcdic2ascii _eay2000_ebcdic2ascii 11#define ebcdic2ascii _openssl_ebcdic2ascii
10#define ascii2ebcdic _eay2000_ascii2ebcdic 12#define ascii2ebcdic _openssl_ascii2ebcdic
11 13
12extern const unsigned char os_toascii[256]; 14extern const unsigned char os_toascii[256];
13extern const unsigned char os_toebcdic[256]; 15extern const unsigned char os_toebcdic[256];
14void ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t count); 16void *ebcdic2ascii(void *dest, const void *srce, size_t count);
15void ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t count); 17void *ascii2ebcdic(void *dest, const void *srce, size_t count);
16 18
17#endif 19#endif
diff --git a/src/lib/libcrypto/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl
index ae827edddb..fb74e4eb13 100644
--- a/src/lib/libcrypto/err/Makefile.ssl
+++ b/src/lib/libcrypto/err/Makefile.ssl
@@ -82,8 +82,8 @@ err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 84err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
85err.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 85err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
86err.o: ../cryptlib.h 86err.o: ../../include/openssl/stack.h ../cryptlib.h
87err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 87err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
88err_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 88err_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
89err_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 89err_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -96,15 +96,16 @@ err_all.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
96err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h 96err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
97err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 97err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
98err_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h 98err_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
99err_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 99err_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
100err_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 100err_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
101err_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 101err_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
102err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 102err_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
103err_all.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 103err_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
104err_all.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 104err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
105err_all.o: ../../include/openssl/x509v3.h
105err_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 106err_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
106err_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 107err_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
107err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 108err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
108err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 109err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
109err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 110err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
110err_prn.o: ../cryptlib.h 111err_prn.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 8810d838c6..93c64cbc4f 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -91,7 +91,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
91{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, 91{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
92{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, 92{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
93{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, 93{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
94{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuation file routines"}, 94{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
95{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"}, 95{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"},
96{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, 96{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
97{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"}, 97{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"},
@@ -100,6 +100,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
100{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, 100{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
101{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, 101{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
102{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"}, 102{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
103{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
103{0,NULL}, 104{0,NULL},
104 }; 105 };
105 106
@@ -221,7 +222,7 @@ void ERR_load_strings(int lib, ERR_STRING_DATA *str)
221 while (str->error) 222 while (str->error)
222 { 223 {
223 str->error|=ERR_PACK(lib,0,0); 224 str->error|=ERR_PACK(lib,0,0);
224 lh_insert(error_hash,(char *)str); 225 lh_insert(error_hash,str);
225 str++; 226 str++;
226 } 227 }
227 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); 228 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
@@ -427,7 +428,7 @@ const char *ERR_lib_error_string(unsigned long e)
427 if (error_hash != NULL) 428 if (error_hash != NULL)
428 { 429 {
429 d.error=ERR_PACK(l,0,0); 430 d.error=ERR_PACK(l,0,0);
430 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); 431 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
431 } 432 }
432 433
433 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); 434 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH);
@@ -448,7 +449,7 @@ const char *ERR_func_error_string(unsigned long e)
448 if (error_hash != NULL) 449 if (error_hash != NULL)
449 { 450 {
450 d.error=ERR_PACK(l,f,0); 451 d.error=ERR_PACK(l,f,0);
451 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); 452 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
452 } 453 }
453 454
454 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); 455 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH);
@@ -469,12 +470,11 @@ const char *ERR_reason_error_string(unsigned long e)
469 if (error_hash != NULL) 470 if (error_hash != NULL)
470 { 471 {
471 d.error=ERR_PACK(l,0,r); 472 d.error=ERR_PACK(l,0,r);
472 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); 473 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
473 if (p == NULL) 474 if (p == NULL)
474 { 475 {
475 d.error=ERR_PACK(0,0,r); 476 d.error=ERR_PACK(0,0,r);
476 p=(ERR_STRING_DATA *)lh_retrieve(error_hash, 477 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
477 (char *)&d);
478 } 478 }
479 } 479 }
480 480
@@ -517,7 +517,7 @@ void ERR_remove_state(unsigned long pid)
517 pid=(unsigned long)CRYPTO_thread_id(); 517 pid=(unsigned long)CRYPTO_thread_id();
518 tmp.pid=pid; 518 tmp.pid=pid;
519 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 519 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
520 p=(ERR_STATE *)lh_delete(thread_hash,(char *)&tmp); 520 p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
521 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 521 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
522 522
523 if (p != NULL) ERR_STATE_free(p); 523 if (p != NULL) ERR_STATE_free(p);
@@ -551,7 +551,7 @@ ERR_STATE *ERR_get_state(void)
551 else 551 else
552 { 552 {
553 tmp.pid=pid; 553 tmp.pid=pid;
554 ret=(ERR_STATE *)lh_retrieve(thread_hash,(char *)&tmp); 554 ret=(ERR_STATE *)lh_retrieve(thread_hash,&tmp);
555 CRYPTO_r_unlock(CRYPTO_LOCK_ERR); 555 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
556 } 556 }
557 557
@@ -569,7 +569,7 @@ ERR_STATE *ERR_get_state(void)
569 ret->err_data_flags[i]=0; 569 ret->err_data_flags[i]=0;
570 } 570 }
571 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 571 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
572 tmpp=(ERR_STATE *)lh_insert(thread_hash,(char *)ret); 572 tmpp=(ERR_STATE *)lh_insert(thread_hash,ret);
573 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 573 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
574 if (tmpp != NULL) /* old entry - should not happen */ 574 if (tmpp != NULL) /* old entry - should not happen */
575 { 575 {
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h
index 9411fb3568..15bafbff43 100644
--- a/src/lib/libcrypto/err/err.h
+++ b/src/lib/libcrypto/err/err.h
@@ -122,6 +122,7 @@ typedef struct err_state_st
122#define ERR_LIB_PKCS7 33 122#define ERR_LIB_PKCS7 33
123#define ERR_LIB_X509V3 34 123#define ERR_LIB_X509V3 34
124#define ERR_LIB_PKCS12 35 124#define ERR_LIB_PKCS12 35
125#define ERR_LIB_RAND 36
125 126
126#define ERR_LIB_USER 128 127#define ERR_LIB_USER 128
127 128
@@ -149,6 +150,7 @@ typedef struct err_state_st
149#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__) 150#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__)
150#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__) 151#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__)
151#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__) 152#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__)
153#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),ERR_file_name,__LINE__)
152 154
153/* Borland C seems too stupid to be able to shift and do longs in 155/* Borland C seems too stupid to be able to shift and do longs in
154 * the pre-processor :-( */ 156 * the pre-processor :-( */
@@ -160,7 +162,7 @@ typedef struct err_state_st
160#define ERR_GET_REASON(l) (int)((l)&0xfffL) 162#define ERR_GET_REASON(l) (int)((l)&0xfffL)
161#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) 163#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
162 164
163/* OS fuctions */ 165/* OS functions */
164#define SYS_F_FOPEN 1 166#define SYS_F_FOPEN 1
165#define SYS_F_CONNECT 2 167#define SYS_F_CONNECT 2
166#define SYS_F_GETSERVBYNAME 3 168#define SYS_F_GETSERVBYNAME 3
@@ -239,9 +241,9 @@ void ERR_print_errors(BIO *bp);
239void ERR_add_error_data(int num, ...); 241void ERR_add_error_data(int num, ...);
240#endif 242#endif
241void ERR_load_strings(int lib,ERR_STRING_DATA str[]); 243void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
242void ERR_load_ERR_strings(void ); 244void ERR_load_ERR_strings(void);
243void ERR_load_crypto_strings(void ); 245void ERR_load_crypto_strings(void);
244void ERR_free_strings(void ); 246void ERR_free_strings(void);
245 247
246void ERR_remove_state(unsigned long pid); /* if zero we look it up */ 248void ERR_remove_state(unsigned long pid); /* if zero we look it up */
247ERR_STATE *ERR_get_state(void); 249ERR_STATE *ERR_get_state(void);
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
index ad820227d2..10c463b389 100644
--- a/src/lib/libcrypto/err/err_all.c
+++ b/src/lib/libcrypto/err/err_all.c
@@ -80,6 +80,7 @@
80#include <openssl/x509v3.h> 80#include <openssl/x509v3.h>
81#include <openssl/conf.h> 81#include <openssl/conf.h>
82#include <openssl/pkcs12.h> 82#include <openssl/pkcs12.h>
83#include <openssl/rand.h>
83#include <openssl/err.h> 84#include <openssl/err.h>
84 85
85void ERR_load_crypto_strings(void) 86void ERR_load_crypto_strings(void)
@@ -116,5 +117,6 @@ void ERR_load_crypto_strings(void)
116 ERR_load_CRYPTO_strings(); 117 ERR_load_CRYPTO_strings();
117 ERR_load_PKCS7_strings(); 118 ERR_load_PKCS7_strings();
118 ERR_load_PKCS12_strings(); 119 ERR_load_PKCS12_strings();
120 ERR_load_RAND_strings();
119#endif 121#endif
120 } 122 }
diff --git a/src/lib/libcrypto/err/openssl.ec b/src/lib/libcrypto/err/openssl.ec
index c2a8acff0c..e132ba3182 100644
--- a/src/lib/libcrypto/err/openssl.ec
+++ b/src/lib/libcrypto/err/openssl.ec
@@ -21,6 +21,7 @@ L PKCS12 crypto/pkcs12/pkcs12.h crypto/pkcs12/pk12err.c
21L RSAREF rsaref/rsaref.h rsaref/rsar_err.c 21L RSAREF rsaref/rsaref.h rsaref/rsar_err.c
22L SSL ssl/ssl.h ssl/ssl_err.c 22L SSL ssl/ssl.h ssl/ssl_err.c
23L COMP crypto/comp/comp.h crypto/comp/comp_err.c 23L COMP crypto/comp/comp.h crypto/comp/comp_err.c
24L RAND crypto/rand/rand.h crypto/rand/rand_err.c
24 25
25 26
26F RSAREF_F_RSA_BN2BIN 27F RSAREF_F_RSA_BN2BIN
@@ -47,11 +48,11 @@ R SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048
47R SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 48R SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
48R SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 49R SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
49R SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 50R SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051
50R SSL_R_TLSV1_ALERT_EXPORT_RESTRICION 1060 51R SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
51R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 52R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
52R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 53R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
53R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 54R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
54R SSL_R_TLSV1_ALERT_USER_CANCLED 1090 55R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
55R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 56R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
56 57
57R RSAREF_R_CONTENT_ENCODING 0x0400 58R RSAREF_R_CONTENT_ENCODING 0x0400
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl
index 753479a015..c763b5ccd6 100644
--- a/src/lib/libcrypto/evp/Makefile.ssl
+++ b/src/lib/libcrypto/evp/Makefile.ssl
@@ -35,7 +35,8 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c \
35 m_ripemd.c \ 35 m_ripemd.c \
36 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ 36 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
37 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ 37 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
38 c_all.c evp_lib.c bio_ok.c evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c 38 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
39 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c
39 40
40LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \ 41LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
41 e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \ 42 e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \
@@ -50,7 +51,8 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
50 m_ripemd.o \ 51 m_ripemd.o \
51 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ 52 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
52 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \ 53 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \
53 c_all.o evp_lib.o bio_ok.o evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o 54 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \
55 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o
54 56
55SRC= $(LIBSRC) 57SRC= $(LIBSRC)
56 58
@@ -176,13 +178,45 @@ c_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
176c_all.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 178c_all.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
177c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 179c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
178c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 180c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
179c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 181c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h
180c_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
181c_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 182c_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
182c_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 183c_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
183c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 184c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
184c_all.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 185c_all.o: ../../include/openssl/stack.h ../cryptlib.h
185c_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 186c_allc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
187c_allc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
188c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
189c_allc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
190c_allc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
191c_allc.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
192c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
193c_allc.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
194c_allc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
195c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
196c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
197c_allc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
198c_allc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
199c_allc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
200c_allc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
201c_allc.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
202c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
203c_alld.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
204c_alld.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
205c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
206c_alld.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
207c_alld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
208c_alld.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
209c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
210c_alld.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
211c_alld.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
212c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
213c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
214c_alld.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
215c_alld.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
216c_alld.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
217c_alld.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
218c_alld.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
219c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
186digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 220digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
187digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 221digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
188digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 222digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c
index 84729119df..bd5e24f993 100644
--- a/src/lib/libcrypto/evp/bio_b64.c
+++ b/src/lib/libcrypto/evp/bio_b64.c
@@ -69,6 +69,7 @@ static int b64_read(BIO *h,char *buf,int size);
69static long b64_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long b64_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int b64_new(BIO *h); 70static int b64_new(BIO *h);
71static int b64_free(BIO *data); 71static int b64_free(BIO *data);
72static long b64_callback_ctrl(BIO *h,int cmd,void (*fp)());
72#define B64_BLOCK_SIZE 1024 73#define B64_BLOCK_SIZE 1024
73#define B64_BLOCK_SIZE2 768 74#define B64_BLOCK_SIZE2 768
74#define B64_NONE 0 75#define B64_NONE 0
@@ -100,6 +101,7 @@ static BIO_METHOD methods_b64=
100 b64_ctrl, 101 b64_ctrl,
101 b64_new, 102 b64_new,
102 b64_free, 103 b64_free,
104 b64_callback_ctrl,
103 }; 105 };
104 106
105BIO_METHOD *BIO_f_base64(void) 107BIO_METHOD *BIO_f_base64(void)
@@ -237,8 +239,8 @@ static int b64_read(BIO *b, char *out, int outl)
237 &(ctx->tmp[0])); 239 &(ctx->tmp[0]));
238 for (x=0; x < i; x++) 240 for (x=0; x < i; x++)
239 ctx->tmp[x]=p[x]; 241 ctx->tmp[x]=p[x];
240 EVP_DecodeInit(&ctx->base64);
241 } 242 }
243 EVP_DecodeInit(&ctx->base64);
242 ctx->start=0; 244 ctx->start=0;
243 break; 245 break;
244 } 246 }
@@ -522,3 +524,17 @@ again:
522 return(ret); 524 return(ret);
523 } 525 }
524 526
527static long b64_callback_ctrl(BIO *b, int cmd, void (*fp)())
528 {
529 long ret=1;
530
531 if (b->next_bio == NULL) return(0);
532 switch (cmd)
533 {
534 default:
535 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
536 break;
537 }
538 return(ret);
539 }
540
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c
index 0a7b1ecf07..629bf4b95d 100644
--- a/src/lib/libcrypto/evp/bio_enc.c
+++ b/src/lib/libcrypto/evp/bio_enc.c
@@ -69,6 +69,7 @@ static int enc_read(BIO *h,char *buf,int size);
69static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int enc_new(BIO *h); 70static 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,void (*fp)());
72#define ENC_BLOCK_SIZE (1024*4) 73#define ENC_BLOCK_SIZE (1024*4)
73 74
74typedef struct enc_struct 75typedef struct enc_struct
@@ -92,6 +93,7 @@ static BIO_METHOD methods_enc=
92 enc_ctrl, 93 enc_ctrl,
93 enc_new, 94 enc_new,
94 enc_free, 95 enc_free,
96 enc_callback_ctrl,
95 }; 97 };
96 98
97BIO_METHOD *BIO_f_cipher(void) 99BIO_METHOD *BIO_f_cipher(void)
@@ -184,9 +186,11 @@ static int enc_read(BIO *b, char *out, int outl)
184 ctx->ok=i; 186 ctx->ok=i;
185 ctx->buf_off=0; 187 ctx->buf_off=0;
186 } 188 }
187 else 189 else
190 {
188 ret=(ret == 0)?i:ret; 191 ret=(ret == 0)?i:ret;
189 break; 192 break;
193 }
190 } 194 }
191 else 195 else
192 { 196 {
@@ -194,13 +198,19 @@ static int enc_read(BIO *b, char *out, int outl)
194 (unsigned char *)ctx->buf,&ctx->buf_len, 198 (unsigned char *)ctx->buf,&ctx->buf_len,
195 (unsigned char *)&(ctx->buf[8]),i); 199 (unsigned char *)&(ctx->buf[8]),i);
196 ctx->cont=1; 200 ctx->cont=1;
201 /* Note: it is possible for EVP_CipherUpdate to
202 * decrypt zero bytes because this is or looks like
203 * the final block: if this happens we should retry
204 * and either read more data or decrypt the final
205 * block
206 */
207 if(ctx->buf_len == 0) continue;
197 } 208 }
198 209
199 if (ctx->buf_len <= outl) 210 if (ctx->buf_len <= outl)
200 i=ctx->buf_len; 211 i=ctx->buf_len;
201 else 212 else
202 i=outl; 213 i=outl;
203
204 if (i <= 0) break; 214 if (i <= 0) break;
205 memcpy(out,ctx->buf,i); 215 memcpy(out,ctx->buf,i);
206 ret+=i; 216 ret+=i;
@@ -360,6 +370,20 @@ again:
360 return(ret); 370 return(ret);
361 } 371 }
362 372
373static long enc_callback_ctrl(BIO *b, int cmd, void (*fp)())
374 {
375 long ret=1;
376
377 if (b->next_bio == NULL) return(0);
378 switch (cmd)
379 {
380 default:
381 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
382 break;
383 }
384 return(ret);
385 }
386
363/* 387/*
364void BIO_set_cipher_ctx(b,c) 388void BIO_set_cipher_ctx(b,c)
365BIO *b; 389BIO *b;
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c
index 317167f9c4..aef928dd8f 100644
--- a/src/lib/libcrypto/evp/bio_md.c
+++ b/src/lib/libcrypto/evp/bio_md.c
@@ -72,6 +72,8 @@ static int md_gets(BIO *h,char *str,int size);
72static long md_ctrl(BIO *h,int cmd,long arg1,char *arg2); 72static long md_ctrl(BIO *h,int cmd,long arg1,char *arg2);
73static int md_new(BIO *h); 73static int md_new(BIO *h);
74static int md_free(BIO *data); 74static int md_free(BIO *data);
75static long md_callback_ctrl(BIO *h,int cmd,void (*fp)());
76
75static BIO_METHOD methods_md= 77static BIO_METHOD methods_md=
76 { 78 {
77 BIO_TYPE_MD,"message digest", 79 BIO_TYPE_MD,"message digest",
@@ -82,6 +84,7 @@ static BIO_METHOD methods_md=
82 md_ctrl, 84 md_ctrl,
83 md_new, 85 md_new,
84 md_free, 86 md_free,
87 md_callback_ctrl,
85 }; 88 };
86 89
87BIO_METHOD *BIO_f_md(void) 90BIO_METHOD *BIO_f_md(void)
@@ -220,6 +223,20 @@ static long md_ctrl(BIO *b, int cmd, long num, char *ptr)
220 return(ret); 223 return(ret);
221 } 224 }
222 225
226static long md_callback_ctrl(BIO *b, int cmd, void (*fp)())
227 {
228 long ret=1;
229
230 if (b->next_bio == NULL) return(0);
231 switch (cmd)
232 {
233 default:
234 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
235 break;
236 }
237 return(ret);
238 }
239
223static int md_gets(BIO *bp, char *buf, int size) 240static int md_gets(BIO *bp, char *buf, int size)
224 { 241 {
225 EVP_MD_CTX *ctx; 242 EVP_MD_CTX *ctx;
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c
index 101275d648..e6ff5f2cdb 100644
--- a/src/lib/libcrypto/evp/bio_ok.c
+++ b/src/lib/libcrypto/evp/bio_ok.c
@@ -67,7 +67,7 @@
67 and everything was OK. BUT if user types wrong password 67 and everything was OK. BUT if user types wrong password
68 BIO_f_cipher outputs only garbage and my function crashes. Yes 68 BIO_f_cipher outputs only garbage and my function crashes. Yes
69 I can and I should fix my function, but BIO_f_cipher is 69 I can and I should fix my function, but BIO_f_cipher is
70 easy way to add encryption support to many exisiting applications 70 easy way to add encryption support to many existing applications
71 and it's hard to debug and fix them all. 71 and it's hard to debug and fix them all.
72 72
73 So I wanted another BIO which would catch the incorrect passwords and 73 So I wanted another BIO which would catch the incorrect passwords and
@@ -80,10 +80,10 @@
80 1) you must somehow separate checksum from actual data. 80 1) you must somehow separate checksum from actual data.
81 2) you need lot's of memory when reading the file, because you 81 2) you need lot's of memory when reading the file, because you
82 must read to the end of the file and verify the checksum before 82 must read to the end of the file and verify the checksum before
83 leting the application to read the data. 83 letting the application to read the data.
84 84
85 BIO_f_reliable tries to solve both problems, so that you can 85 BIO_f_reliable tries to solve both problems, so that you can
86 read and write arbitraly long streams using only fixed amount 86 read and write arbitrary long streams using only fixed amount
87 of memory. 87 of memory.
88 88
89 BIO_f_reliable splits data stream into blocks. Each block is prefixed 89 BIO_f_reliable splits data stream into blocks. Each block is prefixed
@@ -91,7 +91,7 @@
91 several Kbytes of memory to buffer single block before verifying 91 several Kbytes of memory to buffer single block before verifying
92 it's digest. 92 it's digest.
93 93
94 BIO_f_reliable goes futher and adds several important capabilities: 94 BIO_f_reliable goes further and adds several important capabilities:
95 95
96 1) the digest of the block is computed over the whole stream 96 1) the digest of the block is computed over the whole stream
97 -- so nobody can rearrange the blocks or remove or replace them. 97 -- so nobody can rearrange the blocks or remove or replace them.
@@ -110,7 +110,7 @@
110 and then compare the digest output. 110 and then compare the digest output.
111 111
112 Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I 112 Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I
113 initialy wrote and tested this code on x86 machine and wrote the 113 initially wrote and tested this code on x86 machine and wrote the
114 digests out in machine-dependent order :( There are people using 114 digests out in machine-dependent order :( There are people using
115 this code and I cannot change this easily without making existing 115 this code and I cannot change this easily without making existing
116 data files unreadable. 116 data files unreadable.
@@ -130,6 +130,8 @@ static int ok_read(BIO *h,char *buf,int size);
130static long ok_ctrl(BIO *h,int cmd,long arg1,char *arg2); 130static long ok_ctrl(BIO *h,int cmd,long arg1,char *arg2);
131static int ok_new(BIO *h); 131static int ok_new(BIO *h);
132static int ok_free(BIO *data); 132static int ok_free(BIO *data);
133static long ok_callback_ctrl(BIO *h,int cmd,void (*fp)());
134
133static void sig_out(BIO* b); 135static void sig_out(BIO* b);
134static void sig_in(BIO* b); 136static void sig_in(BIO* b);
135static void block_out(BIO* b); 137static void block_out(BIO* b);
@@ -173,6 +175,7 @@ static BIO_METHOD methods_ok=
173 ok_ctrl, 175 ok_ctrl,
174 ok_new, 176 ok_new,
175 ok_free, 177 ok_free,
178 ok_callback_ctrl,
176 }; 179 };
177 180
178BIO_METHOD *BIO_f_reliable(void) 181BIO_METHOD *BIO_f_reliable(void)
@@ -428,6 +431,20 @@ static long ok_ctrl(BIO *b, int cmd, long num, char *ptr)
428 return(ret); 431 return(ret);
429 } 432 }
430 433
434static long ok_callback_ctrl(BIO *b, int cmd, void (*fp)())
435 {
436 long ret=1;
437
438 if (b->next_bio == NULL) return(0);
439 switch (cmd)
440 {
441 default:
442 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
443 break;
444 }
445 return(ret);
446 }
447
431static void longswap(void *_ptr, int len) 448static void longswap(void *_ptr, int len)
432{ 449{
433#ifndef L_ENDIAN 450#ifndef L_ENDIAN
@@ -451,12 +468,12 @@ static void sig_out(BIO* b)
451 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return; 468 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return;
452 469
453 EVP_DigestInit(md, md->digest); 470 EVP_DigestInit(md, md->digest);
454 RAND_bytes(&(md->md.base[0]), md->digest->md_size); 471 RAND_pseudo_bytes(&(md->md.base[0]), md->digest->md_size);
455 memcpy(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]), md->digest->md_size); 472 memcpy(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]), md->digest->md_size);
456 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); 473 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size);
457 ctx->buf_len+= md->digest->md_size; 474 ctx->buf_len+= md->digest->md_size;
458 475
459 EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); 476 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
460 md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); 477 md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]));
461 ctx->buf_len+= md->digest->md_size; 478 ctx->buf_len+= md->digest->md_size;
462 ctx->blockout= 1; 479 ctx->blockout= 1;
@@ -480,7 +497,7 @@ static void sig_in(BIO* b)
480 longswap(&(md->md.base[0]), md->digest->md_size); 497 longswap(&(md->md.base[0]), md->digest->md_size);
481 ctx->buf_off+= md->digest->md_size; 498 ctx->buf_off+= md->digest->md_size;
482 499
483 EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); 500 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
484 md->digest->final(tmp, &(md->md.base[0])); 501 md->digest->final(tmp, &(md->md.base[0]));
485 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; 502 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0;
486 ctx->buf_off+= md->digest->md_size; 503 ctx->buf_off+= md->digest->md_size;
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c
index a4d3b43fb9..1e185830a3 100644
--- a/src/lib/libcrypto/evp/c_all.c
+++ b/src/lib/libcrypto/evp/c_all.c
@@ -59,135 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64 62
65void SSLeay_add_all_algorithms(void) 63void OpenSSL_add_all_algorithms(void)
66 { 64{
67 SSLeay_add_all_ciphers(); 65 OpenSSL_add_all_ciphers();
68 SSLeay_add_all_digests(); 66 OpenSSL_add_all_digests();
69 } 67}
70
71void SSLeay_add_all_ciphers(void)
72 {
73#ifndef NO_DES
74 EVP_add_cipher(EVP_des_cfb());
75 EVP_add_cipher(EVP_des_ede_cfb());
76 EVP_add_cipher(EVP_des_ede3_cfb());
77
78 EVP_add_cipher(EVP_des_ofb());
79 EVP_add_cipher(EVP_des_ede_ofb());
80 EVP_add_cipher(EVP_des_ede3_ofb());
81
82 EVP_add_cipher(EVP_desx_cbc());
83 EVP_add_cipher_alias(SN_desx_cbc,"DESX");
84 EVP_add_cipher_alias(SN_desx_cbc,"desx");
85
86 EVP_add_cipher(EVP_des_cbc());
87 EVP_add_cipher_alias(SN_des_cbc,"DES");
88 EVP_add_cipher_alias(SN_des_cbc,"des");
89 EVP_add_cipher(EVP_des_ede_cbc());
90 EVP_add_cipher(EVP_des_ede3_cbc());
91 EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
92 EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");
93
94 EVP_add_cipher(EVP_des_ecb());
95 EVP_add_cipher(EVP_des_ede());
96 EVP_add_cipher(EVP_des_ede3());
97#endif
98
99#ifndef NO_RC4
100 EVP_add_cipher(EVP_rc4());
101 EVP_add_cipher(EVP_rc4_40());
102#endif
103
104#ifndef NO_IDEA
105 EVP_add_cipher(EVP_idea_ecb());
106 EVP_add_cipher(EVP_idea_cfb());
107 EVP_add_cipher(EVP_idea_ofb());
108 EVP_add_cipher(EVP_idea_cbc());
109 EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
110 EVP_add_cipher_alias(SN_idea_cbc,"idea");
111#endif
112
113#ifndef NO_RC2
114 EVP_add_cipher(EVP_rc2_ecb());
115 EVP_add_cipher(EVP_rc2_cfb());
116 EVP_add_cipher(EVP_rc2_ofb());
117 EVP_add_cipher(EVP_rc2_cbc());
118 EVP_add_cipher(EVP_rc2_40_cbc());
119 EVP_add_cipher(EVP_rc2_64_cbc());
120 EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
121 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
122#endif
123
124#ifndef NO_BF
125 EVP_add_cipher(EVP_bf_ecb());
126 EVP_add_cipher(EVP_bf_cfb());
127 EVP_add_cipher(EVP_bf_ofb());
128 EVP_add_cipher(EVP_bf_cbc());
129 EVP_add_cipher_alias(SN_bf_cbc,"BF");
130 EVP_add_cipher_alias(SN_bf_cbc,"bf");
131 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
132#endif
133
134#ifndef NO_CAST
135 EVP_add_cipher(EVP_cast5_ecb());
136 EVP_add_cipher(EVP_cast5_cfb());
137 EVP_add_cipher(EVP_cast5_ofb());
138 EVP_add_cipher(EVP_cast5_cbc());
139 EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
140 EVP_add_cipher_alias(SN_cast5_cbc,"cast");
141 EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
142 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
143#endif
144
145#ifndef NO_RC5
146 EVP_add_cipher(EVP_rc5_32_12_16_ecb());
147 EVP_add_cipher(EVP_rc5_32_12_16_cfb());
148 EVP_add_cipher(EVP_rc5_32_12_16_ofb());
149 EVP_add_cipher(EVP_rc5_32_12_16_cbc());
150 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
151 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
152#endif
153 }
154
155
156void SSLeay_add_all_digests(void)
157 {
158#ifndef NO_MD2
159 EVP_add_digest(EVP_md2());
160#endif
161#ifndef NO_MD5
162 EVP_add_digest(EVP_md5());
163 EVP_add_digest_alias(SN_md5,"ssl2-md5");
164 EVP_add_digest_alias(SN_md5,"ssl3-md5");
165#endif
166#ifndef NO_SHA
167 EVP_add_digest(EVP_sha());
168#ifndef NO_DSA
169 EVP_add_digest(EVP_dss());
170#endif
171#endif
172#ifndef NO_SHA
173 EVP_add_digest(EVP_sha1());
174 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
175 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
176#ifndef NO_DSA
177 EVP_add_digest(EVP_dss1());
178 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
179 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
180 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
181#endif
182#endif
183#if !defined(NO_MDC2) && !defined(NO_DES)
184 EVP_add_digest(EVP_mdc2());
185#endif
186#ifndef NO_RIPEMD
187 EVP_add_digest(EVP_ripemd160());
188 EVP_add_digest_alias(SN_ripemd160,"ripemd");
189 EVP_add_digest_alias(SN_ripemd160,"rmd160");
190#endif
191 PKCS12_PBE_add();
192 PKCS5_PBE_add();
193 }
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c
new file mode 100644
index 0000000000..f24d3756c9
--- /dev/null
+++ b/src/lib/libcrypto/evp/c_allc.c
@@ -0,0 +1,149 @@
1/* crypto/evp/c_allc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_ciphers(void)
66 {
67#ifndef NO_DES
68 EVP_add_cipher(EVP_des_cfb());
69 EVP_add_cipher(EVP_des_ede_cfb());
70 EVP_add_cipher(EVP_des_ede3_cfb());
71
72 EVP_add_cipher(EVP_des_ofb());
73 EVP_add_cipher(EVP_des_ede_ofb());
74 EVP_add_cipher(EVP_des_ede3_ofb());
75
76 EVP_add_cipher(EVP_desx_cbc());
77 EVP_add_cipher_alias(SN_desx_cbc,"DESX");
78 EVP_add_cipher_alias(SN_desx_cbc,"desx");
79
80 EVP_add_cipher(EVP_des_cbc());
81 EVP_add_cipher_alias(SN_des_cbc,"DES");
82 EVP_add_cipher_alias(SN_des_cbc,"des");
83 EVP_add_cipher(EVP_des_ede_cbc());
84 EVP_add_cipher(EVP_des_ede3_cbc());
85 EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
86 EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");
87
88 EVP_add_cipher(EVP_des_ecb());
89 EVP_add_cipher(EVP_des_ede());
90 EVP_add_cipher(EVP_des_ede3());
91#endif
92
93#ifndef NO_RC4
94 EVP_add_cipher(EVP_rc4());
95 EVP_add_cipher(EVP_rc4_40());
96#endif
97
98#ifndef NO_IDEA
99 EVP_add_cipher(EVP_idea_ecb());
100 EVP_add_cipher(EVP_idea_cfb());
101 EVP_add_cipher(EVP_idea_ofb());
102 EVP_add_cipher(EVP_idea_cbc());
103 EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
104 EVP_add_cipher_alias(SN_idea_cbc,"idea");
105#endif
106
107#ifndef NO_RC2
108 EVP_add_cipher(EVP_rc2_ecb());
109 EVP_add_cipher(EVP_rc2_cfb());
110 EVP_add_cipher(EVP_rc2_ofb());
111 EVP_add_cipher(EVP_rc2_cbc());
112 EVP_add_cipher(EVP_rc2_40_cbc());
113 EVP_add_cipher(EVP_rc2_64_cbc());
114 EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
115 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
116#endif
117
118#ifndef NO_BF
119 EVP_add_cipher(EVP_bf_ecb());
120 EVP_add_cipher(EVP_bf_cfb());
121 EVP_add_cipher(EVP_bf_ofb());
122 EVP_add_cipher(EVP_bf_cbc());
123 EVP_add_cipher_alias(SN_bf_cbc,"BF");
124 EVP_add_cipher_alias(SN_bf_cbc,"bf");
125 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
126#endif
127
128#ifndef NO_CAST
129 EVP_add_cipher(EVP_cast5_ecb());
130 EVP_add_cipher(EVP_cast5_cfb());
131 EVP_add_cipher(EVP_cast5_ofb());
132 EVP_add_cipher(EVP_cast5_cbc());
133 EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
134 EVP_add_cipher_alias(SN_cast5_cbc,"cast");
135 EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
136 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
137#endif
138
139#ifndef NO_RC5
140 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_ofb());
143 EVP_add_cipher(EVP_rc5_32_12_16_cbc());
144 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
145 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
146#endif
147 PKCS12_PBE_add();
148 PKCS5_PBE_add();
149 }
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c
new file mode 100644
index 0000000000..febe51a3ee
--- /dev/null
+++ b/src/lib/libcrypto/evp/c_alld.c
@@ -0,0 +1,100 @@
1/* crypto/evp/c_alld.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_digests(void)
66 {
67#ifndef NO_MD2
68 EVP_add_digest(EVP_md2());
69#endif
70#ifndef NO_MD5
71 EVP_add_digest(EVP_md5());
72 EVP_add_digest_alias(SN_md5,"ssl2-md5");
73 EVP_add_digest_alias(SN_md5,"ssl3-md5");
74#endif
75#ifndef NO_SHA
76 EVP_add_digest(EVP_sha());
77#ifndef NO_DSA
78 EVP_add_digest(EVP_dss());
79#endif
80#endif
81#ifndef NO_SHA
82 EVP_add_digest(EVP_sha1());
83 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
84 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
85#ifndef NO_DSA
86 EVP_add_digest(EVP_dss1());
87 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
88 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
89 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
90#endif
91#endif
92#if !defined(NO_MDC2) && !defined(NO_DES)
93 EVP_add_digest(EVP_mdc2());
94#endif
95#ifndef NO_RIPEMD
96 EVP_add_digest(EVP_ripemd160());
97 EVP_add_digest_alias(SN_ripemd160,"ripemd");
98 EVP_add_digest_alias(SN_ripemd160,"rmd160");
99#endif
100 }
diff --git a/src/lib/libcrypto/evp/e_cbc_3d.c b/src/lib/libcrypto/evp/e_cbc_3d.c
index 02ccc6dc90..5d16b865c5 100644
--- a/src/lib/libcrypto/evp/e_cbc_3d.c
+++ b/src/lib/libcrypto/evp/e_cbc_3d.c
@@ -115,8 +115,8 @@ static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
115 115
116 if (deskey != NULL) 116 if (deskey != NULL)
117 { 117 {
118 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 118 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
119 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 119 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
120 memcpy( (char *)ctx->c.des_ede.ks3, 120 memcpy( (char *)ctx->c.des_ede.ks3,
121 (char *)ctx->c.des_ede.ks1, 121 (char *)ctx->c.des_ede.ks1,
122 sizeof(ctx->c.des_ede.ks1)); 122 sizeof(ctx->c.des_ede.ks1));
@@ -134,9 +134,9 @@ static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
134 134
135 if (deskey != NULL) 135 if (deskey != NULL)
136 { 136 {
137 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 137 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
138 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 138 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
139 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 139 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
140 } 140 }
141 } 141 }
142 142
diff --git a/src/lib/libcrypto/evp/e_cbc_d.c b/src/lib/libcrypto/evp/e_cbc_d.c
index 9203f3f52d..5b4e5b8601 100644
--- a/src/lib/libcrypto/evp/e_cbc_d.c
+++ b/src/lib/libcrypto/evp/e_cbc_d.c
@@ -93,7 +93,7 @@ static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
93 memcpy(&(ctx->oiv[0]),iv,8); 93 memcpy(&(ctx->oiv[0]),iv,8);
94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
95 if (deskey != NULL) 95 if (deskey != NULL)
96 des_set_key(deskey,ctx->c.des_ks); 96 des_set_key_unchecked(deskey,ctx->c.des_ks);
97 } 97 }
98 98
99static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 99static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libcrypto/evp/e_cfb_3d.c b/src/lib/libcrypto/evp/e_cfb_3d.c
index bd32b072e2..b364bd4e31 100644
--- a/src/lib/libcrypto/evp/e_cfb_3d.c
+++ b/src/lib/libcrypto/evp/e_cfb_3d.c
@@ -116,8 +116,8 @@ static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
117 if (deskey != NULL) 117 if (deskey != NULL)
118 { 118 {
119 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 119 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
120 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 120 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
121 memcpy( (char *)ctx->c.des_ede.ks3, 121 memcpy( (char *)ctx->c.des_ede.ks3,
122 (char *)ctx->c.des_ede.ks1, 122 (char *)ctx->c.des_ede.ks1,
123 sizeof(ctx->c.des_ede.ks1)); 123 sizeof(ctx->c.des_ede.ks1));
@@ -136,9 +136,9 @@ static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
137 if (deskey != NULL) 137 if (deskey != NULL)
138 { 138 {
139 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 139 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
140 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 140 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
141 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 141 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
142 } 142 }
143 } 143 }
144 144
diff --git a/src/lib/libcrypto/evp/e_cfb_d.c b/src/lib/libcrypto/evp/e_cfb_d.c
index 6bdf20b646..9e1714bd15 100644
--- a/src/lib/libcrypto/evp/e_cfb_d.c
+++ b/src/lib/libcrypto/evp/e_cfb_d.c
@@ -95,7 +95,7 @@ static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
95 memcpy(&(ctx->oiv[0]),iv,8); 95 memcpy(&(ctx->oiv[0]),iv,8);
96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
97 if (deskey != NULL) 97 if (deskey != NULL)
98 des_set_key(deskey,ctx->c.des_ks); 98 des_set_key_unchecked(deskey,ctx->c.des_ks);
99 } 99 }
100 100
101static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 101static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libcrypto/evp/e_ecb_3d.c b/src/lib/libcrypto/evp/e_ecb_3d.c
index 354a8b79a7..806e971d36 100644
--- a/src/lib/libcrypto/evp/e_ecb_3d.c
+++ b/src/lib/libcrypto/evp/e_ecb_3d.c
@@ -110,8 +110,8 @@ static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
110 110
111 if (deskey != NULL) 111 if (deskey != NULL)
112 { 112 {
113 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 113 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
114 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 114 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
115 memcpy( (char *)ctx->c.des_ede.ks3, 115 memcpy( (char *)ctx->c.des_ede.ks3,
116 (char *)ctx->c.des_ede.ks1, 116 (char *)ctx->c.des_ede.ks1,
117 sizeof(ctx->c.des_ede.ks1)); 117 sizeof(ctx->c.des_ede.ks1));
@@ -125,9 +125,9 @@ static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
125 125
126 if (deskey != NULL) 126 if (deskey != NULL)
127 { 127 {
128 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 128 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
129 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 129 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
130 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 130 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
131 } 131 }
132 } 132 }
133 133
diff --git a/src/lib/libcrypto/evp/e_ecb_d.c b/src/lib/libcrypto/evp/e_ecb_d.c
index 5fb4e64b1c..c11bef55ef 100644
--- a/src/lib/libcrypto/evp/e_ecb_d.c
+++ b/src/lib/libcrypto/evp/e_ecb_d.c
@@ -90,7 +90,7 @@ static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
90 des_cblock *deskey = (des_cblock *)key; 90 des_cblock *deskey = (des_cblock *)key;
91 91
92 if (deskey != NULL) 92 if (deskey != NULL)
93 des_set_key(deskey,ctx->c.des_ks); 93 des_set_key_unchecked(deskey,ctx->c.des_ks);
94 } 94 }
95 95
96static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 96static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libcrypto/evp/e_ofb_3d.c b/src/lib/libcrypto/evp/e_ofb_3d.c
index 5233567c0c..d1a33e2ecd 100644
--- a/src/lib/libcrypto/evp/e_ofb_3d.c
+++ b/src/lib/libcrypto/evp/e_ofb_3d.c
@@ -116,8 +116,8 @@ static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
117 if (deskey != NULL) 117 if (deskey != NULL)
118 { 118 {
119 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 119 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
120 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 120 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
121 memcpy( (char *)ctx->c.des_ede.ks3, 121 memcpy( (char *)ctx->c.des_ede.ks3,
122 (char *)ctx->c.des_ede.ks1, 122 (char *)ctx->c.des_ede.ks1,
123 sizeof(ctx->c.des_ede.ks1)); 123 sizeof(ctx->c.des_ede.ks1));
@@ -136,9 +136,9 @@ static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
137 if (deskey != NULL) 137 if (deskey != NULL)
138 { 138 {
139 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 139 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
140 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 140 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
141 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 141 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
142 } 142 }
143 } 143 }
144 144
diff --git a/src/lib/libcrypto/evp/e_ofb_d.c b/src/lib/libcrypto/evp/e_ofb_d.c
index 398b3a002e..d51ce230f4 100644
--- a/src/lib/libcrypto/evp/e_ofb_d.c
+++ b/src/lib/libcrypto/evp/e_ofb_d.c
@@ -95,7 +95,7 @@ static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
95 memcpy(&(ctx->oiv[0]),iv,8); 95 memcpy(&(ctx->oiv[0]),iv,8);
96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
97 if (deskey != NULL) 97 if (deskey != NULL)
98 des_set_key(deskey,ctx->c.des_ks); 98 des_set_key_unchecked(deskey,ctx->c.des_ks);
99 } 99 }
100 100
101static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 101static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c
index 3a6628a75c..7568fad4ff 100644
--- a/src/lib/libcrypto/evp/e_xcbc_d.c
+++ b/src/lib/libcrypto/evp/e_xcbc_d.c
@@ -94,7 +94,7 @@ static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
95 if (deskey != NULL) 95 if (deskey != NULL)
96 { 96 {
97 des_set_key(deskey,ctx->c.desx_cbc.ks); 97 des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks);
98 memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); 98 memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8);
99 memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); 99 memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8);
100 } 100 }
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 0152624a76..14a4cb11f6 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -185,7 +185,7 @@ void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
185 *outl=ret; 185 *outl=ret;
186 } 186 }
187 187
188int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen) 188int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int dlen)
189 { 189 {
190 int i,ret=0; 190 int i,ret=0;
191 unsigned long l; 191 unsigned long l;
@@ -337,7 +337,7 @@ end:
337 return(rv); 337 return(rv);
338 } 338 }
339 339
340int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n) 340int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n)
341 { 341 {
342 int i,ret=0,a,b,c,d; 342 int i,ret=0,a,b,c,d;
343 unsigned long l; 343 unsigned long l;
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 570fe27d39..54215b0905 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -149,7 +149,7 @@ extern "C" {
149 149
150/* Type needs to be a bit field 150/* Type needs to be a bit field
151 * Sub-type needs to be for variations on the method, as in, can it do 151 * Sub-type needs to be for variations on the method, as in, can it do
152 * arbitary encryption.... */ 152 * arbitrary encryption.... */
153typedef struct evp_pkey_st 153typedef struct evp_pkey_st
154 { 154 {
155 int type; 155 int type;
@@ -343,7 +343,7 @@ typedef struct evp_cipher_ctx_st
343 unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */ 343 unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */
344 int num; /* used by cfb/ofb mode */ 344 int num; /* used by cfb/ofb mode */
345 345
346 char *app_data; /* aplication stuff */ 346 char *app_data; /* application stuff */
347 union { 347 union {
348#ifndef NO_RC4 348#ifndef NO_RC4
349 struct 349 struct
@@ -421,9 +421,10 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
421#define EVP_MD_size(e) ((e)->md_size) 421#define EVP_MD_size(e) ((e)->md_size)
422#define EVP_MD_block_size(e) ((e)->block_size) 422#define EVP_MD_block_size(e) ((e)->block_size)
423 423
424#define EVP_MD_CTX_md(e) ((e)->digest)
424#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) 425#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
425#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) 426#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
426#define EVP_MD_CTX_type(e) ((e)->digest) 427#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
427 428
428#define EVP_CIPHER_nid(e) ((e)->nid) 429#define EVP_CIPHER_nid(e) ((e)->nid)
429#define EVP_CIPHER_block_size(e) ((e)->block_size) 430#define EVP_CIPHER_block_size(e) ((e)->block_size)
@@ -521,15 +522,14 @@ void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
521void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, 522void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,
522 int *outl,unsigned char *in,int inl); 523 int *outl,unsigned char *in,int inl);
523void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); 524void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
524int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int n); 525int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
525 526
526void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); 527void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
527int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, 528int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
528 unsigned char *in, int inl); 529 unsigned char *in, int inl);
529int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned 530int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
530 char *out, int *outl); 531 char *out, int *outl);
531int EVP_DecodeBlock(unsigned char *t, unsigned 532int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
532 char *f, int n);
533 533
534void ERR_load_EVP_strings(void ); 534void ERR_load_EVP_strings(void );
535 535
@@ -594,9 +594,12 @@ EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
594EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); 594EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
595EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); 595EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
596 596
597void SSLeay_add_all_algorithms(void); 597void OpenSSL_add_all_algorithms(void);
598void SSLeay_add_all_ciphers(void); 598void OpenSSL_add_all_ciphers(void);
599void SSLeay_add_all_digests(void); 599void OpenSSL_add_all_digests(void);
600#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
601#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
602#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
600 603
601int EVP_add_cipher(EVP_CIPHER *cipher); 604int EVP_add_cipher(EVP_CIPHER *cipher);
602int EVP_add_digest(EVP_MD *digest); 605int EVP_add_digest(EVP_MD *digest);
@@ -613,6 +616,18 @@ int EVP_PKEY_type(int type);
613int EVP_PKEY_bits(EVP_PKEY *pkey); 616int EVP_PKEY_bits(EVP_PKEY *pkey);
614int EVP_PKEY_size(EVP_PKEY *pkey); 617int EVP_PKEY_size(EVP_PKEY *pkey);
615int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); 618int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
619#ifndef NO_RSA
620int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key);
621RSA * EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
622#endif
623#ifndef NO_DSA
624int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key);
625DSA * EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
626#endif
627#ifndef NO_DH
628int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key);
629DH * EVP_PKEY_get1_DH(EVP_PKEY *pkey);
630#endif
616EVP_PKEY * EVP_PKEY_new(void); 631EVP_PKEY * EVP_PKEY_new(void);
617void EVP_PKEY_free(EVP_PKEY *pkey); 632void EVP_PKEY_free(EVP_PKEY *pkey);
618EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, 633EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp,
@@ -621,6 +636,8 @@ int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
621 636
622EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp, 637EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp,
623 long length); 638 long length);
639EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
640 long length);
624int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); 641int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
625 642
626int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from); 643int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from);
@@ -677,6 +694,9 @@ void EVP_PBE_cleanup(void);
677#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 694#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
678#define EVP_F_EVP_PKEY_DECRYPT 104 695#define EVP_F_EVP_PKEY_DECRYPT 104
679#define EVP_F_EVP_PKEY_ENCRYPT 105 696#define EVP_F_EVP_PKEY_ENCRYPT 105
697#define EVP_F_EVP_PKEY_GET1_DH 119
698#define EVP_F_EVP_PKEY_GET1_DSA 120
699#define EVP_F_EVP_PKEY_GET1_RSA 121
680#define EVP_F_EVP_PKEY_NEW 106 700#define EVP_F_EVP_PKEY_NEW 106
681#define EVP_F_EVP_SIGNFINAL 107 701#define EVP_F_EVP_SIGNFINAL 107
682#define EVP_F_EVP_VERIFYFINAL 108 702#define EVP_F_EVP_VERIFYFINAL 108
@@ -693,10 +713,13 @@ void EVP_PBE_cleanup(void);
693#define EVP_R_DIFFERENT_KEY_TYPES 101 713#define EVP_R_DIFFERENT_KEY_TYPES 101
694#define EVP_R_ENCODE_ERROR 115 714#define EVP_R_ENCODE_ERROR 115
695#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 715#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
716#define EVP_R_EXPECTING_AN_RSA_KEY 127
717#define EVP_R_EXPECTING_A_DH_KEY 128
718#define EVP_R_EXPECTING_A_DSA_KEY 129
696#define EVP_R_INPUT_NOT_INITIALIZED 111 719#define EVP_R_INPUT_NOT_INITIALIZED 111
697#define EVP_R_IV_TOO_LARGE 102 720#define EVP_R_IV_TOO_LARGE 102
698#define EVP_R_KEYGEN_FAILURE 120 721#define EVP_R_KEYGEN_FAILURE 120
699#define EVP_R_MISSING_PARMATERS 103 722#define EVP_R_MISSING_PARAMETERS 103
700#define EVP_R_NO_DSA_PARAMETERS 116 723#define EVP_R_NO_DSA_PARAMETERS 116
701#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 724#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
702#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 725#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c
index c61cc922e8..97953a0fc1 100644
--- a/src/lib/libcrypto/evp/evp_err.c
+++ b/src/lib/libcrypto/evp/evp_err.c
@@ -77,6 +77,9 @@ static ERR_STRING_DATA EVP_str_functs[]=
77{ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"}, 77{ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"},
78{ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"}, 78{ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"},
79{ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"}, 79{ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"},
80{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DH,0), "EVP_PKEY_get1_DH"},
81{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DSA,0), "EVP_PKEY_get1_DSA"},
82{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_RSA,0), "EVP_PKEY_get1_RSA"},
80{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"}, 83{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"},
81{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"}, 84{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"},
82{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"}, 85{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"},
@@ -96,10 +99,13 @@ static ERR_STRING_DATA EVP_str_reasons[]=
96{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"}, 99{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"},
97{EVP_R_ENCODE_ERROR ,"encode error"}, 100{EVP_R_ENCODE_ERROR ,"encode error"},
98{EVP_R_EVP_PBE_CIPHERINIT_ERROR ,"evp pbe cipherinit error"}, 101{EVP_R_EVP_PBE_CIPHERINIT_ERROR ,"evp pbe cipherinit error"},
102{EVP_R_EXPECTING_AN_RSA_KEY ,"expecting an rsa key"},
103{EVP_R_EXPECTING_A_DH_KEY ,"expecting a dh key"},
104{EVP_R_EXPECTING_A_DSA_KEY ,"expecting a dsa key"},
99{EVP_R_INPUT_NOT_INITIALIZED ,"input not initialized"}, 105{EVP_R_INPUT_NOT_INITIALIZED ,"input not initialized"},
100{EVP_R_IV_TOO_LARGE ,"iv too large"}, 106{EVP_R_IV_TOO_LARGE ,"iv too large"},
101{EVP_R_KEYGEN_FAILURE ,"keygen failure"}, 107{EVP_R_KEYGEN_FAILURE ,"keygen failure"},
102{EVP_R_MISSING_PARMATERS ,"missing parmaters"}, 108{EVP_R_MISSING_PARAMETERS ,"missing parameters"},
103{EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"}, 109{EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"},
104{EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"}, 110{EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"},
105{EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"}, 111{EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"},
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index 21eda418bc..667c21cca8 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -81,15 +81,18 @@ char *EVP_get_pw_prompt(void)
81 return(prompt_string); 81 return(prompt_string);
82 } 82 }
83 83
84#ifdef NO_DES 84/* For historical reasons, the standard function for reading passwords is
85int des_read_pw_string(char *buf,int len,const char *prompt,int verify); 85 * in the DES library -- if someone ever wants to disable DES,
86#endif 86 * this function will fail */
87
88int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) 87int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
89 { 88 {
89#ifndef NO_DES
90 if ((prompt == NULL) && (prompt_string[0] != '\0')) 90 if ((prompt == NULL) && (prompt_string[0] != '\0'))
91 prompt=prompt_string; 91 prompt=prompt_string;
92 return(des_read_pw_string(buf,len,prompt,verify)); 92 return(des_read_pw_string(buf,len,prompt,verify));
93#else
94 return -1;
95#endif
93 } 96 }
94 97
95int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt, 98int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt,
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index 3f9bf55828..a431945ef5 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -115,6 +115,7 @@ int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
115int EVP_CIPHER_type(const EVP_CIPHER *ctx) 115int EVP_CIPHER_type(const EVP_CIPHER *ctx)
116{ 116{
117 int nid; 117 int nid;
118 ASN1_OBJECT *otmp;
118 nid = EVP_CIPHER_nid(ctx); 119 nid = EVP_CIPHER_nid(ctx);
119 120
120 switch(nid) { 121 switch(nid) {
@@ -131,7 +132,10 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx)
131 return NID_rc4; 132 return NID_rc4;
132 133
133 default: 134 default:
134 135 /* Check it has an OID and it is valid */
136 otmp = OBJ_nid2obj(nid);
137 if(!otmp || !otmp->data) nid = NID_undef;
138 ASN1_OBJECT_free(otmp);
135 return nid; 139 return nid;
136 } 140 }
137} 141}
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index 421e452db1..d5e6f5880f 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -62,19 +62,22 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey);
66
65/* Extract a private key from a PKCS8 structure */ 67/* Extract a private key from a PKCS8 structure */
66 68
67EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) 69EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
68{ 70{
69 EVP_PKEY *pkey; 71 EVP_PKEY *pkey = NULL;
70#ifndef NO_RSA 72#ifndef NO_RSA
71 RSA *rsa; 73 RSA *rsa = NULL;
72#endif 74#endif
73#ifndef NO_DSA 75#ifndef NO_DSA
74 DSA *dsa; 76 DSA *dsa = NULL;
75 ASN1_INTEGER *dsapriv; 77 ASN1_INTEGER *privkey;
76 STACK *ndsa; 78 ASN1_TYPE *t1, *t2, *param = NULL;
77 BN_CTX *ctx; 79 STACK *ndsa = NULL;
80 BN_CTX *ctx = NULL;
78 int plen; 81 int plen;
79#endif 82#endif
80 X509_ALGOR *a; 83 X509_ALGOR *a;
@@ -82,21 +85,14 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
82 int pkeylen; 85 int pkeylen;
83 char obj_tmp[80]; 86 char obj_tmp[80];
84 87
85 switch (p8->broken) { 88 if(p8->pkey->type == V_ASN1_OCTET_STRING) {
86 case PKCS8_OK: 89 p8->broken = PKCS8_OK;
87 p = p8->pkey->value.octet_string->data; 90 p = p8->pkey->value.octet_string->data;
88 pkeylen = p8->pkey->value.octet_string->length; 91 pkeylen = p8->pkey->value.octet_string->length;
89 break; 92 } else {
90 93 p8->broken = PKCS8_NO_OCTET;
91 case PKCS8_NO_OCTET:
92 p = p8->pkey->value.sequence->data; 94 p = p8->pkey->value.sequence->data;
93 pkeylen = p8->pkey->value.sequence->length; 95 pkeylen = p8->pkey->value.sequence->length;
94 break;
95
96 default:
97 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE);
98 return NULL;
99 break;
100 } 96 }
101 if (!(pkey = EVP_PKEY_new())) { 97 if (!(pkey = EVP_PKEY_new())) {
102 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 98 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
@@ -121,65 +117,83 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
121 * be recalculated. 117 * be recalculated.
122 */ 118 */
123 119
124 /* Check for broken Netscape Database DSA PKCS#8, UGH! */ 120 /* Check for broken DSA PKCS#8, UGH! */
125 if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { 121 if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) {
126 if(!(ndsa = ASN1_seq_unpack(p, pkeylen, 122 if(!(ndsa = ASN1_seq_unpack(p, pkeylen,
127 (char *(*)())d2i_ASN1_INTEGER, 123 (char *(*)())d2i_ASN1_TYPE,
128 ASN1_STRING_free))) { 124 ASN1_TYPE_free))) {
129 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 125 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
130 return NULL; 126 goto dsaerr;
131 } 127 }
132 if(sk_num(ndsa) != 2 ) { 128 if(sk_num(ndsa) != 2 ) {
133 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 129 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
134 sk_pop_free(ndsa, ASN1_STRING_free); 130 goto dsaerr;
135 return NULL;
136 } 131 }
137 dsapriv = (ASN1_INTEGER *) sk_pop(ndsa); 132 /* Handle Two broken types:
138 sk_pop_free(ndsa, ASN1_STRING_free); 133 * SEQUENCE {parameters, priv_key}
139 } else if (!(dsapriv=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) { 134 * SEQUENCE {pub_key, priv_key}
135 */
136
137 t1 = (ASN1_TYPE *)sk_value(ndsa, 0);
138 t2 = (ASN1_TYPE *)sk_value(ndsa, 1);
139 if(t1->type == V_ASN1_SEQUENCE) {
140 p8->broken = PKCS8_EMBEDDED_PARAM;
141 param = t1;
142 } else if(a->parameter->type == V_ASN1_SEQUENCE) {
143 p8->broken = PKCS8_NS_DB;
144 param = a->parameter;
145 } else {
140 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 146 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
141 return NULL; 147 goto dsaerr;
142 } 148 }
143 /* Retrieve parameters */ 149
144 if (a->parameter->type != V_ASN1_SEQUENCE) { 150 if(t2->type != V_ASN1_INTEGER) {
145 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_NO_DSA_PARAMETERS); 151 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
146 return NULL; 152 goto dsaerr;
153 }
154 privkey = t2->value.integer;
155 } else if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) {
156 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
157 goto dsaerr;
147 } 158 }
148 p = a->parameter->value.sequence->data; 159 p = param->value.sequence->data;
149 plen = a->parameter->value.sequence->length; 160 plen = param->value.sequence->length;
150 if (!(dsa = d2i_DSAparams (NULL, &p, plen))) { 161 if (!(dsa = d2i_DSAparams (NULL, &p, plen))) {
151 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 162 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
152 return NULL; 163 goto dsaerr;
153 } 164 }
154 /* We have parameters now set private key */ 165 /* We have parameters now set private key */
155 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(dsapriv, NULL))) { 166 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
156 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR); 167 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR);
157 DSA_free (dsa); 168 goto dsaerr;
158 return NULL;
159 } 169 }
160 /* Calculate public key (ouch!) */ 170 /* Calculate public key (ouch!) */
161 if (!(dsa->pub_key = BN_new())) { 171 if (!(dsa->pub_key = BN_new())) {
162 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 172 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
163 DSA_free (dsa); 173 goto dsaerr;
164 return NULL;
165 } 174 }
166 if (!(ctx = BN_CTX_new())) { 175 if (!(ctx = BN_CTX_new())) {
167 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 176 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
168 DSA_free (dsa); 177 goto dsaerr;
169 return NULL;
170 } 178 }
171 179
172 if (!BN_mod_exp(dsa->pub_key, dsa->g, 180 if (!BN_mod_exp(dsa->pub_key, dsa->g,
173 dsa->priv_key, dsa->p, ctx)) { 181 dsa->priv_key, dsa->p, ctx)) {
174 182
175 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR); 183 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR);
176 BN_CTX_free (ctx); 184 goto dsaerr;
177 DSA_free (dsa);
178 return NULL;
179 } 185 }
180 186
181 EVP_PKEY_assign_DSA (pkey, dsa); 187 EVP_PKEY_assign_DSA(pkey, dsa);
182 BN_CTX_free (ctx); 188 BN_CTX_free (ctx);
189 sk_pop_free(ndsa, ASN1_TYPE_free);
190 break;
191 dsaerr:
192 BN_CTX_free (ctx);
193 sk_pop_free(ndsa, ASN1_TYPE_free);
194 DSA_free(dsa);
195 EVP_PKEY_free(pkey);
196 return NULL;
183 break; 197 break;
184#endif 198#endif
185 default: 199 default:
@@ -193,30 +207,35 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
193 return pkey; 207 return pkey;
194} 208}
195 209
210PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
211{
212 return EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK);
213}
214
196/* Turn a private key into a PKCS8 structure */ 215/* Turn a private key into a PKCS8 structure */
197 216
198PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey) 217PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken)
199{ 218{
200 PKCS8_PRIV_KEY_INFO *p8; 219 PKCS8_PRIV_KEY_INFO *p8;
201#ifndef NO_DSA 220
202 ASN1_INTEGER *dpkey;
203 unsigned char *p, *q;
204 int len;
205#endif
206 if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) { 221 if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) {
207 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); 222 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
208 return NULL; 223 return NULL;
209 } 224 }
225 p8->broken = broken;
210 ASN1_INTEGER_set (p8->version, 0); 226 ASN1_INTEGER_set (p8->version, 0);
211 if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) { 227 if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) {
212 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); 228 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
213 PKCS8_PRIV_KEY_INFO_free (p8); 229 PKCS8_PRIV_KEY_INFO_free (p8);
214 return NULL; 230 return NULL;
215 } 231 }
232 p8->pkey->type = V_ASN1_OCTET_STRING;
216 switch (EVP_PKEY_type(pkey->type)) { 233 switch (EVP_PKEY_type(pkey->type)) {
217#ifndef NO_RSA 234#ifndef NO_RSA
218 case EVP_PKEY_RSA: 235 case EVP_PKEY_RSA:
219 236
237 if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE;
238
220 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption); 239 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption);
221 p8->pkeyalg->parameter->type = V_ASN1_NULL; 240 p8->pkeyalg->parameter->type = V_ASN1_NULL;
222 if (!ASN1_pack_string ((char *)pkey, i2d_PrivateKey, 241 if (!ASN1_pack_string ((char *)pkey, i2d_PrivateKey,
@@ -229,36 +248,11 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
229#endif 248#endif
230#ifndef NO_DSA 249#ifndef NO_DSA
231 case EVP_PKEY_DSA: 250 case EVP_PKEY_DSA:
232 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa); 251 if(!dsa_pkey2pkcs8(p8, pkey)) {
233
234 /* get paramaters and place in AlgorithmIdentifier */
235 len = i2d_DSAparams (pkey->pkey.dsa, NULL);
236 if (!(p = Malloc(len))) {
237 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
238 PKCS8_PRIV_KEY_INFO_free (p8); 252 PKCS8_PRIV_KEY_INFO_free (p8);
239 return NULL; 253 return NULL;
240 } 254 }
241 q = p; 255
242 i2d_DSAparams (pkey->pkey.dsa, &q);
243 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
244 p8->pkeyalg->parameter->value.sequence = ASN1_STRING_new();
245 ASN1_STRING_set(p8->pkeyalg->parameter->value.sequence, p, len);
246 Free(p);
247 /* Get private key into an integer and pack */
248 if (!(dpkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) {
249 EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
250 PKCS8_PRIV_KEY_INFO_free (p8);
251 return NULL;
252 }
253
254 if (!ASN1_pack_string((char *)dpkey, i2d_ASN1_INTEGER,
255 &p8->pkey->value.octet_string)) {
256 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
257 ASN1_INTEGER_free (dpkey);
258 PKCS8_PRIV_KEY_INFO_free (p8);
259 return NULL;
260 }
261 ASN1_INTEGER_free (dpkey);
262 break; 256 break;
263#endif 257#endif
264 default: 258 default:
@@ -266,9 +260,8 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
266 PKCS8_PRIV_KEY_INFO_free (p8); 260 PKCS8_PRIV_KEY_INFO_free (p8);
267 return NULL; 261 return NULL;
268 } 262 }
269 p8->pkey->type = V_ASN1_OCTET_STRING; 263 RAND_add(p8->pkey->value.octet_string->data,
270 RAND_seed (p8->pkey->value.octet_string->data, 264 p8->pkey->value.octet_string->length, 0);
271 p8->pkey->value.octet_string->length);
272 return p8; 265 return p8;
273} 266}
274 267
@@ -295,4 +288,112 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken)
295 } 288 }
296} 289}
297 290
291#ifndef NO_DSA
292static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey)
293{
294 ASN1_STRING *params;
295 ASN1_INTEGER *prkey;
296 ASN1_TYPE *ttmp;
297 STACK *ndsa;
298 unsigned char *p, *q;
299 int len;
300 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa);
301 len = i2d_DSAparams (pkey->pkey.dsa, NULL);
302 if (!(p = Malloc(len))) {
303 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
304 PKCS8_PRIV_KEY_INFO_free (p8);
305 return 0;
306 }
307 q = p;
308 i2d_DSAparams (pkey->pkey.dsa, &q);
309 params = ASN1_STRING_new();
310 ASN1_STRING_set(params, p, len);
311 Free(p);
312 /* Get private key into integer */
313 if (!(prkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) {
314 EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
315 return 0;
316 }
317
318 switch(p8->broken) {
298 319
320 case PKCS8_OK:
321 case PKCS8_NO_OCTET:
322
323 if (!ASN1_pack_string((char *)prkey, i2d_ASN1_INTEGER,
324 &p8->pkey->value.octet_string)) {
325 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
326 M_ASN1_INTEGER_free (prkey);
327 return 0;
328 }
329
330 M_ASN1_INTEGER_free (prkey);
331 p8->pkeyalg->parameter->value.sequence = params;
332 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
333
334 break;
335
336 case PKCS8_NS_DB:
337
338 p8->pkeyalg->parameter->value.sequence = params;
339 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
340 ndsa = sk_new_null();
341 ttmp = ASN1_TYPE_new();
342 if (!(ttmp->value.integer = BN_to_ASN1_INTEGER (pkey->pkey.dsa->pub_key, NULL))) {
343 EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
344 PKCS8_PRIV_KEY_INFO_free(p8);
345 return 0;
346 }
347 ttmp->type = V_ASN1_INTEGER;
348 sk_push(ndsa, (char *)ttmp);
349
350 ttmp = ASN1_TYPE_new();
351 ttmp->value.integer = prkey;
352 ttmp->type = V_ASN1_INTEGER;
353 sk_push(ndsa, (char *)ttmp);
354
355 p8->pkey->value.octet_string = ASN1_OCTET_STRING_new();
356
357 if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE,
358 &p8->pkey->value.octet_string->data,
359 &p8->pkey->value.octet_string->length)) {
360
361 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
362 sk_pop_free(ndsa, ASN1_TYPE_free);
363 M_ASN1_INTEGER_free(prkey);
364 return 0;
365 }
366 sk_pop_free(ndsa, ASN1_TYPE_free);
367 break;
368
369 case PKCS8_EMBEDDED_PARAM:
370
371 p8->pkeyalg->parameter->type = V_ASN1_NULL;
372 ndsa = sk_new_null();
373 ttmp = ASN1_TYPE_new();
374 ttmp->value.sequence = params;
375 ttmp->type = V_ASN1_SEQUENCE;
376 sk_push(ndsa, (char *)ttmp);
377
378 ttmp = ASN1_TYPE_new();
379 ttmp->value.integer = prkey;
380 ttmp->type = V_ASN1_INTEGER;
381 sk_push(ndsa, (char *)ttmp);
382
383 p8->pkey->value.octet_string = ASN1_OCTET_STRING_new();
384
385 if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE,
386 &p8->pkey->value.octet_string->data,
387 &p8->pkey->value.octet_string->length)) {
388
389 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
390 sk_pop_free(ndsa, ASN1_TYPE_free);
391 M_ASN1_INTEGER_free (prkey);
392 return 0;
393 }
394 sk_pop_free(ndsa, ASN1_TYPE_free);
395 break;
396 }
397 return 1;
398}
399#endif
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index 3422b77de6..4cb387f8de 100644
--- a/src/lib/libcrypto/evp/p_lib.c
+++ b/src/lib/libcrypto/evp/p_lib.c
@@ -119,7 +119,7 @@ int EVP_PKEY_copy_parameters(EVP_PKEY *to, EVP_PKEY *from)
119 119
120 if (EVP_PKEY_missing_parameters(from)) 120 if (EVP_PKEY_missing_parameters(from))
121 { 121 {
122 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARMATERS); 122 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS);
123 goto err; 123 goto err;
124 } 124 }
125#ifndef NO_DSA 125#ifndef NO_DSA
@@ -202,8 +202,66 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)
202 pkey->type=EVP_PKEY_type(type); 202 pkey->type=EVP_PKEY_type(type);
203 pkey->save_type=type; 203 pkey->save_type=type;
204 pkey->pkey.ptr=key; 204 pkey->pkey.ptr=key;
205 return(1); 205 return(key != NULL);
206 }
207
208#ifndef NO_RSA
209int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
210{
211 int ret = EVP_PKEY_assign_RSA(pkey, key);
212 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_RSA);
213 return ret;
214}
215
216RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
217 {
218 if(pkey->type != EVP_PKEY_RSA) {
219 EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
220 return NULL;
221 }
222 CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_RSA);
223 return pkey->pkey.rsa;
224}
225#endif
226
227#ifndef NO_DSA
228int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
229{
230 int ret = EVP_PKEY_assign_DSA(pkey, key);
231 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DSA);
232 return ret;
233}
234
235DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
236 {
237 if(pkey->type != EVP_PKEY_DSA) {
238 EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY);
239 return NULL;
240 }
241 CRYPTO_add(&pkey->pkey.dsa->references, 1, CRYPTO_LOCK_DSA);
242 return pkey->pkey.dsa;
243}
244#endif
245
246#ifndef NO_DH
247
248int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
249{
250 int ret = EVP_PKEY_assign_DH(pkey, key);
251 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DH);
252 return ret;
253}
254
255DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
256 {
257 if(pkey->type != EVP_PKEY_DH) {
258 EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY);
259 return NULL;
206 } 260 }
261 CRYPTO_add(&pkey->pkey.dh->references, 1, CRYPTO_LOCK_DH);
262 return pkey->pkey.dh;
263}
264#endif
207 265
208int EVP_PKEY_type(int type) 266int EVP_PKEY_type(int type)
209 { 267 {
@@ -244,7 +302,7 @@ void EVP_PKEY_free(EVP_PKEY *x)
244 } 302 }
245#endif 303#endif
246 EVP_PKEY_free_it(x); 304 EVP_PKEY_free_it(x);
247 Free((char *)x); 305 Free(x);
248 } 306 }
249 307
250static void EVP_PKEY_free_it(EVP_PKEY *x) 308static void EVP_PKEY_free_it(EVP_PKEY *x)
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c
index ddb9fd6942..b9ca7892c2 100644
--- a/src/lib/libcrypto/evp/p_open.c
+++ b/src/lib/libcrypto/evp/p_open.c
@@ -110,4 +110,10 @@ int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
110 EVP_DecryptInit(ctx,NULL,NULL,NULL); 110 EVP_DecryptInit(ctx,NULL,NULL,NULL);
111 return(i); 111 return(i);
112 } 112 }
113#else /* !NO_RSA */
114
115# ifdef PEDANTIC
116static void *dummy=&dummy;
117# endif
118
113#endif 119#endif
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c
index 09b46f4b0e..d449e892bf 100644
--- a/src/lib/libcrypto/evp/p_seal.c
+++ b/src/lib/libcrypto/evp/p_seal.c
@@ -73,9 +73,10 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
73 int i; 73 int i;
74 74
75 if (npubk <= 0) return(0); 75 if (npubk <= 0) return(0);
76 RAND_bytes(key,EVP_MAX_KEY_LENGTH); 76 if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0)
77 return(0);
77 if (type->iv_len > 0) 78 if (type->iv_len > 0)
78 RAND_bytes(iv,type->iv_len); 79 RAND_pseudo_bytes(iv,type->iv_len);
79 80
80 EVP_CIPHER_CTX_init(ctx); 81 EVP_CIPHER_CTX_init(ctx);
81 EVP_EncryptInit(ctx,type,key,iv); 82 EVP_EncryptInit(ctx,type,key,iv);
diff --git a/src/lib/libcrypto/ex_data.c b/src/lib/libcrypto/ex_data.c
index 176574766b..a057dd3b68 100644
--- a/src/lib/libcrypto/ex_data.c
+++ b/src/lib/libcrypto/ex_data.c
@@ -63,15 +63,15 @@
63#include <openssl/lhash.h> 63#include <openssl/lhash.h>
64#include "cryptlib.h" 64#include "cryptlib.h"
65 65
66int CRYPTO_get_ex_new_index(int idx, STACK **skp, long argl, char *argp, 66int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
67 int (*new_func)(), int (*dup_func)(), void (*free_func)()) 67 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
68 { 68 {
69 int ret= -1; 69 int ret= -1;
70 CRYPTO_EX_DATA_FUNCS *a; 70 CRYPTO_EX_DATA_FUNCS *a;
71 71
72 MemCheck_off(); 72 MemCheck_off();
73 if (*skp == NULL) 73 if (*skp == NULL)
74 *skp=sk_new_null(); 74 *skp=sk_CRYPTO_EX_DATA_FUNCS_new_null();
75 if (*skp == NULL) 75 if (*skp == NULL)
76 { 76 {
77 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 77 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
@@ -88,23 +88,23 @@ int CRYPTO_get_ex_new_index(int idx, STACK **skp, long argl, char *argp,
88 a->new_func=new_func; 88 a->new_func=new_func;
89 a->dup_func=dup_func; 89 a->dup_func=dup_func;
90 a->free_func=free_func; 90 a->free_func=free_func;
91 while (sk_num(*skp) <= idx) 91 while (sk_CRYPTO_EX_DATA_FUNCS_num(*skp) <= idx)
92 { 92 {
93 if (!sk_push(*skp,NULL)) 93 if (!sk_CRYPTO_EX_DATA_FUNCS_push(*skp,NULL))
94 { 94 {
95 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 95 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
96 Free(a); 96 Free(a);
97 goto err; 97 goto err;
98 } 98 }
99 } 99 }
100 sk_set(*skp,idx, (char *)a); 100 sk_CRYPTO_EX_DATA_FUNCS_set(*skp,idx, a);
101 ret=idx; 101 ret=idx;
102err: 102err:
103 MemCheck_on(); 103 MemCheck_on();
104 return(idx); 104 return(idx);
105 } 105 }
106 106
107int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, char *val) 107int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
108 { 108 {
109 int i; 109 int i;
110 110
@@ -131,7 +131,7 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, char *val)
131 return(1); 131 return(1);
132 } 132 }
133 133
134char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx) 134void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx)
135 { 135 {
136 if (ad->sk == NULL) 136 if (ad->sk == NULL)
137 return(0); 137 return(0);
@@ -145,7 +145,7 @@ char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx)
145 * being duplicated, a pointer to the 145 * being duplicated, a pointer to the
146 * 'new' object to be inserted, the index, and the argi/argp 146 * 'new' object to be inserted, the index, and the argi/argp
147 */ 147 */
148int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to, 148int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to,
149 CRYPTO_EX_DATA *from) 149 CRYPTO_EX_DATA *from)
150 { 150 {
151 int i,j,m,r; 151 int i,j,m,r;
@@ -154,14 +154,14 @@ int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to,
154 154
155 if (meth == NULL) return(1); 155 if (meth == NULL) return(1);
156 if (from->sk == NULL) return(1); 156 if (from->sk == NULL) return(1);
157 m=sk_num(meth); 157 m=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
158 j=sk_num(from->sk); 158 j=sk_num(from->sk);
159 for (i=0; i<j; i++) 159 for (i=0; i<j; i++)
160 { 160 {
161 from_d=CRYPTO_get_ex_data(from,i); 161 from_d=CRYPTO_get_ex_data(from,i);
162 if (i < m) 162 if (i < m)
163 { 163 {
164 mm=(CRYPTO_EX_DATA_FUNCS *)sk_value(meth,i); 164 mm=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
165 if (mm->dup_func != NULL) 165 if (mm->dup_func != NULL)
166 r=mm->dup_func(to,from,(char **)&from_d,i, 166 r=mm->dup_func(to,from,(char **)&from_d,i,
167 mm->argl,mm->argp); 167 mm->argl,mm->argp);
@@ -172,18 +172,18 @@ int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to,
172 } 172 }
173 173
174/* Call each free callback */ 174/* Call each free callback */
175void CRYPTO_free_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad) 175void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad)
176 { 176 {
177 CRYPTO_EX_DATA_FUNCS *m; 177 CRYPTO_EX_DATA_FUNCS *m;
178 char *ptr; 178 void *ptr;
179 int i,max; 179 int i,max;
180 180
181 if (meth != NULL) 181 if (meth != NULL)
182 { 182 {
183 max=sk_num(meth); 183 max=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
184 for (i=0; i<max; i++) 184 for (i=0; i<max; i++)
185 { 185 {
186 m=(CRYPTO_EX_DATA_FUNCS *)sk_value(meth,i); 186 m=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
187 if ((m != NULL) && (m->free_func != NULL)) 187 if ((m != NULL) && (m->free_func != NULL))
188 { 188 {
189 ptr=CRYPTO_get_ex_data(ad,i); 189 ptr=CRYPTO_get_ex_data(ad,i);
@@ -198,19 +198,19 @@ void CRYPTO_free_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad)
198 } 198 }
199 } 199 }
200 200
201void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad) 201void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad)
202 { 202 {
203 CRYPTO_EX_DATA_FUNCS *m; 203 CRYPTO_EX_DATA_FUNCS *m;
204 char *ptr; 204 void *ptr;
205 int i,max; 205 int i,max;
206 206
207 ad->sk=NULL; 207 ad->sk=NULL;
208 if (meth != NULL) 208 if (meth != NULL)
209 { 209 {
210 max=sk_num(meth); 210 max=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
211 for (i=0; i<max; i++) 211 for (i=0; i<max; i++)
212 { 212 {
213 m=(CRYPTO_EX_DATA_FUNCS *)sk_value(meth,i); 213 m=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
214 if ((m != NULL) && (m->new_func != NULL)) 214 if ((m != NULL) && (m->new_func != NULL))
215 { 215 {
216 ptr=CRYPTO_get_ex_data(ad,i); 216 ptr=CRYPTO_get_ex_data(ad,i);
@@ -220,4 +220,4 @@ void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad)
220 } 220 }
221 } 221 }
222 222
223 223IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index 5c349bbb56..23b7c98f8f 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -109,7 +109,7 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
109 memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx)); 109 memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx));
110 } 110 }
111 111
112void HMAC_Update(HMAC_CTX *ctx, unsigned char *data, int len) 112void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len)
113 { 113 {
114 EVP_DigestUpdate(&(ctx->md_ctx),data,len); 114 EVP_DigestUpdate(&(ctx->md_ctx),data,len);
115 } 115 }
@@ -134,7 +134,7 @@ void HMAC_cleanup(HMAC_CTX *ctx)
134 } 134 }
135 135
136unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 136unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
137 unsigned char *d, int n, unsigned char *md, 137 const unsigned char *d, int n, unsigned char *md,
138 unsigned int *md_len) 138 unsigned int *md_len)
139 { 139 {
140 HMAC_CTX c; 140 HMAC_CTX c;
diff --git a/src/lib/libcrypto/hmac/hmac.h b/src/lib/libcrypto/hmac/hmac.h
index f928975fcd..223eeda7f3 100644
--- a/src/lib/libcrypto/hmac/hmac.h
+++ b/src/lib/libcrypto/hmac/hmac.h
@@ -85,11 +85,11 @@ typedef struct hmac_ctx_st
85 85
86void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 86void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
87 const EVP_MD *md); 87 const EVP_MD *md);
88void HMAC_Update(HMAC_CTX *ctx,unsigned char *key, int len); 88void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
89void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 89void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
90void HMAC_cleanup(HMAC_CTX *ctx); 90void HMAC_cleanup(HMAC_CTX *ctx);
91unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 91unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
92 unsigned char *d, int n, unsigned char *md, 92 const unsigned char *d, int n, unsigned char *md,
93 unsigned int *md_len); 93 unsigned int *md_len);
94 94
95 95
diff --git a/src/lib/libcrypto/hmac/hmactest.c b/src/lib/libcrypto/hmac/hmactest.c
index 9a67dff36a..4b56b8ee13 100644
--- a/src/lib/libcrypto/hmac/hmactest.c
+++ b/src/lib/libcrypto/hmac/hmactest.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
73#include <openssl/ebcdic.h> 73#include <openssl/ebcdic.h>
74#endif 74#endif
75 75
76struct test_st 76static struct test_st
77 { 77 {
78 unsigned char key[16]; 78 unsigned char key[16];
79 int key_len; 79 int key_len;
diff --git a/src/lib/libcrypto/install.com b/src/lib/libcrypto/install.com
index b75d1b44b2..44cfc4e89a 100644
--- a/src/lib/libcrypto/install.com
+++ b/src/lib/libcrypto/install.com
@@ -90,6 +90,7 @@ $ COPY 'tmp' WRK_SSLINCLUDE: /LOG
90$ ELSE 90$ ELSE
91$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG 91$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG
92$ ENDIF 92$ ENDIF
93$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'tmp'
93$ GOTO LOOP_SDIRS 94$ GOTO LOOP_SDIRS
94$ LOOP_SDIRS_END: 95$ LOOP_SDIRS_END:
95$ 96$
diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl
index d6845d6caa..eef4000460 100644
--- a/src/lib/libcrypto/lhash/Makefile.ssl
+++ b/src/lib/libcrypto/lhash/Makefile.ssl
@@ -82,7 +82,8 @@ lh_stats.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82lh_stats.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82lh_stats.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 84lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
85lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 85lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
86lh_stats.o: ../cryptlib.h 86lh_stats.o: ../../include/openssl/stack.h ../cryptlib.h
87lhash.o: ../../include/openssl/crypto.h ../../include/openssl/lhash.h 87lhash.o: ../../include/openssl/crypto.h ../../include/openssl/lhash.h
88lhash.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 88lhash.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
89lhash.o: ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c
index 801322beb6..6a340a2403 100644
--- a/src/lib/libcrypto/lhash/lhash.c
+++ b/src/lib/libcrypto/lhash/lhash.c
@@ -64,11 +64,11 @@
64 * 64 *
65 * 2.1 eay - Added an 'error in last operation' flag. eay 6-May-98 65 * 2.1 eay - Added an 'error in last operation' flag. eay 6-May-98
66 * 66 *
67 * 2.0 eay - Fixed a bug that occured when using lh_delete 67 * 2.0 eay - Fixed a bug that occurred when using lh_delete
68 * from inside lh_doall(). As entries were deleted, 68 * from inside lh_doall(). As entries were deleted,
69 * the 'table' was 'contract()ed', making some entries 69 * the 'table' was 'contract()ed', making some entries
70 * jump from the end of the table to the start, there by 70 * jump from the end of the table to the start, there by
71 * skiping the lh_doall() processing. eay - 4/12/95 71 * skipping the lh_doall() processing. eay - 4/12/95
72 * 72 *
73 * 1.9 eay - Fixed a memory leak in lh_free, the LHASH_NODEs 73 * 1.9 eay - Fixed a memory leak in lh_free, the LHASH_NODEs
74 * were not being free()ed. 21/11/95 74 * were not being free()ed. 21/11/95
@@ -107,12 +107,9 @@ const char *lh_version="lhash" OPENSSL_VERSION_PTEXT;
107#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ 107#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */
108#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ 108#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */
109 109
110
111#define P_CP char *
112#define P_CPP char *,char *
113static void expand(LHASH *lh); 110static void expand(LHASH *lh);
114static void contract(LHASH *lh); 111static void contract(LHASH *lh);
115static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash); 112static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash);
116 113
117LHASH *lh_new(unsigned long (*h)(), int (*c)()) 114LHASH *lh_new(unsigned long (*h)(), int (*c)())
118 { 115 {
@@ -152,7 +149,7 @@ LHASH *lh_new(unsigned long (*h)(), int (*c)())
152 ret->error=0; 149 ret->error=0;
153 return(ret); 150 return(ret);
154err1: 151err1:
155 Free((char *)ret); 152 Free(ret);
156err0: 153err0:
157 return(NULL); 154 return(NULL);
158 } 155 }
@@ -175,15 +172,15 @@ void lh_free(LHASH *lh)
175 n=nn; 172 n=nn;
176 } 173 }
177 } 174 }
178 Free((char *)lh->b); 175 Free(lh->b);
179 Free((char *)lh); 176 Free(lh);
180 } 177 }
181 178
182char *lh_insert(LHASH *lh, char *data) 179void *lh_insert(LHASH *lh, void *data)
183 { 180 {
184 unsigned long hash; 181 unsigned long hash;
185 LHASH_NODE *nn,**rn; 182 LHASH_NODE *nn,**rn;
186 char *ret; 183 void *ret;
187 184
188 lh->error=0; 185 lh->error=0;
189 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))
@@ -217,11 +214,11 @@ char *lh_insert(LHASH *lh, char *data)
217 return(ret); 214 return(ret);
218 } 215 }
219 216
220char *lh_delete(LHASH *lh, char *data) 217void *lh_delete(LHASH *lh, void *data)
221 { 218 {
222 unsigned long hash; 219 unsigned long hash;
223 LHASH_NODE *nn,**rn; 220 LHASH_NODE *nn,**rn;
224 char *ret; 221 void *ret;
225 222
226 lh->error=0; 223 lh->error=0;
227 rn=getrn(lh,data,&hash); 224 rn=getrn(lh,data,&hash);
@@ -236,7 +233,7 @@ char *lh_delete(LHASH *lh, char *data)
236 nn= *rn; 233 nn= *rn;
237 *rn=nn->next; 234 *rn=nn->next;
238 ret=nn->data; 235 ret=nn->data;
239 Free((char *)nn); 236 Free(nn);
240 lh->num_delete++; 237 lh->num_delete++;
241 } 238 }
242 239
@@ -248,11 +245,11 @@ char *lh_delete(LHASH *lh, char *data)
248 return(ret); 245 return(ret);
249 } 246 }
250 247
251char *lh_retrieve(LHASH *lh, char *data) 248void *lh_retrieve(LHASH *lh, void *data)
252 { 249 {
253 unsigned long hash; 250 unsigned long hash;
254 LHASH_NODE **rn; 251 LHASH_NODE **rn;
255 char *ret; 252 void *ret;
256 253
257 lh->error=0; 254 lh->error=0;
258 rn=getrn(lh,data,&hash); 255 rn=getrn(lh,data,&hash);
@@ -275,7 +272,7 @@ void lh_doall(LHASH *lh, void (*func)())
275 lh_doall_arg(lh,func,NULL); 272 lh_doall_arg(lh,func,NULL);
276 } 273 }
277 274
278void lh_doall_arg(LHASH *lh, void (*func)(), char *arg) 275void lh_doall_arg(LHASH *lh, void (*func)(), void *arg)
279 { 276 {
280 int i; 277 int i;
281 LHASH_NODE *a,*n; 278 LHASH_NODE *a,*n;
@@ -332,7 +329,7 @@ static void expand(LHASH *lh)
332 if ((lh->p) >= lh->pmax) 329 if ((lh->p) >= lh->pmax)
333 { 330 {
334 j=(int)lh->num_alloc_nodes*2; 331 j=(int)lh->num_alloc_nodes*2;
335 n=(LHASH_NODE **)Realloc((char *)lh->b, 332 n=(LHASH_NODE **)Realloc(lh->b,
336 (unsigned int)sizeof(LHASH_NODE *)*j); 333 (unsigned int)sizeof(LHASH_NODE *)*j);
337 if (n == NULL) 334 if (n == NULL)
338 { 335 {
@@ -360,7 +357,7 @@ static void contract(LHASH *lh)
360 lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */ 357 lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */
361 if (lh->p == 0) 358 if (lh->p == 0)
362 { 359 {
363 n=(LHASH_NODE **)Realloc((char *)lh->b, 360 n=(LHASH_NODE **)Realloc(lh->b,
364 (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax)); 361 (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax));
365 if (n == NULL) 362 if (n == NULL)
366 { 363 {
@@ -391,7 +388,7 @@ static void contract(LHASH *lh)
391 } 388 }
392 } 389 }
393 390
394static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash) 391static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash)
395 { 392 {
396 LHASH_NODE **ret,*n1; 393 LHASH_NODE **ret,*n1;
397 unsigned long hash,nn; 394 unsigned long hash,nn;
@@ -426,8 +423,7 @@ static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash)
426 } 423 }
427 424
428/* 425/*
429static unsigned long lh_strhash(str) 426unsigned long lh_strhash(char *str)
430char *str;
431 { 427 {
432 int i,l; 428 int i,l;
433 unsigned long ret=0; 429 unsigned long ret=0;
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h
index 6e5a1fe708..6f6eeb2698 100644
--- a/src/lib/libcrypto/lhash/lhash.h
+++ b/src/lib/libcrypto/lhash/lhash.h
@@ -73,7 +73,7 @@ extern "C" {
73 73
74typedef struct lhash_node_st 74typedef struct lhash_node_st
75 { 75 {
76 char *data; 76 void *data;
77 struct lhash_node_st *next; 77 struct lhash_node_st *next;
78#ifndef NO_HASH_COMP 78#ifndef NO_HASH_COMP
79 unsigned long hash; 79 unsigned long hash;
@@ -116,13 +116,13 @@ typedef struct lhash_st
116 * in lh_insert(). */ 116 * in lh_insert(). */
117#define lh_error(lh) ((lh)->error) 117#define lh_error(lh) ((lh)->error)
118 118
119LHASH *lh_new(unsigned long (*h)(), int (*c)()); 119LHASH *lh_new(unsigned long (*h)(/* void *a */), int (*c)(/* void *a,void *b */));
120void lh_free(LHASH *lh); 120void lh_free(LHASH *lh);
121char *lh_insert(LHASH *lh, char *data); 121void *lh_insert(LHASH *lh, void *data);
122char *lh_delete(LHASH *lh, char *data); 122void *lh_delete(LHASH *lh, void *data);
123char *lh_retrieve(LHASH *lh, char *data); 123void *lh_retrieve(LHASH *lh, void *data);
124void lh_doall(LHASH *lh, void (*func)(/* char *b */)); 124 void lh_doall(LHASH *lh, void (*func)(/*void *b*/));
125void lh_doall_arg(LHASH *lh, void (*func)(/*char *a,char *b*/),char *arg); 125void lh_doall_arg(LHASH *lh, void (*func)(/*void *a,void *b*/),void *arg);
126unsigned long lh_strhash(const char *c); 126unsigned long lh_strhash(const char *c);
127 127
128#ifndef NO_FP_API 128#ifndef NO_FP_API
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
index 4274354b5f..eab615a5be 100644
--- a/src/lib/libcrypto/md2/Makefile.ssl
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -84,5 +84,5 @@ md2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
84md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 84md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
85md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 85md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
86md2_one.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h 86md2_one.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
87md2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 87md2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
88md2_one.o: ../cryptlib.h 88md2_one.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h
index 0d3592506c..582bffb859 100644
--- a/src/lib/libcrypto/md2/md2.h
+++ b/src/lib/libcrypto/md2/md2.h
@@ -81,9 +81,9 @@ typedef struct MD2state_st
81 81
82const char *MD2_options(void); 82const char *MD2_options(void);
83void MD2_Init(MD2_CTX *c); 83void MD2_Init(MD2_CTX *c);
84void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len); 84void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
85void MD2_Final(unsigned char *md, MD2_CTX *c); 85void MD2_Final(unsigned char *md, MD2_CTX *c);
86unsigned char *MD2(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}
89#endif 89#endif
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index c7d8d6aef5..608baefa8f 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -69,9 +69,9 @@ const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
69 69
70#define UCHAR unsigned char 70#define UCHAR unsigned char
71 71
72static void md2_block(MD2_CTX *c, unsigned char *d); 72static void md2_block(MD2_CTX *c, const unsigned char *d);
73/* The magic S table - I have converted it to hex since it is 73/* The magic S table - I have converted it to hex since it is
74 * basicaly just a random byte string. */ 74 * basically just a random byte string. */
75static MD2_INT S[256]={ 75static MD2_INT S[256]={
76 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 76 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01,
77 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 77 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
@@ -123,7 +123,7 @@ void MD2_Init(MD2_CTX *c)
123 memset(c->data,0,MD2_BLOCK); 123 memset(c->data,0,MD2_BLOCK);
124 } 124 }
125 125
126void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len) 126void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
127 { 127 {
128 register UCHAR *p; 128 register UCHAR *p;
129 129
@@ -161,7 +161,7 @@ void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len)
161 c->num=(int)len; 161 c->num=(int)len;
162 } 162 }
163 163
164static void md2_block(MD2_CTX *c, unsigned char *d) 164static void md2_block(MD2_CTX *c, const unsigned char *d)
165 { 165 {
166 register MD2_INT t,*sp1,*sp2; 166 register MD2_INT t,*sp1,*sp2;
167 register int i,j; 167 register int i,j;
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
index 7157299d95..b12c37ce4d 100644
--- a/src/lib/libcrypto/md2/md2_one.c
+++ b/src/lib/libcrypto/md2/md2_one.c
@@ -63,7 +63,7 @@
63/* This is a separate file so that #defines in cryptlib.h can 63/* This is a separate file so that #defines in cryptlib.h can
64 * map my MD functions to different names */ 64 * map my MD functions to different names */
65 65
66unsigned char *MD2(unsigned char *d, unsigned long n, unsigned char *md) 66unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
67 { 67 {
68 MD2_CTX c; 68 MD2_CTX c;
69 static unsigned char m[MD2_DIGEST_LENGTH]; 69 static unsigned char m[MD2_DIGEST_LENGTH];
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index 461d124957..e3f4fb4c34 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
73#include <openssl/ebcdic.h> 73#include <openssl/ebcdic.h>
74#endif 74#endif
75 75
76char *test[]={ 76static char *test[]={
77 "", 77 "",
78 "a", 78 "a",
79 "abc", 79 "abc",
@@ -84,7 +84,7 @@ char *test[]={
84 NULL, 84 NULL,
85 }; 85 };
86 86
87char *ret[]={ 87static char *ret[]={
88 "8350e5a3e24c153df2275c9f80692773", 88 "8350e5a3e24c153df2275c9f80692773",
89 "32ec01ec4a6dac72c0ab96fb34c0b5d1", 89 "32ec01ec4a6dac72c0ab96fb34c0b5d1",
90 "da853b0d3f88d99b30283a69e6ded6bb", 90 "da853b0d3f88d99b30283a69e6ded6bb",
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h
index 2b91f9eef2..1a404a458d 100644
--- a/src/lib/libcrypto/md32_common.h
+++ b/src/lib/libcrypto/md32_common.h
@@ -94,6 +94,8 @@
94 * in original (data) byte order, implemented externally (it 94 * in original (data) byte order, implemented externally (it
95 * actually is optional if data and host are of the same 95 * actually is optional if data and host are of the same
96 * "endianess"). 96 * "endianess").
97 * HASH_MAKE_STRING
98 * macro convering context variables to an ASCII hash string.
97 * 99 *
98 * Optional macros: 100 * Optional macros:
99 * 101 *
@@ -178,8 +180,17 @@
178#undef ROTATE 180#undef ROTATE
179#ifndef PEDANTIC 181#ifndef PEDANTIC
180# if defined(_MSC_VER) 182# if defined(_MSC_VER)
181# define ROTATE(a,n) _lrotl(a,n) 183# define ROTATE(a,n) _lrotl(a,n)
182# elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) 184# elif defined(__MWERKS__)
185# if defined(__POWERPC__)
186# define ROTATE(a,n) __rlwinm(a,n,0,31)
187# elif defined(__MC68K__)
188 /* Motorola specific tweak. <appro@fy.chalmers.se> */
189# define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
190# else
191# define ROTATE(a,n) __rol(a,n)
192# endif
193# elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM)
183 /* 194 /*
184 * Some GNU C inline assembler templates. Note that these are 195 * Some GNU C inline assembler templates. Note that these are
185 * rotates by *constant* number of bits! But that's exactly 196 * rotates by *constant* number of bits! But that's exactly
@@ -189,16 +200,16 @@
189 */ 200 */
190# if defined(__i386) 201# if defined(__i386)
191# define ROTATE(a,n) ({ register unsigned int ret; \ 202# define ROTATE(a,n) ({ register unsigned int ret; \
192 asm volatile ( \ 203 asm ( \
193 "roll %1,%0" \ 204 "roll %1,%0" \
194 : "=r"(ret) \ 205 : "=r"(ret) \
195 : "I"(n), "0"(a) \ 206 : "I"(n), "0"(a) \
196 : "cc"); \ 207 : "cc"); \
197 ret; \ 208 ret; \
198 }) 209 })
199# elif defined(__powerpc) 210# elif defined(__powerpc) || defined(__ppc)
200# define ROTATE(a,n) ({ register unsigned int ret; \ 211# define ROTATE(a,n) ({ register unsigned int ret; \
201 asm volatile ( \ 212 asm ( \
202 "rlwinm %0,%1,%2,0,31" \ 213 "rlwinm %0,%1,%2,0,31" \
203 : "=r"(ret) \ 214 : "=r"(ret) \
204 : "r"(a), "I"(n)); \ 215 : "r"(a), "I"(n)); \
@@ -211,18 +222,18 @@
211 * Engage compiler specific "fetch in reverse byte order" 222 * Engage compiler specific "fetch in reverse byte order"
212 * intrinsic function if available. 223 * intrinsic function if available.
213 */ 224 */
214# if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) 225# if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM)
215 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */ 226 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */
216# if defined(__i386) && !defined(I386_ONLY) 227# if defined(__i386) && !defined(I386_ONLY)
217# define BE_FETCH32(a) ({ register unsigned int l=(a);\ 228# define BE_FETCH32(a) ({ register unsigned int l=(a);\
218 asm volatile ( \ 229 asm ( \
219 "bswapl %0" \ 230 "bswapl %0" \
220 : "=r"(l) : "0"(l)); \ 231 : "=r"(l) : "0"(l)); \
221 l; \ 232 l; \
222 }) 233 })
223# elif defined(__powerpc) 234# elif defined(__powerpc)
224# define LE_FETCH32(a) ({ register unsigned int l; \ 235# define LE_FETCH32(a) ({ register unsigned int l; \
225 asm volatile ( \ 236 asm ( \
226 "lwbrx %0,0,%1" \ 237 "lwbrx %0,0,%1" \
227 : "=r"(l) \ 238 : "=r"(l) \
228 : "r"(a)); \ 239 : "r"(a)); \
@@ -231,7 +242,7 @@
231 242
232# elif defined(__sparc) && defined(ULTRASPARC) 243# elif defined(__sparc) && defined(ULTRASPARC)
233# define LE_FETCH32(a) ({ register unsigned int l; \ 244# define LE_FETCH32(a) ({ register unsigned int l; \
234 asm volatile ( \ 245 asm ( \
235 "lda [%1]#ASI_PRIMARY_LITTLE,%0"\ 246 "lda [%1]#ASI_PRIMARY_LITTLE,%0"\
236 : "=r"(l) \ 247 : "=r"(l) \
237 : "r"(a)); \ 248 : "r"(a)); \
@@ -399,8 +410,9 @@
399 * Time for some action:-) 410 * Time for some action:-)
400 */ 411 */
401 412
402void HASH_UPDATE (HASH_CTX *c, const unsigned char *data, unsigned long len) 413void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
403 { 414 {
415 const unsigned char *data=data_;
404 register HASH_LONG * p; 416 register HASH_LONG * p;
405 register unsigned long l; 417 register unsigned long l;
406 int sw,sc,ew,ec; 418 int sw,sc,ew,ec;
@@ -581,10 +593,11 @@ void HASH_FINAL (unsigned char *md, HASH_CTX *c)
581#endif 593#endif
582 HASH_BLOCK_HOST_ORDER (c,p,1); 594 HASH_BLOCK_HOST_ORDER (c,p,1);
583 595
584 l=c->A; HOST_l2c(l,md); 596#ifndef HASH_MAKE_STRING
585 l=c->B; HOST_l2c(l,md); 597#error "HASH_MAKE_STRING must be defined!"
586 l=c->C; HOST_l2c(l,md); 598#else
587 l=c->D; HOST_l2c(l,md); 599 HASH_MAKE_STRING(c,md);
600#endif
588 601
589 c->num=0; 602 c->num=0;
590 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack 603 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
index cc73fba2ba..d50f967be7 100644
--- a/src/lib/libcrypto/md5/Makefile.ssl
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -19,6 +19,13 @@ AR= ar r
19MD5_ASM_OBJ= 19MD5_ASM_OBJ=
20 20
21CFLAGS= $(INCLUDES) $(CFLAG) 21CFLAGS= $(INCLUDES) $(CFLAG)
22
23# We let the C compiler driver to take care of .s files. This is done in
24# order to be excused from maintaining a separate set of architecture
25# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
26# gcc, then the driver will automatically translate it to -xarch=v8plus
27# and pass it down to assembler.
28AS=$(CC) -c
22ASFLAGS=$(CFLAGS) 29ASFLAGS=$(CFLAGS)
23 30
24GENERAL=Makefile 31GENERAL=Makefile
@@ -77,7 +84,7 @@ asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
77# if they didn't bother to upgrade GNU assembler. Such users should 84# if they didn't bother to upgrade GNU assembler. Such users should
78# not choose this option, but be adviced to *remove* GNU assembler 85# not choose this option, but be adviced to *remove* GNU assembler
79# or upgrade it. 86# or upgrade it.
80sm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S 87asm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
81 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \ 88 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
82 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o 89 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
83 90
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index bdab6d45e8..d10bc8397f 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -103,9 +103,9 @@ typedef struct MD5state_st
103 } MD5_CTX; 103 } MD5_CTX;
104 104
105void MD5_Init(MD5_CTX *c); 105void MD5_Init(MD5_CTX *c);
106void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len); 106void MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
107void MD5_Final(unsigned char *md, MD5_CTX *c); 107void MD5_Final(unsigned char *md, MD5_CTX *c);
108unsigned char *MD5(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
111} 111}
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index ba0115ae79..23d196b8d4 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -60,7 +60,7 @@
60#include "md5_locl.h" 60#include "md5_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63char *MD5_version="MD5" OPENSSL_VERSION_PTEXT; 63const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
64 64
65/* Implemented from RFC1321 The MD5 Message-Digest Algorithm 65/* Implemented from RFC1321 The MD5 Message-Digest Algorithm
66 */ 66 */
@@ -186,6 +186,9 @@ void md5_block_host_order (MD5_CTX *c, const void *data, int num)
186#endif 186#endif
187 187
188#ifndef md5_block_data_order 188#ifndef md5_block_data_order
189#ifdef X
190#undef X
191#endif
189void md5_block_data_order (MD5_CTX *c, const void *data_, int num) 192void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
190 { 193 {
191 const unsigned char *data=data_; 194 const unsigned char *data=data_;
@@ -204,16 +207,15 @@ void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
204 * 207 *
205 * <appro@fy.chalmers.se> 208 * <appro@fy.chalmers.se>
206 */ 209 */
207 MD5_LONG X[MD5_LBLOCK]; 210#ifndef MD32_XARRAY
208 /* 211 /* See comment in crypto/sha/sha_locl.h for details. */
209 * In case you wonder why don't I use c->data for this. 212 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
210 * RISCs usually have a handful of registers and if X is 213 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
211 * declared as automatic array good optimizing compiler 214# define X(i) XX##i
212 * shall accomodate at least part of it in register bank 215#else
213 * instead of memory. 216 MD5_LONG XX[MD5_LBLOCK];
214 * 217# define X(i) XX[i]
215 * <appro@fy.chalmers.se> 218#endif
216 */
217 219
218 A=c->A; 220 A=c->A;
219 B=c->B; 221 B=c->B;
@@ -222,75 +224,75 @@ void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
222 224
223 for (;num--;) 225 for (;num--;)
224 { 226 {
225 HOST_c2l(data,l); X[ 0]=l; HOST_c2l(data,l); X[ 1]=l; 227 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
226 /* Round 0 */ 228 /* Round 0 */
227 R0(A,B,C,D,X[ 0], 7,0xd76aa478L); HOST_c2l(data,l); X[ 2]=l; 229 R0(A,B,C,D,X( 0), 7,0xd76aa478L); HOST_c2l(data,l); X( 2)=l;
228 R0(D,A,B,C,X[ 1],12,0xe8c7b756L); HOST_c2l(data,l); X[ 3]=l; 230 R0(D,A,B,C,X( 1),12,0xe8c7b756L); HOST_c2l(data,l); X( 3)=l;
229 R0(C,D,A,B,X[ 2],17,0x242070dbL); HOST_c2l(data,l); X[ 4]=l; 231 R0(C,D,A,B,X( 2),17,0x242070dbL); HOST_c2l(data,l); X( 4)=l;
230 R0(B,C,D,A,X[ 3],22,0xc1bdceeeL); HOST_c2l(data,l); X[ 5]=l; 232 R0(B,C,D,A,X( 3),22,0xc1bdceeeL); HOST_c2l(data,l); X( 5)=l;
231 R0(A,B,C,D,X[ 4], 7,0xf57c0fafL); HOST_c2l(data,l); X[ 6]=l; 233 R0(A,B,C,D,X( 4), 7,0xf57c0fafL); HOST_c2l(data,l); X( 6)=l;
232 R0(D,A,B,C,X[ 5],12,0x4787c62aL); HOST_c2l(data,l); X[ 7]=l; 234 R0(D,A,B,C,X( 5),12,0x4787c62aL); HOST_c2l(data,l); X( 7)=l;
233 R0(C,D,A,B,X[ 6],17,0xa8304613L); HOST_c2l(data,l); X[ 8]=l; 235 R0(C,D,A,B,X( 6),17,0xa8304613L); HOST_c2l(data,l); X( 8)=l;
234 R0(B,C,D,A,X[ 7],22,0xfd469501L); HOST_c2l(data,l); X[ 9]=l; 236 R0(B,C,D,A,X( 7),22,0xfd469501L); HOST_c2l(data,l); X( 9)=l;
235 R0(A,B,C,D,X[ 8], 7,0x698098d8L); HOST_c2l(data,l); X[10]=l; 237 R0(A,B,C,D,X( 8), 7,0x698098d8L); HOST_c2l(data,l); X(10)=l;
236 R0(D,A,B,C,X[ 9],12,0x8b44f7afL); HOST_c2l(data,l); X[11]=l; 238 R0(D,A,B,C,X( 9),12,0x8b44f7afL); HOST_c2l(data,l); X(11)=l;
237 R0(C,D,A,B,X[10],17,0xffff5bb1L); HOST_c2l(data,l); X[12]=l; 239 R0(C,D,A,B,X(10),17,0xffff5bb1L); HOST_c2l(data,l); X(12)=l;
238 R0(B,C,D,A,X[11],22,0x895cd7beL); HOST_c2l(data,l); X[13]=l; 240 R0(B,C,D,A,X(11),22,0x895cd7beL); HOST_c2l(data,l); X(13)=l;
239 R0(A,B,C,D,X[12], 7,0x6b901122L); HOST_c2l(data,l); X[14]=l; 241 R0(A,B,C,D,X(12), 7,0x6b901122L); HOST_c2l(data,l); X(14)=l;
240 R0(D,A,B,C,X[13],12,0xfd987193L); HOST_c2l(data,l); X[15]=l; 242 R0(D,A,B,C,X(13),12,0xfd987193L); HOST_c2l(data,l); X(15)=l;
241 R0(C,D,A,B,X[14],17,0xa679438eL); 243 R0(C,D,A,B,X(14),17,0xa679438eL);
242 R0(B,C,D,A,X[15],22,0x49b40821L); 244 R0(B,C,D,A,X(15),22,0x49b40821L);
243 /* Round 1 */ 245 /* Round 1 */
244 R1(A,B,C,D,X[ 1], 5,0xf61e2562L); 246 R1(A,B,C,D,X( 1), 5,0xf61e2562L);
245 R1(D,A,B,C,X[ 6], 9,0xc040b340L); 247 R1(D,A,B,C,X( 6), 9,0xc040b340L);
246 R1(C,D,A,B,X[11],14,0x265e5a51L); 248 R1(C,D,A,B,X(11),14,0x265e5a51L);
247 R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL); 249 R1(B,C,D,A,X( 0),20,0xe9b6c7aaL);
248 R1(A,B,C,D,X[ 5], 5,0xd62f105dL); 250 R1(A,B,C,D,X( 5), 5,0xd62f105dL);
249 R1(D,A,B,C,X[10], 9,0x02441453L); 251 R1(D,A,B,C,X(10), 9,0x02441453L);
250 R1(C,D,A,B,X[15],14,0xd8a1e681L); 252 R1(C,D,A,B,X(15),14,0xd8a1e681L);
251 R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L); 253 R1(B,C,D,A,X( 4),20,0xe7d3fbc8L);
252 R1(A,B,C,D,X[ 9], 5,0x21e1cde6L); 254 R1(A,B,C,D,X( 9), 5,0x21e1cde6L);
253 R1(D,A,B,C,X[14], 9,0xc33707d6L); 255 R1(D,A,B,C,X(14), 9,0xc33707d6L);
254 R1(C,D,A,B,X[ 3],14,0xf4d50d87L); 256 R1(C,D,A,B,X( 3),14,0xf4d50d87L);
255 R1(B,C,D,A,X[ 8],20,0x455a14edL); 257 R1(B,C,D,A,X( 8),20,0x455a14edL);
256 R1(A,B,C,D,X[13], 5,0xa9e3e905L); 258 R1(A,B,C,D,X(13), 5,0xa9e3e905L);
257 R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L); 259 R1(D,A,B,C,X( 2), 9,0xfcefa3f8L);
258 R1(C,D,A,B,X[ 7],14,0x676f02d9L); 260 R1(C,D,A,B,X( 7),14,0x676f02d9L);
259 R1(B,C,D,A,X[12],20,0x8d2a4c8aL); 261 R1(B,C,D,A,X(12),20,0x8d2a4c8aL);
260 /* Round 2 */ 262 /* Round 2 */
261 R2(A,B,C,D,X[ 5], 4,0xfffa3942L); 263 R2(A,B,C,D,X( 5), 4,0xfffa3942L);
262 R2(D,A,B,C,X[ 8],11,0x8771f681L); 264 R2(D,A,B,C,X( 8),11,0x8771f681L);
263 R2(C,D,A,B,X[11],16,0x6d9d6122L); 265 R2(C,D,A,B,X(11),16,0x6d9d6122L);
264 R2(B,C,D,A,X[14],23,0xfde5380cL); 266 R2(B,C,D,A,X(14),23,0xfde5380cL);
265 R2(A,B,C,D,X[ 1], 4,0xa4beea44L); 267 R2(A,B,C,D,X( 1), 4,0xa4beea44L);
266 R2(D,A,B,C,X[ 4],11,0x4bdecfa9L); 268 R2(D,A,B,C,X( 4),11,0x4bdecfa9L);
267 R2(C,D,A,B,X[ 7],16,0xf6bb4b60L); 269 R2(C,D,A,B,X( 7),16,0xf6bb4b60L);
268 R2(B,C,D,A,X[10],23,0xbebfbc70L); 270 R2(B,C,D,A,X(10),23,0xbebfbc70L);
269 R2(A,B,C,D,X[13], 4,0x289b7ec6L); 271 R2(A,B,C,D,X(13), 4,0x289b7ec6L);
270 R2(D,A,B,C,X[ 0],11,0xeaa127faL); 272 R2(D,A,B,C,X( 0),11,0xeaa127faL);
271 R2(C,D,A,B,X[ 3],16,0xd4ef3085L); 273 R2(C,D,A,B,X( 3),16,0xd4ef3085L);
272 R2(B,C,D,A,X[ 6],23,0x04881d05L); 274 R2(B,C,D,A,X( 6),23,0x04881d05L);
273 R2(A,B,C,D,X[ 9], 4,0xd9d4d039L); 275 R2(A,B,C,D,X( 9), 4,0xd9d4d039L);
274 R2(D,A,B,C,X[12],11,0xe6db99e5L); 276 R2(D,A,B,C,X(12),11,0xe6db99e5L);
275 R2(C,D,A,B,X[15],16,0x1fa27cf8L); 277 R2(C,D,A,B,X(15),16,0x1fa27cf8L);
276 R2(B,C,D,A,X[ 2],23,0xc4ac5665L); 278 R2(B,C,D,A,X( 2),23,0xc4ac5665L);
277 /* Round 3 */ 279 /* Round 3 */
278 R3(A,B,C,D,X[ 0], 6,0xf4292244L); 280 R3(A,B,C,D,X( 0), 6,0xf4292244L);
279 R3(D,A,B,C,X[ 7],10,0x432aff97L); 281 R3(D,A,B,C,X( 7),10,0x432aff97L);
280 R3(C,D,A,B,X[14],15,0xab9423a7L); 282 R3(C,D,A,B,X(14),15,0xab9423a7L);
281 R3(B,C,D,A,X[ 5],21,0xfc93a039L); 283 R3(B,C,D,A,X( 5),21,0xfc93a039L);
282 R3(A,B,C,D,X[12], 6,0x655b59c3L); 284 R3(A,B,C,D,X(12), 6,0x655b59c3L);
283 R3(D,A,B,C,X[ 3],10,0x8f0ccc92L); 285 R3(D,A,B,C,X( 3),10,0x8f0ccc92L);
284 R3(C,D,A,B,X[10],15,0xffeff47dL); 286 R3(C,D,A,B,X(10),15,0xffeff47dL);
285 R3(B,C,D,A,X[ 1],21,0x85845dd1L); 287 R3(B,C,D,A,X( 1),21,0x85845dd1L);
286 R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL); 288 R3(A,B,C,D,X( 8), 6,0x6fa87e4fL);
287 R3(D,A,B,C,X[15],10,0xfe2ce6e0L); 289 R3(D,A,B,C,X(15),10,0xfe2ce6e0L);
288 R3(C,D,A,B,X[ 6],15,0xa3014314L); 290 R3(C,D,A,B,X( 6),15,0xa3014314L);
289 R3(B,C,D,A,X[13],21,0x4e0811a1L); 291 R3(B,C,D,A,X(13),21,0x4e0811a1L);
290 R3(A,B,C,D,X[ 4], 6,0xf7537e82L); 292 R3(A,B,C,D,X( 4), 6,0xf7537e82L);
291 R3(D,A,B,C,X[11],10,0xbd3af235L); 293 R3(D,A,B,C,X(11),10,0xbd3af235L);
292 R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL); 294 R3(C,D,A,B,X( 2),15,0x2ad7d2bbL);
293 R3(B,C,D,A,X[ 9],21,0xeb86d391L); 295 R3(B,C,D,A,X( 9),21,0xeb86d391L);
294 296
295 A = c->A += A; 297 A = c->A += A;
296 B = c->B += B; 298 B = c->B += B;
diff --git a/src/lib/libcrypto/md5/md5_locl.h b/src/lib/libcrypto/md5/md5_locl.h
index 9d04696dbd..06af633228 100644
--- a/src/lib/libcrypto/md5/md5_locl.h
+++ b/src/lib/libcrypto/md5/md5_locl.h
@@ -66,7 +66,7 @@
66#endif 66#endif
67 67
68#ifdef MD5_ASM 68#ifdef MD5_ASM
69# if defined(__i386) || defined(_M_IX86) 69# if 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(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);
@@ -77,11 +77,11 @@
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) 80#if 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)
84 * are in this case of the same "endianess" these two are 84 * are in this case of the same "endianness" these two are
85 * otherwise indistinguishable. But normally you don't want to 85 * otherwise indistinguishable. But normally you don't want to
86 * call the same function because unaligned access in places 86 * call the same function because unaligned access in places
87 * where alignment is expected is usually a "Bad Thing". Indeed, 87 * where alignment is expected is usually a "Bad Thing". Indeed,
@@ -112,6 +112,13 @@ void md5_block_data_order (MD5_CTX *c, const void *p,int num);
112#define HASH_UPDATE MD5_Update 112#define HASH_UPDATE MD5_Update
113#define HASH_TRANSFORM MD5_Transform 113#define HASH_TRANSFORM MD5_Transform
114#define HASH_FINAL MD5_Final 114#define HASH_FINAL MD5_Final
115#define HASH_MAKE_STRING(c,s) do { \
116 unsigned long ll; \
117 ll=(c)->A; HOST_l2c(ll,(s)); \
118 ll=(c)->B; HOST_l2c(ll,(s)); \
119 ll=(c)->C; HOST_l2c(ll,(s)); \
120 ll=(c)->D; HOST_l2c(ll,(s)); \
121 } while (0)
115#define HASH_BLOCK_HOST_ORDER md5_block_host_order 122#define HASH_BLOCK_HOST_ORDER md5_block_host_order
116#if !defined(L_ENDIAN) || defined(md5_block_data_order) 123#if !defined(L_ENDIAN) || defined(md5_block_data_order)
117#define HASH_BLOCK_DATA_ORDER md5_block_data_order 124#define HASH_BLOCK_DATA_ORDER md5_block_data_order
@@ -119,7 +126,7 @@ void md5_block_data_order (MD5_CTX *c, const void *p,int num);
119 * Little-endians (Intel and Alpha) feel better without this. 126 * Little-endians (Intel and Alpha) feel better without this.
120 * It looks like memcpy does better job than generic 127 * It looks like memcpy does better job than generic
121 * md5_block_data_order on copying-n-aligning input data. 128 * md5_block_data_order on copying-n-aligning input data.
122 * But franlky speaking I didn't expect such result on Alpha. 129 * But frankly speaking I didn't expect such result on Alpha.
123 * On the other hand I've got this with egcs-1.0.2 and if 130 * On the other hand I've got this with egcs-1.0.2 and if
124 * program is compiled with another (better?) compiler it 131 * program is compiled with another (better?) compiler it
125 * might turn out other way around. 132 * might turn out other way around.
@@ -140,7 +147,7 @@ void md5_block_data_order (MD5_CTX *c, const void *p,int num);
140*/ 147*/
141 148
142/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be 149/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
143 * simplified to the code below. Wei attributes these optimisations 150 * simplified to the code below. Wei attributes these optimizations
144 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. 151 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
145 */ 152 */
146#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) 153#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
diff --git a/src/lib/libcrypto/md5/md5_one.c b/src/lib/libcrypto/md5/md5_one.c
index 4b10e7f940..b89dec850d 100644
--- a/src/lib/libcrypto/md5/md5_one.c
+++ b/src/lib/libcrypto/md5/md5_one.c
@@ -64,7 +64,7 @@
64#include <openssl/ebcdic.h> 64#include <openssl/ebcdic.h>
65#endif 65#endif
66 66
67unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md) 67unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md)
68 { 68 {
69 MD5_CTX c; 69 MD5_CTX c;
70 static unsigned char m[MD5_DIGEST_LENGTH]; 70 static unsigned char m[MD5_DIGEST_LENGTH];
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c
index a192a62bb3..6bd8656302 100644
--- a/src/lib/libcrypto/md5/md5test.c
+++ b/src/lib/libcrypto/md5/md5test.c
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
69#else 69#else
70#include <openssl/md5.h> 70#include <openssl/md5.h>
71 71
72char *test[]={ 72static char *test[]={
73 "", 73 "",
74 "a", 74 "a",
75 "abc", 75 "abc",
@@ -80,7 +80,7 @@ char *test[]={
80 NULL, 80 NULL,
81 }; 81 };
82 82
83char *ret[]={ 83static char *ret[]={
84 "d41d8cd98f00b204e9800998ecf8427e", 84 "d41d8cd98f00b204e9800998ecf8427e",
85 "0cc175b9c0f1b6a831c399e269772661", 85 "0cc175b9c0f1b6a831c399e269772661",
86 "900150983cd24fb0d6963f7d28e17f72", 86 "900150983cd24fb0d6963f7d28e17f72",
diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl
index f8c824c4a8..7c28103350 100644
--- a/src/lib/libcrypto/mdc2/Makefile.ssl
+++ b/src/lib/libcrypto/mdc2/Makefile.ssl
@@ -83,7 +83,7 @@ mdc2_one.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
83mdc2_one.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 83mdc2_one.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
84mdc2_one.o: ../../include/openssl/err.h ../../include/openssl/mdc2.h 84mdc2_one.o: ../../include/openssl/err.h ../../include/openssl/mdc2.h
85mdc2_one.o: ../../include/openssl/opensslconf.h 85mdc2_one.o: ../../include/openssl/opensslconf.h
86mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 86mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87mdc2_one.o: ../cryptlib.h 87mdc2_one.o: ../../include/openssl/stack.h ../cryptlib.h
88mdc2dgst.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 88mdc2dgst.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
89mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h 89mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h
diff --git a/src/lib/libcrypto/mdc2/mdc2.h b/src/lib/libcrypto/mdc2/mdc2.h
index ec8e159fc9..00acd707cd 100644
--- a/src/lib/libcrypto/mdc2/mdc2.h
+++ b/src/lib/libcrypto/mdc2/mdc2.h
@@ -82,9 +82,10 @@ typedef struct mdc2_ctx_st
82 82
83 83
84void MDC2_Init(MDC2_CTX *c); 84void MDC2_Init(MDC2_CTX *c);
85void MDC2_Update(MDC2_CTX *c, unsigned char *data, unsigned long len); 85void MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len);
86void MDC2_Final(unsigned char *md, MDC2_CTX *c); 86void MDC2_Final(unsigned char *md, MDC2_CTX *c);
87unsigned char *MDC2(unsigned char *d, unsigned long n, unsigned char *md); 87unsigned char *MDC2(const unsigned char *d, unsigned long n,
88 unsigned char *md);
88 89
89#ifdef __cplusplus 90#ifdef __cplusplus
90} 91}
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 61fc1e184e..5a661e5f45 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -59,371 +59,203 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/crypto.h> 61#include <openssl/crypto.h>
62#ifdef CRYPTO_MDEBUG_TIME
63# include <time.h>
64#endif
65#include <openssl/buffer.h>
66#include <openssl/bio.h>
67#include <openssl/lhash.h>
68#include "cryptlib.h" 62#include "cryptlib.h"
69 63
70/* #ifdef CRYPTO_MDEBUG */
71/* static int mh_mode=CRYPTO_MEM_CHECK_ON; */
72/* #else */
73static int mh_mode=CRYPTO_MEM_CHECK_OFF;
74/* #endif */
75/* State CRYPTO_MEM_CHECK_ON exists only temporarily when the library
76 * thinks that certain allocations should not be checked (e.g. the data
77 * structures used for memory checking). It is not suitable as an initial
78 * state: the library will unexpectedly enable memory checking when it
79 * executes one of those sections that want to disable checking
80 * temporarily.
81 *
82 * State CRYPTO_MEM_CHECK_ENABLE without ..._ON makes no sense whatsoever.
83 */
84
85static unsigned long order=0;
86
87static LHASH *mh=NULL;
88 64
89typedef struct mem_st 65static int allow_customize = 1; /* we provide flexible functions for */
90 { 66static int allow_customize_debug = 1;/* exchanging memory-related functions at
91 char *addr; 67 * run-time, but this must be done
92 int num; 68 * before any blocks are actually
93 const char *file; 69 * allocated; or we'll run into huge
94 int line; 70 * problems when malloc/free pairs
95#ifdef CRYPTO_MDEBUG_THREAD 71 * don't match etc. */
96 unsigned long thread; 72
73/* may be changed as long as `allow_customize' is set */
74static void *(*malloc_locked_func)(size_t) = malloc;
75static void (*free_locked_func)(void *) = free;
76static void *(*malloc_func)(size_t) = malloc;
77static void *(*realloc_func)(void *, size_t)= realloc;
78static void (*free_func)(void *) = free;
79
80/* may be changed as long as `allow_customize_debug' is set */
81/* XXX use correct function pointer types */
82#ifdef CRYPTO_MDEBUG
83 /* use default functions from mem_dbg.c */
84 static void (*malloc_debug_func)()= (void (*)())CRYPTO_dbg_malloc;
85 static void (*realloc_debug_func)()= (void (*)())CRYPTO_dbg_realloc;
86 static void (*free_debug_func)()= (void (*)())CRYPTO_dbg_free;
87 static void (*set_debug_options_func)()= (void (*)())CRYPTO_dbg_set_options;
88 static long (*get_debug_options_func)()= (long (*)())CRYPTO_dbg_get_options;
89#else
90 /* applications can use CRYPTO_malloc_debug_init() to select above case
91 * at run-time */
92 static void (*malloc_debug_func)()= NULL;
93 static void (*realloc_debug_func)()= NULL;
94 static void (*free_debug_func)()= NULL;
95 static void (*set_debug_options_func)()= NULL;
96 static long (*get_debug_options_func)()= NULL;
97#endif 97#endif
98 unsigned long order;
99#ifdef CRYPTO_MDEBUG_TIME
100 time_t time;
101#endif
102 } MEM;
103
104int CRYPTO_mem_ctrl(int mode)
105 {
106 int ret=mh_mode;
107
108 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
109 switch (mode)
110 {
111 /* for applications: */
112 case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
113 mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;
114 break;
115 case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */
116 mh_mode = 0;
117 break;
118 98
119 /* switch off temporarily (for library-internal use): */
120 case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
121 mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;
122 break;
123 case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
124 if (mh_mode&CRYPTO_MEM_CHECK_ON)
125 mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
126 break;
127 99
128 default: 100int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
129 break; 101 void (*f)(void *))
130 }
131 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
132 return(ret);
133 }
134
135static int mem_cmp(MEM *a, MEM *b)
136 {
137 return(a->addr - b->addr);
138 }
139
140static unsigned long mem_hash(MEM *a)
141 { 102 {
142 unsigned long ret; 103 if (!allow_customize)
143 104 return 0;
144 ret=(unsigned long)a->addr; 105 if ((m == NULL) || (r == NULL) || (f == NULL))
145 106 return 0;
146 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
147 return(ret);
148 }
149
150static char *(*malloc_locked_func)()=(char *(*)())malloc;
151static void (*free_locked_func)()=(void (*)())free;
152static char *(*malloc_func)()= (char *(*)())malloc;
153static char *(*realloc_func)()= (char *(*)())realloc;
154static void (*free_func)()= (void (*)())free;
155
156void CRYPTO_set_mem_functions(char *(*m)(), char *(*r)(), void (*f)())
157 {
158 if ((m == NULL) || (r == NULL) || (f == NULL)) return;
159 malloc_func=m; 107 malloc_func=m;
160 realloc_func=r; 108 realloc_func=r;
161 free_func=f; 109 free_func=f;
162 malloc_locked_func=m; 110 malloc_locked_func=m;
163 free_locked_func=f; 111 free_locked_func=f;
112 return 1;
164 } 113 }
165 114
166void CRYPTO_set_locked_mem_functions(char *(*m)(), void (*f)()) 115int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
167 { 116 {
168 if ((m == NULL) || (f == NULL)) return; 117 if (!allow_customize)
118 return 0;
119 if ((m == NULL) || (f == NULL))
120 return 0;
169 malloc_locked_func=m; 121 malloc_locked_func=m;
170 free_locked_func=f; 122 free_locked_func=f;
123 return 1;
124 }
125
126int CRYPTO_set_mem_debug_functions(void (*m)(), void (*r)(), void (*f)(),void (*so)(),long (*go)())
127 {
128 if (!allow_customize_debug)
129 return 0;
130 malloc_debug_func=m;
131 realloc_debug_func=r;
132 free_debug_func=f;
133 set_debug_options_func=so;
134 get_debug_options_func=go;
135 return 1;
171 } 136 }
172 137
173void CRYPTO_get_mem_functions(char *(**m)(), char *(**r)(), void (**f)()) 138void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
139 void (**f)(void *))
174 { 140 {
175 if (m != NULL) *m=malloc_func; 141 if (m != NULL) *m=malloc_func;
176 if (r != NULL) *r=realloc_func; 142 if (r != NULL) *r=realloc_func;
177 if (f != NULL) *f=free_func; 143 if (f != NULL) *f=free_func;
178 } 144 }
179 145
180void CRYPTO_get_locked_mem_functions(char *(**m)(), void (**f)()) 146void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
181 { 147 {
182 if (m != NULL) *m=malloc_locked_func; 148 if (m != NULL) *m=malloc_locked_func;
183 if (f != NULL) *f=free_locked_func; 149 if (f != NULL) *f=free_locked_func;
184 } 150 }
185 151
186void *CRYPTO_malloc_locked(int num) 152void CRYPTO_get_mem_debug_functions(void (**m)(), void (**r)(), void (**f)(),void (**so)(),long (**go)())
187 { 153 {
188 return(malloc_locked_func(num)); 154 if (m != NULL) *m=malloc_debug_func;
155 if (r != NULL) *r=realloc_debug_func;
156 if (f != NULL) *f=free_debug_func;
157 if (so != NULL) *so=set_debug_options_func;
158 if (go != NULL) *go=get_debug_options_func;
189 } 159 }
190 160
191void CRYPTO_free_locked(void *str)
192 {
193 free_locked_func(str);
194 }
195 161
196void *CRYPTO_malloc(int num) 162void *CRYPTO_malloc_locked(int num, const char *file, int line)
197 { 163 {
198 return(malloc_func(num)); 164 char *ret = NULL;
199 }
200 165
201void *CRYPTO_realloc(void *str, int num) 166 allow_customize = 0;
202 { 167 if (malloc_debug_func != NULL)
203 return(realloc_func(str,num));
204 }
205
206void CRYPTO_free(void *str)
207 {
208 free_func(str);
209 }
210
211static unsigned long break_order_num=0;
212void *CRYPTO_dbg_malloc(int num, const char *file, int line)
213 {
214 char *ret;
215 MEM *m,*mm;
216
217 if ((ret=malloc_func(num)) == NULL)
218 return(NULL);
219
220 if (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
221 { 168 {
222 MemCheck_off(); 169 allow_customize_debug = 0;
223 if ((m=(MEM *)Malloc(sizeof(MEM))) == NULL) 170 malloc_debug_func(NULL, num, file, line, 0);
224 {
225 Free(ret);
226 MemCheck_on();
227 return(NULL);
228 }
229 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
230 if (mh == NULL)
231 {
232 if ((mh=lh_new(mem_hash,mem_cmp)) == NULL)
233 {
234 Free(ret);
235 Free(m);
236 ret=NULL;
237 goto err;
238 }
239 }
240
241 m->addr=ret;
242 m->file=file;
243 m->line=line;
244 m->num=num;
245#ifdef CRYPTO_MDEBUG_THREAD
246 m->thread=CRYPTO_thread_id();
247#endif
248 if (order == break_order_num)
249 {
250 /* BREAK HERE */
251 m->order=order;
252 }
253 m->order=order++;
254#ifdef CRYPTO_MDEBUG_TIME
255 m->time=time(NULL);
256#endif
257 if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL)
258 {
259 /* Not good, but don't sweat it */
260 Free(mm);
261 }
262err:
263 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
264 MemCheck_on();
265 } 171 }
266 return(ret); 172 ret = malloc_locked_func(num);
173#ifdef LEVITTE_DEBUG
174 fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num);
175#endif
176 if (malloc_debug_func != NULL)
177 malloc_debug_func(ret, num, file, line, 1);
178
179 return ret;
267 } 180 }
268 181
269void CRYPTO_dbg_free(void *addr) 182void CRYPTO_free_locked(void *str)
270 { 183 {
271 MEM m,*mp; 184 if (free_debug_func != NULL)
272 185 free_debug_func(str, 0);
273 if ((mh_mode & CRYPTO_MEM_CHECK_ENABLE) && (mh != NULL)) 186#ifdef LEVITTE_DEBUG
274 { 187 fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str);
275 MemCheck_off(); 188#endif
276 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC); 189 free_locked_func(str);
277 m.addr=addr; 190 if (free_debug_func != NULL)
278 mp=(MEM *)lh_delete(mh,(char *)&m); 191 free_debug_func(NULL, 1);
279 if (mp != NULL)
280 Free(mp);
281 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
282 MemCheck_on();
283 }
284 free_func(addr);
285 } 192 }
286 193
287void *CRYPTO_dbg_realloc(void *addr, int num, const char *file, int line) 194void *CRYPTO_malloc(int num, const char *file, int line)
288 { 195 {
289 char *ret; 196 char *ret = NULL;
290 MEM m,*mp;
291
292 ret=realloc_func(addr,num);
293 if (ret == addr) return(ret);
294 197
295 if (mh_mode & CRYPTO_MEM_CHECK_ENABLE) 198 allow_customize = 0;
199 if (malloc_debug_func != NULL)
296 { 200 {
297 MemCheck_off(); 201 allow_customize_debug = 0;
298 if (ret == NULL) return(NULL); 202 malloc_debug_func(NULL, num, file, line, 0);
299 m.addr=addr;
300 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
301 mp=(MEM *)lh_delete(mh,(char *)&m);
302 if (mp != NULL)
303 {
304 mp->addr=ret;
305 lh_insert(mh,(char *)mp);
306 }
307 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
308 MemCheck_on();
309 } 203 }
310 return(ret); 204 ret = malloc_func(num);
311 } 205#ifdef LEVITTE_DEBUG
312 206 fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num);
313void *CRYPTO_remalloc(void *a, int n) 207#endif
314 { 208 if (malloc_debug_func != NULL)
315 if (a != NULL) Free(a); 209 malloc_debug_func(ret, num, file, line, 1);
316 a=(char *)Malloc(n);
317 return(a);
318 }
319 210
320void *CRYPTO_dbg_remalloc(void *a, int n, const char *file, int line) 211 return ret;
321 {
322 if (a != NULL) CRYPTO_dbg_free(a);
323 a=(char *)CRYPTO_dbg_malloc(n,file,line);
324 return(a);
325 } 212 }
326 213
327 214void *CRYPTO_realloc(void *str, int num, const char *file, int line)
328typedef struct mem_leak_st
329 { 215 {
330 BIO *bio; 216 char *ret = NULL;
331 int chunks;
332 long bytes;
333 } MEM_LEAK;
334 217
335static void print_leak(MEM *m, MEM_LEAK *l) 218 if (realloc_debug_func != NULL)
336 { 219 realloc_debug_func(str, NULL, num, file, line, 0);
337 char buf[128]; 220 ret = realloc_func(str,num);
338#ifdef CRYPTO_MDEBUG_TIME 221#ifdef LEVITTE_DEBUG
339 struct tm *lcl; 222 fprintf(stderr, "LEVITTE_DEBUG: | 0x%p -> 0x%p (%d)\n", str, ret, num);
340#endif 223#endif
224 if (realloc_debug_func != NULL)
225 realloc_debug_func(str, ret, num, file, line, 1);
341 226
342 if(m->addr == (char *)l->bio) 227 return ret;
343 return;
344
345#ifdef CRYPTO_MDEBUG_TIME
346 lcl = localtime(&m->time);
347#endif
348
349 sprintf(buf,
350#ifdef CRYPTO_MDEBUG_TIME
351 "[%02d:%02d:%02d] "
352#endif
353 "%5lu file=%s, line=%d, "
354#ifdef CRYPTO_MDEBUG_THREAD
355 "thread=%lu, "
356#endif
357 "number=%d, address=%08lX\n",
358#ifdef CRYPTO_MDEBUG_TIME
359 lcl->tm_hour,lcl->tm_min,lcl->tm_sec,
360#endif
361 m->order,m->file,m->line,
362#ifdef CRYPTO_MDEBUG_THREAD
363 m->thread,
364#endif
365 m->num,(unsigned long)m->addr);
366
367 BIO_puts(l->bio,buf);
368 l->chunks++;
369 l->bytes+=m->num;
370 } 228 }
371 229
372void CRYPTO_mem_leaks(BIO *b) 230void CRYPTO_free(void *str)
373 { 231 {
374 MEM_LEAK ml; 232 if (free_debug_func != NULL)
375 char buf[80]; 233 free_debug_func(str, 0);
376 234#ifdef LEVITTE_DEBUG
377 if (mh == NULL) return; 235 fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str);
378 ml.bio=b;
379 ml.bytes=0;
380 ml.chunks=0;
381 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
382 lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml);
383 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
384 if (ml.chunks != 0)
385 {
386 sprintf(buf,"%ld bytes leaked in %d chunks\n",
387 ml.bytes,ml.chunks);
388 BIO_puts(b,buf);
389 }
390
391#if 0
392 lh_stats_bio(mh,b);
393 lh_node_stats_bio(mh,b);
394 lh_node_usage_stats_bio(mh,b);
395#endif 236#endif
237 free_func(str);
238 if (free_debug_func != NULL)
239 free_debug_func(NULL, 1);
396 } 240 }
397 241
398static void (*mem_cb)()=NULL; 242void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
399
400static void cb_leak(MEM *m, char *cb)
401 { 243 {
402 void (*mem_callback)()=(void (*)())cb; 244 if (a != NULL) Free(a);
403 mem_callback(m->order,m->file,m->line,m->num,m->addr); 245 a=(char *)Malloc(num);
246 return(a);
404 } 247 }
405 248
406void CRYPTO_mem_leaks_cb(void (*cb)()) 249
250void CRYPTO_set_mem_debug_options(long bits)
407 { 251 {
408 if (mh == NULL) return; 252 if (set_debug_options_func != NULL)
409 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC); 253 set_debug_options_func(bits);
410 mem_cb=cb;
411 lh_doall_arg(mh,(void (*)())cb_leak,(char *)mem_cb);
412 mem_cb=NULL;
413 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
414 } 254 }
415 255
416#ifndef NO_FP_API 256long CRYPTO_get_mem_debug_options(void)
417void CRYPTO_mem_leaks_fp(FILE *fp)
418 { 257 {
419 BIO *b; 258 if (get_debug_options_func != NULL)
420 259 return get_debug_options_func();
421 if (mh == NULL) return; 260 return 0;
422 if ((b=BIO_new(BIO_s_file())) == NULL)
423 return;
424 BIO_set_fp(b,fp,BIO_NOCLOSE);
425 CRYPTO_mem_leaks(b);
426 BIO_free(b);
427 } 261 }
428#endif
429
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
new file mode 100644
index 0000000000..14770c0733
--- /dev/null
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -0,0 +1,703 @@
1/* crypto/mem_dbg.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <time.h>
62#include <openssl/crypto.h>
63#include <openssl/buffer.h>
64#include <openssl/bio.h>
65#include <openssl/lhash.h>
66#include "cryptlib.h"
67
68static int mh_mode=CRYPTO_MEM_CHECK_OFF;
69/* The state changes to CRYPTO_MEM_CHECK_ON | CRYPTO_MEM_CHECK_ENABLE
70 * when the application asks for it (usually after library initialisation
71 * for which no book-keeping is desired).
72 *
73 * State CRYPTO_MEM_CHECK_ON exists only temporarily when the library
74 * thinks that certain allocations should not be checked (e.g. the data
75 * structures used for memory checking). It is not suitable as an initial
76 * state: the library will unexpectedly enable memory checking when it
77 * executes one of those sections that want to disable checking
78 * temporarily.
79 *
80 * State CRYPTO_MEM_CHECK_ENABLE without ..._ON makes no sense whatsoever.
81 */
82
83static unsigned long order = 0; /* number of memory requests */
84static LHASH *mh=NULL; /* hash-table of memory requests (address as key) */
85
86
87typedef struct app_mem_info_st
88/* For application-defined information (static C-string `info')
89 * to be displayed in memory leak list.
90 * Each thread has its own stack. For applications, there is
91 * CRYPTO_push_info("...") to push an entry,
92 * CRYPTO_pop_info() to pop an entry,
93 * CRYPTO_remove_all_info() to pop all entries.
94 */
95 {
96 unsigned long thread;
97 const char *file;
98 int line;
99 const char *info;
100 struct app_mem_info_st *next; /* tail of thread's stack */
101 int references;
102 } APP_INFO;
103
104static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's
105 * that are at the top of their thread's stack
106 * (with `thread' as key) */
107
108typedef struct mem_st
109/* memory-block description */
110 {
111 char *addr;
112 int num;
113 const char *file;
114 int line;
115 unsigned long thread;
116 unsigned long order;
117 time_t time;
118 APP_INFO *app_info;
119 } MEM;
120
121static long options = /* extra information to be recorded */
122#if defined(CRYPTO_MDEBUG_TIME) || defined(CRYPTO_MDEBUG_ALL)
123 V_CRYPTO_MDEBUG_TIME |
124#endif
125#if defined(CRYPTO_MDEBUG_THREAD) || defined(CRYPTO_MDEBUG_ALL)
126 V_CRYPTO_MDEBUG_THREAD |
127#endif
128 0;
129
130
131static unsigned long disabling_thread = 0;
132
133int CRYPTO_mem_ctrl(int mode)
134 {
135 int ret=mh_mode;
136
137 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
138 switch (mode)
139 {
140 /* for applications: */
141 case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
142 mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;
143 disabling_thread = 0;
144 break;
145 case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */
146 mh_mode = 0;
147 disabling_thread = 0;
148 break;
149
150 /* switch off temporarily (for library-internal use): */
151 case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
152 if (mh_mode & CRYPTO_MEM_CHECK_ON)
153 {
154 mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;
155 if (disabling_thread != CRYPTO_thread_id()) /* otherwise we already have the MALLOC2 lock */
156 {
157 /* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
158 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
159 * somebody else holds CRYPTO_LOCK_MALLOC2 (and cannot release
160 * it because we block entry to this function).
161 * Give them a chance, first, and then claim the locks in
162 * appropriate order (long-time lock first).
163 */
164 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
165 /* Note that after we have waited for CRYPTO_LOCK_MALLOC2
166 * and CRYPTO_LOCK_MALLOC, we'll still be in the right
167 * "case" and "if" branch because MemCheck_start and
168 * MemCheck_stop may never be used while there are multiple
169 * OpenSSL threads. */
170 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
171 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
172 disabling_thread=CRYPTO_thread_id();
173 }
174 }
175 break;
176 case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
177 if (mh_mode & CRYPTO_MEM_CHECK_ON)
178 {
179 mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
180 if (disabling_thread != 0)
181 {
182 disabling_thread=0;
183 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
184 }
185 }
186 break;
187
188 default:
189 break;
190 }
191 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
192 return(ret);
193 }
194
195int CRYPTO_is_mem_check_on(void)
196 {
197 int ret = 0;
198
199 if (mh_mode & CRYPTO_MEM_CHECK_ON)
200 {
201 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
202
203 ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
204 && disabling_thread != CRYPTO_thread_id();
205
206 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
207 }
208 return(ret);
209 }
210
211
212void CRYPTO_dbg_set_options(long bits)
213 {
214 options = bits;
215 }
216
217long CRYPTO_dbg_get_options(void)
218 {
219 return options;
220 }
221
222static int mem_cmp(MEM *a, MEM *b)
223 {
224 return(a->addr - b->addr);
225 }
226
227static unsigned long mem_hash(MEM *a)
228 {
229 unsigned long ret;
230
231 ret=(unsigned long)a->addr;
232
233 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
234 return(ret);
235 }
236
237static int app_info_cmp(APP_INFO *a, APP_INFO *b)
238 {
239 return(a->thread != b->thread);
240 }
241
242static unsigned long app_info_hash(APP_INFO *a)
243 {
244 unsigned long ret;
245
246 ret=(unsigned long)a->thread;
247
248 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
249 return(ret);
250 }
251
252static APP_INFO *pop_info()
253 {
254 APP_INFO tmp;
255 APP_INFO *ret = NULL;
256
257 if (amih != NULL)
258 {
259 tmp.thread=CRYPTO_thread_id();
260 if ((ret=(APP_INFO *)lh_delete(amih,&tmp)) != NULL)
261 {
262 APP_INFO *next=ret->next;
263
264 if (next != NULL)
265 {
266 next->references++;
267 lh_insert(amih,(char *)next);
268 }
269#ifdef LEVITTE_DEBUG
270 if (ret->thread != tmp.thread)
271 {
272 fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
273 ret->thread, tmp.thread);
274 abort();
275 }
276#endif
277 if (--(ret->references) <= 0)
278 {
279 ret->next = NULL;
280 if (next != NULL)
281 next->references--;
282 Free(ret);
283 }
284 }
285 }
286 return(ret);
287 }
288
289int CRYPTO_push_info_(const char *info, const char *file, int line)
290 {
291 APP_INFO *ami, *amim;
292 int ret=0;
293
294 if (is_MemCheck_on())
295 {
296 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
297
298 if ((ami = (APP_INFO *)Malloc(sizeof(APP_INFO))) == NULL)
299 {
300 ret=0;
301 goto err;
302 }
303 if (amih == NULL)
304 {
305 if ((amih=lh_new(app_info_hash,app_info_cmp)) == NULL)
306 {
307 Free(ami);
308 ret=0;
309 goto err;
310 }
311 }
312
313 ami->thread=CRYPTO_thread_id();
314 ami->file=file;
315 ami->line=line;
316 ami->info=info;
317 ami->references=1;
318 ami->next=NULL;
319
320 if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL)
321 {
322#ifdef LEVITTE_DEBUG
323 if (ami->thread != amim->thread)
324 {
325 fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
326 amim->thread, ami->thread);
327 abort();
328 }
329#endif
330 ami->next=amim;
331 }
332 err:
333 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
334 }
335
336 return(ret);
337 }
338
339int CRYPTO_pop_info(void)
340 {
341 int ret=0;
342
343 if (is_MemCheck_on()) /* _must_ be true, or something went severely wrong */
344 {
345 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
346
347 ret=(pop_info() != NULL);
348
349 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
350 }
351 return(ret);
352 }
353
354int CRYPTO_remove_all_info(void)
355 {
356 int ret=0;
357
358 if (is_MemCheck_on()) /* _must_ be true */
359 {
360 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
361
362 while(pop_info() != NULL)
363 ret++;
364
365 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
366 }
367 return(ret);
368 }
369
370
371static unsigned long break_order_num=0;
372void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
373 int before_p)
374 {
375 MEM *m,*mm;
376 APP_INFO tmp,*amim;
377
378 switch(before_p & 127)
379 {
380 case 0:
381 break;
382 case 1:
383 if (addr == NULL)
384 break;
385
386 if (is_MemCheck_on())
387 {
388 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
389 if ((m=(MEM *)Malloc(sizeof(MEM))) == NULL)
390 {
391 Free(addr);
392 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
393 return;
394 }
395 if (mh == NULL)
396 {
397 if ((mh=lh_new(mem_hash,mem_cmp)) == NULL)
398 {
399 Free(addr);
400 Free(m);
401 addr=NULL;
402 goto err;
403 }
404 }
405
406 m->addr=addr;
407 m->file=file;
408 m->line=line;
409 m->num=num;
410 if (options & V_CRYPTO_MDEBUG_THREAD)
411 m->thread=CRYPTO_thread_id();
412 else
413 m->thread=0;
414
415 if (order == break_order_num)
416 {
417 /* BREAK HERE */
418 m->order=order;
419 }
420 m->order=order++;
421#ifdef LEVITTE_DEBUG
422 fprintf(stderr, "LEVITTE_DEBUG: [%5d] %c 0x%p (%d)\n",
423 m->order,
424 (before_p & 128) ? '*' : '+',
425 m->addr, m->num);
426#endif
427 if (options & V_CRYPTO_MDEBUG_TIME)
428 m->time=time(NULL);
429 else
430 m->time=0;
431
432 tmp.thread=CRYPTO_thread_id();
433 m->app_info=NULL;
434 if (amih != NULL
435 && (amim=(APP_INFO *)lh_retrieve(amih,(char *)&tmp)) != NULL)
436 {
437 m->app_info = amim;
438 amim->references++;
439 }
440
441 if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL)
442 {
443 /* Not good, but don't sweat it */
444 if (mm->app_info != NULL)
445 {
446 mm->app_info->references--;
447 }
448 Free(mm);
449 }
450 err:
451 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
452 }
453 break;
454 }
455 return;
456 }
457
458void CRYPTO_dbg_free(void *addr, int before_p)
459 {
460 MEM m,*mp;
461
462 switch(before_p)
463 {
464 case 0:
465 if (addr == NULL)
466 break;
467
468 if (is_MemCheck_on() && (mh != NULL))
469 {
470 MemCheck_off();
471
472 m.addr=addr;
473 mp=(MEM *)lh_delete(mh,(char *)&m);
474 if (mp != NULL)
475 {
476#ifdef LEVITTE_DEBUG
477 fprintf(stderr, "LEVITTE_DEBUG: [%5d] - 0x%p (%d)\n",
478 mp->order, mp->addr, mp->num);
479#endif
480 if (mp->app_info != NULL)
481 {
482 mp->app_info->references--;
483 }
484 Free(mp);
485 }
486
487 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
488 }
489 break;
490 case 1:
491 break;
492 }
493 }
494
495void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
496 const char *file, int line, int before_p)
497 {
498 MEM m,*mp;
499
500#ifdef LEVITTE_DEBUG
501 fprintf(stderr, "LEVITTE_DEBUG: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n",
502 addr1, addr2, num, file, line, before_p);
503#endif
504
505 switch(before_p)
506 {
507 case 0:
508 break;
509 case 1:
510 if (addr2 == NULL)
511 break;
512
513 if (addr1 == NULL)
514 {
515 CRYPTO_dbg_malloc(addr2, num, file, line, 128 | before_p);
516 break;
517 }
518
519 if (is_MemCheck_on())
520 {
521 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
522
523 m.addr=addr1;
524 mp=(MEM *)lh_delete(mh,(char *)&m);
525 if (mp != NULL)
526 {
527#ifdef LEVITTE_DEBUG
528 fprintf(stderr, "LEVITTE_DEBUG: [%5d] * 0x%p (%d) -> 0x%p (%d)\n",
529 mp->order,
530 mp->addr, mp->num,
531 addr2, num);
532#endif
533 mp->addr=addr2;
534 mp->num=num;
535 lh_insert(mh,(char *)mp);
536 }
537
538 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
539 }
540 break;
541 }
542 return;
543 }
544
545
546typedef struct mem_leak_st
547 {
548 BIO *bio;
549 int chunks;
550 long bytes;
551 } MEM_LEAK;
552
553static void print_leak(MEM *m, MEM_LEAK *l)
554 {
555 char buf[1024];
556 char *bufp = buf;
557 APP_INFO *amip;
558 int ami_cnt;
559 struct tm *lcl = NULL;
560 unsigned long ti;
561
562 if(m->addr == (char *)l->bio)
563 return;
564
565 if (options & V_CRYPTO_MDEBUG_TIME)
566 {
567 lcl = localtime(&m->time);
568
569 sprintf(bufp, "[%02d:%02d:%02d] ",
570 lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
571 bufp += strlen(bufp);
572 }
573
574 sprintf(bufp, "%5lu file=%s, line=%d, ",
575 m->order,m->file,m->line);
576 bufp += strlen(bufp);
577
578 if (options & V_CRYPTO_MDEBUG_THREAD)
579 {
580 sprintf(bufp, "thread=%lu, ", m->thread);
581 bufp += strlen(bufp);
582 }
583
584 sprintf(bufp, "number=%d, address=%08lX\n",
585 m->num,(unsigned long)m->addr);
586 bufp += strlen(bufp);
587
588 BIO_puts(l->bio,buf);
589
590 l->chunks++;
591 l->bytes+=m->num;
592
593 amip=m->app_info;
594 ami_cnt=0;
595 if (!amip)
596 return;
597 ti=amip->thread;
598
599 do
600 {
601 int buf_len;
602 int info_len;
603
604 ami_cnt++;
605 memset(buf,'>',ami_cnt);
606 sprintf(buf + ami_cnt,
607 " thread=%lu, file=%s, line=%d, info=\"",
608 amip->thread, amip->file, amip->line);
609 buf_len=strlen(buf);
610 info_len=strlen(amip->info);
611 if (128 - buf_len - 3 < info_len)
612 {
613 memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
614 buf_len = 128 - 3;
615 }
616 else
617 {
618 strcpy(buf + buf_len, amip->info);
619 buf_len = strlen(buf);
620 }
621 sprintf(buf + buf_len, "\"\n");
622
623 BIO_puts(l->bio,buf);
624
625 amip = amip->next;
626 }
627 while(amip && amip->thread == ti);
628
629#ifdef LEVITTE_DEBUG
630 if (amip)
631 {
632 fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
633 abort();
634 }
635#endif
636 }
637
638void CRYPTO_mem_leaks(BIO *b)
639 {
640 MEM_LEAK ml;
641 char buf[80];
642
643 if (mh == NULL) return;
644 ml.bio=b;
645 ml.bytes=0;
646 ml.chunks=0;
647 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
648 lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml);
649 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
650 if (ml.chunks != 0)
651 {
652 sprintf(buf,"%ld bytes leaked in %d chunks\n",
653 ml.bytes,ml.chunks);
654 BIO_puts(b,buf);
655 }
656
657#if 0
658 lh_stats_bio(mh,b);
659 lh_node_stats_bio(mh,b);
660 lh_node_usage_stats_bio(mh,b);
661#endif
662 }
663
664union void_fn_to_char_u
665 {
666 char *char_p;
667 void (*fn_p)();
668 };
669
670static void cb_leak(MEM *m, char *cb)
671 {
672 union void_fn_to_char_u mem_callback;
673
674 mem_callback.char_p=cb;
675 mem_callback.fn_p(m->order,m->file,m->line,m->num,m->addr);
676 }
677
678void CRYPTO_mem_leaks_cb(void (*cb)())
679 {
680 union void_fn_to_char_u mem_cb;
681
682 if (mh == NULL) return;
683 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
684 mem_cb.fn_p=cb;
685 lh_doall_arg(mh,(void (*)())cb_leak,mem_cb.char_p);
686 mem_cb.char_p=NULL;
687 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
688 }
689
690#ifndef NO_FP_API
691void CRYPTO_mem_leaks_fp(FILE *fp)
692 {
693 BIO *b;
694
695 if (mh == NULL) return;
696 if ((b=BIO_new(BIO_s_file())) == NULL)
697 return;
698 BIO_set_fp(b,fp,BIO_NOCLOSE);
699 CRYPTO_mem_leaks(b);
700 BIO_free(b);
701 }
702#endif
703
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
index 53450f8754..f05e15df96 100644
--- a/src/lib/libcrypto/objects/Makefile.ssl
+++ b/src/lib/libcrypto/objects/Makefile.ssl
@@ -37,9 +37,6 @@ top:
37 37
38all: obj_dat.h lib 38all: obj_dat.h lib
39 39
40obj_dat.h: objects.h obj_dat.pl
41 $(PERL) ./obj_dat.pl < objects.h > obj_dat.h
42
43lib: $(LIBOBJ) 40lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 41 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) 42 $(RANLIB) $(LIB)
diff --git a/src/lib/libcrypto/objects/o_names.c b/src/lib/libcrypto/objects/o_names.c
index 4da5e45b9c..d654eb220e 100644
--- a/src/lib/libcrypto/objects/o_names.c
+++ b/src/lib/libcrypto/objects/o_names.c
@@ -4,15 +4,25 @@
4 4
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 8
8/* I use the ex_data stuff to manage the identifiers for the obj_name_types 9/* I use the ex_data stuff to manage the identifiers for the obj_name_types
9 * that applications may define. I only really use the free function field. 10 * that applications may define. I only really use the free function field.
10 */ 11 */
11static LHASH *names_lh=NULL; 12static LHASH *names_lh=NULL;
12static int names_type_num=OBJ_NAME_TYPE_NUM; 13static int names_type_num=OBJ_NAME_TYPE_NUM;
13static STACK *names_cmp=NULL; 14
14static STACK *names_hash=NULL; 15typedef struct name_funcs_st
15static STACK *names_free=NULL; 16 {
17 unsigned long (*hash_func)();
18 int (*cmp_func)();
19 void (*free_func)();
20 } NAME_FUNCS;
21
22DECLARE_STACK_OF(NAME_FUNCS)
23IMPLEMENT_STACK_OF(NAME_FUNCS)
24
25STACK_OF(NAME_FUNCS) *name_funcs_stack;
16 26
17static unsigned long obj_name_hash(OBJ_NAME *a); 27static unsigned long obj_name_hash(OBJ_NAME *a);
18static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); 28static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b);
@@ -31,51 +41,57 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(), int (*cmp_func)(),
31 { 41 {
32 int ret; 42 int ret;
33 int i; 43 int i;
44 NAME_FUNCS *name_funcs;
34 45
35 if (names_free == NULL) 46 if (name_funcs_stack == NULL)
36 { 47 {
37 MemCheck_off(); 48 MemCheck_off();
38 names_hash=sk_new_null(); 49 name_funcs_stack=sk_NAME_FUNCS_new_null();
39 names_cmp=sk_new_null();
40 names_free=sk_new_null();
41 MemCheck_on(); 50 MemCheck_on();
42 } 51 }
43 if ((names_free == NULL) || (names_hash == NULL) || (names_cmp == NULL)) 52 if ((name_funcs_stack == NULL))
44 { 53 {
45 /* ERROR */ 54 /* ERROR */
46 return(0); 55 return(0);
47 } 56 }
48 ret=names_type_num; 57 ret=names_type_num;
49 names_type_num++; 58 names_type_num++;
50 for (i=sk_num(names_free); i<names_type_num; i++) 59 for (i=sk_NAME_FUNCS_num(name_funcs_stack); i<names_type_num; i++)
51 { 60 {
52 MemCheck_off(); 61 MemCheck_off();
53 sk_push(names_hash,(char *)strcmp); 62 name_funcs = Malloc(sizeof(NAME_FUNCS));
54 sk_push(names_cmp,(char *)lh_strhash); 63 name_funcs->hash_func = lh_strhash;
55 sk_push(names_free,NULL); 64 name_funcs->cmp_func = (int (*)())strcmp;
65 name_funcs->free_func = 0; /* NULL is often declared to
66 * ((void *)0), which according
67 * to Compaq C is not really
68 * compatible with a function
69 * pointer. -- Richard Levitte*/
70 sk_NAME_FUNCS_push(name_funcs_stack,name_funcs);
56 MemCheck_on(); 71 MemCheck_on();
57 } 72 }
73 name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
58 if (hash_func != NULL) 74 if (hash_func != NULL)
59 sk_set(names_hash,ret,(char *)hash_func); 75 name_funcs->hash_func = hash_func;
60 if (cmp_func != NULL) 76 if (cmp_func != NULL)
61 sk_set(names_cmp,ret,(char *)cmp_func); 77 name_funcs->cmp_func = cmp_func;
62 if (free_func != NULL) 78 if (free_func != NULL)
63 sk_set(names_free,ret,(char *)free_func); 79 name_funcs->free_func = free_func;
64 return(ret); 80 return(ret);
65 } 81 }
66 82
67static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) 83static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
68 { 84 {
69 int ret; 85 int ret;
70 int (*cmp)();
71 86
72 ret=a->type-b->type; 87 ret=a->type-b->type;
73 if (ret == 0) 88 if (ret == 0)
74 { 89 {
75 if ((names_cmp != NULL) && (sk_num(names_cmp) > a->type)) 90 if ((name_funcs_stack != NULL)
91 && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
76 { 92 {
77 cmp=(int (*)())sk_value(names_cmp,a->type); 93 ret=sk_NAME_FUNCS_value(name_funcs_stack,a->type)
78 ret=cmp(a->name,b->name); 94 ->cmp_func(a->name,b->name);
79 } 95 }
80 else 96 else
81 ret=strcmp(a->name,b->name); 97 ret=strcmp(a->name,b->name);
@@ -86,12 +102,11 @@ static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
86static unsigned long obj_name_hash(OBJ_NAME *a) 102static unsigned long obj_name_hash(OBJ_NAME *a)
87 { 103 {
88 unsigned long ret; 104 unsigned long ret;
89 unsigned long (*hash)();
90 105
91 if ((names_hash != NULL) && (sk_num(names_hash) > a->type)) 106 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
92 { 107 {
93 hash=(unsigned long (*)())sk_value(names_hash,a->type); 108 ret=sk_NAME_FUNCS_value(name_funcs_stack,a->type)
94 ret=hash(a->name); 109 ->hash_func(a->name);
95 } 110 }
96 else 111 else
97 { 112 {
@@ -117,7 +132,7 @@ const char *OBJ_NAME_get(const char *name, int type)
117 132
118 for (;;) 133 for (;;)
119 { 134 {
120 ret=(OBJ_NAME *)lh_retrieve(names_lh,(char *)&on); 135 ret=(OBJ_NAME *)lh_retrieve(names_lh,&on);
121 if (ret == NULL) return(NULL); 136 if (ret == NULL) return(NULL);
122 if ((ret->alias) && !alias) 137 if ((ret->alias) && !alias)
123 { 138 {
@@ -133,7 +148,6 @@ const char *OBJ_NAME_get(const char *name, int type)
133 148
134int OBJ_NAME_add(const char *name, int type, const char *data) 149int OBJ_NAME_add(const char *name, int type, const char *data)
135 { 150 {
136 void (*f)();
137 OBJ_NAME *onp,*ret; 151 OBJ_NAME *onp,*ret;
138 int alias; 152 int alias;
139 153
@@ -154,16 +168,20 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
154 onp->type=type; 168 onp->type=type;
155 onp->data=data; 169 onp->data=data;
156 170
157 ret=(OBJ_NAME *)lh_insert(names_lh,(char *)onp); 171 ret=(OBJ_NAME *)lh_insert(names_lh,onp);
158 if (ret != NULL) 172 if (ret != NULL)
159 { 173 {
160 /* free things */ 174 /* free things */
161 if ((names_free != NULL) && (sk_num(names_free) > ret->type)) 175 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type))
162 { 176 {
163 f=(void (*)())sk_value(names_free,ret->type); 177 /* XXX: I'm not sure I understand why the free
164 f(ret->name,ret->type,ret->data); 178 * function should get three arguments...
179 * -- Richard Levitte
180 */
181 sk_NAME_FUNCS_value(name_funcs_stack,ret->type)
182 ->free_func(ret->name,ret->type,ret->data);
165 } 183 }
166 Free((char *)ret); 184 Free(ret);
167 } 185 }
168 else 186 else
169 { 187 {
@@ -179,23 +197,26 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
179int OBJ_NAME_remove(const char *name, int type) 197int OBJ_NAME_remove(const char *name, int type)
180 { 198 {
181 OBJ_NAME on,*ret; 199 OBJ_NAME on,*ret;
182 void (*f)();
183 200
184 if (names_lh == NULL) return(0); 201 if (names_lh == NULL) return(0);
185 202
186 type&= ~OBJ_NAME_ALIAS; 203 type&= ~OBJ_NAME_ALIAS;
187 on.name=name; 204 on.name=name;
188 on.type=type; 205 on.type=type;
189 ret=(OBJ_NAME *)lh_delete(names_lh,(char *)&on); 206 ret=(OBJ_NAME *)lh_delete(names_lh,&on);
190 if (ret != NULL) 207 if (ret != NULL)
191 { 208 {
192 /* free things */ 209 /* free things */
193 if ((names_free != NULL) && (sk_num(names_free) > type)) 210 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type))
194 { 211 {
195 f=(void (*)())sk_value(names_free,type); 212 /* XXX: I'm not sure I understand why the free
196 f(ret->name,ret->type,ret->data); 213 * function should get three arguments...
214 * -- Richard Levitte
215 */
216 sk_NAME_FUNCS_value(name_funcs_stack,ret->type)
217 ->free_func(ret->name,ret->type,ret->data);
197 } 218 }
198 Free((char *)ret); 219 Free(ret);
199 return(1); 220 return(1);
200 } 221 }
201 else 222 else
@@ -215,6 +236,11 @@ static void names_lh_free(OBJ_NAME *onp, int type)
215 } 236 }
216 } 237 }
217 238
239static void name_funcs_free(NAME_FUNCS *ptr)
240 {
241 Free(ptr);
242 }
243
218void OBJ_NAME_cleanup(int type) 244void OBJ_NAME_cleanup(int type)
219 { 245 {
220 unsigned long down_load; 246 unsigned long down_load;
@@ -229,13 +255,9 @@ void OBJ_NAME_cleanup(int type)
229 if (type < 0) 255 if (type < 0)
230 { 256 {
231 lh_free(names_lh); 257 lh_free(names_lh);
232 sk_free(names_hash); 258 sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free);
233 sk_free(names_cmp);
234 sk_free(names_free);
235 names_lh=NULL; 259 names_lh=NULL;
236 names_hash=NULL; 260 name_funcs_stack = NULL;
237 names_cmp=NULL;
238 names_free=NULL;
239 } 261 }
240 else 262 else
241 names_lh->down_load=down_load; 263 names_lh->down_load=down_load;
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index d47b874399..da6df3762a 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -214,16 +214,12 @@ int OBJ_new_nid(int num)
214int OBJ_add_object(ASN1_OBJECT *obj) 214int OBJ_add_object(ASN1_OBJECT *obj)
215 { 215 {
216 ASN1_OBJECT *o; 216 ASN1_OBJECT *o;
217 ADDED_OBJ *ao[4],*aop; 217 ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
218 int i; 218 int i;
219 219
220 if (added == NULL) 220 if (added == NULL)
221 if (!init_added()) return(0); 221 if (!init_added()) return(0);
222 if ((o=OBJ_dup(obj)) == NULL) goto err; 222 if ((o=OBJ_dup(obj)) == NULL) goto err;
223 ao[ADDED_DATA]=NULL;
224 ao[ADDED_SNAME]=NULL;
225 ao[ADDED_LNAME]=NULL;
226 ao[ADDED_NID]=NULL;
227 ao[ADDED_NID]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ)); 223 ao[ADDED_NID]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ));
228 if ((o->length != 0) && (obj->data != NULL)) 224 if ((o->length != 0) && (obj->data != NULL))
229 ao[ADDED_DATA]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ)); 225 ao[ADDED_DATA]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ));
@@ -238,7 +234,7 @@ int OBJ_add_object(ASN1_OBJECT *obj)
238 { 234 {
239 ao[i]->type=i; 235 ao[i]->type=i;
240 ao[i]->obj=o; 236 ao[i]->obj=o;
241 aop=(ADDED_OBJ *)lh_insert(added,(char *)ao[i]); 237 aop=(ADDED_OBJ *)lh_insert(added,ao[i]);
242 /* memory leak, buit should not normally matter */ 238 /* memory leak, buit should not normally matter */
243 if (aop != NULL) 239 if (aop != NULL)
244 Free(aop); 240 Free(aop);
@@ -276,7 +272,7 @@ ASN1_OBJECT *OBJ_nid2obj(int n)
276 ad.type=ADDED_NID; 272 ad.type=ADDED_NID;
277 ad.obj= &ob; 273 ad.obj= &ob;
278 ob.nid=n; 274 ob.nid=n;
279 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 275 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
280 if (adp != NULL) 276 if (adp != NULL)
281 return(adp->obj); 277 return(adp->obj);
282 else 278 else
@@ -308,7 +304,7 @@ const char *OBJ_nid2sn(int n)
308 ad.type=ADDED_NID; 304 ad.type=ADDED_NID;
309 ad.obj= &ob; 305 ad.obj= &ob;
310 ob.nid=n; 306 ob.nid=n;
311 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 307 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
312 if (adp != NULL) 308 if (adp != NULL)
313 return(adp->obj->sn); 309 return(adp->obj->sn);
314 else 310 else
@@ -340,7 +336,7 @@ const char *OBJ_nid2ln(int n)
340 ad.type=ADDED_NID; 336 ad.type=ADDED_NID;
341 ad.obj= &ob; 337 ad.obj= &ob;
342 ob.nid=n; 338 ob.nid=n;
343 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 339 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
344 if (adp != NULL) 340 if (adp != NULL)
345 return(adp->obj->ln); 341 return(adp->obj->ln);
346 else 342 else
@@ -365,7 +361,7 @@ int OBJ_obj2nid(ASN1_OBJECT *a)
365 { 361 {
366 ad.type=ADDED_DATA; 362 ad.type=ADDED_DATA;
367 ad.obj=a; 363 ad.obj=a;
368 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 364 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
369 if (adp != NULL) return (adp->obj->nid); 365 if (adp != NULL) return (adp->obj->nid);
370 } 366 }
371 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ, 367 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,
@@ -504,7 +500,7 @@ int OBJ_ln2nid(const char *s)
504 { 500 {
505 ad.type=ADDED_LNAME; 501 ad.type=ADDED_LNAME;
506 ad.obj= &o; 502 ad.obj= &o;
507 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 503 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
508 if (adp != NULL) return (adp->obj->nid); 504 if (adp != NULL) return (adp->obj->nid);
509 } 505 }
510 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs,NUM_LN, 506 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs,NUM_LN,
@@ -523,7 +519,7 @@ int OBJ_sn2nid(const char *s)
523 { 519 {
524 ad.type=ADDED_SNAME; 520 ad.type=ADDED_SNAME;
525 ad.obj= &o; 521 ad.obj= &o;
526 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 522 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
527 if (adp != NULL) return (adp->obj->nid); 523 if (adp != NULL) return (adp->obj->nid);
528 } 524 }
529 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN, 525 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN,
@@ -647,7 +643,7 @@ int OBJ_create(char *oid, char *sn, char *ln)
647 ok=OBJ_add_object(op); 643 ok=OBJ_add_object(op);
648err: 644err:
649 ASN1_OBJECT_free(op); 645 ASN1_OBJECT_free(op);
650 Free((char *)buf); 646 Free(buf);
651 return(ok); 647 return(ok);
652 } 648 }
653 649
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 5043daef2a..e6e3c3b9c0 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -38,7 +38,10 @@ sub expand_obj
38 return(%objn); 38 return(%objn);
39 } 39 }
40 40
41while (<>) 41open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
42open (OUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
43
44while (<IN>)
42 { 45 {
43 next unless /^\#define\s+(\S+)\s+(.*)$/; 46 next unless /^\#define\s+(\S+)\s+(.*)$/;
44 $v=$1; 47 $v=$1;
@@ -55,6 +58,7 @@ while (<>)
55 $objd{$v}=$d; 58 $objd{$v}=$d;
56 } 59 }
57 } 60 }
61close IN;
58 62
59%ob=&expand_obj(*objd); 63%ob=&expand_obj(*objd);
60 64
@@ -132,7 +136,7 @@ foreach (sort obj_cmp @a)
132 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v)); 136 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v));
133 } 137 }
134 138
135print <<'EOF'; 139print OUT <<'EOF';
136/* lib/obj/obj_dat.h */ 140/* lib/obj/obj_dat.h */
137/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 141/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
138 * All rights reserved. 142 * All rights reserved.
@@ -193,21 +197,21 @@ print <<'EOF';
193 197
194/* THIS FILE IS GENERATED FROM Objects.h by obj_dat.pl via the 198/* THIS FILE IS GENERATED FROM Objects.h by obj_dat.pl via the
195 * following command: 199 * following command:
196 * perl obj_dat.pl < objects.h > obj_dat.h 200 * perl obj_dat.pl objects.h obj_dat.h
197 */ 201 */
198 202
199EOF 203EOF
200 204
201printf "#define NUM_NID %d\n",$n; 205printf OUT "#define NUM_NID %d\n",$n;
202printf "#define NUM_SN %d\n",$#sn+1; 206printf OUT "#define NUM_SN %d\n",$#sn+1;
203printf "#define NUM_LN %d\n",$#ln+1; 207printf OUT "#define NUM_LN %d\n",$#ln+1;
204printf "#define NUM_OBJ %d\n\n",$#ob+1; 208printf OUT "#define NUM_OBJ %d\n\n",$#ob+1;
205 209
206printf "static unsigned char lvalues[%d]={\n",$lvalues+1; 210printf OUT "static unsigned char lvalues[%d]={\n",$lvalues+1;
207print @lvalues; 211print OUT @lvalues;
208print "};\n\n"; 212print OUT "};\n\n";
209 213
210printf "static ASN1_OBJECT nid_objs[NUM_NID]={\n"; 214printf OUT "static ASN1_OBJECT nid_objs[NUM_NID]={\n";
211foreach (@out) 215foreach (@out)
212 { 216 {
213 if (length($_) > 75) 217 if (length($_) > 75)
@@ -218,30 +222,32 @@ foreach (@out)
218 $t=$out.$_.","; 222 $t=$out.$_.",";
219 if (length($t) > 70) 223 if (length($t) > 70)
220 { 224 {
221 print "$out\n"; 225 print OUT "$out\n";
222 $t="\t$_,"; 226 $t="\t$_,";
223 } 227 }
224 $out=$t; 228 $out=$t;
225 } 229 }
226 chop $out; 230 chop $out;
227 print "$out"; 231 print OUT "$out";
228 } 232 }
229 else 233 else
230 { print $_; } 234 { print OUT $_; }
231 } 235 }
232print "};\n\n"; 236print OUT "};\n\n";
237
238printf OUT "static ASN1_OBJECT *sn_objs[NUM_SN]={\n";
239print OUT @sn;
240print OUT "};\n\n";
233 241
234printf "static ASN1_OBJECT *sn_objs[NUM_SN]={\n"; 242printf OUT "static ASN1_OBJECT *ln_objs[NUM_LN]={\n";
235print @sn; 243print OUT @ln;
236print "};\n\n"; 244print OUT "};\n\n";
237 245
238printf "static ASN1_OBJECT *ln_objs[NUM_LN]={\n"; 246printf OUT "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n";
239print @ln; 247print OUT @ob;
240print "};\n\n"; 248print OUT "};\n\n";
241 249
242printf "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n"; 250close OUT;
243print @ob;
244print "};\n\n";
245 251
246sub der_it 252sub der_it
247 { 253 {
diff --git a/src/lib/libcrypto/objects/objects.h b/src/lib/libcrypto/objects/objects.h
index d03748e022..d1a5ad2502 100644
--- a/src/lib/libcrypto/objects/objects.h
+++ b/src/lib/libcrypto/objects/objects.h
@@ -110,10 +110,12 @@ extern "C" {
110#define NID_md5WithRSAEncryption 8 110#define NID_md5WithRSAEncryption 8
111#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L 111#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L
112 112
113#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES"
113#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" 114#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC"
114#define NID_pbeWithMD2AndDES_CBC 9 115#define NID_pbeWithMD2AndDES_CBC 9
115#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L 116#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L
116 117
118#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES"
117#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" 119#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC"
118#define NID_pbeWithMD5AndDES_CBC 10 120#define NID_pbeWithMD5AndDES_CBC 10
119#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L 121#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L
@@ -230,6 +232,7 @@ extern "C" {
230#define SN_idea_cbc "IDEA-CBC" 232#define SN_idea_cbc "IDEA-CBC"
231#define LN_idea_cbc "idea-cbc" 233#define LN_idea_cbc "idea-cbc"
232#define NID_idea_cbc 34 234#define NID_idea_cbc 34
235#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L
233 236
234#define SN_idea_cfb64 "IDEA-CFB" 237#define SN_idea_cfb64 "IDEA-CFB"
235#define LN_idea_cfb64 "idea-cfb" 238#define LN_idea_cfb64 "idea-cfb"
@@ -380,6 +383,7 @@ extern "C" {
380#define OBJ_dsa_2 OBJ_algorithm,12L 383#define OBJ_dsa_2 OBJ_algorithm,12L
381 384
382/* proposed by microsoft to RSA */ 385/* proposed by microsoft to RSA */
386#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64"
383#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" 387#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC"
384#define NID_pbeWithSHA1AndRC2_CBC 68 388#define NID_pbeWithSHA1AndRC2_CBC 68
385#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L 389#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L
@@ -499,6 +503,7 @@ extern "C" {
499#define SN_bf_cbc "BF-CBC" 503#define SN_bf_cbc "BF-CBC"
500#define LN_bf_cbc "bf-cbc" 504#define LN_bf_cbc "bf-cbc"
501#define NID_bf_cbc 91 505#define NID_bf_cbc 91
506#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L
502 507
503#define SN_bf_ecb "BF-ECB" 508#define SN_bf_ecb "BF-ECB"
504#define LN_bf_ecb "bf-ecb" 509#define LN_bf_ecb "bf-ecb"
@@ -627,7 +632,7 @@ extern "C" {
627#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L 632#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L
628 633
629/* The name should actually be rsaSignatureWithripemd160, but I'm going 634/* The name should actually be rsaSignatureWithripemd160, but I'm going
630 * to contiune using the convention I'm using with the other ciphers */ 635 * to continue using the convention I'm using with the other ciphers */
631#define SN_ripemd160WithRSA "RSA-RIPEMD160" 636#define SN_ripemd160WithRSA "RSA-RIPEMD160"
632#define LN_ripemd160WithRSA "ripemd160WithRSA" 637#define LN_ripemd160WithRSA "ripemd160WithRSA"
633#define NID_ripemd160WithRSA 119 638#define NID_ripemd160WithRSA 119
@@ -661,12 +666,12 @@ extern "C" {
661#define SN_rle_compression "RLE" 666#define SN_rle_compression "RLE"
662#define LN_rle_compression "run length compression" 667#define LN_rle_compression "run length compression"
663#define NID_rle_compression 124 668#define NID_rle_compression 124
664#define OBJ_rle_compression 1L,1L,1L,1L,666L.1L 669#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L
665 670
666#define SN_zlib_compression "ZLIB" 671#define SN_zlib_compression "ZLIB"
667#define LN_zlib_compression "zlib compression" 672#define LN_zlib_compression "zlib compression"
668#define NID_zlib_compression 125 673#define NID_zlib_compression 125
669#define OBJ_zlib_compression 1L,1L,1L,1L,666L.2L 674#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L
670 675
671#define SN_ext_key_usage "extendedKeyUsage" 676#define SN_ext_key_usage "extendedKeyUsage"
672#define LN_ext_key_usage "X509v3 Extended Key Usage" 677#define LN_ext_key_usage "X509v3 Extended Key Usage"
@@ -735,7 +740,7 @@ extern "C" {
735#define NID_ms_efs 138 740#define NID_ms_efs 138
736#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L 741#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L
737 742
738/* Addidional usage: Netscape */ 743/* Additional usage: Netscape */
739 744
740#define SN_ns_sgc "nsSGC" 745#define SN_ns_sgc "nsSGC"
741#define LN_ns_sgc "Netscape Server Gated Crypto" 746#define LN_ns_sgc "Netscape Server Gated Crypto"
@@ -767,26 +772,32 @@ extern "C" {
767#define OBJ_pkcs12 OBJ_pkcs,12L 772#define OBJ_pkcs12 OBJ_pkcs,12L
768#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 773#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1
769 774
775#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128"
770#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" 776#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4"
771#define NID_pbe_WithSHA1And128BitRC4 144 777#define NID_pbe_WithSHA1And128BitRC4 144
772#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L 778#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L
773 779
780#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40"
774#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" 781#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4"
775#define NID_pbe_WithSHA1And40BitRC4 145 782#define NID_pbe_WithSHA1And40BitRC4 145
776#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L 783#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L
777 784
785#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES"
778#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" 786#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC"
779#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 787#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146
780#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L 788#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L
781 789
790#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES"
782#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" 791#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC"
783#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 792#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147
784#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L 793#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L
785 794
795#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128"
786#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" 796#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC"
787#define NID_pbe_WithSHA1And128BitRC2_CBC 148 797#define NID_pbe_WithSHA1And128BitRC2_CBC 148
788#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L 798#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L
789 799
800#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40"
790#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" 801#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC"
791#define NID_pbe_WithSHA1And40BitRC2_CBC 149 802#define NID_pbe_WithSHA1And40BitRC2_CBC 149
792#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L 803#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L
@@ -876,20 +887,73 @@ extern "C" {
876#define SN_SMIMECapabilities "SMIME-CAPS" 887#define SN_SMIMECapabilities "SMIME-CAPS"
877#define LN_SMIMECapabilities "S/MIME Capabilities" 888#define LN_SMIMECapabilities "S/MIME Capabilities"
878#define NID_SMIMECapabilities 167 889#define NID_SMIMECapabilities 167
879#define OBJ_SMIMECapabilities OBJ_id_pkcs9,15L 890#define OBJ_SMIMECapabilities OBJ_pkcs9,15L
880 891
892#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64"
881#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" 893#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC"
882#define NID_pbeWithMD2AndRC2_CBC 168 894#define NID_pbeWithMD2AndRC2_CBC 168
883#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L 895#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L
884 896
897#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64"
885#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" 898#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC"
886#define NID_pbeWithMD5AndRC2_CBC 169 899#define NID_pbeWithMD5AndRC2_CBC 169
887#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L 900#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L
888 901
902#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES"
889#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" 903#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC"
890#define NID_pbeWithSHA1AndDES_CBC 170 904#define NID_pbeWithSHA1AndDES_CBC 170
891#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L 905#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L
892 906
907/* Extension request OIDs */
908
909#define LN_ms_ext_req "Microsoft Extension Request"
910#define SN_ms_ext_req "msExtReq"
911#define NID_ms_ext_req 171
912#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L
913
914#define LN_ext_req "Extension Request"
915#define SN_ext_req "extReq"
916#define NID_ext_req 172
917#define OBJ_ext_req OBJ_pkcs9,14L
918
919#define SN_name "name"
920#define LN_name "name"
921#define NID_name 173
922#define OBJ_name OBJ_X509,41L
923
924#define SN_dnQualifier "dnQualifier"
925#define LN_dnQualifier "dnQualifier"
926#define NID_dnQualifier 174
927#define OBJ_dnQualifier OBJ_X509,46L
928
929#define SN_id_pe "id-pe"
930#define NID_id_pe 175
931#define OBJ_id_pe OBJ_id_pkix,1L
932
933#define SN_id_ad "id-ad"
934#define NID_id_ad 176
935#define OBJ_id_ad OBJ_id_pkix,48L
936
937#define SN_info_access "authorityInfoAccess"
938#define LN_info_access "Authority Information Access"
939#define NID_info_access 177
940#define OBJ_info_access OBJ_id_pe,1L
941
942#define SN_ad_OCSP "OCSP"
943#define LN_ad_OCSP "OCSP"
944#define NID_ad_OCSP 178
945#define OBJ_ad_OCSP OBJ_id_ad,1L
946
947#define SN_ad_ca_issuers "caIssuers"
948#define LN_ad_ca_issuers "CA Issuers"
949#define NID_ad_ca_issuers 179
950#define OBJ_ad_ca_issuers OBJ_id_ad,2L
951
952#define SN_OSCP_sign "OCSPSigning"
953#define LN_OCSP_sign "OCSP Signing"
954#define NID_OCSP_sign 180
955#define OBJ_OCSP_sign OBJ_id_kp,9L
956
893#include <openssl/bio.h> 957#include <openssl/bio.h>
894#include <openssl/asn1.h> 958#include <openssl/asn1.h>
895 959
diff --git a/src/lib/libcrypto/opensslconf.h.in b/src/lib/libcrypto/opensslconf.h.in
index e4a8f8ad54..1b85ae5989 100644
--- a/src/lib/libcrypto/opensslconf.h.in
+++ b/src/lib/libcrypto/opensslconf.h.in
@@ -1,5 +1,4 @@
1/* crypto/opensslconf.h */ 1/* crypto/opensslconf.h.in */
2/* WARNING: This file is autogenerated by Configure */
3 2
4/* Generate 80386 code? */ 3/* Generate 80386 code? */
5#undef I386_ONLY 4#undef I386_ONLY
@@ -25,11 +24,25 @@
25#define RC2_INT unsigned int 24#define RC2_INT unsigned int
26#endif 25#endif
27 26
28#if defined(HEADER_RC4_H) && !defined(RC4_INT) 27#if defined(HEADER_RC4_H)
28#if !defined(RC4_INT)
29/* using int types make the structure larger but make the code faster 29/* using int types make the structure larger but make the code faster
30 * on most boxes I have tested - up to %20 faster. */ 30 * on most boxes I have tested - up to %20 faster. */
31/*
32 * I don't know what does "most" mean, but declaring "int" is a must on:
33 * - Intel P6 because partial register stalls are very expensive;
34 * - elder Alpha because it lacks byte load/store instructions;
35 */
31#define RC4_INT unsigned int 36#define RC4_INT unsigned int
32#endif 37#endif
38#if !defined(RC4_CHUNK)
39/*
40 * This enables code handling data aligned at natural CPU word
41 * boundary. See crypto/rc4/rc4_enc.c for further details.
42 */
43#undef RC4_CHUNK
44#endif
45#endif
33 46
34#if defined(HEADER_DES_H) && !defined(DES_LONG) 47#if defined(HEADER_DES_H) && !defined(DES_LONG)
35/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a 48/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h
index b841347f05..55d5d06cf5 100644
--- a/src/lib/libcrypto/opensslv.h
+++ b/src/lib/libcrypto/opensslv.h
@@ -7,15 +7,15 @@
7 * 0.9.3-dev 0x00903000 7 * 0.9.3-dev 0x00903000
8 * 0.9.3beta1 0x00903001 8 * 0.9.3beta1 0x00903001
9 * 0.9.3beta2-dev 0x00903002 9 * 0.9.3beta2-dev 0x00903002
10 * 0.9.3beta2 0x00903002 10 * 0.9.3beta2 0x00903002 (same as ...beta2-dev)
11 * 0.9.3 0x00903100 11 * 0.9.3 0x00903100
12 * 0.9.3a 0x00903101 12 * 0.9.3a 0x00903101
13 * 0.9.4 0x00904100 13 * 0.9.4 0x00904100
14 * 1.2.3z 0x1020311a 14 * 1.2.3z 0x1020311a
15 * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) 15 * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
16 */ 16 */
17#define OPENSSL_VERSION_NUMBER 0x00904100L 17#define OPENSSL_VERSION_NUMBER 0x00905100L
18#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.4 09 Aug 1999" 18#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.5 28 Feb 2000"
19#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 19#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
20 20
21#endif /* HEADER_OPENSSLV_H */ 21#endif /* HEADER_OPENSSLV_H */
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h
index fc333e42c8..e4bae0b4aa 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -103,13 +103,16 @@ extern "C" {
103 103
104#define PEM_STRING_X509_OLD "X509 CERTIFICATE" 104#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
105#define PEM_STRING_X509 "CERTIFICATE" 105#define PEM_STRING_X509 "CERTIFICATE"
106#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
106#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" 107#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
107#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" 108#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
108#define PEM_STRING_X509_CRL "X509 CRL" 109#define PEM_STRING_X509_CRL "X509 CRL"
109#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" 110#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
111#define PEM_STRING_PUBLIC "PUBLIC KEY"
110#define PEM_STRING_RSA "RSA PRIVATE KEY" 112#define PEM_STRING_RSA "RSA PRIVATE KEY"
111#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" 113#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
112#define PEM_STRING_DSA "DSA PRIVATE KEY" 114#define PEM_STRING_DSA "DSA PRIVATE KEY"
115#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
113#define PEM_STRING_PKCS7 "PKCS7" 116#define PEM_STRING_PKCS7 "PKCS7"
114#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" 117#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
115#define PEM_STRING_PKCS8INF "PRIVATE KEY" 118#define PEM_STRING_PKCS8INF "PRIVATE KEY"
@@ -528,7 +531,10 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str);
528 531
529DECLARE_PEM_rw(X509, X509) 532DECLARE_PEM_rw(X509, X509)
530 533
534DECLARE_PEM_rw(X509_AUX, X509)
535
531DECLARE_PEM_rw(X509_REQ, X509_REQ) 536DECLARE_PEM_rw(X509_REQ, X509_REQ)
537DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
532 538
533DECLARE_PEM_rw(X509_CRL, X509_CRL) 539DECLARE_PEM_rw(X509_CRL, X509_CRL)
534 540
@@ -545,6 +551,7 @@ DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
545DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) 551DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
546 552
547DECLARE_PEM_rw(RSAPublicKey, RSA) 553DECLARE_PEM_rw(RSAPublicKey, RSA)
554DECLARE_PEM_rw(RSA_PUBKEY, RSA)
548 555
549#endif 556#endif
550 557
@@ -552,6 +559,8 @@ DECLARE_PEM_rw(RSAPublicKey, RSA)
552 559
553DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) 560DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
554 561
562DECLARE_PEM_rw(DSA_PUBKEY, DSA)
563
555DECLARE_PEM_rw(DSAparams, DSA) 564DECLARE_PEM_rw(DSAparams, DSA)
556 565
557#endif 566#endif
@@ -564,10 +573,36 @@ DECLARE_PEM_rw(DHparams, DH)
564 573
565DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) 574DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
566 575
576DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
577
578int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
579 char *kstr, int klen,
580 pem_password_cb *cb, void *u);
567int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, 581int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
568 char *, int, pem_password_cb *, void *); 582 char *, int, pem_password_cb *, void *);
583int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
584 char *kstr, int klen,
585 pem_password_cb *cb, void *u);
586int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
587 char *kstr, int klen,
588 pem_password_cb *cb, void *u);
589EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
590
591int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
592 char *kstr, int klen,
593 pem_password_cb *cb, void *u);
594int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
595 char *kstr, int klen,
596 pem_password_cb *cb, void *u);
597int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
598 char *kstr, int klen,
599 pem_password_cb *cb, void *u);
600
601EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
602
569int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, 603int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
570 char *kstr,int klen, pem_password_cb *cd, void *u); 604 char *kstr,int klen, pem_password_cb *cd, void *u);
605
571#endif /* SSLEAY_MACROS */ 606#endif /* SSLEAY_MACROS */
572 607
573 608
@@ -579,6 +614,8 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
579/* Error codes for the PEM functions. */ 614/* Error codes for the PEM functions. */
580 615
581/* Function codes. */ 616/* Function codes. */
617#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
618#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
582#define PEM_F_DEF_CALLBACK 100 619#define PEM_F_DEF_CALLBACK 100
583#define PEM_F_LOAD_IV 101 620#define PEM_F_LOAD_IV 101
584#define PEM_F_PEM_ASN1_READ 102 621#define PEM_F_PEM_ASN1_READ 102
@@ -586,6 +623,7 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
586#define PEM_F_PEM_ASN1_WRITE 104 623#define PEM_F_PEM_ASN1_WRITE 104
587#define PEM_F_PEM_ASN1_WRITE_BIO 105 624#define PEM_F_PEM_ASN1_WRITE_BIO 105
588#define PEM_F_PEM_DO_HEADER 106 625#define PEM_F_PEM_DO_HEADER 106
626#define PEM_F_PEM_F_DO_PK8KEY_FP 122
589#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 627#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118
590#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 628#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
591#define PEM_F_PEM_READ 108 629#define PEM_F_PEM_READ 108
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c
index bc473f3cff..dc9c35b4b4 100644
--- a/src/lib/libcrypto/pem/pem_all.c
+++ b/src/lib/libcrypto/pem/pem_all.c
@@ -65,10 +65,21 @@
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
69static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa);
70#endif
71#ifndef NO_DSA
72static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa);
73#endif
74
68IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509) 75IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509)
69 76
77IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX)
78
70IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) 79IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ)
71 80
81IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ)
82
72IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL) 83IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL)
73 84
74IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7) 85IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7)
@@ -82,15 +93,92 @@ IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF,
82 93
83#ifndef NO_RSA 94#ifndef NO_RSA
84 95
85IMPLEMENT_PEM_rw_cb(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) 96/* We treat RSA or DSA private keys as a special case.
97 *
98 * For private keys we read in an EVP_PKEY structure with
99 * PEM_read_bio_PrivateKey() and extract the relevant private
100 * key: this means can handle "traditional" and PKCS#8 formats
101 * transparently.
102 */
103
104static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa)
105{
106 RSA *rtmp;
107 if(!key) return NULL;
108 rtmp = EVP_PKEY_get1_RSA(key);
109 EVP_PKEY_free(key);
110 if(!rtmp) return NULL;
111 if(rsa) {
112 RSA_free(*rsa);
113 *rsa = rtmp;
114 }
115 return rtmp;
116}
117
118RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb,
119 void *u)
120{
121 EVP_PKEY *pktmp;
122 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
123 return pkey_get_rsa(pktmp, rsa);
124}
125
126#ifndef NO_FP_API
127
128RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb,
129 void *u)
130{
131 EVP_PKEY *pktmp;
132 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
133 return pkey_get_rsa(pktmp, rsa);
134}
135
136#endif
86 137
138IMPLEMENT_PEM_write_cb(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
87IMPLEMENT_PEM_rw(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) 139IMPLEMENT_PEM_rw(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
140IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
88 141
89#endif 142#endif
90 143
91#ifndef NO_DSA 144#ifndef NO_DSA
92 145
93IMPLEMENT_PEM_rw_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) 146static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa)
147{
148 DSA *dtmp;
149 if(!key) return NULL;
150 dtmp = EVP_PKEY_get1_DSA(key);
151 EVP_PKEY_free(key);
152 if(!dtmp) return NULL;
153 if(dsa) {
154 DSA_free(*dsa);
155 *dsa = dtmp;
156 }
157 return dtmp;
158}
159
160DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb,
161 void *u)
162{
163 EVP_PKEY *pktmp;
164 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
165 return pkey_get_dsa(pktmp, dsa);
166}
167
168IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
169IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
170
171#ifndef NO_FP_API
172
173DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb,
174 void *u)
175{
176 EVP_PKEY *pktmp;
177 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
178 return pkey_get_dsa(pktmp, dsa);
179}
180
181#endif
94 182
95IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams) 183IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams)
96 184
@@ -111,3 +199,5 @@ IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
111 */ 199 */
112IMPLEMENT_PEM_read(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey) 200IMPLEMENT_PEM_read(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey)
113IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey) 201IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey)
202
203IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY)
diff --git a/src/lib/libcrypto/pem/pem_err.c b/src/lib/libcrypto/pem/pem_err.c
index fa70f60998..642129da20 100644
--- a/src/lib/libcrypto/pem/pem_err.c
+++ b/src/lib/libcrypto/pem/pem_err.c
@@ -65,6 +65,8 @@
65#ifndef NO_ERR 65#ifndef NO_ERR
66static ERR_STRING_DATA PEM_str_functs[]= 66static ERR_STRING_DATA PEM_str_functs[]=
67 { 67 {
68{ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_BIO,0), "d2i_PKCS8PrivateKey_bio"},
69{ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_FP,0), "d2i_PKCS8PrivateKey_fp"},
68{ERR_PACK(0,PEM_F_DEF_CALLBACK,0), "DEF_CALLBACK"}, 70{ERR_PACK(0,PEM_F_DEF_CALLBACK,0), "DEF_CALLBACK"},
69{ERR_PACK(0,PEM_F_LOAD_IV,0), "LOAD_IV"}, 71{ERR_PACK(0,PEM_F_LOAD_IV,0), "LOAD_IV"},
70{ERR_PACK(0,PEM_F_PEM_ASN1_READ,0), "PEM_ASN1_read"}, 72{ERR_PACK(0,PEM_F_PEM_ASN1_READ,0), "PEM_ASN1_read"},
@@ -72,6 +74,7 @@ static ERR_STRING_DATA PEM_str_functs[]=
72{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE,0), "PEM_ASN1_write"}, 74{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE,0), "PEM_ASN1_write"},
73{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE_BIO,0), "PEM_ASN1_write_bio"}, 75{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE_BIO,0), "PEM_ASN1_write_bio"},
74{ERR_PACK(0,PEM_F_PEM_DO_HEADER,0), "PEM_do_header"}, 76{ERR_PACK(0,PEM_F_PEM_DO_HEADER,0), "PEM_do_header"},
77{ERR_PACK(0,PEM_F_PEM_F_DO_PK8KEY_FP,0), "PEM_F_DO_PK8KEY_FP"},
75{ERR_PACK(0,PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY,0), "PEM_F_PEM_WRITE_PKCS8PRIVATEKEY"}, 78{ERR_PACK(0,PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY,0), "PEM_F_PEM_WRITE_PKCS8PRIVATEKEY"},
76{ERR_PACK(0,PEM_F_PEM_GET_EVP_CIPHER_INFO,0), "PEM_get_EVP_CIPHER_INFO"}, 79{ERR_PACK(0,PEM_F_PEM_GET_EVP_CIPHER_INFO,0), "PEM_get_EVP_CIPHER_INFO"},
77{ERR_PACK(0,PEM_F_PEM_READ,0), "PEM_read"}, 80{ERR_PACK(0,PEM_F_PEM_READ,0), "PEM_read"},
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index fec18a4c2e..b65239a920 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -132,6 +132,17 @@ start:
132 } 132 }
133 pp=(char **)&(xi->x509); 133 pp=(char **)&(xi->x509);
134 } 134 }
135 else if ((strcmp(name,PEM_STRING_X509_TRUSTED) == 0))
136 {
137 d2i=(char *(*)())d2i_X509_AUX;
138 if (xi->x509 != NULL)
139 {
140 if (!sk_X509_INFO_push(ret,xi)) goto err;
141 if ((xi=X509_INFO_new()) == NULL) goto err;
142 goto start;
143 }
144 pp=(char **)&(xi->x509);
145 }
135 else if (strcmp(name,PEM_STRING_X509_CRL) == 0) 146 else if (strcmp(name,PEM_STRING_X509_CRL) == 0)
136 { 147 {
137 d2i=(char *(*)())d2i_X509_CRL; 148 d2i=(char *(*)())d2i_X509_CRL;
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 90f02011ba..072211ba0f 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -75,8 +75,17 @@ const char *PEM_version="PEM" OPENSSL_VERSION_PTEXT;
75 75
76static int def_callback(char *buf, int num, int w, void *userdata); 76static int def_callback(char *buf, int num, int w, void *userdata);
77static int load_iv(unsigned char **fromp,unsigned char *to, int num); 77static int load_iv(unsigned char **fromp,unsigned char *to, int num);
78 78static int check_pem(const char *nm, const char *name);
79static int def_callback(char *buf, int num, int w, void *userdata) 79static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
80 int nid, const EVP_CIPHER *enc,
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)
80 { 89 {
81#ifdef NO_FP_API 90#ifdef NO_FP_API
82 /* We should not ever call the default callback routine from 91 /* We should not ever call the default callback routine from
@@ -86,6 +95,12 @@ static int def_callback(char *buf, int num, int w, void *userdata)
86#else 95#else
87 int i,j; 96 int i,j;
88 const char *prompt; 97 const char *prompt;
98 if(key) {
99 i=strlen(key);
100 i=(i > num)?num:i;
101 memcpy(buf,key,i);
102 return(i);
103 }
89 104
90 prompt=EVP_get_pw_prompt(); 105 prompt=EVP_get_pw_prompt();
91 if (prompt == NULL) 106 if (prompt == NULL)
@@ -168,6 +183,47 @@ char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x,
168 } 183 }
169#endif 184#endif
170 185
186static int check_pem(const char *nm, const char *name)
187{
188 /* Normal matching nm and name */
189 if (!strcmp(nm,name)) return 1;
190
191 /* Make PEM_STRING_EVP_PKEY match any private key */
192
193 if(!strcmp(nm,PEM_STRING_PKCS8) &&
194 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
195
196 if(!strcmp(nm,PEM_STRING_PKCS8INF) &&
197 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
198
199 if(!strcmp(nm,PEM_STRING_RSA) &&
200 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
201
202 if(!strcmp(nm,PEM_STRING_DSA) &&
203 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
204
205 /* Permit older strings */
206
207 if(!strcmp(nm,PEM_STRING_X509_OLD) &&
208 !strcmp(name,PEM_STRING_X509)) return 1;
209
210 if(!strcmp(nm,PEM_STRING_X509_REQ_OLD) &&
211 !strcmp(name,PEM_STRING_X509_REQ)) return 1;
212
213 /* Allow normal certs to be read as trusted certs */
214 if(!strcmp(nm,PEM_STRING_X509) &&
215 !strcmp(name,PEM_STRING_X509_TRUSTED)) return 1;
216
217 if(!strcmp(nm,PEM_STRING_X509_OLD) &&
218 !strcmp(name,PEM_STRING_X509_TRUSTED)) return 1;
219
220 /* Some CAs use PKCS#7 with CERTIFICATE headers */
221 if(!strcmp(nm, PEM_STRING_X509) &&
222 !strcmp(name, PEM_STRING_PKCS7)) return 1;
223
224 return 0;
225}
226
171char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, 227char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
172 pem_password_cb *cb, void *u) 228 pem_password_cb *cb, void *u)
173 { 229 {
@@ -179,22 +235,13 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
179 235
180 for (;;) 236 for (;;)
181 { 237 {
182 if (!PEM_read_bio(bp,&nm,&header,&data,&len)) return(NULL); 238 if (!PEM_read_bio(bp,&nm,&header,&data,&len)) {
183 if ( (strcmp(nm,name) == 0) || 239 if(ERR_GET_REASON(ERR_peek_error()) ==
184 ((strcmp(nm,PEM_STRING_RSA) == 0) && 240 PEM_R_NO_START_LINE)
185 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) || 241 ERR_add_error_data(2, "Expecting: ", name);
186 ((strcmp(nm,PEM_STRING_DSA) == 0) && 242 return(NULL);
187 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) || 243 }
188 ((strcmp(nm,PEM_STRING_PKCS8) == 0) && 244 if(check_pem(nm, name)) break;
189 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||
190 ((strcmp(nm,PEM_STRING_PKCS8INF) == 0) &&
191 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||
192 ((strcmp(nm,PEM_STRING_X509_OLD) == 0) &&
193 (strcmp(name,PEM_STRING_X509) == 0)) ||
194 ((strcmp(nm,PEM_STRING_X509_REQ_OLD) == 0) &&
195 (strcmp(name,PEM_STRING_X509_REQ) == 0))
196 )
197 break;
198 Free(nm); 245 Free(nm);
199 Free(header); 246 Free(header);
200 Free(data); 247 Free(data);
@@ -218,7 +265,7 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
218 X509_SIG *p8; 265 X509_SIG *p8;
219 int klen; 266 int klen;
220 char psbuf[PEM_BUFSIZE]; 267 char psbuf[PEM_BUFSIZE];
221 p8 = d2i_X509_SIG((X509_SIG **)x, &p, len); 268 p8 = d2i_X509_SIG(NULL, &p, len);
222 if(!p8) goto p8err; 269 if(!p8) goto p8err;
223 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u); 270 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u);
224 else klen=def_callback(psbuf,PEM_BUFSIZE,0,u); 271 else klen=def_callback(psbuf,PEM_BUFSIZE,0,u);
@@ -231,6 +278,10 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
231 X509_SIG_free(p8); 278 X509_SIG_free(p8);
232 if(!p8inf) goto p8err; 279 if(!p8inf) goto p8err;
233 ret = (char *)EVP_PKCS82PKEY(p8inf); 280 ret = (char *)EVP_PKCS82PKEY(p8inf);
281 if(x) {
282 if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
283 *x = ret;
284 }
234 PKCS8_PRIV_KEY_INFO_free(p8inf); 285 PKCS8_PRIV_KEY_INFO_free(p8inf);
235 } 286 }
236 } else ret=d2i(x,&p,len); 287 } else ret=d2i(x,&p,len);
@@ -321,8 +372,9 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
321#endif 372#endif
322 kstr=(unsigned char *)buf; 373 kstr=(unsigned char *)buf;
323 } 374 }
324 RAND_seed(data,i);/* put in the RSA key. */ 375 RAND_add(data,i,0);/* put in the RSA key. */
325 RAND_bytes(iv,8); /* Generate a salt */ 376 if (RAND_bytes(iv,8) <= 0) /* Generate a salt */
377 goto err;
326 /* The 'iv' is used as the iv and as a salt. It is 378 /* The 'iv' is used as the iv and as a salt. It is
327 * NOT taken from the BytesToKey function */ 379 * NOT taken from the BytesToKey function */
328 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL); 380 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL);
@@ -743,16 +795,44 @@ err:
743 return(0); 795 return(0);
744 } 796 }
745 797
746/* This function writes a private key in PKCS#8 format: it is a "drop in" 798/* These functions write a private key in PKCS#8 format: it is a "drop in"
747 * replacement for PEM_write_bio_PrivateKey(). As usual if 'enc' is NULL then 799 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
748 * it uses the unencrypted private key form. It uses PKCS#5 v2.0 password based 800 * is NULL then it uses the unencrypted private key form. The 'nid' versions
749 * encryption algorithms. 801 * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0.
750 */ 802 */
751 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
752int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, 811int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
753 char *kstr, int klen, 812 char *kstr, int klen,
754 pem_password_cb *cb, void *u) 813 pem_password_cb *cb, void *u)
755{ 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{
756 X509_SIG *p8; 836 X509_SIG *p8;
757 PKCS8_PRIV_KEY_INFO *p8inf; 837 PKCS8_PRIV_KEY_INFO *p8inf;
758 char buf[PEM_BUFSIZE]; 838 char buf[PEM_BUFSIZE];
@@ -762,7 +842,7 @@ int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
762 PEM_R_ERROR_CONVERTING_PRIVATE_KEY); 842 PEM_R_ERROR_CONVERTING_PRIVATE_KEY);
763 return 0; 843 return 0;
764 } 844 }
765 if(enc) { 845 if(enc || (nid != -1)) {
766 if(!kstr) { 846 if(!kstr) {
767 if(!cb) klen = def_callback(buf, PEM_BUFSIZE, 1, u); 847 if(!cb) klen = def_callback(buf, PEM_BUFSIZE, 1, u);
768 else klen = cb(buf, PEM_BUFSIZE, 1, u); 848 else klen = cb(buf, PEM_BUFSIZE, 1, u);
@@ -775,29 +855,109 @@ int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
775 855
776 kstr = buf; 856 kstr = buf;
777 } 857 }
778 p8 = PKCS8_encrypt(-1, enc, kstr, klen, NULL, 0, 0, p8inf); 858 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);
779 if(kstr == buf) memset(buf, 0, klen); 859 if(kstr == buf) memset(buf, 0, klen);
780 PKCS8_PRIV_KEY_INFO_free(p8inf); 860 PKCS8_PRIV_KEY_INFO_free(p8inf);
781 ret = PEM_write_bio_PKCS8(bp, p8); 861 if(isder) ret = i2d_PKCS8_bio(bp, p8);
862 else ret = PEM_write_bio_PKCS8(bp, p8);
782 X509_SIG_free(p8); 863 X509_SIG_free(p8);
783 return ret; 864 return ret;
784 } else { 865 } else {
785 ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf); 866 if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
867 else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf);
786 PKCS8_PRIV_KEY_INFO_free(p8inf); 868 PKCS8_PRIV_KEY_INFO_free(p8inf);
787 return ret; 869 return ret;
788 } 870 }
789} 871}
790 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
791int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, 929int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
792 char *kstr, int klen, pem_password_cb *cb, void *u) 930 char *kstr, int klen, pem_password_cb *cb, void *u)
793{ 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{
794 BIO *bp; 939 BIO *bp;
795 int ret; 940 int ret;
796 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { 941 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
797 PEMerr(PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY,ERR_R_BUF_LIB); 942 PEMerr(PEM_F_PEM_F_DO_PK8KEY_FP,ERR_R_BUF_LIB);
798 return(0); 943 return(0);
799 } 944 }
800 ret = PEM_write_bio_PKCS8PrivateKey(bp, x, enc, kstr, klen, cb, u); 945 ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u);
801 BIO_free(bp); 946 BIO_free(bp);
802 return ret; 947 return ret;
803} 948}
949
950EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
951{
952 BIO *bp;
953 EVP_PKEY *ret;
954 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
955 PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP,ERR_R_BUF_LIB);
956 return NULL;
957 }
958 ret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u);
959 BIO_free(bp);
960 return ret;
961}
962
963#endif
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c
index 23f95beb1e..126e29d375 100644
--- a/src/lib/libcrypto/pem/pem_seal.c
+++ b/src/lib/libcrypto/pem/pem_seal.c
@@ -175,4 +175,10 @@ err:
175 if (s != NULL) Free(s); 175 if (s != NULL) Free(s);
176 return(ret); 176 return(ret);
177 } 177 }
178#else /* !NO_RSA */
179
180# if PEDANTIC
181static void *dummy=&dummy;
182# endif
183
178#endif 184#endif
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
index 51dcce067f..252a57bdb5 100644
--- a/src/lib/libcrypto/perlasm/x86ms.pl
+++ b/src/lib/libcrypto/perlasm/x86ms.pl
@@ -341,7 +341,14 @@ sub main'set_label
341 $label{$_[0]}="${label}${_[0]}"; 341 $label{$_[0]}="${label}${_[0]}";
342 $label++; 342 $label++;
343 } 343 }
344 push(@out,"$label{$_[0]}:\n"); 344 if((defined $_[1]) && ($_[1] == 1))
345 {
346 push(@out,"$label{$_[0]}::\n");
347 }
348 else
349 {
350 push(@out,"$label{$_[0]}:\n");
351 }
345 } 352 }
346 353
347sub main'data_word 354sub main'data_word
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index 8c456b14af..60d75f5ce4 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -368,10 +368,10 @@ sub main'function_end_B
368 368
369 $func=$under.$func; 369 $func=$under.$func;
370 370
371 push(@out,".${func}_end:\n"); 371 push(@out,".L_${func}_end:\n");
372 if ($main'cpp) 372 if ($main'cpp)
373 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); } 373 { push(@out,"\tSIZE($func,.L_${func}_end-$func)\n"); }
374 else { push(@out,"\t.size\t$func,.${func}_end-$func\n"); } 374 else { push(@out,"\t.size\t$func,.L_${func}_end-$func\n"); }
375 push(@out,".ident \"desasm.pl\"\n"); 375 push(@out,".ident \"desasm.pl\"\n");
376 $stack=0; 376 $stack=0;
377 %label=(); 377 %label=();
diff --git a/src/lib/libcrypto/pkcs12/Makefile.ssl b/src/lib/libcrypto/pkcs12/Makefile.ssl
index 7b0c65fad9..5716f608b6 100644
--- a/src/lib/libcrypto/pkcs12/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs12/Makefile.ssl
@@ -1,5 +1,5 @@
1# 1#
2# SSLeay/crypto/asn1/Makefile 2# SSLeay/crypto/pkcs12/Makefile
3# 3#
4 4
5DIR= pkcs12 5DIR= pkcs12
@@ -24,10 +24,10 @@ APPS=
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c p12_decr.c \ 25LIBSRC= p12_add.c p12_attr.c p12_bags.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\ 26 p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c p12_mutl.c\
27 p12_sbag.c p12_utl.c pk12err.c 27 p12_sbag.c p12_utl.c p12_npas.c pk12err.c
28LIBOBJ= p12_add.o p12_attr.o p12_bags.o p12_crpt.o p12_crt.o p12_decr.o \ 28LIBOBJ= p12_add.o p12_attr.o p12_bags.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\ 29 p12_init.o p12_key.o p12_kiss.o p12_lib.o p12_mac.o p12_mutl.o\
30 p12_sbag.o p12_utl.o pk12err.o 30 p12_sbag.o p12_utl.o p12_npas.o pk12err.o
31 31
32SRC= $(LIBSRC) 32SRC= $(LIBSRC)
33 33
@@ -293,6 +293,23 @@ p12_mutl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
293p12_mutl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 293p12_mutl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
294p12_mutl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 294p12_mutl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
295p12_mutl.o: ../cryptlib.h 295p12_mutl.o: ../cryptlib.h
296p12_npas.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
297p12_npas.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
298p12_npas.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
299p12_npas.o: ../../include/openssl/des.h ../../include/openssl/dh.h
300p12_npas.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
301p12_npas.o: ../../include/openssl/err.h ../../include/openssl/evp.h
302p12_npas.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
303p12_npas.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
304p12_npas.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
305p12_npas.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h
306p12_npas.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
307p12_npas.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
308p12_npas.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
309p12_npas.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
310p12_npas.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
311p12_npas.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
312p12_npas.o: ../../include/openssl/x509_vfy.h
296p12_sbag.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 313p12_sbag.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
297p12_sbag.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 314p12_sbag.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
298p12_sbag.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 315p12_sbag.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
diff --git a/src/lib/libcrypto/pkcs12/p12_add.c b/src/lib/libcrypto/pkcs12/p12_add.c
index ae3d9de3b4..d045cbba8d 100644
--- a/src/lib/libcrypto/pkcs12/p12_add.c
+++ b/src/lib/libcrypto/pkcs12/p12_add.c
@@ -133,7 +133,7 @@ PKCS7 *PKCS12_pack_p7data (STACK *sk)
133 return NULL; 133 return NULL;
134 } 134 }
135 p7->type = OBJ_nid2obj(NID_pkcs7_data); 135 p7->type = OBJ_nid2obj(NID_pkcs7_data);
136 if (!(p7->d.data = ASN1_OCTET_STRING_new())) { 136 if (!(p7->d.data = M_ASN1_OCTET_STRING_new())) {
137 PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); 137 PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE);
138 return NULL; 138 return NULL;
139 } 139 }
@@ -157,20 +157,18 @@ PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,
157 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 157 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
158 return NULL; 158 return NULL;
159 } 159 }
160 p7->type = OBJ_nid2obj(NID_pkcs7_encrypted); 160 if(!PKCS7_set_type(p7, NID_pkcs7_encrypted)) {
161 if (!(p7->d.encrypted = PKCS7_ENCRYPT_new ())) { 161 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA,
162 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 162 PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE);
163 return NULL; 163 return NULL;
164 } 164 }
165 ASN1_INTEGER_set (p7->d.encrypted->version, 0);
166 p7->d.encrypted->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data);
167 if (!(pbe = PKCS5_pbe_set (pbe_nid, iter, salt, saltlen))) { 165 if (!(pbe = PKCS5_pbe_set (pbe_nid, iter, salt, saltlen))) {
168 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 166 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
169 return NULL; 167 return NULL;
170 } 168 }
171 X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); 169 X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm);
172 p7->d.encrypted->enc_data->algorithm = pbe; 170 p7->d.encrypted->enc_data->algorithm = pbe;
173 ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data); 171 M_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data);
174 if (!(p7->d.encrypted->enc_data->enc_data = 172 if (!(p7->d.encrypted->enc_data->enc_data =
175 PKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen, 173 PKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen,
176 (char *)bags, 1))) { 174 (char *)bags, 1))) {
@@ -191,24 +189,28 @@ X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
191 189
192 if (!(p8 = X509_SIG_new())) { 190 if (!(p8 = X509_SIG_new())) {
193 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); 191 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE);
194 return NULL; 192 goto err;
195 } 193 }
196 194
197 if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen); 195 if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen);
198 else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); 196 else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
199 if(!pbe) { 197 if(!pbe) {
200 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); 198 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB);
201 return NULL; 199 goto err;
202 } 200 }
203 X509_ALGOR_free(p8->algor); 201 X509_ALGOR_free(p8->algor);
204 p8->algor = pbe; 202 p8->algor = pbe;
205 ASN1_OCTET_STRING_free(p8->digest); 203 M_ASN1_OCTET_STRING_free(p8->digest);
206 if (!(p8->digest = 204 if (!(p8->digest =
207 PKCS12_i2d_encrypt (pbe, i2d_PKCS8_PRIV_KEY_INFO, pass, passlen, 205 PKCS12_i2d_encrypt (pbe, i2d_PKCS8_PRIV_KEY_INFO, pass, passlen,
208 (char *)p8inf, 0))) { 206 (char *)p8inf, 0))) {
209 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR); 207 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR);
210 return NULL; 208 goto err;
211 } 209 }
212 210
213 return p8; 211 return p8;
212
213 err:
214 X509_SIG_free(p8);
215 return NULL;
214} 216}
diff --git a/src/lib/libcrypto/pkcs12/p12_attr.c b/src/lib/libcrypto/pkcs12/p12_attr.c
index 31c9782b77..f559351d18 100644
--- a/src/lib/libcrypto/pkcs12/p12_attr.c
+++ b/src/lib/libcrypto/pkcs12/p12_attr.c
@@ -73,11 +73,11 @@ int PKCS12_add_localkeyid (PKCS12_SAFEBAG *bag, unsigned char *name,
73 return 0; 73 return 0;
74 } 74 }
75 keyid->type = V_ASN1_OCTET_STRING; 75 keyid->type = V_ASN1_OCTET_STRING;
76 if (!(oct = ASN1_OCTET_STRING_new())) { 76 if (!(oct = M_ASN1_OCTET_STRING_new())) {
77 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE); 77 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
78 return 0; 78 return 0;
79 } 79 }
80 if (!ASN1_OCTET_STRING_set(oct, name, namelen)) { 80 if (!M_ASN1_OCTET_STRING_set(oct, name, namelen)) {
81 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE); 81 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
82 return 0; 82 return 0;
83 } 83 }
@@ -115,11 +115,11 @@ int PKCS8_add_keyusage (PKCS8_PRIV_KEY_INFO *p8, int usage)
115 return 0; 115 return 0;
116 } 116 }
117 keyid->type = V_ASN1_BIT_STRING; 117 keyid->type = V_ASN1_BIT_STRING;
118 if (!(bstr = ASN1_BIT_STRING_new())) { 118 if (!(bstr = M_ASN1_BIT_STRING_new())) {
119 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE); 119 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
120 return 0; 120 return 0;
121 } 121 }
122 if (!ASN1_BIT_STRING_set(bstr, &us_val, 1)) { 122 if (!M_ASN1_BIT_STRING_set(bstr, &us_val, 1)) {
123 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE); 123 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
124 return 0; 124 return 0;
125 } 125 }
@@ -176,7 +176,7 @@ int PKCS12_add_friendlyname_uni (PKCS12_SAFEBAG *bag,
176 return 0; 176 return 0;
177 } 177 }
178 fname->type = V_ASN1_BMPSTRING; 178 fname->type = V_ASN1_BMPSTRING;
179 if (!(bmp = ASN1_BMPSTRING_new())) { 179 if (!(bmp = M_ASN1_BMPSTRING_new())) {
180 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI, 180 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI,
181 ERR_R_MALLOC_FAILURE); 181 ERR_R_MALLOC_FAILURE);
182 return 0; 182 return 0;
diff --git a/src/lib/libcrypto/pkcs12/p12_bags.c b/src/lib/libcrypto/pkcs12/p12_bags.c
index d6eab92c83..c358b06735 100644
--- a/src/lib/libcrypto/pkcs12/p12_bags.c
+++ b/src/lib/libcrypto/pkcs12/p12_bags.c
@@ -171,15 +171,15 @@ void PKCS12_BAGS_free (PKCS12_BAGS *a)
171 switch (OBJ_obj2nid(a->type)) { 171 switch (OBJ_obj2nid(a->type)) {
172 172
173 case NID_x509Certificate: 173 case NID_x509Certificate:
174 ASN1_OCTET_STRING_free (a->value.x509cert); 174 M_ASN1_OCTET_STRING_free (a->value.x509cert);
175 break; 175 break;
176 176
177 case NID_x509Crl: 177 case NID_x509Crl:
178 ASN1_OCTET_STRING_free (a->value.x509crl); 178 M_ASN1_OCTET_STRING_free (a->value.x509crl);
179 break; 179 break;
180 180
181 case NID_sdsiCertificate: 181 case NID_sdsiCertificate:
182 ASN1_IA5STRING_free (a->value.sdsicert); 182 M_ASN1_IA5STRING_free (a->value.sdsicert);
183 break; 183 break;
184 184
185 default: 185 default:
@@ -188,5 +188,5 @@ void PKCS12_BAGS_free (PKCS12_BAGS *a)
188 } 188 }
189 189
190 ASN1_OBJECT_free (a->type); 190 ASN1_OBJECT_free (a->type);
191 Free ((char *)a); 191 Free (a);
192} 192}
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index 6de6f8128f..7b96584f07 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -70,10 +70,12 @@ EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC4, EVP_rc4(), EVP_sha1(),
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
73EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC, 74EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
74 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); 75 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
75EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC, 76EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC,
76 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); 77 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
78#endif
77#ifndef NO_RC2 79#ifndef NO_RC2
78EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(), 80EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(),
79 EVP_sha1(), PKCS12_PBE_keyivgen); 81 EVP_sha1(), PKCS12_PBE_keyivgen);
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index d3d288e187..4be44eac50 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -155,7 +155,7 @@ ASN1_OCTET_STRING *PKCS12_i2d_encrypt (X509_ALGOR *algor, int (*i2d)(),
155 ASN1_OCTET_STRING *oct; 155 ASN1_OCTET_STRING *oct;
156 unsigned char *in, *p; 156 unsigned char *in, *p;
157 int inlen; 157 int inlen;
158 if (!(oct = ASN1_OCTET_STRING_new ())) { 158 if (!(oct = M_ASN1_OCTET_STRING_new ())) {
159 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE); 159 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE);
160 return NULL; 160 return NULL;
161 } 161 }
diff --git a/src/lib/libcrypto/pkcs12/p12_init.c b/src/lib/libcrypto/pkcs12/p12_init.c
index dc6ab41db8..d5d4884c82 100644
--- a/src/lib/libcrypto/pkcs12/p12_init.c
+++ b/src/lib/libcrypto/pkcs12/p12_init.c
@@ -69,11 +69,11 @@ 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 = ASN1_INTEGER_new ())) { 72 if (!(pkcs12->version = M_ASN1_INTEGER_new ())) {
73 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 73 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
74 return NULL; 74 return NULL;
75 } 75 }
76 ASN1_INTEGER_set (pkcs12->version, 3); 76 ASN1_INTEGER_set(pkcs12->version, 3);
77 if (!(pkcs12->authsafes = PKCS7_new())) { 77 if (!(pkcs12->authsafes = PKCS7_new())) {
78 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 78 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
79 return NULL; 79 return NULL;
@@ -82,7 +82,7 @@ PKCS12 *PKCS12_init (int mode)
82 switch (mode) { 82 switch (mode) {
83 case NID_pkcs7_data: 83 case NID_pkcs7_data:
84 if (!(pkcs12->authsafes->d.data = 84 if (!(pkcs12->authsafes->d.data =
85 ASN1_OCTET_STRING_new())) { 85 M_ASN1_OCTET_STRING_new())) {
86 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 86 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
87 return NULL; 87 return NULL;
88 } 88 }
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 25d8cdae57..02fdd20e2f 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -64,7 +64,7 @@
64/* Uncomment out this line to get debugging info about key generation */ 64/* Uncomment out this line to get debugging info about key generation */
65/*#define DEBUG_KEYGEN*/ 65/*#define DEBUG_KEYGEN*/
66#ifdef DEBUG_KEYGEN 66#ifdef DEBUG_KEYGEN
67#include <bio.h> 67#include <openssl/bio.h>
68extern BIO *bio_err; 68extern BIO *bio_err;
69void h__dump (unsigned char *p, int len); 69void h__dump (unsigned char *p, int len);
70#endif 70#endif
@@ -104,13 +104,12 @@ int PKCS12_key_gen_uni (unsigned char *pass, int passlen, unsigned char *salt,
104#ifdef DEBUG_KEYGEN 104#ifdef DEBUG_KEYGEN
105 unsigned char *tmpout = out; 105 unsigned char *tmpout = out;
106 int tmpn = n; 106 int tmpn = n;
107 BIO_printf (bio_err, "KEYGEN DEBUG\n"); 107 fprintf(stderr, "KEYGEN DEBUG\n");
108 BIO_printf (bio_err, "ID %d, ITER %d\n", id, iter); 108 fprintf(stderr, "ID %d, ITER %d\n", id, iter);
109 BIO_printf (bio_err, "Password (length %d):\n", passlen); 109 fprintf(stderr, "Password (length %d):\n", passlen);
110 h__dump (pass, passlen); 110 h__dump(pass, passlen);
111 BIO_printf (bio_err, "Salt (length %d):\n", saltlen); 111 fprintf(stderr, "Salt (length %d):\n", saltlen);
112 h__dump (salt, saltlen); 112 h__dump(salt, saltlen);
113 BIO_printf (bio_err, "ID %d, ITER %d\n\n", id, iter);
114#endif 113#endif
115 v = EVP_MD_block_size (md_type); 114 v = EVP_MD_block_size (md_type);
116 u = EVP_MD_size (md_type); 115 u = EVP_MD_size (md_type);
@@ -150,8 +149,8 @@ int PKCS12_key_gen_uni (unsigned char *pass, int passlen, unsigned char *salt,
150 BN_free (Ij); 149 BN_free (Ij);
151 BN_free (Bpl1); 150 BN_free (Bpl1);
152#ifdef DEBUG_KEYGEN 151#ifdef DEBUG_KEYGEN
153 BIO_printf (bio_err, "Output KEY (length %d)\n", tmpn); 152 fprintf(stderr, "Output KEY (length %d)\n", tmpn);
154 h__dump (tmpout, tmpn); 153 h__dump(tmpout, tmpn);
155#endif 154#endif
156 return 1; 155 return 1;
157 } 156 }
@@ -176,7 +175,7 @@ int PKCS12_key_gen_uni (unsigned char *pass, int passlen, unsigned char *salt,
176#ifdef DEBUG_KEYGEN 175#ifdef DEBUG_KEYGEN
177void h__dump (unsigned char *p, int len) 176void h__dump (unsigned char *p, int len)
178{ 177{
179 for (; len --; p++) BIO_printf (bio_err, "%02X", *p); 178 for (; len --; p++) fprintf(stderr, "%02X", *p);
180 BIO_printf (bio_err, "\n"); 179 fprintf(stderr, "\n");
181} 180}
182#endif 181#endif
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index 767e1303da..08a60556e0 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -139,16 +139,16 @@ static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen,
139 sk_pop_free (asafes, PKCS7_free); 139 sk_pop_free (asafes, PKCS7_free);
140 return 0; 140 return 0;
141 } 141 }
142 if (!parse_bags (bags, pass, passlen, pkey, cert, ca, 142 if (!parse_bags(bags, pass, passlen, pkey, cert, ca,
143 &keyid, &keymatch)) { 143 &keyid, &keymatch)) {
144 sk_pop_free (bags, PKCS12_SAFEBAG_free); 144 sk_pop_free(bags, PKCS12_SAFEBAG_free);
145 sk_pop_free (asafes, PKCS7_free); 145 sk_pop_free(asafes, PKCS7_free);
146 return 0; 146 return 0;
147 } 147 }
148 sk_pop_free (bags, PKCS12_SAFEBAG_free); 148 sk_pop_free(bags, PKCS12_SAFEBAG_free);
149 } 149 }
150 sk_pop_free (asafes, PKCS7_free); 150 sk_pop_free(asafes, PKCS7_free);
151 if (keyid) ASN1_OCTET_STRING_free (keyid); 151 if (keyid) M_ASN1_OCTET_STRING_free(keyid);
152 return 1; 152 return 1;
153} 153}
154 154
@@ -158,8 +158,8 @@ static int parse_bags (STACK *bags, const char *pass, int passlen,
158 ASN1_OCTET_STRING **keyid, char *keymatch) 158 ASN1_OCTET_STRING **keyid, char *keymatch)
159{ 159{
160 int i; 160 int i;
161 for (i = 0; i < sk_num (bags); i++) { 161 for (i = 0; i < sk_num(bags); i++) {
162 if (!parse_bag ((PKCS12_SAFEBAG *)sk_value (bags, i), 162 if (!parse_bag((PKCS12_SAFEBAG *)sk_value (bags, i),
163 pass, passlen, pkey, cert, ca, keyid, 163 pass, passlen, pkey, cert, ca, keyid,
164 keymatch)) return 0; 164 keymatch)) return 0;
165 } 165 }
@@ -170,7 +170,7 @@ static int parse_bags (STACK *bags, const char *pass, int passlen,
170#define MATCH_CERT 0x2 170#define MATCH_CERT 0x2
171#define MATCH_ALL 0x3 171#define MATCH_ALL 0x3
172 172
173static int parse_bag (PKCS12_SAFEBAG *bag, const char *pass, int passlen, 173static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
174 EVP_PKEY **pkey, X509 **cert, STACK **ca, 174 EVP_PKEY **pkey, X509 **cert, STACK **ca,
175 ASN1_OCTET_STRING **keyid, 175 ASN1_OCTET_STRING **keyid,
176 char *keymatch) 176 char *keymatch)
@@ -187,9 +187,9 @@ static int parse_bag (PKCS12_SAFEBAG *bag, const char *pass, int passlen,
187 /* Check for any local key id matching (if needed) */ 187 /* Check for any local key id matching (if needed) */
188 if (lkey && ((*keymatch & MATCH_ALL) != MATCH_ALL)) { 188 if (lkey && ((*keymatch & MATCH_ALL) != MATCH_ALL)) {
189 if (*keyid) { 189 if (*keyid) {
190 if (ASN1_OCTET_STRING_cmp (*keyid, lkey)) lkey = NULL; 190 if (M_ASN1_OCTET_STRING_cmp(*keyid, lkey)) lkey = NULL;
191 } else { 191 } else {
192 if (!(*keyid = ASN1_OCTET_STRING_dup (lkey))) { 192 if (!(*keyid = M_ASN1_OCTET_STRING_dup(lkey))) {
193 PKCS12err(PKCS12_F_PARSE_BAGS,ERR_R_MALLOC_FAILURE); 193 PKCS12err(PKCS12_F_PARSE_BAGS,ERR_R_MALLOC_FAILURE);
194 return 0; 194 return 0;
195 } 195 }
@@ -200,16 +200,16 @@ static int parse_bag (PKCS12_SAFEBAG *bag, const char *pass, int passlen,
200 { 200 {
201 case NID_keyBag: 201 case NID_keyBag:
202 if (!lkey || !pkey) return 1; 202 if (!lkey || !pkey) return 1;
203 if (!(*pkey = EVP_PKCS82PKEY (bag->value.keybag))) return 0; 203 if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag))) return 0;
204 *keymatch |= MATCH_KEY; 204 *keymatch |= MATCH_KEY;
205 break; 205 break;
206 206
207 case NID_pkcs8ShroudedKeyBag: 207 case NID_pkcs8ShroudedKeyBag:
208 if (!lkey || !pkey) return 1; 208 if (!lkey || !pkey) return 1;
209 if (!(p8 = M_PKCS12_decrypt_skey (bag, pass, passlen))) 209 if (!(p8 = M_PKCS12_decrypt_skey(bag, pass, passlen)))
210 return 0; 210 return 0;
211 *pkey = EVP_PKCS82PKEY (p8); 211 *pkey = EVP_PKCS82PKEY(p8);
212 PKCS8_PRIV_KEY_INFO_free (p8); 212 PKCS8_PRIV_KEY_INFO_free(p8);
213 if (!(*pkey)) return 0; 213 if (!(*pkey)) return 0;
214 *keymatch |= MATCH_KEY; 214 *keymatch |= MATCH_KEY;
215 break; 215 break;
diff --git a/src/lib/libcrypto/pkcs12/p12_lib.c b/src/lib/libcrypto/pkcs12/p12_lib.c
index 00a6695d9b..7ca9c14908 100644
--- a/src/lib/libcrypto/pkcs12/p12_lib.c
+++ b/src/lib/libcrypto/pkcs12/p12_lib.c
@@ -104,8 +104,8 @@ PKCS12 *PKCS12_new(void)
104void PKCS12_free (PKCS12 *a) 104void PKCS12_free (PKCS12 *a)
105{ 105{
106 if (a == NULL) return; 106 if (a == NULL) return;
107 ASN1_INTEGER_free (a->version); 107 M_ASN1_INTEGER_free(a->version);
108 PKCS12_MAC_DATA_free (a->mac); 108 PKCS12_MAC_DATA_free (a->mac);
109 PKCS7_free (a->authsafes); 109 PKCS7_free (a->authsafes);
110 Free ((char *)a); 110 Free (a);
111} 111}
diff --git a/src/lib/libcrypto/pkcs12/p12_mac.c b/src/lib/libcrypto/pkcs12/p12_mac.c
index f163d4cfaa..f5ab0d6464 100644
--- a/src/lib/libcrypto/pkcs12/p12_mac.c
+++ b/src/lib/libcrypto/pkcs12/p12_mac.c
@@ -82,9 +82,9 @@ PKCS12_MAC_DATA *PKCS12_MAC_DATA_new(void)
82 ASN1_CTX c; 82 ASN1_CTX c;
83 M_ASN1_New_Malloc(ret, PKCS12_MAC_DATA); 83 M_ASN1_New_Malloc(ret, PKCS12_MAC_DATA);
84 ret->dinfo = X509_SIG_new(); 84 ret->dinfo = X509_SIG_new();
85 ret->salt = ASN1_OCTET_STRING_new(); 85 ret->salt = M_ASN1_OCTET_STRING_new();
86 ret->iter = NULL; 86 ret->iter = NULL;
87 return (ret); 87 return(ret);
88 M_ASN1_New_Error(ASN1_F_PKCS12_MAC_DATA_NEW); 88 M_ASN1_New_Error(ASN1_F_PKCS12_MAC_DATA_NEW);
89} 89}
90 90
@@ -94,9 +94,9 @@ PKCS12_MAC_DATA *d2i_PKCS12_MAC_DATA(PKCS12_MAC_DATA **a, unsigned char **pp,
94 M_ASN1_D2I_vars(a,PKCS12_MAC_DATA *,PKCS12_MAC_DATA_new); 94 M_ASN1_D2I_vars(a,PKCS12_MAC_DATA *,PKCS12_MAC_DATA_new);
95 M_ASN1_D2I_Init(); 95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence(); 96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get (ret->dinfo, d2i_X509_SIG); 97 M_ASN1_D2I_get(ret->dinfo, d2i_X509_SIG);
98 M_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING); 98 M_ASN1_D2I_get(ret->salt, d2i_ASN1_OCTET_STRING);
99 M_ASN1_D2I_get_opt (ret->iter, d2i_ASN1_INTEGER, V_ASN1_INTEGER); 99 M_ASN1_D2I_get_opt(ret->iter, d2i_ASN1_INTEGER, V_ASN1_INTEGER);
100 M_ASN1_D2I_Finish(a, PKCS12_MAC_DATA_free, ASN1_F_D2I_PKCS12_MAC_DATA); 100 M_ASN1_D2I_Finish(a, PKCS12_MAC_DATA_free, ASN1_F_D2I_PKCS12_MAC_DATA);
101} 101}
102 102
@@ -104,7 +104,7 @@ void PKCS12_MAC_DATA_free (PKCS12_MAC_DATA *a)
104{ 104{
105 if (a == NULL) return; 105 if (a == NULL) return;
106 X509_SIG_free (a->dinfo); 106 X509_SIG_free (a->dinfo);
107 ASN1_OCTET_STRING_free (a->salt); 107 M_ASN1_OCTET_STRING_free(a->salt);
108 ASN1_INTEGER_free (a->iter); 108 M_ASN1_INTEGER_free(a->iter);
109 Free ((char *)a); 109 Free (a);
110} 110}
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c
index bac558d6b9..f1094b3840 100644
--- a/src/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/src/lib/libcrypto/pkcs12/p12_mutl.c
@@ -131,7 +131,7 @@ int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
131 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_GENERATION_ERROR); 131 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_GENERATION_ERROR);
132 return 0; 132 return 0;
133 } 133 }
134 if (!(ASN1_OCTET_STRING_set (p12->mac->dinfo->digest, mac, maclen))) { 134 if (!(M_ASN1_OCTET_STRING_set (p12->mac->dinfo->digest, mac, maclen))) {
135 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_STRING_SET_ERROR); 135 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_STRING_SET_ERROR);
136 return 0; 136 return 0;
137 } 137 }
@@ -142,13 +142,13 @@ int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
142int 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,
143 EVP_MD *md_type) 143 EVP_MD *md_type)
144{ 144{
145 if (!(p12->mac = PKCS12_MAC_DATA_new ())) return PKCS12_ERROR; 145 if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR;
146 if (iter > 1) { 146 if (iter > 1) {
147 if(!(p12->mac->iter = ASN1_INTEGER_new())) { 147 if(!(p12->mac->iter = M_ASN1_INTEGER_new())) {
148 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); 148 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
149 return 0; 149 return 0;
150 } 150 }
151 ASN1_INTEGER_set (p12->mac->iter, iter); 151 ASN1_INTEGER_set(p12->mac->iter, iter);
152 } 152 }
153 if (!saltlen) saltlen = PKCS12_SALT_LEN; 153 if (!saltlen) saltlen = PKCS12_SALT_LEN;
154 p12->mac->salt->length = saltlen; 154 p12->mac->salt->length = saltlen;
@@ -156,7 +156,10 @@ int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
156 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); 156 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
157 return 0; 157 return 0;
158 } 158 }
159 if (!salt) RAND_bytes (p12->mac->salt->data, saltlen); 159 if (!salt) {
160 if (RAND_bytes (p12->mac->salt->data, saltlen) <= 0)
161 return 0;
162 }
160 else memcpy (p12->mac->salt->data, salt, saltlen); 163 else memcpy (p12->mac->salt->data, salt, saltlen);
161 p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type)); 164 p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type));
162 if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) { 165 if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) {
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
new file mode 100644
index 0000000000..ee71707e2c
--- /dev/null
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -0,0 +1,212 @@
1/* p12_npas.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 <stdlib.h>
61#include <string.h>
62#include <openssl/pem.h>
63#include <openssl/err.h>
64#include <openssl/pkcs12.h>
65
66/* PKCS#12 password change routine */
67
68static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass);
69static int newpass_bags(STACK *bags, char *oldpass, char *newpass);
70static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass);
71static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen);
72
73/*
74 * Change the password on a PKCS#12 structure.
75 */
76
77int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass)
78{
79
80/* Check for NULL PKCS12 structure */
81
82if(!p12) {
83 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_INVALID_NULL_PKCS12_POINTER);
84 return 0;
85}
86
87/* Check the mac */
88
89if (!PKCS12_verify_mac(p12, oldpass, -1)) {
90 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_MAC_VERIFY_FAILURE);
91 return 0;
92}
93
94if (!newpass_p12(p12, oldpass, newpass)) {
95 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_PARSE_ERROR);
96 return 0;
97}
98
99return 1;
100
101}
102
103/* Parse the outer PKCS#12 structure */
104
105static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
106{
107 STACK *asafes, *newsafes, *bags;
108 int i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;
109 PKCS7 *p7, *p7new;
110 ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;
111 unsigned char mac[EVP_MAX_MD_SIZE];
112 unsigned int maclen;
113 if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114 if(!(newsafes = sk_new(NULL))) return 0;
115 for (i = 0; i < sk_num (asafes); i++) {
116 p7 = (PKCS7 *) sk_value(asafes, i);
117 bagnid = OBJ_obj2nid(p7->type);
118 if (bagnid == NID_pkcs7_data) {
119 bags = M_PKCS12_unpack_p7data(p7);
120 } else if (bagnid == NID_pkcs7_encrypted) {
121 bags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);
122 alg_get(p7->d.encrypted->enc_data->algorithm,
123 &pbe_nid, &pbe_iter, &pbe_saltlen);
124 } else continue;
125 if (!bags) {
126 sk_pop_free(asafes, PKCS7_free);
127 return 0;
128 }
129 if (!newpass_bags(bags, oldpass, newpass)) {
130 sk_pop_free(bags, PKCS12_SAFEBAG_free);
131 sk_pop_free(asafes, PKCS7_free);
132 return 0;
133 }
134 /* Repack bag in same form with new password */
135 if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);
136 else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
137 pbe_saltlen, pbe_iter, bags);
138 sk_pop_free(bags, PKCS12_SAFEBAG_free);
139 if(!p7new) {
140 sk_pop_free(asafes, PKCS7_free);
141 return 0;
142 }
143 sk_push(newsafes, (char *)p7new);
144 }
145 sk_pop_free(asafes, PKCS7_free);
146
147 /* Repack safe: save old safe in case of error */
148
149 p12_data_tmp = p12->authsafes->d.data;
150 if(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr;
151 if(!M_PKCS12_pack_authsafes(p12, newsafes)) goto saferr;
152
153 if(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr;
154 if(!(macnew = ASN1_OCTET_STRING_new())) goto saferr;
155 if(!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr;
156 ASN1_OCTET_STRING_free(p12->mac->dinfo->digest);
157 p12->mac->dinfo->digest = macnew;
158 ASN1_OCTET_STRING_free(p12_data_tmp);
159
160 return 1;
161
162 saferr:
163 /* Restore old safe */
164 ASN1_OCTET_STRING_free(p12->authsafes->d.data);
165 ASN1_OCTET_STRING_free(macnew);
166 p12->authsafes->d.data = p12_data_tmp;
167 return 0;
168
169}
170
171
172static int newpass_bags(STACK *bags, char *oldpass, char *newpass)
173{
174 int i;
175 for (i = 0; i < sk_num(bags); i++) {
176 if (!newpass_bag((PKCS12_SAFEBAG *)sk_value(bags, i),
177 oldpass, newpass)) return 0;
178 }
179 return 1;
180}
181
182/* Change password of safebag: only needs handle shrouded keybags */
183
184static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass)
185{
186 PKCS8_PRIV_KEY_INFO *p8;
187 X509_SIG *p8new;
188 int p8_nid, p8_saltlen, p8_iter;
189
190 if(M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1;
191
192 if (!(p8 = M_PKCS12_decrypt_skey(bag, oldpass, -1))) return 0;
193 alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen);
194 if(!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen,
195 p8_iter, p8))) return 0;
196 X509_SIG_free(bag->value.shkeybag);
197 bag->value.shkeybag = p8new;
198 return 1;
199}
200
201static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen)
202{
203 PBEPARAM *pbe;
204 unsigned char *p;
205 p = alg->parameter->value.sequence->data;
206 pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
207 *pnid = OBJ_obj2nid(alg->algorithm);
208 *piter = ASN1_INTEGER_get(pbe->iter);
209 *psaltlen = pbe->salt->length;
210 PBEPARAM_free(pbe);
211 return 0;
212}
diff --git a/src/lib/libcrypto/pkcs12/pk12err.c b/src/lib/libcrypto/pkcs12/pk12err.c
index 38d7be7675..9d8de10e1e 100644
--- a/src/lib/libcrypto/pkcs12/pk12err.c
+++ b/src/lib/libcrypto/pkcs12/pk12err.c
@@ -79,6 +79,7 @@ static ERR_STRING_DATA PKCS12_str_functs[]=
79{ERR_PACK(0,PKCS12_F_PKCS12_KEY_GEN_UNI,0), "PKCS12_key_gen_uni"}, 79{ERR_PACK(0,PKCS12_F_PKCS12_KEY_GEN_UNI,0), "PKCS12_key_gen_uni"},
80{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_KEYBAG,0), "PKCS12_MAKE_KEYBAG"}, 80{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_KEYBAG,0), "PKCS12_MAKE_KEYBAG"},
81{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_SHKEYBAG,0), "PKCS12_MAKE_SHKEYBAG"}, 81{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_SHKEYBAG,0), "PKCS12_MAKE_SHKEYBAG"},
82{ERR_PACK(0,PKCS12_F_PKCS12_NEWPASS,0), "PKCS12_newpass"},
82{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7DATA,0), "PKCS12_pack_p7data"}, 83{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7DATA,0), "PKCS12_pack_p7data"},
83{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7ENCDATA,0), "PKCS12_pack_p7encdata"}, 84{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7ENCDATA,0), "PKCS12_pack_p7encdata"},
84{ERR_PACK(0,PKCS12_F_PKCS12_PACK_SAFEBAG,0), "PKCS12_pack_safebag"}, 85{ERR_PACK(0,PKCS12_F_PKCS12_PACK_SAFEBAG,0), "PKCS12_pack_safebag"},
@@ -99,6 +100,7 @@ static ERR_STRING_DATA PKCS12_str_reasons[]=
99{PKCS12_R_DECODE_ERROR ,"decode error"}, 100{PKCS12_R_DECODE_ERROR ,"decode error"},
100{PKCS12_R_ENCODE_ERROR ,"encode error"}, 101{PKCS12_R_ENCODE_ERROR ,"encode error"},
101{PKCS12_R_ENCRYPT_ERROR ,"encrypt error"}, 102{PKCS12_R_ENCRYPT_ERROR ,"encrypt error"},
103{PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE,"error setting encrypted data type"},
102{PKCS12_R_INVALID_NULL_ARGUMENT ,"invalid null argument"}, 104{PKCS12_R_INVALID_NULL_ARGUMENT ,"invalid null argument"},
103{PKCS12_R_INVALID_NULL_PKCS12_POINTER ,"invalid null pkcs12 pointer"}, 105{PKCS12_R_INVALID_NULL_PKCS12_POINTER ,"invalid null pkcs12 pointer"},
104{PKCS12_R_IV_GEN_ERROR ,"iv gen error"}, 106{PKCS12_R_IV_GEN_ERROR ,"iv gen error"},
diff --git a/src/lib/libcrypto/pkcs12/pkcs12.h b/src/lib/libcrypto/pkcs12/pkcs12.h
index 4cfba5e6c6..254000fa12 100644
--- a/src/lib/libcrypto/pkcs12/pkcs12.h
+++ b/src/lib/libcrypto/pkcs12/pkcs12.h
@@ -273,6 +273,7 @@ int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);
273int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); 273int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
274PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); 274PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
275PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); 275PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
276int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
276 277
277/* BEGIN ERROR CODES */ 278/* BEGIN ERROR CODES */
278/* The following lines are auto generated by the script mkerr.pl. Any changes 279/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -296,6 +297,7 @@ PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
296#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 297#define PKCS12_F_PKCS12_KEY_GEN_UNI 111
297#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 298#define PKCS12_F_PKCS12_MAKE_KEYBAG 112
298#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 299#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113
300#define PKCS12_F_PKCS12_NEWPASS 128
299#define PKCS12_F_PKCS12_PACK_P7DATA 114 301#define PKCS12_F_PKCS12_PACK_P7DATA 114
300#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 302#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115
301#define PKCS12_F_PKCS12_PACK_SAFEBAG 117 303#define PKCS12_F_PKCS12_PACK_SAFEBAG 117
@@ -313,6 +315,7 @@ PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
313#define PKCS12_R_DECODE_ERROR 101 315#define PKCS12_R_DECODE_ERROR 101
314#define PKCS12_R_ENCODE_ERROR 102 316#define PKCS12_R_ENCODE_ERROR 102
315#define PKCS12_R_ENCRYPT_ERROR 103 317#define PKCS12_R_ENCRYPT_ERROR 103
318#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120
316#define PKCS12_R_INVALID_NULL_ARGUMENT 104 319#define PKCS12_R_INVALID_NULL_ARGUMENT 104
317#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 320#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105
318#define PKCS12_R_IV_GEN_ERROR 106 321#define PKCS12_R_IV_GEN_ERROR 106
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
index 6c4644b2f2..0e508386e8 100644
--- a/src/lib/libcrypto/pkcs7/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs7/Makefile.ssl
@@ -1,5 +1,5 @@
1# 1#
2# SSLeay/crypto/asn1/Makefile 2# SSLeay/crypto/pkcs7/Makefile
3# 3#
4 4
5DIR= pkcs7 5DIR= pkcs7
@@ -15,6 +15,9 @@ MAKEDEPEND= $(TOP)/util/domd $(TOP)
15MAKEFILE= Makefile.ssl 15MAKEFILE= Makefile.ssl
16AR= ar r 16AR= ar r
17 17
18PEX_LIBS=
19EX_LIBS=
20
18CFLAGS= $(INCLUDES) $(CFLAG) 21CFLAGS= $(INCLUDES) $(CFLAG)
19 22
20GENERAL=Makefile README 23GENERAL=Makefile README
@@ -22,8 +25,8 @@ TEST=
22APPS= 25APPS=
23 26
24LIB=$(TOP)/libcrypto.a 27LIB=$(TOP)/libcrypto.a
25LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c 28LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c pk7_mime.c
26LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o 29LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o pk7_smime.o pk7_attr.o pk7_mime.o
27 30
28SRC= $(LIBSRC) 31SRC= $(LIBSRC)
29 32
@@ -42,16 +45,16 @@ all: lib
42testapps: enc dec sign verify 45testapps: enc dec sign verify
43 46
44enc: enc.o lib 47enc: enc.o lib
45 $(CC) $(CFLAGS) -o enc enc.o $(LIB) 48 $(CC) $(CFLAGS) -o enc enc.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
46 49
47dec: dec.o lib 50dec: dec.o lib
48 $(CC) $(CFLAGS) -o dec dec.o $(LIB) 51 $(CC) $(CFLAGS) -o dec dec.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
49 52
50sign: sign.o lib 53sign: sign.o lib
51 $(CC) $(CFLAGS) -o sign sign.o $(LIB) 54 $(CC) $(CFLAGS) -o sign sign.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
52 55
53verify: verify.o example.o lib 56verify: verify.o example.o lib
54 $(CC) $(CFLAGS) -o verify verify.o example.o $(LIB) 57 $(CC) $(CFLAGS) -o verify verify.o $(PEX_LIBS) example.o $(LIB) $(EX_LIBS)
55 58
56lib: $(LIBOBJ) 59lib: $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ) 60 $(AR) $(LIB) $(LIBOBJ)
@@ -90,18 +93,35 @@ dclean:
90 mv -f Makefile.new $(MAKEFILE) 93 mv -f Makefile.new $(MAKEFILE)
91 94
92clean: 95clean:
93 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 96 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff enc dec sign verify
94 97
95# DO NOT DELETE THIS LINE -- make depend depends on it. 98# DO NOT DELETE THIS LINE -- make depend depends on it.
96 99
100pk7_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
101pk7_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
102pk7_attr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
103pk7_attr.o: ../../include/openssl/des.h ../../include/openssl/dh.h
104pk7_attr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
105pk7_attr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
106pk7_attr.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
107pk7_attr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
108pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
109pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h
110pk7_attr.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
111pk7_attr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
112pk7_attr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
113pk7_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
114pk7_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
115pk7_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
97pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 116pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
98pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 117pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
99pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 118pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
100pk7_doit.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 119pk7_doit.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
101pk7_doit.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 120pk7_doit.o: ../../include/openssl/des.h ../../include/openssl/dh.h
102pk7_doit.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 121pk7_doit.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
103pk7_doit.o: ../../include/openssl/err.h ../../include/openssl/evp.h 122pk7_doit.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
104pk7_doit.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 123pk7_doit.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
124pk7_doit.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
105pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 125pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
106pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 126pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
107pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 127pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -110,7 +130,8 @@ pk7_doit.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
110pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 130pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
111pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 131pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
112pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 132pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
113pk7_doit.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 133pk7_doit.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
134pk7_doit.o: ../cryptlib.h
114pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 135pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
115pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 136pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
116pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 137pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -128,6 +149,42 @@ pk7_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
128pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 149pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
129pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 150pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
130pk7_lib.o: ../cryptlib.h 151pk7_lib.o: ../cryptlib.h
152pk7_mime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
153pk7_mime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
154pk7_mime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
155pk7_mime.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
156pk7_mime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
157pk7_mime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
158pk7_mime.o: ../../include/openssl/err.h ../../include/openssl/evp.h
159pk7_mime.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
160pk7_mime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
161pk7_mime.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
162pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
163pk7_mime.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
164pk7_mime.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
165pk7_mime.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
166pk7_mime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
167pk7_mime.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
168pk7_mime.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
169pk7_smime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
170pk7_smime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
171pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
172pk7_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
173pk7_smime.o: ../../include/openssl/des.h ../../include/openssl/dh.h
174pk7_smime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
175pk7_smime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
176pk7_smime.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
177pk7_smime.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
178pk7_smime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
179pk7_smime.o: ../../include/openssl/objects.h
180pk7_smime.o: ../../include/openssl/opensslconf.h
181pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
182pk7_smime.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
183pk7_smime.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
184pk7_smime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
185pk7_smime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
186pk7_smime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
187pk7_smime.o: ../../include/openssl/x509v3.h ../cryptlib.h
131pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 188pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
132pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 189pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
133pkcs7err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 190pkcs7err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
diff --git a/src/lib/libcrypto/pkcs7/bio_ber.c b/src/lib/libcrypto/pkcs7/bio_ber.c
index 2f17723e98..4803966fd2 100644
--- a/src/lib/libcrypto/pkcs7/bio_ber.c
+++ b/src/lib/libcrypto/pkcs7/bio_ber.c
@@ -69,6 +69,7 @@ static int ber_read(BIO *h,char *buf,int size);
69static long ber_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long ber_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int ber_new(BIO *h); 70static int ber_new(BIO *h);
71static int ber_free(BIO *data); 71static int ber_free(BIO *data);
72static long ber_callback_ctrl(BIO *h,int cmd,void *(*fp)());
72#define BER_BUF_SIZE (32) 73#define BER_BUF_SIZE (32)
73 74
74/* This is used to hold the state of the BER objects being read. */ 75/* This is used to hold the state of the BER objects being read. */
@@ -92,7 +93,7 @@ typedef struct bio_ber_struct
92 /* most of the following are used when doing non-blocking IO */ 93 /* most of the following are used when doing non-blocking IO */
93 /* reading */ 94 /* reading */
94 long num_left; /* number of bytes still to read/write in block */ 95 long num_left; /* number of bytes still to read/write in block */
95 int depth; /* used with idefinite encoding. */ 96 int depth; /* used with indefinite encoding. */
96 int finished; /* No more read data */ 97 int finished; /* No more read data */
97 98
98 /* writting */ 99 /* writting */
@@ -115,6 +116,7 @@ static BIO_METHOD methods_ber=
115 ber_ctrl, 116 ber_ctrl,
116 ber_new, 117 ber_new,
117 ber_free, 118 ber_free,
119 ber_callback_ctrl,
118 }; 120 };
119 121
120BIO_METHOD *BIO_f_ber(void) 122BIO_METHOD *BIO_f_ber(void)
@@ -409,6 +411,20 @@ again:
409 return(ret); 411 return(ret);
410 } 412 }
411 413
414static long ber_callback_ctrl(BIO *b, int cmd, void *(*fp)())
415 {
416 long ret=1;
417
418 if (b->next_bio == NULL) return(0);
419 switch (cmd)
420 {
421 default:
422 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
423 break;
424 }
425 return(ret);
426 }
427
412/* 428/*
413void BIO_set_cipher_ctx(b,c) 429void BIO_set_cipher_ctx(b,c)
414BIO *b; 430BIO *b;
diff --git a/src/lib/libcrypto/pkcs7/dec.c b/src/lib/libcrypto/pkcs7/dec.c
index b3661f28d3..6752ec568a 100644
--- a/src/lib/libcrypto/pkcs7/dec.c
+++ b/src/lib/libcrypto/pkcs7/dec.c
@@ -57,6 +57,7 @@
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h>
60#include <openssl/bio.h> 61#include <openssl/bio.h>
61#include <openssl/x509.h> 62#include <openssl/x509.h>
62#include <openssl/pem.h> 63#include <openssl/pem.h>
@@ -85,7 +86,7 @@ char *argv[];
85 int i,printit=0; 86 int i,printit=0;
86 STACK_OF(PKCS7_SIGNER_INFO) *sk; 87 STACK_OF(PKCS7_SIGNER_INFO) *sk;
87 88
88 SSLeay_add_all_algorithms(); 89 OpenSSL_add_all_algorithms();
89 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 90 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
90 91
91 data=BIO_new(BIO_s_file()); 92 data=BIO_new(BIO_s_file());
@@ -121,9 +122,10 @@ char *argv[];
121 } 122 }
122 123
123 if ((in=BIO_new_file(keyfile,"r")) == NULL) goto err; 124 if ((in=BIO_new_file(keyfile,"r")) == NULL) goto err;
124 if ((x509=PEM_read_bio_X509(in,NULL,NULL)) == NULL) goto err; 125 if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err;
125 BIO_reset(in); 126 BIO_reset(in);
126 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL)) == NULL) goto err; 127 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL)
128 goto err;
127 BIO_free(in); 129 BIO_free(in);
128 130
129 if (pp == NULL) 131 if (pp == NULL)
@@ -131,7 +133,7 @@ char *argv[];
131 133
132 134
133 /* Load the PKCS7 object from a file */ 135 /* Load the PKCS7 object from a file */
134 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL)) == NULL) goto err; 136 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL,NULL)) == NULL) goto err;
135 137
136 138
137 139
@@ -148,7 +150,7 @@ char *argv[];
148 /* We need to process the data */ 150 /* We need to process the data */
149 /* We cannot support detached encryption */ 151 /* We cannot support detached encryption */
150 p7bio=PKCS7_dataDecode(p7,pkey,detached,x509); 152 p7bio=PKCS7_dataDecode(p7,pkey,detached,x509);
151 153
152 if (p7bio == NULL) 154 if (p7bio == NULL)
153 { 155 {
154 printf("problems decoding\n"); 156 printf("problems decoding\n");
diff --git a/src/lib/libcrypto/pkcs7/enc.c b/src/lib/libcrypto/pkcs7/enc.c
index 43bfd10a23..2b56c2eff3 100644
--- a/src/lib/libcrypto/pkcs7/enc.c
+++ b/src/lib/libcrypto/pkcs7/enc.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h>
59#include <openssl/bio.h> 60#include <openssl/bio.h>
60#include <openssl/x509.h> 61#include <openssl/x509.h>
61#include <openssl/pem.h> 62#include <openssl/pem.h>
@@ -76,7 +77,7 @@ char *argv[];
76 const EVP_CIPHER *cipher=NULL; 77 const EVP_CIPHER *cipher=NULL;
77 STACK_OF(X509) *recips=NULL; 78 STACK_OF(X509) *recips=NULL;
78 79
79 SSLeay_add_all_algorithms(); 80 OpenSSL_add_all_algorithms();
80 81
81 data=BIO_new(BIO_s_file()); 82 data=BIO_new(BIO_s_file());
82 while(argc > 1) 83 while(argc > 1)
@@ -98,7 +99,8 @@ char *argv[];
98 argc-=2; 99 argc-=2;
99 argv+=2; 100 argv+=2;
100 if (!(in=BIO_new_file(keyfile,"r"))) goto err; 101 if (!(in=BIO_new_file(keyfile,"r"))) goto err;
101 if (!(x509=PEM_read_bio_X509(in,NULL,NULL))) goto err; 102 if (!(x509=PEM_read_bio_X509(in,NULL,NULL,NULL)))
103 goto err;
102 if(!recips) recips = sk_X509_new_null(); 104 if(!recips) recips = sk_X509_new_null();
103 sk_X509_push(recips, x509); 105 sk_X509_push(recips, x509);
104 BIO_free(in); 106 BIO_free(in);
@@ -125,7 +127,14 @@ char *argv[];
125#else 127#else
126 PKCS7_set_type(p7,NID_pkcs7_enveloped); 128 PKCS7_set_type(p7,NID_pkcs7_enveloped);
127#endif 129#endif
128 if(!cipher) cipher = EVP_des_ede3_cbc(); 130 if(!cipher) {
131#ifndef NO_DES
132 cipher = EVP_des_ede3_cbc();
133#else
134 fprintf(stderr, "No cipher selected\n");
135 goto err;
136#endif
137 }
129 138
130 if (!PKCS7_set_cipher(p7,cipher)) goto err; 139 if (!PKCS7_set_cipher(p7,cipher)) goto err;
131 for(i = 0; i < sk_X509_num(recips); i++) { 140 for(i = 0; i < sk_X509_num(recips); i++) {
diff --git a/src/lib/libcrypto/pkcs7/example.c b/src/lib/libcrypto/pkcs7/example.c
index 7354890084..f6656be28e 100644
--- a/src/lib/libcrypto/pkcs7/example.c
+++ b/src/lib/libcrypto/pkcs7/example.c
@@ -1,5 +1,6 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h>
3#include <openssl/pkcs7.h> 4#include <openssl/pkcs7.h>
4#include <openssl/asn1_mac.h> 5#include <openssl/asn1_mac.h>
5 6
@@ -36,7 +37,7 @@ void add_signed_string(PKCS7_SIGNER_INFO *si, char *str)
36 signed_string_nid= 37 signed_string_nid=
37 OBJ_create("1.2.3.4.5","OID_example","Our example OID"); 38 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
38 os=ASN1_OCTET_STRING_new(); 39 os=ASN1_OCTET_STRING_new();
39 ASN1_OCTET_STRING_set(os,str,strlen(str)); 40 ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));
40 /* When we add, we do not free */ 41 /* When we add, we do not free */
41 PKCS7_add_signed_attribute(si,signed_string_nid, 42 PKCS7_add_signed_attribute(si,signed_string_nid,
42 V_ASN1_OCTET_STRING,(char *)os); 43 V_ASN1_OCTET_STRING,(char *)os);
@@ -68,7 +69,7 @@ int get_signed_string(PKCS7_SIGNER_INFO *si, char *buf, int len)
68 return(0); 69 return(0);
69 } 70 }
70 71
71static signed_seq2string_nid= -1; 72static int signed_seq2string_nid= -1;
72/* ########################################### */ 73/* ########################################### */
73int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) 74int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
74 { 75 {
@@ -86,8 +87,8 @@ int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
86 87
87 os1=ASN1_OCTET_STRING_new(); 88 os1=ASN1_OCTET_STRING_new();
88 os2=ASN1_OCTET_STRING_new(); 89 os2=ASN1_OCTET_STRING_new();
89 ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); 90 ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1));
90 ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); 91 ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1));
91 i =i2d_ASN1_OCTET_STRING(os1,NULL); 92 i =i2d_ASN1_OCTET_STRING(os1,NULL);
92 i+=i2d_ASN1_OCTET_STRING(os2,NULL); 93 i+=i2d_ASN1_OCTET_STRING(os2,NULL);
93 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); 94 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
@@ -197,7 +198,7 @@ X509_ATTRIBUTE *create_string(char *str)
197 signed_string_nid= 198 signed_string_nid=
198 OBJ_create("1.2.3.4.5","OID_example","Our example OID"); 199 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
199 os=ASN1_OCTET_STRING_new(); 200 os=ASN1_OCTET_STRING_new();
200 ASN1_OCTET_STRING_set(os,str,strlen(str)); 201 ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));
201 /* When we add, we do not free */ 202 /* When we add, we do not free */
202 ret=X509_ATTRIBUTE_create(signed_string_nid, 203 ret=X509_ATTRIBUTE_create(signed_string_nid,
203 V_ASN1_OCTET_STRING,(char *)os); 204 V_ASN1_OCTET_STRING,(char *)os);
@@ -250,8 +251,8 @@ X509_ATTRIBUTE *add_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
250 251
251 os1=ASN1_OCTET_STRING_new(); 252 os1=ASN1_OCTET_STRING_new();
252 os2=ASN1_OCTET_STRING_new(); 253 os2=ASN1_OCTET_STRING_new();
253 ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); 254 ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1));
254 ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); 255 ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1));
255 i =i2d_ASN1_OCTET_STRING(os1,NULL); 256 i =i2d_ASN1_OCTET_STRING(os1,NULL);
256 i+=i2d_ASN1_OCTET_STRING(os2,NULL); 257 i+=i2d_ASN1_OCTET_STRING(os2,NULL);
257 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); 258 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c
new file mode 100644
index 0000000000..3b9c0fe3f2
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pk7_attr.c
@@ -0,0 +1,85 @@
1/* pk7_attr.c */
2/* S/MIME code.
3 * Copyright (C) 1997-8 Dr S N Henson (shenson@bigfoot.com)
4 * All Rights Reserved.
5 * Redistribution of this code without the authors permission is expressly
6 * prohibited.
7 */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <openssl/bio.h>
12#include <openssl/asn1.h>
13#include <openssl/pem.h>
14#include <openssl/pkcs7.h>
15#include <openssl/err.h>
16
17int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap)
18{
19 ASN1_STRING *seq;
20 unsigned char *p, *pp;
21 int len;
22 len=i2d_ASN1_SET(cap,NULL,i2d_X509_ALGOR, V_ASN1_SEQUENCE,
23 V_ASN1_UNIVERSAL, IS_SEQUENCE);
24 if(!(pp=(unsigned char *)Malloc(len))) {
25 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
26 return 0;
27 }
28 p=pp;
29 i2d_ASN1_SET(cap,&p,i2d_X509_ALGOR, V_ASN1_SEQUENCE,
30 V_ASN1_UNIVERSAL, IS_SEQUENCE);
31 if(!(seq = ASN1_STRING_new())) {
32 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
33 return 0;
34 }
35 if(!ASN1_STRING_set (seq, pp, len)) {
36 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
37 return 0;
38 }
39 Free (pp);
40 return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
41 V_ASN1_SEQUENCE, seq);
42}
43
44STACK *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si)
45{
46 ASN1_TYPE *cap;
47 unsigned char *p;
48 cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities);
49 if (!cap) return NULL;
50 p = cap->value.sequence->data;
51 return d2i_ASN1_SET (NULL, &p, cap->value.sequence->length,
52 (char *(*)())d2i_X509_ALGOR, X509_ALGOR_free, V_ASN1_SEQUENCE,
53 V_ASN1_UNIVERSAL);
54}
55
56/* Basic smime-capabilities OID and optional integer arg */
57int PKCS7_simple_smimecap(STACK *sk, int nid, int arg)
58{
59 X509_ALGOR *alg;
60 if(!(alg = X509_ALGOR_new())) {
61 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
62 return 0;
63 }
64 ASN1_OBJECT_free(alg->algorithm);
65 alg->algorithm = OBJ_nid2obj (nid);
66 if (arg > 0) {
67 ASN1_INTEGER *nbit;
68 if(!(alg->parameter = ASN1_TYPE_new())) {
69 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
70 return 0;
71 }
72 if(!(nbit = ASN1_INTEGER_new())) {
73 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
74 return 0;
75 }
76 if(!ASN1_INTEGER_set (nbit, arg)) {
77 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
78 return 0;
79 }
80 alg->parameter->value.integer = nbit;
81 alg->parameter->type = V_ASN1_INTEGER;
82 }
83 sk_push (sk, (char *)alg);
84 return 1;
85}
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index dee81b547a..80ac5e34b4 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -61,6 +61,7 @@
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
64 65
65static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, 66static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
66 void *value); 67 void *value);
@@ -160,9 +161,10 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
160 BIO_get_cipher_ctx(btmp, &ctx); 161 BIO_get_cipher_ctx(btmp, &ctx);
161 keylen=EVP_CIPHER_key_length(evp_cipher); 162 keylen=EVP_CIPHER_key_length(evp_cipher);
162 ivlen=EVP_CIPHER_iv_length(evp_cipher); 163 ivlen=EVP_CIPHER_iv_length(evp_cipher);
163 RAND_bytes(key,keylen); 164 if (RAND_bytes(key,keylen) <= 0)
165 goto err;
164 xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher)); 166 xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher));
165 if (ivlen > 0) RAND_bytes(iv,ivlen); 167 if (ivlen > 0) RAND_pseudo_bytes(iv,ivlen);
166 EVP_CipherInit(ctx, evp_cipher, key, iv, 1); 168 EVP_CipherInit(ctx, evp_cipher, key, iv, 1);
167 169
168 if (ivlen > 0) { 170 if (ivlen > 0) {
@@ -204,7 +206,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
204 Free(tmp); 206 Free(tmp);
205 goto err; 207 goto err;
206 } 208 }
207 ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj); 209 M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj);
208 } 210 }
209 Free(tmp); 211 Free(tmp);
210 memset(key, 0, keylen); 212 memset(key, 0, keylen);
@@ -216,30 +218,23 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
216 btmp=NULL; 218 btmp=NULL;
217 } 219 }
218 220
219 if (bio == NULL) /* ??????????? */ 221 if (bio == NULL) {
220 {
221 if (p7->detached) 222 if (p7->detached)
222 bio=BIO_new(BIO_s_null()); 223 bio=BIO_new(BIO_s_null());
223 else 224 else {
224 {
225 bio=BIO_new(BIO_s_mem());
226 /* We need to set this so that when we have read all
227 * the data, the encrypt BIO, if present, will read
228 * EOF and encode the last few bytes */
229 BIO_set_mem_eof_return(bio,0);
230
231 if (PKCS7_type_is_signed(p7) && 225 if (PKCS7_type_is_signed(p7) &&
232 PKCS7_type_is_data(p7->d.sign->contents)) 226 PKCS7_type_is_data(p7->d.sign->contents)) {
233 {
234 ASN1_OCTET_STRING *os; 227 ASN1_OCTET_STRING *os;
235
236 os=p7->d.sign->contents->d.data; 228 os=p7->d.sign->contents->d.data;
237 if (os->length > 0) 229 if (os->length > 0) bio =
238 BIO_write(bio,(char *)os->data, 230 BIO_new_mem_buf(os->data, os->length);
239 os->length); 231 }
240 } 232 if(bio == NULL) {
233 bio=BIO_new(BIO_s_mem());
234 BIO_set_mem_eof_return(bio,0);
241 } 235 }
242 } 236 }
237 }
243 BIO_push(out,bio); 238 BIO_push(out,bio);
244 bio=NULL; 239 bio=NULL;
245 if (0) 240 if (0)
@@ -259,7 +254,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
259 { 254 {
260 int i,j; 255 int i,j;
261 BIO *out=NULL,*btmp=NULL,*etmp=NULL,*bio=NULL; 256 BIO *out=NULL,*btmp=NULL,*etmp=NULL,*bio=NULL;
262 char *tmp=NULL; 257 unsigned char *tmp=NULL;
263 X509_ALGOR *xa; 258 X509_ALGOR *xa;
264 ASN1_OCTET_STRING *data_body=NULL; 259 ASN1_OCTET_STRING *data_body=NULL;
265 const EVP_MD *evp_md; 260 const EVP_MD *evp_md;
@@ -270,6 +265,9 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
270 STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; 265 STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
271 X509_ALGOR *xalg=NULL; 266 X509_ALGOR *xalg=NULL;
272 PKCS7_RECIP_INFO *ri=NULL; 267 PKCS7_RECIP_INFO *ri=NULL;
268#ifndef NO_RC2
269 char is_rc2 = 0;
270#endif
273/* EVP_PKEY *pkey; */ 271/* EVP_PKEY *pkey; */
274#if 0 272#if 0
275 X509_STORE_CTX s_ctx; 273 X509_STORE_CTX s_ctx;
@@ -314,6 +312,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
314 goto err; 312 goto err;
315 } 313 }
316 314
315 if(EVP_CIPHER_nid(evp_cipher) == NID_rc2_cbc)
316 {
317#ifndef NO_RC2
318 is_rc2 = 1;
319#else
320 PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
321 goto err;
322#endif
323 }
324
317 /* We will be checking the signature */ 325 /* We will be checking the signature */
318 if (md_sk != NULL) 326 if (md_sk != NULL)
319 { 327 {
@@ -372,7 +380,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
372 ri=sk_PKCS7_RECIP_INFO_value(rsk,i); 380 ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
373 if(!X509_NAME_cmp(ri->issuer_and_serial->issuer, 381 if(!X509_NAME_cmp(ri->issuer_and_serial->issuer,
374 pcert->cert_info->issuer) && 382 pcert->cert_info->issuer) &&
375 !ASN1_INTEGER_cmp(pcert->cert_info->serialNumber, 383 !M_ASN1_INTEGER_cmp(pcert->cert_info->serialNumber,
376 ri->issuer_and_serial->serial)) break; 384 ri->issuer_and_serial->serial)) break;
377 ri=NULL; 385 ri=NULL;
378 } 386 }
@@ -383,17 +391,15 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
383 } 391 }
384 392
385 jj=EVP_PKEY_size(pkey); 393 jj=EVP_PKEY_size(pkey);
386 tmp=Malloc(jj+10); 394 tmp=(unsigned char *)Malloc(jj+10);
387 if (tmp == NULL) 395 if (tmp == NULL)
388 { 396 {
389 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE); 397 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE);
390 goto err; 398 goto err;
391 } 399 }
392 400
393 jj=EVP_PKEY_decrypt((unsigned char *)tmp, 401 jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key),
394 ASN1_STRING_data(ri->enc_key), 402 M_ASN1_STRING_length(ri->enc_key), pkey);
395 ASN1_STRING_length(ri->enc_key),
396 pkey);
397 if (jj <= 0) 403 if (jj <= 0)
398 { 404 {
399 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_EVP_LIB); 405 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_EVP_LIB);
@@ -406,13 +412,25 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
406 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) 412 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
407 return(NULL); 413 return(NULL);
408 414
409 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) 415 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) {
410 { 416 /* HACK: some S/MIME clients don't use the same key
411 PKCS7err(PKCS7_F_PKCS7_DATADECODE, 417 * and effective key length. The key length is
418 * determined by the size of the decrypted RSA key.
419 * So we hack things to manually set the RC2 key
420 * because we currently can't do this with the EVP
421 * interface.
422 */
423#ifndef NO_RC2
424 if(is_rc2) RC2_set_key(&(evp_ctx->c.rc2_ks),jj, tmp,
425 EVP_CIPHER_CTX_key_length(evp_ctx)*8);
426 else
427#endif
428 {
429 PKCS7err(PKCS7_F_PKCS7_DATADECODE,
412 PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); 430 PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH);
413 goto err; 431 goto err;
414 } 432 }
415 EVP_CipherInit(evp_ctx,NULL,(unsigned char *)tmp,NULL,0); 433 } else EVP_CipherInit(evp_ctx,NULL,tmp,NULL,0);
416 434
417 memset(tmp,0,jj); 435 memset(tmp,0,jj);
418 436
@@ -430,6 +448,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
430 } 448 }
431 else 449 else
432 { 450 {
451#if 0
433 bio=BIO_new(BIO_s_mem()); 452 bio=BIO_new(BIO_s_mem());
434 /* We need to set this so that when we have read all 453 /* We need to set this so that when we have read all
435 * the data, the encrypt BIO, if present, will read 454 * the data, the encrypt BIO, if present, will read
@@ -438,6 +457,14 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
438 457
439 if (data_body->length > 0) 458 if (data_body->length > 0)
440 BIO_write(bio,(char *)data_body->data,data_body->length); 459 BIO_write(bio,(char *)data_body->data,data_body->length);
460#else
461 if (data_body->length > 0)
462 bio = BIO_new_mem_buf(data_body->data,data_body->length);
463 else {
464 bio=BIO_new(BIO_s_mem());
465 BIO_set_mem_eof_return(bio,0);
466 }
467#endif
441 } 468 }
442 BIO_push(out,bio); 469 BIO_push(out,bio);
443 bio=NULL; 470 bio=NULL;
@@ -479,12 +506,12 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
479 case NID_pkcs7_signedAndEnveloped: 506 case NID_pkcs7_signedAndEnveloped:
480 /* XXXXXXXXXXXXXXXX */ 507 /* XXXXXXXXXXXXXXXX */
481 si_sk=p7->d.signed_and_enveloped->signer_info; 508 si_sk=p7->d.signed_and_enveloped->signer_info;
482 os=ASN1_OCTET_STRING_new(); 509 os=M_ASN1_OCTET_STRING_new();
483 p7->d.signed_and_enveloped->enc_data->enc_data=os; 510 p7->d.signed_and_enveloped->enc_data->enc_data=os;
484 break; 511 break;
485 case NID_pkcs7_enveloped: 512 case NID_pkcs7_enveloped:
486 /* XXXXXXXXXXXXXXXX */ 513 /* XXXXXXXXXXXXXXXX */
487 os=ASN1_OCTET_STRING_new(); 514 os=M_ASN1_OCTET_STRING_new();
488 p7->d.enveloped->enc_data->enc_data=os; 515 p7->d.enveloped->enc_data->enc_data=os;
489 break; 516 break;
490 case NID_pkcs7_signed: 517 case NID_pkcs7_signed:
@@ -492,7 +519,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
492 os=p7->d.sign->contents->d.data; 519 os=p7->d.sign->contents->d.data;
493 /* If detached data then the content is excluded */ 520 /* If detached data then the content is excluded */
494 if(p7->detached) { 521 if(p7->detached) {
495 ASN1_OCTET_STRING_free(os); 522 M_ASN1_OCTET_STRING_free(os);
496 p7->d.sign->contents->d.data = NULL; 523 p7->d.sign->contents->d.data = NULL;
497 } 524 }
498 break; 525 break;
@@ -527,7 +554,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
527 PKCS7err(PKCS7_F_PKCS7_DATASIGN,PKCS7_R_INTERNAL_ERROR); 554 PKCS7err(PKCS7_F_PKCS7_DATASIGN,PKCS7_R_INTERNAL_ERROR);
528 goto err; 555 goto err;
529 } 556 }
530 if (EVP_MD_type(EVP_MD_CTX_type(mdc)) == j) 557 if (EVP_MD_CTX_type(mdc) == j)
531 break; 558 break;
532 else 559 else
533 btmp=btmp->next_bio; 560 btmp=btmp->next_bio;
@@ -561,10 +588,10 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
561 V_ASN1_UTCTIME,sign_time); 588 V_ASN1_UTCTIME,sign_time);
562 589
563 /* Add digest */ 590 /* Add digest */
564 md_tmp=EVP_MD_CTX_type(&ctx_tmp); 591 md_tmp=EVP_MD_CTX_md(&ctx_tmp);
565 EVP_DigestFinal(&ctx_tmp,md_data,&md_len); 592 EVP_DigestFinal(&ctx_tmp,md_data,&md_len);
566 digest=ASN1_OCTET_STRING_new(); 593 digest=M_ASN1_OCTET_STRING_new();
567 ASN1_OCTET_STRING_set(digest,md_data,md_len); 594 M_ASN1_OCTET_STRING_set(digest,md_data,md_len);
568 PKCS7_add_signed_attribute(si, 595 PKCS7_add_signed_attribute(si,
569 NID_pkcs9_messageDigest, 596 NID_pkcs9_messageDigest,
570 V_ASN1_OCTET_STRING,digest); 597 V_ASN1_OCTET_STRING,digest);
@@ -611,8 +638,17 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
611 goto err; 638 goto err;
612 } 639 }
613 BIO_get_mem_ptr(btmp,&buf_mem); 640 BIO_get_mem_ptr(btmp,&buf_mem);
614 ASN1_OCTET_STRING_set(os, 641 /* Mark the BIO read only then we can use its copy of the data
642 * instead of making an extra copy.
643 */
644 BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY);
645 BIO_set_mem_eof_return(btmp, 0);
646 os->data = (unsigned char *)buf_mem->data;
647 os->length = buf_mem->length;
648#if 0
649 M_ASN1_OCTET_STRING_set(os,
615 (unsigned char *)buf_mem->data,buf_mem->length); 650 (unsigned char *)buf_mem->data,buf_mem->length);
651#endif
616 } 652 }
617 if (pp != NULL) Free(pp); 653 if (pp != NULL) Free(pp);
618 pp=NULL; 654 pp=NULL;
@@ -658,6 +694,7 @@ int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio,
658 694
659 /* Lets verify */ 695 /* Lets verify */
660 X509_STORE_CTX_init(ctx,cert_store,x509,cert); 696 X509_STORE_CTX_init(ctx,cert_store,x509,cert);
697 X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_SMIME_SIGN);
661 i=X509_verify_cert(ctx); 698 i=X509_verify_cert(ctx);
662 if (i <= 0) 699 if (i <= 0)
663 { 700 {
@@ -709,7 +746,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
709 PKCS7_R_INTERNAL_ERROR); 746 PKCS7_R_INTERNAL_ERROR);
710 goto err; 747 goto err;
711 } 748 }
712 if (EVP_MD_type(EVP_MD_CTX_type(mdc)) == md_type) 749 if (EVP_MD_CTX_type(mdc) == md_type)
713 break; 750 break;
714 btmp=btmp->next_bio; 751 btmp=btmp->next_bio;
715 } 752 }
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c
index 8b863d0558..45973fe850 100644
--- a/src/lib/libcrypto/pkcs7/pk7_lib.c
+++ b/src/lib/libcrypto/pkcs7/pk7_lib.c
@@ -123,7 +123,7 @@ int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data)
123 { 123 {
124 case NID_pkcs7_signed: 124 case NID_pkcs7_signed:
125 if (p7->d.sign->contents != NULL) 125 if (p7->d.sign->contents != NULL)
126 PKCS7_content_free(p7->d.sign->contents); 126 PKCS7_free(p7->d.sign->contents);
127 p7->d.sign->contents=p7_data; 127 p7->d.sign->contents=p7_data;
128 break; 128 break;
129 case NID_pkcs7_digest: 129 case NID_pkcs7_digest:
@@ -157,7 +157,7 @@ int PKCS7_set_type(PKCS7 *p7, int type)
157 break; 157 break;
158 case NID_pkcs7_data: 158 case NID_pkcs7_data:
159 p7->type=obj; 159 p7->type=obj;
160 if ((p7->d.data=ASN1_OCTET_STRING_new()) == NULL) 160 if ((p7->d.data=M_ASN1_OCTET_STRING_new()) == NULL)
161 goto err; 161 goto err;
162 break; 162 break;
163 case NID_pkcs7_signedAndEnveloped: 163 case NID_pkcs7_signedAndEnveloped:
@@ -165,9 +165,6 @@ int PKCS7_set_type(PKCS7 *p7, int type)
165 if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new()) 165 if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new())
166 == NULL) goto err; 166 == NULL) goto err;
167 ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1); 167 ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1);
168/* p7->d.signed_and_enveloped->enc_data->content_type=
169 OBJ_nid2obj(NID_pkcs7_encrypted);*/
170
171 break; 168 break;
172 case NID_pkcs7_enveloped: 169 case NID_pkcs7_enveloped:
173 p7->type=obj; 170 p7->type=obj;
@@ -175,8 +172,14 @@ int PKCS7_set_type(PKCS7 *p7, int type)
175 == NULL) goto err; 172 == NULL) goto err;
176 ASN1_INTEGER_set(p7->d.enveloped->version,0); 173 ASN1_INTEGER_set(p7->d.enveloped->version,0);
177 break; 174 break;
178 case NID_pkcs7_digest:
179 case NID_pkcs7_encrypted: 175 case NID_pkcs7_encrypted:
176 p7->type=obj;
177 if ((p7->d.encrypted=PKCS7_ENCRYPT_new())
178 == NULL) goto err;
179 ASN1_INTEGER_set(p7->d.encrypted->version,0);
180 break;
181
182 case NID_pkcs7_digest:
180 default: 183 default:
181 PKCS7err(PKCS7_F_PKCS7_SET_TYPE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE); 184 PKCS7err(PKCS7_F_PKCS7_SET_TYPE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
182 goto err; 185 goto err;
@@ -224,8 +227,13 @@ int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi)
224 } 227 }
225 if (!j) /* we need to add another algorithm */ 228 if (!j) /* we need to add another algorithm */
226 { 229 {
227 alg=X509_ALGOR_new(); 230 if(!(alg=X509_ALGOR_new())
231 || !(alg->parameter = ASN1_TYPE_new())) {
232 PKCS7err(PKCS7_F_PKCS7_ADD_SIGNER,ERR_R_MALLOC_FAILURE);
233 return(0);
234 }
228 alg->algorithm=OBJ_nid2obj(nid); 235 alg->algorithm=OBJ_nid2obj(nid);
236 alg->parameter->type = V_ASN1_NULL;
229 sk_X509_ALGOR_push(md_sk,alg); 237 sk_X509_ALGOR_push(md_sk,alg);
230 } 238 }
231 239
@@ -289,6 +297,9 @@ int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)
289int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, 297int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
290 EVP_MD *dgst) 298 EVP_MD *dgst)
291 { 299 {
300 char is_dsa;
301 if (pkey->type == EVP_PKEY_DSA) is_dsa = 1;
302 else is_dsa = 0;
292 /* We now need to add another PKCS7_SIGNER_INFO entry */ 303 /* We now need to add another PKCS7_SIGNER_INFO entry */
293 ASN1_INTEGER_set(p7i->version,1); 304 ASN1_INTEGER_set(p7i->version,1);
294 X509_NAME_set(&p7i->issuer_and_serial->issuer, 305 X509_NAME_set(&p7i->issuer_and_serial->issuer,
@@ -296,17 +307,16 @@ int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
296 307
297 /* because ASN1_INTEGER_set is used to set a 'long' we will do 308 /* because ASN1_INTEGER_set is used to set a 'long' we will do
298 * things the ugly way. */ 309 * things the ugly way. */
299 ASN1_INTEGER_free(p7i->issuer_and_serial->serial); 310 M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
300 p7i->issuer_and_serial->serial= 311 p7i->issuer_and_serial->serial=
301 ASN1_INTEGER_dup(X509_get_serialNumber(x509)); 312 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));
302 313
303 /* lets keep the pkey around for a while */ 314 /* lets keep the pkey around for a while */
304 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY); 315 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
305 p7i->pkey=pkey; 316 p7i->pkey=pkey;
306 317
307 /* Set the algorithms */ 318 /* Set the algorithms */
308 if (pkey->type == EVP_PKEY_DSA) 319 if (is_dsa) p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
309 p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
310 else 320 else
311 p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst)); 321 p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst));
312 322
@@ -320,9 +330,12 @@ int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
320 330
321 if (p7i->digest_enc_alg->parameter != NULL) 331 if (p7i->digest_enc_alg->parameter != NULL)
322 ASN1_TYPE_free(p7i->digest_enc_alg->parameter); 332 ASN1_TYPE_free(p7i->digest_enc_alg->parameter);
323 if ((p7i->digest_enc_alg->parameter=ASN1_TYPE_new()) == NULL) 333 if(is_dsa) p7i->digest_enc_alg->parameter = NULL;
324 goto err; 334 else {
325 p7i->digest_enc_alg->parameter->type=V_ASN1_NULL; 335 if (!(p7i->digest_enc_alg->parameter=ASN1_TYPE_new()))
336 goto err;
337 p7i->digest_enc_alg->parameter->type=V_ASN1_NULL;
338 }
326 339
327 return(1); 340 return(1);
328err: 341err:
@@ -397,9 +410,9 @@ int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
397 X509_NAME_set(&p7i->issuer_and_serial->issuer, 410 X509_NAME_set(&p7i->issuer_and_serial->issuer,
398 X509_get_issuer_name(x509)); 411 X509_get_issuer_name(x509));
399 412
400 ASN1_INTEGER_free(p7i->issuer_and_serial->serial); 413 M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
401 p7i->issuer_and_serial->serial= 414 p7i->issuer_and_serial->serial=
402 ASN1_INTEGER_dup(X509_get_serialNumber(x509)); 415 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));
403 416
404 X509_ALGOR_free(p7i->key_enc_algor); 417 X509_ALGOR_free(p7i->key_enc_algor);
405 p7i->key_enc_algor=(X509_ALGOR *)ASN1_dup(i2d_X509_ALGOR, 418 p7i->key_enc_algor=(X509_ALGOR *)ASN1_dup(i2d_X509_ALGOR,
@@ -425,6 +438,7 @@ X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si)
425int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) 438int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
426 { 439 {
427 int i; 440 int i;
441 ASN1_OBJECT *objtmp;
428 PKCS7_ENC_CONTENT *ec; 442 PKCS7_ENC_CONTENT *ec;
429 443
430 i=OBJ_obj2nid(p7->type); 444 i=OBJ_obj2nid(p7->type);
@@ -441,7 +455,13 @@ int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
441 return(0); 455 return(0);
442 } 456 }
443 457
444 /* Setup cipher OID */ 458 /* Check cipher OID exists and has data in it*/
459 i = EVP_CIPHER_type(cipher);
460 if(i == NID_undef) {
461 PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
462 return(0);
463 }
464 objtmp = OBJ_nid2obj(i);
445 465
446 ec->cipher = cipher; 466 ec->cipher = cipher;
447 return 1; 467 return 1;
diff --git a/src/lib/libcrypto/pkcs7/pk7_mime.c b/src/lib/libcrypto/pkcs7/pk7_mime.c
new file mode 100644
index 0000000000..734643be28
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pk7_mime.c
@@ -0,0 +1,673 @@
1/* pk7_mime.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 <ctype.h>
61#include "cryptlib.h"
62#include <openssl/rand.h>
63#include <openssl/x509.h>
64
65/* MIME and related routines */
66
67/* MIME format structures
68 * Note that all are translated to lower case apart from
69 * parameter values. Quotes are stripped off
70 */
71
72typedef struct {
73char *name; /* Name of line e.g. "content-type" */
74char *value; /* Value of line e.g. "text/plain" */
75STACK /* MIME_PARAM */ *params; /* Zero or more parameters */
76} MIME_HEADER;
77
78typedef struct {
79char *param_name; /* Param name e.g. "micalg" */
80char *param_value; /* Param value e.g. "sha1" */
81} MIME_PARAM;
82
83
84static int B64_write_PKCS7(BIO *bio, PKCS7 *p7);
85static PKCS7 *B64_read_PKCS7(BIO *bio);
86static char * strip_ends(char *name);
87static char * strip_start(char *name);
88static char * strip_end(char *name);
89static MIME_HEADER *mime_hdr_new(char *name, char *value);
90static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value);
91static STACK *mime_parse_hdr(BIO *bio);
92static int mime_hdr_cmp(MIME_HEADER **a, MIME_HEADER **b);
93static int mime_param_cmp(MIME_PARAM **a, MIME_PARAM **b);
94static void mime_param_free(MIME_PARAM *param);
95static int mime_bound_check(char *line, int linelen, char *bound, int blen);
96static int multi_split(BIO *bio, char *bound, STACK **ret);
97static int iscrlf(char c);
98static MIME_HEADER *mime_hdr_find(STACK *hdrs, char *name);
99static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name);
100static void mime_hdr_free(MIME_HEADER *hdr);
101
102#define MAX_SMLEN 1024
103#define mime_debug(x) /* x */
104
105
106typedef void (*stkfree)();
107
108/* Base 64 read and write of PKCS#7 structure */
109
110static int B64_write_PKCS7(BIO *bio, PKCS7 *p7)
111{
112 BIO *b64;
113 if(!(b64 = BIO_new(BIO_f_base64()))) {
114 PKCS7err(PKCS7_F_B64_WRITE_PKCS7,ERR_R_MALLOC_FAILURE);
115 return 0;
116 }
117 bio = BIO_push(b64, bio);
118 i2d_PKCS7_bio(bio, p7);
119 BIO_flush(bio);
120 bio = BIO_pop(bio);
121 BIO_free(b64);
122 return 1;
123}
124
125static PKCS7 *B64_read_PKCS7(BIO *bio)
126{
127 BIO *b64;
128 PKCS7 *p7;
129 if(!(b64 = BIO_new(BIO_f_base64()))) {
130 PKCS7err(PKCS7_F_B64_READ_PKCS7,ERR_R_MALLOC_FAILURE);
131 return 0;
132 }
133 bio = BIO_push(b64, bio);
134 if(!(p7 = d2i_PKCS7_bio(bio, NULL)))
135 PKCS7err(PKCS7_F_B64_READ_PKCS7,PKCS7_R_DECODE_ERROR);
136 BIO_flush(bio);
137 bio = BIO_pop(bio);
138 BIO_free(b64);
139 return p7;
140}
141
142/* SMIME sender */
143
144int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
145{
146 char linebuf[MAX_SMLEN];
147 char bound[33], c;
148 int i;
149 if((flags & PKCS7_DETACHED) && data) {
150 /* We want multipart/signed */
151 /* Generate a random boundary */
152 RAND_pseudo_bytes((unsigned char *)bound, 32);
153 for(i = 0; i < 32; i++) {
154 c = bound[i] & 0xf;
155 if(c < 10) c += '0';
156 else c += 'A' - 10;
157 bound[i] = c;
158 }
159 bound[32] = 0;
160 BIO_printf(bio, "MIME-Version: 1.0\n");
161 BIO_printf(bio, "Content-Type: multipart/signed ; ");
162 BIO_printf(bio, "protocol=\"application/x-pkcs7-signature\" ; ");
163 BIO_printf(bio, "micalg=sha1 ; boundary=\"----%s\"\n\n", bound);
164 BIO_printf(bio, "This is an S/MIME signed message\n\n");
165 /* Now write out the first part */
166 BIO_printf(bio, "------%s\r\n", bound);
167 if(flags & PKCS7_TEXT) BIO_printf(bio, "Content-Type: text/plain\n\n");
168 while((i = BIO_read(data, linebuf, MAX_SMLEN)) > 0)
169 BIO_write(bio, linebuf, i);
170 BIO_printf(bio, "\n------%s\n", bound);
171
172 /* Headers for signature */
173
174 BIO_printf(bio, "Content-Type: application/x-pkcs7-signature; name=\"smime.p7s\"\n");
175 BIO_printf(bio, "Content-Transfer-Encoding: base64\n");
176 BIO_printf(bio, "Content-Disposition: attachment; filename=\"smime.p7s\"\n\n");
177 B64_write_PKCS7(bio, p7);
178 BIO_printf(bio,"\n------%s--\n\n", bound);
179 return 1;
180 }
181 /* MIME headers */
182 BIO_printf(bio, "MIME-Version: 1.0\n");
183 BIO_printf(bio, "Content-Disposition: attachment; filename=\"smime.p7m\"\n");
184 BIO_printf(bio, "Content-Type: application/x-pkcs7-mime; name=\"smime.p7m\"\n");
185 BIO_printf(bio, "Content-Transfer-Encoding: base64\n\n");
186 B64_write_PKCS7(bio, p7);
187 BIO_printf(bio, "\n");
188 return 1;
189}
190
191/* SMIME reader: handle multipart/signed and opaque signing.
192 * in multipart case the content is placed in a memory BIO
193 * pointed to by "bcont". In opaque this is set to NULL
194 */
195
196PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont)
197{
198 BIO *p7in;
199 STACK *headers = NULL;
200 STACK *parts = NULL;
201 MIME_HEADER *hdr;
202 MIME_PARAM *prm;
203 PKCS7 *p7;
204 int ret;
205
206 if(bcont) *bcont = NULL;
207
208 if (!(headers = mime_parse_hdr(bio))) {
209 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_PARSE_ERROR);
210 return NULL;
211 }
212
213 if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
214 sk_pop_free(headers, mime_hdr_free);
215 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_CONTENT_TYPE);
216 return NULL;
217 }
218
219 /* Handle multipart/signed */
220
221 if(!strcmp(hdr->value, "multipart/signed")) {
222 /* Split into two parts */
223 prm = mime_param_find(hdr, "boundary");
224 if(!prm || !prm->param_value) {
225 sk_pop_free(headers, mime_hdr_free);
226 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BOUNDARY);
227 return NULL;
228 }
229 ret = multi_split(bio, prm->param_value, &parts);
230 sk_pop_free(headers, mime_hdr_free);
231 if(!ret || (sk_num(parts) != 2) ) {
232 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BODY_FAILURE);
233 sk_pop_free(parts, (stkfree)BIO_free);
234 return NULL;
235 }
236
237 /* Parse the signature piece */
238 p7in = (BIO *)sk_value(parts, 1);
239
240 if (!(headers = mime_parse_hdr(p7in))) {
241 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_SIG_PARSE_ERROR);
242 sk_pop_free(parts, (stkfree)BIO_free);
243 return NULL;
244 }
245
246 /* Get content type */
247
248 if(!(hdr = mime_hdr_find(headers, "content-type")) ||
249 !hdr->value) {
250 sk_pop_free(headers, mime_hdr_free);
251 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_SIG_CONTENT_TYPE);
252 return NULL;
253 }
254
255 if(strcmp(hdr->value, "application/x-pkcs7-signature") &&
256 strcmp(hdr->value, "application/pkcs7-signature")) {
257 sk_pop_free(headers, mime_hdr_free);
258 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_SIG_INVALID_MIME_TYPE);
259 ERR_add_error_data(2, "type: ", hdr->value);
260 sk_pop_free(parts, (stkfree)BIO_free);
261 return NULL;
262 }
263 sk_pop_free(headers, mime_hdr_free);
264 /* Read in PKCS#7 */
265 if(!(p7 = B64_read_PKCS7(p7in))) {
266 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_PKCS7_SIG_PARSE_ERROR);
267 sk_pop_free(parts, (stkfree)BIO_free);
268 return NULL;
269 }
270
271 if(bcont) {
272 *bcont = (BIO *)sk_value(parts, 0);
273 BIO_free(p7in);
274 sk_free(parts);
275 } else sk_pop_free(parts, (stkfree)BIO_free);
276 return p7;
277 }
278
279 /* OK, if not multipart/signed try opaque signature */
280
281 if (strcmp (hdr->value, "application/x-pkcs7-mime") &&
282 strcmp (hdr->value, "application/pkcs7-mime")) {
283 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_INVALID_MIME_TYPE);
284 ERR_add_error_data(2, "type: ", hdr->value);
285 sk_pop_free(headers, mime_hdr_free);
286 return NULL;
287 }
288
289 sk_pop_free(headers, mime_hdr_free);
290
291 if(!(p7 = B64_read_PKCS7(bio))) {
292 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_PKCS7_PARSE_ERROR);
293 return NULL;
294 }
295 return p7;
296
297}
298
299/* Copy text from one BIO to another making the output CRLF at EOL */
300int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
301{
302 char eol;
303 int len;
304 char linebuf[MAX_SMLEN];
305 if(flags & PKCS7_BINARY) {
306 while((len = BIO_read(in, linebuf, MAX_SMLEN)) > 0)
307 BIO_write(out, linebuf, len);
308 return 1;
309 }
310 if(flags & PKCS7_TEXT) BIO_printf(out, "Content-Type: text/plain\r\n\r\n");
311 while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) {
312 eol = 0;
313 while(iscrlf(linebuf[len - 1])) {
314 len--;
315 eol = 1;
316 }
317 BIO_write(out, linebuf, len);
318 if(eol) BIO_write(out, "\r\n", 2);
319 }
320 return 1;
321}
322
323/* Strip off headers if they are text/plain */
324int SMIME_text(BIO *in, BIO *out)
325{
326 char iobuf[4096];
327 int len;
328 STACK *headers;
329 MIME_HEADER *hdr;
330 if (!(headers = mime_parse_hdr(in))) {
331 PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_PARSE_ERROR);
332 return 0;
333 }
334 if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
335 PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_NO_CONTENT_TYPE);
336 sk_pop_free(headers, mime_hdr_free);
337 return 0;
338 }
339 if (strcmp (hdr->value, "text/plain")) {
340 PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_INVALID_MIME_TYPE);
341 ERR_add_error_data(2, "type: ", hdr->value);
342 sk_pop_free(headers, mime_hdr_free);
343 return 0;
344 }
345 sk_pop_free(headers, mime_hdr_free);
346 while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0)
347 BIO_write(out, iobuf, len);
348 return 1;
349}
350
351/* Split a multipart/XXX message body into component parts: result is
352 * canonical parts in a STACK of bios
353 */
354
355static int multi_split(BIO *bio, char *bound, STACK **ret)
356{
357 char linebuf[MAX_SMLEN];
358 int len, blen;
359 BIO *bpart = NULL;
360 STACK *parts;
361 char state, part, first;
362 blen = strlen(bound);
363 part = 0;
364 state = 0;
365 first = 1;
366 parts = sk_new(NULL);
367 *ret = parts;
368 while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
369 state = mime_bound_check(linebuf, len, bound, blen);
370 if(state == 1) {
371 first = 1;
372 part++;
373 } else if(state == 2) {
374 sk_push(parts, (char *)bpart);
375 return 1;
376 } else if(part) {
377 if(first) {
378 first = 0;
379 if(bpart) sk_push(parts, (char *)bpart);
380 bpart = BIO_new(BIO_s_mem());
381
382 } else BIO_write(bpart, "\r\n", 2);
383 /* Strip CR+LF from linebuf */
384 while(iscrlf(linebuf[len - 1])) len--;
385 BIO_write(bpart, linebuf, len);
386 }
387 }
388 return 0;
389}
390
391static int iscrlf(char c)
392{
393 if(c == '\r' || c == '\n') return 1;
394 return 0;
395}
396
397/* This is the big one: parse MIME header lines up to message body */
398
399#define MIME_INVALID 0
400#define MIME_START 1
401#define MIME_TYPE 2
402#define MIME_NAME 3
403#define MIME_VALUE 4
404#define MIME_QUOTE 5
405#define MIME_COMMENT 6
406
407
408static STACK *mime_parse_hdr(BIO *bio)
409{
410 char *p, *q, c;
411 char *ntmp;
412 char linebuf[MAX_SMLEN];
413 MIME_HEADER *mhdr = NULL;
414 STACK *headers;
415 int len, state, save_state = 0;
416 headers = sk_new(mime_hdr_cmp);
417 while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
418 /* If whitespace at line start then continuation line */
419 if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME;
420 else state = MIME_START;
421 ntmp = NULL;
422 /* Go through all characters */
423 for(p = linebuf, q = linebuf; (c = *p) && (c!='\r') && (c!='\n'); p++) {
424
425 /* State machine to handle MIME headers
426 * if this looks horrible that's because it *is*
427 */
428
429 switch(state) {
430 case MIME_START:
431 if(c == ':') {
432 state = MIME_TYPE;
433 *p = 0;
434 ntmp = strip_ends(q);
435 q = p + 1;
436 }
437 break;
438
439 case MIME_TYPE:
440 if(c == ';') {
441 mime_debug("Found End Value\n");
442 *p = 0;
443 mhdr = mime_hdr_new(ntmp, strip_ends(q));
444 sk_push(headers, (char *)mhdr);
445 ntmp = NULL;
446 q = p + 1;
447 state = MIME_NAME;
448 } else if(c == '(') {
449 save_state = state;
450 state = MIME_COMMENT;
451 }
452 break;
453
454 case MIME_COMMENT:
455 if(c == ')') {
456 state = save_state;
457 }
458 break;
459
460 case MIME_NAME:
461 if(c == '=') {
462 state = MIME_VALUE;
463 *p = 0;
464 ntmp = strip_ends(q);
465 q = p + 1;
466 }
467 break ;
468
469 case MIME_VALUE:
470 if(c == ';') {
471 state = MIME_NAME;
472 *p = 0;
473 mime_hdr_addparam(mhdr, ntmp, strip_ends(q));
474 ntmp = NULL;
475 q = p + 1;
476 } else if (c == '"') {
477 mime_debug("Found Quote\n");
478 state = MIME_QUOTE;
479 } else if(c == '(') {
480 save_state = state;
481 state = MIME_COMMENT;
482 }
483 break;
484
485 case MIME_QUOTE:
486 if(c == '"') {
487 mime_debug("Found Match Quote\n");
488 state = MIME_VALUE;
489 }
490 break;
491 }
492 }
493
494 if(state == MIME_TYPE) {
495 mhdr = mime_hdr_new(ntmp, strip_ends(q));
496 sk_push(headers, (char *)mhdr);
497 } else if(state == MIME_VALUE)
498 mime_hdr_addparam(mhdr, ntmp, strip_ends(q));
499 if(p == linebuf) break; /* Blank line means end of headers */
500}
501
502return headers;
503
504}
505
506static char *strip_ends(char *name)
507{
508 return strip_end(strip_start(name));
509}
510
511/* Strip a parameter of whitespace from start of param */
512static char *strip_start(char *name)
513{
514 char *p, c;
515 /* Look for first non white space or quote */
516 for(p = name; (c = *p) ;p++) {
517 if(c == '"') {
518 /* Next char is start of string if non null */
519 if(p[1]) return p + 1;
520 /* Else null string */
521 return NULL;
522 }
523 if(!isspace((unsigned char)c)) return p;
524 }
525 return NULL;
526}
527
528/* As above but strip from end of string : maybe should handle brackets? */
529static char *strip_end(char *name)
530{
531 char *p, c;
532 if(!name) return NULL;
533 /* Look for first non white space or quote */
534 for(p = name + strlen(name) - 1; p >= name ;p--) {
535 c = *p;
536 if(c == '"') {
537 if(p - 1 == name) return NULL;
538 *p = 0;
539 return name;
540 }
541 if(isspace((unsigned char)c)) *p = 0;
542 else return name;
543 }
544 return NULL;
545}
546
547static MIME_HEADER *mime_hdr_new(char *name, char *value)
548{
549 MIME_HEADER *mhdr;
550 char *tmpname, *tmpval, *p;
551 int c;
552 if(name) {
553 if(!(tmpname = BUF_strdup(name))) return NULL;
554 for(p = tmpname ; *p; p++) {
555 c = *p;
556 if(isupper(c)) {
557 c = tolower(c);
558 *p = c;
559 }
560 }
561 } else tmpname = NULL;
562 if(value) {
563 if(!(tmpval = BUF_strdup(value))) return NULL;
564 for(p = tmpval ; *p; p++) {
565 c = *p;
566 if(isupper(c)) {
567 c = tolower(c);
568 *p = c;
569 }
570 }
571 } else tmpval = NULL;
572 mhdr = (MIME_HEADER *) Malloc(sizeof(MIME_HEADER));
573 if(!mhdr) return NULL;
574 mhdr->name = tmpname;
575 mhdr->value = tmpval;
576 if(!(mhdr->params = sk_new(mime_param_cmp))) return NULL;
577 return mhdr;
578}
579
580static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
581{
582 char *tmpname, *tmpval, *p;
583 int c;
584 MIME_PARAM *mparam;
585 if(name) {
586 tmpname = BUF_strdup(name);
587 if(!tmpname) return 0;
588 for(p = tmpname ; *p; p++) {
589 c = *p;
590 if(isupper(c)) {
591 c = tolower(c);
592 *p = c;
593 }
594 }
595 } else tmpname = NULL;
596 if(value) {
597 tmpval = BUF_strdup(value);
598 if(!tmpval) return 0;
599 } else tmpval = NULL;
600 /* Parameter values are case sensitive so leave as is */
601 mparam = (MIME_PARAM *) Malloc(sizeof(MIME_PARAM));
602 if(!mparam) return 0;
603 mparam->param_name = tmpname;
604 mparam->param_value = tmpval;
605 sk_push(mhdr->params, (char *)mparam);
606 return 1;
607}
608
609static int mime_hdr_cmp(MIME_HEADER **a, MIME_HEADER **b)
610{
611 return(strcmp((*a)->name, (*b)->name));
612}
613
614static int mime_param_cmp(MIME_PARAM **a, MIME_PARAM **b)
615{
616 return(strcmp((*a)->param_name, (*b)->param_name));
617}
618
619/* Find a header with a given name (if possible) */
620
621static MIME_HEADER *mime_hdr_find(STACK *hdrs, char *name)
622{
623 MIME_HEADER htmp;
624 int idx;
625 htmp.name = name;
626 idx = sk_find(hdrs, (char *)&htmp);
627 if(idx < 0) return NULL;
628 return (MIME_HEADER *)sk_value(hdrs, idx);
629}
630
631static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name)
632{
633 MIME_PARAM param;
634 int idx;
635 param.param_name = name;
636 idx = sk_find(hdr->params, (char *)&param);
637 if(idx < 0) return NULL;
638 return (MIME_PARAM *)sk_value(hdr->params, idx);
639}
640
641static void mime_hdr_free(MIME_HEADER *hdr)
642{
643 if(hdr->name) Free(hdr->name);
644 if(hdr->value) Free(hdr->value);
645 if(hdr->params) sk_pop_free(hdr->params, mime_param_free);
646 Free(hdr);
647}
648
649static void mime_param_free(MIME_PARAM *param)
650{
651 if(param->param_name) Free(param->param_name);
652 if(param->param_value) Free(param->param_value);
653 Free(param);
654}
655
656/* Check for a multipart boundary. Returns:
657 * 0 : no boundary
658 * 1 : part boundary
659 * 2 : final boundary
660 */
661static int mime_bound_check(char *line, int linelen, char *bound, int blen)
662{
663 if(linelen == -1) linelen = strlen(line);
664 if(blen == -1) blen = strlen(bound);
665 /* Quickly eliminate if line length too short */
666 if(blen + 2 > linelen) return 0;
667 /* Check for part boundary */
668 if(!strncmp(line, "--", 2) && !strncmp(line + 2, bound, blen)) {
669 if(!strncmp(line + blen + 2, "--", 2)) return 2;
670 else return 1;
671 }
672 return 0;
673}
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c
new file mode 100644
index 0000000000..b41f42ed04
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pk7_smime.c
@@ -0,0 +1,427 @@
1/* pk7_smime.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59/* Simple PKCS#7 processing functions */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
65
66PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
67 BIO *data, int flags)
68{
69 PKCS7 *p7;
70 PKCS7_SIGNER_INFO *si;
71 BIO *p7bio;
72 STACK *smcap;
73 int i;
74
75 if(!X509_check_private_key(signcert, pkey)) {
76 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
77 return NULL;
78 }
79
80 if(!(p7 = PKCS7_new())) {
81 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
82 return NULL;
83 }
84
85 PKCS7_set_type(p7, NID_pkcs7_signed);
86
87 PKCS7_content_new(p7, NID_pkcs7_data);
88
89 if (!(si = PKCS7_add_signature(p7,signcert,pkey,EVP_sha1()))) {
90 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR);
91 return NULL;
92 }
93
94 if(!(flags & PKCS7_NOCERTS)) {
95 PKCS7_add_certificate(p7, signcert);
96 if(certs) for(i = 0; i < sk_X509_num(certs); i++)
97 PKCS7_add_certificate(p7, sk_X509_value(certs, i));
98 }
99
100 if(!(p7bio = PKCS7_dataInit(p7, NULL))) {
101 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
102 return NULL;
103 }
104
105
106 SMIME_crlf_copy(data, p7bio, flags);
107
108 if(!(flags & PKCS7_NOATTR)) {
109 PKCS7_add_signed_attribute(si, NID_pkcs9_contentType,
110 V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data));
111 /* Add SMIMECapabilities */
112 if(!(smcap = sk_new(NULL))) {
113 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
114 return NULL;
115 }
116#ifndef NO_DES
117 PKCS7_simple_smimecap (smcap, NID_des_ede3_cbc, -1);
118#endif
119#ifndef NO_RC2
120 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 128);
121 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 64);
122#endif
123#ifndef NO_DES
124 PKCS7_simple_smimecap (smcap, NID_des_cbc, -1);
125#endif
126#ifndef NO_RC2
127 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40);
128#endif
129 PKCS7_add_attrib_smimecap (si, smcap);
130 sk_pop_free(smcap, X509_ALGOR_free);
131 }
132
133 if(flags & PKCS7_DETACHED)PKCS7_set_detached(p7, 1);
134
135 if (!PKCS7_dataFinal(p7,p7bio)) {
136 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_DATASIGN);
137 return NULL;
138 }
139
140 BIO_free_all(p7bio);
141 return p7;
142}
143
144int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
145 BIO *indata, BIO *out, int flags)
146{
147 STACK_OF(X509) *signers;
148 X509 *signer;
149 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
150 PKCS7_SIGNER_INFO *si;
151 X509_STORE_CTX cert_ctx;
152 char buf[4096];
153 int i, j=0;
154 BIO *p7bio;
155 BIO *tmpout;
156
157 if(!p7) {
158 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_INVALID_NULL_POINTER);
159 return 0;
160 }
161
162 if(!PKCS7_type_is_signed(p7)) {
163 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_WRONG_CONTENT_TYPE);
164 return 0;
165 }
166
167 /* Check for no data and no content: no data to verify signature */
168 if(PKCS7_get_detached(p7) && !indata) {
169 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_NO_CONTENT);
170 return 0;
171 }
172
173 /* Check for data and content: two sets of data */
174 if(!PKCS7_get_detached(p7) && indata) {
175 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_CONTENT_AND_DATA_PRESENT);
176 return 0;
177 }
178
179 sinfos = PKCS7_get_signer_info(p7);
180
181 if(!sinfos || !sk_PKCS7_SIGNER_INFO_num(sinfos)) {
182 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_NO_SIGNATURES_ON_DATA);
183 return 0;
184 }
185
186
187 signers = PKCS7_get0_signers(p7, certs, flags);
188
189 if(!signers) return 0;
190
191 /* Now verify the certificates */
192
193 if (!(flags & PKCS7_NOVERIFY)) for (i = 0; i < sk_X509_num(signers); i++) {
194 signer = sk_X509_value (signers, i);
195 if (!(flags & PKCS7_NOCHAIN)) {
196 X509_STORE_CTX_init(&cert_ctx, store, signer,
197 p7->d.sign->cert);
198 X509_STORE_CTX_set_purpose(&cert_ctx,
199 X509_PURPOSE_SMIME_SIGN);
200 } else X509_STORE_CTX_init (&cert_ctx, store, signer, NULL);
201 i = X509_verify_cert(&cert_ctx);
202 if (i <= 0) j = X509_STORE_CTX_get_error(&cert_ctx);
203 X509_STORE_CTX_cleanup(&cert_ctx);
204 if (i <= 0) {
205 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_CERTIFICATE_VERIFY_ERROR);
206 ERR_add_error_data(2, "Verify error:",
207 X509_verify_cert_error_string(j));
208 sk_X509_free(signers);
209 return 0;
210 }
211 /* Check for revocation status here */
212 }
213
214 p7bio=PKCS7_dataInit(p7,indata);
215
216 if(flags & PKCS7_TEXT) {
217 if(!(tmpout = BIO_new(BIO_s_mem()))) {
218 PKCS7err(PKCS7_F_PKCS7_VERIFY,ERR_R_MALLOC_FAILURE);
219 goto err;
220 }
221 } else tmpout = out;
222
223 /* We now have to 'read' from p7bio to calculate digests etc. */
224 for (;;)
225 {
226 i=BIO_read(p7bio,buf,sizeof(buf));
227 if (i <= 0) break;
228 if (tmpout) BIO_write(tmpout, buf, i);
229 }
230
231 if(flags & PKCS7_TEXT) {
232 if(!SMIME_text(tmpout, out)) {
233 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_SMIME_TEXT_ERROR);
234 BIO_free(tmpout);
235 goto err;
236 }
237 BIO_free(tmpout);
238 }
239
240 /* Now Verify All Signatures */
241 if (!(flags & PKCS7_NOSIGS))
242 for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
243 {
244 si=sk_PKCS7_SIGNER_INFO_value(sinfos,i);
245 signer = sk_X509_value (signers, i);
246 j=PKCS7_signatureVerify(p7bio,p7,si, signer);
247 if (j <= 0) {
248 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_SIGNATURE_FAILURE);
249 goto err;
250 }
251 }
252
253 sk_X509_free(signers);
254 if(indata) BIO_pop(p7bio);
255 BIO_free_all(p7bio);
256
257 return 1;
258
259 err:
260
261 sk_X509_free(signers);
262 BIO_free(p7bio);
263
264 return 0;
265}
266
267STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
268{
269 STACK_OF(X509) *signers;
270 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
271 PKCS7_SIGNER_INFO *si;
272 PKCS7_ISSUER_AND_SERIAL *ias;
273 X509 *signer;
274 int i;
275
276 if(!p7) {
277 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_INVALID_NULL_POINTER);
278 return NULL;
279 }
280
281 if(!PKCS7_type_is_signed(p7)) {
282 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_WRONG_CONTENT_TYPE);
283 return NULL;
284 }
285 if(!(signers = sk_X509_new(NULL))) {
286 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,ERR_R_MALLOC_FAILURE);
287 return NULL;
288 }
289
290 /* Collect all the signers together */
291
292 sinfos = PKCS7_get_signer_info(p7);
293
294 if(sk_PKCS7_SIGNER_INFO_num(sinfos) <= 0) {
295 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_NO_SIGNERS);
296 return 0;
297 }
298
299 for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
300 {
301 si = sk_PKCS7_SIGNER_INFO_value(sinfos, i);
302 ias = si->issuer_and_serial;
303 signer = NULL;
304 /* If any certificates passed they take priority */
305 if (certs) signer = X509_find_by_issuer_and_serial (certs,
306 ias->issuer, ias->serial);
307 if (!signer && !(flags & PKCS7_NOINTERN)
308 && p7->d.sign->cert) signer =
309 X509_find_by_issuer_and_serial (p7->d.sign->cert,
310 ias->issuer, ias->serial);
311 if (!signer) {
312 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND);
313 sk_X509_free(signers);
314 return 0;
315 }
316
317 sk_X509_push(signers, signer);
318 }
319 return signers;
320}
321
322
323/* Build a complete PKCS#7 enveloped data */
324
325PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
326 int flags)
327{
328 PKCS7 *p7;
329 BIO *p7bio = NULL;
330 int i;
331 X509 *x509;
332 if(!(p7 = PKCS7_new())) {
333 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,ERR_R_MALLOC_FAILURE);
334 return NULL;
335 }
336
337 PKCS7_set_type(p7, NID_pkcs7_enveloped);
338 if(!PKCS7_set_cipher(p7, cipher)) {
339 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_ERROR_SETTING_CIPHER);
340 goto err;
341 }
342
343 for(i = 0; i < sk_X509_num(certs); i++) {
344 x509 = sk_X509_value(certs, i);
345 if(!PKCS7_add_recipient(p7, x509)) {
346 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,
347 PKCS7_R_ERROR_ADDING_RECIPIENT);
348 goto err;
349 }
350 }
351
352 if(!(p7bio = PKCS7_dataInit(p7, NULL))) {
353 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,ERR_R_MALLOC_FAILURE);
354 goto err;
355 }
356
357 SMIME_crlf_copy(in, p7bio, flags);
358
359 BIO_flush(p7bio);
360
361 if (!PKCS7_dataFinal(p7,p7bio)) {
362 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_PKCS7_DATAFINAL_ERROR);
363 goto err;
364 }
365 BIO_free_all(p7bio);
366
367 return p7;
368
369 err:
370
371 BIO_free(p7bio);
372 PKCS7_free(p7);
373 return NULL;
374
375}
376
377int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
378{
379 BIO *tmpmem;
380 int ret, i;
381 char buf[4096];
382
383 if(!p7) {
384 PKCS7err(PKCS7_F_PKCS7_DECRYPT,PKCS7_R_INVALID_NULL_POINTER);
385 return 0;
386 }
387
388 if(!PKCS7_type_is_enveloped(p7)) {
389 PKCS7err(PKCS7_F_PKCS7_DECRYPT,PKCS7_R_WRONG_CONTENT_TYPE);
390 return 0;
391 }
392
393 if(!X509_check_private_key(cert, pkey)) {
394 PKCS7err(PKCS7_F_PKCS7_DECRYPT,
395 PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
396 return 0;
397 }
398
399 if(!(tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert))) {
400 PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_DECRYPT_ERROR);
401 return 0;
402 }
403
404 if (flags & PKCS7_TEXT) {
405 BIO *tmpbuf, *bread;
406 /* Encrypt BIOs can't do BIO_gets() so add a buffer BIO */
407 if(!(tmpbuf = BIO_new(BIO_f_buffer()))) {
408 PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
409 return 0;
410 }
411 if(!(bread = BIO_push(tmpbuf, tmpmem))) {
412 PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
413 return 0;
414 }
415 ret = SMIME_text(bread, data);
416 BIO_free_all(bread);
417 return ret;
418 } else {
419 for(;;) {
420 i = BIO_read(tmpmem, buf, sizeof(buf));
421 if(i <= 0) break;
422 BIO_write(data, buf, i);
423 }
424 BIO_free_all(tmpmem);
425 return 1;
426 }
427}
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.h b/src/lib/libcrypto/pkcs7/pkcs7.h
index c42bd6d391..3ec725d226 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7.h
+++ b/src/lib/libcrypto/pkcs7/pkcs7.h
@@ -71,8 +71,9 @@ extern "C" {
71#endif 71#endif
72 72
73#ifdef WIN32 73#ifdef WIN32
74/* Under Win32 this is defined in wincrypt.h */ 74/* Under Win32 thes are defined in wincrypt.h */
75#undef PKCS7_ISSUER_AND_SERIAL 75#undef PKCS7_ISSUER_AND_SERIAL
76#undef PKCS7_SIGNER_INFO
76#endif 77#endif
77 78
78/* 79/*
@@ -219,6 +220,7 @@ typedef struct pkcs7_st
219#define PKCS7_get_attributes(si) ((si)->unauth_attr) 220#define PKCS7_get_attributes(si) ((si)->unauth_attr)
220 221
221#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) 222#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
223#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
222#define PKCS7_type_is_signedAndEnveloped(a) \ 224#define PKCS7_type_is_signedAndEnveloped(a) \
223 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) 225 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
224#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) 226#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
@@ -236,6 +238,29 @@ typedef struct pkcs7_st
236#endif 238#endif
237#endif 239#endif
238 240
241/* S/MIME related flags */
242
243#define PKCS7_TEXT 0x1
244#define PKCS7_NOCERTS 0x2
245#define PKCS7_NOSIGS 0x4
246#define PKCS7_NOCHAIN 0x8
247#define PKCS7_NOINTERN 0x10
248#define PKCS7_NOVERIFY 0x20
249#define PKCS7_DETACHED 0x40
250#define PKCS7_BINARY 0x80
251#define PKCS7_NOATTR 0x100
252
253/* Flags: for compatibility with older code */
254
255#define SMIME_TEXT PKCS7_TEXT
256#define SMIME_NOCERTS PKCS7_NOCERTS
257#define SMIME_NOSIGS PKCS7_NOSIGS
258#define SMIME_NOCHAIN PKCS7_NOCHAIN
259#define SMIME_NOINTERN PKCS7_NOINTERN
260#define SMIME_NOVERIFY PKCS7_NOVERIFY
261#define SMIME_DETACHED PKCS7_DETACHED
262#define SMIME_BINARY PKCS7_BINARY
263#define SMIME_NOATTR PKCS7_NOATTR
239 264
240PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void ); 265PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void );
241void PKCS7_ISSUER_AND_SERIAL_free( 266void PKCS7_ISSUER_AND_SERIAL_free(
@@ -247,7 +272,7 @@ PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(
247 unsigned char **pp, long length); 272 unsigned char **pp, long length);
248 273
249#ifndef SSLEAY_MACROS 274#ifndef SSLEAY_MACROS
250int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,EVP_MD *type, 275int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
251 unsigned char *md,unsigned int *len); 276 unsigned char *md,unsigned int *len);
252#ifndef NO_FP_API 277#ifndef NO_FP_API
253PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); 278PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
@@ -368,6 +393,23 @@ int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
368int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); 393int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
369 394
370 395
396PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
397 BIO *data, int flags);
398int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
399 BIO *indata, BIO *out, int flags);
400STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
401PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
402 int flags);
403int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
404
405int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap);
406STACK *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
407int PKCS7_simple_smimecap(STACK *sk, int nid, int arg);
408
409int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
410PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
411int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
412int SMIME_text(BIO *in, BIO *out);
371 413
372/* BEGIN ERROR CODES */ 414/* BEGIN ERROR CODES */
373/* The following lines are auto generated by the script mkerr.pl. Any changes 415/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -377,6 +419,9 @@ int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
377/* Error codes for the PKCS7 functions. */ 419/* Error codes for the PKCS7 functions. */
378 420
379/* Function codes. */ 421/* Function codes. */
422#define PKCS7_F_B64_READ_PKCS7 120
423#define PKCS7_F_B64_WRITE_PKCS7 121
424#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118
380#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 425#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
381#define PKCS7_F_PKCS7_ADD_CRL 101 426#define PKCS7_F_PKCS7_ADD_CRL 101
382#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 427#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
@@ -386,20 +431,56 @@ int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
386#define PKCS7_F_PKCS7_DATAINIT 105 431#define PKCS7_F_PKCS7_DATAINIT 105
387#define PKCS7_F_PKCS7_DATASIGN 106 432#define PKCS7_F_PKCS7_DATASIGN 106
388#define PKCS7_F_PKCS7_DATAVERIFY 107 433#define PKCS7_F_PKCS7_DATAVERIFY 107
434#define PKCS7_F_PKCS7_DECRYPT 114
435#define PKCS7_F_PKCS7_ENCRYPT 115
436#define PKCS7_F_PKCS7_GET0_SIGNERS 124
389#define PKCS7_F_PKCS7_SET_CIPHER 108 437#define PKCS7_F_PKCS7_SET_CIPHER 108
390#define PKCS7_F_PKCS7_SET_CONTENT 109 438#define PKCS7_F_PKCS7_SET_CONTENT 109
391#define PKCS7_F_PKCS7_SET_TYPE 110 439#define PKCS7_F_PKCS7_SET_TYPE 110
440#define PKCS7_F_PKCS7_SIGN 116
392#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 441#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113
442#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119
443#define PKCS7_F_PKCS7_VERIFY 117
444#define PKCS7_F_SMIME_READ_PKCS7 122
445#define PKCS7_F_SMIME_TEXT 123
393 446
394/* Reason codes. */ 447/* Reason codes. */
448#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117
449#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144
395#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 450#define PKCS7_R_CIPHER_NOT_INITIALIZED 116
451#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118
452#define PKCS7_R_DECODE_ERROR 130
396#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 453#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100
454#define PKCS7_R_DECRYPT_ERROR 119
397#define PKCS7_R_DIGEST_FAILURE 101 455#define PKCS7_R_DIGEST_FAILURE 101
456#define PKCS7_R_ERROR_ADDING_RECIPIENT 120
457#define PKCS7_R_ERROR_SETTING_CIPHER 121
398#define PKCS7_R_INTERNAL_ERROR 102 458#define PKCS7_R_INTERNAL_ERROR 102
459#define PKCS7_R_INVALID_MIME_TYPE 131
460#define PKCS7_R_INVALID_NULL_POINTER 143
461#define PKCS7_R_MIME_NO_CONTENT_TYPE 132
462#define PKCS7_R_MIME_PARSE_ERROR 133
463#define PKCS7_R_MIME_SIG_PARSE_ERROR 134
399#define PKCS7_R_MISSING_CERIPEND_INFO 103 464#define PKCS7_R_MISSING_CERIPEND_INFO 103
465#define PKCS7_R_NO_CONTENT 122
466#define PKCS7_R_NO_CONTENT_TYPE 135
467#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136
468#define PKCS7_R_NO_MULTIPART_BOUNDARY 137
400#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 469#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115
470#define PKCS7_R_NO_SIGNATURES_ON_DATA 123
471#define PKCS7_R_NO_SIGNERS 142
472#define PKCS7_R_NO_SIG_CONTENT_TYPE 138
401#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 473#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104
474#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124
475#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125
476#define PKCS7_R_PKCS7_DATASIGN 126
477#define PKCS7_R_PKCS7_PARSE_ERROR 139
478#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140
479#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127
402#define PKCS7_R_SIGNATURE_FAILURE 105 480#define PKCS7_R_SIGNATURE_FAILURE 105
481#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128
482#define PKCS7_R_SIG_INVALID_MIME_TYPE 141
483#define PKCS7_R_SMIME_TEXT_ERROR 129
403#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 484#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106
404#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 485#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107
405#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 486#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108
diff --git a/src/lib/libcrypto/pkcs7/pkcs7err.c b/src/lib/libcrypto/pkcs7/pkcs7err.c
index 82be3c2ca1..813a8af9ed 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7err.c
+++ b/src/lib/libcrypto/pkcs7/pkcs7err.c
@@ -65,6 +65,9 @@
65#ifndef NO_ERR 65#ifndef NO_ERR
66static ERR_STRING_DATA PKCS7_str_functs[]= 66static ERR_STRING_DATA PKCS7_str_functs[]=
67 { 67 {
68{ERR_PACK(0,PKCS7_F_B64_READ_PKCS7,0), "B64_READ_PKCS7"},
69{ERR_PACK(0,PKCS7_F_B64_WRITE_PKCS7,0), "B64_WRITE_PKCS7"},
70{ERR_PACK(0,PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,0), "PKCS7_add_attrib_smimecap"},
68{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CERTIFICATE,0), "PKCS7_add_certificate"}, 71{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CERTIFICATE,0), "PKCS7_add_certificate"},
69{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CRL,0), "PKCS7_add_crl"}, 72{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CRL,0), "PKCS7_add_crl"},
70{ERR_PACK(0,PKCS7_F_PKCS7_ADD_RECIPIENT_INFO,0), "PKCS7_add_recipient_info"}, 73{ERR_PACK(0,PKCS7_F_PKCS7_ADD_RECIPIENT_INFO,0), "PKCS7_add_recipient_info"},
@@ -74,23 +77,59 @@ static ERR_STRING_DATA PKCS7_str_functs[]=
74{ERR_PACK(0,PKCS7_F_PKCS7_DATAINIT,0), "PKCS7_dataInit"}, 77{ERR_PACK(0,PKCS7_F_PKCS7_DATAINIT,0), "PKCS7_dataInit"},
75{ERR_PACK(0,PKCS7_F_PKCS7_DATASIGN,0), "PKCS7_DATASIGN"}, 78{ERR_PACK(0,PKCS7_F_PKCS7_DATASIGN,0), "PKCS7_DATASIGN"},
76{ERR_PACK(0,PKCS7_F_PKCS7_DATAVERIFY,0), "PKCS7_dataVerify"}, 79{ERR_PACK(0,PKCS7_F_PKCS7_DATAVERIFY,0), "PKCS7_dataVerify"},
80{ERR_PACK(0,PKCS7_F_PKCS7_DECRYPT,0), "PKCS7_decrypt"},
81{ERR_PACK(0,PKCS7_F_PKCS7_ENCRYPT,0), "PKCS7_encrypt"},
82{ERR_PACK(0,PKCS7_F_PKCS7_GET0_SIGNERS,0), "PKCS7_get0_signers"},
77{ERR_PACK(0,PKCS7_F_PKCS7_SET_CIPHER,0), "PKCS7_set_cipher"}, 83{ERR_PACK(0,PKCS7_F_PKCS7_SET_CIPHER,0), "PKCS7_set_cipher"},
78{ERR_PACK(0,PKCS7_F_PKCS7_SET_CONTENT,0), "PKCS7_set_content"}, 84{ERR_PACK(0,PKCS7_F_PKCS7_SET_CONTENT,0), "PKCS7_set_content"},
79{ERR_PACK(0,PKCS7_F_PKCS7_SET_TYPE,0), "PKCS7_set_type"}, 85{ERR_PACK(0,PKCS7_F_PKCS7_SET_TYPE,0), "PKCS7_set_type"},
86{ERR_PACK(0,PKCS7_F_PKCS7_SIGN,0), "PKCS7_sign"},
80{ERR_PACK(0,PKCS7_F_PKCS7_SIGNATUREVERIFY,0), "PKCS7_signatureVerify"}, 87{ERR_PACK(0,PKCS7_F_PKCS7_SIGNATUREVERIFY,0), "PKCS7_signatureVerify"},
88{ERR_PACK(0,PKCS7_F_PKCS7_SIMPLE_SMIMECAP,0), "PKCS7_simple_smimecap"},
89{ERR_PACK(0,PKCS7_F_PKCS7_VERIFY,0), "PKCS7_verify"},
90{ERR_PACK(0,PKCS7_F_SMIME_READ_PKCS7,0), "SMIME_read_PKCS7"},
91{ERR_PACK(0,PKCS7_F_SMIME_TEXT,0), "SMIME_text"},
81{0,NULL} 92{0,NULL}
82 }; 93 };
83 94
84static ERR_STRING_DATA PKCS7_str_reasons[]= 95static ERR_STRING_DATA PKCS7_str_reasons[]=
85 { 96 {
97{PKCS7_R_CERTIFICATE_VERIFY_ERROR ,"certificate verify error"},
98{PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER ,"cipher has no object identifier"},
86{PKCS7_R_CIPHER_NOT_INITIALIZED ,"cipher not initialized"}, 99{PKCS7_R_CIPHER_NOT_INITIALIZED ,"cipher not initialized"},
100{PKCS7_R_CONTENT_AND_DATA_PRESENT ,"content and data present"},
101{PKCS7_R_DECODE_ERROR ,"decode error"},
87{PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH ,"decrypted key is wrong length"}, 102{PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH ,"decrypted key is wrong length"},
103{PKCS7_R_DECRYPT_ERROR ,"decrypt error"},
88{PKCS7_R_DIGEST_FAILURE ,"digest failure"}, 104{PKCS7_R_DIGEST_FAILURE ,"digest failure"},
105{PKCS7_R_ERROR_ADDING_RECIPIENT ,"error adding recipient"},
106{PKCS7_R_ERROR_SETTING_CIPHER ,"error setting cipher"},
89{PKCS7_R_INTERNAL_ERROR ,"internal error"}, 107{PKCS7_R_INTERNAL_ERROR ,"internal error"},
108{PKCS7_R_INVALID_MIME_TYPE ,"invalid mime type"},
109{PKCS7_R_INVALID_NULL_POINTER ,"invalid null pointer"},
110{PKCS7_R_MIME_NO_CONTENT_TYPE ,"mime no content type"},
111{PKCS7_R_MIME_PARSE_ERROR ,"mime parse error"},
112{PKCS7_R_MIME_SIG_PARSE_ERROR ,"mime sig parse error"},
90{PKCS7_R_MISSING_CERIPEND_INFO ,"missing ceripend info"}, 113{PKCS7_R_MISSING_CERIPEND_INFO ,"missing ceripend info"},
114{PKCS7_R_NO_CONTENT ,"no content"},
115{PKCS7_R_NO_CONTENT_TYPE ,"no content type"},
116{PKCS7_R_NO_MULTIPART_BODY_FAILURE ,"no multipart body failure"},
117{PKCS7_R_NO_MULTIPART_BOUNDARY ,"no multipart boundary"},
91{PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE,"no recipient matches certificate"}, 118{PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE,"no recipient matches certificate"},
119{PKCS7_R_NO_SIGNATURES_ON_DATA ,"no signatures on data"},
120{PKCS7_R_NO_SIGNERS ,"no signers"},
121{PKCS7_R_NO_SIG_CONTENT_TYPE ,"no sig content type"},
92{PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE,"operation not supported on this type"}, 122{PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE,"operation not supported on this type"},
123{PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR ,"pkcs7 add signature error"},
124{PKCS7_R_PKCS7_DATAFINAL_ERROR ,"pkcs7 datafinal error"},
125{PKCS7_R_PKCS7_DATASIGN ,"pkcs7 datasign"},
126{PKCS7_R_PKCS7_PARSE_ERROR ,"pkcs7 parse error"},
127{PKCS7_R_PKCS7_SIG_PARSE_ERROR ,"pkcs7 sig parse error"},
128{PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE,"private key does not match certificate"},
93{PKCS7_R_SIGNATURE_FAILURE ,"signature failure"}, 129{PKCS7_R_SIGNATURE_FAILURE ,"signature failure"},
130{PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND ,"signer certificate not found"},
131{PKCS7_R_SIG_INVALID_MIME_TYPE ,"sig invalid mime type"},
132{PKCS7_R_SMIME_TEXT_ERROR ,"smime text error"},
94{PKCS7_R_UNABLE_TO_FIND_CERTIFICATE ,"unable to find certificate"}, 133{PKCS7_R_UNABLE_TO_FIND_CERTIFICATE ,"unable to find certificate"},
95{PKCS7_R_UNABLE_TO_FIND_MEM_BIO ,"unable to find mem bio"}, 134{PKCS7_R_UNABLE_TO_FIND_MEM_BIO ,"unable to find mem bio"},
96{PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST ,"unable to find message digest"}, 135{PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST ,"unable to find message digest"},
diff --git a/src/lib/libcrypto/pkcs7/sign.c b/src/lib/libcrypto/pkcs7/sign.c
index d5f1154006..22290e192c 100644
--- a/src/lib/libcrypto/pkcs7/sign.c
+++ b/src/lib/libcrypto/pkcs7/sign.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h>
59#include <openssl/bio.h> 60#include <openssl/bio.h>
60#include <openssl/x509.h> 61#include <openssl/x509.h>
61#include <openssl/pem.h> 62#include <openssl/pem.h>
@@ -75,10 +76,18 @@ char *argv[];
75 int i; 76 int i;
76 int nodetach=0; 77 int nodetach=0;
77 78
79#ifndef NO_MD2
78 EVP_add_digest(EVP_md2()); 80 EVP_add_digest(EVP_md2());
81#endif
82#ifndef NO_MD5
79 EVP_add_digest(EVP_md5()); 83 EVP_add_digest(EVP_md5());
84#endif
85#ifndef NO_SHA1
80 EVP_add_digest(EVP_sha1()); 86 EVP_add_digest(EVP_sha1());
87#endif
88#ifndef NO_MDC2
81 EVP_add_digest(EVP_mdc2()); 89 EVP_add_digest(EVP_mdc2());
90#endif
82 91
83 data=BIO_new(BIO_s_file()); 92 data=BIO_new(BIO_s_file());
84again: 93again:
@@ -97,9 +106,9 @@ again:
97 BIO_set_fp(data,stdin,BIO_NOCLOSE); 106 BIO_set_fp(data,stdin,BIO_NOCLOSE);
98 107
99 if ((in=BIO_new_file("server.pem","r")) == NULL) goto err; 108 if ((in=BIO_new_file("server.pem","r")) == NULL) goto err;
100 if ((x509=PEM_read_bio_X509(in,NULL,NULL)) == NULL) goto err; 109 if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err;
101 BIO_reset(in); 110 BIO_reset(in);
102 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL)) == NULL) goto err; 111 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL) goto err;
103 BIO_free(in); 112 BIO_free(in);
104 113
105 p7=PKCS7_new(); 114 p7=PKCS7_new();
diff --git a/src/lib/libcrypto/pkcs7/verify.c b/src/lib/libcrypto/pkcs7/verify.c
index 32d9783e45..49fc8d8bed 100644
--- a/src/lib/libcrypto/pkcs7/verify.c
+++ b/src/lib/libcrypto/pkcs7/verify.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h>
59#include <openssl/bio.h> 60#include <openssl/bio.h>
60#include <openssl/asn1.h> 61#include <openssl/asn1.h>
61#include <openssl/x509.h> 62#include <openssl/x509.h>
@@ -84,10 +85,18 @@ char *argv[];
84 85
85 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 86 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
86 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE); 87 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
88#ifndef NO_MD2
87 EVP_add_digest(EVP_md2()); 89 EVP_add_digest(EVP_md2());
90#endif
91#ifndef NO_MD5
88 EVP_add_digest(EVP_md5()); 92 EVP_add_digest(EVP_md5());
93#endif
94#ifndef NO_SHA1
89 EVP_add_digest(EVP_sha1()); 95 EVP_add_digest(EVP_sha1());
96#endif
97#ifndef NO_MDC2
90 EVP_add_digest(EVP_mdc2()); 98 EVP_add_digest(EVP_mdc2());
99#endif
91 100
92 data=BIO_new(BIO_s_file()); 101 data=BIO_new(BIO_s_file());
93 102
@@ -121,7 +130,7 @@ char *argv[];
121 130
122 131
123 /* Load the PKCS7 object from a file */ 132 /* Load the PKCS7 object from a file */
124 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL)) == NULL) goto err; 133 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL,NULL)) == NULL) goto err;
125 134
126 /* This stuff is being setup for certificate verification. 135 /* This stuff is being setup for certificate verification.
127 * When using SSL, it could be replaced with a 136 * When using SSL, it could be replaced with a
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
index 014356cb18..be8eea34a2 100644
--- a/src/lib/libcrypto/rand/Makefile.ssl
+++ b/src/lib/libcrypto/rand/Makefile.ssl
@@ -22,8 +22,8 @@ TEST= randtest.c
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC=md_rand.c randfile.c rand_lib.c 25LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c
26LIBOBJ=md_rand.o randfile.o rand_lib.o 26LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o
27 27
28SRC= $(LIBSRC) 28SRC= $(LIBSRC)
29 29
@@ -79,9 +79,14 @@ clean:
79# DO NOT DELETE THIS LINE -- make depend depends on it. 79# DO NOT DELETE THIS LINE -- make depend depends on it.
80 80
81md_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 81md_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
82md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 82md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
83md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 83md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
84md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
84md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 85md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
86rand_egd.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h
87rand_err.o: ../../include/openssl/err.h ../../include/openssl/rand.h
85rand_lib.o: ../../include/openssl/rand.h 88rand_lib.o: ../../include/openssl/rand.h
86randfile.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 89randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
87randfile.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h 90randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
91randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
92randfile.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
index c9a071bd22..6b158f0349 100644
--- a/src/lib/libcrypto/rand/md_rand.c
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -56,15 +56,23 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#define ENTROPY_NEEDED 16 /* require 128 bits = 16 bytes of randomness */
60
61#ifndef MD_RAND_DEBUG
62# ifndef NDEBUG
63# define NDEBUG
64# endif
65#endif
66
67#include <assert.h>
59#include <stdio.h> 68#include <stdio.h>
60#include <sys/types.h>
61#include <fcntl.h>
62#include <time.h> 69#include <time.h>
63#include <string.h> 70#include <string.h>
64 71
65#include "openssl/e_os.h" 72#include "openssl/e_os.h"
66 73
67#include <openssl/crypto.h> 74#include <openssl/crypto.h>
75#include <openssl/err.h>
68 76
69#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND) 77#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
70#if !defined(NO_SHA) && !defined(NO_SHA1) 78#if !defined(NO_SHA) && !defined(NO_SHA1)
@@ -130,17 +138,23 @@ static int state_num=0,state_index=0;
130static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH]; 138static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH];
131static unsigned char md[MD_DIGEST_LENGTH]; 139static unsigned char md[MD_DIGEST_LENGTH];
132static long md_count[2]={0,0}; 140static long md_count[2]={0,0};
141static double entropy=0;
142static int initialized=0;
133 143
134const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT; 144const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
135 145
136static void ssleay_rand_cleanup(void); 146static void ssleay_rand_cleanup(void);
137static void ssleay_rand_seed(const void *buf, int num); 147static void ssleay_rand_seed(const void *buf, int num);
138static void ssleay_rand_bytes(unsigned char *buf, int num); 148static void ssleay_rand_add(const void *buf, int num, double add_entropy);
149static int ssleay_rand_bytes(unsigned char *buf, int num);
150static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
139 151
140RAND_METHOD rand_ssleay_meth={ 152RAND_METHOD rand_ssleay_meth={
141 ssleay_rand_seed, 153 ssleay_rand_seed,
142 ssleay_rand_bytes, 154 ssleay_rand_bytes,
143 ssleay_rand_cleanup, 155 ssleay_rand_cleanup,
156 ssleay_rand_add,
157 ssleay_rand_pseudo_bytes,
144 }; 158 };
145 159
146RAND_METHOD *RAND_SSLeay(void) 160RAND_METHOD *RAND_SSLeay(void)
@@ -156,22 +170,49 @@ static void ssleay_rand_cleanup(void)
156 memset(md,0,MD_DIGEST_LENGTH); 170 memset(md,0,MD_DIGEST_LENGTH);
157 md_count[0]=0; 171 md_count[0]=0;
158 md_count[1]=0; 172 md_count[1]=0;
173 entropy=0;
159 } 174 }
160 175
161static void ssleay_rand_seed(const void *buf, int num) 176static void ssleay_rand_add(const void *buf, int num, double add)
162 { 177 {
163 int i,j,k,st_idx,st_num; 178 int i,j,k,st_idx;
179 long md_c[2];
180 unsigned char local_md[MD_DIGEST_LENGTH];
164 MD_CTX m; 181 MD_CTX m;
165 182
166#ifdef NORAND 183#ifdef NORAND
167 return; 184 return;
168#endif 185#endif
169 186
187 /*
188 * (Based on the rand(3) manpage)
189 *
190 * The input is chopped up into units of 20 bytes (or less for
191 * the last block). Each of these blocks is run through the hash
192 * function as follows: The data passed to the hash function
193 * is the current 'md', the same number of bytes from the 'state'
194 * (the location determined by in incremented looping index) as
195 * the current 'block', the new key data 'block', and 'count'
196 * (which is incremented after each use).
197 * The result of this is kept in 'md' and also xored into the
198 * 'state' at the same locations that were used as input into the
199 * hash function.
200 */
201
170 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 202 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
171 st_idx=state_index; 203 st_idx=state_index;
172 st_num=state_num;
173 204
174 state_index=(state_index+num); 205 /* use our own copies of the counters so that even
206 * if a concurrent thread seeds with exactly the
207 * same data and uses the same subarray there's _some_
208 * difference */
209 md_c[0] = md_count[0];
210 md_c[1] = md_count[1];
211
212 memcpy(local_md, md, sizeof md);
213
214 /* state_index <= state_num <= STATE_SIZE */
215 state_index += num;
175 if (state_index >= STATE_SIZE) 216 if (state_index >= STATE_SIZE)
176 { 217 {
177 state_index%=STATE_SIZE; 218 state_index%=STATE_SIZE;
@@ -182,6 +223,14 @@ static void ssleay_rand_seed(const void *buf, int num)
182 if (state_index > state_num) 223 if (state_index > state_num)
183 state_num=state_index; 224 state_num=state_index;
184 } 225 }
226 /* state_index <= state_num <= STATE_SIZE */
227
228 /* state[st_idx], ..., state[(st_idx + num - 1) % STATE_SIZE]
229 * are what we will use now, but other threads may use them
230 * as well */
231
232 md_count[1] += (num / MD_DIGEST_LENGTH) + (num % MD_DIGEST_LENGTH > 0);
233
185 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 234 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
186 235
187 for (i=0; i<num; i+=MD_DIGEST_LENGTH) 236 for (i=0; i<num; i+=MD_DIGEST_LENGTH)
@@ -190,7 +239,7 @@ static void ssleay_rand_seed(const void *buf, int num)
190 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j; 239 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j;
191 240
192 MD_Init(&m); 241 MD_Init(&m);
193 MD_Update(&m,md,MD_DIGEST_LENGTH); 242 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
194 k=(st_idx+j)-STATE_SIZE; 243 k=(st_idx+j)-STATE_SIZE;
195 if (k > 0) 244 if (k > 0)
196 { 245 {
@@ -201,33 +250,107 @@ static void ssleay_rand_seed(const void *buf, int num)
201 MD_Update(&m,&(state[st_idx]),j); 250 MD_Update(&m,&(state[st_idx]),j);
202 251
203 MD_Update(&m,buf,j); 252 MD_Update(&m,buf,j);
204 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count)); 253 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
205 MD_Final(md,&m); 254 MD_Final(local_md,&m);
206 md_count[1]++; 255 md_c[1]++;
207 256
208 buf=(const char *)buf + j; 257 buf=(const char *)buf + j;
209 258
210 for (k=0; k<j; k++) 259 for (k=0; k<j; k++)
211 { 260 {
212 state[st_idx++]^=md[k]; 261 /* Parallel threads may interfere with this,
262 * but always each byte of the new state is
263 * the XOR of some previous value of its
264 * and local_md (itermediate values may be lost).
265 * Alway using locking could hurt performance more
266 * than necessary given that conflicts occur only
267 * when the total seeding is longer than the random
268 * state. */
269 state[st_idx++]^=local_md[k];
213 if (st_idx >= STATE_SIZE) 270 if (st_idx >= STATE_SIZE)
214 {
215 st_idx=0; 271 st_idx=0;
216 st_num=STATE_SIZE;
217 }
218 } 272 }
219 } 273 }
220 memset((char *)&m,0,sizeof(m)); 274 memset((char *)&m,0,sizeof(m));
275
276 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
277 /* Don't just copy back local_md into md -- this could mean that
278 * other thread's seeding remains without effect (except for
279 * the incremented counter). By XORing it we keep at least as
280 * much entropy as fits into md. */
281 for (k = 0; k < sizeof md; k++)
282 {
283 md[k] ^= local_md[k];
284 }
285 if (entropy < ENTROPY_NEEDED) /* stop counting when we have enough */
286 entropy += add;
287 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
288
289#ifndef THREADS
290 assert(md_c[1] == md_count[1]);
291#endif
221 } 292 }
222 293
223static void ssleay_rand_bytes(unsigned char *buf, int num) 294static void ssleay_rand_seed(const void *buf, int num)
295 {
296 ssleay_rand_add(buf, num, num);
297 }
298
299static void ssleay_rand_initialize(void)
224 { 300 {
225 int i,j,k,st_num,st_idx;
226 MD_CTX m;
227 static int init=1;
228 unsigned long l; 301 unsigned long l;
302#ifndef GETPID_IS_MEANINGLESS
303 pid_t curr_pid = getpid();
304#endif
229#ifdef DEVRANDOM 305#ifdef DEVRANDOM
230 int fd; 306 FILE *fh;
307#endif
308
309 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
310 /* put in some default random data, we need more than just this */
311#ifndef GETPID_IS_MEANINGLESS
312 l=curr_pid;
313 RAND_add(&l,sizeof(l),0);
314 l=getuid();
315 RAND_add(&l,sizeof(l),0);
316#endif
317 l=time(NULL);
318 RAND_add(&l,sizeof(l),0);
319
320#ifdef DEVRANDOM
321 /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
322 * have this. Use /dev/urandom if you can as /dev/random may block
323 * if it runs out of random entries. */
324
325 if ((fh = fopen(DEVRANDOM, "r")) != NULL)
326 {
327 unsigned char tmpbuf[ENTROPY_NEEDED];
328 int n;
329
330 setvbuf(fh, NULL, _IONBF, 0);
331 n=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh);
332 fclose(fh);
333 RAND_add(tmpbuf,sizeof tmpbuf,n);
334 memset(tmpbuf,0,n);
335 }
336#endif
337#ifdef PURIFY
338 memset(state,0,STATE_SIZE);
339 memset(md,0,MD_DIGEST_LENGTH);
340#endif
341 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
342 initialized=1;
343 }
344
345static int ssleay_rand_bytes(unsigned char *buf, int num)
346 {
347 int i,j,k,st_num,st_idx;
348 int ok;
349 long md_c[2];
350 unsigned char local_md[MD_DIGEST_LENGTH];
351 MD_CTX m;
352#ifndef GETPID_IS_MEANINGLESS
353 pid_t curr_pid = getpid();
231#endif 354#endif
232 355
233#ifdef PREDICT 356#ifdef PREDICT
@@ -236,65 +359,63 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
236 359
237 for (i=0; i<num; i++) 360 for (i=0; i<num; i++)
238 buf[i]=val++; 361 buf[i]=val++;
239 return; 362 return(1);
240 } 363 }
241#endif 364#endif
242 365
366 /*
367 * (Based on the rand(3) manpage:)
368 *
369 * For each group of 10 bytes (or less), we do the following:
370 *
371 * Input into the hash function the top 10 bytes from the
372 * local 'md' (which is initialized from the global 'md'
373 * before any bytes are generated), the bytes that are
374 * to be overwritten by the random bytes, and bytes from the
375 * 'state' (incrementing looping index). From this digest output
376 * (which is kept in 'md'), the top (up to) 10 bytes are
377 * returned to the caller and the bottom (up to) 10 bytes are xored
378 * into the 'state'.
379 * Finally, after we have finished 'num' random bytes for the
380 * caller, 'count' (which is incremented) and the local and global 'md'
381 * are fed into the hash function and the results are kept in the
382 * global 'md'.
383 */
384
243 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 385 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
244 386
245 if (init) 387 if (!initialized)
388 ssleay_rand_initialize();
389
390 ok = (entropy >= ENTROPY_NEEDED);
391 if (!ok)
246 { 392 {
247 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 393 /* If the PRNG state is not yet unpredictable, then seeing
248 /* put in some default random data, we need more than 394 * the PRNG output may help attackers to determine the new
249 * just this */ 395 * state; thus we have to decrease the entropy estimate.
250 RAND_seed(&m,sizeof(m)); 396 * Once we've had enough initial seeding we don't bother to
251#ifndef MSDOS 397 * adjust the entropy count, though, because we're not ambitious
252 l=getpid(); 398 * to provide *information-theoretic* randomness.
253 RAND_seed(&l,sizeof(l));
254 l=getuid();
255 RAND_seed(&l,sizeof(l));
256#endif
257 l=time(NULL);
258 RAND_seed(&l,sizeof(l));
259
260/* #ifdef DEVRANDOM */
261 /*
262 * Use a random entropy pool device.
263 * Linux 1.3.x, OpenBSD, and FreeBSD have
264 * this. Use /dev/urandom if you can
265 * as /dev/random will block if it runs out
266 * of random entries.
267 */ 399 */
268 if ((fd = open(DEVRANDOM, O_RDONLY)) != NULL) 400 entropy -= num;
269 { 401 if (entropy < 0)
270 unsigned char tmpbuf[32]; 402 entropy = 0;
271
272 read(fd, tmpbuf, sizeof(tmpbuf));
273 /* we don't care how many bytes we read,
274 * we will just copy the 'stack' if there is
275 * nothing else :-) */
276 /* the above comment is EVIL. Security software
277 * RELIES ON THESE PRIMITIVES HAVING MORE SECURE
278 * BEHAVIOUR! Secure entropy is required in
279 * many cases! */
280 RAND_seed(tmpbuf,32);
281 memset(tmpbuf,0,32);
282 }
283/* #endif */
284#ifdef PURIFY
285 memset(state,0,STATE_SIZE);
286 memset(md,0,MD_DIGEST_LENGTH);
287#endif
288 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
289 init=0;
290 } 403 }
291 404
292 st_idx=state_index; 405 st_idx=state_index;
293 st_num=state_num; 406 st_num=state_num;
407 md_c[0] = md_count[0];
408 md_c[1] = md_count[1];
409 memcpy(local_md, md, sizeof md);
410
294 state_index+=num; 411 state_index+=num;
295 if (state_index > state_num) 412 if (state_index > state_num)
296 state_index=(state_index%state_num); 413 state_index %= state_num;
414
415 /* state[st_idx], ..., state[(st_idx + num - 1) % st_num]
416 * are now ours (but other threads may use them too) */
297 417
418 md_count[0] += 1;
298 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 419 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
299 420
300 while (num > 0) 421 while (num > 0)
@@ -302,8 +423,15 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
302 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num; 423 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;
303 num-=j; 424 num-=j;
304 MD_Init(&m); 425 MD_Init(&m);
305 MD_Update(&m,&(md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2); 426#ifndef GETPID_IS_MEANINGLESS
306 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count)); 427 if (curr_pid) /* just in the first iteration to save time */
428 {
429 MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid);
430 curr_pid = 0;
431 }
432#endif
433 MD_Update(&m,&(local_md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2);
434 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
307#ifndef PURIFY 435#ifndef PURIFY
308 MD_Update(&m,buf,j); /* purify complains */ 436 MD_Update(&m,buf,j); /* purify complains */
309#endif 437#endif
@@ -315,23 +443,57 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
315 } 443 }
316 else 444 else
317 MD_Update(&m,&(state[st_idx]),j); 445 MD_Update(&m,&(state[st_idx]),j);
318 MD_Final(md,&m); 446 MD_Final(local_md,&m);
319 447
320 for (i=0; i<j; i++) 448 for (i=0; i<j; i++)
321 { 449 {
450 state[st_idx++]^=local_md[i]; /* may compete with other threads */
451 *(buf++)=local_md[i+MD_DIGEST_LENGTH/2];
322 if (st_idx >= st_num) 452 if (st_idx >= st_num)
323 st_idx=0; 453 st_idx=0;
324 state[st_idx++]^=md[i];
325 *(buf++)=md[i+MD_DIGEST_LENGTH/2];
326 } 454 }
327 } 455 }
328 456
329 MD_Init(&m); 457 MD_Init(&m);
330 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count)); 458 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
331 md_count[0]++; 459 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
460 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
332 MD_Update(&m,md,MD_DIGEST_LENGTH); 461 MD_Update(&m,md,MD_DIGEST_LENGTH);
333 MD_Final(md,&m); 462 MD_Final(md,&m);
463 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
464
334 memset(&m,0,sizeof(m)); 465 memset(&m,0,sizeof(m));
466 if (ok)
467 return(1);
468 else
469 {
470 RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
471 return(0);
472 }
473 }
474
475/* pseudo-random bytes that are guaranteed to be unique but not
476 unpredictable */
477static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
478 {
479 int ret, err;
480
481 ret = RAND_bytes(buf, num);
482 if (ret == 0)
483 {
484 err = ERR_peek_error();
485 if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
486 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
487 (void)ERR_get_error();
488 }
489 return (ret);
490 }
491
492int RAND_status(void)
493 {
494 if (!initialized)
495 ssleay_rand_initialize();
496 return (entropy >= ENTROPY_NEEDED);
335 } 497 }
336 498
337#ifdef WINDOWS 499#ifdef WINDOWS
@@ -358,12 +520,12 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
358 */ 520 */
359/* 521/*
360 * I have modified the loading of bytes via RAND_seed() mechanism since 522 * I have modified the loading of bytes via RAND_seed() mechanism since
361 * the origional would have been very very CPU intensive since RAND_seed() 523 * the original would have been very very CPU intensive since RAND_seed()
362 * does an MD5 per 16 bytes of input. The cost to digest 16 bytes is the same 524 * does an MD5 per 16 bytes of input. The cost to digest 16 bytes is the same
363 * as that to digest 56 bytes. So under the old system, a screen of 525 * as that to digest 56 bytes. So under the old system, a screen of
364 * 1024*768*256 would have been CPU cost of approximatly 49,000 56 byte MD5 526 * 1024*768*256 would have been CPU cost of approximately 49,000 56 byte MD5
365 * digests or digesting 2.7 mbytes. What I have put in place would 527 * digests or digesting 2.7 mbytes. What I have put in place would
366 * be 48 16k MD5 digests, or efectivly 48*16+48 MD5 bytes or 816 kbytes 528 * be 48 16k MD5 digests, or effectively 48*16+48 MD5 bytes or 816 kbytes
367 * or about 3.5 times as much. 529 * or about 3.5 times as much.
368 * - eric 530 * - eric
369 */ 531 */
diff --git a/src/lib/libcrypto/rand/md_rand_munged.c b/src/lib/libcrypto/rand/md_rand_munged.c
new file mode 100644
index 0000000000..1611bf335b
--- /dev/null
+++ b/src/lib/libcrypto/rand/md_rand_munged.c
@@ -0,0 +1,515 @@
1/* crypto/rand/md_rand.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <sys/types.h>
61#include <fcntl.h>
62#include <time.h>
63#include <string.h>
64
65#include "openssl/e_os.h"
66
67#include <openssl/crypto.h>
68
69#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
70#if !defined(NO_SHA) && !defined(NO_SHA1)
71#define USE_SHA1_RAND
72#elif !defined(NO_MD5)
73#define USE_MD5_RAND
74#elif !defined(NO_MDC2) && !defined(NO_DES)
75#define USE_MDC2_RAND
76#elif !defined(NO_MD2)
77#define USE_MD2_RAND
78#else
79#error No message digest algorithm available
80#endif
81#endif
82
83/* Changed how the state buffer used. I now attempt to 'wrap' such
84 * that I don't run over the same locations the next time go through
85 * the 1023 bytes - many thanks to
86 * Robert J. LeBlanc <rjl@renaissoft.com> for his comments
87 */
88
89#if defined(USE_MD5_RAND)
90#include <openssl/md5.h>
91#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
92#define MD_CTX MD5_CTX
93#define MD_Init(a) MD5_Init(a)
94#define MD_Update(a,b,c) MD5_Update(a,b,c)
95#define MD_Final(a,b) MD5_Final(a,b)
96#define MD(a,b,c) MD5(a,b,c)
97#elif defined(USE_SHA1_RAND)
98#include <openssl/sha.h>
99#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
100#define MD_CTX SHA_CTX
101#define MD_Init(a) SHA1_Init(a)
102#define MD_Update(a,b,c) SHA1_Update(a,b,c)
103#define MD_Final(a,b) SHA1_Final(a,b)
104#define MD(a,b,c) SHA1(a,b,c)
105#elif defined(USE_MDC2_RAND)
106#include <openssl/mdc2.h>
107#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
108#define MD_CTX MDC2_CTX
109#define MD_Init(a) MDC2_Init(a)
110#define MD_Update(a,b,c) MDC2_Update(a,b,c)
111#define MD_Final(a,b) MDC2_Final(a,b)
112#define MD(a,b,c) MDC2(a,b,c)
113#elif defined(USE_MD2_RAND)
114#include <openssl/md2.h>
115#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
116#define MD_CTX MD2_CTX
117#define MD_Init(a) MD2_Init(a)
118#define MD_Update(a,b,c) MD2_Update(a,b,c)
119#define MD_Final(a,b) MD2_Final(a,b)
120#define MD(a,b,c) MD2(a,b,c)
121#endif
122
123#include <openssl/rand.h>
124
125/* #define NORAND 1 */
126/* #define PREDICT 1 */
127
128#define STATE_SIZE 1023
129static int state_num=0,state_index=0;
130static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH];
131static unsigned char md[MD_DIGEST_LENGTH];
132static long md_count[2]={0,0};
133static double entropy=0;
134static int initialized=0;
135
136const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
137
138static void ssleay_rand_cleanup(void);
139static void ssleay_rand_seed(const void *buf, int num);
140static void ssleay_rand_add(const void *buf, int num, double add_entropy);
141static int ssleay_rand_bytes(unsigned char *buf, int num);
142static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
143
144RAND_METHOD rand_ssleay_meth={
145 ssleay_rand_seed,
146 ssleay_rand_bytes,
147 ssleay_rand_cleanup,
148 ssleay_rand_add,
149 ssleay_rand_pseudo_bytes,
150 };
151
152RAND_METHOD *RAND_SSLeay(void)
153 {
154 return(&rand_ssleay_meth);
155 }
156
157static void ssleay_rand_cleanup(void)
158 {
159 memset(state,0,sizeof(state));
160 state_num=0;
161 state_index=0;
162 memset(md,0,MD_DIGEST_LENGTH);
163 md_count[0]=0;
164 md_count[1]=0;
165 entropy=0;
166 }
167
168static void ssleay_rand_add(const void *buf, int num, double add)
169 {
170 int i,j,k,st_idx;
171 long md_c[2];
172 unsigned char local_md[MD_DIGEST_LENGTH];
173 MD_CTX m;
174
175#ifdef NORAND
176 return;
177#endif
178
179 /*
180 * (Based on the rand(3) manpage)
181 *
182 * The input is chopped up into units of 20 bytes (or less for
183 * the last block). Each of these blocks is run through the hash
184 * function as follows: The data passed to the hash function
185 * is the current 'md', the same number of bytes from the 'state'
186 * (the location determined by in incremented looping index) as
187 * the current 'block', the new key data 'block', and 'count'
188 * (which is incremented after each use).
189 * The result of this is kept in 'md' and also xored into the
190 * 'state' at the same locations that were used as input into the
191 * hash function.
192 */
193
194 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
195 st_idx=state_index;
196
197 /* use our own copies of the counters so that even
198 * if a concurrent thread seeds with exactly the
199 * same data and uses the same subarray there's _some_
200 * difference */
201 md_c[0] = md_count[0];
202 md_c[1] = md_count[1];
203
204 memcpy(local_md, md, sizeof md);
205
206 /* state_index <= state_num <= STATE_SIZE */
207 state_index += num;
208 if (state_index >= STATE_SIZE)
209 {
210 state_index%=STATE_SIZE;
211 state_num=STATE_SIZE;
212 }
213 else if (state_num < STATE_SIZE)
214 {
215 if (state_index > state_num)
216 state_num=state_index;
217 }
218 /* state_index <= state_num <= STATE_SIZE */
219
220 /* state[st_idx], ..., state[(st_idx + num - 1) % STATE_SIZE]
221 * are what we will use now, but other threads may use them
222 * as well */
223
224 md_count[1] += (num / MD_DIGEST_LENGTH) + (num % MD_DIGEST_LENGTH > 0);
225
226 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
227
228 for (i=0; i<num; i+=MD_DIGEST_LENGTH)
229 {
230 j=(num-i);
231 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j;
232
233 MD_Init(&m);
234 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
235 k=(st_idx+j)-STATE_SIZE;
236 if (k > 0)
237 {
238 MD_Update(&m,&(state[st_idx]),j-k);
239 MD_Update(&m,&(state[0]),k);
240 }
241 else
242 MD_Update(&m,&(state[st_idx]),j);
243
244 MD_Update(&m,buf,j);
245 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count));
246 MD_Final(md,&m);
247 md_count[1]++;
248
249 buf=(const char *)buf + j;
250
251 for (k=0; k<j; k++)
252 {
253 state[st_idx++]^=md[k];
254 if (st_idx >= STATE_SIZE)
255 {
256 st_idx=0;
257 st_num=STATE_SIZE;
258 }
259 }
260 }
261 memset((char *)&m,0,sizeof(m));
262 }
263
264static void ssleay_rand_bytes(unsigned char *buf, int num)
265 {
266 int i,j,k,st_num,st_idx;
267 MD_CTX m;
268 static int init=1;
269 unsigned long l;
270#ifdef DEVRANDOM
271 int fd;
272#endif
273
274#ifdef PREDICT
275 {
276 static unsigned char val=0;
277
278 for (i=0; i<num; i++)
279 buf[i]=val++;
280 return;
281 }
282#endif
283
284 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
285
286 if (init)
287 {
288 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
289 /* put in some default random data, we need more than
290 * just this */
291 RAND_seed(&m,sizeof(m));
292#ifndef MSDOS
293 l=getpid();
294 RAND_seed(&l,sizeof(l));
295 l=getuid();
296 RAND_seed(&l,sizeof(l));
297#endif
298 l=time(NULL);
299 RAND_seed(&l,sizeof(l));
300
301/* #ifdef DEVRANDOM */
302 /*
303 * Use a random entropy pool device.
304 * Linux 1.3.x, OpenBSD, and FreeBSD have
305 * this. Use /dev/urandom if you can
306 * as /dev/random will block if it runs out
307 * of random entries.
308 */
309 if ((fd = open(DEVRANDOM, O_RDONLY)) != NULL)
310 {
311 unsigned char tmpbuf[32];
312
313 read(fd, tmpbuf, sizeof(tmpbuf));
314 /* we don't care how many bytes we read,
315 * we will just copy the 'stack' if there is
316 * nothing else :-) */
317 /* the above comment is EVIL. Security software
318 * RELIES ON THESE PRIMITIVES HAVING MORE SECURE
319 * BEHAVIOUR! Secure entropy is required in
320 * many cases! */
321 RAND_seed(tmpbuf,32);
322 memset(tmpbuf,0,32);
323 }
324/* #endif */
325#ifdef PURIFY
326 memset(state,0,STATE_SIZE);
327 memset(md,0,MD_DIGEST_LENGTH);
328#endif
329 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
330 init=0;
331 }
332
333 st_idx=state_index;
334 st_num=state_num;
335 state_index+=num;
336 if (state_index > state_num)
337 state_index=(state_index%state_num);
338
339 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
340
341 while (num > 0)
342 {
343 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;
344 num-=j;
345 MD_Init(&m);
346#ifndef GETPID_IS_MEANINGLESS
347 if (curr_pid) /* just in the first iteration to save time */
348 {
349 MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid);
350 curr_pid = 0;
351 }
352#endif
353 MD_Update(&m,&(local_md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2);
354 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
355#ifndef PURIFY
356 MD_Update(&m,buf,j); /* purify complains */
357#endif
358 k=(st_idx+j)-st_num;
359 if (k > 0)
360 {
361 MD_Update(&m,&(state[st_idx]),j-k);
362 MD_Update(&m,&(state[0]),k);
363 }
364 else
365 MD_Update(&m,&(state[st_idx]),j);
366 MD_Final(local_md,&m);
367
368 for (i=0; i<j; i++)
369 {
370 state[st_idx++]^=local_md[i]; /* may compete with other threads */
371 *(buf++)=local_md[i+MD_DIGEST_LENGTH/2];
372 if (st_idx >= st_num)
373 st_idx=0;
374 }
375 }
376
377 MD_Init(&m);
378 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
379 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
380 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
381 MD_Update(&m,md,MD_DIGEST_LENGTH);
382 MD_Final(md,&m);
383 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
384
385 memset(&m,0,sizeof(m));
386 if (ok)
387 return(1);
388 else
389 {
390 RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
391 return(0);
392 }
393 }
394
395/* pseudo-random bytes that are guaranteed to be unique but not
396 unpredictable */
397static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
398 {
399 int ret, err;
400
401 ret = RAND_bytes(buf, num);
402 if (ret == 0)
403 {
404 err = ERR_peek_error();
405 if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
406 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
407 (void)ERR_get_error();
408 }
409 return (ret);
410 }
411
412int RAND_status(void)
413 {
414 if (!initialized)
415 ssleay_rand_initialize();
416 return (entropy >= ENTROPY_NEEDED);
417 }
418
419#ifdef WINDOWS
420#include <windows.h>
421#include <openssl/rand.h>
422
423/*****************************************************************************
424 * Initialisation function for the SSL random generator. Takes the contents
425 * of the screen as random seed.
426 *
427 * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V.
428 *
429 * Code adapted from
430 * <URL:http://www.microsoft.com/kb/developr/win_dk/q97193.htm>;
431 * the original copyright message is:
432 *
433 * (C) Copyright Microsoft Corp. 1993. All rights reserved.
434 *
435 * You have a royalty-free right to use, modify, reproduce and
436 * distribute the Sample Files (and/or any modified version) in
437 * any way you find useful, provided that you agree that
438 * Microsoft has no warranty obligations or liability for any
439 * Sample Application Files which are modified.
440 */
441/*
442 * I have modified the loading of bytes via RAND_seed() mechanism since
443 * the original would have been very very CPU intensive since RAND_seed()
444 * does an MD5 per 16 bytes of input. The cost to digest 16 bytes is the same
445 * as that to digest 56 bytes. So under the old system, a screen of
446 * 1024*768*256 would have been CPU cost of approximately 49,000 56 byte MD5
447 * digests or digesting 2.7 mbytes. What I have put in place would
448 * be 48 16k MD5 digests, or effectively 48*16+48 MD5 bytes or 816 kbytes
449 * or about 3.5 times as much.
450 * - eric
451 */
452void RAND_screen(void)
453{
454 HDC hScrDC; /* screen DC */
455 HDC hMemDC; /* memory DC */
456 HBITMAP hBitmap; /* handle for our bitmap */
457 HBITMAP hOldBitmap; /* handle for previous bitmap */
458 BITMAP bm; /* bitmap properties */
459 unsigned int size; /* size of bitmap */
460 char *bmbits; /* contents of bitmap */
461 int w; /* screen width */
462 int h; /* screen height */
463 int y; /* y-coordinate of screen lines to grab */
464 int n = 16; /* number of screen lines to grab at a time */
465
466 /* Create a screen DC and a memory DC compatible to screen DC */
467 hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
468 hMemDC = CreateCompatibleDC(hScrDC);
469
470 /* Get screen resolution */
471 w = GetDeviceCaps(hScrDC, HORZRES);
472 h = GetDeviceCaps(hScrDC, VERTRES);
473
474 /* Create a bitmap compatible with the screen DC */
475 hBitmap = CreateCompatibleBitmap(hScrDC, w, n);
476
477 /* Select new bitmap into memory DC */
478 hOldBitmap = SelectObject(hMemDC, hBitmap);
479
480 /* Get bitmap properties */
481 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
482 size = (unsigned int)bm.bmWidthBytes * bm.bmHeight * bm.bmPlanes;
483
484 bmbits = Malloc(size);
485 if (bmbits) {
486 /* Now go through the whole screen, repeatedly grabbing n lines */
487 for (y = 0; y < h-n; y += n)
488 {
489 unsigned char md[MD_DIGEST_LENGTH];
490
491 /* Bitblt screen DC to memory DC */
492 BitBlt(hMemDC, 0, 0, w, n, hScrDC, 0, y, SRCCOPY);
493
494 /* Copy bitmap bits from memory DC to bmbits */
495 GetBitmapBits(hBitmap, size, bmbits);
496
497 /* Get the MD5 of the bitmap */
498 MD(bmbits,size,md);
499
500 /* Seed the random generator with the MD5 digest */
501 RAND_seed(md, MD_DIGEST_LENGTH);
502 }
503
504 Free(bmbits);
505 }
506
507 /* Select old bitmap back into memory DC */
508 hBitmap = SelectObject(hMemDC, hOldBitmap);
509
510 /* Clean up */
511 DeleteObject(hBitmap);
512 DeleteDC(hMemDC);
513 DeleteDC(hScrDC);
514}
515#endif
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index fd8ee38366..28f45ec052 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -66,24 +66,45 @@ extern "C" {
66typedef struct rand_meth_st 66typedef struct rand_meth_st
67 { 67 {
68 void (*seed)(const void *buf, int num); 68 void (*seed)(const void *buf, int num);
69 void (*bytes)(unsigned char *buf, int num); 69 int (*bytes)(unsigned char *buf, int num);
70 void (*cleanup)(void); 70 void (*cleanup)(void);
71 void (*add)(const void *buf, int num, double entropy);
72 int (*pseudorand)(unsigned char *buf, int num);
71 } RAND_METHOD; 73 } RAND_METHOD;
72 74
73void RAND_set_rand_method(RAND_METHOD *meth); 75void RAND_set_rand_method(RAND_METHOD *meth);
74RAND_METHOD *RAND_get_rand_method(void ); 76RAND_METHOD *RAND_get_rand_method(void );
75RAND_METHOD *RAND_SSLeay(void); 77RAND_METHOD *RAND_SSLeay(void);
76void RAND_cleanup(void ); 78void RAND_cleanup(void );
77void RAND_bytes(unsigned char *buf,int num); 79int RAND_bytes(unsigned char *buf,int num);
80int RAND_pseudo_bytes(unsigned char *buf,int num);
78void RAND_seed(const void *buf,int num); 81void RAND_seed(const void *buf,int num);
82void RAND_add(const void *buf,int num,double entropy);
79int RAND_load_file(const char *file,long max_bytes); 83int RAND_load_file(const char *file,long max_bytes);
80int RAND_write_file(const char *file); 84int RAND_write_file(const char *file);
81char *RAND_file_name(char *file,int num); 85const char *RAND_file_name(char *file,int num);
86int RAND_status(void);
87int RAND_egd(const char *path);
82#ifdef WINDOWS 88#ifdef WINDOWS
83void RAND_screen(void); 89void RAND_screen(void);
84#endif 90#endif
91void ERR_load_RAND_strings(void);
92
93/* BEGIN ERROR CODES */
94/* The following lines are auto generated by the script mkerr.pl. Any changes
95 * made after this point may be overwritten when the script is next run.
96 */
97
98/* Error codes for the RAND functions. */
99
100/* Function codes. */
101#define RAND_F_SSLEAY_RAND_BYTES 100
102
103/* Reason codes. */
104#define RAND_R_PRNG_NOT_SEEDED 100
105
85#ifdef __cplusplus 106#ifdef __cplusplus
86} 107}
87#endif 108#endif
88
89#endif 109#endif
110
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c
new file mode 100644
index 0000000000..d834408bd4
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_egd.c
@@ -0,0 +1,110 @@
1/* crypto/rand/rand_egd.c */
2/* Written by Ulf Moeller for the OpenSSL project. */
3/* ====================================================================
4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
22 *
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * openssl-core@openssl.org.
27 *
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
31 *
32 * 6. Redistributions of any form whatsoever must retain the following
33 * acknowledgment:
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This product includes cryptographic software written by Eric Young
52 * (eay@cryptsoft.com). This product includes software written by Tim
53 * Hudson (tjh@cryptsoft.com).
54 *
55 */
56
57#include <openssl/rand.h>
58
59/* Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
60 */
61
62#if defined(WIN32) || defined(VMS) || defined(__VMS)
63int RAND_egd(const char *path)
64 {
65 return(-1);
66 }
67#else
68#include <openssl/opensslconf.h>
69#include OPENSSL_UNISTD
70#include <sys/types.h>
71#include <sys/socket.h>
72#include <sys/un.h>
73#include <string.h>
74
75#ifndef offsetof
76# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
77#endif
78
79int RAND_egd(const char *path)
80 {
81 int ret = -1;
82 struct sockaddr_un addr;
83 int len, num;
84 int fd = -1;
85 unsigned char buf[256];
86
87 memset(&addr, 0, sizeof(addr));
88 addr.sun_family = AF_UNIX;
89 if (strlen(path) > sizeof(addr.sun_path))
90 return (-1);
91 strcpy(addr.sun_path,path);
92 len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
93 fd = socket(AF_UNIX, SOCK_STREAM, 0);
94 if (fd == -1) return (-1);
95 if (connect(fd, (struct sockaddr *)&addr, len) == -1) goto err;
96 buf[0] = 1;
97 buf[1] = 255;
98 write(fd, buf, 2);
99 if (read(fd, buf, 1) != 1) goto err;
100 if (buf[0] == 0) goto err;
101 num = read(fd, buf, 255);
102 if (num < 1) goto err;
103 RAND_seed(buf, num);
104 if (RAND_status() == 1)
105 ret = num;
106 err:
107 if (fd != -1) close(fd);
108 return(ret);
109 }
110#endif
diff --git a/src/lib/libcrypto/rand/rand_err.c b/src/lib/libcrypto/rand/rand_err.c
new file mode 100644
index 0000000000..d1263edf80
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_err.c
@@ -0,0 +1,93 @@
1/* crypto/rand/rand_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 */
59
60#include <stdio.h>
61#include <openssl/err.h>
62#include <openssl/rand.h>
63
64/* BEGIN ERROR CODES */
65#ifndef NO_ERR
66static ERR_STRING_DATA RAND_str_functs[]=
67 {
68{ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"},
69{0,NULL}
70 };
71
72static ERR_STRING_DATA RAND_str_reasons[]=
73 {
74{RAND_R_PRNG_NOT_SEEDED ,"prng not seeded"},
75{0,NULL}
76 };
77
78#endif
79
80void ERR_load_RAND_strings(void)
81 {
82 static int init=1;
83
84 if (init)
85 {
86 init=0;
87#ifndef NO_ERR
88 ERR_load_strings(ERR_LIB_RAND,RAND_str_functs);
89 ERR_load_strings(ERR_LIB_RAND,RAND_str_reasons);
90#endif
91
92 }
93 }
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index 34c6d5b968..b09a300c46 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -57,7 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <time.h> 60#include <time.h>
62#include <openssl/rand.h> 61#include <openssl/rand.h>
63 62
@@ -90,9 +89,22 @@ void RAND_seed(const void *buf, int num)
90 rand_meth->seed(buf,num); 89 rand_meth->seed(buf,num);
91 } 90 }
92 91
93void RAND_bytes(unsigned char *buf, int num) 92void RAND_add(const void *buf, int num, double entropy)
94 { 93 {
95 if (rand_meth != NULL) 94 if (rand_meth != NULL)
96 rand_meth->bytes(buf,num); 95 rand_meth->add(buf,num,entropy);
97 } 96 }
98 97
98int RAND_bytes(unsigned char *buf, int num)
99 {
100 if (rand_meth != NULL)
101 return rand_meth->bytes(buf,num);
102 return(-1);
103 }
104
105int RAND_pseudo_bytes(unsigned char *buf, int num)
106 {
107 if (rand_meth != NULL)
108 return rand_meth->pseudorand(buf,num);
109 return(-1);
110 }
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 6829d4ec37..658a8d6b65 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -60,22 +60,35 @@
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#include <sys/types.h>
64#include <sys/stat.h>
65#include <sys/types.h>
66 63
67#include "openssl/e_os.h" 64#include "openssl/e_os.h"
68 65
66#ifdef VMS
67#include <unixio.h>
68#endif
69#ifndef NO_SYS_TYPES_H
70# include <sys/types.h>
71#endif
72#ifdef MAC_OS_pre_X
73# include <stat.h>
74#else
75# include <sys/stat.h>
76#endif
77
78#include <openssl/crypto.h>
69#include <openssl/rand.h> 79#include <openssl/rand.h>
70 80
71#undef BUFSIZE 81#undef BUFSIZE
72#define BUFSIZE 1024 82#define BUFSIZE 1024
73#define RAND_DATA 1024 83#define RAND_DATA 1024
74 84
75/* #define RFILE ".rand" - defined in ../../e_os.h */ 85/* #define RFILE ".rnd" - defined in ../../e_os.h */
76 86
77int RAND_load_file(const char *file, long bytes) 87int RAND_load_file(const char *file, long bytes)
78 { 88 {
89 /* If bytes >= 0, read up to 'bytes' bytes.
90 * if bytes == -1, read complete file. */
91
79 MS_STATIC unsigned char buf[BUFSIZE]; 92 MS_STATIC unsigned char buf[BUFSIZE];
80 struct stat sb; 93 struct stat sb;
81 int i,ret=0,n; 94 int i,ret=0,n;
@@ -85,23 +98,28 @@ int RAND_load_file(const char *file, long bytes)
85 98
86 i=stat(file,&sb); 99 i=stat(file,&sb);
87 /* If the state fails, put some crap in anyway */ 100 /* If the state fails, put some crap in anyway */
88 RAND_seed(&sb,sizeof(sb)); 101 RAND_add(&sb,sizeof(sb),0);
89 ret+=sizeof(sb);
90 if (i < 0) return(0); 102 if (i < 0) return(0);
91 if (bytes <= 0) return(ret); 103 if (bytes == 0) return(ret);
92 104
93 in=fopen(file,"rb"); 105 in=fopen(file,"rb");
94 if (in == NULL) goto err; 106 if (in == NULL) goto err;
95 for (;;) 107 for (;;)
96 { 108 {
97 n=(bytes < BUFSIZE)?(int)bytes:BUFSIZE; 109 if (bytes > 0)
110 n = (bytes < BUFSIZE)?(int)bytes:BUFSIZE;
111 else
112 n = BUFSIZE;
98 i=fread(buf,1,n,in); 113 i=fread(buf,1,n,in);
99 if (i <= 0) break; 114 if (i <= 0) break;
100 /* even if n != i, use the full array */ 115 /* even if n != i, use the full array */
101 RAND_seed(buf,n); 116 RAND_add(buf,n,i);
102 ret+=i; 117 ret+=i;
103 bytes-=n; 118 if (bytes > 0)
104 if (bytes <= 0) break; 119 {
120 bytes-=n;
121 if (bytes == 0) break;
122 }
105 } 123 }
106 fclose(in); 124 fclose(in);
107 memset(buf,0,BUFSIZE); 125 memset(buf,0,BUFSIZE);
@@ -112,29 +130,48 @@ err:
112int RAND_write_file(const char *file) 130int RAND_write_file(const char *file)
113 { 131 {
114 unsigned char buf[BUFSIZE]; 132 unsigned char buf[BUFSIZE];
115 int i,ret=0; 133 int i,ret=0,err=0;
116 FILE *out; 134 FILE *out = NULL;
117 int n; 135 int n;
118 136
119 /* Under VMS, fopen(file, "wb") will craete a new version of the 137#ifdef VMS
138 /* Under VMS, fopen(file, "wb") will create a new version of the
120 same file. This is not good, so let's try updating an existing 139 same file. This is not good, so let's try updating an existing
121 one, and create file only if it doesn't already exist. This 140 one, and create file only if it doesn't already exist. */
122 should be completely harmless on system that have no file 141 /* At the same time, if we just update a file, we also need to
123 versions. -- Richard Levitte */ 142 truncate it, and unfortunately, ftruncate() and truncate() do
143 not exist everywhere. All that remains is to delete old versions
144 of the random data file (done at the end). */
145#if 0
124 out=fopen(file,"rb+"); 146 out=fopen(file,"rb+");
125 if (out == NULL && errno == ENOENT) 147 if (out == NULL && errno != ENOENT)
148 goto err;
149#endif
150#endif
151
152 if (out == NULL)
126 { 153 {
127 errno = 0; 154#if defined O_CREAT && defined O_EXCL
155 /* chmod(..., 0600) is too late to protect the file,
156 * permissions should be restrictive from the start */
157 int fd = open(file, O_CREAT | O_EXCL, 0600);
158 if (fd != -1)
159 out = fdopen(fd, "wb");
160#else
128 out=fopen(file,"wb"); 161 out=fopen(file,"wb");
162#endif
129 } 163 }
130 if (out == NULL) goto err; 164 if (out == NULL) goto err;
165#ifndef NO_CHMOD
131 chmod(file,0600); 166 chmod(file,0600);
167#endif
132 n=RAND_DATA; 168 n=RAND_DATA;
133 for (;;) 169 for (;;)
134 { 170 {
135 i=(n > BUFSIZE)?BUFSIZE:n; 171 i=(n > BUFSIZE)?BUFSIZE:n;
136 n-=BUFSIZE; 172 n-=BUFSIZE;
137 RAND_bytes(buf,i); 173 if (RAND_bytes(buf,i) <= 0)
174 err=1;
138 i=fwrite(buf,1,i,out); 175 i=fwrite(buf,1,i,out);
139 if (i <= 0) 176 if (i <= 0)
140 { 177 {
@@ -144,13 +181,40 @@ int RAND_write_file(const char *file)
144 ret+=i; 181 ret+=i;
145 if (n <= 0) break; 182 if (n <= 0) break;
146 } 183 }
184#ifdef VMS
185 /* We may have updated an existing file using mode "rb+",
186 * now remove any old extra bytes */
187#if 0
188 if (ret > 0)
189 ftruncate(fileno(out), ret);
190#else
191 /* Try to delete older versions of the file, until there aren't
192 any */
193 {
194 char *tmpf;
195
196 tmpf = Malloc(strlen(file) + 4); /* to add ";-1" and a nul */
197 if (tmpf)
198 {
199 strcpy(tmpf, file);
200 strcat(tmpf, ";-1");
201 while(delete(tmpf) == 0)
202 ;
203 rename(file,";1"); /* Make sure it's version 1, or we
204 will reach the limit (32767) at
205 some point... */
206 }
207 }
208#endif
209#endif
210
147 fclose(out); 211 fclose(out);
148 memset(buf,0,BUFSIZE); 212 memset(buf,0,BUFSIZE);
149err: 213err:
150 return(ret); 214 return(err ? -1 : ret);
151 } 215 }
152 216
153char *RAND_file_name(char *buf, int size) 217const char *RAND_file_name(char *buf, int size)
154 { 218 {
155 char *s; 219 char *s;
156 char *ret=NULL; 220 char *ret=NULL;
diff --git a/src/lib/libcrypto/rand/randtest.c b/src/lib/libcrypto/rand/randtest.c
index f0706d779a..da96e3f695 100644
--- a/src/lib/libcrypto/rand/randtest.c
+++ b/src/lib/libcrypto/rand/randtest.c
@@ -73,7 +73,7 @@ int main()
73 /*double d; */ 73 /*double d; */
74 long d; 74 long d;
75 75
76 RAND_bytes(buf,2500); 76 RAND_pseudo_bytes(buf,2500);
77 77
78 n1=0; 78 n1=0;
79 for (i=0; i<16; i++) n2[i]=0; 79 for (i=0; i<16; i++) n2[i]=0;
diff --git a/src/lib/libcrypto/rc2/rc2speed.c b/src/lib/libcrypto/rc2/rc2speed.c
index c3da63e77e..9f7f5ccfa3 100644
--- a/src/lib/libcrypto/rc2/rc2speed.c
+++ b/src/lib/libcrypto/rc2/rc2speed.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libcrypto/rc2/rc2test.c b/src/lib/libcrypto/rc2/rc2test.c
index 6a5defa6ea..521269ded1 100644
--- a/src/lib/libcrypto/rc2/rc2test.c
+++ b/src/lib/libcrypto/rc2/rc2test.c
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
72#else 72#else
73#include <openssl/rc2.h> 73#include <openssl/rc2.h>
74 74
75unsigned char RC2key[4][16]={ 75static unsigned char RC2key[4][16]={
76 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 76 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -83,14 +83,14 @@ unsigned char RC2key[4][16]={
83 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F}, 83 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F},
84 }; 84 };
85 85
86unsigned char RC2plain[4][8]={ 86static unsigned char RC2plain[4][8]={
87 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 87 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
88 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 88 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
89 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, 89 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
90 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 90 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
91 }; 91 };
92 92
93unsigned char RC2cipher[4][8]={ 93static unsigned char RC2cipher[4][8]={
94 {0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7}, 94 {0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7},
95 {0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74}, 95 {0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74},
96 {0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E}, 96 {0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E},
diff --git a/src/lib/libcrypto/rc4/rc4.h b/src/lib/libcrypto/rc4/rc4.h
index 7418c2a9a2..8556dddab0 100644
--- a/src/lib/libcrypto/rc4/rc4.h
+++ b/src/lib/libcrypto/rc4/rc4.h
@@ -77,8 +77,8 @@ typedef struct rc4_key_st
77 77
78 78
79const char *RC4_options(void); 79const char *RC4_options(void);
80void RC4_set_key(RC4_KEY *key, int len, unsigned char *data); 80void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
81void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, 81void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
82 unsigned char *outdata); 82 unsigned char *outdata);
83 83
84#ifdef __cplusplus 84#ifdef __cplusplus
diff --git a/src/lib/libcrypto/rc4/rc4_enc.c b/src/lib/libcrypto/rc4/rc4_enc.c
index 3256bea8cc..d5f18a3a70 100644
--- a/src/lib/libcrypto/rc4/rc4_enc.c
+++ b/src/lib/libcrypto/rc4/rc4_enc.c
@@ -67,7 +67,7 @@
67 * Date: Wed, 14 Sep 1994 06:35:31 GMT 67 * Date: Wed, 14 Sep 1994 06:35:31 GMT
68 */ 68 */
69 69
70void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, 70void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
71 unsigned char *outdata) 71 unsigned char *outdata)
72 { 72 {
73 register RC4_INT *d; 73 register RC4_INT *d;
@@ -78,6 +78,190 @@ void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata,
78 y=key->y; 78 y=key->y;
79 d=key->data; 79 d=key->data;
80 80
81#if defined(RC4_CHUNK)
82 /*
83 * The original reason for implementing this(*) was the fact that
84 * pre-21164a Alpha CPUs don't have byte load/store instructions
85 * and e.g. a byte store has to be done with 64-bit load, shift,
86 * and, or and finally 64-bit store. Peaking data and operating
87 * at natural word size made it possible to reduce amount of
88 * instructions as well as to perform early read-ahead without
89 * suffering from RAW (read-after-write) hazard. This resulted
90 * in ~40%(**) performance improvement on 21064 box with gcc.
91 * But it's not only Alpha users who win here:-) Thanks to the
92 * early-n-wide read-ahead this implementation also exhibits
93 * >40% speed-up on SPARC and 20-30% on 64-bit MIPS (depending
94 * on sizeof(RC4_INT)).
95 *
96 * (*) "this" means code which recognizes the case when input
97 * and output pointers appear to be aligned at natural CPU
98 * word boundary
99 * (**) i.e. according to 'apps/openssl speed rc4' benchmark,
100 * crypto/rc4/rc4speed.c exhibits almost 70% speed-up...
101 *
102 * Cavets.
103 *
104 * - RC4_CHUNK="unsigned long long" should be a #1 choice for
105 * UltraSPARC. Unfortunately gcc generates very slow code
106 * (2.5-3 times slower than one generated by Sun's WorkShop
107 * C) and therefore gcc (at least 2.95 and earlier) should
108 * always be told that RC4_CHUNK="unsigned long".
109 *
110 * <appro@fy.chalmers.se>
111 */
112
113# define RC4_STEP ( \
114 x=(x+1) &0xff, \
115 tx=d[x], \
116 y=(tx+y)&0xff, \
117 ty=d[y], \
118 d[y]=tx, \
119 d[x]=ty, \
120 (RC4_CHUNK)d[(tx+ty)&0xff]\
121 )
122
123 if ( ( ((unsigned long)indata & (sizeof(RC4_CHUNK)-1)) |
124 ((unsigned long)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 )
125 {
126 RC4_CHUNK ichunk,otp;
127 const union { long one; char little; } is_endian = {1};
128
129 /*
130 * I reckon we can afford to implement both endian
131 * cases and to decide which way to take at run-time
132 * because the machine code appears to be very compact
133 * and redundant 1-2KB is perfectly tolerable (i.e.
134 * in case the compiler fails to eliminate it:-). By
135 * suggestion from Terrel Larson <terr@terralogic.net>
136 * who also stands for the is_endian union:-)
137 *
138 * Special notes.
139 *
140 * - is_endian is declared automatic as doing otherwise
141 * (declaring static) prevents gcc from eliminating
142 * the redundant code;
143 * - compilers (those I've tried) don't seem to have
144 * problems eliminating either the operators guarded
145 * by "if (sizeof(RC4_CHUNK)==8)" or the condition
146 * expressions themselves so I've got 'em to replace
147 * corresponding #ifdefs from the previous version;
148 * - I chose to let the redundant switch cases when
149 * sizeof(RC4_CHUNK)!=8 be (were also #ifdefed
150 * before);
151 * - in case you wonder "&(sizeof(RC4_CHUNK)*8-1)" in
152 * [LB]ESHFT guards against "shift is out of range"
153 * warnings when sizeof(RC4_CHUNK)!=8
154 *
155 * <appro@fy.chalmers.se>
156 */
157 if (!is_endian.little)
158 { /* BIG-ENDIAN CASE */
159# define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1))
160 for (;len&-sizeof(RC4_CHUNK);len-=sizeof(RC4_CHUNK))
161 {
162 ichunk = *(RC4_CHUNK *)indata;
163 otp = RC4_STEP<<BESHFT(0);
164 otp |= RC4_STEP<<BESHFT(1);
165 otp |= RC4_STEP<<BESHFT(2);
166 otp |= RC4_STEP<<BESHFT(3);
167 if (sizeof(RC4_CHUNK)==8)
168 {
169 otp |= RC4_STEP<<BESHFT(4);
170 otp |= RC4_STEP<<BESHFT(5);
171 otp |= RC4_STEP<<BESHFT(6);
172 otp |= RC4_STEP<<BESHFT(7);
173 }
174 *(RC4_CHUNK *)outdata = otp^ichunk;
175 indata += sizeof(RC4_CHUNK);
176 outdata += sizeof(RC4_CHUNK);
177 }
178 if (len)
179 {
180 RC4_CHUNK mask=(RC4_CHUNK)-1, ochunk;
181
182 ichunk = *(RC4_CHUNK *)indata;
183 ochunk = *(RC4_CHUNK *)outdata;
184 otp = 0;
185 i = BESHFT(0);
186 mask <<= (sizeof(RC4_CHUNK)-len)<<3;
187 switch (len&(sizeof(RC4_CHUNK)-1))
188 {
189 case 7: otp = RC4_STEP<<i, i-=8;
190 case 6: otp |= RC4_STEP<<i, i-=8;
191 case 5: otp |= RC4_STEP<<i, i-=8;
192 case 4: otp |= RC4_STEP<<i, i-=8;
193 case 3: otp |= RC4_STEP<<i, i-=8;
194 case 2: otp |= RC4_STEP<<i, i-=8;
195 case 1: otp |= RC4_STEP<<i, i-=8;
196 case 0: ; /*
197 * it's never the case,
198 * but it has to be here
199 * for ultrix?
200 */
201 }
202 ochunk &= ~mask;
203 ochunk |= (otp^ichunk) & mask;
204 *(RC4_CHUNK *)outdata = ochunk;
205 }
206 key->x=x;
207 key->y=y;
208 return;
209 }
210 else
211 { /* LITTLE-ENDIAN CASE */
212# define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1))
213 for (;len&-sizeof(RC4_CHUNK);len-=sizeof(RC4_CHUNK))
214 {
215 ichunk = *(RC4_CHUNK *)indata;
216 otp = RC4_STEP;
217 otp |= RC4_STEP<<8;
218 otp |= RC4_STEP<<16;
219 otp |= RC4_STEP<<24;
220 if (sizeof(RC4_CHUNK)==8)
221 {
222 otp |= RC4_STEP<<LESHFT(4);
223 otp |= RC4_STEP<<LESHFT(5);
224 otp |= RC4_STEP<<LESHFT(6);
225 otp |= RC4_STEP<<LESHFT(7);
226 }
227 *(RC4_CHUNK *)outdata = otp^ichunk;
228 indata += sizeof(RC4_CHUNK);
229 outdata += sizeof(RC4_CHUNK);
230 }
231 if (len)
232 {
233 RC4_CHUNK mask=(RC4_CHUNK)-1, ochunk;
234
235 ichunk = *(RC4_CHUNK *)indata;
236 ochunk = *(RC4_CHUNK *)outdata;
237 otp = 0;
238 i = 0;
239 mask >>= (sizeof(RC4_CHUNK)-len)<<3;
240 switch (len&(sizeof(RC4_CHUNK)-1))
241 {
242 case 7: otp = RC4_STEP, i+=8;
243 case 6: otp |= RC4_STEP<<i, i+=8;
244 case 5: otp |= RC4_STEP<<i, i+=8;
245 case 4: otp |= RC4_STEP<<i, i+=8;
246 case 3: otp |= RC4_STEP<<i, i+=8;
247 case 2: otp |= RC4_STEP<<i, i+=8;
248 case 1: otp |= RC4_STEP<<i, i+=8;
249 case 0: ; /*
250 * it's never the case,
251 * but it has to be here
252 * for ultrix?
253 */
254 }
255 ochunk &= ~mask;
256 ochunk |= (otp^ichunk) & mask;
257 *(RC4_CHUNK *)outdata = ochunk;
258 }
259 key->x=x;
260 key->y=y;
261 return;
262 }
263 }
264#endif
81#define LOOP(in,out) \ 265#define LOOP(in,out) \
82 x=((x+1)&0xff); \ 266 x=((x+1)&0xff); \
83 tx=d[x]; \ 267 tx=d[x]; \
diff --git a/src/lib/libcrypto/rc4/rc4_skey.c b/src/lib/libcrypto/rc4/rc4_skey.c
index c67a445f1f..bb10c1ebe2 100644
--- a/src/lib/libcrypto/rc4/rc4_skey.c
+++ b/src/lib/libcrypto/rc4/rc4_skey.c
@@ -85,7 +85,7 @@ const char *RC4_options(void)
85 * Date: Wed, 14 Sep 1994 06:35:31 GMT 85 * Date: Wed, 14 Sep 1994 06:35:31 GMT
86 */ 86 */
87 87
88void RC4_set_key(RC4_KEY *key, int len, register unsigned char *data) 88void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
89 { 89 {
90 register RC4_INT tmp; 90 register RC4_INT tmp;
91 register int id1,id2; 91 register int id1,id2;
diff --git a/src/lib/libcrypto/rc4/rc4speed.c b/src/lib/libcrypto/rc4/rc4speed.c
index 4fb5ebf573..b448f4a5c6 100644
--- a/src/lib/libcrypto/rc4/rc4speed.c
+++ b/src/lib/libcrypto/rc4/rc4speed.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libcrypto/rc4/rc4test.c b/src/lib/libcrypto/rc4/rc4test.c
index 5abf8cff30..3914eb6c38 100644
--- a/src/lib/libcrypto/rc4/rc4test.c
+++ b/src/lib/libcrypto/rc4/rc4test.c
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
69#else 69#else
70#include <openssl/rc4.h> 70#include <openssl/rc4.h>
71 71
72unsigned char keys[7][30]={ 72static unsigned char keys[7][30]={
73 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, 73 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
74 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, 74 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
75 {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 75 {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
@@ -78,8 +78,8 @@ unsigned char keys[7][30]={
78 {4,0xef,0x01,0x23,0x45}, 78 {4,0xef,0x01,0x23,0x45},
79 }; 79 };
80 80
81unsigned char data_len[7]={8,8,8,20,28,10}; 81static unsigned char data_len[7]={8,8,8,20,28,10};
82unsigned char data[7][30]={ 82static unsigned char data[7][30]={
83 {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff}, 83 {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff},
84 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, 84 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
85 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, 85 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
@@ -94,7 +94,7 @@ unsigned char data[7][30]={
94 {0}, 94 {0},
95 }; 95 };
96 96
97unsigned char output[7][30]={ 97static unsigned char output[7][30]={
98 {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00}, 98 {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00},
99 {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00}, 99 {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00},
100 {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00}, 100 {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00},
diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl
index 5b6d1d2599..c6153d4361 100644
--- a/src/lib/libcrypto/ripemd/Makefile.ssl
+++ b/src/lib/libcrypto/ripemd/Makefile.ssl
@@ -102,6 +102,7 @@ clean:
102 102
103# DO NOT DELETE THIS LINE -- make depend depends on it. 103# DO NOT DELETE THIS LINE -- make depend depends on it.
104 104
105rmd_dgst.o: ../../include/openssl/opensslconf.h
105rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h 106rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
106rmd_dgst.o: rmd_locl.h rmdconst.h 107rmd_dgst.o: ../md32_common.h rmd_locl.h rmdconst.h
107rmd_one.o: ../../include/openssl/ripemd.h rmd_locl.h rmdconst.h 108rmd_one.o: ../../include/openssl/ripemd.h
diff --git a/src/lib/libcrypto/ripemd/asm/rips.cpp b/src/lib/libcrypto/ripemd/asm/rips.cpp
index 321a98443e..f7a13677a9 100644
--- a/src/lib/libcrypto/ripemd/asm/rips.cpp
+++ b/src/lib/libcrypto/ripemd/asm/rips.cpp
@@ -34,6 +34,8 @@ void GetTSC(unsigned long& tsc)
34#include <stdlib.h> 34#include <stdlib.h>
35#include <openssl/ripemd.h> 35#include <openssl/ripemd.h>
36 36
37#define ripemd160_block_x86 ripemd160_block_asm_host_order
38
37extern "C" { 39extern "C" {
38void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num); 40void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num);
39} 41}
@@ -55,8 +57,10 @@ void main(int argc,char *argv[])
55 if (num == 0) num=16; 57 if (num == 0) num=16;
56 if (num > 250) num=16; 58 if (num > 250) num=16;
57 numm=num+2; 59 numm=num+2;
60#if 0
58 num*=64; 61 num*=64;
59 numm*=64; 62 numm*=64;
63#endif
60 64
61 for (j=0; j<6; j++) 65 for (j=0; j<6; j++)
62 { 66 {
@@ -71,7 +75,7 @@ void main(int argc,char *argv[])
71 GetTSC(e2); 75 GetTSC(e2);
72 ripemd160_block_x86(&ctx,buffer,num); 76 ripemd160_block_x86(&ctx,buffer,num);
73 } 77 }
74 printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num, 78 printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num*64,
75 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
76 } 80 }
77 } 81 }
diff --git a/src/lib/libcrypto/ripemd/asm/rm-win32.asm b/src/lib/libcrypto/ripemd/asm/rm-win32.asm
index bd38791c13..f07d517857 100644
--- a/src/lib/libcrypto/ripemd/asm/rm-win32.asm
+++ b/src/lib/libcrypto/ripemd/asm/rm-win32.asm
@@ -8,1965 +8,1966 @@
8 .386 8 .386
9.model FLAT 9.model FLAT
10_TEXT SEGMENT 10_TEXT SEGMENT
11PUBLIC _ripemd160_block_x86 11PUBLIC _ripemd160_block_asm_host_order
12 12
13_ripemd160_block_x86 PROC NEAR 13_ripemd160_block_asm_host_order PROC NEAR
14 mov edx, DWORD PTR 4[esp]
15 mov eax, DWORD PTR 8[esp]
14 push esi 16 push esi
15 mov ecx, DWORD PTR 16[esp] 17 mov ecx, DWORD PTR [edx]
16 push edi 18 push edi
17 mov esi, DWORD PTR 16[esp] 19 mov esi, DWORD PTR 4[edx]
18 push ebp 20 push ebp
19 add ecx, esi 21 mov edi, DWORD PTR 8[edx]
20 push ebx 22 push ebx
21 sub ecx, 64 23 sub esp, 108
22 sub esp, 88
23 mov DWORD PTR [esp],ecx
24 mov edi, DWORD PTR 108[esp]
25L000start: 24L000start:
26 ; 25 ;
27 mov eax, DWORD PTR [esi] 26 mov ebx, DWORD PTR [eax]
28 mov ebx, DWORD PTR 4[esi] 27 mov ebp, DWORD PTR 4[eax]
29 mov DWORD PTR 4[esp],eax 28 mov DWORD PTR [esp],ebx
29 mov DWORD PTR 4[esp],ebp
30 mov ebx, DWORD PTR 8[eax]
31 mov ebp, DWORD PTR 12[eax]
30 mov DWORD PTR 8[esp],ebx 32 mov DWORD PTR 8[esp],ebx
31 mov eax, DWORD PTR 8[esi] 33 mov DWORD PTR 12[esp],ebp
32 mov ebx, DWORD PTR 12[esi] 34 mov ebx, DWORD PTR 16[eax]
33 mov DWORD PTR 12[esp],eax 35 mov ebp, DWORD PTR 20[eax]
34 mov DWORD PTR 16[esp],ebx 36 mov DWORD PTR 16[esp],ebx
35 mov eax, DWORD PTR 16[esi] 37 mov DWORD PTR 20[esp],ebp
36 mov ebx, DWORD PTR 20[esi] 38 mov ebx, DWORD PTR 24[eax]
37 mov DWORD PTR 20[esp],eax 39 mov ebp, DWORD PTR 28[eax]
38 mov DWORD PTR 24[esp],ebx 40 mov DWORD PTR 24[esp],ebx
39 mov eax, DWORD PTR 24[esi] 41 mov DWORD PTR 28[esp],ebp
40 mov ebx, DWORD PTR 28[esi] 42 mov ebx, DWORD PTR 32[eax]
41 mov DWORD PTR 28[esp],eax 43 mov ebp, DWORD PTR 36[eax]
42 mov DWORD PTR 32[esp],ebx 44 mov DWORD PTR 32[esp],ebx
43 mov eax, DWORD PTR 32[esi] 45 mov DWORD PTR 36[esp],ebp
44 mov ebx, DWORD PTR 36[esi] 46 mov ebx, DWORD PTR 40[eax]
45 mov DWORD PTR 36[esp],eax 47 mov ebp, DWORD PTR 44[eax]
46 mov DWORD PTR 40[esp],ebx 48 mov DWORD PTR 40[esp],ebx
47 mov eax, DWORD PTR 40[esi] 49 mov DWORD PTR 44[esp],ebp
48 mov ebx, DWORD PTR 44[esi] 50 mov ebx, DWORD PTR 48[eax]
49 mov DWORD PTR 44[esp],eax 51 mov ebp, DWORD PTR 52[eax]
50 mov DWORD PTR 48[esp],ebx 52 mov DWORD PTR 48[esp],ebx
51 mov eax, DWORD PTR 48[esi] 53 mov DWORD PTR 52[esp],ebp
52 mov ebx, DWORD PTR 52[esi] 54 mov ebx, DWORD PTR 56[eax]
53 mov DWORD PTR 52[esp],eax 55 mov ebp, DWORD PTR 60[eax]
54 mov DWORD PTR 56[esp],ebx 56 mov DWORD PTR 56[esp],ebx
55 mov eax, DWORD PTR 56[esi] 57 mov DWORD PTR 60[esp],ebp
56 mov ebx, DWORD PTR 60[esi] 58 mov eax, edi
57 mov DWORD PTR 60[esp],eax 59 mov ebx, DWORD PTR 12[edx]
58 mov DWORD PTR 64[esp],ebx 60 mov ebp, DWORD PTR 16[edx]
59 add esi, 64
60 mov eax, DWORD PTR [edi]
61 mov DWORD PTR 112[esp],esi
62 mov ebx, DWORD PTR 4[edi]
63 mov ecx, DWORD PTR 8[edi]
64 mov edx, DWORD PTR 12[edi]
65 mov ebp, DWORD PTR 16[edi]
66 ; 0 61 ; 0
67 mov esi, ecx 62 xor eax, ebx
68 xor esi, edx 63 mov edx, DWORD PTR [esp]
69 mov edi, DWORD PTR 4[esp] 64 xor eax, esi
70 xor esi, ebx 65 add ecx, edx
71 add eax, edi 66 rol edi, 10
72 rol ecx, 10 67 add ecx, eax
73 add eax, esi 68 mov eax, esi
74 mov esi, ebx 69 rol ecx, 11
75 rol eax, 11 70 add ecx, ebp
76 add eax, ebp
77 ; 1 71 ; 1
78 xor esi, ecx 72 xor eax, edi
79 mov edi, DWORD PTR 8[esp] 73 mov edx, DWORD PTR 4[esp]
80 xor esi, eax 74 xor eax, ecx
81 add ebp, esi 75 add ebp, eax
82 mov esi, eax 76 mov eax, ecx
83 rol ebx, 10 77 rol esi, 10
84 add ebp, edi
85 xor esi, ebx
86 rol ebp, 14
87 add ebp, edx 78 add ebp, edx
79 xor eax, esi
80 rol ebp, 14
81 add ebp, ebx
88 ; 2 82 ; 2
89 mov edi, DWORD PTR 12[esp] 83 mov edx, DWORD PTR 8[esp]
90 xor esi, ebp 84 xor eax, ebp
91 add edx, edi 85 add ebx, edx
92 rol eax, 10 86 rol ecx, 10
93 add edx, esi 87 add ebx, eax
94 mov esi, ebp 88 mov eax, ebp
95 rol edx, 15 89 rol ebx, 15
96 add edx, ecx 90 add ebx, edi
97 ; 3 91 ; 3
98 xor esi, eax 92 xor eax, ecx
99 mov edi, DWORD PTR 16[esp] 93 mov edx, DWORD PTR 12[esp]
100 xor esi, edx 94 xor eax, ebx
101 add ecx, esi 95 add edi, eax
102 mov esi, edx 96 mov eax, ebx
103 rol ebp, 10 97 rol ebp, 10
104 add ecx, edi 98 add edi, edx
105 xor esi, ebp 99 xor eax, ebp
106 rol ecx, 12 100 rol edi, 12
107 add ecx, ebx 101 add edi, esi
108 ; 4 102 ; 4
109 mov edi, DWORD PTR 20[esp] 103 mov edx, DWORD PTR 16[esp]
110 xor esi, ecx 104 xor eax, edi
111 add ebx, edi 105 add esi, edx
112 rol edx, 10 106 rol ebx, 10
113 add ebx, esi 107 add esi, eax
114 mov esi, ecx 108 mov eax, edi
115 rol ebx, 5 109 rol esi, 5
116 add ebx, eax 110 add esi, ecx
117 ; 5 111 ; 5
118 xor esi, edx 112 xor eax, ebx
119 mov edi, DWORD PTR 24[esp] 113 mov edx, DWORD PTR 20[esp]
120 xor esi, ebx 114 xor eax, esi
121 add eax, esi 115 add ecx, eax
122 mov esi, ebx 116 mov eax, esi
123 rol ecx, 10 117 rol edi, 10
124 add eax, edi 118 add ecx, edx
125 xor esi, ecx 119 xor eax, edi
126 rol eax, 8 120 rol ecx, 8
127 add eax, ebp 121 add ecx, ebp
128 ; 6 122 ; 6
129 mov edi, DWORD PTR 28[esp] 123 mov edx, DWORD PTR 24[esp]
130 xor esi, eax 124 xor eax, ecx
131 add ebp, edi
132 rol ebx, 10
133 add ebp, esi
134 mov esi, eax
135 rol ebp, 7
136 add ebp, edx 125 add ebp, edx
126 rol esi, 10
127 add ebp, eax
128 mov eax, ecx
129 rol ebp, 7
130 add ebp, ebx
137 ; 7 131 ; 7
138 xor esi, ebx 132 xor eax, esi
139 mov edi, DWORD PTR 32[esp] 133 mov edx, DWORD PTR 28[esp]
140 xor esi, ebp 134 xor eax, ebp
141 add edx, esi 135 add ebx, eax
142 mov esi, ebp 136 mov eax, ebp
143 rol eax, 10 137 rol ecx, 10
144 add edx, edi 138 add ebx, edx
145 xor esi, eax 139 xor eax, ecx
146 rol edx, 9 140 rol ebx, 9
147 add edx, ecx 141 add ebx, edi
148 ; 8 142 ; 8
149 mov edi, DWORD PTR 36[esp] 143 mov edx, DWORD PTR 32[esp]
150 xor esi, edx 144 xor eax, ebx
151 add ecx, edi 145 add edi, edx
152 rol ebp, 10 146 rol ebp, 10
153 add ecx, esi 147 add edi, eax
154 mov esi, edx 148 mov eax, ebx
155 rol ecx, 11 149 rol edi, 11
156 add ecx, ebx 150 add edi, esi
157 ; 9 151 ; 9
158 xor esi, ebp 152 xor eax, ebp
159 mov edi, DWORD PTR 40[esp] 153 mov edx, DWORD PTR 36[esp]
160 xor esi, ecx 154 xor eax, edi
161 add ebx, esi 155 add esi, eax
162 mov esi, ecx 156 mov eax, edi
163 rol edx, 10 157 rol ebx, 10
164 add ebx, edi 158 add esi, edx
165 xor esi, edx 159 xor eax, ebx
166 rol ebx, 13 160 rol esi, 13
167 add ebx, eax 161 add esi, ecx
168 ; 10 162 ; 10
169 mov edi, DWORD PTR 44[esp] 163 mov edx, DWORD PTR 40[esp]
170 xor esi, ebx 164 xor eax, esi
171 add eax, edi 165 add ecx, edx
172 rol ecx, 10 166 rol edi, 10
173 add eax, esi 167 add ecx, eax
174 mov esi, ebx 168 mov eax, esi
175 rol eax, 14 169 rol ecx, 14
176 add eax, ebp 170 add ecx, ebp
177 ; 11 171 ; 11
178 xor esi, ecx 172 xor eax, edi
179 mov edi, DWORD PTR 48[esp] 173 mov edx, DWORD PTR 44[esp]
180 xor esi, eax 174 xor eax, ecx
181 add ebp, esi 175 add ebp, eax
182 mov esi, eax 176 mov eax, ecx
183 rol ebx, 10 177 rol esi, 10
184 add ebp, edi
185 xor esi, ebx
186 rol ebp, 15
187 add ebp, edx 178 add ebp, edx
179 xor eax, esi
180 rol ebp, 15
181 add ebp, ebx
188 ; 12 182 ; 12
189 mov edi, DWORD PTR 52[esp] 183 mov edx, DWORD PTR 48[esp]
190 xor esi, ebp 184 xor eax, ebp
191 add edx, edi 185 add ebx, edx
192 rol eax, 10 186 rol ecx, 10
193 add edx, esi 187 add ebx, eax
194 mov esi, ebp 188 mov eax, ebp
195 rol edx, 6 189 rol ebx, 6
196 add edx, ecx 190 add ebx, edi
197 ; 13 191 ; 13
198 xor esi, eax 192 xor eax, ecx
199 mov edi, DWORD PTR 56[esp] 193 mov edx, DWORD PTR 52[esp]
200 xor esi, edx 194 xor eax, ebx
201 add ecx, esi 195 add edi, eax
202 mov esi, edx 196 mov eax, ebx
203 rol ebp, 10 197 rol ebp, 10
204 add ecx, edi 198 add edi, edx
205 xor esi, ebp 199 xor eax, ebp
206 rol ecx, 7 200 rol edi, 7
207 add ecx, ebx 201 add edi, esi
208 ; 14 202 ; 14
209 mov edi, DWORD PTR 60[esp] 203 mov edx, DWORD PTR 56[esp]
210 xor esi, ecx 204 xor eax, edi
211 add ebx, edi 205 add esi, edx
212 rol edx, 10 206 rol ebx, 10
213 add ebx, esi 207 add esi, eax
214 mov esi, ecx 208 mov eax, edi
215 rol ebx, 9 209 rol esi, 9
216 add ebx, eax 210 add esi, ecx
217 ; 15 211 ; 15
218 xor esi, edx 212 xor eax, ebx
219 mov edi, DWORD PTR 64[esp] 213 mov edx, DWORD PTR 60[esp]
220 xor esi, ebx 214 xor eax, esi
221 add eax, esi 215 add ecx, eax
222 mov esi, -1 216 mov eax, -1
223 rol ecx, 10 217 rol edi, 10
224 add eax, edi 218 add ecx, edx
225 mov edi, DWORD PTR 32[esp] 219 mov edx, DWORD PTR 28[esp]
226 rol eax, 8 220 rol ecx, 8
227 add eax, ebp 221 add ecx, ebp
228 ; 16 222 ; 16
229 add ebp, edi
230 mov edi, ebx
231 sub esi, eax
232 and edi, eax
233 and esi, ecx
234 or edi, esi
235 mov esi, DWORD PTR 20[esp]
236 rol ebx, 10
237 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
238 mov edi, -1
239 rol ebp, 7
240 add ebp, edx 223 add ebp, edx
224 mov edx, esi
225 sub eax, ecx
226 and edx, ecx
227 and eax, edi
228 or edx, eax
229 mov eax, DWORD PTR 16[esp]
230 rol esi, 10
231 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
232 mov edx, -1
233 rol ebp, 7
234 add ebp, ebx
241 ; 17 235 ; 17
242 add edx, esi 236 add ebx, eax
243 mov esi, eax 237 mov eax, ecx
244 sub edi, ebp 238 sub edx, ebp
245 and esi, ebp 239 and eax, ebp
246 and edi, ebx 240 and edx, esi
247 or esi, edi 241 or eax, edx
248 mov edi, DWORD PTR 56[esp] 242 mov edx, DWORD PTR 52[esp]
249 rol eax, 10 243 rol ecx, 10
250 lea edx, DWORD PTR 1518500249[esi*1+edx] 244 lea ebx, DWORD PTR 1518500249[eax*1+ebx]
251 mov esi, -1 245 mov eax, -1
252 rol edx, 6 246 rol ebx, 6
253 add edx, ecx 247 add ebx, edi
254 ; 18 248 ; 18
255 add ecx, edi 249 add edi, edx
256 mov edi, ebp 250 mov edx, ebp
257 sub esi, edx 251 sub eax, ebx
258 and edi, edx 252 and edx, ebx
259 and esi, eax 253 and eax, ecx
260 or edi, esi 254 or edx, eax
261 mov esi, DWORD PTR 8[esp] 255 mov eax, DWORD PTR 4[esp]
262 rol ebp, 10 256 rol ebp, 10
263 lea ecx, DWORD PTR 1518500249[edi*1+ecx] 257 lea edi, DWORD PTR 1518500249[edx*1+edi]
264 mov edi, -1 258 mov edx, -1
265 rol ecx, 8 259 rol edi, 8
266 add ecx, ebx 260 add edi, esi
267 ; 19 261 ; 19
268 add ebx, esi 262 add esi, eax
269 mov esi, edx 263 mov eax, ebx
270 sub edi, ecx 264 sub edx, edi
271 and esi, ecx 265 and eax, edi
272 and edi, ebp 266 and edx, ebp
273 or esi, edi 267 or eax, edx
274 mov edi, DWORD PTR 44[esp] 268 mov edx, DWORD PTR 40[esp]
275 rol edx, 10 269 rol ebx, 10
276 lea ebx, DWORD PTR 1518500249[esi*1+ebx] 270 lea esi, DWORD PTR 1518500249[eax*1+esi]
277 mov esi, -1 271 mov eax, -1
278 rol ebx, 13 272 rol esi, 13
279 add ebx, eax 273 add esi, ecx
280 ; 20 274 ; 20
281 add eax, edi 275 add ecx, edx
282 mov edi, ecx 276 mov edx, edi
283 sub esi, ebx 277 sub eax, esi
284 and edi, ebx 278 and edx, esi
285 and esi, edx 279 and eax, ebx
286 or edi, esi 280 or edx, eax
287 mov esi, DWORD PTR 28[esp] 281 mov eax, DWORD PTR 24[esp]
288 rol ecx, 10 282 rol edi, 10
289 lea eax, DWORD PTR 1518500249[edi*1+eax] 283 lea ecx, DWORD PTR 1518500249[edx*1+ecx]
290 mov edi, -1 284 mov edx, -1
291 rol eax, 11 285 rol ecx, 11
292 add eax, ebp 286 add ecx, ebp
293 ; 21 287 ; 21
294 add ebp, esi 288 add ebp, eax
295 mov esi, ebx 289 mov eax, esi
296 sub edi, eax 290 sub edx, ecx
297 and esi, eax 291 and eax, ecx
298 and edi, ecx 292 and edx, edi
299 or esi, edi 293 or eax, edx
300 mov edi, DWORD PTR 64[esp] 294 mov edx, DWORD PTR 60[esp]
301 rol ebx, 10 295 rol esi, 10
302 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 296 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
303 mov esi, -1 297 mov eax, -1
304 rol ebp, 9 298 rol ebp, 9
305 add ebp, edx 299 add ebp, ebx
306 ; 22 300 ; 22
307 add edx, edi 301 add ebx, edx
308 mov edi, eax 302 mov edx, ecx
309 sub esi, ebp 303 sub eax, ebp
310 and edi, ebp 304 and edx, ebp
311 and esi, ebx 305 and eax, esi
312 or edi, esi 306 or edx, eax
313 mov esi, DWORD PTR 16[esp] 307 mov eax, DWORD PTR 12[esp]
314 rol eax, 10 308 rol ecx, 10
315 lea edx, DWORD PTR 1518500249[edi*1+edx] 309 lea ebx, DWORD PTR 1518500249[edx*1+ebx]
316 mov edi, -1 310 mov edx, -1
317 rol edx, 7 311 rol ebx, 7
318 add edx, ecx 312 add ebx, edi
319 ; 23 313 ; 23
320 add ecx, esi 314 add edi, eax
321 mov esi, ebp 315 mov eax, ebp
322 sub edi, edx 316 sub edx, ebx
323 and esi, edx 317 and eax, ebx
324 and edi, eax 318 and edx, ecx
325 or esi, edi 319 or eax, edx
326 mov edi, DWORD PTR 52[esp] 320 mov edx, DWORD PTR 48[esp]
327 rol ebp, 10 321 rol ebp, 10
328 lea ecx, DWORD PTR 1518500249[esi*1+ecx] 322 lea edi, DWORD PTR 1518500249[eax*1+edi]
329 mov esi, -1 323 mov eax, -1
330 rol ecx, 15 324 rol edi, 15
331 add ecx, ebx 325 add edi, esi
332 ; 24 326 ; 24
333 add ebx, edi 327 add esi, edx
334 mov edi, edx 328 mov edx, ebx
335 sub esi, ecx 329 sub eax, edi
336 and edi, ecx 330 and edx, edi
337 and esi, ebp 331 and eax, ebp
338 or edi, esi 332 or edx, eax
339 mov esi, DWORD PTR 4[esp] 333 mov eax, DWORD PTR [esp]
340 rol edx, 10 334 rol ebx, 10
341 lea ebx, DWORD PTR 1518500249[edi*1+ebx] 335 lea esi, DWORD PTR 1518500249[edx*1+esi]
342 mov edi, -1 336 mov edx, -1
343 rol ebx, 7 337 rol esi, 7
344 add ebx, eax 338 add esi, ecx
345 ; 25 339 ; 25
346 add eax, esi 340 add ecx, eax
347 mov esi, ecx 341 mov eax, edi
348 sub edi, ebx 342 sub edx, esi
349 and esi, ebx 343 and eax, esi
350 and edi, edx 344 and edx, ebx
351 or esi, edi 345 or eax, edx
352 mov edi, DWORD PTR 40[esp] 346 mov edx, DWORD PTR 36[esp]
353 rol ecx, 10 347 rol edi, 10
354 lea eax, DWORD PTR 1518500249[esi*1+eax] 348 lea ecx, DWORD PTR 1518500249[eax*1+ecx]
355 mov esi, -1 349 mov eax, -1
356 rol eax, 12 350 rol ecx, 12
357 add eax, ebp 351 add ecx, ebp
358 ; 26 352 ; 26
359 add ebp, edi
360 mov edi, ebx
361 sub esi, eax
362 and edi, eax
363 and esi, ecx
364 or edi, esi
365 mov esi, DWORD PTR 24[esp]
366 rol ebx, 10
367 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
368 mov edi, -1
369 rol ebp, 15
370 add ebp, edx 353 add ebp, edx
354 mov edx, esi
355 sub eax, ecx
356 and edx, ecx
357 and eax, edi
358 or edx, eax
359 mov eax, DWORD PTR 20[esp]
360 rol esi, 10
361 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
362 mov edx, -1
363 rol ebp, 15
364 add ebp, ebx
371 ; 27 365 ; 27
372 add edx, esi 366 add ebx, eax
373 mov esi, eax 367 mov eax, ecx
374 sub edi, ebp 368 sub edx, ebp
375 and esi, ebp 369 and eax, ebp
376 and edi, ebx 370 and edx, esi
377 or esi, edi 371 or eax, edx
378 mov edi, DWORD PTR 12[esp] 372 mov edx, DWORD PTR 8[esp]
379 rol eax, 10 373 rol ecx, 10
380 lea edx, DWORD PTR 1518500249[esi*1+edx] 374 lea ebx, DWORD PTR 1518500249[eax*1+ebx]
381 mov esi, -1 375 mov eax, -1
382 rol edx, 9 376 rol ebx, 9
383 add edx, ecx 377 add ebx, edi
384 ; 28 378 ; 28
385 add ecx, edi 379 add edi, edx
386 mov edi, ebp 380 mov edx, ebp
387 sub esi, edx 381 sub eax, ebx
388 and edi, edx 382 and edx, ebx
389 and esi, eax 383 and eax, ecx
390 or edi, esi 384 or edx, eax
391 mov esi, DWORD PTR 60[esp] 385 mov eax, DWORD PTR 56[esp]
392 rol ebp, 10 386 rol ebp, 10
393 lea ecx, DWORD PTR 1518500249[edi*1+ecx] 387 lea edi, DWORD PTR 1518500249[edx*1+edi]
394 mov edi, -1 388 mov edx, -1
395 rol ecx, 11 389 rol edi, 11
396 add ecx, ebx 390 add edi, esi
397 ; 29 391 ; 29
398 add ebx, esi 392 add esi, eax
399 mov esi, edx 393 mov eax, ebx
400 sub edi, ecx 394 sub edx, edi
401 and esi, ecx 395 and eax, edi
402 and edi, ebp 396 and edx, ebp
403 or esi, edi 397 or eax, edx
404 mov edi, DWORD PTR 48[esp] 398 mov edx, DWORD PTR 44[esp]
405 rol edx, 10 399 rol ebx, 10
406 lea ebx, DWORD PTR 1518500249[esi*1+ebx] 400 lea esi, DWORD PTR 1518500249[eax*1+esi]
407 mov esi, -1 401 mov eax, -1
408 rol ebx, 7 402 rol esi, 7
409 add ebx, eax 403 add esi, ecx
410 ; 30 404 ; 30
411 add eax, edi 405 add ecx, edx
412 mov edi, ecx 406 mov edx, edi
413 sub esi, ebx 407 sub eax, esi
414 and edi, ebx 408 and edx, esi
415 and esi, edx 409 and eax, ebx
416 or edi, esi 410 or edx, eax
417 mov esi, DWORD PTR 36[esp] 411 mov eax, DWORD PTR 32[esp]
418 rol ecx, 10 412 rol edi, 10
419 lea eax, DWORD PTR 1518500249[edi*1+eax] 413 lea ecx, DWORD PTR 1518500249[edx*1+ecx]
420 mov edi, -1 414 mov edx, -1
421 rol eax, 13 415 rol ecx, 13
422 add eax, ebp 416 add ecx, ebp
423 ; 31 417 ; 31
424 add ebp, esi 418 add ebp, eax
425 mov esi, ebx 419 mov eax, esi
426 sub edi, eax 420 sub edx, ecx
427 and esi, eax 421 and eax, ecx
428 and edi, ecx 422 and edx, edi
429 or esi, edi 423 or eax, edx
430 mov edi, -1 424 mov edx, -1
431 rol ebx, 10 425 rol esi, 10
432 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 426 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
433 sub edi, eax 427 sub edx, ecx
434 rol ebp, 12 428 rol ebp, 12
435 add ebp, edx 429 add ebp, ebx
436 ; 32 430 ; 32
437 mov esi, DWORD PTR 16[esp] 431 mov eax, DWORD PTR 12[esp]
438 or edi, ebp 432 or edx, ebp
439 add edx, esi 433 add ebx, eax
440 xor edi, ebx 434 xor edx, esi
441 mov esi, -1 435 mov eax, -1
442 rol eax, 10 436 rol ecx, 10
443 lea edx, DWORD PTR 1859775393[edi*1+edx] 437 lea ebx, DWORD PTR 1859775393[edx*1+ebx]
444 sub esi, ebp 438 sub eax, ebp
445 rol edx, 11 439 rol ebx, 11
446 add edx, ecx 440 add ebx, edi
447 ; 33 441 ; 33
448 mov edi, DWORD PTR 44[esp] 442 mov edx, DWORD PTR 40[esp]
449 or esi, edx 443 or eax, ebx
450 add ecx, edi 444 add edi, edx
451 xor esi, eax 445 xor eax, ecx
452 mov edi, -1 446 mov edx, -1
453 rol ebp, 10 447 rol ebp, 10
454 lea ecx, DWORD PTR 1859775393[esi*1+ecx] 448 lea edi, DWORD PTR 1859775393[eax*1+edi]
455 sub edi, edx 449 sub edx, ebx
456 rol ecx, 13 450 rol edi, 13
457 add ecx, ebx 451 add edi, esi
458 ; 34 452 ; 34
459 mov esi, DWORD PTR 60[esp] 453 mov eax, DWORD PTR 56[esp]
460 or edi, ecx 454 or edx, edi
461 add ebx, esi 455 add esi, eax
462 xor edi, ebp 456 xor edx, ebp
463 mov esi, -1 457 mov eax, -1
464 rol edx, 10 458 rol ebx, 10
465 lea ebx, DWORD PTR 1859775393[edi*1+ebx] 459 lea esi, DWORD PTR 1859775393[edx*1+esi]
466 sub esi, ecx 460 sub eax, edi
467 rol ebx, 6 461 rol esi, 6
468 add ebx, eax 462 add esi, ecx
469 ; 35 463 ; 35
470 mov edi, DWORD PTR 20[esp] 464 mov edx, DWORD PTR 16[esp]
471 or esi, ebx 465 or eax, esi
472 add eax, edi 466 add ecx, edx
473 xor esi, edx 467 xor eax, ebx
474 mov edi, -1 468 mov edx, -1
475 rol ecx, 10 469 rol edi, 10
476 lea eax, DWORD PTR 1859775393[esi*1+eax] 470 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
477 sub edi, ebx 471 sub edx, esi
478 rol eax, 7 472 rol ecx, 7
479 add eax, ebp 473 add ecx, ebp
480 ; 36 474 ; 36
481 mov esi, DWORD PTR 40[esp] 475 mov eax, DWORD PTR 36[esp]
482 or edi, eax 476 or edx, ecx
483 add ebp, esi 477 add ebp, eax
484 xor edi, ecx 478 xor edx, edi
485 mov esi, -1 479 mov eax, -1
486 rol ebx, 10 480 rol esi, 10
487 lea ebp, DWORD PTR 1859775393[edi*1+ebp] 481 lea ebp, DWORD PTR 1859775393[edx*1+ebp]
488 sub esi, eax 482 sub eax, ecx
489 rol ebp, 14 483 rol ebp, 14
490 add ebp, edx 484 add ebp, ebx
491 ; 37 485 ; 37
492 mov edi, DWORD PTR 64[esp] 486 mov edx, DWORD PTR 60[esp]
493 or esi, ebp 487 or eax, ebp
494 add edx, edi 488 add ebx, edx
495 xor esi, ebx 489 xor eax, esi
496 mov edi, -1 490 mov edx, -1
497 rol eax, 10 491 rol ecx, 10
498 lea edx, DWORD PTR 1859775393[esi*1+edx] 492 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
499 sub edi, ebp 493 sub edx, ebp
500 rol edx, 9 494 rol ebx, 9
501 add edx, ecx 495 add ebx, edi
502 ; 38 496 ; 38
503 mov esi, DWORD PTR 36[esp] 497 mov eax, DWORD PTR 32[esp]
504 or edi, edx 498 or edx, ebx
505 add ecx, esi 499 add edi, eax
506 xor edi, eax 500 xor edx, ecx
507 mov esi, -1 501 mov eax, -1
508 rol ebp, 10 502 rol ebp, 10
509 lea ecx, DWORD PTR 1859775393[edi*1+ecx] 503 lea edi, DWORD PTR 1859775393[edx*1+edi]
510 sub esi, edx 504 sub eax, ebx
511 rol ecx, 13 505 rol edi, 13
512 add ecx, ebx 506 add edi, esi
513 ; 39 507 ; 39
514 mov edi, DWORD PTR 8[esp] 508 mov edx, DWORD PTR 4[esp]
515 or esi, ecx 509 or eax, edi
516 add ebx, edi 510 add esi, edx
517 xor esi, ebp 511 xor eax, ebp
518 mov edi, -1 512 mov edx, -1
519 rol edx, 10 513 rol ebx, 10
520 lea ebx, DWORD PTR 1859775393[esi*1+ebx] 514 lea esi, DWORD PTR 1859775393[eax*1+esi]
521 sub edi, ecx 515 sub edx, edi
522 rol ebx, 15 516 rol esi, 15
523 add ebx, eax 517 add esi, ecx
524 ; 40 518 ; 40
525 mov esi, DWORD PTR 12[esp] 519 mov eax, DWORD PTR 8[esp]
526 or edi, ebx 520 or edx, esi
527 add eax, esi 521 add ecx, eax
528 xor edi, edx 522 xor edx, ebx
529 mov esi, -1 523 mov eax, -1
530 rol ecx, 10 524 rol edi, 10
531 lea eax, DWORD PTR 1859775393[edi*1+eax] 525 lea ecx, DWORD PTR 1859775393[edx*1+ecx]
532 sub esi, ebx 526 sub eax, esi
533 rol eax, 14 527 rol ecx, 14
534 add eax, ebp 528 add ecx, ebp
535 ; 41 529 ; 41
536 mov edi, DWORD PTR 32[esp] 530 mov edx, DWORD PTR 28[esp]
537 or esi, eax 531 or eax, ecx
538 add ebp, edi
539 xor esi, ecx
540 mov edi, -1
541 rol ebx, 10
542 lea ebp, DWORD PTR 1859775393[esi*1+ebp]
543 sub edi, eax
544 rol ebp, 8
545 add ebp, edx 532 add ebp, edx
533 xor eax, edi
534 mov edx, -1
535 rol esi, 10
536 lea ebp, DWORD PTR 1859775393[eax*1+ebp]
537 sub edx, ecx
538 rol ebp, 8
539 add ebp, ebx
546 ; 42 540 ; 42
547 mov esi, DWORD PTR 4[esp] 541 mov eax, DWORD PTR [esp]
548 or edi, ebp 542 or edx, ebp
549 add edx, esi 543 add ebx, eax
550 xor edi, ebx 544 xor edx, esi
551 mov esi, -1 545 mov eax, -1
552 rol eax, 10 546 rol ecx, 10
553 lea edx, DWORD PTR 1859775393[edi*1+edx] 547 lea ebx, DWORD PTR 1859775393[edx*1+ebx]
554 sub esi, ebp 548 sub eax, ebp
555 rol edx, 13 549 rol ebx, 13
556 add edx, ecx 550 add ebx, edi
557 ; 43 551 ; 43
558 mov edi, DWORD PTR 28[esp] 552 mov edx, DWORD PTR 24[esp]
559 or esi, edx 553 or eax, ebx
560 add ecx, edi 554 add edi, edx
561 xor esi, eax 555 xor eax, ecx
562 mov edi, -1 556 mov edx, -1
563 rol ebp, 10 557 rol ebp, 10
564 lea ecx, DWORD PTR 1859775393[esi*1+ecx] 558 lea edi, DWORD PTR 1859775393[eax*1+edi]
565 sub edi, edx 559 sub edx, ebx
566 rol ecx, 6 560 rol edi, 6
567 add ecx, ebx 561 add edi, esi
568 ; 44 562 ; 44
569 mov esi, DWORD PTR 56[esp] 563 mov eax, DWORD PTR 52[esp]
570 or edi, ecx 564 or edx, edi
571 add ebx, esi 565 add esi, eax
572 xor edi, ebp 566 xor edx, ebp
573 mov esi, -1 567 mov eax, -1
574 rol edx, 10 568 rol ebx, 10
575 lea ebx, DWORD PTR 1859775393[edi*1+ebx] 569 lea esi, DWORD PTR 1859775393[edx*1+esi]
576 sub esi, ecx 570 sub eax, edi
577 rol ebx, 5 571 rol esi, 5
578 add ebx, eax 572 add esi, ecx
579 ; 45 573 ; 45
580 mov edi, DWORD PTR 48[esp] 574 mov edx, DWORD PTR 44[esp]
581 or esi, ebx 575 or eax, esi
582 add eax, edi 576 add ecx, edx
583 xor esi, edx 577 xor eax, ebx
584 mov edi, -1 578 mov edx, -1
585 rol ecx, 10 579 rol edi, 10
586 lea eax, DWORD PTR 1859775393[esi*1+eax] 580 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
587 sub edi, ebx 581 sub edx, esi
588 rol eax, 12 582 rol ecx, 12
589 add eax, ebp 583 add ecx, ebp
590 ; 46 584 ; 46
591 mov esi, DWORD PTR 24[esp] 585 mov eax, DWORD PTR 20[esp]
592 or edi, eax 586 or edx, ecx
593 add ebp, esi 587 add ebp, eax
594 xor edi, ecx 588 xor edx, edi
595 mov esi, -1 589 mov eax, -1
596 rol ebx, 10 590 rol esi, 10
597 lea ebp, DWORD PTR 1859775393[edi*1+ebp] 591 lea ebp, DWORD PTR 1859775393[edx*1+ebp]
598 sub esi, eax 592 sub eax, ecx
599 rol ebp, 7 593 rol ebp, 7
600 add ebp, edx 594 add ebp, ebx
601 ; 47 595 ; 47
602 mov edi, DWORD PTR 52[esp] 596 mov edx, DWORD PTR 48[esp]
603 or esi, ebp 597 or eax, ebp
604 add edx, edi 598 add ebx, edx
605 xor esi, ebx 599 xor eax, esi
606 mov edi, -1 600 mov edx, -1
607 rol eax, 10 601 rol ecx, 10
608 lea edx, DWORD PTR 1859775393[esi*1+edx] 602 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
609 mov esi, eax 603 mov eax, ecx
610 rol edx, 5 604 rol ebx, 5
611 add edx, ecx 605 add ebx, edi
612 ; 48 606 ; 48
613 sub edi, eax 607 sub edx, ecx
614 and esi, edx 608 and eax, ebx
615 and edi, ebp 609 and edx, ebp
616 or edi, esi 610 or edx, eax
617 mov esi, DWORD PTR 8[esp] 611 mov eax, DWORD PTR 4[esp]
618 rol ebp, 10 612 rol ebp, 10
619 lea ecx, DWORD PTR 2400959708[edi+ecx] 613 lea edi, DWORD PTR 2400959708[edx+edi]
620 mov edi, -1 614 mov edx, -1
621 add ecx, esi 615 add edi, eax
622 mov esi, ebp 616 mov eax, ebp
623 rol ecx, 11 617 rol edi, 11
624 add ecx, ebx 618 add edi, esi
625 ; 49 619 ; 49
626 sub edi, ebp 620 sub edx, ebp
627 and esi, ecx 621 and eax, edi
628 and edi, edx 622 and edx, ebx
629 or edi, esi 623 or edx, eax
630 mov esi, DWORD PTR 40[esp] 624 mov eax, DWORD PTR 36[esp]
631 rol edx, 10 625 rol ebx, 10
632 lea ebx, DWORD PTR 2400959708[edi+ebx] 626 lea esi, DWORD PTR 2400959708[edx+esi]
633 mov edi, -1 627 mov edx, -1
634 add ebx, esi 628 add esi, eax
635 mov esi, edx 629 mov eax, ebx
636 rol ebx, 12 630 rol esi, 12
637 add ebx, eax 631 add esi, ecx
638 ; 50 632 ; 50
639 sub edi, edx 633 sub edx, ebx
640 and esi, ebx 634 and eax, esi
641 and edi, ecx 635 and edx, edi
642 or edi, esi 636 or edx, eax
643 mov esi, DWORD PTR 48[esp] 637 mov eax, DWORD PTR 44[esp]
644 rol ecx, 10 638 rol edi, 10
645 lea eax, DWORD PTR 2400959708[edi+eax] 639 lea ecx, DWORD PTR 2400959708[edx+ecx]
646 mov edi, -1 640 mov edx, -1
647 add eax, esi 641 add ecx, eax
648 mov esi, ecx 642 mov eax, edi
649 rol eax, 14 643 rol ecx, 14
650 add eax, ebp 644 add ecx, ebp
651 ; 51 645 ; 51
652 sub edi, ecx 646 sub edx, edi
653 and esi, eax 647 and eax, ecx
654 and edi, ebx 648 and edx, esi
655 or edi, esi 649 or edx, eax
656 mov esi, DWORD PTR 44[esp] 650 mov eax, DWORD PTR 40[esp]
657 rol ebx, 10 651 rol esi, 10
658 lea ebp, DWORD PTR 2400959708[edi+ebp] 652 lea ebp, DWORD PTR 2400959708[edx+ebp]
659 mov edi, -1 653 mov edx, -1
660 add ebp, esi 654 add ebp, eax
661 mov esi, ebx 655 mov eax, esi
662 rol ebp, 15 656 rol ebp, 15
663 add ebp, edx 657 add ebp, ebx
664 ; 52 658 ; 52
665 sub edi, ebx 659 sub edx, esi
666 and esi, ebp 660 and eax, ebp
667 and edi, eax 661 and edx, ecx
668 or edi, esi 662 or edx, eax
669 mov esi, DWORD PTR 4[esp] 663 mov eax, DWORD PTR [esp]
670 rol eax, 10 664 rol ecx, 10
671 lea edx, DWORD PTR 2400959708[edi+edx] 665 lea ebx, DWORD PTR 2400959708[edx+ebx]
672 mov edi, -1 666 mov edx, -1
673 add edx, esi 667 add ebx, eax
674 mov esi, eax 668 mov eax, ecx
675 rol edx, 14 669 rol ebx, 14
676 add edx, ecx 670 add ebx, edi
677 ; 53 671 ; 53
678 sub edi, eax 672 sub edx, ecx
679 and esi, edx 673 and eax, ebx
680 and edi, ebp 674 and edx, ebp
681 or edi, esi 675 or edx, eax
682 mov esi, DWORD PTR 36[esp] 676 mov eax, DWORD PTR 32[esp]
683 rol ebp, 10 677 rol ebp, 10
684 lea ecx, DWORD PTR 2400959708[edi+ecx] 678 lea edi, DWORD PTR 2400959708[edx+edi]
685 mov edi, -1 679 mov edx, -1
686 add ecx, esi 680 add edi, eax
687 mov esi, ebp 681 mov eax, ebp
688 rol ecx, 15 682 rol edi, 15
689 add ecx, ebx 683 add edi, esi
690 ; 54 684 ; 54
691 sub edi, ebp 685 sub edx, ebp
692 and esi, ecx 686 and eax, edi
693 and edi, edx 687 and edx, ebx
694 or edi, esi 688 or edx, eax
695 mov esi, DWORD PTR 52[esp] 689 mov eax, DWORD PTR 48[esp]
696 rol edx, 10 690 rol ebx, 10
697 lea ebx, DWORD PTR 2400959708[edi+ebx] 691 lea esi, DWORD PTR 2400959708[edx+esi]
698 mov edi, -1 692 mov edx, -1
699 add ebx, esi 693 add esi, eax
700 mov esi, edx 694 mov eax, ebx
701 rol ebx, 9 695 rol esi, 9
702 add ebx, eax 696 add esi, ecx
703 ; 55 697 ; 55
704 sub edi, edx 698 sub edx, ebx
705 and esi, ebx 699 and eax, esi
706 and edi, ecx 700 and edx, edi
707 or edi, esi 701 or edx, eax
708 mov esi, DWORD PTR 20[esp] 702 mov eax, DWORD PTR 16[esp]
709 rol ecx, 10 703 rol edi, 10
710 lea eax, DWORD PTR 2400959708[edi+eax] 704 lea ecx, DWORD PTR 2400959708[edx+ecx]
711 mov edi, -1 705 mov edx, -1
712 add eax, esi 706 add ecx, eax
713 mov esi, ecx 707 mov eax, edi
714 rol eax, 8 708 rol ecx, 8
715 add eax, ebp 709 add ecx, ebp
716 ; 56 710 ; 56
717 sub edi, ecx 711 sub edx, edi
718 and esi, eax 712 and eax, ecx
719 and edi, ebx 713 and edx, esi
720 or edi, esi 714 or edx, eax
721 mov esi, DWORD PTR 56[esp] 715 mov eax, DWORD PTR 52[esp]
722 rol ebx, 10 716 rol esi, 10
723 lea ebp, DWORD PTR 2400959708[edi+ebp] 717 lea ebp, DWORD PTR 2400959708[edx+ebp]
724 mov edi, -1 718 mov edx, -1
725 add ebp, esi 719 add ebp, eax
726 mov esi, ebx 720 mov eax, esi
727 rol ebp, 9 721 rol ebp, 9
728 add ebp, edx 722 add ebp, ebx
729 ; 57 723 ; 57
730 sub edi, ebx 724 sub edx, esi
731 and esi, ebp 725 and eax, ebp
732 and edi, eax 726 and edx, ecx
733 or edi, esi 727 or edx, eax
734 mov esi, DWORD PTR 16[esp] 728 mov eax, DWORD PTR 12[esp]
735 rol eax, 10 729 rol ecx, 10
736 lea edx, DWORD PTR 2400959708[edi+edx] 730 lea ebx, DWORD PTR 2400959708[edx+ebx]
737 mov edi, -1 731 mov edx, -1
738 add edx, esi 732 add ebx, eax
739 mov esi, eax 733 mov eax, ecx
740 rol edx, 14 734 rol ebx, 14
741 add edx, ecx 735 add ebx, edi
742 ; 58 736 ; 58
743 sub edi, eax 737 sub edx, ecx
744 and esi, edx 738 and eax, ebx
745 and edi, ebp 739 and edx, ebp
746 or edi, esi 740 or edx, eax
747 mov esi, DWORD PTR 32[esp] 741 mov eax, DWORD PTR 28[esp]
748 rol ebp, 10 742 rol ebp, 10
749 lea ecx, DWORD PTR 2400959708[edi+ecx] 743 lea edi, DWORD PTR 2400959708[edx+edi]
750 mov edi, -1 744 mov edx, -1
751 add ecx, esi 745 add edi, eax
752 mov esi, ebp 746 mov eax, ebp
753 rol ecx, 5 747 rol edi, 5
754 add ecx, ebx 748 add edi, esi
755 ; 59 749 ; 59
756 sub edi, ebp 750 sub edx, ebp
757 and esi, ecx 751 and eax, edi
758 and edi, edx 752 and edx, ebx
759 or edi, esi 753 or edx, eax
760 mov esi, DWORD PTR 64[esp] 754 mov eax, DWORD PTR 60[esp]
761 rol edx, 10 755 rol ebx, 10
762 lea ebx, DWORD PTR 2400959708[edi+ebx] 756 lea esi, DWORD PTR 2400959708[edx+esi]
763 mov edi, -1 757 mov edx, -1
764 add ebx, esi 758 add esi, eax
765 mov esi, edx 759 mov eax, ebx
766 rol ebx, 6 760 rol esi, 6
767 add ebx, eax 761 add esi, ecx
768 ; 60 762 ; 60
769 sub edi, edx 763 sub edx, ebx
770 and esi, ebx 764 and eax, esi
771 and edi, ecx 765 and edx, edi
772 or edi, esi 766 or edx, eax
773 mov esi, DWORD PTR 60[esp] 767 mov eax, DWORD PTR 56[esp]
774 rol ecx, 10 768 rol edi, 10
775 lea eax, DWORD PTR 2400959708[edi+eax] 769 lea ecx, DWORD PTR 2400959708[edx+ecx]
776 mov edi, -1 770 mov edx, -1
777 add eax, esi 771 add ecx, eax
778 mov esi, ecx 772 mov eax, edi
779 rol eax, 8 773 rol ecx, 8
780 add eax, ebp 774 add ecx, ebp
781 ; 61 775 ; 61
782 sub edi, ecx 776 sub edx, edi
783 and esi, eax 777 and eax, ecx
784 and edi, ebx 778 and edx, esi
785 or edi, esi 779 or edx, eax
786 mov esi, DWORD PTR 24[esp] 780 mov eax, DWORD PTR 20[esp]
787 rol ebx, 10 781 rol esi, 10
788 lea ebp, DWORD PTR 2400959708[edi+ebp] 782 lea ebp, DWORD PTR 2400959708[edx+ebp]
789 mov edi, -1 783 mov edx, -1
790 add ebp, esi 784 add ebp, eax
791 mov esi, ebx 785 mov eax, esi
792 rol ebp, 6 786 rol ebp, 6
793 add ebp, edx 787 add ebp, ebx
794 ; 62 788 ; 62
795 sub edi, ebx 789 sub edx, esi
796 and esi, ebp 790 and eax, ebp
797 and edi, eax 791 and edx, ecx
798 or edi, esi 792 or edx, eax
799 mov esi, DWORD PTR 28[esp] 793 mov eax, DWORD PTR 24[esp]
800 rol eax, 10 794 rol ecx, 10
801 lea edx, DWORD PTR 2400959708[edi+edx] 795 lea ebx, DWORD PTR 2400959708[edx+ebx]
802 mov edi, -1 796 mov edx, -1
803 add edx, esi 797 add ebx, eax
804 mov esi, eax 798 mov eax, ecx
805 rol edx, 5 799 rol ebx, 5
806 add edx, ecx 800 add ebx, edi
807 ; 63 801 ; 63
808 sub edi, eax 802 sub edx, ecx
809 and esi, edx 803 and eax, ebx
810 and edi, ebp 804 and edx, ebp
811 or edi, esi 805 or edx, eax
812 mov esi, DWORD PTR 12[esp] 806 mov eax, DWORD PTR 8[esp]
813 rol ebp, 10 807 rol ebp, 10
814 lea ecx, DWORD PTR 2400959708[edi+ecx] 808 lea edi, DWORD PTR 2400959708[edx+edi]
815 mov edi, -1 809 mov edx, -1
816 add ecx, esi 810 add edi, eax
817 sub edi, ebp 811 sub edx, ebp
818 rol ecx, 12 812 rol edi, 12
819 add ecx, ebx 813 add edi, esi
820 ; 64 814 ; 64
821 mov esi, DWORD PTR 20[esp] 815 mov eax, DWORD PTR 16[esp]
822 or edi, edx 816 or edx, ebx
823 add ebx, esi 817 add esi, eax
824 xor edi, ecx 818 xor edx, edi
825 mov esi, -1 819 mov eax, -1
826 rol edx, 10 820 rol ebx, 10
827 lea ebx, DWORD PTR 2840853838[edi*1+ebx] 821 lea esi, DWORD PTR 2840853838[edx*1+esi]
828 sub esi, edx 822 sub eax, ebx
829 rol ebx, 9 823 rol esi, 9
830 add ebx, eax 824 add esi, ecx
831 ; 65 825 ; 65
832 mov edi, DWORD PTR 4[esp] 826 mov edx, DWORD PTR [esp]
833 or esi, ecx 827 or eax, edi
834 add eax, edi 828 add ecx, edx
835 xor esi, ebx 829 xor eax, esi
836 mov edi, -1 830 mov edx, -1
837 rol ecx, 10 831 rol edi, 10
838 lea eax, DWORD PTR 2840853838[esi*1+eax] 832 lea ecx, DWORD PTR 2840853838[eax*1+ecx]
839 sub edi, ecx 833 sub edx, edi
840 rol eax, 15 834 rol ecx, 15
841 add eax, ebp 835 add ecx, ebp
842 ; 66 836 ; 66
843 mov esi, DWORD PTR 24[esp] 837 mov eax, DWORD PTR 20[esp]
844 or edi, ebx 838 or edx, esi
845 add ebp, esi 839 add ebp, eax
846 xor edi, eax 840 xor edx, ecx
847 mov esi, -1 841 mov eax, -1
848 rol ebx, 10 842 rol esi, 10
849 lea ebp, DWORD PTR 2840853838[edi*1+ebp] 843 lea ebp, DWORD PTR 2840853838[edx*1+ebp]
850 sub esi, ebx 844 sub eax, esi
851 rol ebp, 5 845 rol ebp, 5
852 add ebp, edx 846 add ebp, ebx
853 ; 67 847 ; 67
854 mov edi, DWORD PTR 40[esp] 848 mov edx, DWORD PTR 36[esp]
855 or esi, eax 849 or eax, ecx
856 add edx, edi 850 add ebx, edx
857 xor esi, ebp 851 xor eax, ebp
858 mov edi, -1 852 mov edx, -1
859 rol eax, 10 853 rol ecx, 10
860 lea edx, DWORD PTR 2840853838[esi*1+edx] 854 lea ebx, DWORD PTR 2840853838[eax*1+ebx]
861 sub edi, eax 855 sub edx, ecx
862 rol edx, 11 856 rol ebx, 11
863 add edx, ecx 857 add ebx, edi
864 ; 68 858 ; 68
865 mov esi, DWORD PTR 32[esp] 859 mov eax, DWORD PTR 28[esp]
866 or edi, ebp 860 or edx, ebp
867 add ecx, esi 861 add edi, eax
868 xor edi, edx 862 xor edx, ebx
869 mov esi, -1 863 mov eax, -1
870 rol ebp, 10 864 rol ebp, 10
871 lea ecx, DWORD PTR 2840853838[edi*1+ecx] 865 lea edi, DWORD PTR 2840853838[edx*1+edi]
872 sub esi, ebp 866 sub eax, ebp
873 rol ecx, 6 867 rol edi, 6
874 add ecx, ebx 868 add edi, esi
875 ; 69 869 ; 69
876 mov edi, DWORD PTR 52[esp] 870 mov edx, DWORD PTR 48[esp]
877 or esi, edx 871 or eax, ebx
878 add ebx, edi 872 add esi, edx
879 xor esi, ecx 873 xor eax, edi
880 mov edi, -1 874 mov edx, -1
881 rol edx, 10 875 rol ebx, 10
882 lea ebx, DWORD PTR 2840853838[esi*1+ebx] 876 lea esi, DWORD PTR 2840853838[eax*1+esi]
883 sub edi, edx 877 sub edx, ebx
884 rol ebx, 8 878 rol esi, 8
885 add ebx, eax 879 add esi, ecx
886 ; 70 880 ; 70
887 mov esi, DWORD PTR 12[esp] 881 mov eax, DWORD PTR 8[esp]
888 or edi, ecx 882 or edx, edi
889 add eax, esi 883 add ecx, eax
890 xor edi, ebx 884 xor edx, esi
891 mov esi, -1 885 mov eax, -1
892 rol ecx, 10 886 rol edi, 10
893 lea eax, DWORD PTR 2840853838[edi*1+eax] 887 lea ecx, DWORD PTR 2840853838[edx*1+ecx]
894 sub esi, ecx 888 sub eax, edi
895 rol eax, 13 889 rol ecx, 13
896 add eax, ebp 890 add ecx, ebp
897 ; 71 891 ; 71
898 mov edi, DWORD PTR 44[esp] 892 mov edx, DWORD PTR 40[esp]
899 or esi, ebx 893 or eax, esi
900 add ebp, edi
901 xor esi, eax
902 mov edi, -1
903 rol ebx, 10
904 lea ebp, DWORD PTR 2840853838[esi*1+ebp]
905 sub edi, ebx
906 rol ebp, 12
907 add ebp, edx 894 add ebp, edx
895 xor eax, ecx
896 mov edx, -1
897 rol esi, 10
898 lea ebp, DWORD PTR 2840853838[eax*1+ebp]
899 sub edx, esi
900 rol ebp, 12
901 add ebp, ebx
908 ; 72 902 ; 72
909 mov esi, DWORD PTR 60[esp] 903 mov eax, DWORD PTR 56[esp]
910 or edi, eax 904 or edx, ecx
911 add edx, esi 905 add ebx, eax
912 xor edi, ebp 906 xor edx, ebp
913 mov esi, -1 907 mov eax, -1
914 rol eax, 10 908 rol ecx, 10
915 lea edx, DWORD PTR 2840853838[edi*1+edx] 909 lea ebx, DWORD PTR 2840853838[edx*1+ebx]
916 sub esi, eax 910 sub eax, ecx
917 rol edx, 5 911 rol ebx, 5
918 add edx, ecx 912 add ebx, edi
919 ; 73 913 ; 73
920 mov edi, DWORD PTR 8[esp] 914 mov edx, DWORD PTR 4[esp]
921 or esi, ebp 915 or eax, ebp
922 add ecx, edi 916 add edi, edx
923 xor esi, edx 917 xor eax, ebx
924 mov edi, -1 918 mov edx, -1
925 rol ebp, 10 919 rol ebp, 10
926 lea ecx, DWORD PTR 2840853838[esi*1+ecx] 920 lea edi, DWORD PTR 2840853838[eax*1+edi]
927 sub edi, ebp 921 sub edx, ebp
928 rol ecx, 12 922 rol edi, 12
929 add ecx, ebx 923 add edi, esi
930 ; 74 924 ; 74
931 mov esi, DWORD PTR 16[esp] 925 mov eax, DWORD PTR 12[esp]
932 or edi, edx 926 or edx, ebx
933 add ebx, esi 927 add esi, eax
934 xor edi, ecx 928 xor edx, edi
935 mov esi, -1 929 mov eax, -1
936 rol edx, 10 930 rol ebx, 10
937 lea ebx, DWORD PTR 2840853838[edi*1+ebx] 931 lea esi, DWORD PTR 2840853838[edx*1+esi]
938 sub esi, edx 932 sub eax, ebx
939 rol ebx, 13 933 rol esi, 13
940 add ebx, eax 934 add esi, ecx
941 ; 75 935 ; 75
942 mov edi, DWORD PTR 36[esp] 936 mov edx, DWORD PTR 32[esp]
943 or esi, ecx 937 or eax, edi
944 add eax, edi 938 add ecx, edx
945 xor esi, ebx 939 xor eax, esi
946 mov edi, -1 940 mov edx, -1
947 rol ecx, 10 941 rol edi, 10
948 lea eax, DWORD PTR 2840853838[esi*1+eax] 942 lea ecx, DWORD PTR 2840853838[eax*1+ecx]
949 sub edi, ecx 943 sub edx, edi
950 rol eax, 14 944 rol ecx, 14
951 add eax, ebp 945 add ecx, ebp
952 ; 76 946 ; 76
953 mov esi, DWORD PTR 48[esp] 947 mov eax, DWORD PTR 44[esp]
954 or edi, ebx 948 or edx, esi
955 add ebp, esi 949 add ebp, eax
956 xor edi, eax 950 xor edx, ecx
957 mov esi, -1 951 mov eax, -1
958 rol ebx, 10 952 rol esi, 10
959 lea ebp, DWORD PTR 2840853838[edi*1+ebp] 953 lea ebp, DWORD PTR 2840853838[edx*1+ebp]
960 sub esi, ebx 954 sub eax, esi
961 rol ebp, 11 955 rol ebp, 11
962 add ebp, edx 956 add ebp, ebx
963 ; 77 957 ; 77
964 mov edi, DWORD PTR 28[esp] 958 mov edx, DWORD PTR 24[esp]
965 or esi, eax 959 or eax, ecx
966 add edx, edi 960 add ebx, edx
967 xor esi, ebp 961 xor eax, ebp
968 mov edi, -1 962 mov edx, -1
969 rol eax, 10 963 rol ecx, 10
970 lea edx, DWORD PTR 2840853838[esi*1+edx] 964 lea ebx, DWORD PTR 2840853838[eax*1+ebx]
971 sub edi, eax 965 sub edx, ecx
972 rol edx, 8 966 rol ebx, 8
973 add edx, ecx 967 add ebx, edi
974 ; 78 968 ; 78
975 mov esi, DWORD PTR 64[esp] 969 mov eax, DWORD PTR 60[esp]
976 or edi, ebp 970 or edx, ebp
977 add ecx, esi 971 add edi, eax
978 xor edi, edx 972 xor edx, ebx
979 mov esi, -1 973 mov eax, -1
980 rol ebp, 10 974 rol ebp, 10
981 lea ecx, DWORD PTR 2840853838[edi*1+ecx] 975 lea edi, DWORD PTR 2840853838[edx*1+edi]
982 sub esi, ebp 976 sub eax, ebp
983 rol ecx, 5 977 rol edi, 5
984 add ecx, ebx 978 add edi, esi
985 ; 79 979 ; 79
986 mov edi, DWORD PTR 56[esp] 980 mov edx, DWORD PTR 52[esp]
987 or esi, edx 981 or eax, ebx
988 add ebx, edi 982 add esi, edx
989 xor esi, ecx 983 xor eax, edi
990 mov edi, DWORD PTR 108[esp] 984 mov edx, DWORD PTR 128[esp]
991 rol edx, 10 985 rol ebx, 10
992 lea ebx, DWORD PTR 2840853838[esi*1+ebx] 986 lea esi, DWORD PTR 2840853838[eax*1+esi]
993 mov DWORD PTR 68[esp],eax 987 mov DWORD PTR 64[esp],ecx
994 rol ebx, 6 988 rol esi, 6
995 add ebx, eax 989 add esi, ecx
996 mov eax, DWORD PTR [edi] 990 mov ecx, DWORD PTR [edx]
997 mov DWORD PTR 72[esp],ebx 991 mov DWORD PTR 68[esp],esi
998 mov DWORD PTR 76[esp],ecx 992 mov DWORD PTR 72[esp],edi
999 mov ebx, DWORD PTR 4[edi] 993 mov esi, DWORD PTR 4[edx]
1000 mov DWORD PTR 80[esp],edx 994 mov DWORD PTR 76[esp],ebx
1001 mov ecx, DWORD PTR 8[edi] 995 mov edi, DWORD PTR 8[edx]
1002 mov DWORD PTR 84[esp],ebp 996 mov DWORD PTR 80[esp],ebp
1003 mov edx, DWORD PTR 12[edi] 997 mov ebx, DWORD PTR 12[edx]
1004 mov ebp, DWORD PTR 16[edi] 998 mov ebp, DWORD PTR 16[edx]
1005 ; 80 999 ; 80
1006 mov edi, -1 1000 mov edx, -1
1007 sub edi, edx 1001 sub edx, ebx
1008 mov esi, DWORD PTR 24[esp] 1002 mov eax, DWORD PTR 20[esp]
1009 or edi, ecx 1003 or edx, edi
1010 add eax, esi 1004 add ecx, eax
1011 xor edi, ebx 1005 xor edx, esi
1012 mov esi, -1 1006 mov eax, -1
1013 rol ecx, 10 1007 rol edi, 10
1014 lea eax, DWORD PTR 1352829926[edi*1+eax] 1008 lea ecx, DWORD PTR 1352829926[edx*1+ecx]
1015 sub esi, ecx 1009 sub eax, edi
1016 rol eax, 8 1010 rol ecx, 8
1017 add eax, ebp 1011 add ecx, ebp
1018 ; 81 1012 ; 81
1019 mov edi, DWORD PTR 60[esp] 1013 mov edx, DWORD PTR 56[esp]
1020 or esi, ebx 1014 or eax, esi
1021 add ebp, edi
1022 xor esi, eax
1023 mov edi, -1
1024 rol ebx, 10
1025 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1026 sub edi, ebx
1027 rol ebp, 9
1028 add ebp, edx 1015 add ebp, edx
1016 xor eax, ecx
1017 mov edx, -1
1018 rol esi, 10
1019 lea ebp, DWORD PTR 1352829926[eax*1+ebp]
1020 sub edx, esi
1021 rol ebp, 9
1022 add ebp, ebx
1029 ; 82 1023 ; 82
1030 mov esi, DWORD PTR 32[esp] 1024 mov eax, DWORD PTR 28[esp]
1031 or edi, eax 1025 or edx, ecx
1032 add edx, esi 1026 add ebx, eax
1033 xor edi, ebp 1027 xor edx, ebp
1034 mov esi, -1 1028 mov eax, -1
1035 rol eax, 10 1029 rol ecx, 10
1036 lea edx, DWORD PTR 1352829926[edi*1+edx] 1030 lea ebx, DWORD PTR 1352829926[edx*1+ebx]
1037 sub esi, eax 1031 sub eax, ecx
1038 rol edx, 9 1032 rol ebx, 9
1039 add edx, ecx 1033 add ebx, edi
1040 ; 83 1034 ; 83
1041 mov edi, DWORD PTR 4[esp] 1035 mov edx, DWORD PTR [esp]
1042 or esi, ebp 1036 or eax, ebp
1043 add ecx, edi 1037 add edi, edx
1044 xor esi, edx 1038 xor eax, ebx
1045 mov edi, -1 1039 mov edx, -1
1046 rol ebp, 10 1040 rol ebp, 10
1047 lea ecx, DWORD PTR 1352829926[esi*1+ecx] 1041 lea edi, DWORD PTR 1352829926[eax*1+edi]
1048 sub edi, ebp 1042 sub edx, ebp
1049 rol ecx, 11 1043 rol edi, 11
1050 add ecx, ebx 1044 add edi, esi
1051 ; 84 1045 ; 84
1052 mov esi, DWORD PTR 40[esp] 1046 mov eax, DWORD PTR 36[esp]
1053 or edi, edx 1047 or edx, ebx
1054 add ebx, esi 1048 add esi, eax
1055 xor edi, ecx 1049 xor edx, edi
1056 mov esi, -1 1050 mov eax, -1
1057 rol edx, 10 1051 rol ebx, 10
1058 lea ebx, DWORD PTR 1352829926[edi*1+ebx] 1052 lea esi, DWORD PTR 1352829926[edx*1+esi]
1059 sub esi, edx 1053 sub eax, ebx
1060 rol ebx, 13 1054 rol esi, 13
1061 add ebx, eax 1055 add esi, ecx
1062 ; 85 1056 ; 85
1063 mov edi, DWORD PTR 12[esp] 1057 mov edx, DWORD PTR 8[esp]
1064 or esi, ecx 1058 or eax, edi
1065 add eax, edi 1059 add ecx, edx
1066 xor esi, ebx 1060 xor eax, esi
1067 mov edi, -1 1061 mov edx, -1
1068 rol ecx, 10 1062 rol edi, 10
1069 lea eax, DWORD PTR 1352829926[esi*1+eax] 1063 lea ecx, DWORD PTR 1352829926[eax*1+ecx]
1070 sub edi, ecx 1064 sub edx, edi
1071 rol eax, 15 1065 rol ecx, 15
1072 add eax, ebp 1066 add ecx, ebp
1073 ; 86 1067 ; 86
1074 mov esi, DWORD PTR 48[esp] 1068 mov eax, DWORD PTR 44[esp]
1075 or edi, ebx 1069 or edx, esi
1076 add ebp, esi 1070 add ebp, eax
1077 xor edi, eax 1071 xor edx, ecx
1078 mov esi, -1 1072 mov eax, -1
1079 rol ebx, 10 1073 rol esi, 10
1080 lea ebp, DWORD PTR 1352829926[edi*1+ebp] 1074 lea ebp, DWORD PTR 1352829926[edx*1+ebp]
1081 sub esi, ebx 1075 sub eax, esi
1082 rol ebp, 15 1076 rol ebp, 15
1083 add ebp, edx 1077 add ebp, ebx
1084 ; 87 1078 ; 87
1085 mov edi, DWORD PTR 20[esp] 1079 mov edx, DWORD PTR 16[esp]
1086 or esi, eax 1080 or eax, ecx
1087 add edx, edi 1081 add ebx, edx
1088 xor esi, ebp 1082 xor eax, ebp
1089 mov edi, -1 1083 mov edx, -1
1090 rol eax, 10 1084 rol ecx, 10
1091 lea edx, DWORD PTR 1352829926[esi*1+edx] 1085 lea ebx, DWORD PTR 1352829926[eax*1+ebx]
1092 sub edi, eax 1086 sub edx, ecx
1093 rol edx, 5 1087 rol ebx, 5
1094 add edx, ecx 1088 add ebx, edi
1095 ; 88 1089 ; 88
1096 mov esi, DWORD PTR 56[esp] 1090 mov eax, DWORD PTR 52[esp]
1097 or edi, ebp 1091 or edx, ebp
1098 add ecx, esi 1092 add edi, eax
1099 xor edi, edx 1093 xor edx, ebx
1100 mov esi, -1 1094 mov eax, -1
1101 rol ebp, 10 1095 rol ebp, 10
1102 lea ecx, DWORD PTR 1352829926[edi*1+ecx] 1096 lea edi, DWORD PTR 1352829926[edx*1+edi]
1103 sub esi, ebp 1097 sub eax, ebp
1104 rol ecx, 7 1098 rol edi, 7
1105 add ecx, ebx 1099 add edi, esi
1106 ; 89 1100 ; 89
1107 mov edi, DWORD PTR 28[esp] 1101 mov edx, DWORD PTR 24[esp]
1108 or esi, edx 1102 or eax, ebx
1109 add ebx, edi 1103 add esi, edx
1110 xor esi, ecx 1104 xor eax, edi
1111 mov edi, -1 1105 mov edx, -1
1112 rol edx, 10 1106 rol ebx, 10
1113 lea ebx, DWORD PTR 1352829926[esi*1+ebx] 1107 lea esi, DWORD PTR 1352829926[eax*1+esi]
1114 sub edi, edx 1108 sub edx, ebx
1115 rol ebx, 7 1109 rol esi, 7
1116 add ebx, eax 1110 add esi, ecx
1117 ; 90 1111 ; 90
1118 mov esi, DWORD PTR 64[esp] 1112 mov eax, DWORD PTR 60[esp]
1119 or edi, ecx 1113 or edx, edi
1120 add eax, esi 1114 add ecx, eax
1121 xor edi, ebx 1115 xor edx, esi
1122 mov esi, -1 1116 mov eax, -1
1123 rol ecx, 10 1117 rol edi, 10
1124 lea eax, DWORD PTR 1352829926[edi*1+eax] 1118 lea ecx, DWORD PTR 1352829926[edx*1+ecx]
1125 sub esi, ecx 1119 sub eax, edi
1126 rol eax, 8 1120 rol ecx, 8
1127 add eax, ebp 1121 add ecx, ebp
1128 ; 91 1122 ; 91
1129 mov edi, DWORD PTR 36[esp] 1123 mov edx, DWORD PTR 32[esp]
1130 or esi, ebx 1124 or eax, esi
1131 add ebp, edi
1132 xor esi, eax
1133 mov edi, -1
1134 rol ebx, 10
1135 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1136 sub edi, ebx
1137 rol ebp, 11
1138 add ebp, edx 1125 add ebp, edx
1126 xor eax, ecx
1127 mov edx, -1
1128 rol esi, 10
1129 lea ebp, DWORD PTR 1352829926[eax*1+ebp]
1130 sub edx, esi
1131 rol ebp, 11
1132 add ebp, ebx
1139 ; 92 1133 ; 92
1140 mov esi, DWORD PTR 8[esp] 1134 mov eax, DWORD PTR 4[esp]
1141 or edi, eax 1135 or edx, ecx
1142 add edx, esi 1136 add ebx, eax
1143 xor edi, ebp 1137 xor edx, ebp
1144 mov esi, -1 1138 mov eax, -1
1145 rol eax, 10 1139 rol ecx, 10
1146 lea edx, DWORD PTR 1352829926[edi*1+edx] 1140 lea ebx, DWORD PTR 1352829926[edx*1+ebx]
1147 sub esi, eax 1141 sub eax, ecx
1148 rol edx, 14 1142 rol ebx, 14
1149 add edx, ecx 1143 add ebx, edi
1150 ; 93 1144 ; 93
1151 mov edi, DWORD PTR 44[esp] 1145 mov edx, DWORD PTR 40[esp]
1152 or esi, ebp 1146 or eax, ebp
1153 add ecx, edi 1147 add edi, edx
1154 xor esi, edx 1148 xor eax, ebx
1155 mov edi, -1 1149 mov edx, -1
1156 rol ebp, 10 1150 rol ebp, 10
1157 lea ecx, DWORD PTR 1352829926[esi*1+ecx] 1151 lea edi, DWORD PTR 1352829926[eax*1+edi]
1158 sub edi, ebp 1152 sub edx, ebp
1159 rol ecx, 14 1153 rol edi, 14
1160 add ecx, ebx 1154 add edi, esi
1161 ; 94 1155 ; 94
1162 mov esi, DWORD PTR 16[esp] 1156 mov eax, DWORD PTR 12[esp]
1163 or edi, edx 1157 or edx, ebx
1164 add ebx, esi 1158 add esi, eax
1165 xor edi, ecx 1159 xor edx, edi
1166 mov esi, -1 1160 mov eax, -1
1167 rol edx, 10 1161 rol ebx, 10
1168 lea ebx, DWORD PTR 1352829926[edi*1+ebx] 1162 lea esi, DWORD PTR 1352829926[edx*1+esi]
1169 sub esi, edx 1163 sub eax, ebx
1170 rol ebx, 12 1164 rol esi, 12
1171 add ebx, eax 1165 add esi, ecx
1172 ; 95 1166 ; 95
1173 mov edi, DWORD PTR 52[esp] 1167 mov edx, DWORD PTR 48[esp]
1174 or esi, ecx 1168 or eax, edi
1175 add eax, edi 1169 add ecx, edx
1176 xor esi, ebx 1170 xor eax, esi
1177 mov edi, -1 1171 mov edx, -1
1178 rol ecx, 10 1172 rol edi, 10
1179 lea eax, DWORD PTR 1352829926[esi*1+eax] 1173 lea ecx, DWORD PTR 1352829926[eax*1+ecx]
1180 mov esi, ecx 1174 mov eax, edi
1181 rol eax, 6 1175 rol ecx, 6
1182 add eax, ebp 1176 add ecx, ebp
1183 ; 96 1177 ; 96
1184 sub edi, ecx 1178 sub edx, edi
1185 and esi, eax 1179 and eax, ecx
1186 and edi, ebx 1180 and edx, esi
1187 or edi, esi 1181 or edx, eax
1188 mov esi, DWORD PTR 28[esp] 1182 mov eax, DWORD PTR 24[esp]
1189 rol ebx, 10 1183 rol esi, 10
1190 lea ebp, DWORD PTR 1548603684[edi+ebp] 1184 lea ebp, DWORD PTR 1548603684[edx+ebp]
1191 mov edi, -1 1185 mov edx, -1
1192 add ebp, esi 1186 add ebp, eax
1193 mov esi, ebx 1187 mov eax, esi
1194 rol ebp, 9 1188 rol ebp, 9
1195 add ebp, edx 1189 add ebp, ebx
1196 ; 97 1190 ; 97
1197 sub edi, ebx 1191 sub edx, esi
1198 and esi, ebp 1192 and eax, ebp
1199 and edi, eax 1193 and edx, ecx
1200 or edi, esi 1194 or edx, eax
1201 mov esi, DWORD PTR 48[esp] 1195 mov eax, DWORD PTR 44[esp]
1202 rol eax, 10 1196 rol ecx, 10
1203 lea edx, DWORD PTR 1548603684[edi+edx] 1197 lea ebx, DWORD PTR 1548603684[edx+ebx]
1204 mov edi, -1 1198 mov edx, -1
1205 add edx, esi 1199 add ebx, eax
1206 mov esi, eax 1200 mov eax, ecx
1207 rol edx, 13 1201 rol ebx, 13
1208 add edx, ecx 1202 add ebx, edi
1209 ; 98 1203 ; 98
1210 sub edi, eax 1204 sub edx, ecx
1211 and esi, edx 1205 and eax, ebx
1212 and edi, ebp 1206 and edx, ebp
1213 or edi, esi 1207 or edx, eax
1214 mov esi, DWORD PTR 16[esp] 1208 mov eax, DWORD PTR 12[esp]
1215 rol ebp, 10 1209 rol ebp, 10
1216 lea ecx, DWORD PTR 1548603684[edi+ecx] 1210 lea edi, DWORD PTR 1548603684[edx+edi]
1217 mov edi, -1 1211 mov edx, -1
1218 add ecx, esi 1212 add edi, eax
1219 mov esi, ebp 1213 mov eax, ebp
1220 rol ecx, 15 1214 rol edi, 15
1221 add ecx, ebx 1215 add edi, esi
1222 ; 99 1216 ; 99
1223 sub edi, ebp 1217 sub edx, ebp
1224 and esi, ecx 1218 and eax, edi
1225 and edi, edx 1219 and edx, ebx
1226 or edi, esi 1220 or edx, eax
1227 mov esi, DWORD PTR 32[esp] 1221 mov eax, DWORD PTR 28[esp]
1228 rol edx, 10 1222 rol ebx, 10
1229 lea ebx, DWORD PTR 1548603684[edi+ebx] 1223 lea esi, DWORD PTR 1548603684[edx+esi]
1230 mov edi, -1 1224 mov edx, -1
1231 add ebx, esi 1225 add esi, eax
1232 mov esi, edx 1226 mov eax, ebx
1233 rol ebx, 7 1227 rol esi, 7
1234 add ebx, eax 1228 add esi, ecx
1235 ; 100 1229 ; 100
1236 sub edi, edx 1230 sub edx, ebx
1237 and esi, ebx 1231 and eax, esi
1238 and edi, ecx 1232 and edx, edi
1239 or edi, esi 1233 or edx, eax
1240 mov esi, DWORD PTR 4[esp] 1234 mov eax, DWORD PTR [esp]
1241 rol ecx, 10 1235 rol edi, 10
1242 lea eax, DWORD PTR 1548603684[edi+eax] 1236 lea ecx, DWORD PTR 1548603684[edx+ecx]
1243 mov edi, -1 1237 mov edx, -1
1244 add eax, esi 1238 add ecx, eax
1245 mov esi, ecx 1239 mov eax, edi
1246 rol eax, 12 1240 rol ecx, 12
1247 add eax, ebp 1241 add ecx, ebp
1248 ; 101 1242 ; 101
1249 sub edi, ecx 1243 sub edx, edi
1250 and esi, eax 1244 and eax, ecx
1251 and edi, ebx 1245 and edx, esi
1252 or edi, esi 1246 or edx, eax
1253 mov esi, DWORD PTR 56[esp] 1247 mov eax, DWORD PTR 52[esp]
1254 rol ebx, 10 1248 rol esi, 10
1255 lea ebp, DWORD PTR 1548603684[edi+ebp] 1249 lea ebp, DWORD PTR 1548603684[edx+ebp]
1256 mov edi, -1 1250 mov edx, -1
1257 add ebp, esi 1251 add ebp, eax
1258 mov esi, ebx 1252 mov eax, esi
1259 rol ebp, 8 1253 rol ebp, 8
1260 add ebp, edx 1254 add ebp, ebx
1261 ; 102 1255 ; 102
1262 sub edi, ebx 1256 sub edx, esi
1263 and esi, ebp 1257 and eax, ebp
1264 and edi, eax 1258 and edx, ecx
1265 or edi, esi 1259 or edx, eax
1266 mov esi, DWORD PTR 24[esp] 1260 mov eax, DWORD PTR 20[esp]
1267 rol eax, 10 1261 rol ecx, 10
1268 lea edx, DWORD PTR 1548603684[edi+edx] 1262 lea ebx, DWORD PTR 1548603684[edx+ebx]
1269 mov edi, -1 1263 mov edx, -1
1270 add edx, esi 1264 add ebx, eax
1271 mov esi, eax 1265 mov eax, ecx
1272 rol edx, 9 1266 rol ebx, 9
1273 add edx, ecx 1267 add ebx, edi
1274 ; 103 1268 ; 103
1275 sub edi, eax 1269 sub edx, ecx
1276 and esi, edx 1270 and eax, ebx
1277 and edi, ebp 1271 and edx, ebp
1278 or edi, esi 1272 or edx, eax
1279 mov esi, DWORD PTR 44[esp] 1273 mov eax, DWORD PTR 40[esp]
1280 rol ebp, 10 1274 rol ebp, 10
1281 lea ecx, DWORD PTR 1548603684[edi+ecx] 1275 lea edi, DWORD PTR 1548603684[edx+edi]
1282 mov edi, -1 1276 mov edx, -1
1283 add ecx, esi 1277 add edi, eax
1284 mov esi, ebp 1278 mov eax, ebp
1285 rol ecx, 11 1279 rol edi, 11
1286 add ecx, ebx 1280 add edi, esi
1287 ; 104 1281 ; 104
1288 sub edi, ebp 1282 sub edx, ebp
1289 and esi, ecx 1283 and eax, edi
1290 and edi, edx 1284 and edx, ebx
1291 or edi, esi 1285 or edx, eax
1292 mov esi, DWORD PTR 60[esp] 1286 mov eax, DWORD PTR 56[esp]
1293 rol edx, 10 1287 rol ebx, 10
1294 lea ebx, DWORD PTR 1548603684[edi+ebx] 1288 lea esi, DWORD PTR 1548603684[edx+esi]
1295 mov edi, -1 1289 mov edx, -1
1296 add ebx, esi 1290 add esi, eax
1297 mov esi, edx 1291 mov eax, ebx
1298 rol ebx, 7 1292 rol esi, 7
1299 add ebx, eax 1293 add esi, ecx
1300 ; 105 1294 ; 105
1301 sub edi, edx 1295 sub edx, ebx
1302 and esi, ebx 1296 and eax, esi
1303 and edi, ecx 1297 and edx, edi
1304 or edi, esi 1298 or edx, eax
1305 mov esi, DWORD PTR 64[esp] 1299 mov eax, DWORD PTR 60[esp]
1306 rol ecx, 10 1300 rol edi, 10
1307 lea eax, DWORD PTR 1548603684[edi+eax] 1301 lea ecx, DWORD PTR 1548603684[edx+ecx]
1308 mov edi, -1 1302 mov edx, -1
1309 add eax, esi 1303 add ecx, eax
1310 mov esi, ecx 1304 mov eax, edi
1311 rol eax, 7 1305 rol ecx, 7
1312 add eax, ebp 1306 add ecx, ebp
1313 ; 106 1307 ; 106
1314 sub edi, ecx 1308 sub edx, edi
1315 and esi, eax 1309 and eax, ecx
1316 and edi, ebx 1310 and edx, esi
1317 or edi, esi 1311 or edx, eax
1318 mov esi, DWORD PTR 36[esp] 1312 mov eax, DWORD PTR 32[esp]
1319 rol ebx, 10 1313 rol esi, 10
1320 lea ebp, DWORD PTR 1548603684[edi+ebp] 1314 lea ebp, DWORD PTR 1548603684[edx+ebp]
1321 mov edi, -1 1315 mov edx, -1
1322 add ebp, esi 1316 add ebp, eax
1323 mov esi, ebx 1317 mov eax, esi
1324 rol ebp, 12 1318 rol ebp, 12
1325 add ebp, edx 1319 add ebp, ebx
1326 ; 107 1320 ; 107
1327 sub edi, ebx 1321 sub edx, esi
1328 and esi, ebp 1322 and eax, ebp
1329 and edi, eax 1323 and edx, ecx
1330 or edi, esi 1324 or edx, eax
1331 mov esi, DWORD PTR 52[esp] 1325 mov eax, DWORD PTR 48[esp]
1332 rol eax, 10 1326 rol ecx, 10
1333 lea edx, DWORD PTR 1548603684[edi+edx] 1327 lea ebx, DWORD PTR 1548603684[edx+ebx]
1334 mov edi, -1 1328 mov edx, -1
1335 add edx, esi 1329 add ebx, eax
1336 mov esi, eax 1330 mov eax, ecx
1337 rol edx, 7 1331 rol ebx, 7
1338 add edx, ecx 1332 add ebx, edi
1339 ; 108 1333 ; 108
1340 sub edi, eax 1334 sub edx, ecx
1341 and esi, edx 1335 and eax, ebx
1342 and edi, ebp 1336 and edx, ebp
1343 or edi, esi 1337 or edx, eax
1344 mov esi, DWORD PTR 20[esp] 1338 mov eax, DWORD PTR 16[esp]
1345 rol ebp, 10 1339 rol ebp, 10
1346 lea ecx, DWORD PTR 1548603684[edi+ecx] 1340 lea edi, DWORD PTR 1548603684[edx+edi]
1347 mov edi, -1 1341 mov edx, -1
1348 add ecx, esi 1342 add edi, eax
1349 mov esi, ebp 1343 mov eax, ebp
1350 rol ecx, 6 1344 rol edi, 6
1351 add ecx, ebx 1345 add edi, esi
1352 ; 109 1346 ; 109
1353 sub edi, ebp 1347 sub edx, ebp
1354 and esi, ecx 1348 and eax, edi
1355 and edi, edx 1349 and edx, ebx
1356 or edi, esi 1350 or edx, eax
1357 mov esi, DWORD PTR 40[esp] 1351 mov eax, DWORD PTR 36[esp]
1358 rol edx, 10 1352 rol ebx, 10
1359 lea ebx, DWORD PTR 1548603684[edi+ebx] 1353 lea esi, DWORD PTR 1548603684[edx+esi]
1360 mov edi, -1 1354 mov edx, -1
1361 add ebx, esi 1355 add esi, eax
1362 mov esi, edx 1356 mov eax, ebx
1363 rol ebx, 15 1357 rol esi, 15
1364 add ebx, eax 1358 add esi, ecx
1365 ; 110 1359 ; 110
1366 sub edi, edx 1360 sub edx, ebx
1367 and esi, ebx 1361 and eax, esi
1368 and edi, ecx 1362 and edx, edi
1369 or edi, esi 1363 or edx, eax
1370 mov esi, DWORD PTR 8[esp] 1364 mov eax, DWORD PTR 4[esp]
1371 rol ecx, 10 1365 rol edi, 10
1372 lea eax, DWORD PTR 1548603684[edi+eax] 1366 lea ecx, DWORD PTR 1548603684[edx+ecx]
1373 mov edi, -1 1367 mov edx, -1
1374 add eax, esi 1368 add ecx, eax
1375 mov esi, ecx 1369 mov eax, edi
1376 rol eax, 13 1370 rol ecx, 13
1377 add eax, ebp 1371 add ecx, ebp
1378 ; 111 1372 ; 111
1379 sub edi, ecx 1373 sub edx, edi
1380 and esi, eax 1374 and eax, ecx
1381 and edi, ebx 1375 and edx, esi
1382 or edi, esi 1376 or edx, eax
1383 mov esi, DWORD PTR 12[esp] 1377 mov eax, DWORD PTR 8[esp]
1384 rol ebx, 10 1378 rol esi, 10
1385 lea ebp, DWORD PTR 1548603684[edi+ebp] 1379 lea ebp, DWORD PTR 1548603684[edx+ebp]
1386 mov edi, -1 1380 mov edx, -1
1387 add ebp, esi 1381 add ebp, eax
1388 sub edi, eax 1382 sub edx, ecx
1389 rol ebp, 11 1383 rol ebp, 11
1390 add ebp, edx 1384 add ebp, ebx
1391 ; 112 1385 ; 112
1392 mov esi, DWORD PTR 64[esp] 1386 mov eax, DWORD PTR 60[esp]
1393 or edi, ebp 1387 or edx, ebp
1394 add edx, esi 1388 add ebx, eax
1395 xor edi, ebx 1389 xor edx, esi
1396 mov esi, -1 1390 mov eax, -1
1397 rol eax, 10 1391 rol ecx, 10
1398 lea edx, DWORD PTR 1836072691[edi*1+edx] 1392 lea ebx, DWORD PTR 1836072691[edx*1+ebx]
1399 sub esi, ebp 1393 sub eax, ebp
1400 rol edx, 9 1394 rol ebx, 9
1401 add edx, ecx 1395 add ebx, edi
1402 ; 113 1396 ; 113
1403 mov edi, DWORD PTR 24[esp] 1397 mov edx, DWORD PTR 20[esp]
1404 or esi, edx 1398 or eax, ebx
1405 add ecx, edi 1399 add edi, edx
1406 xor esi, eax 1400 xor eax, ecx
1407 mov edi, -1 1401 mov edx, -1
1408 rol ebp, 10 1402 rol ebp, 10
1409 lea ecx, DWORD PTR 1836072691[esi*1+ecx] 1403 lea edi, DWORD PTR 1836072691[eax*1+edi]
1410 sub edi, edx 1404 sub edx, ebx
1411 rol ecx, 7 1405 rol edi, 7
1412 add ecx, ebx 1406 add edi, esi
1413 ; 114 1407 ; 114
1414 mov esi, DWORD PTR 8[esp] 1408 mov eax, DWORD PTR 4[esp]
1415 or edi, ecx 1409 or edx, edi
1416 add ebx, esi 1410 add esi, eax
1417 xor edi, ebp 1411 xor edx, ebp
1418 mov esi, -1 1412 mov eax, -1
1419 rol edx, 10 1413 rol ebx, 10
1420 lea ebx, DWORD PTR 1836072691[edi*1+ebx] 1414 lea esi, DWORD PTR 1836072691[edx*1+esi]
1421 sub esi, ecx 1415 sub eax, edi
1422 rol ebx, 15 1416 rol esi, 15
1423 add ebx, eax 1417 add esi, ecx
1424 ; 115 1418 ; 115
1425 mov edi, DWORD PTR 16[esp] 1419 mov edx, DWORD PTR 12[esp]
1426 or esi, ebx 1420 or eax, esi
1427 add eax, edi 1421 add ecx, edx
1428 xor esi, edx 1422 xor eax, ebx
1429 mov edi, -1 1423 mov edx, -1
1430 rol ecx, 10 1424 rol edi, 10
1431 lea eax, DWORD PTR 1836072691[esi*1+eax] 1425 lea ecx, DWORD PTR 1836072691[eax*1+ecx]
1432 sub edi, ebx 1426 sub edx, esi
1433 rol eax, 11 1427 rol ecx, 11
1434 add eax, ebp 1428 add ecx, ebp
1435 ; 116 1429 ; 116
1436 mov esi, DWORD PTR 32[esp] 1430 mov eax, DWORD PTR 28[esp]
1437 or edi, eax 1431 or edx, ecx
1438 add ebp, esi 1432 add ebp, eax
1439 xor edi, ecx 1433 xor edx, edi
1440 mov esi, -1 1434 mov eax, -1
1441 rol ebx, 10 1435 rol esi, 10
1442 lea ebp, DWORD PTR 1836072691[edi*1+ebp] 1436 lea ebp, DWORD PTR 1836072691[edx*1+ebp]
1443 sub esi, eax 1437 sub eax, ecx
1444 rol ebp, 8 1438 rol ebp, 8
1445 add ebp, edx 1439 add ebp, ebx
1446 ; 117 1440 ; 117
1447 mov edi, DWORD PTR 60[esp] 1441 mov edx, DWORD PTR 56[esp]
1448 or esi, ebp 1442 or eax, ebp
1449 add edx, edi 1443 add ebx, edx
1450 xor esi, ebx 1444 xor eax, esi
1451 mov edi, -1 1445 mov edx, -1
1452 rol eax, 10 1446 rol ecx, 10
1453 lea edx, DWORD PTR 1836072691[esi*1+edx] 1447 lea ebx, DWORD PTR 1836072691[eax*1+ebx]
1454 sub edi, ebp 1448 sub edx, ebp
1455 rol edx, 6 1449 rol ebx, 6
1456 add edx, ecx 1450 add ebx, edi
1457 ; 118 1451 ; 118
1458 mov esi, DWORD PTR 28[esp] 1452 mov eax, DWORD PTR 24[esp]
1459 or edi, edx 1453 or edx, ebx
1460 add ecx, esi 1454 add edi, eax
1461 xor edi, eax 1455 xor edx, ecx
1462 mov esi, -1 1456 mov eax, -1
1463 rol ebp, 10 1457 rol ebp, 10
1464 lea ecx, DWORD PTR 1836072691[edi*1+ecx] 1458 lea edi, DWORD PTR 1836072691[edx*1+edi]
1465 sub esi, edx 1459 sub eax, ebx
1466 rol ecx, 6 1460 rol edi, 6
1467 add ecx, ebx 1461 add edi, esi
1468 ; 119 1462 ; 119
1469 mov edi, DWORD PTR 40[esp] 1463 mov edx, DWORD PTR 36[esp]
1470 or esi, ecx 1464 or eax, edi
1471 add ebx, edi 1465 add esi, edx
1472 xor esi, ebp 1466 xor eax, ebp
1473 mov edi, -1 1467 mov edx, -1
1474 rol edx, 10 1468 rol ebx, 10
1475 lea ebx, DWORD PTR 1836072691[esi*1+ebx] 1469 lea esi, DWORD PTR 1836072691[eax*1+esi]
1476 sub edi, ecx 1470 sub edx, edi
1477 rol ebx, 14 1471 rol esi, 14
1478 add ebx, eax 1472 add esi, ecx
1479 ; 120 1473 ; 120
1480 mov esi, DWORD PTR 48[esp] 1474 mov eax, DWORD PTR 44[esp]
1481 or edi, ebx 1475 or edx, esi
1482 add eax, esi 1476 add ecx, eax
1483 xor edi, edx 1477 xor edx, ebx
1484 mov esi, -1 1478 mov eax, -1
1485 rol ecx, 10 1479 rol edi, 10
1486 lea eax, DWORD PTR 1836072691[edi*1+eax] 1480 lea ecx, DWORD PTR 1836072691[edx*1+ecx]
1487 sub esi, ebx 1481 sub eax, esi
1488 rol eax, 12 1482 rol ecx, 12
1489 add eax, ebp 1483 add ecx, ebp
1490 ; 121 1484 ; 121
1491 mov edi, DWORD PTR 36[esp] 1485 mov edx, DWORD PTR 32[esp]
1492 or esi, eax 1486 or eax, ecx
1493 add ebp, edi
1494 xor esi, ecx
1495 mov edi, -1
1496 rol ebx, 10
1497 lea ebp, DWORD PTR 1836072691[esi*1+ebp]
1498 sub edi, eax
1499 rol ebp, 13
1500 add ebp, edx 1487 add ebp, edx
1488 xor eax, edi
1489 mov edx, -1
1490 rol esi, 10
1491 lea ebp, DWORD PTR 1836072691[eax*1+ebp]
1492 sub edx, ecx
1493 rol ebp, 13
1494 add ebp, ebx
1501 ; 122 1495 ; 122
1502 mov esi, DWORD PTR 52[esp] 1496 mov eax, DWORD PTR 48[esp]
1503 or edi, ebp 1497 or edx, ebp
1504 add edx, esi 1498 add ebx, eax
1505 xor edi, ebx 1499 xor edx, esi
1506 mov esi, -1 1500 mov eax, -1
1507 rol eax, 10 1501 rol ecx, 10
1508 lea edx, DWORD PTR 1836072691[edi*1+edx] 1502 lea ebx, DWORD PTR 1836072691[edx*1+ebx]
1509 sub esi, ebp 1503 sub eax, ebp
1510 rol edx, 5 1504 rol ebx, 5
1511 add edx, ecx 1505 add ebx, edi
1512 ; 123 1506 ; 123
1513 mov edi, DWORD PTR 12[esp] 1507 mov edx, DWORD PTR 8[esp]
1514 or esi, edx 1508 or eax, ebx
1515 add ecx, edi 1509 add edi, edx
1516 xor esi, eax 1510 xor eax, ecx
1517 mov edi, -1 1511 mov edx, -1
1518 rol ebp, 10 1512 rol ebp, 10
1519 lea ecx, DWORD PTR 1836072691[esi*1+ecx] 1513 lea edi, DWORD PTR 1836072691[eax*1+edi]
1520 sub edi, edx 1514 sub edx, ebx
1521 rol ecx, 14 1515 rol edi, 14
1522 add ecx, ebx 1516 add edi, esi
1523 ; 124 1517 ; 124
1524 mov esi, DWORD PTR 44[esp] 1518 mov eax, DWORD PTR 40[esp]
1525 or edi, ecx 1519 or edx, edi
1526 add ebx, esi 1520 add esi, eax
1527 xor edi, ebp 1521 xor edx, ebp
1528 mov esi, -1 1522 mov eax, -1
1529 rol edx, 10 1523 rol ebx, 10
1530 lea ebx, DWORD PTR 1836072691[edi*1+ebx] 1524 lea esi, DWORD PTR 1836072691[edx*1+esi]
1531 sub esi, ecx 1525 sub eax, edi
1532 rol ebx, 13 1526 rol esi, 13
1533 add ebx, eax 1527 add esi, ecx
1534 ; 125 1528 ; 125
1535 mov edi, DWORD PTR 4[esp] 1529 mov edx, DWORD PTR [esp]
1536 or esi, ebx 1530 or eax, esi
1537 add eax, edi 1531 add ecx, edx
1538 xor esi, edx 1532 xor eax, ebx
1539 mov edi, -1 1533 mov edx, -1
1540 rol ecx, 10 1534 rol edi, 10
1541 lea eax, DWORD PTR 1836072691[esi*1+eax] 1535 lea ecx, DWORD PTR 1836072691[eax*1+ecx]
1542 sub edi, ebx 1536 sub edx, esi
1543 rol eax, 13 1537 rol ecx, 13
1544 add eax, ebp 1538 add ecx, ebp
1545 ; 126 1539 ; 126
1546 mov esi, DWORD PTR 20[esp] 1540 mov eax, DWORD PTR 16[esp]
1547 or edi, eax 1541 or edx, ecx
1548 add ebp, esi 1542 add ebp, eax
1549 xor edi, ecx 1543 xor edx, edi
1550 mov esi, -1 1544 mov eax, -1
1551 rol ebx, 10 1545 rol esi, 10
1552 lea ebp, DWORD PTR 1836072691[edi*1+ebp] 1546 lea ebp, DWORD PTR 1836072691[edx*1+ebp]
1553 sub esi, eax 1547 sub eax, ecx
1554 rol ebp, 7 1548 rol ebp, 7
1555 add ebp, edx 1549 add ebp, ebx
1556 ; 127 1550 ; 127
1557 mov edi, DWORD PTR 56[esp] 1551 mov edx, DWORD PTR 52[esp]
1558 or esi, ebp 1552 or eax, ebp
1559 add edx, edi 1553 add ebx, edx
1560 xor esi, ebx 1554 xor eax, esi
1561 mov edi, DWORD PTR 36[esp] 1555 mov edx, DWORD PTR 32[esp]
1562 rol eax, 10 1556 rol ecx, 10
1563 lea edx, DWORD PTR 1836072691[esi*1+edx] 1557 lea ebx, DWORD PTR 1836072691[eax*1+ebx]
1564 mov esi, -1 1558 mov eax, -1
1565 rol edx, 5 1559 rol ebx, 5
1566 add edx, ecx 1560 add ebx, edi
1567 ; 128 1561 ; 128
1568 add ecx, edi 1562 add edi, edx
1569 mov edi, ebp 1563 mov edx, ebp
1570 sub esi, edx 1564 sub eax, ebx
1571 and edi, edx 1565 and edx, ebx
1572 and esi, eax 1566 and eax, ecx
1573 or edi, esi 1567 or edx, eax
1574 mov esi, DWORD PTR 28[esp] 1568 mov eax, DWORD PTR 24[esp]
1575 rol ebp, 10 1569 rol ebp, 10
1576 lea ecx, DWORD PTR 2053994217[edi*1+ecx] 1570 lea edi, DWORD PTR 2053994217[edx*1+edi]
1577 mov edi, -1 1571 mov edx, -1
1578 rol ecx, 15 1572 rol edi, 15
1579 add ecx, ebx 1573 add edi, esi
1580 ; 129 1574 ; 129
1581 add ebx, esi 1575 add esi, eax
1582 mov esi, edx 1576 mov eax, ebx
1583 sub edi, ecx 1577 sub edx, edi
1584 and esi, ecx 1578 and eax, edi
1585 and edi, ebp 1579 and edx, ebp
1586 or esi, edi 1580 or eax, edx
1587 mov edi, DWORD PTR 20[esp] 1581 mov edx, DWORD PTR 16[esp]
1588 rol edx, 10 1582 rol ebx, 10
1589 lea ebx, DWORD PTR 2053994217[esi*1+ebx] 1583 lea esi, DWORD PTR 2053994217[eax*1+esi]
1590 mov esi, -1 1584 mov eax, -1
1591 rol ebx, 5 1585 rol esi, 5
1592 add ebx, eax 1586 add esi, ecx
1593 ; 130 1587 ; 130
1594 add eax, edi 1588 add ecx, edx
1595 mov edi, ecx 1589 mov edx, edi
1596 sub esi, ebx 1590 sub eax, esi
1597 and edi, ebx 1591 and edx, esi
1598 and esi, edx 1592 and eax, ebx
1599 or edi, esi 1593 or edx, eax
1600 mov esi, DWORD PTR 8[esp] 1594 mov eax, DWORD PTR 4[esp]
1601 rol ecx, 10 1595 rol edi, 10
1602 lea eax, DWORD PTR 2053994217[edi*1+eax] 1596 lea ecx, DWORD PTR 2053994217[edx*1+ecx]
1603 mov edi, -1 1597 mov edx, -1
1604 rol eax, 8 1598 rol ecx, 8
1605 add eax, ebp 1599 add ecx, ebp
1606 ; 131 1600 ; 131
1607 add ebp, esi 1601 add ebp, eax
1608 mov esi, ebx 1602 mov eax, esi
1609 sub edi, eax 1603 sub edx, ecx
1610 and esi, eax 1604 and eax, ecx
1611 and edi, ecx 1605 and edx, edi
1612 or esi, edi 1606 or eax, edx
1613 mov edi, DWORD PTR 16[esp] 1607 mov edx, DWORD PTR 12[esp]
1614 rol ebx, 10 1608 rol esi, 10
1615 lea ebp, DWORD PTR 2053994217[esi*1+ebp] 1609 lea ebp, DWORD PTR 2053994217[eax*1+ebp]
1616 mov esi, -1 1610 mov eax, -1
1617 rol ebp, 11 1611 rol ebp, 11
1618 add ebp, edx 1612 add ebp, ebx
1619 ; 132 1613 ; 132
1620 add edx, edi 1614 add ebx, edx
1621 mov edi, eax 1615 mov edx, ecx
1622 sub esi, ebp 1616 sub eax, ebp
1623 and edi, ebp 1617 and edx, ebp
1624 and esi, ebx 1618 and eax, esi
1625 or edi, esi 1619 or edx, eax
1626 mov esi, DWORD PTR 48[esp] 1620 mov eax, DWORD PTR 44[esp]
1627 rol eax, 10 1621 rol ecx, 10
1628 lea edx, DWORD PTR 2053994217[edi*1+edx] 1622 lea ebx, DWORD PTR 2053994217[edx*1+ebx]
1629 mov edi, -1 1623 mov edx, -1
1630 rol edx, 14 1624 rol ebx, 14
1631 add edx, ecx 1625 add ebx, edi
1632 ; 133 1626 ; 133
1633 add ecx, esi 1627 add edi, eax
1634 mov esi, ebp 1628 mov eax, ebp
1635 sub edi, edx 1629 sub edx, ebx
1636 and esi, edx 1630 and eax, ebx
1637 and edi, eax 1631 and edx, ecx
1638 or esi, edi 1632 or eax, edx
1639 mov edi, DWORD PTR 64[esp] 1633 mov edx, DWORD PTR 60[esp]
1640 rol ebp, 10 1634 rol ebp, 10
1641 lea ecx, DWORD PTR 2053994217[esi*1+ecx] 1635 lea edi, DWORD PTR 2053994217[eax*1+edi]
1642 mov esi, -1 1636 mov eax, -1
1643 rol ecx, 14 1637 rol edi, 14
1644 add ecx, ebx 1638 add edi, esi
1645 ; 134 1639 ; 134
1646 add ebx, edi 1640 add esi, edx
1647 mov edi, edx 1641 mov edx, ebx
1648 sub esi, ecx 1642 sub eax, edi
1649 and edi, ecx 1643 and edx, edi
1650 and esi, ebp 1644 and eax, ebp
1651 or edi, esi 1645 or edx, eax
1652 mov esi, DWORD PTR 4[esp] 1646 mov eax, DWORD PTR [esp]
1653 rol edx, 10 1647 rol ebx, 10
1654 lea ebx, DWORD PTR 2053994217[edi*1+ebx] 1648 lea esi, DWORD PTR 2053994217[edx*1+esi]
1655 mov edi, -1 1649 mov edx, -1
1656 rol ebx, 6 1650 rol esi, 6
1657 add ebx, eax 1651 add esi, ecx
1658 ; 135 1652 ; 135
1659 add eax, esi 1653 add ecx, eax
1660 mov esi, ecx 1654 mov eax, edi
1661 sub edi, ebx 1655 sub edx, esi
1662 and esi, ebx 1656 and eax, esi
1663 and edi, edx 1657 and edx, ebx
1664 or esi, edi 1658 or eax, edx
1665 mov edi, DWORD PTR 24[esp] 1659 mov edx, DWORD PTR 20[esp]
1666 rol ecx, 10 1660 rol edi, 10
1667 lea eax, DWORD PTR 2053994217[esi*1+eax] 1661 lea ecx, DWORD PTR 2053994217[eax*1+ecx]
1668 mov esi, -1 1662 mov eax, -1
1669 rol eax, 14 1663 rol ecx, 14
1670 add eax, ebp 1664 add ecx, ebp
1671 ; 136 1665 ; 136
1672 add ebp, edi
1673 mov edi, ebx
1674 sub esi, eax
1675 and edi, eax
1676 and esi, ecx
1677 or edi, esi
1678 mov esi, DWORD PTR 52[esp]
1679 rol ebx, 10
1680 lea ebp, DWORD PTR 2053994217[edi*1+ebp]
1681 mov edi, -1
1682 rol ebp, 6
1683 add ebp, edx 1666 add ebp, edx
1667 mov edx, esi
1668 sub eax, ecx
1669 and edx, ecx
1670 and eax, edi
1671 or edx, eax
1672 mov eax, DWORD PTR 48[esp]
1673 rol esi, 10
1674 lea ebp, DWORD PTR 2053994217[edx*1+ebp]
1675 mov edx, -1
1676 rol ebp, 6
1677 add ebp, ebx
1684 ; 137 1678 ; 137
1685 add edx, esi 1679 add ebx, eax
1686 mov esi, eax 1680 mov eax, ecx
1687 sub edi, ebp 1681 sub edx, ebp
1688 and esi, ebp 1682 and eax, ebp
1689 and edi, ebx 1683 and edx, esi
1690 or esi, edi 1684 or eax, edx
1691 mov edi, DWORD PTR 12[esp] 1685 mov edx, DWORD PTR 8[esp]
1692 rol eax, 10 1686 rol ecx, 10
1693 lea edx, DWORD PTR 2053994217[esi*1+edx] 1687 lea ebx, DWORD PTR 2053994217[eax*1+ebx]
1694 mov esi, -1 1688 mov eax, -1
1695 rol edx, 9 1689 rol ebx, 9
1696 add edx, ecx 1690 add ebx, edi
1697 ; 138 1691 ; 138
1698 add ecx, edi 1692 add edi, edx
1699 mov edi, ebp 1693 mov edx, ebp
1700 sub esi, edx 1694 sub eax, ebx
1701 and edi, edx 1695 and edx, ebx
1702 and esi, eax 1696 and eax, ecx
1703 or edi, esi 1697 or edx, eax
1704 mov esi, DWORD PTR 56[esp] 1698 mov eax, DWORD PTR 52[esp]
1705 rol ebp, 10 1699 rol ebp, 10
1706 lea ecx, DWORD PTR 2053994217[edi*1+ecx] 1700 lea edi, DWORD PTR 2053994217[edx*1+edi]
1707 mov edi, -1 1701 mov edx, -1
1708 rol ecx, 12 1702 rol edi, 12
1709 add ecx, ebx 1703 add edi, esi
1710 ; 139 1704 ; 139
1711 add ebx, esi 1705 add esi, eax
1712 mov esi, edx 1706 mov eax, ebx
1713 sub edi, ecx 1707 sub edx, edi
1714 and esi, ecx 1708 and eax, edi
1715 and edi, ebp 1709 and edx, ebp
1716 or esi, edi 1710 or eax, edx
1717 mov edi, DWORD PTR 40[esp] 1711 mov edx, DWORD PTR 36[esp]
1718 rol edx, 10 1712 rol ebx, 10
1719 lea ebx, DWORD PTR 2053994217[esi*1+ebx] 1713 lea esi, DWORD PTR 2053994217[eax*1+esi]
1720 mov esi, -1 1714 mov eax, -1
1721 rol ebx, 9 1715 rol esi, 9
1722 add ebx, eax 1716 add esi, ecx
1723 ; 140 1717 ; 140
1724 add eax, edi 1718 add ecx, edx
1725 mov edi, ecx 1719 mov edx, edi
1726 sub esi, ebx 1720 sub eax, esi
1727 and edi, ebx 1721 and edx, esi
1728 and esi, edx 1722 and eax, ebx
1729 or edi, esi 1723 or edx, eax
1730 mov esi, DWORD PTR 32[esp] 1724 mov eax, DWORD PTR 28[esp]
1731 rol ecx, 10 1725 rol edi, 10
1732 lea eax, DWORD PTR 2053994217[edi*1+eax] 1726 lea ecx, DWORD PTR 2053994217[edx*1+ecx]
1733 mov edi, -1 1727 mov edx, -1
1734 rol eax, 12 1728 rol ecx, 12
1735 add eax, ebp 1729 add ecx, ebp
1736 ; 141 1730 ; 141
1737 add ebp, esi 1731 add ebp, eax
1738 mov esi, ebx 1732 mov eax, esi
1739 sub edi, eax 1733 sub edx, ecx
1740 and esi, eax 1734 and eax, ecx
1741 and edi, ecx 1735 and edx, edi
1742 or esi, edi 1736 or eax, edx
1743 mov edi, DWORD PTR 44[esp] 1737 mov edx, DWORD PTR 40[esp]
1744 rol ebx, 10 1738 rol esi, 10
1745 lea ebp, DWORD PTR 2053994217[esi*1+ebp] 1739 lea ebp, DWORD PTR 2053994217[eax*1+ebp]
1746 mov esi, -1 1740 mov eax, -1
1747 rol ebp, 5 1741 rol ebp, 5
1748 add ebp, edx 1742 add ebp, ebx
1749 ; 142 1743 ; 142
1750 add edx, edi 1744 add ebx, edx
1751 mov edi, eax 1745 mov edx, ecx
1752 sub esi, ebp 1746 sub eax, ebp
1753 and edi, ebp 1747 and edx, ebp
1754 and esi, ebx 1748 and eax, esi
1755 or edi, esi 1749 or edx, eax
1756 mov esi, DWORD PTR 60[esp] 1750 mov eax, DWORD PTR 56[esp]
1757 rol eax, 10 1751 rol ecx, 10
1758 lea edx, DWORD PTR 2053994217[edi*1+edx] 1752 lea ebx, DWORD PTR 2053994217[edx*1+ebx]
1759 mov edi, -1 1753 mov edx, -1
1760 rol edx, 15 1754 rol ebx, 15
1761 add edx, ecx 1755 add ebx, edi
1762 ; 143 1756 ; 143
1763 add ecx, esi 1757 add edi, eax
1764 mov esi, ebp 1758 mov eax, ebp
1765 sub edi, edx 1759 sub edx, ebx
1766 and esi, edx 1760 and eax, ebx
1767 and edi, eax 1761 and edx, ecx
1768 or edi, esi 1762 or edx, eax
1769 mov esi, edx 1763 mov eax, ebx
1770 rol ebp, 10 1764 rol ebp, 10
1771 lea ecx, DWORD PTR 2053994217[edi*1+ecx] 1765 lea edi, DWORD PTR 2053994217[edx*1+edi]
1772 xor esi, ebp 1766 xor eax, ebp
1773 rol ecx, 8 1767 rol edi, 8
1774 add ecx, ebx 1768 add edi, esi
1775 ; 144 1769 ; 144
1776 mov edi, DWORD PTR 52[esp] 1770 mov edx, DWORD PTR 48[esp]
1777 xor esi, ecx 1771 xor eax, edi
1778 add ebx, edi 1772 add esi, edx
1779 rol edx, 10 1773 rol ebx, 10
1780 add ebx, esi 1774 add esi, eax
1781 mov esi, ecx 1775 mov eax, edi
1782 rol ebx, 8 1776 rol esi, 8
1783 add ebx, eax 1777 add esi, ecx
1784 ; 145 1778 ; 145
1785 xor esi, edx 1779 xor eax, ebx
1786 mov edi, DWORD PTR 64[esp] 1780 mov edx, DWORD PTR 60[esp]
1787 xor esi, ebx 1781 xor eax, esi
1788 add eax, esi 1782 add ecx, eax
1789 mov esi, ebx 1783 mov eax, esi
1790 rol ecx, 10 1784 rol edi, 10
1791 add eax, edi 1785 add ecx, edx
1792 xor esi, ecx 1786 xor eax, edi
1793 rol eax, 5 1787 rol ecx, 5
1794 add eax, ebp 1788 add ecx, ebp
1795 ; 146 1789 ; 146
1796 mov edi, DWORD PTR 44[esp] 1790 mov edx, DWORD PTR 40[esp]
1797 xor esi, eax 1791 xor eax, ecx
1798 add ebp, edi
1799 rol ebx, 10
1800 add ebp, esi
1801 mov esi, eax
1802 rol ebp, 12
1803 add ebp, edx 1792 add ebp, edx
1793 rol esi, 10
1794 add ebp, eax
1795 mov eax, ecx
1796 rol ebp, 12
1797 add ebp, ebx
1804 ; 147 1798 ; 147
1805 xor esi, ebx 1799 xor eax, esi
1806 mov edi, DWORD PTR 20[esp] 1800 mov edx, DWORD PTR 16[esp]
1807 xor esi, ebp 1801 xor eax, ebp
1808 add edx, esi 1802 add ebx, eax
1809 mov esi, ebp 1803 mov eax, ebp
1810 rol eax, 10 1804 rol ecx, 10
1811 add edx, edi 1805 add ebx, edx
1812 xor esi, eax 1806 xor eax, ecx
1813 rol edx, 9 1807 rol ebx, 9
1814 add edx, ecx 1808 add ebx, edi
1815 ; 148 1809 ; 148
1816 mov edi, DWORD PTR 8[esp] 1810 mov edx, DWORD PTR 4[esp]
1817 xor esi, edx 1811 xor eax, ebx
1818 add ecx, edi 1812 add edi, edx
1819 rol ebp, 10 1813 rol ebp, 10
1820 add ecx, esi 1814 add edi, eax
1821 mov esi, edx 1815 mov eax, ebx
1822 rol ecx, 12 1816 rol edi, 12
1823 add ecx, ebx 1817 add edi, esi
1824 ; 149 1818 ; 149
1825 xor esi, ebp 1819 xor eax, ebp
1826 mov edi, DWORD PTR 24[esp] 1820 mov edx, DWORD PTR 20[esp]
1827 xor esi, ecx 1821 xor eax, edi
1828 add ebx, esi 1822 add esi, eax
1829 mov esi, ecx 1823 mov eax, edi
1830 rol edx, 10 1824 rol ebx, 10
1831 add ebx, edi 1825 add esi, edx
1832 xor esi, edx 1826 xor eax, ebx
1833 rol ebx, 5 1827 rol esi, 5
1834 add ebx, eax 1828 add esi, ecx
1835 ; 150 1829 ; 150
1836 mov edi, DWORD PTR 36[esp] 1830 mov edx, DWORD PTR 32[esp]
1837 xor esi, ebx 1831 xor eax, esi
1838 add eax, edi 1832 add ecx, edx
1839 rol ecx, 10 1833 rol edi, 10
1840 add eax, esi 1834 add ecx, eax
1841 mov esi, ebx 1835 mov eax, esi
1842 rol eax, 14 1836 rol ecx, 14
1843 add eax, ebp 1837 add ecx, ebp
1844 ; 151 1838 ; 151
1845 xor esi, ecx 1839 xor eax, edi
1846 mov edi, DWORD PTR 32[esp] 1840 mov edx, DWORD PTR 28[esp]
1847 xor esi, eax 1841 xor eax, ecx
1848 add ebp, esi 1842 add ebp, eax
1849 mov esi, eax 1843 mov eax, ecx
1850 rol ebx, 10 1844 rol esi, 10
1851 add ebp, edi
1852 xor esi, ebx
1853 rol ebp, 6
1854 add ebp, edx 1845 add ebp, edx
1846 xor eax, esi
1847 rol ebp, 6
1848 add ebp, ebx
1855 ; 152 1849 ; 152
1856 mov edi, DWORD PTR 28[esp] 1850 mov edx, DWORD PTR 24[esp]
1857 xor esi, ebp 1851 xor eax, ebp
1858 add edx, edi 1852 add ebx, edx
1859 rol eax, 10 1853 rol ecx, 10
1860 add edx, esi 1854 add ebx, eax
1861 mov esi, ebp 1855 mov eax, ebp
1862 rol edx, 8 1856 rol ebx, 8
1863 add edx, ecx 1857 add ebx, edi
1864 ; 153 1858 ; 153
1865 xor esi, eax 1859 xor eax, ecx
1866 mov edi, DWORD PTR 12[esp] 1860 mov edx, DWORD PTR 8[esp]
1867 xor esi, edx 1861 xor eax, ebx
1868 add ecx, esi 1862 add edi, eax
1869 mov esi, edx 1863 mov eax, ebx
1870 rol ebp, 10 1864 rol ebp, 10
1871 add ecx, edi 1865 add edi, edx
1872 xor esi, ebp 1866 xor eax, ebp
1873 rol ecx, 13 1867 rol edi, 13
1874 add ecx, ebx 1868 add edi, esi
1875 ; 154 1869 ; 154
1876 mov edi, DWORD PTR 56[esp] 1870 mov edx, DWORD PTR 52[esp]
1877 xor esi, ecx 1871 xor eax, edi
1878 add ebx, edi 1872 add esi, edx
1879 rol edx, 10 1873 rol ebx, 10
1880 add ebx, esi 1874 add esi, eax
1881 mov esi, ecx 1875 mov eax, edi
1882 rol ebx, 6 1876 rol esi, 6
1883 add ebx, eax 1877 add esi, ecx
1884 ; 155 1878 ; 155
1885 xor esi, edx 1879 xor eax, ebx
1886 mov edi, DWORD PTR 60[esp] 1880 mov edx, DWORD PTR 56[esp]
1887 xor esi, ebx 1881 xor eax, esi
1888 add eax, esi 1882 add ecx, eax
1889 mov esi, ebx 1883 mov eax, esi
1890 rol ecx, 10 1884 rol edi, 10
1891 add eax, edi 1885 add ecx, edx
1892 xor esi, ecx 1886 xor eax, edi
1893 rol eax, 5 1887 rol ecx, 5
1894 add eax, ebp 1888 add ecx, ebp
1895 ; 156 1889 ; 156
1896 mov edi, DWORD PTR 4[esp] 1890 mov edx, DWORD PTR [esp]
1897 xor esi, eax 1891 xor eax, ecx
1898 add ebp, edi
1899 rol ebx, 10
1900 add ebp, esi
1901 mov esi, eax
1902 rol ebp, 15
1903 add ebp, edx 1892 add ebp, edx
1893 rol esi, 10
1894 add ebp, eax
1895 mov eax, ecx
1896 rol ebp, 15
1897 add ebp, ebx
1904 ; 157 1898 ; 157
1905 xor esi, ebx 1899 xor eax, esi
1906 mov edi, DWORD PTR 16[esp] 1900 mov edx, DWORD PTR 12[esp]
1907 xor esi, ebp 1901 xor eax, ebp
1908 add edx, esi 1902 add ebx, eax
1909 mov esi, ebp 1903 mov eax, ebp
1910 rol eax, 10 1904 rol ecx, 10
1911 add edx, edi 1905 add ebx, edx
1912 xor esi, eax 1906 xor eax, ecx
1913 rol edx, 13 1907 rol ebx, 13
1914 add edx, ecx 1908 add ebx, edi
1915 ; 158 1909 ; 158
1916 mov edi, DWORD PTR 40[esp] 1910 mov edx, DWORD PTR 36[esp]
1917 xor esi, edx 1911 xor eax, ebx
1918 add ecx, edi 1912 add edi, edx
1919 rol ebp, 10 1913 rol ebp, 10
1920 add ecx, esi 1914 add edi, eax
1921 mov esi, edx 1915 mov eax, ebx
1922 rol ecx, 11 1916 rol edi, 11
1923 add ecx, ebx 1917 add edi, esi
1924 ; 159 1918 ; 159
1925 xor esi, ebp 1919 xor eax, ebp
1926 mov edi, DWORD PTR 48[esp] 1920 mov edx, DWORD PTR 44[esp]
1927 xor esi, ecx 1921 xor eax, edi
1928 add ebx, esi 1922 add esi, eax
1929 rol edx, 10 1923 rol ebx, 10
1930 add ebx, edi 1924 add esi, edx
1931 mov edi, DWORD PTR 108[esp] 1925 mov edx, DWORD PTR 128[esp]
1932 rol ebx, 11 1926 rol esi, 11
1927 add esi, ecx
1928 mov eax, DWORD PTR 4[edx]
1933 add ebx, eax 1929 add ebx, eax
1934 mov esi, DWORD PTR 4[edi] 1930 mov eax, DWORD PTR 72[esp]
1935 add edx, esi 1931 add ebx, eax
1936 mov esi, DWORD PTR 76[esp] 1932 mov eax, DWORD PTR 8[edx]
1937 add edx, esi 1933 add ebp, eax
1938 mov esi, DWORD PTR 8[edi] 1934 mov eax, DWORD PTR 76[esp]
1939 add ebp, esi 1935 add ebp, eax
1940 mov esi, DWORD PTR 80[esp] 1936 mov eax, DWORD PTR 12[edx]
1941 add ebp, esi 1937 add ecx, eax
1942 mov esi, DWORD PTR 12[edi] 1938 mov eax, DWORD PTR 80[esp]
1943 add eax, esi 1939 add ecx, eax
1944 mov esi, DWORD PTR 84[esp] 1940 mov eax, DWORD PTR 16[edx]
1945 add eax, esi 1941 add esi, eax
1946 mov esi, DWORD PTR 16[edi] 1942 mov eax, DWORD PTR 64[esp]
1947 add ebx, esi 1943 add esi, eax
1948 mov esi, DWORD PTR 68[esp] 1944 mov eax, DWORD PTR [edx]
1949 add ebx, esi 1945 add edi, eax
1950 mov esi, DWORD PTR [edi] 1946 mov eax, DWORD PTR 68[esp]
1951 add ecx, esi 1947 add edi, eax
1952 mov esi, DWORD PTR 72[esp] 1948 mov eax, DWORD PTR 136[esp]
1953 add ecx, esi 1949 mov DWORD PTR [edx],ebx
1954 mov DWORD PTR [edi],edx 1950 mov DWORD PTR 4[edx],ebp
1955 mov DWORD PTR 4[edi],ebp 1951 mov DWORD PTR 8[edx],ecx
1956 mov DWORD PTR 8[edi],eax 1952 sub eax, 1
1957 mov DWORD PTR 12[edi],ebx 1953 mov DWORD PTR 12[edx],esi
1958 mov DWORD PTR 16[edi],ecx 1954 mov DWORD PTR 16[edx],edi
1959 mov edi, DWORD PTR [esp] 1955 jle $L001get_out
1960 mov esi, DWORD PTR 112[esp] 1956 mov DWORD PTR 136[esp],eax
1961 cmp edi, esi 1957 mov edi, ecx
1962 mov edi, DWORD PTR 108[esp] 1958 mov eax, DWORD PTR 132[esp]
1963 jge L000start 1959 mov ecx, ebx
1964 add esp, 88 1960 add eax, 64
1961 mov esi, ebp
1962 mov DWORD PTR 132[esp],eax
1963 jmp L000start
1964$L001get_out:
1965 add esp, 108
1965 pop ebx 1966 pop ebx
1966 pop ebp 1967 pop ebp
1967 pop edi 1968 pop edi
1968 pop esi 1969 pop esi
1969 ret 1970 ret
1970_ripemd160_block_x86 ENDP 1971_ripemd160_block_asm_host_order ENDP
1971_TEXT ENDS 1972_TEXT ENDS
1972END 1973END
diff --git a/src/lib/libcrypto/ripemd/asm/rmd-586.pl b/src/lib/libcrypto/ripemd/asm/rmd-586.pl
index e53c5fadba..0ab6f76bff 100644
--- a/src/lib/libcrypto/ripemd/asm/rmd-586.pl
+++ b/src/lib/libcrypto/ripemd/asm/rmd-586.pl
@@ -1,9 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3# Normal is the 3# Normal is the
4# ripemd160_block_x86(MD5_CTX *c, ULONG *X); 4# ripemd160_block_asm_host_order(RIPEMD160_CTX *c, ULONG *X,int blocks);
5# version, non-normal is the
6# ripemd160_block_x86(MD5_CTX *c, ULONG *X,int blocks);
7 5
8$normal=0; 6$normal=0;
9 7
@@ -12,13 +10,13 @@ require "x86asm.pl";
12 10
13&asm_init($ARGV[0],$0); 11&asm_init($ARGV[0],$0);
14 12
15$A="eax"; 13$A="ecx";
16$B="ebx"; 14$B="esi";
17$C="ecx"; 15$C="edi";
18$D="edx"; 16$D="ebx";
19$E="ebp"; 17$E="ebp";
20$tmp1="esi"; 18$tmp1="eax";
21$tmp2="edi"; 19$tmp2="edx";
22 20
23$KL1=0x5A827999; 21$KL1=0x5A827999;
24$KL2=0x6ED9EBA1; 22$KL2=0x6ED9EBA1;
@@ -58,13 +56,13 @@ $KR3=0x7A6D76E9;
58 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11, 56 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11,
59 ); 57 );
60 58
61&ripemd160_block("ripemd160_block_x86"); 59&ripemd160_block("ripemd160_block_asm_host_order");
62&asm_finish(); 60&asm_finish();
63 61
64sub Xv 62sub Xv
65 { 63 {
66 local($n)=@_; 64 local($n)=@_;
67 return(&swtmp($n+1)); 65 return(&swtmp($n));
68 # tmp on stack 66 # tmp on stack
69 } 67 }
70 68
@@ -82,7 +80,7 @@ sub RIP1
82 &comment($p++); 80 &comment($p++);
83 if ($p & 1) 81 if ($p & 1)
84 { 82 {
85 &mov($tmp1, $c) if $o == -1; 83 #&mov($tmp1, $c) if $o == -1;
86 &xor($tmp1, $d) if $o == -1; 84 &xor($tmp1, $d) if $o == -1;
87 &mov($tmp2, &Xv($pos)); 85 &mov($tmp2, &Xv($pos));
88 &xor($tmp1, $b); 86 &xor($tmp1, $b);
@@ -290,7 +288,7 @@ sub RIP5
290 &rotl($c, 10); 288 &rotl($c, 10);
291 &lea($a, &DWP($K,$a,$tmp1,1)); 289 &lea($a, &DWP($K,$a,$tmp1,1));
292 &sub($tmp2, &Np($d)) if $o <= 0; 290 &sub($tmp2, &Np($d)) if $o <= 0;
293 &mov(&swtmp(1+16), $A) if $o == 1; 291 &mov(&swtmp(16), $A) if $o == 1;
294 &mov($tmp1, &Np($d)) if $o == 2; 292 &mov($tmp1, &Np($d)) if $o == 2;
295 &rotl($a, $s); 293 &rotl($a, $s);
296 &add($a, $e); 294 &add($a, $e);
@@ -310,19 +308,25 @@ sub ripemd160_block
310 # D 12 308 # D 12
311 # E 16 309 # E 16
312 310
311 &mov($tmp2, &wparam(0));
312 &mov($tmp1, &wparam(1));
313 &push("esi"); 313 &push("esi");
314 &mov($C, &wparam(2)); 314 &mov($A, &DWP( 0,$tmp2,"",0));
315 &push("edi"); 315 &push("edi");
316 &mov($tmp1, &wparam(1)); # edi 316 &mov($B, &DWP( 4,$tmp2,"",0));
317 &push("ebp"); 317 &push("ebp");
318 &add($C, $tmp1); # offset we end at 318 &mov($C, &DWP( 8,$tmp2,"",0));
319 &push("ebx"); 319 &push("ebx");
320 &sub($C, 64); 320 &stack_push(16+5+6);
321 &stack_push(16+5+1); 321 # Special comment about the figure of 6.
322 # XXX 322 # Idea is to pad the current frame so
323 323 # that the top of the stack gets fairly
324 &mov(&swtmp(0), $C); 324 # aligned. Well, as you realize it would
325 &mov($tmp2, &wparam(0)); # Done at end of loop 325 # always depend on how the frame below is
326 # aligned. The good news are that gcc-2.95
327 # and later does keep first argument at
328 # least double-wise aligned.
329 # <appro@fy.chalmers.se>
326 330
327 &set_label("start") unless $normal; 331 &set_label("start") unless $normal;
328 &comment(""); 332 &comment("");
@@ -332,16 +336,12 @@ sub ripemd160_block
332 336
333 for ($z=0; $z<16; $z+=2) 337 for ($z=0; $z<16; $z+=2)
334 { 338 {
335 &mov($A, &DWP( $z*4,$tmp1,"",0)); 339 &mov($D, &DWP( $z*4,$tmp1,"",0));
336 &mov($B, &DWP( ($z+1)*4,$tmp1,"",0)); 340 &mov($E, &DWP( ($z+1)*4,$tmp1,"",0));
337 &mov(&swtmp(1+$z), $A); 341 &mov(&swtmp($z), $D);
338 &mov(&swtmp(1+$z+1), $B); 342 &mov(&swtmp($z+1), $E);
339 } 343 }
340 &add($tmp1, 64); 344 &mov($tmp1, $C);
341 &mov($A, &DWP( 0,$tmp2,"",0));
342 &mov(&wparam(1),$tmp1);
343 &mov($B, &DWP( 4,$tmp2,"",0));
344 &mov($C, &DWP( 8,$tmp2,"",0));
345 &mov($D, &DWP(12,$tmp2,"",0)); 345 &mov($D, &DWP(12,$tmp2,"",0));
346 &mov($E, &DWP(16,$tmp2,"",0)); 346 &mov($E, &DWP(16,$tmp2,"",0));
347 347
@@ -431,14 +431,14 @@ sub ripemd160_block
431 &RIP5($B,$C,$D,$E,$A,$wl[79],$sl[79],$KL4,1); 431 &RIP5($B,$C,$D,$E,$A,$wl[79],$sl[79],$KL4,1);
432 432
433 # &mov($tmp2, &wparam(0)); # moved into last RIP5 433 # &mov($tmp2, &wparam(0)); # moved into last RIP5
434 # &mov(&swtmp(1+16), $A); 434 # &mov(&swtmp(16), $A);
435 &mov($A, &DWP( 0,$tmp2,"",0)); 435 &mov($A, &DWP( 0,$tmp2,"",0));
436 &mov(&swtmp(1+17), $B); 436 &mov(&swtmp(16+1), $B);
437 &mov(&swtmp(1+18), $C); 437 &mov(&swtmp(16+2), $C);
438 &mov($B, &DWP( 4,$tmp2,"",0)); 438 &mov($B, &DWP( 4,$tmp2,"",0));
439 &mov(&swtmp(1+19), $D); 439 &mov(&swtmp(16+3), $D);
440 &mov($C, &DWP( 8,$tmp2,"",0)); 440 &mov($C, &DWP( 8,$tmp2,"",0));
441 &mov(&swtmp(1+20), $E); 441 &mov(&swtmp(16+4), $E);
442 &mov($D, &DWP(12,$tmp2,"",0)); 442 &mov($D, &DWP(12,$tmp2,"",0));
443 &mov($E, &DWP(16,$tmp2,"",0)); 443 &mov($E, &DWP(16,$tmp2,"",0));
444 444
@@ -531,46 +531,54 @@ sub ripemd160_block
531 531
532 &mov($tmp1, &DWP( 4,$tmp2,"",0)); # ctx->B 532 &mov($tmp1, &DWP( 4,$tmp2,"",0)); # ctx->B
533 &add($D, $tmp1); 533 &add($D, $tmp1);
534 &mov($tmp1, &swtmp(1+18)); # $c 534 &mov($tmp1, &swtmp(16+2)); # $c
535 &add($D, $tmp1); 535 &add($D, $tmp1);
536 536
537 &mov($tmp1, &DWP( 8,$tmp2,"",0)); # ctx->C 537 &mov($tmp1, &DWP( 8,$tmp2,"",0)); # ctx->C
538 &add($E, $tmp1); 538 &add($E, $tmp1);
539 &mov($tmp1, &swtmp(1+19)); # $d 539 &mov($tmp1, &swtmp(16+3)); # $d
540 &add($E, $tmp1); 540 &add($E, $tmp1);
541 541
542 &mov($tmp1, &DWP(12,$tmp2,"",0)); # ctx->D 542 &mov($tmp1, &DWP(12,$tmp2,"",0)); # ctx->D
543 &add($A, $tmp1); 543 &add($A, $tmp1);
544 &mov($tmp1, &swtmp(1+20)); # $e 544 &mov($tmp1, &swtmp(16+4)); # $e
545 &add($A, $tmp1); 545 &add($A, $tmp1);
546 546
547 547
548 &mov($tmp1, &DWP(16,$tmp2,"",0)); # ctx->E 548 &mov($tmp1, &DWP(16,$tmp2,"",0)); # ctx->E
549 &add($B, $tmp1); 549 &add($B, $tmp1);
550 &mov($tmp1, &swtmp(1+16)); # $a 550 &mov($tmp1, &swtmp(16+0)); # $a
551 &add($B, $tmp1); 551 &add($B, $tmp1);
552 552
553 &mov($tmp1, &DWP( 0,$tmp2,"",0)); # ctx->A 553 &mov($tmp1, &DWP( 0,$tmp2,"",0)); # ctx->A
554 &add($C, $tmp1); 554 &add($C, $tmp1);
555 &mov($tmp1, &swtmp(1+17)); # $b 555 &mov($tmp1, &swtmp(16+1)); # $b
556 &add($C, $tmp1); 556 &add($C, $tmp1);
557 557
558 &mov($tmp1, &wparam(2));
559
558 &mov(&DWP( 0,$tmp2,"",0), $D); 560 &mov(&DWP( 0,$tmp2,"",0), $D);
559 &mov(&DWP( 4,$tmp2,"",0), $E); 561 &mov(&DWP( 4,$tmp2,"",0), $E);
560 &mov(&DWP( 8,$tmp2,"",0), $A); 562 &mov(&DWP( 8,$tmp2,"",0), $A);
561 &mov(&DWP(12,$tmp2,"",0), $B); 563 &sub($tmp1,1);
562 &mov(&DWP(16,$tmp2,"",0), $C); 564 &mov(&DWP(12,$tmp2,"",0), $B);
565 &mov(&DWP(16,$tmp2,"",0), $C);
563 566
564 &mov($tmp2, &swtmp(0)); 567 &jle(&label("get_out"));
565 &mov($tmp1, &wparam(1)); 568
569 &mov(&wparam(2),$tmp1);
570 &mov($C, $A);
571 &mov($tmp1, &wparam(1));
572 &mov($A, $D);
573 &add($tmp1, 64);
574 &mov($B, $E);
575 &mov(&wparam(1),$tmp1);
566 576
567 &cmp($tmp2,$tmp1); 577 &jmp(&label("start"));
568 &mov($tmp2, &wparam(0));
569 578
570 # XXX 579 &set_label("get_out");
571 &jge(&label("start"));
572 580
573 &stack_pop(16+5+1); 581 &stack_pop(16+5+6);
574 582
575 &pop("ebx"); 583 &pop("ebx");
576 &pop("ebp"); 584 &pop("ebp");
diff --git a/src/lib/libcrypto/ripemd/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h
index ab76be4c33..dd1627cf40 100644
--- a/src/lib/libcrypto/ripemd/ripemd.h
+++ b/src/lib/libcrypto/ripemd/ripemd.h
@@ -67,26 +67,33 @@ extern "C" {
67#error RIPEMD is disabled. 67#error RIPEMD is disabled.
68#endif 68#endif
69 69
70#if defined(WIN16) || defined(__LP32__)
71#define RIPEMD160_LONG unsigned long
72#elif defined(_CRAY) || defined(__ILP64__)
73#define RIPEMD160_LONG unsigned long
74#define RIPEMD160_LONG_LOG2 3
75#else
76#define RIPEMD160_LONG unsigned int
77#endif
78
70#define RIPEMD160_CBLOCK 64 79#define RIPEMD160_CBLOCK 64
71#define RIPEMD160_LBLOCK 16 80#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4)
72#define RIPEMD160_BLOCK 16
73#define RIPEMD160_LAST_BLOCK 56
74#define RIPEMD160_LENGTH_BLOCK 8
75#define RIPEMD160_DIGEST_LENGTH 20 81#define RIPEMD160_DIGEST_LENGTH 20
76 82
77typedef struct RIPEMD160state_st 83typedef struct RIPEMD160state_st
78 { 84 {
79 unsigned long A,B,C,D,E; 85 RIPEMD160_LONG A,B,C,D,E;
80 unsigned long Nl,Nh; 86 RIPEMD160_LONG Nl,Nh;
81 unsigned long data[RIPEMD160_LBLOCK]; 87 RIPEMD160_LONG data[RIPEMD160_LBLOCK];
82 int num; 88 int num;
83 } RIPEMD160_CTX; 89 } RIPEMD160_CTX;
84 90
85void RIPEMD160_Init(RIPEMD160_CTX *c); 91void RIPEMD160_Init(RIPEMD160_CTX *c);
86void RIPEMD160_Update(RIPEMD160_CTX *c, unsigned char *data, unsigned long len); 92void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len);
87void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 93void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
88unsigned char *RIPEMD160(unsigned char *d, unsigned long n, unsigned char *md); 94unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
89void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b); 95 unsigned char *md);
96void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
90#ifdef __cplusplus 97#ifdef __cplusplus
91} 98}
92#endif 99#endif
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c
index b590856229..bdfae270b6 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -60,7 +60,7 @@
60#include "rmd_locl.h" 60#include "rmd_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; 63const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
64 64
65# ifdef RMD160_ASM 65# ifdef RMD160_ASM
66 void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num); 66 void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num);
@@ -68,6 +68,7 @@ char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
68# else 68# else
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
71void RIPEMD160_Init(RIPEMD160_CTX *c) 72void RIPEMD160_Init(RIPEMD160_CTX *c)
72 { 73 {
73 c->A=RIPEMD160_A; 74 c->A=RIPEMD160_A;
@@ -80,180 +81,21 @@ void RIPEMD160_Init(RIPEMD160_CTX *c)
80 c->num=0; 81 c->num=0;
81 } 82 }
82 83
83void RIPEMD160_Update(RIPEMD160_CTX *c, register unsigned char *data, 84#ifndef ripemd160_block_host_order
84 unsigned long len) 85#ifdef X
85 { 86#undef X
86 register ULONG *p;
87 int sw,sc;
88 ULONG l;
89
90 if (len == 0) return;
91
92 l=(c->Nl+(len<<3))&0xffffffffL;
93 if (l < c->Nl) /* overflow */
94 c->Nh++;
95 c->Nh+=(len>>29);
96 c->Nl=l;
97
98 if (c->num != 0)
99 {
100 p=c->data;
101 sw=c->num>>2;
102 sc=c->num&0x03;
103
104 if ((c->num+len) >= RIPEMD160_CBLOCK)
105 {
106 l= p[sw];
107 p_c2l(data,l,sc);
108 p[sw++]=l;
109 for (; sw<RIPEMD160_LBLOCK; sw++)
110 {
111 c2l(data,l);
112 p[sw]=l;
113 }
114 len-=(RIPEMD160_CBLOCK-c->num);
115
116 ripemd160_block(c,p,64);
117 c->num=0;
118 /* drop through and do the rest */
119 }
120 else
121 {
122 int ew,ec;
123
124 c->num+=(int)len;
125 if ((sc+len) < 4) /* ugly, add char's to a word */
126 {
127 l= p[sw];
128 p_c2l_p(data,l,sc,len);
129 p[sw]=l;
130 }
131 else
132 {
133 ew=(c->num>>2);
134 ec=(c->num&0x03);
135 l= p[sw];
136 p_c2l(data,l,sc);
137 p[sw++]=l;
138 for (; sw < ew; sw++)
139 { c2l(data,l); p[sw]=l; }
140 if (ec)
141 {
142 c2l_p(data,l,ec);
143 p[sw]=l;
144 }
145 }
146 return;
147 }
148 }
149 /* we now can process the input data in blocks of RIPEMD160_CBLOCK
150 * chars and save the leftovers to c->data. */
151#ifdef L_ENDIAN
152 if ((((unsigned long)data)%sizeof(ULONG)) == 0)
153 {
154 sw=(int)len/RIPEMD160_CBLOCK;
155 if (sw > 0)
156 {
157 sw*=RIPEMD160_CBLOCK;
158 ripemd160_block(c,(ULONG *)data,sw);
159 data+=sw;
160 len-=sw;
161 }
162 }
163#endif
164 p=c->data;
165 while (len >= RIPEMD160_CBLOCK)
166 {
167#if defined(L_ENDIAN) || defined(B_ENDIAN)
168 if (p != (unsigned long *)data)
169 memcpy(p,data,RIPEMD160_CBLOCK);
170 data+=RIPEMD160_CBLOCK;
171#ifdef B_ENDIAN
172 for (sw=(RIPEMD160_LBLOCK/4); sw; sw--)
173 {
174 Endian_Reverse32(p[0]);
175 Endian_Reverse32(p[1]);
176 Endian_Reverse32(p[2]);
177 Endian_Reverse32(p[3]);
178 p+=4;
179 }
180#endif
181#else
182 for (sw=(RIPEMD160_LBLOCK/4); sw; sw--)
183 {
184 c2l(data,l); *(p++)=l;
185 c2l(data,l); *(p++)=l;
186 c2l(data,l); *(p++)=l;
187 c2l(data,l); *(p++)=l;
188 }
189#endif 87#endif
190 p=c->data; 88#define X(i) XX[i]
191 ripemd160_block(c,p,64); 89void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
192 len-=RIPEMD160_CBLOCK;
193 }
194 sc=(int)len;
195 c->num=sc;
196 if (sc)
197 {
198 sw=sc>>2; /* words to copy */
199#ifdef L_ENDIAN
200 p[sw]=0;
201 memcpy(p,data,sc);
202#else
203 sc&=0x03;
204 for ( ; sw; sw--)
205 { c2l(data,l); *(p++)=l; }
206 c2l_p(data,l,sc);
207 *p=l;
208#endif
209 }
210 }
211
212void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b)
213 { 90 {
214 ULONG p[16]; 91 const RIPEMD160_LONG *XX=p;
215#if !defined(L_ENDIAN) 92 register unsigned long A,B,C,D,E;
216 ULONG *q; 93 register unsigned long a,b,c,d,e;
217 int i;
218#endif
219 94
220#if defined(B_ENDIAN) || defined(L_ENDIAN) 95 for (;num--;XX+=HASH_LBLOCK)
221 memcpy(p,b,64);
222#ifdef B_ENDIAN
223 q=p;
224 for (i=(RIPEMD160_LBLOCK/4); i; i--)
225 {
226 Endian_Reverse32(q[0]);
227 Endian_Reverse32(q[1]);
228 Endian_Reverse32(q[2]);
229 Endian_Reverse32(q[3]);
230 q+=4;
231 }
232#endif
233#else
234 q=p;
235 for (i=(RIPEMD160_LBLOCK/4); i; i--)
236 { 96 {
237 ULONG l;
238 c2l(b,l); *(q++)=l;
239 c2l(b,l); *(q++)=l;
240 c2l(b,l); *(q++)=l;
241 c2l(b,l); *(q++)=l;
242 }
243#endif
244 ripemd160_block(c,p,64);
245 }
246
247#ifndef RMD160_ASM
248
249void ripemd160_block(RIPEMD160_CTX *ctx, register ULONG *X, int num)
250 {
251 register ULONG A,B,C,D,E;
252 ULONG a,b,c,d,e;
253 97
254 for (;;) 98 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
255 {
256 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
257 99
258 RIP1(A,B,C,D,E,WL00,SL00); 100 RIP1(A,B,C,D,E,WL00,SL00);
259 RIP1(E,A,B,C,D,WL01,SL01); 101 RIP1(E,A,B,C,D,WL01,SL01);
@@ -436,80 +278,216 @@ void ripemd160_block(RIPEMD160_CTX *ctx, register ULONG *X, int num)
436 ctx->E=ctx->A+b+C; 278 ctx->E=ctx->A+b+C;
437 ctx->A=D; 279 ctx->A=D;
438 280
439 X+=16;
440 num-=64;
441 if (num <= 0) break;
442 } 281 }
443 } 282 }
444#endif 283#endif
445 284
446void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c) 285#ifndef ripemd160_block_data_order
286#ifdef X
287#undef X
288#endif
289void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num)
447 { 290 {
448 register int i,j; 291 const unsigned char *data=p;
449 register ULONG l; 292 register unsigned long A,B,C,D,E;
450 register ULONG *p; 293 unsigned long a,b,c,d,e,l;
451 static unsigned char end[4]={0x80,0x00,0x00,0x00}; 294#ifndef MD32_XARRAY
452 unsigned char *cp=end; 295 /* See comment in crypto/sha/sha_locl.h for details. */
453 296 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
454 /* c->num should definitly have room for at least one more byte. */ 297 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
455 p=c->data; 298# define X(i) XX##i
456 j=c->num; 299#else
457 i=j>>2; 300 RIPEMD160_LONG XX[16];
458 301# define X(i) XX[i]
459 /* purify often complains about the following line as an
460 * Uninitialized Memory Read. While this can be true, the
461 * following p_c2l macro will reset l when that case is true.
462 * This is because j&0x03 contains the number of 'valid' bytes
463 * already in p[i]. If and only if j&0x03 == 0, the UMR will
464 * occur but this is also the only time p_c2l will do
465 * l= *(cp++) instead of l|= *(cp++)
466 * Many thanks to Alex Tang <altitude@cic.net> for pickup this
467 * 'potential bug' */
468#ifdef PURIFY
469 if ((j&0x03) == 0) p[i]=0;
470#endif 302#endif
471 l=p[i]; 303
472 p_c2l(cp,l,j&0x03); 304 for (;num--;)
473 p[i]=l;
474 i++;
475 /* i is the next 'undefined word' */
476 if (c->num >= RIPEMD160_LAST_BLOCK)
477 { 305 {
478 for (; i<RIPEMD160_LBLOCK; i++)
479 p[i]=0;
480 ripemd160_block(c,p,64);
481 i=0;
482 }
483 for (; i<(RIPEMD160_LBLOCK-2); i++)
484 p[i]=0;
485 p[RIPEMD160_LBLOCK-2]=c->Nl;
486 p[RIPEMD160_LBLOCK-1]=c->Nh;
487 ripemd160_block(c,p,64);
488 cp=md;
489 l=c->A; l2c(l,cp);
490 l=c->B; l2c(l,cp);
491 l=c->C; l2c(l,cp);
492 l=c->D; l2c(l,cp);
493 l=c->E; l2c(l,cp);
494
495 /* clear stuff, ripemd160_block may be leaving some stuff on the stack
496 * but I'm not worried :-) */
497 c->num=0;
498/* memset((char *)&c,0,sizeof(c));*/
499 }
500 306
501#ifdef undef 307 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
502int printit(unsigned long *l) 308
503 { 309 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
504 int i,ii; 310 RIP1(A,B,C,D,E,WL00,SL00); HOST_c2l(data,l); X( 2)=l;
311 RIP1(E,A,B,C,D,WL01,SL01); HOST_c2l(data,l); X( 3)=l;
312 RIP1(D,E,A,B,C,WL02,SL02); HOST_c2l(data,l); X( 4)=l;
313 RIP1(C,D,E,A,B,WL03,SL03); HOST_c2l(data,l); X( 5)=l;
314 RIP1(B,C,D,E,A,WL04,SL04); HOST_c2l(data,l); X( 6)=l;
315 RIP1(A,B,C,D,E,WL05,SL05); HOST_c2l(data,l); X( 7)=l;
316 RIP1(E,A,B,C,D,WL06,SL06); HOST_c2l(data,l); X( 8)=l;
317 RIP1(D,E,A,B,C,WL07,SL07); HOST_c2l(data,l); X( 9)=l;
318 RIP1(C,D,E,A,B,WL08,SL08); HOST_c2l(data,l); X(10)=l;
319 RIP1(B,C,D,E,A,WL09,SL09); HOST_c2l(data,l); X(11)=l;
320 RIP1(A,B,C,D,E,WL10,SL10); HOST_c2l(data,l); X(12)=l;
321 RIP1(E,A,B,C,D,WL11,SL11); HOST_c2l(data,l); X(13)=l;
322 RIP1(D,E,A,B,C,WL12,SL12); HOST_c2l(data,l); X(14)=l;
323 RIP1(C,D,E,A,B,WL13,SL13); HOST_c2l(data,l); X(15)=l;
324 RIP1(B,C,D,E,A,WL14,SL14);
325 RIP1(A,B,C,D,E,WL15,SL15);
326
327 RIP2(E,A,B,C,D,WL16,SL16,KL1);
328 RIP2(D,E,A,B,C,WL17,SL17,KL1);
329 RIP2(C,D,E,A,B,WL18,SL18,KL1);
330 RIP2(B,C,D,E,A,WL19,SL19,KL1);
331 RIP2(A,B,C,D,E,WL20,SL20,KL1);
332 RIP2(E,A,B,C,D,WL21,SL21,KL1);
333 RIP2(D,E,A,B,C,WL22,SL22,KL1);
334 RIP2(C,D,E,A,B,WL23,SL23,KL1);
335 RIP2(B,C,D,E,A,WL24,SL24,KL1);
336 RIP2(A,B,C,D,E,WL25,SL25,KL1);
337 RIP2(E,A,B,C,D,WL26,SL26,KL1);
338 RIP2(D,E,A,B,C,WL27,SL27,KL1);
339 RIP2(C,D,E,A,B,WL28,SL28,KL1);
340 RIP2(B,C,D,E,A,WL29,SL29,KL1);
341 RIP2(A,B,C,D,E,WL30,SL30,KL1);
342 RIP2(E,A,B,C,D,WL31,SL31,KL1);
343
344 RIP3(D,E,A,B,C,WL32,SL32,KL2);
345 RIP3(C,D,E,A,B,WL33,SL33,KL2);
346 RIP3(B,C,D,E,A,WL34,SL34,KL2);
347 RIP3(A,B,C,D,E,WL35,SL35,KL2);
348 RIP3(E,A,B,C,D,WL36,SL36,KL2);
349 RIP3(D,E,A,B,C,WL37,SL37,KL2);
350 RIP3(C,D,E,A,B,WL38,SL38,KL2);
351 RIP3(B,C,D,E,A,WL39,SL39,KL2);
352 RIP3(A,B,C,D,E,WL40,SL40,KL2);
353 RIP3(E,A,B,C,D,WL41,SL41,KL2);
354 RIP3(D,E,A,B,C,WL42,SL42,KL2);
355 RIP3(C,D,E,A,B,WL43,SL43,KL2);
356 RIP3(B,C,D,E,A,WL44,SL44,KL2);
357 RIP3(A,B,C,D,E,WL45,SL45,KL2);
358 RIP3(E,A,B,C,D,WL46,SL46,KL2);
359 RIP3(D,E,A,B,C,WL47,SL47,KL2);
360
361 RIP4(C,D,E,A,B,WL48,SL48,KL3);
362 RIP4(B,C,D,E,A,WL49,SL49,KL3);
363 RIP4(A,B,C,D,E,WL50,SL50,KL3);
364 RIP4(E,A,B,C,D,WL51,SL51,KL3);
365 RIP4(D,E,A,B,C,WL52,SL52,KL3);
366 RIP4(C,D,E,A,B,WL53,SL53,KL3);
367 RIP4(B,C,D,E,A,WL54,SL54,KL3);
368 RIP4(A,B,C,D,E,WL55,SL55,KL3);
369 RIP4(E,A,B,C,D,WL56,SL56,KL3);
370 RIP4(D,E,A,B,C,WL57,SL57,KL3);
371 RIP4(C,D,E,A,B,WL58,SL58,KL3);
372 RIP4(B,C,D,E,A,WL59,SL59,KL3);
373 RIP4(A,B,C,D,E,WL60,SL60,KL3);
374 RIP4(E,A,B,C,D,WL61,SL61,KL3);
375 RIP4(D,E,A,B,C,WL62,SL62,KL3);
376 RIP4(C,D,E,A,B,WL63,SL63,KL3);
377
378 RIP5(B,C,D,E,A,WL64,SL64,KL4);
379 RIP5(A,B,C,D,E,WL65,SL65,KL4);
380 RIP5(E,A,B,C,D,WL66,SL66,KL4);
381 RIP5(D,E,A,B,C,WL67,SL67,KL4);
382 RIP5(C,D,E,A,B,WL68,SL68,KL4);
383 RIP5(B,C,D,E,A,WL69,SL69,KL4);
384 RIP5(A,B,C,D,E,WL70,SL70,KL4);
385 RIP5(E,A,B,C,D,WL71,SL71,KL4);
386 RIP5(D,E,A,B,C,WL72,SL72,KL4);
387 RIP5(C,D,E,A,B,WL73,SL73,KL4);
388 RIP5(B,C,D,E,A,WL74,SL74,KL4);
389 RIP5(A,B,C,D,E,WL75,SL75,KL4);
390 RIP5(E,A,B,C,D,WL76,SL76,KL4);
391 RIP5(D,E,A,B,C,WL77,SL77,KL4);
392 RIP5(C,D,E,A,B,WL78,SL78,KL4);
393 RIP5(B,C,D,E,A,WL79,SL79,KL4);
394
395 a=A; b=B; c=C; d=D; e=E;
396 /* Do other half */
397 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
398
399 RIP5(A,B,C,D,E,WR00,SR00,KR0);
400 RIP5(E,A,B,C,D,WR01,SR01,KR0);
401 RIP5(D,E,A,B,C,WR02,SR02,KR0);
402 RIP5(C,D,E,A,B,WR03,SR03,KR0);
403 RIP5(B,C,D,E,A,WR04,SR04,KR0);
404 RIP5(A,B,C,D,E,WR05,SR05,KR0);
405 RIP5(E,A,B,C,D,WR06,SR06,KR0);
406 RIP5(D,E,A,B,C,WR07,SR07,KR0);
407 RIP5(C,D,E,A,B,WR08,SR08,KR0);
408 RIP5(B,C,D,E,A,WR09,SR09,KR0);
409 RIP5(A,B,C,D,E,WR10,SR10,KR0);
410 RIP5(E,A,B,C,D,WR11,SR11,KR0);
411 RIP5(D,E,A,B,C,WR12,SR12,KR0);
412 RIP5(C,D,E,A,B,WR13,SR13,KR0);
413 RIP5(B,C,D,E,A,WR14,SR14,KR0);
414 RIP5(A,B,C,D,E,WR15,SR15,KR0);
415
416 RIP4(E,A,B,C,D,WR16,SR16,KR1);
417 RIP4(D,E,A,B,C,WR17,SR17,KR1);
418 RIP4(C,D,E,A,B,WR18,SR18,KR1);
419 RIP4(B,C,D,E,A,WR19,SR19,KR1);
420 RIP4(A,B,C,D,E,WR20,SR20,KR1);
421 RIP4(E,A,B,C,D,WR21,SR21,KR1);
422 RIP4(D,E,A,B,C,WR22,SR22,KR1);
423 RIP4(C,D,E,A,B,WR23,SR23,KR1);
424 RIP4(B,C,D,E,A,WR24,SR24,KR1);
425 RIP4(A,B,C,D,E,WR25,SR25,KR1);
426 RIP4(E,A,B,C,D,WR26,SR26,KR1);
427 RIP4(D,E,A,B,C,WR27,SR27,KR1);
428 RIP4(C,D,E,A,B,WR28,SR28,KR1);
429 RIP4(B,C,D,E,A,WR29,SR29,KR1);
430 RIP4(A,B,C,D,E,WR30,SR30,KR1);
431 RIP4(E,A,B,C,D,WR31,SR31,KR1);
432
433 RIP3(D,E,A,B,C,WR32,SR32,KR2);
434 RIP3(C,D,E,A,B,WR33,SR33,KR2);
435 RIP3(B,C,D,E,A,WR34,SR34,KR2);
436 RIP3(A,B,C,D,E,WR35,SR35,KR2);
437 RIP3(E,A,B,C,D,WR36,SR36,KR2);
438 RIP3(D,E,A,B,C,WR37,SR37,KR2);
439 RIP3(C,D,E,A,B,WR38,SR38,KR2);
440 RIP3(B,C,D,E,A,WR39,SR39,KR2);
441 RIP3(A,B,C,D,E,WR40,SR40,KR2);
442 RIP3(E,A,B,C,D,WR41,SR41,KR2);
443 RIP3(D,E,A,B,C,WR42,SR42,KR2);
444 RIP3(C,D,E,A,B,WR43,SR43,KR2);
445 RIP3(B,C,D,E,A,WR44,SR44,KR2);
446 RIP3(A,B,C,D,E,WR45,SR45,KR2);
447 RIP3(E,A,B,C,D,WR46,SR46,KR2);
448 RIP3(D,E,A,B,C,WR47,SR47,KR2);
449
450 RIP2(C,D,E,A,B,WR48,SR48,KR3);
451 RIP2(B,C,D,E,A,WR49,SR49,KR3);
452 RIP2(A,B,C,D,E,WR50,SR50,KR3);
453 RIP2(E,A,B,C,D,WR51,SR51,KR3);
454 RIP2(D,E,A,B,C,WR52,SR52,KR3);
455 RIP2(C,D,E,A,B,WR53,SR53,KR3);
456 RIP2(B,C,D,E,A,WR54,SR54,KR3);
457 RIP2(A,B,C,D,E,WR55,SR55,KR3);
458 RIP2(E,A,B,C,D,WR56,SR56,KR3);
459 RIP2(D,E,A,B,C,WR57,SR57,KR3);
460 RIP2(C,D,E,A,B,WR58,SR58,KR3);
461 RIP2(B,C,D,E,A,WR59,SR59,KR3);
462 RIP2(A,B,C,D,E,WR60,SR60,KR3);
463 RIP2(E,A,B,C,D,WR61,SR61,KR3);
464 RIP2(D,E,A,B,C,WR62,SR62,KR3);
465 RIP2(C,D,E,A,B,WR63,SR63,KR3);
466
467 RIP1(B,C,D,E,A,WR64,SR64);
468 RIP1(A,B,C,D,E,WR65,SR65);
469 RIP1(E,A,B,C,D,WR66,SR66);
470 RIP1(D,E,A,B,C,WR67,SR67);
471 RIP1(C,D,E,A,B,WR68,SR68);
472 RIP1(B,C,D,E,A,WR69,SR69);
473 RIP1(A,B,C,D,E,WR70,SR70);
474 RIP1(E,A,B,C,D,WR71,SR71);
475 RIP1(D,E,A,B,C,WR72,SR72);
476 RIP1(C,D,E,A,B,WR73,SR73);
477 RIP1(B,C,D,E,A,WR74,SR74);
478 RIP1(A,B,C,D,E,WR75,SR75);
479 RIP1(E,A,B,C,D,WR76,SR76);
480 RIP1(D,E,A,B,C,WR77,SR77);
481 RIP1(C,D,E,A,B,WR78,SR78);
482 RIP1(B,C,D,E,A,WR79,SR79);
483
484 D =ctx->B+c+D;
485 ctx->B=ctx->C+d+E;
486 ctx->C=ctx->D+e+A;
487 ctx->D=ctx->E+a+B;
488 ctx->E=ctx->A+b+C;
489 ctx->A=D;
505 490
506 for (i=0; i<2; i++)
507 {
508 for (ii=0; ii<8; ii++)
509 {
510 fprintf(stderr,"%08lx ",l[i*8+ii]);
511 }
512 fprintf(stderr,"\n");
513 } 491 }
514 } 492 }
515#endif 493#endif
diff --git a/src/lib/libcrypto/ripemd/rmd_locl.h b/src/lib/libcrypto/ripemd/rmd_locl.h
index d6ba02001a..145cf316b9 100644
--- a/src/lib/libcrypto/ripemd/rmd_locl.h
+++ b/src/lib/libcrypto/ripemd/rmd_locl.h
@@ -58,134 +58,76 @@
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/opensslconf.h>
61#include <openssl/ripemd.h> 62#include <openssl/ripemd.h>
62 63
63#define ULONG unsigned long 64#ifndef RIPEMD160_LONG_LOG2
64#define UCHAR unsigned char 65#define RIPEMD160_LONG_LOG2 2 /* default to 32 bits */
65#define UINT unsigned int 66#endif
66 67
67#undef c2nl 68/*
68#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ 69 * DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c
69 l|=(((unsigned long)(*((c)++)))<<16), \ 70 * FOR EXPLANATIONS ON FOLLOWING "CODE."
70 l|=(((unsigned long)(*((c)++)))<< 8), \ 71 * <appro@fy.chalmers.se>
71 l|=(((unsigned long)(*((c)++))) )) 72 */
72 73#ifdef RMD160_ASM
73#undef p_c2nl 74# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
74#define p_c2nl(c,l,n) { \ 75# define ripemd160_block_host_order ripemd160_block_asm_host_order
75 switch (n) { \ 76# endif
76 case 0: l =((unsigned long)(*((c)++)))<<24; \ 77#endif
77 case 1: l|=((unsigned long)(*((c)++)))<<16; \ 78
78 case 2: l|=((unsigned long)(*((c)++)))<< 8; \ 79void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
79 case 3: l|=((unsigned long)(*((c)++))); \ 80void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);
80 } \ 81
81 } 82#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
82 83#define ripemd160_block_data_order ripemd160_block_host_order
83#undef c2nl_p 84#endif
84/* NOTE the pointer is not incremented at the end of this */ 85
85#define c2nl_p(c,l,n) { \ 86#define DATA_ORDER_IS_LITTLE_ENDIAN
86 l=0; \ 87
87 (c)+=n; \ 88#define HASH_LONG RIPEMD160_LONG
88 switch (n) { \ 89#define HASH_LONG_LOG2 RIPEMD160_LONG_LOG2
89 case 3: l =((unsigned long)(*(--(c))))<< 8; \ 90#define HASH_CTX RIPEMD160_CTX
90 case 2: l|=((unsigned long)(*(--(c))))<<16; \ 91#define HASH_CBLOCK RIPEMD160_CBLOCK
91 case 1: l|=((unsigned long)(*(--(c))))<<24; \ 92#define HASH_LBLOCK RIPEMD160_LBLOCK
92 } \ 93#define HASH_UPDATE RIPEMD160_Update
93 } 94#define HASH_TRANSFORM RIPEMD160_Transform
94 95#define HASH_FINAL RIPEMD160_Final
95#undef p_c2nl_p 96#define HASH_BLOCK_HOST_ORDER ripemd160_block_host_order
96#define p_c2nl_p(c,l,sc,len) { \ 97#define HASH_MAKE_STRING(c,s) do { \
97 switch (sc) \ 98 unsigned long ll; \
98 { \ 99 ll=(c)->A; HOST_l2c(ll,(s)); \
99 case 0: l =((unsigned long)(*((c)++)))<<24; \ 100 ll=(c)->B; HOST_l2c(ll,(s)); \
100 if (--len == 0) break; \ 101 ll=(c)->C; HOST_l2c(ll,(s)); \
101 case 1: l|=((unsigned long)(*((c)++)))<<16; \ 102 ll=(c)->D; HOST_l2c(ll,(s)); \
102 if (--len == 0) break; \ 103 ll=(c)->E; HOST_l2c(ll,(s)); \
103 case 2: l|=((unsigned long)(*((c)++)))<< 8; \ 104 } while (0)
104 } \ 105#if !defined(L_ENDIAN) || defined(ripemd160_block_data_order)
105 } 106#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
106
107#undef nl2c
108#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
109 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
110 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
111 *((c)++)=(unsigned char)(((l) )&0xff))
112
113#undef c2l
114#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
115 l|=(((unsigned long)(*((c)++)))<< 8), \
116 l|=(((unsigned long)(*((c)++)))<<16), \
117 l|=(((unsigned long)(*((c)++)))<<24))
118
119#undef p_c2l
120#define p_c2l(c,l,n) { \
121 switch (n) { \
122 case 0: l =((unsigned long)(*((c)++))); \
123 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
124 case 2: l|=((unsigned long)(*((c)++)))<<16; \
125 case 3: l|=((unsigned long)(*((c)++)))<<24; \
126 } \
127 }
128
129#undef c2l_p
130/* NOTE the pointer is not incremented at the end of this */
131#define c2l_p(c,l,n) { \
132 l=0; \
133 (c)+=n; \
134 switch (n) { \
135 case 3: l =((unsigned long)(*(--(c))))<<16; \
136 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
137 case 1: l|=((unsigned long)(*(--(c)))); \
138 } \
139 }
140
141#undef p_c2l_p
142#define p_c2l_p(c,l,sc,len) { \
143 switch (sc) \
144 { \
145 case 0: l =((unsigned long)(*((c)++))); \
146 if (--len == 0) break; \
147 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
148 if (--len == 0) break; \
149 case 2: l|=((unsigned long)(*((c)++)))<<16; \
150 } \
151 }
152
153#undef l2c
154#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
155 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
156 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
157 *((c)++)=(unsigned char)(((l)>>24)&0xff))
158
159#undef ROTATE
160#if defined(WIN32)
161#define ROTATE(a,n) _lrotl(a,n)
162#else
163#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
164#endif 107#endif
165 108
166/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */ 109#ifndef FLAT_INC
167#if defined(WIN32) 110#include "../md32_common.h"
168/* 5 instructions with rotate instruction, else 9 */
169#define Endian_Reverse32(a) \
170 { \
171 unsigned long l=(a); \
172 (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
173 }
174#else 111#else
175/* 6 instructions with rotate instruction, else 8 */ 112#include "md32_common.h"
176#define Endian_Reverse32(a) \
177 { \
178 unsigned long l=(a); \
179 l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
180 (a)=ROTATE(l,16L); \
181 }
182#endif 113#endif
183 114
115#if 0
184#define F1(x,y,z) ((x)^(y)^(z)) 116#define F1(x,y,z) ((x)^(y)^(z))
185#define F2(x,y,z) (((x)&(y))|((~x)&z)) 117#define F2(x,y,z) (((x)&(y))|((~x)&z))
186#define F3(x,y,z) (((x)|(~y))^(z)) 118#define F3(x,y,z) (((x)|(~y))^(z))
187#define F4(x,y,z) (((x)&(z))|((y)&(~(z)))) 119#define F4(x,y,z) (((x)&(z))|((y)&(~(z))))
188#define F5(x,y,z) ((x)^((y)|(~(z)))) 120#define F5(x,y,z) ((x)^((y)|(~(z))))
121#else
122/*
123 * Transformed F2 and F4 are courtesy of Wei Dai <weidai@eskimo.com>
124 */
125#define F1(x,y,z) ((x) ^ (y) ^ (z))
126#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
127#define F3(x,y,z) (((~(y)) | (x)) ^ (z))
128#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
129#define F5(x,y,z) (((~(z)) | (y)) ^ (x))
130#endif
189 131
190#define RIPEMD160_A 0x67452301L 132#define RIPEMD160_A 0x67452301L
191#define RIPEMD160_B 0xEFCDAB89L 133#define RIPEMD160_B 0xEFCDAB89L
@@ -196,27 +138,27 @@
196#include "rmdconst.h" 138#include "rmdconst.h"
197 139
198#define RIP1(a,b,c,d,e,w,s) { \ 140#define RIP1(a,b,c,d,e,w,s) { \
199 a+=F1(b,c,d)+X[w]; \ 141 a+=F1(b,c,d)+X(w); \
200 a=ROTATE(a,s)+e; \ 142 a=ROTATE(a,s)+e; \
201 c=ROTATE(c,10); } 143 c=ROTATE(c,10); }
202 144
203#define RIP2(a,b,c,d,e,w,s,K) { \ 145#define RIP2(a,b,c,d,e,w,s,K) { \
204 a+=F2(b,c,d)+X[w]+K; \ 146 a+=F2(b,c,d)+X(w)+K; \
205 a=ROTATE(a,s)+e; \ 147 a=ROTATE(a,s)+e; \
206 c=ROTATE(c,10); } 148 c=ROTATE(c,10); }
207 149
208#define RIP3(a,b,c,d,e,w,s,K) { \ 150#define RIP3(a,b,c,d,e,w,s,K) { \
209 a+=F3(b,c,d)+X[w]+K; \ 151 a+=F3(b,c,d)+X(w)+K; \
210 a=ROTATE(a,s)+e; \ 152 a=ROTATE(a,s)+e; \
211 c=ROTATE(c,10); } 153 c=ROTATE(c,10); }
212 154
213#define RIP4(a,b,c,d,e,w,s,K) { \ 155#define RIP4(a,b,c,d,e,w,s,K) { \
214 a+=F4(b,c,d)+X[w]+K; \ 156 a+=F4(b,c,d)+X(w)+K; \
215 a=ROTATE(a,s)+e; \ 157 a=ROTATE(a,s)+e; \
216 c=ROTATE(c,10); } 158 c=ROTATE(c,10); }
217 159
218#define RIP5(a,b,c,d,e,w,s,K) { \ 160#define RIP5(a,b,c,d,e,w,s,K) { \
219 a+=F5(b,c,d)+X[w]+K; \ 161 a+=F5(b,c,d)+X(w)+K; \
220 a=ROTATE(a,s)+e; \ 162 a=ROTATE(a,s)+e; \
221 c=ROTATE(c,10); } 163 c=ROTATE(c,10); }
222 164
diff --git a/src/lib/libcrypto/ripemd/rmd_one.c b/src/lib/libcrypto/ripemd/rmd_one.c
index 5b6ff14714..efdf2dd6ef 100644
--- a/src/lib/libcrypto/ripemd/rmd_one.c
+++ b/src/lib/libcrypto/ripemd/rmd_one.c
@@ -57,9 +57,10 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "rmd_locl.h" 60#include <string.h>
61#include <openssl/ripemd.h>
61 62
62unsigned char *RIPEMD160(unsigned char *d, unsigned long n, 63unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
63 unsigned char *md) 64 unsigned char *md)
64 { 65 {
65 RIPEMD160_CTX c; 66 RIPEMD160_CTX c;
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
index 5e93d4627c..5d79c99725 100644
--- a/src/lib/libcrypto/ripemd/rmdtest.c
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
73#include <openssl/ebcdic.h> 73#include <openssl/ebcdic.h>
74#endif 74#endif
75 75
76char *test[]={ 76static char *test[]={
77 "", 77 "",
78 "a", 78 "a",
79 "abc", 79 "abc",
@@ -85,7 +85,7 @@ char *test[]={
85 NULL, 85 NULL,
86 }; 86 };
87 87
88char *ret[]={ 88static char *ret[]={
89 "9c1185a5c5e9fc54612808977ee8f548b2258d31", 89 "9c1185a5c5e9fc54612808977ee8f548b2258d31",
90 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", 90 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
91 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", 91 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl
index 3bb89701a2..7b3960e70d 100644
--- a/src/lib/libcrypto/rsa/Makefile.ssl
+++ b/src/lib/libcrypto/rsa/Makefile.ssl
@@ -18,14 +18,14 @@ AR= ar r
18CFLAGS= $(INCLUDES) $(CFLAG) 18CFLAGS= $(INCLUDES) $(CFLAG)
19 19
20GENERAL=Makefile 20GENERAL=Makefile
21TEST=rsa_oaep_test.c 21TEST=rsa_test.c
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ 25LIBSRC= 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 26 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c
27LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \ 27LIBOBJ= 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 28 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o
29 29
30SRC= $(LIBSRC) 30SRC= $(LIBSRC)
31 31
@@ -83,52 +83,61 @@ clean:
83rsa_chk.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 83rsa_chk.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
84rsa_chk.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 84rsa_chk.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
85rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 85rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
86rsa_chk.o: ../../include/openssl/stack.h 86rsa_chk.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 87rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
88rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 88rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
89rsa_eay.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 89rsa_eay.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
90rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 90rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
91rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 91rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
92rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 92rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
93rsa_eay.o: ../cryptlib.h 93rsa_eay.o: ../../include/openssl/stack.h ../cryptlib.h
94rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 94rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
95rsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 95rsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
96rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 96rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
97rsa_err.o: ../../include/openssl/stack.h 97rsa_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
98rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 98rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
99rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 99rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100rsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 100rsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
101rsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 101rsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
102rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 102rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
103rsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h 103rsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
104rsa_gen.o: ../cryptlib.h
104rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 105rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
105rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 106rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
106rsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 107rsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
107rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 108rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
108rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 109rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
109rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 110rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
110rsa_lib.o: ../cryptlib.h 111rsa_lib.o: ../../include/openssl/stack.h ../cryptlib.h
111rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 112rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
112rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 113rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113rsa_none.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 114rsa_none.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
114rsa_none.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 115rsa_none.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
115rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 116rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
116rsa_none.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 117rsa_none.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
117rsa_none.o: ../cryptlib.h 118rsa_none.o: ../../include/openssl/stack.h ../cryptlib.h
119rsa_null.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
120rsa_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
121rsa_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
122rsa_null.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
123rsa_null.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
124rsa_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
125rsa_null.o: ../../include/openssl/stack.h ../cryptlib.h
118rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 126rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
119rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 127rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120rsa_oaep.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 128rsa_oaep.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
121rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 129rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
122rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 130rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
123rsa_oaep.o: ../../include/openssl/rsa.h ../../include/openssl/sha.h 131rsa_oaep.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
124rsa_oaep.o: ../../include/openssl/stack.h ../cryptlib.h 132rsa_oaep.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
133rsa_oaep.o: ../cryptlib.h
125rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 134rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
126rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 135rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
127rsa_pk1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 136rsa_pk1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
128rsa_pk1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 137rsa_pk1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
129rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 138rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
130rsa_pk1.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 139rsa_pk1.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
131rsa_pk1.o: ../cryptlib.h 140rsa_pk1.o: ../../include/openssl/stack.h ../cryptlib.h
132rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 141rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
133rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 142rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
134rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 143rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -168,5 +177,5 @@ rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
168rsa_ssl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 177rsa_ssl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
169rsa_ssl.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 178rsa_ssl.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
170rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 179rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
171rsa_ssl.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 180rsa_ssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
172rsa_ssl.o: ../cryptlib.h 181rsa_ssl.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h
index 9230b2fcc9..f9f9b5cfe9 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -91,6 +91,18 @@ typedef struct rsa_meth_st
91 int (*finish)(RSA *rsa); /* called at free */ 91 int (*finish)(RSA *rsa); /* called at free */
92 int flags; /* RSA_METHOD_FLAG_* things */ 92 int flags; /* RSA_METHOD_FLAG_* things */
93 char *app_data; /* may be needed! */ 93 char *app_data; /* may be needed! */
94/* New sign and verify functions: some libraries don't allow arbitrary data
95 * to be signed/verified: this allows them to be used. Note: for this to work
96 * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
97 * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
98 * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
99 * option is set in 'flags'.
100 */
101 int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len,
102 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
103 int (*rsa_verify)(int dtype, unsigned char *m, unsigned int m_len,
104 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
105
94 } RSA_METHOD; 106 } RSA_METHOD;
95 107
96struct rsa_st 108struct rsa_st
@@ -140,12 +152,16 @@ struct rsa_st
140 */ 152 */
141#define RSA_FLAG_EXT_PKEY 0x20 153#define RSA_FLAG_EXT_PKEY 0x20
142 154
155/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
156 */
157#define RSA_FLAG_SIGN_VER 0x40
158
143#define RSA_PKCS1_PADDING 1 159#define RSA_PKCS1_PADDING 1
144#define RSA_SSLV23_PADDING 2 160#define RSA_SSLV23_PADDING 2
145#define RSA_NO_PADDING 3 161#define RSA_NO_PADDING 3
146#define RSA_PKCS1_OAEP_PADDING 4 162#define RSA_PKCS1_OAEP_PADDING 4
147 163
148#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,(char *)arg) 164#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
149#define RSA_get_app_data(s) RSA_get_ex_data(s,0) 165#define RSA_get_app_data(s) RSA_get_ex_data(s,0)
150 166
151RSA * RSA_new(void); 167RSA * RSA_new(void);
@@ -181,6 +197,8 @@ RSA_METHOD *RSA_PKCS1_RSAref(void);
181/* these are the actual SSLeay RSA functions */ 197/* these are the actual SSLeay RSA functions */
182RSA_METHOD *RSA_PKCS1_SSLeay(void); 198RSA_METHOD *RSA_PKCS1_SSLeay(void);
183 199
200RSA_METHOD *RSA_null_method(void);
201
184void ERR_load_RSA_strings(void ); 202void ERR_load_RSA_strings(void );
185 203
186RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length); 204RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length);
@@ -241,10 +259,10 @@ int RSA_padding_add_none(unsigned char *to,int tlen,
241int RSA_padding_check_none(unsigned char *to,int tlen, 259int RSA_padding_check_none(unsigned char *to,int tlen,
242 unsigned char *f,int fl,int rsa_len); 260 unsigned char *f,int fl,int rsa_len);
243 261
244int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), 262int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
245 int (*dup_func)(), void (*free_func)()); 263 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
246int RSA_set_ex_data(RSA *r,int idx,char *arg); 264int RSA_set_ex_data(RSA *r,int idx,void *arg);
247char *RSA_get_ex_data(RSA *r, int idx); 265void *RSA_get_ex_data(RSA *r, int idx);
248 266
249/* BEGIN ERROR CODES */ 267/* BEGIN ERROR CODES */
250/* The following lines are auto generated by the script mkerr.pl. Any changes 268/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -262,6 +280,7 @@ char *RSA_get_ex_data(RSA *r, int idx);
262#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 280#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104
263#define RSA_F_RSA_GENERATE_KEY 105 281#define RSA_F_RSA_GENERATE_KEY 105
264#define RSA_F_RSA_NEW_METHOD 106 282#define RSA_F_RSA_NEW_METHOD 106
283#define RSA_F_RSA_NULL 124
265#define RSA_F_RSA_PADDING_ADD_NONE 107 284#define RSA_F_RSA_PADDING_ADD_NONE 107
266#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 285#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121
267#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 286#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108
@@ -292,10 +311,11 @@ char *RSA_get_ex_data(RSA *r, int idx);
292#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 311#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
293#define RSA_R_DATA_TOO_SMALL 111 312#define RSA_R_DATA_TOO_SMALL 111
294#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 313#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122
295#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
296#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 314#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
297#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 315#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124
298#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 316#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
317#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
318#define RSA_R_INVALID_MESSAGE_LENGTH 131
299#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 319#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
300#define RSA_R_KEY_SIZE_TOO_SMALL 120 320#define RSA_R_KEY_SIZE_TOO_SMALL 120
301#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 321#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
@@ -304,6 +324,7 @@ char *RSA_get_ex_data(RSA *r, int idx);
304#define RSA_R_PADDING_CHECK_FAILED 114 324#define RSA_R_PADDING_CHECK_FAILED 114
305#define RSA_R_P_NOT_PRIME 128 325#define RSA_R_P_NOT_PRIME 128
306#define RSA_R_Q_NOT_PRIME 129 326#define RSA_R_Q_NOT_PRIME 129
327#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
307#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 328#define RSA_R_SSLV3_ROLLBACK_ATTACK 115
308#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 329#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
309#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 330#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index 776324860c..179b7da90a 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -72,6 +72,8 @@
72#include <openssl/rsa.h> 72#include <openssl/rsa.h>
73#include <openssl/rand.h> 73#include <openssl/rand.h>
74 74
75#ifndef RSA_NULL
76
75static int RSA_eay_public_encrypt(int flen, unsigned char *from, 77static int RSA_eay_public_encrypt(int flen, unsigned char *from,
76 unsigned char *to, RSA *rsa,int padding); 78 unsigned char *to, RSA *rsa,int padding);
77static int RSA_eay_private_encrypt(int flen, unsigned char *from, 79static int RSA_eay_private_encrypt(int flen, unsigned char *from,
@@ -285,4 +287,4 @@ static int RSA_eay_finish(RSA *rsa)
285 return(1); 287 return(1);
286 } 288 }
287 289
288 290#endif
diff --git a/src/lib/libcrypto/rsa/rsa_err.c b/src/lib/libcrypto/rsa/rsa_err.c
index 9fb15e398d..5cfbea2b03 100644
--- a/src/lib/libcrypto/rsa/rsa_err.c
+++ b/src/lib/libcrypto/rsa/rsa_err.c
@@ -73,6 +73,7 @@ static ERR_STRING_DATA RSA_str_functs[]=
73{ERR_PACK(0,RSA_F_RSA_EAY_PUBLIC_ENCRYPT,0), "RSA_EAY_PUBLIC_ENCRYPT"}, 73{ERR_PACK(0,RSA_F_RSA_EAY_PUBLIC_ENCRYPT,0), "RSA_EAY_PUBLIC_ENCRYPT"},
74{ERR_PACK(0,RSA_F_RSA_GENERATE_KEY,0), "RSA_generate_key"}, 74{ERR_PACK(0,RSA_F_RSA_GENERATE_KEY,0), "RSA_generate_key"},
75{ERR_PACK(0,RSA_F_RSA_NEW_METHOD,0), "RSA_new_method"}, 75{ERR_PACK(0,RSA_F_RSA_NEW_METHOD,0), "RSA_new_method"},
76{ERR_PACK(0,RSA_F_RSA_NULL,0), "RSA_NULL"},
76{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_NONE,0), "RSA_padding_add_none"}, 77{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_NONE,0), "RSA_padding_add_none"},
77{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_OAEP,0), "RSA_padding_add_PKCS1_OAEP"}, 78{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_OAEP,0), "RSA_padding_add_PKCS1_OAEP"},
78{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,0), "RSA_padding_add_PKCS1_type_1"}, 79{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,0), "RSA_padding_add_PKCS1_type_1"},
@@ -106,10 +107,11 @@ static ERR_STRING_DATA RSA_str_reasons[]=
106{RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"}, 107{RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"},
107{RSA_R_DATA_TOO_SMALL ,"data too small"}, 108{RSA_R_DATA_TOO_SMALL ,"data too small"},
108{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE ,"data too small for key size"}, 109{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE ,"data too small for key size"},
109{RSA_R_D_E_NOT_CONGRUENT_TO_1 ,"d e not congruent to 1"},
110{RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY ,"digest too big for rsa key"}, 110{RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY ,"digest too big for rsa key"},
111{RSA_R_DMP1_NOT_CONGRUENT_TO_D ,"dmp1 not congruent to d"}, 111{RSA_R_DMP1_NOT_CONGRUENT_TO_D ,"dmp1 not congruent to d"},
112{RSA_R_DMQ1_NOT_CONGRUENT_TO_D ,"dmq1 not congruent to d"}, 112{RSA_R_DMQ1_NOT_CONGRUENT_TO_D ,"dmq1 not congruent to d"},
113{RSA_R_D_E_NOT_CONGRUENT_TO_1 ,"d e not congruent to 1"},
114{RSA_R_INVALID_MESSAGE_LENGTH ,"invalid message length"},
113{RSA_R_IQMP_NOT_INVERSE_OF_Q ,"iqmp not inverse of q"}, 115{RSA_R_IQMP_NOT_INVERSE_OF_Q ,"iqmp not inverse of q"},
114{RSA_R_KEY_SIZE_TOO_SMALL ,"key size too small"}, 116{RSA_R_KEY_SIZE_TOO_SMALL ,"key size too small"},
115{RSA_R_NULL_BEFORE_BLOCK_MISSING ,"null before block missing"}, 117{RSA_R_NULL_BEFORE_BLOCK_MISSING ,"null before block missing"},
@@ -118,6 +120,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
118{RSA_R_PADDING_CHECK_FAILED ,"padding check failed"}, 120{RSA_R_PADDING_CHECK_FAILED ,"padding check failed"},
119{RSA_R_P_NOT_PRIME ,"p not prime"}, 121{RSA_R_P_NOT_PRIME ,"p not prime"},
120{RSA_R_Q_NOT_PRIME ,"q not prime"}, 122{RSA_R_Q_NOT_PRIME ,"q not prime"},
123{RSA_R_RSA_OPERATIONS_NOT_SUPPORTED ,"rsa operations not supported"},
121{RSA_R_SSLV3_ROLLBACK_ATTACK ,"sslv3 rollback attack"}, 124{RSA_R_SSLV3_ROLLBACK_ATTACK ,"sslv3 rollback attack"},
122{RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"}, 125{RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
123{RSA_R_UNKNOWN_ALGORITHM_TYPE ,"unknown algorithm type"}, 126{RSA_R_UNKNOWN_ALGORITHM_TYPE ,"unknown algorithm type"},
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c
index 3227dba794..b1ee5d8dce 100644
--- a/src/lib/libcrypto/rsa/rsa_gen.c
+++ b/src/lib/libcrypto/rsa/rsa_gen.c
@@ -85,6 +85,7 @@ err:
85 RSAerr(RSA_F_RSA_GENERATE_KEY,ERR_LIB_BN); 85 RSAerr(RSA_F_RSA_GENERATE_KEY,ERR_LIB_BN);
86 ok=0; 86 ok=0;
87 } 87 }
88 BN_CTX_end(ctx);
88 BN_CTX_free(ctx); 89 BN_CTX_free(ctx);
89 BN_CTX_free(ctx2); 90 BN_CTX_free(ctx2);
90 91
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index c0ca2923a6..074a4f5074 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -67,7 +67,7 @@ const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
67 67
68static RSA_METHOD *default_RSA_meth=NULL; 68static RSA_METHOD *default_RSA_meth=NULL;
69static int rsa_meth_num=0; 69static int rsa_meth_num=0;
70static STACK *rsa_meth=NULL; 70static STACK_OF(CRYPTO_EX_DATA_FUNCS) *rsa_meth=NULL;
71 71
72RSA *RSA_new(void) 72RSA *RSA_new(void)
73 { 73 {
@@ -105,11 +105,15 @@ RSA *RSA_new_method(RSA_METHOD *meth)
105 105
106 if (default_RSA_meth == NULL) 106 if (default_RSA_meth == NULL)
107 { 107 {
108#ifdef RSA_NULL
109 default_RSA_meth=RSA_null_method();
110#else
108#ifdef RSAref 111#ifdef RSAref
109 default_RSA_meth=RSA_PKCS1_RSAref(); 112 default_RSA_meth=RSA_PKCS1_RSAref();
110#else 113#else
111 default_RSA_meth=RSA_PKCS1_SSLeay(); 114 default_RSA_meth=RSA_PKCS1_SSLeay();
112#endif 115#endif
116#endif
113 } 117 }
114 ret=(RSA *)Malloc(sizeof(RSA)); 118 ret=(RSA *)Malloc(sizeof(RSA));
115 if (ret == NULL) 119 if (ret == NULL)
@@ -146,7 +150,7 @@ RSA *RSA_new_method(RSA_METHOD *meth)
146 ret=NULL; 150 ret=NULL;
147 } 151 }
148 else 152 else
149 CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data); 153 CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data);
150 return(ret); 154 return(ret);
151 } 155 }
152 156
@@ -169,7 +173,7 @@ void RSA_free(RSA *r)
169 } 173 }
170#endif 174#endif
171 175
172 CRYPTO_free_ex_data(rsa_meth,(char *)r,&r->ex_data); 176 CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data);
173 177
174 if (r->meth->finish != NULL) 178 if (r->meth->finish != NULL)
175 r->meth->finish(r); 179 r->meth->finish(r);
@@ -187,20 +191,20 @@ void RSA_free(RSA *r)
187 Free(r); 191 Free(r);
188 } 192 }
189 193
190int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), 194int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
191 int (*dup_func)(), void (*free_func)()) 195 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
192 { 196 {
193 rsa_meth_num++; 197 rsa_meth_num++;
194 return(CRYPTO_get_ex_new_index(rsa_meth_num-1, 198 return(CRYPTO_get_ex_new_index(rsa_meth_num-1,
195 &rsa_meth,argl,argp,new_func,dup_func,free_func)); 199 &rsa_meth,argl,argp,new_func,dup_func,free_func));
196 } 200 }
197 201
198int RSA_set_ex_data(RSA *r, int idx, char *arg) 202int RSA_set_ex_data(RSA *r, int idx, void *arg)
199 { 203 {
200 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); 204 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
201 } 205 }
202 206
203char *RSA_get_ex_data(RSA *r, int idx) 207void *RSA_get_ex_data(RSA *r, int idx)
204 { 208 {
205 return(CRYPTO_get_ex_data(&r->ex_data,idx)); 209 return(CRYPTO_get_ex_data(&r->ex_data,idx));
206 } 210 }
@@ -265,19 +269,19 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
265 if (rsa->blinding != NULL) 269 if (rsa->blinding != NULL)
266 BN_BLINDING_free(rsa->blinding); 270 BN_BLINDING_free(rsa->blinding);
267 271
268 A= &(ctx->bn[0]); 272 BN_CTX_start(ctx);
269 ctx->tos++; 273 A = BN_CTX_get(ctx);
270 if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err; 274 if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err;
271 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; 275 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
272 276
273 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) 277 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
274 goto err; 278 goto err;
275 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); 279 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n);
276 ctx->tos--;
277 rsa->flags|=RSA_FLAG_BLINDING; 280 rsa->flags|=RSA_FLAG_BLINDING;
278 BN_free(Ai); 281 BN_free(Ai);
279 ret=1; 282 ret=1;
280err: 283err:
284 BN_CTX_end(ctx);
281 if (ctx != p_ctx) BN_CTX_free(ctx); 285 if (ctx != p_ctx) BN_CTX_free(ctx);
282 return(ret); 286 return(ret);
283 } 287 }
diff --git a/src/lib/libcrypto/rsa/rsa_null.c b/src/lib/libcrypto/rsa/rsa_null.c
new file mode 100644
index 0000000000..7b58a0eca3
--- /dev/null
+++ b/src/lib/libcrypto/rsa/rsa_null.c
@@ -0,0 +1,149 @@
1/* rsa_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/bn.h>
62#include <openssl/rsa.h>
63#include <openssl/rand.h>
64
65/* This is a dummy RSA implementation that just returns errors when called.
66 * It is designed to allow some RSA functions to work while stopping those
67 * covered by the RSA patent. That is RSA, encryption, decryption, signing
68 * and verify is not allowed but RSA key generation, key checking and other
69 * operations (like storing RSA keys) are permitted.
70 */
71
72static int RSA_null_public_encrypt(int flen, unsigned char *from,
73 unsigned char *to, RSA *rsa,int padding);
74static int RSA_null_private_encrypt(int flen, unsigned char *from,
75 unsigned char *to, RSA *rsa,int padding);
76static int RSA_null_public_decrypt(int flen, unsigned char *from,
77 unsigned char *to, RSA *rsa,int padding);
78static int RSA_null_private_decrypt(int flen, unsigned char *from,
79 unsigned char *to, RSA *rsa,int padding);
80#if 0 /* not currently used */
81static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *i, RSA *rsa);
82#endif
83static int RSA_null_init(RSA *rsa);
84static int RSA_null_finish(RSA *rsa);
85static RSA_METHOD rsa_null_meth={
86 "Null RSA",
87 RSA_null_public_encrypt,
88 RSA_null_public_decrypt,
89 RSA_null_private_encrypt,
90 RSA_null_private_decrypt,
91 NULL, NULL,
92 RSA_null_init,
93 RSA_null_finish,
94 0,
95 NULL,
96 };
97
98RSA_METHOD *RSA_null_method(void)
99 {
100 return(&rsa_null_meth);
101 }
102
103static int RSA_null_public_encrypt(int flen, unsigned char *from,
104 unsigned char *to, RSA *rsa, int padding)
105 {
106 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
107 return -1;
108 }
109
110static int RSA_null_private_encrypt(int flen, unsigned char *from,
111 unsigned char *to, RSA *rsa, int padding)
112 {
113 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
114 return -1;
115 }
116
117static int RSA_null_private_decrypt(int flen, unsigned char *from,
118 unsigned char *to, RSA *rsa, int padding)
119 {
120 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
121 return -1;
122 }
123
124static int RSA_null_public_decrypt(int flen, unsigned char *from,
125 unsigned char *to, RSA *rsa, int padding)
126 {
127 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
128 return -1;
129 }
130
131#if 0 /* not currently used */
132static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
133 {
134 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
135 return -1;
136 }
137#endif
138
139static int RSA_null_init(RSA *rsa)
140 {
141 return(1);
142 }
143
144static int RSA_null_finish(RSA *rsa)
145 {
146 return(1);
147 }
148
149
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c
index 843c40c864..1465c01f4f 100644
--- a/src/lib/libcrypto/rsa/rsa_oaep.c
+++ b/src/lib/libcrypto/rsa/rsa_oaep.c
@@ -50,7 +50,8 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
50 emlen - flen - 2 * SHA_DIGEST_LENGTH - 1); 50 emlen - flen - 2 * SHA_DIGEST_LENGTH - 1);
51 db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01; 51 db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01;
52 memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, (unsigned int) flen); 52 memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, (unsigned int) flen);
53 RAND_bytes(seed, SHA_DIGEST_LENGTH); 53 if (RAND_bytes(seed, SHA_DIGEST_LENGTH) <= 0)
54 return (0);
54#ifdef PKCS_TESTVECT 55#ifdef PKCS_TESTVECT
55 memcpy(seed, 56 memcpy(seed,
56 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f", 57 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f",
diff --git a/src/lib/libcrypto/rsa/rsa_oaep_test.c b/src/lib/libcrypto/rsa/rsa_oaep_test.c
index 0d4e39d3da..e69de29bb2 100644
--- a/src/lib/libcrypto/rsa/rsa_oaep_test.c
+++ b/src/lib/libcrypto/rsa/rsa_oaep_test.c
@@ -1,309 +0,0 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "openssl/e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#ifdef NO_RSA
11int main(int argc, char *argv[])
12{
13 printf("No RSA support\n");
14 return(0);
15}
16#else
17#include <openssl/rsa.h>
18
19#define SetKey \
20 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
21 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
22 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
23 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
24 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
25 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
26 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
27 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
28 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
29 return (sizeof(ctext_ex) - 1);
30
31static int key1(RSA *key, unsigned char *c)
32 {
33 static unsigned char n[] =
34"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
35"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
36"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
37"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
38"\xF5";
39
40 static unsigned char e[] = "\x11";
41
42 static unsigned char d[] =
43"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
44"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
45"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
46"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
47
48 static unsigned char p[] =
49"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
50"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
51"\x0D";
52
53 static unsigned char q[] =
54"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
55"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
56"\x89";
57
58 static unsigned char dmp1[] =
59"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
60"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
61
62 static unsigned char dmq1[] =
63"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
64"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
65"\x51";
66
67 static unsigned char iqmp[] =
68"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
69"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
70
71 static unsigned char ctext_ex[] =
72"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
73"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
74"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
75"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
76
77 SetKey;
78 }
79
80static int key2(RSA *key, unsigned char *c)
81 {
82 static unsigned char n[] =
83"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
84"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
85"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
86"\x34\x77\xCF";
87
88 static unsigned char e[] = "\x3";
89
90 static unsigned char d[] =
91"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
92"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
93"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
94"\xE5\xEB";
95
96 static unsigned char p[] =
97"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
98"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
99
100 static unsigned char q[] =
101"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
102"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
103
104 static unsigned char dmp1[] =
105"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
106"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
107
108 static unsigned char dmq1[] =
109"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
110"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
111
112 static unsigned char iqmp[] =
113"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
114"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
115
116 static unsigned char ctext_ex[] =
117"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
118"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
119"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
120"\x62\x51";
121
122 SetKey;
123 }
124
125static int key3(RSA *key, unsigned char *c)
126 {
127 static unsigned char n[] =
128"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
129"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
130"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
131"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
132"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
133"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
134"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
135"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
136"\xCB";
137
138 static unsigned char e[] = "\x11";
139
140 static unsigned char d[] =
141"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
142"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
143"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
144"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
145"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
146"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
147"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
148"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
149"\xC1";
150
151 static unsigned char p[] =
152"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
153"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
154"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
155"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
156"\x99";
157
158 static unsigned char q[] =
159"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
160"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
161"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
162"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
163"\x03";
164
165 static unsigned char dmp1[] =
166"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
167"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
168"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
169"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
170
171 static unsigned char dmq1[] =
172"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
173"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
174"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
175"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
176
177 static unsigned char iqmp[] =
178"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
179"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
180"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
181"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
182"\xF7";
183
184 static unsigned char ctext_ex[] =
185"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
186"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
187"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
188"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
189"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
190"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
191"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
192"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
193
194 SetKey;
195 }
196
197static int pad_unknown(void)
198{
199 unsigned long l;
200 while ((l = ERR_get_error()) != 0)
201 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
202 return(1);
203 return(0);
204}
205
206int main()
207 {
208 int err=0;
209 int v;
210 RSA *key;
211 unsigned char ptext[256];
212 unsigned char ctext[256];
213 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
214 unsigned char ctext_ex[256];
215 int plen;
216 int clen = 0;
217 int num;
218
219 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
220
221 plen = sizeof(ptext_ex) - 1;
222
223 for (v = 0; v < 3; v++)
224 {
225 key = RSA_new();
226 switch (v) {
227 case 0:
228 clen = key1(key, ctext_ex);
229 break;
230 case 1:
231 clen = key2(key, ctext_ex);
232 break;
233 case 2:
234 clen = key3(key, ctext_ex);
235 break;
236 }
237
238 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
239 RSA_PKCS1_PADDING);
240 if (num != clen)
241 {
242 printf("PKCS#1 v1.5 encryption failed!\n");
243 err=1;
244 goto oaep;
245 }
246
247 num = RSA_private_decrypt(num, ctext, ptext, key,
248 RSA_PKCS1_PADDING);
249 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
250 {
251 printf("PKCS#1 v1.5 decryption failed!\n");
252 err=1;
253 }
254 else
255 printf("PKCS #1 v1.5 encryption/decryption ok\n");
256
257 oaep:
258 ERR_clear_error();
259 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
260 RSA_PKCS1_OAEP_PADDING);
261 if (num == -1 && pad_unknown())
262 {
263 printf("No OAEP support\n");
264 goto next;
265 }
266 if (num != clen)
267 {
268 printf("OAEP encryption failed!\n");
269 err=1;
270 goto next;
271 }
272
273 num = RSA_private_decrypt(num, ctext, ptext, key,
274 RSA_PKCS1_OAEP_PADDING);
275 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
276 {
277 printf("OAEP decryption (encrypted data) failed!\n");
278 err=1;
279 }
280 else if (memcmp(ctext, ctext_ex, num) == 0)
281 {
282 printf("OAEP test vector %d passed!\n", v);
283 goto next;
284 }
285
286 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
287 Try decrypting ctext_ex */
288
289 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
290 RSA_PKCS1_OAEP_PADDING);
291
292 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
293 {
294 printf("OAEP decryption (test vector data) failed!\n");
295 err=1;
296 }
297 else
298 printf("OAEP encryption/decryption ok\n");
299 next:
300 RSA_free(key);
301 }
302
303 ERR_remove_state(0);
304
305 CRYPTO_mem_leaks_fp(stdout);
306
307 return err;
308 }
309#endif
diff --git a/src/lib/libcrypto/rsa/rsa_pk1.c b/src/lib/libcrypto/rsa/rsa_pk1.c
index f0ae51f234..48a32bc264 100644
--- a/src/lib/libcrypto/rsa/rsa_pk1.c
+++ b/src/lib/libcrypto/rsa/rsa_pk1.c
@@ -79,7 +79,7 @@ int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
79 *(p++)=0; 79 *(p++)=0;
80 *(p++)=1; /* Private Key BT (Block Type) */ 80 *(p++)=1; /* Private Key BT (Block Type) */
81 81
82 /* padd out with 0xff data */ 82 /* pad out with 0xff data */
83 j=tlen-3-flen; 83 j=tlen-3-flen;
84 memset(p,0xff,j); 84 memset(p,0xff,j);
85 p+=j; 85 p+=j;
@@ -130,6 +130,11 @@ int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
130 } 130 }
131 i++; /* Skip over the '\0' */ 131 i++; /* Skip over the '\0' */
132 j-=i; 132 j-=i;
133 if (j > tlen)
134 {
135 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE);
136 return(-1);
137 }
133 memcpy(to,p,(unsigned int)j); 138 memcpy(to,p,(unsigned int)j);
134 139
135 return(j); 140 return(j);
@@ -155,12 +160,14 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
155 /* pad out with non-zero random data */ 160 /* pad out with non-zero random data */
156 j=tlen-3-flen; 161 j=tlen-3-flen;
157 162
158 RAND_bytes(p,j); 163 if (RAND_bytes(p,j) <= 0)
164 return(0);
159 for (i=0; i<j; i++) 165 for (i=0; i<j; i++)
160 { 166 {
161 if (*p == '\0') 167 if (*p == '\0')
162 do { 168 do {
163 RAND_bytes(p,1); 169 if (RAND_bytes(p,1) <= 0)
170 return(0);
164 } while (*p == '\0'); 171 } while (*p == '\0');
165 p++; 172 p++;
166 } 173 }
@@ -205,6 +212,11 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
205 } 212 }
206 i++; /* Skip over the '\0' */ 213 i++; /* Skip over the '\0' */
207 j-=i; 214 j-=i;
215 if (j > tlen)
216 {
217 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_DATA_TOO_LARGE);
218 return(-1);
219 }
208 memcpy(to,p,(unsigned int)j); 220 memcpy(to,p,(unsigned int)j);
209 221
210 return(j); 222 return(j);
diff --git a/src/lib/libcrypto/rsa/rsa_saos.c b/src/lib/libcrypto/rsa/rsa_saos.c
index 73b8b0c7ad..61efb0b00f 100644
--- a/src/lib/libcrypto/rsa/rsa_saos.c
+++ b/src/lib/libcrypto/rsa/rsa_saos.c
@@ -136,7 +136,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype, unsigned char *m,
136 else 136 else
137 ret=1; 137 ret=1;
138err: 138err:
139 if (sig != NULL) ASN1_OCTET_STRING_free(sig); 139 if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
140 memset(s,0,(unsigned int)siglen); 140 memset(s,0,(unsigned int)siglen);
141 Free(s); 141 Free(s);
142 return(ret); 142 return(ret);
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 1740494a4c..05bb7fb74a 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -63,59 +63,77 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66/* Size of an SSL signature: MD5+SHA1 */
67#define SSL_SIG_LENGTH 36
68
66int RSA_sign(int type, unsigned char *m, unsigned int m_len, 69int RSA_sign(int type, unsigned char *m, unsigned int m_len,
67 unsigned char *sigret, unsigned int *siglen, RSA *rsa) 70 unsigned char *sigret, unsigned int *siglen, RSA *rsa)
68 { 71 {
69 X509_SIG sig; 72 X509_SIG sig;
70 ASN1_TYPE parameter; 73 ASN1_TYPE parameter;
71 int i,j,ret=1; 74 int i,j,ret=1;
72 unsigned char *p,*s; 75 unsigned char *p,*s = NULL;
73 X509_ALGOR algor; 76 X509_ALGOR algor;
74 ASN1_OCTET_STRING digest; 77 ASN1_OCTET_STRING digest;
75 78 if(rsa->flags & RSA_FLAG_SIGN_VER)
76 sig.algor= &algor; 79 return rsa->meth->rsa_sign(type, m, m_len, sigret, siglen, rsa);
77 sig.algor->algorithm=OBJ_nid2obj(type); 80 /* Special case: SSL signature, just check the length */
78 if (sig.algor->algorithm == NULL) 81 if(type == NID_md5_sha1) {
79 { 82 if(m_len != SSL_SIG_LENGTH) {
80 RSAerr(RSA_F_RSA_SIGN,RSA_R_UNKNOWN_ALGORITHM_TYPE); 83 RSAerr(RSA_F_RSA_SIGN,RSA_R_INVALID_MESSAGE_LENGTH);
81 return(0); 84 return(0);
82 }
83 if (sig.algor->algorithm->length == 0)
84 {
85 RSAerr(RSA_F_RSA_SIGN,RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
86 return(0);
87 } 85 }
88 parameter.type=V_ASN1_NULL; 86 i = SSL_SIG_LENGTH;
89 parameter.value.ptr=NULL; 87 s = m;
90 sig.algor->parameter= &parameter; 88 } else {
89 sig.algor= &algor;
90 sig.algor->algorithm=OBJ_nid2obj(type);
91 if (sig.algor->algorithm == NULL)
92 {
93 RSAerr(RSA_F_RSA_SIGN,RSA_R_UNKNOWN_ALGORITHM_TYPE);
94 return(0);
95 }
96 if (sig.algor->algorithm->length == 0)
97 {
98 RSAerr(RSA_F_RSA_SIGN,RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
99 return(0);
100 }
101 parameter.type=V_ASN1_NULL;
102 parameter.value.ptr=NULL;
103 sig.algor->parameter= &parameter;
91 104
92 sig.digest= &digest; 105 sig.digest= &digest;
93 sig.digest->data=m; 106 sig.digest->data=m;
94 sig.digest->length=m_len; 107 sig.digest->length=m_len;
95 108
96 i=i2d_X509_SIG(&sig,NULL); 109 i=i2d_X509_SIG(&sig,NULL);
110 }
97 j=RSA_size(rsa); 111 j=RSA_size(rsa);
98 if ((i-RSA_PKCS1_PADDING) > j) 112 if ((i-RSA_PKCS1_PADDING) > j)
99 { 113 {
100 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); 114 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
101 return(0); 115 return(0);
102 } 116 }
103 s=(unsigned char *)Malloc((unsigned int)j+1); 117 if(type != NID_md5_sha1) {
104 if (s == NULL) 118 s=(unsigned char *)Malloc((unsigned int)j+1);
105 { 119 if (s == NULL)
106 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE); 120 {
107 return(0); 121 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE);
108 } 122 return(0);
109 p=s; 123 }
110 i2d_X509_SIG(&sig,&p); 124 p=s;
125 i2d_X509_SIG(&sig,&p);
126 }
111 i=RSA_private_encrypt(i,s,sigret,rsa,RSA_PKCS1_PADDING); 127 i=RSA_private_encrypt(i,s,sigret,rsa,RSA_PKCS1_PADDING);
112 if (i <= 0) 128 if (i <= 0)
113 ret=0; 129 ret=0;
114 else 130 else
115 *siglen=i; 131 *siglen=i;
116 132
117 memset(s,0,(unsigned int)j+1); 133 if(type != NID_md5_sha1) {
118 Free(s); 134 memset(s,0,(unsigned int)j+1);
135 Free(s);
136 }
119 return(ret); 137 return(ret);
120 } 138 }
121 139
@@ -132,53 +150,68 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
132 return(0); 150 return(0);
133 } 151 }
134 152
153 if(rsa->flags & RSA_FLAG_SIGN_VER)
154 return rsa->meth->rsa_verify(dtype, m, m_len, sigbuf, siglen, rsa);
155
135 s=(unsigned char *)Malloc((unsigned int)siglen); 156 s=(unsigned char *)Malloc((unsigned int)siglen);
136 if (s == NULL) 157 if (s == NULL)
137 { 158 {
138 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE); 159 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE);
139 goto err; 160 goto err;
140 } 161 }
162 if((dtype == NID_md5_sha1) && (m_len != SSL_SIG_LENGTH) ) {
163 RSAerr(RSA_F_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH);
164 return(0);
165 }
141 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING); 166 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);
142 167
143 if (i <= 0) goto err; 168 if (i <= 0) goto err;
144 169
145 p=s; 170 /* Special case: SSL signature */
146 sig=d2i_X509_SIG(NULL,&p,(long)i); 171 if(dtype == NID_md5_sha1) {
172 if((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH))
173 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
174 else ret = 1;
175 } else {
176 p=s;
177 sig=d2i_X509_SIG(NULL,&p,(long)i);
147 178
148 if (sig == NULL) goto err; 179 if (sig == NULL) goto err;
149 sigtype=OBJ_obj2nid(sig->algor->algorithm); 180 sigtype=OBJ_obj2nid(sig->algor->algorithm);
150 181
151 182
152#ifdef RSA_DEBUG 183 #ifdef RSA_DEBUG
153 /* put a backward compatability flag in EAY */ 184 /* put a backward compatibility flag in EAY */
154 fprintf(stderr,"in(%s) expect(%s)\n",OBJ_nid2ln(sigtype), 185 fprintf(stderr,"in(%s) expect(%s)\n",OBJ_nid2ln(sigtype),
155 OBJ_nid2ln(dtype)); 186 OBJ_nid2ln(dtype));
156#endif 187 #endif
157 if (sigtype != dtype) 188 if (sigtype != dtype)
158 {
159 if (((dtype == NID_md5) &&
160 (sigtype == NID_md5WithRSAEncryption)) ||
161 ((dtype == NID_md2) &&
162 (sigtype == NID_md2WithRSAEncryption)))
163 { 189 {
164 /* ok, we will let it through */ 190 if (((dtype == NID_md5) &&
165#if !defined(NO_STDIO) && !defined(WIN16) 191 (sigtype == NID_md5WithRSAEncryption)) ||
166 fprintf(stderr,"signature has problems, re-make with post SSLeay045\n"); 192 ((dtype == NID_md2) &&
167#endif 193 (sigtype == NID_md2WithRSAEncryption)))
194 {
195 /* ok, we will let it through */
196 #if !defined(NO_STDIO) && !defined(WIN16)
197 fprintf(stderr,"signature has problems, re-make with post SSLeay045\n");
198 #endif
199 }
200 else
201 {
202 RSAerr(RSA_F_RSA_VERIFY,
203 RSA_R_ALGORITHM_MISMATCH);
204 goto err;
205 }
168 } 206 }
169 else 207 if ( ((unsigned int)sig->digest->length != m_len) ||
208 (memcmp(m,sig->digest->data,m_len) != 0))
170 { 209 {
171 RSAerr(RSA_F_RSA_VERIFY,RSA_R_ALGORITHM_MISMATCH); 210 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
172 goto err;
173 } 211 }
174 } 212 else
175 if ( ((unsigned int)sig->digest->length != m_len) || 213 ret=1;
176 (memcmp(m,sig->digest->data,m_len) != 0)) 214 }
177 {
178 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
179 }
180 else
181 ret=1;
182err: 215err:
183 if (sig != NULL) X509_SIG_free(sig); 216 if (sig != NULL) X509_SIG_free(sig);
184 memset(s,0,(unsigned int)siglen); 217 memset(s,0,(unsigned int)siglen);
diff --git a/src/lib/libcrypto/rsa/rsa_ssl.c b/src/lib/libcrypto/rsa/rsa_ssl.c
index 1050844f8d..81a857c813 100644
--- a/src/lib/libcrypto/rsa/rsa_ssl.c
+++ b/src/lib/libcrypto/rsa/rsa_ssl.c
@@ -82,12 +82,14 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, unsigned char *from,
82 /* pad out with non-zero random data */ 82 /* pad out with non-zero random data */
83 j=tlen-3-8-flen; 83 j=tlen-3-8-flen;
84 84
85 RAND_bytes(p,j); 85 if (RAND_bytes(p,j) <= 0)
86 return(0);
86 for (i=0; i<j; i++) 87 for (i=0; i<j; i++)
87 { 88 {
88 if (*p == '\0') 89 if (*p == '\0')
89 do { 90 do {
90 RAND_bytes(p,1); 91 if (RAND_bytes(p,1) <= 0)
92 return(0);
91 } while (*p == '\0'); 93 } while (*p == '\0');
92 p++; 94 p++;
93 } 95 }
@@ -140,6 +142,11 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,
140 142
141 i++; /* Skip over the '\0' */ 143 i++; /* Skip over the '\0' */
142 j-=i; 144 j-=i;
145 if (j > tlen)
146 {
147 RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_DATA_TOO_LARGE);
148 return(-1);
149 }
143 memcpy(to,p,(unsigned int)j); 150 memcpy(to,p,(unsigned int)j);
144 151
145 return(j); 152 return(j);
diff --git a/src/lib/libcrypto/rsa/rsa_test.c b/src/lib/libcrypto/rsa/rsa_test.c
new file mode 100644
index 0000000000..e5ae0c1f69
--- /dev/null
+++ b/src/lib/libcrypto/rsa/rsa_test.c
@@ -0,0 +1,314 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "openssl/e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#include <openssl/rand.h>
11#ifdef NO_RSA
12int main(int argc, char *argv[])
13{
14 printf("No RSA support\n");
15 return(0);
16}
17#else
18#include <openssl/rsa.h>
19
20#define SetKey \
21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
22 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
23 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
24 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
25 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
26 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
27 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
28 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
29 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
30 return (sizeof(ctext_ex) - 1);
31
32static int key1(RSA *key, unsigned char *c)
33 {
34 static unsigned char n[] =
35"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
36"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
37"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
38"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
39"\xF5";
40
41 static unsigned char e[] = "\x11";
42
43 static unsigned char d[] =
44"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
45"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
46"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
47"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
48
49 static unsigned char p[] =
50"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
51"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
52"\x0D";
53
54 static unsigned char q[] =
55"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
56"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
57"\x89";
58
59 static unsigned char dmp1[] =
60"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
61"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
62
63 static unsigned char dmq1[] =
64"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
65"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
66"\x51";
67
68 static unsigned char iqmp[] =
69"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
70"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
71
72 static unsigned char ctext_ex[] =
73"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
74"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
75"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
76"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
77
78 SetKey;
79 }
80
81static int key2(RSA *key, unsigned char *c)
82 {
83 static unsigned char n[] =
84"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
85"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
86"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
87"\x34\x77\xCF";
88
89 static unsigned char e[] = "\x3";
90
91 static unsigned char d[] =
92"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
93"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
94"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
95"\xE5\xEB";
96
97 static unsigned char p[] =
98"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
99"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
100
101 static unsigned char q[] =
102"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
103"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
104
105 static unsigned char dmp1[] =
106"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
107"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
108
109 static unsigned char dmq1[] =
110"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
111"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
112
113 static unsigned char iqmp[] =
114"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
115"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
116
117 static unsigned char ctext_ex[] =
118"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
119"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
120"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
121"\x62\x51";
122
123 SetKey;
124 }
125
126static int key3(RSA *key, unsigned char *c)
127 {
128 static unsigned char n[] =
129"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
130"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
131"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
132"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
133"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
134"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
135"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
136"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
137"\xCB";
138
139 static unsigned char e[] = "\x11";
140
141 static unsigned char d[] =
142"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
143"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
144"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
145"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
146"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
147"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
148"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
149"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
150"\xC1";
151
152 static unsigned char p[] =
153"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
154"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
155"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
156"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
157"\x99";
158
159 static unsigned char q[] =
160"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
161"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
162"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
163"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
164"\x03";
165
166 static unsigned char dmp1[] =
167"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
168"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
169"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
170"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
171
172 static unsigned char dmq1[] =
173"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
174"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
175"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
176"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
177
178 static unsigned char iqmp[] =
179"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
180"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
181"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
182"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
183"\xF7";
184
185 static unsigned char ctext_ex[] =
186"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
187"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
188"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
189"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
190"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
191"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
192"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
193"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
194
195 SetKey;
196 }
197
198static int pad_unknown(void)
199{
200 unsigned long l;
201 while ((l = ERR_get_error()) != 0)
202 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
203 return(1);
204 return(0);
205}
206
207static const char rnd_seed[] = "string to make the random number generator think it has entropy";
208
209int main(int argc, char *argv[])
210 {
211 int err=0;
212 int v;
213 RSA *key;
214 unsigned char ptext[256];
215 unsigned char ctext[256];
216 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
217 unsigned char ctext_ex[256];
218 int plen;
219 int clen = 0;
220 int num;
221
222 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
223
224 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
225
226 plen = sizeof(ptext_ex) - 1;
227
228 for (v = 0; v < 3; v++)
229 {
230 key = RSA_new();
231 switch (v) {
232 case 0:
233 clen = key1(key, ctext_ex);
234 break;
235 case 1:
236 clen = key2(key, ctext_ex);
237 break;
238 case 2:
239 clen = key3(key, ctext_ex);
240 break;
241 }
242
243 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
244 RSA_PKCS1_PADDING);
245 if (num != clen)
246 {
247 printf("PKCS#1 v1.5 encryption failed!\n");
248 err=1;
249 goto oaep;
250 }
251
252 num = RSA_private_decrypt(num, ctext, ptext, key,
253 RSA_PKCS1_PADDING);
254 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
255 {
256 printf("PKCS#1 v1.5 decryption failed!\n");
257 err=1;
258 }
259 else
260 printf("PKCS #1 v1.5 encryption/decryption ok\n");
261
262 oaep:
263 ERR_clear_error();
264 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
265 RSA_PKCS1_OAEP_PADDING);
266 if (num == -1 && pad_unknown())
267 {
268 printf("No OAEP support\n");
269 goto next;
270 }
271 if (num != clen)
272 {
273 printf("OAEP encryption failed!\n");
274 err=1;
275 goto next;
276 }
277
278 num = RSA_private_decrypt(num, ctext, ptext, key,
279 RSA_PKCS1_OAEP_PADDING);
280 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
281 {
282 printf("OAEP decryption (encrypted data) failed!\n");
283 err=1;
284 }
285 else if (memcmp(ctext, ctext_ex, num) == 0)
286 {
287 printf("OAEP test vector %d passed!\n", v);
288 goto next;
289 }
290
291 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
292 Try decrypting ctext_ex */
293
294 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
295 RSA_PKCS1_OAEP_PADDING);
296
297 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
298 {
299 printf("OAEP decryption (test vector data) failed!\n");
300 err=1;
301 }
302 else
303 printf("OAEP encryption/decryption ok\n");
304 next:
305 RSA_free(key);
306 }
307
308 ERR_remove_state(0);
309
310 CRYPTO_mem_leaks_fp(stdout);
311
312 return err;
313 }
314#endif
diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl
index 6ea5b1d719..79ef43aa34 100644
--- a/src/lib/libcrypto/sha/Makefile.ssl
+++ b/src/lib/libcrypto/sha/Makefile.ssl
@@ -104,8 +104,8 @@ clean:
104sha1_one.o: ../../include/openssl/sha.h 104sha1_one.o: ../../include/openssl/sha.h
105sha1dgst.o: ../../include/openssl/opensslconf.h 105sha1dgst.o: ../../include/openssl/opensslconf.h
106sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 106sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
107sha1dgst.o: sha_locl.h 107sha1dgst.o: ../md32_common.h sha_locl.h
108sha_dgst.o: ../../include/openssl/opensslconf.h 108sha_dgst.o: ../../include/openssl/opensslconf.h
109sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 109sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
110sha_dgst.o: sha_locl.h 110sha_dgst.o: ../md32_common.h sha_locl.h
111sha_one.o: ../../include/openssl/sha.h 111sha_one.o: ../../include/openssl/sha.h
diff --git a/src/lib/libcrypto/sha/asm/s1-win32.asm b/src/lib/libcrypto/sha/asm/s1-win32.asm
index 61335666b9..699afdb022 100644
--- a/src/lib/libcrypto/sha/asm/s1-win32.asm
+++ b/src/lib/libcrypto/sha/asm/s1-win32.asm
@@ -8,302 +8,303 @@
8 .486 8 .486
9.model FLAT 9.model FLAT
10_TEXT SEGMENT 10_TEXT SEGMENT
11PUBLIC _sha1_block_x86 11PUBLIC _sha1_block_asm_data_order
12 12
13_sha1_block_x86 PROC NEAR 13_sha1_block_asm_data_order PROC NEAR
14 mov ecx, DWORD PTR 12[esp]
14 push esi 15 push esi
16 shl ecx, 6
17 mov esi, DWORD PTR 12[esp]
15 push ebp 18 push ebp
16 mov eax, DWORD PTR 20[esp] 19 add ecx, esi
17 mov esi, DWORD PTR 16[esp]
18 add eax, esi
19 mov ebp, DWORD PTR 12[esp]
20 push ebx 20 push ebx
21 sub eax, 64 21 mov ebp, DWORD PTR 16[esp]
22 push edi 22 push edi
23 mov ebx, DWORD PTR 4[ebp]
24 sub esp, 72
25 mov edx, DWORD PTR 12[ebp] 23 mov edx, DWORD PTR 12[ebp]
24 sub esp, 108
26 mov edi, DWORD PTR 16[ebp] 25 mov edi, DWORD PTR 16[ebp]
27 mov ecx, DWORD PTR 8[ebp] 26 mov ebx, DWORD PTR 8[ebp]
28 mov DWORD PTR 68[esp],eax 27 mov DWORD PTR 68[esp],ecx
29 ; First we need to setup the X array 28 ; First we need to setup the X array
30 mov eax, DWORD PTR [esi]
31L000start: 29L000start:
32 ; First, load the words onto the stack in network byte order 30 ; First, load the words onto the stack in network byte order
31 mov eax, DWORD PTR [esi]
32 mov ecx, DWORD PTR 4[esi]
33 bswap eax 33 bswap eax
34 bswap ecx
34 mov DWORD PTR [esp],eax 35 mov DWORD PTR [esp],eax
35 mov eax, DWORD PTR 4[esi] 36 mov DWORD PTR 4[esp],ecx
36 bswap eax
37 mov DWORD PTR 4[esp],eax
38 mov eax, DWORD PTR 8[esi] 37 mov eax, DWORD PTR 8[esi]
38 mov ecx, DWORD PTR 12[esi]
39 bswap eax 39 bswap eax
40 bswap ecx
40 mov DWORD PTR 8[esp],eax 41 mov DWORD PTR 8[esp],eax
41 mov eax, DWORD PTR 12[esi] 42 mov DWORD PTR 12[esp],ecx
42 bswap eax
43 mov DWORD PTR 12[esp],eax
44 mov eax, DWORD PTR 16[esi] 43 mov eax, DWORD PTR 16[esi]
44 mov ecx, DWORD PTR 20[esi]
45 bswap eax 45 bswap eax
46 bswap ecx
46 mov DWORD PTR 16[esp],eax 47 mov DWORD PTR 16[esp],eax
47 mov eax, DWORD PTR 20[esi] 48 mov DWORD PTR 20[esp],ecx
48 bswap eax
49 mov DWORD PTR 20[esp],eax
50 mov eax, DWORD PTR 24[esi] 49 mov eax, DWORD PTR 24[esi]
50 mov ecx, DWORD PTR 28[esi]
51 bswap eax 51 bswap eax
52 bswap ecx
52 mov DWORD PTR 24[esp],eax 53 mov DWORD PTR 24[esp],eax
53 mov eax, DWORD PTR 28[esi] 54 mov DWORD PTR 28[esp],ecx
54 bswap eax
55 mov DWORD PTR 28[esp],eax
56 mov eax, DWORD PTR 32[esi] 55 mov eax, DWORD PTR 32[esi]
56 mov ecx, DWORD PTR 36[esi]
57 bswap eax 57 bswap eax
58 bswap ecx
58 mov DWORD PTR 32[esp],eax 59 mov DWORD PTR 32[esp],eax
59 mov eax, DWORD PTR 36[esi] 60 mov DWORD PTR 36[esp],ecx
60 bswap eax
61 mov DWORD PTR 36[esp],eax
62 mov eax, DWORD PTR 40[esi] 61 mov eax, DWORD PTR 40[esi]
62 mov ecx, DWORD PTR 44[esi]
63 bswap eax 63 bswap eax
64 bswap ecx
64 mov DWORD PTR 40[esp],eax 65 mov DWORD PTR 40[esp],eax
65 mov eax, DWORD PTR 44[esi] 66 mov DWORD PTR 44[esp],ecx
66 bswap eax
67 mov DWORD PTR 44[esp],eax
68 mov eax, DWORD PTR 48[esi] 67 mov eax, DWORD PTR 48[esi]
68 mov ecx, DWORD PTR 52[esi]
69 bswap eax 69 bswap eax
70 bswap ecx
70 mov DWORD PTR 48[esp],eax 71 mov DWORD PTR 48[esp],eax
71 mov eax, DWORD PTR 52[esi] 72 mov DWORD PTR 52[esp],ecx
72 bswap eax
73 mov DWORD PTR 52[esp],eax
74 mov eax, DWORD PTR 56[esi] 73 mov eax, DWORD PTR 56[esi]
74 mov ecx, DWORD PTR 60[esi]
75 bswap eax 75 bswap eax
76 bswap ecx
76 mov DWORD PTR 56[esp],eax 77 mov DWORD PTR 56[esp],eax
77 mov eax, DWORD PTR 60[esi] 78 mov DWORD PTR 60[esp],ecx
78 bswap eax
79 mov DWORD PTR 60[esp],eax
80 ; We now have the X array on the stack 79 ; We now have the X array on the stack
81 ; starting at sp-4 80 ; starting at sp-4
82 mov DWORD PTR 64[esp],esi 81 mov DWORD PTR 132[esp],esi
82L001shortcut:
83 ; 83 ;
84 ; Start processing 84 ; Start processing
85 mov eax, DWORD PTR [ebp] 85 mov eax, DWORD PTR [ebp]
86 mov ecx, DWORD PTR 4[ebp]
86 ; 00_15 0 87 ; 00_15 0
87 mov esi, ecx 88 mov esi, ebx
88 mov ebp, eax 89 mov ebp, eax
89 xor esi, edx 90 xor esi, edx
90 rol ebp, 5 91 rol ebp, 5
91 and esi, ebx 92 and esi, ecx
92 add ebp, edi 93 add ebp, edi
93 ror ebx, 1 94 ror ecx, 1
94 mov edi, DWORD PTR [esp] 95 mov edi, DWORD PTR [esp]
95 ror ebx, 1 96 ror ecx, 1
96 xor esi, edx 97 xor esi, edx
97 lea ebp, DWORD PTR 1518500249[edi*1+ebp] 98 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
98 mov edi, ebx 99 mov edi, ecx
99 add esi, ebp 100 add esi, ebp
100 xor edi, ecx 101 xor edi, ebx
101 mov ebp, esi 102 mov ebp, esi
102 and edi, eax 103 and edi, eax
103 rol ebp, 5 104 rol ebp, 5
104 add ebp, edx 105 add ebp, edx
105 mov edx, DWORD PTR 4[esp] 106 mov edx, DWORD PTR 4[esp]
106 ror eax, 1 107 ror eax, 1
107 xor edi, ecx 108 xor edi, ebx
108 ror eax, 1 109 ror eax, 1
109 lea ebp, DWORD PTR 1518500249[edx*1+ebp] 110 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
110 add edi, ebp 111 add edi, ebp
111 ; 00_15 2 112 ; 00_15 2
112 mov edx, eax 113 mov edx, eax
113 mov ebp, edi 114 mov ebp, edi
114 xor edx, ebx 115 xor edx, ecx
115 rol ebp, 5 116 rol ebp, 5
116 and edx, esi 117 and edx, esi
117 add ebp, ecx 118 add ebp, ebx
118 ror esi, 1 119 ror esi, 1
119 mov ecx, DWORD PTR 8[esp] 120 mov ebx, DWORD PTR 8[esp]
120 ror esi, 1 121 ror esi, 1
121 xor edx, ebx 122 xor edx, ecx
122 lea ebp, DWORD PTR 1518500249[ecx*1+ebp] 123 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
123 mov ecx, esi 124 mov ebx, esi
124 add edx, ebp 125 add edx, ebp
125 xor ecx, eax 126 xor ebx, eax
126 mov ebp, edx 127 mov ebp, edx
127 and ecx, edi 128 and ebx, edi
128 rol ebp, 5 129 rol ebp, 5
129 add ebp, ebx 130 add ebp, ecx
130 mov ebx, DWORD PTR 12[esp] 131 mov ecx, DWORD PTR 12[esp]
131 ror edi, 1 132 ror edi, 1
132 xor ecx, eax 133 xor ebx, eax
133 ror edi, 1 134 ror edi, 1
134 lea ebp, DWORD PTR 1518500249[ebx*1+ebp] 135 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
135 add ecx, ebp 136 add ebx, ebp
136 ; 00_15 4 137 ; 00_15 4
137 mov ebx, edi 138 mov ecx, edi
138 mov ebp, ecx 139 mov ebp, ebx
139 xor ebx, esi 140 xor ecx, esi
140 rol ebp, 5 141 rol ebp, 5
141 and ebx, edx 142 and ecx, edx
142 add ebp, eax 143 add ebp, eax
143 ror edx, 1 144 ror edx, 1
144 mov eax, DWORD PTR 16[esp] 145 mov eax, DWORD PTR 16[esp]
145 ror edx, 1 146 ror edx, 1
146 xor ebx, esi 147 xor ecx, esi
147 lea ebp, DWORD PTR 1518500249[eax*1+ebp] 148 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
148 mov eax, edx 149 mov eax, edx
149 add ebx, ebp 150 add ecx, ebp
150 xor eax, edi 151 xor eax, edi
151 mov ebp, ebx 152 mov ebp, ecx
152 and eax, ecx 153 and eax, ebx
153 rol ebp, 5 154 rol ebp, 5
154 add ebp, esi 155 add ebp, esi
155 mov esi, DWORD PTR 20[esp] 156 mov esi, DWORD PTR 20[esp]
156 ror ecx, 1 157 ror ebx, 1
157 xor eax, edi 158 xor eax, edi
158 ror ecx, 1 159 ror ebx, 1
159 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 160 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
160 add eax, ebp 161 add eax, ebp
161 ; 00_15 6 162 ; 00_15 6
162 mov esi, ecx 163 mov esi, ebx
163 mov ebp, eax 164 mov ebp, eax
164 xor esi, edx 165 xor esi, edx
165 rol ebp, 5 166 rol ebp, 5
166 and esi, ebx 167 and esi, ecx
167 add ebp, edi 168 add ebp, edi
168 ror ebx, 1 169 ror ecx, 1
169 mov edi, DWORD PTR 24[esp] 170 mov edi, DWORD PTR 24[esp]
170 ror ebx, 1 171 ror ecx, 1
171 xor esi, edx 172 xor esi, edx
172 lea ebp, DWORD PTR 1518500249[edi*1+ebp] 173 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
173 mov edi, ebx 174 mov edi, ecx
174 add esi, ebp 175 add esi, ebp
175 xor edi, ecx 176 xor edi, ebx
176 mov ebp, esi 177 mov ebp, esi
177 and edi, eax 178 and edi, eax
178 rol ebp, 5 179 rol ebp, 5
179 add ebp, edx 180 add ebp, edx
180 mov edx, DWORD PTR 28[esp] 181 mov edx, DWORD PTR 28[esp]
181 ror eax, 1 182 ror eax, 1
182 xor edi, ecx 183 xor edi, ebx
183 ror eax, 1 184 ror eax, 1
184 lea ebp, DWORD PTR 1518500249[edx*1+ebp] 185 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
185 add edi, ebp 186 add edi, ebp
186 ; 00_15 8 187 ; 00_15 8
187 mov edx, eax 188 mov edx, eax
188 mov ebp, edi 189 mov ebp, edi
189 xor edx, ebx 190 xor edx, ecx
190 rol ebp, 5 191 rol ebp, 5
191 and edx, esi 192 and edx, esi
192 add ebp, ecx 193 add ebp, ebx
193 ror esi, 1 194 ror esi, 1
194 mov ecx, DWORD PTR 32[esp] 195 mov ebx, DWORD PTR 32[esp]
195 ror esi, 1 196 ror esi, 1
196 xor edx, ebx 197 xor edx, ecx
197 lea ebp, DWORD PTR 1518500249[ecx*1+ebp] 198 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
198 mov ecx, esi 199 mov ebx, esi
199 add edx, ebp 200 add edx, ebp
200 xor ecx, eax 201 xor ebx, eax
201 mov ebp, edx 202 mov ebp, edx
202 and ecx, edi 203 and ebx, edi
203 rol ebp, 5 204 rol ebp, 5
204 add ebp, ebx 205 add ebp, ecx
205 mov ebx, DWORD PTR 36[esp] 206 mov ecx, DWORD PTR 36[esp]
206 ror edi, 1 207 ror edi, 1
207 xor ecx, eax 208 xor ebx, eax
208 ror edi, 1 209 ror edi, 1
209 lea ebp, DWORD PTR 1518500249[ebx*1+ebp] 210 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
210 add ecx, ebp 211 add ebx, ebp
211 ; 00_15 10 212 ; 00_15 10
212 mov ebx, edi 213 mov ecx, edi
213 mov ebp, ecx 214 mov ebp, ebx
214 xor ebx, esi 215 xor ecx, esi
215 rol ebp, 5 216 rol ebp, 5
216 and ebx, edx 217 and ecx, edx
217 add ebp, eax 218 add ebp, eax
218 ror edx, 1 219 ror edx, 1
219 mov eax, DWORD PTR 40[esp] 220 mov eax, DWORD PTR 40[esp]
220 ror edx, 1 221 ror edx, 1
221 xor ebx, esi 222 xor ecx, esi
222 lea ebp, DWORD PTR 1518500249[eax*1+ebp] 223 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
223 mov eax, edx 224 mov eax, edx
224 add ebx, ebp 225 add ecx, ebp
225 xor eax, edi 226 xor eax, edi
226 mov ebp, ebx 227 mov ebp, ecx
227 and eax, ecx 228 and eax, ebx
228 rol ebp, 5 229 rol ebp, 5
229 add ebp, esi 230 add ebp, esi
230 mov esi, DWORD PTR 44[esp] 231 mov esi, DWORD PTR 44[esp]
231 ror ecx, 1 232 ror ebx, 1
232 xor eax, edi 233 xor eax, edi
233 ror ecx, 1 234 ror ebx, 1
234 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 235 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
235 add eax, ebp 236 add eax, ebp
236 ; 00_15 12 237 ; 00_15 12
237 mov esi, ecx 238 mov esi, ebx
238 mov ebp, eax 239 mov ebp, eax
239 xor esi, edx 240 xor esi, edx
240 rol ebp, 5 241 rol ebp, 5
241 and esi, ebx 242 and esi, ecx
242 add ebp, edi 243 add ebp, edi
243 ror ebx, 1 244 ror ecx, 1
244 mov edi, DWORD PTR 48[esp] 245 mov edi, DWORD PTR 48[esp]
245 ror ebx, 1 246 ror ecx, 1
246 xor esi, edx 247 xor esi, edx
247 lea ebp, DWORD PTR 1518500249[edi*1+ebp] 248 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
248 mov edi, ebx 249 mov edi, ecx
249 add esi, ebp 250 add esi, ebp
250 xor edi, ecx 251 xor edi, ebx
251 mov ebp, esi 252 mov ebp, esi
252 and edi, eax 253 and edi, eax
253 rol ebp, 5 254 rol ebp, 5
254 add ebp, edx 255 add ebp, edx
255 mov edx, DWORD PTR 52[esp] 256 mov edx, DWORD PTR 52[esp]
256 ror eax, 1 257 ror eax, 1
257 xor edi, ecx 258 xor edi, ebx
258 ror eax, 1 259 ror eax, 1
259 lea ebp, DWORD PTR 1518500249[edx*1+ebp] 260 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
260 add edi, ebp 261 add edi, ebp
261 ; 00_15 14 262 ; 00_15 14
262 mov edx, eax 263 mov edx, eax
263 mov ebp, edi 264 mov ebp, edi
264 xor edx, ebx 265 xor edx, ecx
265 rol ebp, 5 266 rol ebp, 5
266 and edx, esi 267 and edx, esi
267 add ebp, ecx 268 add ebp, ebx
268 ror esi, 1 269 ror esi, 1
269 mov ecx, DWORD PTR 56[esp] 270 mov ebx, DWORD PTR 56[esp]
270 ror esi, 1 271 ror esi, 1
271 xor edx, ebx 272 xor edx, ecx
272 lea ebp, DWORD PTR 1518500249[ecx*1+ebp] 273 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
273 mov ecx, esi 274 mov ebx, esi
274 add edx, ebp 275 add edx, ebp
275 xor ecx, eax 276 xor ebx, eax
276 mov ebp, edx 277 mov ebp, edx
277 and ecx, edi 278 and ebx, edi
278 rol ebp, 5 279 rol ebp, 5
279 add ebp, ebx 280 add ebp, ecx
280 mov ebx, DWORD PTR 60[esp] 281 mov ecx, DWORD PTR 60[esp]
281 ror edi, 1 282 ror edi, 1
282 xor ecx, eax 283 xor ebx, eax
283 ror edi, 1 284 ror edi, 1
284 lea ebp, DWORD PTR 1518500249[ebx*1+ebp] 285 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
285 add ecx, ebp 286 add ebx, ebp
286 ; 16_19 16 287 ; 16_19 16
287 nop 288 nop
288 mov ebp, DWORD PTR [esp] 289 mov ebp, DWORD PTR [esp]
289 mov ebx, DWORD PTR 8[esp] 290 mov ecx, DWORD PTR 8[esp]
290 xor ebx, ebp 291 xor ecx, ebp
291 mov ebp, DWORD PTR 32[esp] 292 mov ebp, DWORD PTR 32[esp]
292 xor ebx, ebp 293 xor ecx, ebp
293 mov ebp, DWORD PTR 52[esp] 294 mov ebp, DWORD PTR 52[esp]
294 xor ebx, ebp 295 xor ecx, ebp
295 mov ebp, edi 296 mov ebp, edi
296 rol ebx, 1 297 rol ecx, 1
297 xor ebp, esi 298 xor ebp, esi
298 mov DWORD PTR [esp],ebx 299 mov DWORD PTR [esp],ecx
299 and ebp, edx 300 and ebp, edx
300 lea ebx, DWORD PTR 1518500249[eax*1+ebx] 301 lea ecx, DWORD PTR 1518500249[eax*1+ecx]
301 xor ebp, esi 302 xor ebp, esi
302 mov eax, ecx 303 mov eax, ebx
303 add ebx, ebp 304 add ecx, ebp
304 rol eax, 5 305 rol eax, 5
305 ror edx, 1 306 ror edx, 1
306 add ebx, eax 307 add ecx, eax
307 mov eax, DWORD PTR 4[esp] 308 mov eax, DWORD PTR 4[esp]
308 mov ebp, DWORD PTR 12[esp] 309 mov ebp, DWORD PTR 12[esp]
309 xor eax, ebp 310 xor eax, ebp
@@ -316,14 +317,14 @@ L000start:
316 mov ebp, edx 317 mov ebp, edx
317 xor ebp, edi 318 xor ebp, edi
318 mov DWORD PTR 4[esp],eax 319 mov DWORD PTR 4[esp],eax
319 and ebp, ecx 320 and ebp, ebx
320 lea eax, DWORD PTR 1518500249[esi*1+eax] 321 lea eax, DWORD PTR 1518500249[esi*1+eax]
321 xor ebp, edi 322 xor ebp, edi
322 mov esi, ebx 323 mov esi, ecx
323 rol esi, 5 324 rol esi, 5
324 ror ecx, 1 325 ror ebx, 1
325 add eax, esi 326 add eax, esi
326 ror ecx, 1 327 ror ebx, 1
327 add eax, ebp 328 add eax, ebp
328 ; 16_19 18 329 ; 16_19 18
329 mov ebp, DWORD PTR 8[esp] 330 mov ebp, DWORD PTR 8[esp]
@@ -333,17 +334,17 @@ L000start:
333 xor esi, ebp 334 xor esi, ebp
334 mov ebp, DWORD PTR 60[esp] 335 mov ebp, DWORD PTR 60[esp]
335 xor esi, ebp 336 xor esi, ebp
336 mov ebp, ecx 337 mov ebp, ebx
337 rol esi, 1 338 rol esi, 1
338 xor ebp, edx 339 xor ebp, edx
339 mov DWORD PTR 8[esp],esi 340 mov DWORD PTR 8[esp],esi
340 and ebp, ebx 341 and ebp, ecx
341 lea esi, DWORD PTR 1518500249[edi*1+esi] 342 lea esi, DWORD PTR 1518500249[edi*1+esi]
342 xor ebp, edx 343 xor ebp, edx
343 mov edi, eax 344 mov edi, eax
344 add esi, ebp 345 add esi, ebp
345 rol edi, 5 346 rol edi, 5
346 ror ebx, 1 347 ror ecx, 1
347 add esi, edi 348 add esi, edi
348 mov edi, DWORD PTR 12[esp] 349 mov edi, DWORD PTR 12[esp]
349 mov ebp, DWORD PTR 20[esp] 350 mov ebp, DWORD PTR 20[esp]
@@ -351,15 +352,15 @@ L000start:
351 mov ebp, DWORD PTR 44[esp] 352 mov ebp, DWORD PTR 44[esp]
352 xor edi, ebp 353 xor edi, ebp
353 mov ebp, DWORD PTR [esp] 354 mov ebp, DWORD PTR [esp]
354 ror ebx, 1 355 ror ecx, 1
355 xor edi, ebp 356 xor edi, ebp
356 rol edi, 1 357 rol edi, 1
357 mov ebp, ebx 358 mov ebp, ecx
358 xor ebp, ecx 359 xor ebp, ebx
359 mov DWORD PTR 12[esp],edi 360 mov DWORD PTR 12[esp],edi
360 and ebp, eax 361 and ebp, eax
361 lea edi, DWORD PTR 1518500249[edx*1+edi] 362 lea edi, DWORD PTR 1518500249[edx*1+edi]
362 xor ebp, ecx 363 xor ebp, ebx
363 mov edx, esi 364 mov edx, esi
364 rol edx, 5 365 rol edx, 5
365 ror eax, 1 366 ror eax, 1
@@ -378,54 +379,54 @@ L000start:
378 rol edx, 1 379 rol edx, 1
379 xor ebp, eax 380 xor ebp, eax
380 mov DWORD PTR 16[esp],edx 381 mov DWORD PTR 16[esp],edx
381 xor ebp, ebx 382 xor ebp, ecx
382 lea edx, DWORD PTR 1859775393[ecx*1+edx] 383 lea edx, DWORD PTR 1859775393[ebx*1+edx]
383 mov ecx, edi 384 mov ebx, edi
384 rol ecx, 5 385 rol ebx, 5
385 ror esi, 1 386 ror esi, 1
386 add ecx, ebp 387 add ebx, ebp
387 ror esi, 1 388 ror esi, 1
388 add edx, ecx 389 add edx, ebx
389 ; 20_39 21 390 ; 20_39 21
390 mov ecx, DWORD PTR 20[esp] 391 mov ebx, DWORD PTR 20[esp]
391 mov ebp, DWORD PTR 28[esp] 392 mov ebp, DWORD PTR 28[esp]
392 xor ecx, ebp 393 xor ebx, ebp
393 mov ebp, DWORD PTR 52[esp] 394 mov ebp, DWORD PTR 52[esp]
394 xor ecx, ebp 395 xor ebx, ebp
395 mov ebp, DWORD PTR 8[esp] 396 mov ebp, DWORD PTR 8[esp]
396 xor ecx, ebp 397 xor ebx, ebp
397 mov ebp, edi 398 mov ebp, edi
398 rol ecx, 1 399 rol ebx, 1
399 xor ebp, esi 400 xor ebp, esi
400 mov DWORD PTR 20[esp],ecx 401 mov DWORD PTR 20[esp],ebx
401 xor ebp, eax 402 xor ebp, eax
402 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 403 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
403 mov ebx, edx 404 mov ecx, edx
404 rol ebx, 5 405 rol ecx, 5
405 ror edi, 1 406 ror edi, 1
406 add ebx, ebp 407 add ecx, ebp
407 ror edi, 1 408 ror edi, 1
408 add ecx, ebx 409 add ebx, ecx
409 ; 20_39 22 410 ; 20_39 22
410 mov ebx, DWORD PTR 24[esp] 411 mov ecx, DWORD PTR 24[esp]
411 mov ebp, DWORD PTR 32[esp] 412 mov ebp, DWORD PTR 32[esp]
412 xor ebx, ebp 413 xor ecx, ebp
413 mov ebp, DWORD PTR 56[esp] 414 mov ebp, DWORD PTR 56[esp]
414 xor ebx, ebp 415 xor ecx, ebp
415 mov ebp, DWORD PTR 12[esp] 416 mov ebp, DWORD PTR 12[esp]
416 xor ebx, ebp 417 xor ecx, ebp
417 mov ebp, edx 418 mov ebp, edx
418 rol ebx, 1 419 rol ecx, 1
419 xor ebp, edi 420 xor ebp, edi
420 mov DWORD PTR 24[esp],ebx 421 mov DWORD PTR 24[esp],ecx
421 xor ebp, esi 422 xor ebp, esi
422 lea ebx, DWORD PTR 1859775393[eax*1+ebx] 423 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
423 mov eax, ecx 424 mov eax, ebx
424 rol eax, 5 425 rol eax, 5
425 ror edx, 1 426 ror edx, 1
426 add eax, ebp 427 add eax, ebp
427 ror edx, 1 428 ror edx, 1
428 add ebx, eax 429 add ecx, eax
429 ; 20_39 23 430 ; 20_39 23
430 mov eax, DWORD PTR 28[esp] 431 mov eax, DWORD PTR 28[esp]
431 mov ebp, DWORD PTR 36[esp] 432 mov ebp, DWORD PTR 36[esp]
@@ -434,17 +435,17 @@ L000start:
434 xor eax, ebp 435 xor eax, ebp
435 mov ebp, DWORD PTR 16[esp] 436 mov ebp, DWORD PTR 16[esp]
436 xor eax, ebp 437 xor eax, ebp
437 mov ebp, ecx 438 mov ebp, ebx
438 rol eax, 1 439 rol eax, 1
439 xor ebp, edx 440 xor ebp, edx
440 mov DWORD PTR 28[esp],eax 441 mov DWORD PTR 28[esp],eax
441 xor ebp, edi 442 xor ebp, edi
442 lea eax, DWORD PTR 1859775393[esi*1+eax] 443 lea eax, DWORD PTR 1859775393[esi*1+eax]
443 mov esi, ebx 444 mov esi, ecx
444 rol esi, 5 445 rol esi, 5
445 ror ecx, 1 446 ror ebx, 1
446 add esi, ebp 447 add esi, ebp
447 ror ecx, 1 448 ror ebx, 1
448 add eax, esi 449 add eax, esi
449 ; 20_39 24 450 ; 20_39 24
450 mov esi, DWORD PTR 32[esp] 451 mov esi, DWORD PTR 32[esp]
@@ -454,17 +455,17 @@ L000start:
454 xor esi, ebp 455 xor esi, ebp
455 mov ebp, DWORD PTR 20[esp] 456 mov ebp, DWORD PTR 20[esp]
456 xor esi, ebp 457 xor esi, ebp
457 mov ebp, ebx 458 mov ebp, ecx
458 rol esi, 1 459 rol esi, 1
459 xor ebp, ecx 460 xor ebp, ebx
460 mov DWORD PTR 32[esp],esi 461 mov DWORD PTR 32[esp],esi
461 xor ebp, edx 462 xor ebp, edx
462 lea esi, DWORD PTR 1859775393[edi*1+esi] 463 lea esi, DWORD PTR 1859775393[edi*1+esi]
463 mov edi, eax 464 mov edi, eax
464 rol edi, 5 465 rol edi, 5
465 ror ebx, 1 466 ror ecx, 1
466 add edi, ebp 467 add edi, ebp
467 ror ebx, 1 468 ror ecx, 1
468 add esi, edi 469 add esi, edi
469 ; 20_39 25 470 ; 20_39 25
470 mov edi, DWORD PTR 36[esp] 471 mov edi, DWORD PTR 36[esp]
@@ -476,9 +477,9 @@ L000start:
476 xor edi, ebp 477 xor edi, ebp
477 mov ebp, eax 478 mov ebp, eax
478 rol edi, 1 479 rol edi, 1
479 xor ebp, ebx
480 mov DWORD PTR 36[esp],edi
481 xor ebp, ecx 480 xor ebp, ecx
481 mov DWORD PTR 36[esp],edi
482 xor ebp, ebx
482 lea edi, DWORD PTR 1859775393[edx*1+edi] 483 lea edi, DWORD PTR 1859775393[edx*1+edi]
483 mov edx, esi 484 mov edx, esi
484 rol edx, 5 485 rol edx, 5
@@ -498,54 +499,54 @@ L000start:
498 rol edx, 1 499 rol edx, 1
499 xor ebp, eax 500 xor ebp, eax
500 mov DWORD PTR 40[esp],edx 501 mov DWORD PTR 40[esp],edx
501 xor ebp, ebx 502 xor ebp, ecx
502 lea edx, DWORD PTR 1859775393[ecx*1+edx] 503 lea edx, DWORD PTR 1859775393[ebx*1+edx]
503 mov ecx, edi 504 mov ebx, edi
504 rol ecx, 5 505 rol ebx, 5
505 ror esi, 1 506 ror esi, 1
506 add ecx, ebp 507 add ebx, ebp
507 ror esi, 1 508 ror esi, 1
508 add edx, ecx 509 add edx, ebx
509 ; 20_39 27 510 ; 20_39 27
510 mov ecx, DWORD PTR 44[esp] 511 mov ebx, DWORD PTR 44[esp]
511 mov ebp, DWORD PTR 52[esp] 512 mov ebp, DWORD PTR 52[esp]
512 xor ecx, ebp 513 xor ebx, ebp
513 mov ebp, DWORD PTR 12[esp] 514 mov ebp, DWORD PTR 12[esp]
514 xor ecx, ebp 515 xor ebx, ebp
515 mov ebp, DWORD PTR 32[esp] 516 mov ebp, DWORD PTR 32[esp]
516 xor ecx, ebp 517 xor ebx, ebp
517 mov ebp, edi 518 mov ebp, edi
518 rol ecx, 1 519 rol ebx, 1
519 xor ebp, esi 520 xor ebp, esi
520 mov DWORD PTR 44[esp],ecx 521 mov DWORD PTR 44[esp],ebx
521 xor ebp, eax 522 xor ebp, eax
522 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 523 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
523 mov ebx, edx 524 mov ecx, edx
524 rol ebx, 5 525 rol ecx, 5
525 ror edi, 1 526 ror edi, 1
526 add ebx, ebp 527 add ecx, ebp
527 ror edi, 1 528 ror edi, 1
528 add ecx, ebx 529 add ebx, ecx
529 ; 20_39 28 530 ; 20_39 28
530 mov ebx, DWORD PTR 48[esp] 531 mov ecx, DWORD PTR 48[esp]
531 mov ebp, DWORD PTR 56[esp] 532 mov ebp, DWORD PTR 56[esp]
532 xor ebx, ebp 533 xor ecx, ebp
533 mov ebp, DWORD PTR 16[esp] 534 mov ebp, DWORD PTR 16[esp]
534 xor ebx, ebp 535 xor ecx, ebp
535 mov ebp, DWORD PTR 36[esp] 536 mov ebp, DWORD PTR 36[esp]
536 xor ebx, ebp 537 xor ecx, ebp
537 mov ebp, edx 538 mov ebp, edx
538 rol ebx, 1 539 rol ecx, 1
539 xor ebp, edi 540 xor ebp, edi
540 mov DWORD PTR 48[esp],ebx 541 mov DWORD PTR 48[esp],ecx
541 xor ebp, esi 542 xor ebp, esi
542 lea ebx, DWORD PTR 1859775393[eax*1+ebx] 543 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
543 mov eax, ecx 544 mov eax, ebx
544 rol eax, 5 545 rol eax, 5
545 ror edx, 1 546 ror edx, 1
546 add eax, ebp 547 add eax, ebp
547 ror edx, 1 548 ror edx, 1
548 add ebx, eax 549 add ecx, eax
549 ; 20_39 29 550 ; 20_39 29
550 mov eax, DWORD PTR 52[esp] 551 mov eax, DWORD PTR 52[esp]
551 mov ebp, DWORD PTR 60[esp] 552 mov ebp, DWORD PTR 60[esp]
@@ -554,17 +555,17 @@ L000start:
554 xor eax, ebp 555 xor eax, ebp
555 mov ebp, DWORD PTR 40[esp] 556 mov ebp, DWORD PTR 40[esp]
556 xor eax, ebp 557 xor eax, ebp
557 mov ebp, ecx 558 mov ebp, ebx
558 rol eax, 1 559 rol eax, 1
559 xor ebp, edx 560 xor ebp, edx
560 mov DWORD PTR 52[esp],eax 561 mov DWORD PTR 52[esp],eax
561 xor ebp, edi 562 xor ebp, edi
562 lea eax, DWORD PTR 1859775393[esi*1+eax] 563 lea eax, DWORD PTR 1859775393[esi*1+eax]
563 mov esi, ebx 564 mov esi, ecx
564 rol esi, 5 565 rol esi, 5
565 ror ecx, 1 566 ror ebx, 1
566 add esi, ebp 567 add esi, ebp
567 ror ecx, 1 568 ror ebx, 1
568 add eax, esi 569 add eax, esi
569 ; 20_39 30 570 ; 20_39 30
570 mov esi, DWORD PTR 56[esp] 571 mov esi, DWORD PTR 56[esp]
@@ -574,17 +575,17 @@ L000start:
574 xor esi, ebp 575 xor esi, ebp
575 mov ebp, DWORD PTR 44[esp] 576 mov ebp, DWORD PTR 44[esp]
576 xor esi, ebp 577 xor esi, ebp
577 mov ebp, ebx 578 mov ebp, ecx
578 rol esi, 1 579 rol esi, 1
579 xor ebp, ecx 580 xor ebp, ebx
580 mov DWORD PTR 56[esp],esi 581 mov DWORD PTR 56[esp],esi
581 xor ebp, edx 582 xor ebp, edx
582 lea esi, DWORD PTR 1859775393[edi*1+esi] 583 lea esi, DWORD PTR 1859775393[edi*1+esi]
583 mov edi, eax 584 mov edi, eax
584 rol edi, 5 585 rol edi, 5
585 ror ebx, 1 586 ror ecx, 1
586 add edi, ebp 587 add edi, ebp
587 ror ebx, 1 588 ror ecx, 1
588 add esi, edi 589 add esi, edi
589 ; 20_39 31 590 ; 20_39 31
590 mov edi, DWORD PTR 60[esp] 591 mov edi, DWORD PTR 60[esp]
@@ -596,9 +597,9 @@ L000start:
596 xor edi, ebp 597 xor edi, ebp
597 mov ebp, eax 598 mov ebp, eax
598 rol edi, 1 599 rol edi, 1
599 xor ebp, ebx
600 mov DWORD PTR 60[esp],edi
601 xor ebp, ecx 600 xor ebp, ecx
601 mov DWORD PTR 60[esp],edi
602 xor ebp, ebx
602 lea edi, DWORD PTR 1859775393[edx*1+edi] 603 lea edi, DWORD PTR 1859775393[edx*1+edi]
603 mov edx, esi 604 mov edx, esi
604 rol edx, 5 605 rol edx, 5
@@ -618,54 +619,54 @@ L000start:
618 rol edx, 1 619 rol edx, 1
619 xor ebp, eax 620 xor ebp, eax
620 mov DWORD PTR [esp],edx 621 mov DWORD PTR [esp],edx
621 xor ebp, ebx 622 xor ebp, ecx
622 lea edx, DWORD PTR 1859775393[ecx*1+edx] 623 lea edx, DWORD PTR 1859775393[ebx*1+edx]
623 mov ecx, edi 624 mov ebx, edi
624 rol ecx, 5 625 rol ebx, 5
625 ror esi, 1 626 ror esi, 1
626 add ecx, ebp 627 add ebx, ebp
627 ror esi, 1 628 ror esi, 1
628 add edx, ecx 629 add edx, ebx
629 ; 20_39 33 630 ; 20_39 33
630 mov ecx, DWORD PTR 4[esp] 631 mov ebx, DWORD PTR 4[esp]
631 mov ebp, DWORD PTR 12[esp] 632 mov ebp, DWORD PTR 12[esp]
632 xor ecx, ebp 633 xor ebx, ebp
633 mov ebp, DWORD PTR 36[esp] 634 mov ebp, DWORD PTR 36[esp]
634 xor ecx, ebp 635 xor ebx, ebp
635 mov ebp, DWORD PTR 56[esp] 636 mov ebp, DWORD PTR 56[esp]
636 xor ecx, ebp 637 xor ebx, ebp
637 mov ebp, edi 638 mov ebp, edi
638 rol ecx, 1 639 rol ebx, 1
639 xor ebp, esi 640 xor ebp, esi
640 mov DWORD PTR 4[esp],ecx 641 mov DWORD PTR 4[esp],ebx
641 xor ebp, eax 642 xor ebp, eax
642 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 643 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
643 mov ebx, edx 644 mov ecx, edx
644 rol ebx, 5 645 rol ecx, 5
645 ror edi, 1 646 ror edi, 1
646 add ebx, ebp 647 add ecx, ebp
647 ror edi, 1 648 ror edi, 1
648 add ecx, ebx 649 add ebx, ecx
649 ; 20_39 34 650 ; 20_39 34
650 mov ebx, DWORD PTR 8[esp] 651 mov ecx, DWORD PTR 8[esp]
651 mov ebp, DWORD PTR 16[esp] 652 mov ebp, DWORD PTR 16[esp]
652 xor ebx, ebp 653 xor ecx, ebp
653 mov ebp, DWORD PTR 40[esp] 654 mov ebp, DWORD PTR 40[esp]
654 xor ebx, ebp 655 xor ecx, ebp
655 mov ebp, DWORD PTR 60[esp] 656 mov ebp, DWORD PTR 60[esp]
656 xor ebx, ebp 657 xor ecx, ebp
657 mov ebp, edx 658 mov ebp, edx
658 rol ebx, 1 659 rol ecx, 1
659 xor ebp, edi 660 xor ebp, edi
660 mov DWORD PTR 8[esp],ebx 661 mov DWORD PTR 8[esp],ecx
661 xor ebp, esi 662 xor ebp, esi
662 lea ebx, DWORD PTR 1859775393[eax*1+ebx] 663 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
663 mov eax, ecx 664 mov eax, ebx
664 rol eax, 5 665 rol eax, 5
665 ror edx, 1 666 ror edx, 1
666 add eax, ebp 667 add eax, ebp
667 ror edx, 1 668 ror edx, 1
668 add ebx, eax 669 add ecx, eax
669 ; 20_39 35 670 ; 20_39 35
670 mov eax, DWORD PTR 12[esp] 671 mov eax, DWORD PTR 12[esp]
671 mov ebp, DWORD PTR 20[esp] 672 mov ebp, DWORD PTR 20[esp]
@@ -674,17 +675,17 @@ L000start:
674 xor eax, ebp 675 xor eax, ebp
675 mov ebp, DWORD PTR [esp] 676 mov ebp, DWORD PTR [esp]
676 xor eax, ebp 677 xor eax, ebp
677 mov ebp, ecx 678 mov ebp, ebx
678 rol eax, 1 679 rol eax, 1
679 xor ebp, edx 680 xor ebp, edx
680 mov DWORD PTR 12[esp],eax 681 mov DWORD PTR 12[esp],eax
681 xor ebp, edi 682 xor ebp, edi
682 lea eax, DWORD PTR 1859775393[esi*1+eax] 683 lea eax, DWORD PTR 1859775393[esi*1+eax]
683 mov esi, ebx 684 mov esi, ecx
684 rol esi, 5 685 rol esi, 5
685 ror ecx, 1 686 ror ebx, 1
686 add esi, ebp 687 add esi, ebp
687 ror ecx, 1 688 ror ebx, 1
688 add eax, esi 689 add eax, esi
689 ; 20_39 36 690 ; 20_39 36
690 mov esi, DWORD PTR 16[esp] 691 mov esi, DWORD PTR 16[esp]
@@ -694,17 +695,17 @@ L000start:
694 xor esi, ebp 695 xor esi, ebp
695 mov ebp, DWORD PTR 4[esp] 696 mov ebp, DWORD PTR 4[esp]
696 xor esi, ebp 697 xor esi, ebp
697 mov ebp, ebx 698 mov ebp, ecx
698 rol esi, 1 699 rol esi, 1
699 xor ebp, ecx 700 xor ebp, ebx
700 mov DWORD PTR 16[esp],esi 701 mov DWORD PTR 16[esp],esi
701 xor ebp, edx 702 xor ebp, edx
702 lea esi, DWORD PTR 1859775393[edi*1+esi] 703 lea esi, DWORD PTR 1859775393[edi*1+esi]
703 mov edi, eax 704 mov edi, eax
704 rol edi, 5 705 rol edi, 5
705 ror ebx, 1 706 ror ecx, 1
706 add edi, ebp 707 add edi, ebp
707 ror ebx, 1 708 ror ecx, 1
708 add esi, edi 709 add esi, edi
709 ; 20_39 37 710 ; 20_39 37
710 mov edi, DWORD PTR 20[esp] 711 mov edi, DWORD PTR 20[esp]
@@ -716,9 +717,9 @@ L000start:
716 xor edi, ebp 717 xor edi, ebp
717 mov ebp, eax 718 mov ebp, eax
718 rol edi, 1 719 rol edi, 1
719 xor ebp, ebx
720 mov DWORD PTR 20[esp],edi
721 xor ebp, ecx 720 xor ebp, ecx
721 mov DWORD PTR 20[esp],edi
722 xor ebp, ebx
722 lea edi, DWORD PTR 1859775393[edx*1+edi] 723 lea edi, DWORD PTR 1859775393[edx*1+edi]
723 mov edx, esi 724 mov edx, esi
724 rol edx, 5 725 rol edx, 5
@@ -738,57 +739,57 @@ L000start:
738 rol edx, 1 739 rol edx, 1
739 xor ebp, eax 740 xor ebp, eax
740 mov DWORD PTR 24[esp],edx 741 mov DWORD PTR 24[esp],edx
741 xor ebp, ebx 742 xor ebp, ecx
742 lea edx, DWORD PTR 1859775393[ecx*1+edx] 743 lea edx, DWORD PTR 1859775393[ebx*1+edx]
743 mov ecx, edi 744 mov ebx, edi
744 rol ecx, 5 745 rol ebx, 5
745 ror esi, 1 746 ror esi, 1
746 add ecx, ebp 747 add ebx, ebp
747 ror esi, 1 748 ror esi, 1
748 add edx, ecx 749 add edx, ebx
749 ; 20_39 39 750 ; 20_39 39
750 mov ecx, DWORD PTR 28[esp] 751 mov ebx, DWORD PTR 28[esp]
751 mov ebp, DWORD PTR 36[esp] 752 mov ebp, DWORD PTR 36[esp]
752 xor ecx, ebp 753 xor ebx, ebp
753 mov ebp, DWORD PTR 60[esp] 754 mov ebp, DWORD PTR 60[esp]
754 xor ecx, ebp 755 xor ebx, ebp
755 mov ebp, DWORD PTR 16[esp] 756 mov ebp, DWORD PTR 16[esp]
756 xor ecx, ebp 757 xor ebx, ebp
757 mov ebp, edi 758 mov ebp, edi
758 rol ecx, 1 759 rol ebx, 1
759 xor ebp, esi 760 xor ebp, esi
760 mov DWORD PTR 28[esp],ecx 761 mov DWORD PTR 28[esp],ebx
761 xor ebp, eax 762 xor ebp, eax
762 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 763 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
763 mov ebx, edx 764 mov ecx, edx
764 rol ebx, 5 765 rol ecx, 5
765 ror edi, 1 766 ror edi, 1
766 add ebx, ebp 767 add ecx, ebp
767 ror edi, 1 768 ror edi, 1
768 add ecx, ebx 769 add ebx, ecx
769 ; 40_59 40 770 ; 40_59 40
770 mov ebx, DWORD PTR 32[esp] 771 mov ecx, DWORD PTR 32[esp]
771 mov ebp, DWORD PTR 40[esp] 772 mov ebp, DWORD PTR 40[esp]
772 xor ebx, ebp 773 xor ecx, ebp
773 mov ebp, DWORD PTR [esp] 774 mov ebp, DWORD PTR [esp]
774 xor ebx, ebp 775 xor ecx, ebp
775 mov ebp, DWORD PTR 20[esp] 776 mov ebp, DWORD PTR 20[esp]
776 xor ebx, ebp 777 xor ecx, ebp
777 mov ebp, edx 778 mov ebp, edx
778 rol ebx, 1 779 rol ecx, 1
779 or ebp, edi 780 or ebp, edi
780 mov DWORD PTR 32[esp],ebx 781 mov DWORD PTR 32[esp],ecx
781 and ebp, esi 782 and ebp, esi
782 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 783 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
783 mov eax, edx 784 mov eax, edx
784 ror edx, 1 785 ror edx, 1
785 and eax, edi 786 and eax, edi
786 or ebp, eax 787 or ebp, eax
787 mov eax, ecx 788 mov eax, ebx
788 rol eax, 5 789 rol eax, 5
789 add ebp, eax 790 add ebp, eax
790 mov eax, DWORD PTR 36[esp] 791 mov eax, DWORD PTR 36[esp]
791 add ebx, ebp 792 add ecx, ebp
792 mov ebp, DWORD PTR 44[esp] 793 mov ebp, DWORD PTR 44[esp]
793 xor eax, ebp 794 xor eax, ebp
794 mov ebp, DWORD PTR 4[esp] 795 mov ebp, DWORD PTR 4[esp]
@@ -797,19 +798,19 @@ L000start:
797 ror edx, 1 798 ror edx, 1
798 xor eax, ebp 799 xor eax, ebp
799 rol eax, 1 800 rol eax, 1
800 mov ebp, ecx 801 mov ebp, ebx
801 mov DWORD PTR 36[esp],eax 802 mov DWORD PTR 36[esp],eax
802 or ebp, edx 803 or ebp, edx
803 lea eax, DWORD PTR 2400959708[esi*1+eax] 804 lea eax, DWORD PTR 2400959708[esi*1+eax]
804 mov esi, ecx 805 mov esi, ebx
805 and ebp, edi 806 and ebp, edi
806 and esi, edx 807 and esi, edx
807 or ebp, esi 808 or ebp, esi
808 mov esi, ebx 809 mov esi, ecx
809 rol esi, 5 810 rol esi, 5
810 ror ecx, 1 811 ror ebx, 1
811 add ebp, esi 812 add ebp, esi
812 ror ecx, 1 813 ror ebx, 1
813 add eax, ebp 814 add eax, ebp
814 ; 40_59 41 815 ; 40_59 41
815 ; 40_59 42 816 ; 40_59 42
@@ -820,15 +821,15 @@ L000start:
820 xor esi, ebp 821 xor esi, ebp
821 mov ebp, DWORD PTR 28[esp] 822 mov ebp, DWORD PTR 28[esp]
822 xor esi, ebp 823 xor esi, ebp
823 mov ebp, ebx 824 mov ebp, ecx
824 rol esi, 1 825 rol esi, 1
825 or ebp, ecx 826 or ebp, ebx
826 mov DWORD PTR 40[esp],esi 827 mov DWORD PTR 40[esp],esi
827 and ebp, edx 828 and ebp, edx
828 lea esi, DWORD PTR 2400959708[edi*1+esi] 829 lea esi, DWORD PTR 2400959708[edi*1+esi]
829 mov edi, ebx 830 mov edi, ecx
830 ror ebx, 1 831 ror ecx, 1
831 and edi, ecx 832 and edi, ebx
832 or ebp, edi 833 or ebp, edi
833 mov edi, eax 834 mov edi, eax
834 rol edi, 5 835 rol edi, 5
@@ -840,16 +841,16 @@ L000start:
840 mov ebp, DWORD PTR 12[esp] 841 mov ebp, DWORD PTR 12[esp]
841 xor edi, ebp 842 xor edi, ebp
842 mov ebp, DWORD PTR 32[esp] 843 mov ebp, DWORD PTR 32[esp]
843 ror ebx, 1 844 ror ecx, 1
844 xor edi, ebp 845 xor edi, ebp
845 rol edi, 1 846 rol edi, 1
846 mov ebp, eax 847 mov ebp, eax
847 mov DWORD PTR 44[esp],edi 848 mov DWORD PTR 44[esp],edi
848 or ebp, ebx 849 or ebp, ecx
849 lea edi, DWORD PTR 2400959708[edx*1+edi] 850 lea edi, DWORD PTR 2400959708[edx*1+edi]
850 mov edx, eax 851 mov edx, eax
851 and ebp, ecx 852 and ebp, ebx
852 and edx, ebx 853 and edx, ecx
853 or ebp, edx 854 or ebp, edx
854 mov edx, esi 855 mov edx, esi
855 rol edx, 5 856 rol edx, 5
@@ -870,63 +871,63 @@ L000start:
870 rol edx, 1 871 rol edx, 1
871 or ebp, eax 872 or ebp, eax
872 mov DWORD PTR 48[esp],edx 873 mov DWORD PTR 48[esp],edx
873 and ebp, ebx 874 and ebp, ecx
874 lea edx, DWORD PTR 2400959708[ecx*1+edx] 875 lea edx, DWORD PTR 2400959708[ebx*1+edx]
875 mov ecx, esi 876 mov ebx, esi
876 ror esi, 1 877 ror esi, 1
877 and ecx, eax 878 and ebx, eax
878 or ebp, ecx 879 or ebp, ebx
879 mov ecx, edi 880 mov ebx, edi
880 rol ecx, 5 881 rol ebx, 5
881 add ebp, ecx 882 add ebp, ebx
882 mov ecx, DWORD PTR 52[esp] 883 mov ebx, DWORD PTR 52[esp]
883 add edx, ebp 884 add edx, ebp
884 mov ebp, DWORD PTR 60[esp] 885 mov ebp, DWORD PTR 60[esp]
885 xor ecx, ebp 886 xor ebx, ebp
886 mov ebp, DWORD PTR 20[esp] 887 mov ebp, DWORD PTR 20[esp]
887 xor ecx, ebp 888 xor ebx, ebp
888 mov ebp, DWORD PTR 40[esp] 889 mov ebp, DWORD PTR 40[esp]
889 ror esi, 1 890 ror esi, 1
890 xor ecx, ebp 891 xor ebx, ebp
891 rol ecx, 1 892 rol ebx, 1
892 mov ebp, edi 893 mov ebp, edi
893 mov DWORD PTR 52[esp],ecx 894 mov DWORD PTR 52[esp],ebx
894 or ebp, esi 895 or ebp, esi
895 lea ecx, DWORD PTR 2400959708[ebx*1+ecx] 896 lea ebx, DWORD PTR 2400959708[ecx*1+ebx]
896 mov ebx, edi 897 mov ecx, edi
897 and ebp, eax 898 and ebp, eax
898 and ebx, esi 899 and ecx, esi
899 or ebp, ebx 900 or ebp, ecx
900 mov ebx, edx 901 mov ecx, edx
901 rol ebx, 5 902 rol ecx, 5
902 ror edi, 1 903 ror edi, 1
903 add ebp, ebx 904 add ebp, ecx
904 ror edi, 1 905 ror edi, 1
905 add ecx, ebp 906 add ebx, ebp
906 ; 40_59 45 907 ; 40_59 45
907 ; 40_59 46 908 ; 40_59 46
908 mov ebx, DWORD PTR 56[esp] 909 mov ecx, DWORD PTR 56[esp]
909 mov ebp, DWORD PTR [esp] 910 mov ebp, DWORD PTR [esp]
910 xor ebx, ebp 911 xor ecx, ebp
911 mov ebp, DWORD PTR 24[esp] 912 mov ebp, DWORD PTR 24[esp]
912 xor ebx, ebp 913 xor ecx, ebp
913 mov ebp, DWORD PTR 44[esp] 914 mov ebp, DWORD PTR 44[esp]
914 xor ebx, ebp 915 xor ecx, ebp
915 mov ebp, edx 916 mov ebp, edx
916 rol ebx, 1 917 rol ecx, 1
917 or ebp, edi 918 or ebp, edi
918 mov DWORD PTR 56[esp],ebx 919 mov DWORD PTR 56[esp],ecx
919 and ebp, esi 920 and ebp, esi
920 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 921 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
921 mov eax, edx 922 mov eax, edx
922 ror edx, 1 923 ror edx, 1
923 and eax, edi 924 and eax, edi
924 or ebp, eax 925 or ebp, eax
925 mov eax, ecx 926 mov eax, ebx
926 rol eax, 5 927 rol eax, 5
927 add ebp, eax 928 add ebp, eax
928 mov eax, DWORD PTR 60[esp] 929 mov eax, DWORD PTR 60[esp]
929 add ebx, ebp 930 add ecx, ebp
930 mov ebp, DWORD PTR 4[esp] 931 mov ebp, DWORD PTR 4[esp]
931 xor eax, ebp 932 xor eax, ebp
932 mov ebp, DWORD PTR 28[esp] 933 mov ebp, DWORD PTR 28[esp]
@@ -935,19 +936,19 @@ L000start:
935 ror edx, 1 936 ror edx, 1
936 xor eax, ebp 937 xor eax, ebp
937 rol eax, 1 938 rol eax, 1
938 mov ebp, ecx 939 mov ebp, ebx
939 mov DWORD PTR 60[esp],eax 940 mov DWORD PTR 60[esp],eax
940 or ebp, edx 941 or ebp, edx
941 lea eax, DWORD PTR 2400959708[esi*1+eax] 942 lea eax, DWORD PTR 2400959708[esi*1+eax]
942 mov esi, ecx 943 mov esi, ebx
943 and ebp, edi 944 and ebp, edi
944 and esi, edx 945 and esi, edx
945 or ebp, esi 946 or ebp, esi
946 mov esi, ebx 947 mov esi, ecx
947 rol esi, 5 948 rol esi, 5
948 ror ecx, 1 949 ror ebx, 1
949 add ebp, esi 950 add ebp, esi
950 ror ecx, 1 951 ror ebx, 1
951 add eax, ebp 952 add eax, ebp
952 ; 40_59 47 953 ; 40_59 47
953 ; 40_59 48 954 ; 40_59 48
@@ -958,15 +959,15 @@ L000start:
958 xor esi, ebp 959 xor esi, ebp
959 mov ebp, DWORD PTR 52[esp] 960 mov ebp, DWORD PTR 52[esp]
960 xor esi, ebp 961 xor esi, ebp
961 mov ebp, ebx 962 mov ebp, ecx
962 rol esi, 1 963 rol esi, 1
963 or ebp, ecx 964 or ebp, ebx
964 mov DWORD PTR [esp],esi 965 mov DWORD PTR [esp],esi
965 and ebp, edx 966 and ebp, edx
966 lea esi, DWORD PTR 2400959708[edi*1+esi] 967 lea esi, DWORD PTR 2400959708[edi*1+esi]
967 mov edi, ebx 968 mov edi, ecx
968 ror ebx, 1 969 ror ecx, 1
969 and edi, ecx 970 and edi, ebx
970 or ebp, edi 971 or ebp, edi
971 mov edi, eax 972 mov edi, eax
972 rol edi, 5 973 rol edi, 5
@@ -978,16 +979,16 @@ L000start:
978 mov ebp, DWORD PTR 36[esp] 979 mov ebp, DWORD PTR 36[esp]
979 xor edi, ebp 980 xor edi, ebp
980 mov ebp, DWORD PTR 56[esp] 981 mov ebp, DWORD PTR 56[esp]
981 ror ebx, 1 982 ror ecx, 1
982 xor edi, ebp 983 xor edi, ebp
983 rol edi, 1 984 rol edi, 1
984 mov ebp, eax 985 mov ebp, eax
985 mov DWORD PTR 4[esp],edi 986 mov DWORD PTR 4[esp],edi
986 or ebp, ebx 987 or ebp, ecx
987 lea edi, DWORD PTR 2400959708[edx*1+edi] 988 lea edi, DWORD PTR 2400959708[edx*1+edi]
988 mov edx, eax 989 mov edx, eax
989 and ebp, ecx 990 and ebp, ebx
990 and edx, ebx 991 and edx, ecx
991 or ebp, edx 992 or ebp, edx
992 mov edx, esi 993 mov edx, esi
993 rol edx, 5 994 rol edx, 5
@@ -1008,63 +1009,63 @@ L000start:
1008 rol edx, 1 1009 rol edx, 1
1009 or ebp, eax 1010 or ebp, eax
1010 mov DWORD PTR 8[esp],edx 1011 mov DWORD PTR 8[esp],edx
1011 and ebp, ebx 1012 and ebp, ecx
1012 lea edx, DWORD PTR 2400959708[ecx*1+edx] 1013 lea edx, DWORD PTR 2400959708[ebx*1+edx]
1013 mov ecx, esi 1014 mov ebx, esi
1014 ror esi, 1 1015 ror esi, 1
1015 and ecx, eax 1016 and ebx, eax
1016 or ebp, ecx 1017 or ebp, ebx
1017 mov ecx, edi 1018 mov ebx, edi
1018 rol ecx, 5 1019 rol ebx, 5
1019 add ebp, ecx 1020 add ebp, ebx
1020 mov ecx, DWORD PTR 12[esp] 1021 mov ebx, DWORD PTR 12[esp]
1021 add edx, ebp 1022 add edx, ebp
1022 mov ebp, DWORD PTR 20[esp] 1023 mov ebp, DWORD PTR 20[esp]
1023 xor ecx, ebp 1024 xor ebx, ebp
1024 mov ebp, DWORD PTR 44[esp] 1025 mov ebp, DWORD PTR 44[esp]
1025 xor ecx, ebp 1026 xor ebx, ebp
1026 mov ebp, DWORD PTR [esp] 1027 mov ebp, DWORD PTR [esp]
1027 ror esi, 1 1028 ror esi, 1
1028 xor ecx, ebp 1029 xor ebx, ebp
1029 rol ecx, 1 1030 rol ebx, 1
1030 mov ebp, edi 1031 mov ebp, edi
1031 mov DWORD PTR 12[esp],ecx 1032 mov DWORD PTR 12[esp],ebx
1032 or ebp, esi 1033 or ebp, esi
1033 lea ecx, DWORD PTR 2400959708[ebx*1+ecx] 1034 lea ebx, DWORD PTR 2400959708[ecx*1+ebx]
1034 mov ebx, edi 1035 mov ecx, edi
1035 and ebp, eax 1036 and ebp, eax
1036 and ebx, esi 1037 and ecx, esi
1037 or ebp, ebx 1038 or ebp, ecx
1038 mov ebx, edx 1039 mov ecx, edx
1039 rol ebx, 5 1040 rol ecx, 5
1040 ror edi, 1 1041 ror edi, 1
1041 add ebp, ebx 1042 add ebp, ecx
1042 ror edi, 1 1043 ror edi, 1
1043 add ecx, ebp 1044 add ebx, ebp
1044 ; 40_59 51 1045 ; 40_59 51
1045 ; 40_59 52 1046 ; 40_59 52
1046 mov ebx, DWORD PTR 16[esp] 1047 mov ecx, DWORD PTR 16[esp]
1047 mov ebp, DWORD PTR 24[esp] 1048 mov ebp, DWORD PTR 24[esp]
1048 xor ebx, ebp 1049 xor ecx, ebp
1049 mov ebp, DWORD PTR 48[esp] 1050 mov ebp, DWORD PTR 48[esp]
1050 xor ebx, ebp 1051 xor ecx, ebp
1051 mov ebp, DWORD PTR 4[esp] 1052 mov ebp, DWORD PTR 4[esp]
1052 xor ebx, ebp 1053 xor ecx, ebp
1053 mov ebp, edx 1054 mov ebp, edx
1054 rol ebx, 1 1055 rol ecx, 1
1055 or ebp, edi 1056 or ebp, edi
1056 mov DWORD PTR 16[esp],ebx 1057 mov DWORD PTR 16[esp],ecx
1057 and ebp, esi 1058 and ebp, esi
1058 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 1059 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
1059 mov eax, edx 1060 mov eax, edx
1060 ror edx, 1 1061 ror edx, 1
1061 and eax, edi 1062 and eax, edi
1062 or ebp, eax 1063 or ebp, eax
1063 mov eax, ecx 1064 mov eax, ebx
1064 rol eax, 5 1065 rol eax, 5
1065 add ebp, eax 1066 add ebp, eax
1066 mov eax, DWORD PTR 20[esp] 1067 mov eax, DWORD PTR 20[esp]
1067 add ebx, ebp 1068 add ecx, ebp
1068 mov ebp, DWORD PTR 28[esp] 1069 mov ebp, DWORD PTR 28[esp]
1069 xor eax, ebp 1070 xor eax, ebp
1070 mov ebp, DWORD PTR 52[esp] 1071 mov ebp, DWORD PTR 52[esp]
@@ -1073,19 +1074,19 @@ L000start:
1073 ror edx, 1 1074 ror edx, 1
1074 xor eax, ebp 1075 xor eax, ebp
1075 rol eax, 1 1076 rol eax, 1
1076 mov ebp, ecx 1077 mov ebp, ebx
1077 mov DWORD PTR 20[esp],eax 1078 mov DWORD PTR 20[esp],eax
1078 or ebp, edx 1079 or ebp, edx
1079 lea eax, DWORD PTR 2400959708[esi*1+eax] 1080 lea eax, DWORD PTR 2400959708[esi*1+eax]
1080 mov esi, ecx 1081 mov esi, ebx
1081 and ebp, edi 1082 and ebp, edi
1082 and esi, edx 1083 and esi, edx
1083 or ebp, esi 1084 or ebp, esi
1084 mov esi, ebx 1085 mov esi, ecx
1085 rol esi, 5 1086 rol esi, 5
1086 ror ecx, 1 1087 ror ebx, 1
1087 add ebp, esi 1088 add ebp, esi
1088 ror ecx, 1 1089 ror ebx, 1
1089 add eax, ebp 1090 add eax, ebp
1090 ; 40_59 53 1091 ; 40_59 53
1091 ; 40_59 54 1092 ; 40_59 54
@@ -1096,15 +1097,15 @@ L000start:
1096 xor esi, ebp 1097 xor esi, ebp
1097 mov ebp, DWORD PTR 12[esp] 1098 mov ebp, DWORD PTR 12[esp]
1098 xor esi, ebp 1099 xor esi, ebp
1099 mov ebp, ebx 1100 mov ebp, ecx
1100 rol esi, 1 1101 rol esi, 1
1101 or ebp, ecx 1102 or ebp, ebx
1102 mov DWORD PTR 24[esp],esi 1103 mov DWORD PTR 24[esp],esi
1103 and ebp, edx 1104 and ebp, edx
1104 lea esi, DWORD PTR 2400959708[edi*1+esi] 1105 lea esi, DWORD PTR 2400959708[edi*1+esi]
1105 mov edi, ebx 1106 mov edi, ecx
1106 ror ebx, 1 1107 ror ecx, 1
1107 and edi, ecx 1108 and edi, ebx
1108 or ebp, edi 1109 or ebp, edi
1109 mov edi, eax 1110 mov edi, eax
1110 rol edi, 5 1111 rol edi, 5
@@ -1116,16 +1117,16 @@ L000start:
1116 mov ebp, DWORD PTR 60[esp] 1117 mov ebp, DWORD PTR 60[esp]
1117 xor edi, ebp 1118 xor edi, ebp
1118 mov ebp, DWORD PTR 16[esp] 1119 mov ebp, DWORD PTR 16[esp]
1119 ror ebx, 1 1120 ror ecx, 1
1120 xor edi, ebp 1121 xor edi, ebp
1121 rol edi, 1 1122 rol edi, 1
1122 mov ebp, eax 1123 mov ebp, eax
1123 mov DWORD PTR 28[esp],edi 1124 mov DWORD PTR 28[esp],edi
1124 or ebp, ebx 1125 or ebp, ecx
1125 lea edi, DWORD PTR 2400959708[edx*1+edi] 1126 lea edi, DWORD PTR 2400959708[edx*1+edi]
1126 mov edx, eax 1127 mov edx, eax
1127 and ebp, ecx 1128 and ebp, ebx
1128 and edx, ebx 1129 and edx, ecx
1129 or ebp, edx 1130 or ebp, edx
1130 mov edx, esi 1131 mov edx, esi
1131 rol edx, 5 1132 rol edx, 5
@@ -1146,63 +1147,63 @@ L000start:
1146 rol edx, 1 1147 rol edx, 1
1147 or ebp, eax 1148 or ebp, eax
1148 mov DWORD PTR 32[esp],edx 1149 mov DWORD PTR 32[esp],edx
1149 and ebp, ebx 1150 and ebp, ecx
1150 lea edx, DWORD PTR 2400959708[ecx*1+edx] 1151 lea edx, DWORD PTR 2400959708[ebx*1+edx]
1151 mov ecx, esi 1152 mov ebx, esi
1152 ror esi, 1 1153 ror esi, 1
1153 and ecx, eax 1154 and ebx, eax
1154 or ebp, ecx 1155 or ebp, ebx
1155 mov ecx, edi 1156 mov ebx, edi
1156 rol ecx, 5 1157 rol ebx, 5
1157 add ebp, ecx 1158 add ebp, ebx
1158 mov ecx, DWORD PTR 36[esp] 1159 mov ebx, DWORD PTR 36[esp]
1159 add edx, ebp 1160 add edx, ebp
1160 mov ebp, DWORD PTR 44[esp] 1161 mov ebp, DWORD PTR 44[esp]
1161 xor ecx, ebp 1162 xor ebx, ebp
1162 mov ebp, DWORD PTR 4[esp] 1163 mov ebp, DWORD PTR 4[esp]
1163 xor ecx, ebp 1164 xor ebx, ebp
1164 mov ebp, DWORD PTR 24[esp] 1165 mov ebp, DWORD PTR 24[esp]
1165 ror esi, 1 1166 ror esi, 1
1166 xor ecx, ebp 1167 xor ebx, ebp
1167 rol ecx, 1 1168 rol ebx, 1
1168 mov ebp, edi 1169 mov ebp, edi
1169 mov DWORD PTR 36[esp],ecx 1170 mov DWORD PTR 36[esp],ebx
1170 or ebp, esi 1171 or ebp, esi
1171 lea ecx, DWORD PTR 2400959708[ebx*1+ecx] 1172 lea ebx, DWORD PTR 2400959708[ecx*1+ebx]
1172 mov ebx, edi 1173 mov ecx, edi
1173 and ebp, eax 1174 and ebp, eax
1174 and ebx, esi 1175 and ecx, esi
1175 or ebp, ebx 1176 or ebp, ecx
1176 mov ebx, edx 1177 mov ecx, edx
1177 rol ebx, 5 1178 rol ecx, 5
1178 ror edi, 1 1179 ror edi, 1
1179 add ebp, ebx 1180 add ebp, ecx
1180 ror edi, 1 1181 ror edi, 1
1181 add ecx, ebp 1182 add ebx, ebp
1182 ; 40_59 57 1183 ; 40_59 57
1183 ; 40_59 58 1184 ; 40_59 58
1184 mov ebx, DWORD PTR 40[esp] 1185 mov ecx, DWORD PTR 40[esp]
1185 mov ebp, DWORD PTR 48[esp] 1186 mov ebp, DWORD PTR 48[esp]
1186 xor ebx, ebp 1187 xor ecx, ebp
1187 mov ebp, DWORD PTR 8[esp] 1188 mov ebp, DWORD PTR 8[esp]
1188 xor ebx, ebp 1189 xor ecx, ebp
1189 mov ebp, DWORD PTR 28[esp] 1190 mov ebp, DWORD PTR 28[esp]
1190 xor ebx, ebp 1191 xor ecx, ebp
1191 mov ebp, edx 1192 mov ebp, edx
1192 rol ebx, 1 1193 rol ecx, 1
1193 or ebp, edi 1194 or ebp, edi
1194 mov DWORD PTR 40[esp],ebx 1195 mov DWORD PTR 40[esp],ecx
1195 and ebp, esi 1196 and ebp, esi
1196 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 1197 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
1197 mov eax, edx 1198 mov eax, edx
1198 ror edx, 1 1199 ror edx, 1
1199 and eax, edi 1200 and eax, edi
1200 or ebp, eax 1201 or ebp, eax
1201 mov eax, ecx 1202 mov eax, ebx
1202 rol eax, 5 1203 rol eax, 5
1203 add ebp, eax 1204 add ebp, eax
1204 mov eax, DWORD PTR 44[esp] 1205 mov eax, DWORD PTR 44[esp]
1205 add ebx, ebp 1206 add ecx, ebp
1206 mov ebp, DWORD PTR 52[esp] 1207 mov ebp, DWORD PTR 52[esp]
1207 xor eax, ebp 1208 xor eax, ebp
1208 mov ebp, DWORD PTR 12[esp] 1209 mov ebp, DWORD PTR 12[esp]
@@ -1211,19 +1212,19 @@ L000start:
1211 ror edx, 1 1212 ror edx, 1
1212 xor eax, ebp 1213 xor eax, ebp
1213 rol eax, 1 1214 rol eax, 1
1214 mov ebp, ecx 1215 mov ebp, ebx
1215 mov DWORD PTR 44[esp],eax 1216 mov DWORD PTR 44[esp],eax
1216 or ebp, edx 1217 or ebp, edx
1217 lea eax, DWORD PTR 2400959708[esi*1+eax] 1218 lea eax, DWORD PTR 2400959708[esi*1+eax]
1218 mov esi, ecx 1219 mov esi, ebx
1219 and ebp, edi 1220 and ebp, edi
1220 and esi, edx 1221 and esi, edx
1221 or ebp, esi 1222 or ebp, esi
1222 mov esi, ebx 1223 mov esi, ecx
1223 rol esi, 5 1224 rol esi, 5
1224 ror ecx, 1 1225 ror ebx, 1
1225 add ebp, esi 1226 add ebp, esi
1226 ror ecx, 1 1227 ror ebx, 1
1227 add eax, ebp 1228 add eax, ebp
1228 ; 40_59 59 1229 ; 40_59 59
1229 ; 20_39 60 1230 ; 20_39 60
@@ -1234,17 +1235,17 @@ L000start:
1234 xor esi, ebp 1235 xor esi, ebp
1235 mov ebp, DWORD PTR 36[esp] 1236 mov ebp, DWORD PTR 36[esp]
1236 xor esi, ebp 1237 xor esi, ebp
1237 mov ebp, ebx 1238 mov ebp, ecx
1238 rol esi, 1 1239 rol esi, 1
1239 xor ebp, ecx 1240 xor ebp, ebx
1240 mov DWORD PTR 48[esp],esi 1241 mov DWORD PTR 48[esp],esi
1241 xor ebp, edx 1242 xor ebp, edx
1242 lea esi, DWORD PTR 3395469782[edi*1+esi] 1243 lea esi, DWORD PTR 3395469782[edi*1+esi]
1243 mov edi, eax 1244 mov edi, eax
1244 rol edi, 5 1245 rol edi, 5
1245 ror ebx, 1 1246 ror ecx, 1
1246 add edi, ebp 1247 add edi, ebp
1247 ror ebx, 1 1248 ror ecx, 1
1248 add esi, edi 1249 add esi, edi
1249 ; 20_39 61 1250 ; 20_39 61
1250 mov edi, DWORD PTR 52[esp] 1251 mov edi, DWORD PTR 52[esp]
@@ -1256,9 +1257,9 @@ L000start:
1256 xor edi, ebp 1257 xor edi, ebp
1257 mov ebp, eax 1258 mov ebp, eax
1258 rol edi, 1 1259 rol edi, 1
1259 xor ebp, ebx
1260 mov DWORD PTR 52[esp],edi
1261 xor ebp, ecx 1260 xor ebp, ecx
1261 mov DWORD PTR 52[esp],edi
1262 xor ebp, ebx
1262 lea edi, DWORD PTR 3395469782[edx*1+edi] 1263 lea edi, DWORD PTR 3395469782[edx*1+edi]
1263 mov edx, esi 1264 mov edx, esi
1264 rol edx, 5 1265 rol edx, 5
@@ -1278,54 +1279,54 @@ L000start:
1278 rol edx, 1 1279 rol edx, 1
1279 xor ebp, eax 1280 xor ebp, eax
1280 mov DWORD PTR 56[esp],edx 1281 mov DWORD PTR 56[esp],edx
1281 xor ebp, ebx 1282 xor ebp, ecx
1282 lea edx, DWORD PTR 3395469782[ecx*1+edx] 1283 lea edx, DWORD PTR 3395469782[ebx*1+edx]
1283 mov ecx, edi 1284 mov ebx, edi
1284 rol ecx, 5 1285 rol ebx, 5
1285 ror esi, 1 1286 ror esi, 1
1286 add ecx, ebp 1287 add ebx, ebp
1287 ror esi, 1 1288 ror esi, 1
1288 add edx, ecx 1289 add edx, ebx
1289 ; 20_39 63 1290 ; 20_39 63
1290 mov ecx, DWORD PTR 60[esp] 1291 mov ebx, DWORD PTR 60[esp]
1291 mov ebp, DWORD PTR 4[esp] 1292 mov ebp, DWORD PTR 4[esp]
1292 xor ecx, ebp 1293 xor ebx, ebp
1293 mov ebp, DWORD PTR 28[esp] 1294 mov ebp, DWORD PTR 28[esp]
1294 xor ecx, ebp 1295 xor ebx, ebp
1295 mov ebp, DWORD PTR 48[esp] 1296 mov ebp, DWORD PTR 48[esp]
1296 xor ecx, ebp 1297 xor ebx, ebp
1297 mov ebp, edi 1298 mov ebp, edi
1298 rol ecx, 1 1299 rol ebx, 1
1299 xor ebp, esi 1300 xor ebp, esi
1300 mov DWORD PTR 60[esp],ecx 1301 mov DWORD PTR 60[esp],ebx
1301 xor ebp, eax 1302 xor ebp, eax
1302 lea ecx, DWORD PTR 3395469782[ebx*1+ecx] 1303 lea ebx, DWORD PTR 3395469782[ecx*1+ebx]
1303 mov ebx, edx 1304 mov ecx, edx
1304 rol ebx, 5 1305 rol ecx, 5
1305 ror edi, 1 1306 ror edi, 1
1306 add ebx, ebp 1307 add ecx, ebp
1307 ror edi, 1 1308 ror edi, 1
1308 add ecx, ebx 1309 add ebx, ecx
1309 ; 20_39 64 1310 ; 20_39 64
1310 mov ebx, DWORD PTR [esp] 1311 mov ecx, DWORD PTR [esp]
1311 mov ebp, DWORD PTR 8[esp] 1312 mov ebp, DWORD PTR 8[esp]
1312 xor ebx, ebp 1313 xor ecx, ebp
1313 mov ebp, DWORD PTR 32[esp] 1314 mov ebp, DWORD PTR 32[esp]
1314 xor ebx, ebp 1315 xor ecx, ebp
1315 mov ebp, DWORD PTR 52[esp] 1316 mov ebp, DWORD PTR 52[esp]
1316 xor ebx, ebp 1317 xor ecx, ebp
1317 mov ebp, edx 1318 mov ebp, edx
1318 rol ebx, 1 1319 rol ecx, 1
1319 xor ebp, edi 1320 xor ebp, edi
1320 mov DWORD PTR [esp],ebx 1321 mov DWORD PTR [esp],ecx
1321 xor ebp, esi 1322 xor ebp, esi
1322 lea ebx, DWORD PTR 3395469782[eax*1+ebx] 1323 lea ecx, DWORD PTR 3395469782[eax*1+ecx]
1323 mov eax, ecx 1324 mov eax, ebx
1324 rol eax, 5 1325 rol eax, 5
1325 ror edx, 1 1326 ror edx, 1
1326 add eax, ebp 1327 add eax, ebp
1327 ror edx, 1 1328 ror edx, 1
1328 add ebx, eax 1329 add ecx, eax
1329 ; 20_39 65 1330 ; 20_39 65
1330 mov eax, DWORD PTR 4[esp] 1331 mov eax, DWORD PTR 4[esp]
1331 mov ebp, DWORD PTR 12[esp] 1332 mov ebp, DWORD PTR 12[esp]
@@ -1334,17 +1335,17 @@ L000start:
1334 xor eax, ebp 1335 xor eax, ebp
1335 mov ebp, DWORD PTR 56[esp] 1336 mov ebp, DWORD PTR 56[esp]
1336 xor eax, ebp 1337 xor eax, ebp
1337 mov ebp, ecx 1338 mov ebp, ebx
1338 rol eax, 1 1339 rol eax, 1
1339 xor ebp, edx 1340 xor ebp, edx
1340 mov DWORD PTR 4[esp],eax 1341 mov DWORD PTR 4[esp],eax
1341 xor ebp, edi 1342 xor ebp, edi
1342 lea eax, DWORD PTR 3395469782[esi*1+eax] 1343 lea eax, DWORD PTR 3395469782[esi*1+eax]
1343 mov esi, ebx 1344 mov esi, ecx
1344 rol esi, 5 1345 rol esi, 5
1345 ror ecx, 1 1346 ror ebx, 1
1346 add esi, ebp 1347 add esi, ebp
1347 ror ecx, 1 1348 ror ebx, 1
1348 add eax, esi 1349 add eax, esi
1349 ; 20_39 66 1350 ; 20_39 66
1350 mov esi, DWORD PTR 8[esp] 1351 mov esi, DWORD PTR 8[esp]
@@ -1354,17 +1355,17 @@ L000start:
1354 xor esi, ebp 1355 xor esi, ebp
1355 mov ebp, DWORD PTR 60[esp] 1356 mov ebp, DWORD PTR 60[esp]
1356 xor esi, ebp 1357 xor esi, ebp
1357 mov ebp, ebx 1358 mov ebp, ecx
1358 rol esi, 1 1359 rol esi, 1
1359 xor ebp, ecx 1360 xor ebp, ebx
1360 mov DWORD PTR 8[esp],esi 1361 mov DWORD PTR 8[esp],esi
1361 xor ebp, edx 1362 xor ebp, edx
1362 lea esi, DWORD PTR 3395469782[edi*1+esi] 1363 lea esi, DWORD PTR 3395469782[edi*1+esi]
1363 mov edi, eax 1364 mov edi, eax
1364 rol edi, 5 1365 rol edi, 5
1365 ror ebx, 1 1366 ror ecx, 1
1366 add edi, ebp 1367 add edi, ebp
1367 ror ebx, 1 1368 ror ecx, 1
1368 add esi, edi 1369 add esi, edi
1369 ; 20_39 67 1370 ; 20_39 67
1370 mov edi, DWORD PTR 12[esp] 1371 mov edi, DWORD PTR 12[esp]
@@ -1376,9 +1377,9 @@ L000start:
1376 xor edi, ebp 1377 xor edi, ebp
1377 mov ebp, eax 1378 mov ebp, eax
1378 rol edi, 1 1379 rol edi, 1
1379 xor ebp, ebx
1380 mov DWORD PTR 12[esp],edi
1381 xor ebp, ecx 1380 xor ebp, ecx
1381 mov DWORD PTR 12[esp],edi
1382 xor ebp, ebx
1382 lea edi, DWORD PTR 3395469782[edx*1+edi] 1383 lea edi, DWORD PTR 3395469782[edx*1+edi]
1383 mov edx, esi 1384 mov edx, esi
1384 rol edx, 5 1385 rol edx, 5
@@ -1398,54 +1399,54 @@ L000start:
1398 rol edx, 1 1399 rol edx, 1
1399 xor ebp, eax 1400 xor ebp, eax
1400 mov DWORD PTR 16[esp],edx 1401 mov DWORD PTR 16[esp],edx
1401 xor ebp, ebx 1402 xor ebp, ecx
1402 lea edx, DWORD PTR 3395469782[ecx*1+edx] 1403 lea edx, DWORD PTR 3395469782[ebx*1+edx]
1403 mov ecx, edi 1404 mov ebx, edi
1404 rol ecx, 5 1405 rol ebx, 5
1405 ror esi, 1 1406 ror esi, 1
1406 add ecx, ebp 1407 add ebx, ebp
1407 ror esi, 1 1408 ror esi, 1
1408 add edx, ecx 1409 add edx, ebx
1409 ; 20_39 69 1410 ; 20_39 69
1410 mov ecx, DWORD PTR 20[esp] 1411 mov ebx, DWORD PTR 20[esp]
1411 mov ebp, DWORD PTR 28[esp] 1412 mov ebp, DWORD PTR 28[esp]
1412 xor ecx, ebp 1413 xor ebx, ebp
1413 mov ebp, DWORD PTR 52[esp] 1414 mov ebp, DWORD PTR 52[esp]
1414 xor ecx, ebp 1415 xor ebx, ebp
1415 mov ebp, DWORD PTR 8[esp] 1416 mov ebp, DWORD PTR 8[esp]
1416 xor ecx, ebp 1417 xor ebx, ebp
1417 mov ebp, edi 1418 mov ebp, edi
1418 rol ecx, 1 1419 rol ebx, 1
1419 xor ebp, esi 1420 xor ebp, esi
1420 mov DWORD PTR 20[esp],ecx 1421 mov DWORD PTR 20[esp],ebx
1421 xor ebp, eax 1422 xor ebp, eax
1422 lea ecx, DWORD PTR 3395469782[ebx*1+ecx] 1423 lea ebx, DWORD PTR 3395469782[ecx*1+ebx]
1423 mov ebx, edx 1424 mov ecx, edx
1424 rol ebx, 5 1425 rol ecx, 5
1425 ror edi, 1 1426 ror edi, 1
1426 add ebx, ebp 1427 add ecx, ebp
1427 ror edi, 1 1428 ror edi, 1
1428 add ecx, ebx 1429 add ebx, ecx
1429 ; 20_39 70 1430 ; 20_39 70
1430 mov ebx, DWORD PTR 24[esp] 1431 mov ecx, DWORD PTR 24[esp]
1431 mov ebp, DWORD PTR 32[esp] 1432 mov ebp, DWORD PTR 32[esp]
1432 xor ebx, ebp 1433 xor ecx, ebp
1433 mov ebp, DWORD PTR 56[esp] 1434 mov ebp, DWORD PTR 56[esp]
1434 xor ebx, ebp 1435 xor ecx, ebp
1435 mov ebp, DWORD PTR 12[esp] 1436 mov ebp, DWORD PTR 12[esp]
1436 xor ebx, ebp 1437 xor ecx, ebp
1437 mov ebp, edx 1438 mov ebp, edx
1438 rol ebx, 1 1439 rol ecx, 1
1439 xor ebp, edi 1440 xor ebp, edi
1440 mov DWORD PTR 24[esp],ebx 1441 mov DWORD PTR 24[esp],ecx
1441 xor ebp, esi 1442 xor ebp, esi
1442 lea ebx, DWORD PTR 3395469782[eax*1+ebx] 1443 lea ecx, DWORD PTR 3395469782[eax*1+ecx]
1443 mov eax, ecx 1444 mov eax, ebx
1444 rol eax, 5 1445 rol eax, 5
1445 ror edx, 1 1446 ror edx, 1
1446 add eax, ebp 1447 add eax, ebp
1447 ror edx, 1 1448 ror edx, 1
1448 add ebx, eax 1449 add ecx, eax
1449 ; 20_39 71 1450 ; 20_39 71
1450 mov eax, DWORD PTR 28[esp] 1451 mov eax, DWORD PTR 28[esp]
1451 mov ebp, DWORD PTR 36[esp] 1452 mov ebp, DWORD PTR 36[esp]
@@ -1454,17 +1455,17 @@ L000start:
1454 xor eax, ebp 1455 xor eax, ebp
1455 mov ebp, DWORD PTR 16[esp] 1456 mov ebp, DWORD PTR 16[esp]
1456 xor eax, ebp 1457 xor eax, ebp
1457 mov ebp, ecx 1458 mov ebp, ebx
1458 rol eax, 1 1459 rol eax, 1
1459 xor ebp, edx 1460 xor ebp, edx
1460 mov DWORD PTR 28[esp],eax 1461 mov DWORD PTR 28[esp],eax
1461 xor ebp, edi 1462 xor ebp, edi
1462 lea eax, DWORD PTR 3395469782[esi*1+eax] 1463 lea eax, DWORD PTR 3395469782[esi*1+eax]
1463 mov esi, ebx 1464 mov esi, ecx
1464 rol esi, 5 1465 rol esi, 5
1465 ror ecx, 1 1466 ror ebx, 1
1466 add esi, ebp 1467 add esi, ebp
1467 ror ecx, 1 1468 ror ebx, 1
1468 add eax, esi 1469 add eax, esi
1469 ; 20_39 72 1470 ; 20_39 72
1470 mov esi, DWORD PTR 32[esp] 1471 mov esi, DWORD PTR 32[esp]
@@ -1474,17 +1475,17 @@ L000start:
1474 xor esi, ebp 1475 xor esi, ebp
1475 mov ebp, DWORD PTR 20[esp] 1476 mov ebp, DWORD PTR 20[esp]
1476 xor esi, ebp 1477 xor esi, ebp
1477 mov ebp, ebx 1478 mov ebp, ecx
1478 rol esi, 1 1479 rol esi, 1
1479 xor ebp, ecx 1480 xor ebp, ebx
1480 mov DWORD PTR 32[esp],esi 1481 mov DWORD PTR 32[esp],esi
1481 xor ebp, edx 1482 xor ebp, edx
1482 lea esi, DWORD PTR 3395469782[edi*1+esi] 1483 lea esi, DWORD PTR 3395469782[edi*1+esi]
1483 mov edi, eax 1484 mov edi, eax
1484 rol edi, 5 1485 rol edi, 5
1485 ror ebx, 1 1486 ror ecx, 1
1486 add edi, ebp 1487 add edi, ebp
1487 ror ebx, 1 1488 ror ecx, 1
1488 add esi, edi 1489 add esi, edi
1489 ; 20_39 73 1490 ; 20_39 73
1490 mov edi, DWORD PTR 36[esp] 1491 mov edi, DWORD PTR 36[esp]
@@ -1496,9 +1497,9 @@ L000start:
1496 xor edi, ebp 1497 xor edi, ebp
1497 mov ebp, eax 1498 mov ebp, eax
1498 rol edi, 1 1499 rol edi, 1
1499 xor ebp, ebx
1500 mov DWORD PTR 36[esp],edi
1501 xor ebp, ecx 1500 xor ebp, ecx
1501 mov DWORD PTR 36[esp],edi
1502 xor ebp, ebx
1502 lea edi, DWORD PTR 3395469782[edx*1+edi] 1503 lea edi, DWORD PTR 3395469782[edx*1+edi]
1503 mov edx, esi 1504 mov edx, esi
1504 rol edx, 5 1505 rol edx, 5
@@ -1518,54 +1519,54 @@ L000start:
1518 rol edx, 1 1519 rol edx, 1
1519 xor ebp, eax 1520 xor ebp, eax
1520 mov DWORD PTR 40[esp],edx 1521 mov DWORD PTR 40[esp],edx
1521 xor ebp, ebx 1522 xor ebp, ecx
1522 lea edx, DWORD PTR 3395469782[ecx*1+edx] 1523 lea edx, DWORD PTR 3395469782[ebx*1+edx]
1523 mov ecx, edi 1524 mov ebx, edi
1524 rol ecx, 5 1525 rol ebx, 5
1525 ror esi, 1 1526 ror esi, 1
1526 add ecx, ebp 1527 add ebx, ebp
1527 ror esi, 1 1528 ror esi, 1
1528 add edx, ecx 1529 add edx, ebx
1529 ; 20_39 75 1530 ; 20_39 75
1530 mov ecx, DWORD PTR 44[esp] 1531 mov ebx, DWORD PTR 44[esp]
1531 mov ebp, DWORD PTR 52[esp] 1532 mov ebp, DWORD PTR 52[esp]
1532 xor ecx, ebp 1533 xor ebx, ebp
1533 mov ebp, DWORD PTR 12[esp] 1534 mov ebp, DWORD PTR 12[esp]
1534 xor ecx, ebp 1535 xor ebx, ebp
1535 mov ebp, DWORD PTR 32[esp] 1536 mov ebp, DWORD PTR 32[esp]
1536 xor ecx, ebp 1537 xor ebx, ebp
1537 mov ebp, edi 1538 mov ebp, edi
1538 rol ecx, 1 1539 rol ebx, 1
1539 xor ebp, esi 1540 xor ebp, esi
1540 mov DWORD PTR 44[esp],ecx 1541 mov DWORD PTR 44[esp],ebx
1541 xor ebp, eax 1542 xor ebp, eax
1542 lea ecx, DWORD PTR 3395469782[ebx*1+ecx] 1543 lea ebx, DWORD PTR 3395469782[ecx*1+ebx]
1543 mov ebx, edx 1544 mov ecx, edx
1544 rol ebx, 5 1545 rol ecx, 5
1545 ror edi, 1 1546 ror edi, 1
1546 add ebx, ebp 1547 add ecx, ebp
1547 ror edi, 1 1548 ror edi, 1
1548 add ecx, ebx 1549 add ebx, ecx
1549 ; 20_39 76 1550 ; 20_39 76
1550 mov ebx, DWORD PTR 48[esp] 1551 mov ecx, DWORD PTR 48[esp]
1551 mov ebp, DWORD PTR 56[esp] 1552 mov ebp, DWORD PTR 56[esp]
1552 xor ebx, ebp 1553 xor ecx, ebp
1553 mov ebp, DWORD PTR 16[esp] 1554 mov ebp, DWORD PTR 16[esp]
1554 xor ebx, ebp 1555 xor ecx, ebp
1555 mov ebp, DWORD PTR 36[esp] 1556 mov ebp, DWORD PTR 36[esp]
1556 xor ebx, ebp 1557 xor ecx, ebp
1557 mov ebp, edx 1558 mov ebp, edx
1558 rol ebx, 1 1559 rol ecx, 1
1559 xor ebp, edi 1560 xor ebp, edi
1560 mov DWORD PTR 48[esp],ebx 1561 mov DWORD PTR 48[esp],ecx
1561 xor ebp, esi 1562 xor ebp, esi
1562 lea ebx, DWORD PTR 3395469782[eax*1+ebx] 1563 lea ecx, DWORD PTR 3395469782[eax*1+ecx]
1563 mov eax, ecx 1564 mov eax, ebx
1564 rol eax, 5 1565 rol eax, 5
1565 ror edx, 1 1566 ror edx, 1
1566 add eax, ebp 1567 add eax, ebp
1567 ror edx, 1 1568 ror edx, 1
1568 add ebx, eax 1569 add ecx, eax
1569 ; 20_39 77 1570 ; 20_39 77
1570 mov eax, DWORD PTR 52[esp] 1571 mov eax, DWORD PTR 52[esp]
1571 mov ebp, DWORD PTR 60[esp] 1572 mov ebp, DWORD PTR 60[esp]
@@ -1574,17 +1575,17 @@ L000start:
1574 xor eax, ebp 1575 xor eax, ebp
1575 mov ebp, DWORD PTR 40[esp] 1576 mov ebp, DWORD PTR 40[esp]
1576 xor eax, ebp 1577 xor eax, ebp
1577 mov ebp, ecx 1578 mov ebp, ebx
1578 rol eax, 1 1579 rol eax, 1
1579 xor ebp, edx 1580 xor ebp, edx
1580 mov DWORD PTR 52[esp],eax 1581 mov DWORD PTR 52[esp],eax
1581 xor ebp, edi 1582 xor ebp, edi
1582 lea eax, DWORD PTR 3395469782[esi*1+eax] 1583 lea eax, DWORD PTR 3395469782[esi*1+eax]
1583 mov esi, ebx 1584 mov esi, ecx
1584 rol esi, 5 1585 rol esi, 5
1585 ror ecx, 1 1586 ror ebx, 1
1586 add esi, ebp 1587 add esi, ebp
1587 ror ecx, 1 1588 ror ebx, 1
1588 add eax, esi 1589 add eax, esi
1589 ; 20_39 78 1590 ; 20_39 78
1590 mov esi, DWORD PTR 56[esp] 1591 mov esi, DWORD PTR 56[esp]
@@ -1594,17 +1595,17 @@ L000start:
1594 xor esi, ebp 1595 xor esi, ebp
1595 mov ebp, DWORD PTR 44[esp] 1596 mov ebp, DWORD PTR 44[esp]
1596 xor esi, ebp 1597 xor esi, ebp
1597 mov ebp, ebx 1598 mov ebp, ecx
1598 rol esi, 1 1599 rol esi, 1
1599 xor ebp, ecx 1600 xor ebp, ebx
1600 mov DWORD PTR 56[esp],esi 1601 mov DWORD PTR 56[esp],esi
1601 xor ebp, edx 1602 xor ebp, edx
1602 lea esi, DWORD PTR 3395469782[edi*1+esi] 1603 lea esi, DWORD PTR 3395469782[edi*1+esi]
1603 mov edi, eax 1604 mov edi, eax
1604 rol edi, 5 1605 rol edi, 5
1605 ror ebx, 1 1606 ror ecx, 1
1606 add edi, ebp 1607 add edi, ebp
1607 ror ebx, 1 1608 ror ecx, 1
1608 add esi, edi 1609 add esi, edi
1609 ; 20_39 79 1610 ; 20_39 79
1610 mov edi, DWORD PTR 60[esp] 1611 mov edi, DWORD PTR 60[esp]
@@ -1616,49 +1617,100 @@ L000start:
1616 xor edi, ebp 1617 xor edi, ebp
1617 mov ebp, eax 1618 mov ebp, eax
1618 rol edi, 1 1619 rol edi, 1
1619 xor ebp, ebx
1620 mov DWORD PTR 60[esp],edi
1621 xor ebp, ecx 1620 xor ebp, ecx
1621 mov DWORD PTR 60[esp],edi
1622 xor ebp, ebx
1622 lea edi, DWORD PTR 3395469782[edx*1+edi] 1623 lea edi, DWORD PTR 3395469782[edx*1+edi]
1623 mov edx, esi 1624 mov edx, esi
1624 rol edx, 5 1625 rol edx, 5
1625 add edx, ebp 1626 add edx, ebp
1626 mov ebp, DWORD PTR 92[esp] 1627 mov ebp, DWORD PTR 128[esp]
1627 ror eax, 1 1628 ror eax, 1
1628 add edi, edx 1629 add edi, edx
1629 ror eax, 1 1630 ror eax, 1
1630 ; End processing 1631 ; End processing
1631 ; 1632 ;
1632 mov edx, DWORD PTR 12[ebp] 1633 mov edx, DWORD PTR 12[ebp]
1633 add edx, ebx 1634 add edx, ecx
1634 mov ebx, DWORD PTR 4[ebp] 1635 mov ecx, DWORD PTR 4[ebp]
1635 add ebx, esi 1636 add ecx, esi
1636 mov esi, eax 1637 mov esi, eax
1637 mov eax, DWORD PTR [ebp] 1638 mov eax, DWORD PTR [ebp]
1638 mov DWORD PTR 12[ebp],edx 1639 mov DWORD PTR 12[ebp],edx
1639 add eax, edi 1640 add eax, edi
1640 mov edi, DWORD PTR 16[ebp] 1641 mov edi, DWORD PTR 16[ebp]
1641 add edi, ecx 1642 add edi, ebx
1642 mov ecx, DWORD PTR 8[ebp] 1643 mov ebx, DWORD PTR 8[ebp]
1643 add ecx, esi 1644 add ebx, esi
1644 mov DWORD PTR [ebp],eax 1645 mov DWORD PTR [ebp],eax
1645 mov esi, DWORD PTR 64[esp] 1646 mov esi, DWORD PTR 132[esp]
1646 mov DWORD PTR 8[ebp],ecx 1647 mov DWORD PTR 8[ebp],ebx
1647 add esi, 64 1648 add esi, 64
1648 mov eax, DWORD PTR 68[esp] 1649 mov eax, DWORD PTR 68[esp]
1649 mov DWORD PTR 16[ebp],edi 1650 mov DWORD PTR 16[ebp],edi
1650 cmp eax, esi 1651 cmp esi, eax
1651 mov DWORD PTR 4[ebp],ebx 1652 mov DWORD PTR 4[ebp],ecx
1652 jl $L001end 1653 jl L000start
1653 mov eax, DWORD PTR [esi] 1654 add esp, 108
1654 jmp L000start
1655$L001end:
1656 add esp, 72
1657 pop edi 1655 pop edi
1658 pop ebx 1656 pop ebx
1659 pop ebp 1657 pop ebp
1660 pop esi 1658 pop esi
1661 ret 1659 ret
1662_sha1_block_x86 ENDP 1660_TEXT SEGMENT
1661PUBLIC _sha1_block_asm_host_order
1662
1663_sha1_block_asm_host_order PROC NEAR
1664 mov ecx, DWORD PTR 12[esp]
1665 push esi
1666 shl ecx, 6
1667 mov esi, DWORD PTR 12[esp]
1668 push ebp
1669 add ecx, esi
1670 push ebx
1671 mov ebp, DWORD PTR 16[esp]
1672 push edi
1673 mov edx, DWORD PTR 12[ebp]
1674 sub esp, 108
1675 mov edi, DWORD PTR 16[ebp]
1676 mov ebx, DWORD PTR 8[ebp]
1677 mov DWORD PTR 68[esp],ecx
1678 ; First we need to setup the X array
1679 mov eax, DWORD PTR [esi]
1680 mov ecx, DWORD PTR 4[esi]
1681 mov DWORD PTR [esp],eax
1682 mov DWORD PTR 4[esp],ecx
1683 mov eax, DWORD PTR 8[esi]
1684 mov ecx, DWORD PTR 12[esi]
1685 mov DWORD PTR 8[esp],eax
1686 mov DWORD PTR 12[esp],ecx
1687 mov eax, DWORD PTR 16[esi]
1688 mov ecx, DWORD PTR 20[esi]
1689 mov DWORD PTR 16[esp],eax
1690 mov DWORD PTR 20[esp],ecx
1691 mov eax, DWORD PTR 24[esi]
1692 mov ecx, DWORD PTR 28[esi]
1693 mov DWORD PTR 24[esp],eax
1694 mov DWORD PTR 28[esp],ecx
1695 mov eax, DWORD PTR 32[esi]
1696 mov ecx, DWORD PTR 36[esi]
1697 mov DWORD PTR 32[esp],eax
1698 mov DWORD PTR 36[esp],ecx
1699 mov eax, DWORD PTR 40[esi]
1700 mov ecx, DWORD PTR 44[esi]
1701 mov DWORD PTR 40[esp],eax
1702 mov DWORD PTR 44[esp],ecx
1703 mov eax, DWORD PTR 48[esi]
1704 mov ecx, DWORD PTR 52[esi]
1705 mov DWORD PTR 48[esp],eax
1706 mov DWORD PTR 52[esp],ecx
1707 mov eax, DWORD PTR 56[esi]
1708 mov ecx, DWORD PTR 60[esi]
1709 mov DWORD PTR 56[esp],eax
1710 mov DWORD PTR 60[esp],ecx
1711 jmp L001shortcut
1712_sha1_block_asm_host_order ENDP
1713_TEXT ENDS
1714_sha1_block_asm_data_order ENDP
1663_TEXT ENDS 1715_TEXT ENDS
1664END 1716END
diff --git a/src/lib/libcrypto/sha/asm/sha1-586.pl b/src/lib/libcrypto/sha/asm/sha1-586.pl
index 04e42ab09f..48d9192a4e 100644
--- a/src/lib/libcrypto/sha/asm/sha1-586.pl
+++ b/src/lib/libcrypto/sha/asm/sha1-586.pl
@@ -8,8 +8,8 @@ require "x86asm.pl";
8&asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386"); 8&asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386");
9 9
10$A="eax"; 10$A="eax";
11$B="ebx"; 11$B="ecx";
12$C="ecx"; 12$C="ebx";
13$D="edx"; 13$D="edx";
14$E="edi"; 14$E="edi";
15$T="esi"; 15$T="esi";
@@ -19,7 +19,7 @@ $off=9*4;
19 19
20@K=(0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6); 20@K=(0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6);
21 21
22&sha1_block("sha1_block_x86"); 22&sha1_block_data("sha1_block_asm_data_order");
23 23
24&asm_finish(); 24&asm_finish();
25 25
@@ -53,11 +53,14 @@ sub X_expand
53 local($in)=@_; 53 local($in)=@_;
54 54
55 &comment("First, load the words onto the stack in network byte order"); 55 &comment("First, load the words onto the stack in network byte order");
56 for ($i=0; $i<16; $i++) 56 for ($i=0; $i<16; $i+=2)
57 { 57 {
58 &mov("eax",&DWP(($i+0)*4,$in,"",0)) unless $i == 0; 58 &mov($A,&DWP(($i+0)*4,$in,"",0));# unless $i == 0;
59 &bswap("eax"); 59 &mov($B,&DWP(($i+1)*4,$in,"",0));
60 &mov(&swtmp($i+0),"eax"); 60 &bswap($A);
61 &bswap($B);
62 &mov(&swtmp($i+0),$A);
63 &mov(&swtmp($i+1),$B);
61 } 64 }
62 65
63 &comment("We now have the X array on the stack"); 66 &comment("We now have the X array on the stack");
@@ -312,7 +315,7 @@ sub BODY_60_79
312 &BODY_20_39(@_); 315 &BODY_20_39(@_);
313 } 316 }
314 317
315sub sha1_block 318sub sha1_block_host
316 { 319 {
317 local($name)=@_; 320 local($name)=@_;
318 321
@@ -325,35 +328,77 @@ sub sha1_block
325 # D 12 328 # D 12
326 # E 16 329 # E 16
327 330
328 &push("esi"); 331 &mov("ecx", &wparam(2));
329 &push("ebp"); 332 &push("esi");
330 &mov("eax", &wparam(2)); 333 &shl("ecx",6);
331 &mov("esi", &wparam(1)); 334 &mov("esi", &wparam(1));
332 &add("eax", "esi"); # offset to leave on 335 &push("ebp");
336 &add("ecx","esi"); # offset to leave on
337 &push("ebx");
333 &mov("ebp", &wparam(0)); 338 &mov("ebp", &wparam(0));
339 &push("edi");
340 &mov($D, &DWP(12,"ebp","",0));
341 &stack_push(18+9);
342 &mov($E, &DWP(16,"ebp","",0));
343 &mov($C, &DWP( 8,"ebp","",0));
344 &mov(&swtmp(17),"ecx");
345
346 &comment("First we need to setup the X array");
347
348 for ($i=0; $i<16; $i+=2)
349 {
350 &mov($A,&DWP(($i+0)*4,"esi","",0));# unless $i == 0;
351 &mov($B,&DWP(($i+1)*4,"esi","",0));
352 &mov(&swtmp($i+0),$A);
353 &mov(&swtmp($i+1),$B);
354 }
355 &jmp(&label("shortcut"));
356 &function_end_B($name);
357 }
358
359
360sub sha1_block_data
361 {
362 local($name)=@_;
363
364 &function_begin_B($name,"");
365
366 # parameter 1 is the MD5_CTX structure.
367 # A 0
368 # B 4
369 # C 8
370 # D 12
371 # E 16
372
373 &mov("ecx", &wparam(2));
374 &push("esi");
375 &shl("ecx",6);
376 &mov("esi", &wparam(1));
377 &push("ebp");
378 &add("ecx","esi"); # offset to leave on
334 &push("ebx"); 379 &push("ebx");
335 &sub("eax", 64); 380 &mov("ebp", &wparam(0));
336 &push("edi"); 381 &push("edi");
337 &mov($B, &DWP( 4,"ebp","",0));
338 &stack_push(18);
339 &mov($D, &DWP(12,"ebp","",0)); 382 &mov($D, &DWP(12,"ebp","",0));
340 &mov($E, &DWP(16,"ebp","",0)); 383 &stack_push(18+9);
341 &mov($C, &DWP( 8,"ebp","",0)); 384 &mov($E, &DWP(16,"ebp","",0));
342 &mov(&swtmp(17),"eax"); 385 &mov($C, &DWP( 8,"ebp","",0));
386 &mov(&swtmp(17),"ecx");
343 387
344 &comment("First we need to setup the X array"); 388 &comment("First we need to setup the X array");
345 &mov("eax",&DWP(0,"esi","",0)); # pulled out of X_expand
346 389
347 &set_label("start") unless $normal; 390 &set_label("start") unless $normal;
348 391
349 &X_expand("esi"); 392 &X_expand("esi");
350 &mov(&swtmp(16),"esi"); 393 &mov(&wparam(1),"esi");
351 394
395 &set_label("shortcut", 1);
352 &comment(""); 396 &comment("");
353 &comment("Start processing"); 397 &comment("Start processing");
354 398
355 # odd start 399 # odd start
356 &mov($A, &DWP( 0,"ebp","",0)); 400 &mov($A, &DWP( 0,"ebp","",0));
401 &mov($B, &DWP( 4,"ebp","",0));
357 $X="esp"; 402 $X="esp";
358 &BODY_00_15(-2,$K[0],$X, 0,$A,$B,$C,$D,$E,$T); 403 &BODY_00_15(-2,$K[0],$X, 0,$A,$B,$C,$D,$E,$T);
359 &BODY_00_15( 0,$K[0],$X, 1,$T,$A,$B,$C,$D,$E); 404 &BODY_00_15( 0,$K[0],$X, 1,$T,$A,$B,$C,$D,$E);
@@ -468,24 +513,26 @@ sub sha1_block
468 &add($C,$T); 513 &add($C,$T);
469 514
470 &mov(&DWP( 0,$tmp1,"",0),$A); 515 &mov(&DWP( 0,$tmp1,"",0),$A);
471 &mov("esi",&swtmp(16)); 516 &mov("esi",&wparam(1));
472 &mov(&DWP( 8,$tmp1,"",0),$C); # This is for looping 517 &mov(&DWP( 8,$tmp1,"",0),$C);
473 &add("esi",64); 518 &add("esi",64);
474 &mov("eax",&swtmp(17)); 519 &mov("eax",&swtmp(17));
475 &mov(&DWP(16,$tmp1,"",0),$E); 520 &mov(&DWP(16,$tmp1,"",0),$E);
476 &cmp("eax","esi"); 521 &cmp("esi","eax");
477 &mov(&DWP( 4,$tmp1,"",0),$B); # This is for looping 522 &mov(&DWP( 4,$tmp1,"",0),$B);
478 &jl(&label("end")); 523 &jl(&label("start"));
479 &mov("eax",&DWP(0,"esi","",0)); # Pulled down from 524
480 &jmp(&label("start")); 525 &stack_pop(18+9);
481
482 &set_label("end");
483 &stack_pop(18);
484 &pop("edi"); 526 &pop("edi");
485 &pop("ebx"); 527 &pop("ebx");
486 &pop("ebp"); 528 &pop("ebp");
487 &pop("esi"); 529 &pop("esi");
488 &ret(); 530 &ret();
531
532 # it has to reside within sha1_block_asm_host_order body
533 # because it calls &jmp(&label("shortcut"));
534 &sha1_block_host("sha1_block_asm_host_order");
535
489 &function_end_B($name); 536 &function_end_B($name);
490 } 537 }
491 538
diff --git a/src/lib/libcrypto/sha/sha.h b/src/lib/libcrypto/sha/sha.h
index cd6960ee1a..77f6d9695e 100644
--- a/src/lib/libcrypto/sha/sha.h
+++ b/src/lib/libcrypto/sha/sha.h
@@ -63,7 +63,7 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_SHA 66#if defined(NO_SHA) || (defined(NO_SHA0) && defined(NO_SHA1))
67#error SHA is disabled. 67#error SHA is disabled.
68#endif 68#endif
69 69
@@ -100,17 +100,17 @@ typedef struct SHAstate_st
100 100
101#ifndef NO_SHA0 101#ifndef NO_SHA0
102void SHA_Init(SHA_CTX *c); 102void SHA_Init(SHA_CTX *c);
103void SHA_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); 103void SHA_Update(SHA_CTX *c, const void *data, unsigned long len);
104void SHA_Final(unsigned char *md, SHA_CTX *c); 104void SHA_Final(unsigned char *md, SHA_CTX *c);
105unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); 105unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md);
106void SHA_Transform(SHA_CTX *c, unsigned char *data); 106void SHA_Transform(SHA_CTX *c, const unsigned char *data);
107#endif 107#endif
108#ifndef NO_SHA1 108#ifndef NO_SHA1
109void SHA1_Init(SHA_CTX *c); 109void SHA1_Init(SHA_CTX *c);
110void SHA1_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); 110void SHA1_Update(SHA_CTX *c, const void *data, unsigned long len);
111void SHA1_Final(unsigned char *md, SHA_CTX *c); 111void SHA1_Final(unsigned char *md, SHA_CTX *c);
112unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); 112unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md);
113void SHA1_Transform(SHA_CTX *c, unsigned char *data); 113void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
114#endif 114#endif
115#ifdef __cplusplus 115#ifdef __cplusplus
116} 116}
diff --git a/src/lib/libcrypto/sha/sha1dgst.c b/src/lib/libcrypto/sha/sha1dgst.c
index 66e885dd76..c09edb4cd7 100644
--- a/src/lib/libcrypto/sha/sha1dgst.c
+++ b/src/lib/libcrypto/sha/sha1dgst.c
@@ -56,443 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h> 59#if !defined(NO_SHA1) && !defined(NO_SHA)
60#include <string.h> 60
61#undef SHA_0 61#undef SHA_0
62#define SHA_1 62#define SHA_1
63#include <openssl/sha.h>
64#include "sha_locl.h"
65#include <openssl/opensslv.h>
66
67#ifndef NO_SHA1
68char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT;
69
70/* Implemented from SHA-1 document - The Secure Hash Algorithm
71 */
72
73#define INIT_DATA_h0 0x67452301UL
74#define INIT_DATA_h1 0xefcdab89UL
75#define INIT_DATA_h2 0x98badcfeUL
76#define INIT_DATA_h3 0x10325476UL
77#define INIT_DATA_h4 0xc3d2e1f0UL
78
79#define K_00_19 0x5a827999UL
80#define K_20_39 0x6ed9eba1UL
81#define K_40_59 0x8f1bbcdcUL
82#define K_60_79 0xca62c1d6UL
83
84#ifdef SHA1_ASM
85 void sha1_block_x86(SHA_CTX *c, register SHA_LONG *p, int num);
86# define sha1_block(c,p,n) sha1_block_x86((c),(p),(n)*SHA_CBLOCK)
87#else
88 static void sha1_block(SHA_CTX *c, register SHA_LONG *p, int num);
89#endif
90
91#if !defined(B_ENDIAN) && defined(SHA1_ASM)
92# define M_c2nl c2l
93# define M_p_c2nl p_c2l
94# define M_c2nl_p c2l_p
95# define M_p_c2nl_p p_c2l_p
96# define M_nl2c l2c
97#else
98# define M_c2nl c2nl
99# define M_p_c2nl p_c2nl
100# define M_c2nl_p c2nl_p
101# define M_p_c2nl_p p_c2nl_p
102# define M_nl2c nl2c
103#endif
104
105void SHA1_Init(SHA_CTX *c)
106 {
107 c->h0=INIT_DATA_h0;
108 c->h1=INIT_DATA_h1;
109 c->h2=INIT_DATA_h2;
110 c->h3=INIT_DATA_h3;
111 c->h4=INIT_DATA_h4;
112 c->Nl=0;
113 c->Nh=0;
114 c->num=0;
115 }
116
117void SHA1_Update(SHA_CTX *c, register const unsigned char *data,
118 unsigned long len)
119 {
120 register SHA_LONG *p;
121 int ew,ec,sw,sc;
122 SHA_LONG l;
123
124 if (len == 0) return;
125
126 l=(c->Nl+(len<<3))&0xffffffffL;
127 if (l < c->Nl) /* overflow */
128 c->Nh++;
129 c->Nh+=(len>>29);
130 c->Nl=l;
131
132 if (c->num != 0)
133 {
134 p=c->data;
135 sw=c->num>>2;
136 sc=c->num&0x03;
137
138 if ((c->num+len) >= SHA_CBLOCK)
139 {
140 l= p[sw];
141 M_p_c2nl(data,l,sc);
142 p[sw++]=l;
143 for (; sw<SHA_LBLOCK; sw++)
144 {
145 M_c2nl(data,l);
146 p[sw]=l;
147 }
148 len-=(SHA_CBLOCK-c->num);
149
150 sha1_block(c,p,1);
151 c->num=0;
152 /* drop through and do the rest */
153 }
154 else
155 {
156 c->num+=(int)len;
157 if ((sc+len) < 4) /* ugly, add char's to a word */
158 {
159 l= p[sw];
160 M_p_c2nl_p(data,l,sc,len);
161 p[sw]=l;
162 }
163 else
164 {
165 ew=(c->num>>2);
166 ec=(c->num&0x03);
167 l= p[sw];
168 M_p_c2nl(data,l,sc);
169 p[sw++]=l;
170 for (; sw < ew; sw++)
171 { M_c2nl(data,l); p[sw]=l; }
172 if (ec)
173 {
174 M_c2nl_p(data,l,ec);
175 p[sw]=l;
176 }
177 }
178 return;
179 }
180 }
181 /* We can only do the following code for assember, the reason
182 * being that the sha1_block 'C' version changes the values
183 * in the 'data' array. The assember code avoids this and
184 * copies it to a local array. I should be able to do this for
185 * the C version as well....
186 */
187#if SHA_LONG_LOG2==2
188#if defined(B_ENDIAN) || defined(SHA1_ASM)
189 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
190 {
191 sw=len/SHA_CBLOCK;
192 if (sw)
193 {
194 sha1_block(c,(SHA_LONG *)data,sw);
195 sw*=SHA_CBLOCK;
196 data+=sw;
197 len-=sw;
198 }
199 }
200#endif
201#endif
202 /* we now can process the input data in blocks of SHA_CBLOCK
203 * chars and save the leftovers to c->data. */
204 p=c->data;
205 while (len >= SHA_CBLOCK)
206 {
207#if SHA_LONG_LOG2==2
208#if defined(B_ENDIAN) || defined(SHA1_ASM)
209#define SHA_NO_TAIL_CODE
210 /*
211 * Basically we get here only when data happens
212 * to be unaligned.
213 */
214 if (p != (SHA_LONG *)data)
215 memcpy(p,data,SHA_CBLOCK);
216 data+=SHA_CBLOCK;
217 sha1_block(c,p=c->data,1);
218 len-=SHA_CBLOCK;
219#elif defined(L_ENDIAN)
220#define BE_COPY(dst,src,i) { \
221 l = ((SHA_LONG *)src)[i]; \
222 Endian_Reverse32(l); \
223 dst[i] = l; \
224 }
225 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
226 {
227 for (sw=(SHA_LBLOCK/4); sw; sw--)
228 {
229 BE_COPY(p,data,0);
230 BE_COPY(p,data,1);
231 BE_COPY(p,data,2);
232 BE_COPY(p,data,3);
233 p+=4;
234 data += 4*sizeof(SHA_LONG);
235 }
236 sha1_block(c,p=c->data,1);
237 len-=SHA_CBLOCK;
238 continue;
239 }
240#endif
241#endif
242#ifndef SHA_NO_TAIL_CODE
243 /*
244 * In addition to "sizeof(SHA_LONG)!= 4" case the
245 * following code covers unaligned access cases on
246 * little-endian machines.
247 * <appro@fy.chalmers.se>
248 */
249 p=c->data;
250 for (sw=(SHA_LBLOCK/4); sw; sw--)
251 {
252 M_c2nl(data,l); p[0]=l;
253 M_c2nl(data,l); p[1]=l;
254 M_c2nl(data,l); p[2]=l;
255 M_c2nl(data,l); p[3]=l;
256 p+=4;
257 }
258 p=c->data;
259 sha1_block(c,p,1);
260 len-=SHA_CBLOCK;
261#endif
262 }
263 ec=(int)len;
264 c->num=ec;
265 ew=(ec>>2);
266 ec&=0x03;
267
268 for (sw=0; sw < ew; sw++)
269 { M_c2nl(data,l); p[sw]=l; }
270 M_c2nl_p(data,l,ec);
271 p[sw]=l;
272 }
273
274void SHA1_Transform(SHA_CTX *c, unsigned char *b)
275 {
276 SHA_LONG p[SHA_LBLOCK];
277
278#if SHA_LONG_LOG2==2
279#if defined(B_ENDIAN) || defined(SHA1_ASM)
280 memcpy(p,b,SHA_CBLOCK);
281 sha1_block(c,p,1);
282 return;
283#elif defined(L_ENDIAN)
284 if (((unsigned long)b%sizeof(SHA_LONG)) == 0)
285 {
286 SHA_LONG *q;
287 int i;
288
289 q=p;
290 for (i=(SHA_LBLOCK/4); i; i--)
291 {
292 unsigned long l;
293 BE_COPY(q,b,0); /* BE_COPY was defined above */
294 BE_COPY(q,b,1);
295 BE_COPY(q,b,2);
296 BE_COPY(q,b,3);
297 q+=4;
298 b+=4*sizeof(SHA_LONG);
299 }
300 sha1_block(c,p,1);
301 return;
302 }
303#endif
304#endif
305#ifndef SHA_NO_TAIL_CODE /* defined above, see comment */
306 {
307 SHA_LONG *q;
308 int i;
309
310 q=p;
311 for (i=(SHA_LBLOCK/4); i; i--)
312 {
313 SHA_LONG l;
314 c2nl(b,l); *(q++)=l;
315 c2nl(b,l); *(q++)=l;
316 c2nl(b,l); *(q++)=l;
317 c2nl(b,l); *(q++)=l;
318 }
319 sha1_block(c,p,1);
320 }
321#endif
322 }
323
324#ifndef SHA1_ASM
325static void sha1_block(SHA_CTX *c, register SHA_LONG *W, int num)
326 {
327 register SHA_LONG A,B,C,D,E,T;
328 SHA_LONG X[SHA_LBLOCK];
329
330 A=c->h0;
331 B=c->h1;
332 C=c->h2;
333 D=c->h3;
334 E=c->h4;
335 63
336 for (;;) 64#include <openssl/opensslv.h>
337 {
338 BODY_00_15( 0,A,B,C,D,E,T,W);
339 BODY_00_15( 1,T,A,B,C,D,E,W);
340 BODY_00_15( 2,E,T,A,B,C,D,W);
341 BODY_00_15( 3,D,E,T,A,B,C,W);
342 BODY_00_15( 4,C,D,E,T,A,B,W);
343 BODY_00_15( 5,B,C,D,E,T,A,W);
344 BODY_00_15( 6,A,B,C,D,E,T,W);
345 BODY_00_15( 7,T,A,B,C,D,E,W);
346 BODY_00_15( 8,E,T,A,B,C,D,W);
347 BODY_00_15( 9,D,E,T,A,B,C,W);
348 BODY_00_15(10,C,D,E,T,A,B,W);
349 BODY_00_15(11,B,C,D,E,T,A,W);
350 BODY_00_15(12,A,B,C,D,E,T,W);
351 BODY_00_15(13,T,A,B,C,D,E,W);
352 BODY_00_15(14,E,T,A,B,C,D,W);
353 BODY_00_15(15,D,E,T,A,B,C,W);
354 BODY_16_19(16,C,D,E,T,A,B,W,W,W,W);
355 BODY_16_19(17,B,C,D,E,T,A,W,W,W,W);
356 BODY_16_19(18,A,B,C,D,E,T,W,W,W,W);
357 BODY_16_19(19,T,A,B,C,D,E,W,W,W,X);
358
359 BODY_20_31(20,E,T,A,B,C,D,W,W,W,X);
360 BODY_20_31(21,D,E,T,A,B,C,W,W,W,X);
361 BODY_20_31(22,C,D,E,T,A,B,W,W,W,X);
362 BODY_20_31(23,B,C,D,E,T,A,W,W,W,X);
363 BODY_20_31(24,A,B,C,D,E,T,W,W,X,X);
364 BODY_20_31(25,T,A,B,C,D,E,W,W,X,X);
365 BODY_20_31(26,E,T,A,B,C,D,W,W,X,X);
366 BODY_20_31(27,D,E,T,A,B,C,W,W,X,X);
367 BODY_20_31(28,C,D,E,T,A,B,W,W,X,X);
368 BODY_20_31(29,B,C,D,E,T,A,W,W,X,X);
369 BODY_20_31(30,A,B,C,D,E,T,W,X,X,X);
370 BODY_20_31(31,T,A,B,C,D,E,W,X,X,X);
371 BODY_32_39(32,E,T,A,B,C,D,X);
372 BODY_32_39(33,D,E,T,A,B,C,X);
373 BODY_32_39(34,C,D,E,T,A,B,X);
374 BODY_32_39(35,B,C,D,E,T,A,X);
375 BODY_32_39(36,A,B,C,D,E,T,X);
376 BODY_32_39(37,T,A,B,C,D,E,X);
377 BODY_32_39(38,E,T,A,B,C,D,X);
378 BODY_32_39(39,D,E,T,A,B,C,X);
379
380 BODY_40_59(40,C,D,E,T,A,B,X);
381 BODY_40_59(41,B,C,D,E,T,A,X);
382 BODY_40_59(42,A,B,C,D,E,T,X);
383 BODY_40_59(43,T,A,B,C,D,E,X);
384 BODY_40_59(44,E,T,A,B,C,D,X);
385 BODY_40_59(45,D,E,T,A,B,C,X);
386 BODY_40_59(46,C,D,E,T,A,B,X);
387 BODY_40_59(47,B,C,D,E,T,A,X);
388 BODY_40_59(48,A,B,C,D,E,T,X);
389 BODY_40_59(49,T,A,B,C,D,E,X);
390 BODY_40_59(50,E,T,A,B,C,D,X);
391 BODY_40_59(51,D,E,T,A,B,C,X);
392 BODY_40_59(52,C,D,E,T,A,B,X);
393 BODY_40_59(53,B,C,D,E,T,A,X);
394 BODY_40_59(54,A,B,C,D,E,T,X);
395 BODY_40_59(55,T,A,B,C,D,E,X);
396 BODY_40_59(56,E,T,A,B,C,D,X);
397 BODY_40_59(57,D,E,T,A,B,C,X);
398 BODY_40_59(58,C,D,E,T,A,B,X);
399 BODY_40_59(59,B,C,D,E,T,A,X);
400
401 BODY_60_79(60,A,B,C,D,E,T,X);
402 BODY_60_79(61,T,A,B,C,D,E,X);
403 BODY_60_79(62,E,T,A,B,C,D,X);
404 BODY_60_79(63,D,E,T,A,B,C,X);
405 BODY_60_79(64,C,D,E,T,A,B,X);
406 BODY_60_79(65,B,C,D,E,T,A,X);
407 BODY_60_79(66,A,B,C,D,E,T,X);
408 BODY_60_79(67,T,A,B,C,D,E,X);
409 BODY_60_79(68,E,T,A,B,C,D,X);
410 BODY_60_79(69,D,E,T,A,B,C,X);
411 BODY_60_79(70,C,D,E,T,A,B,X);
412 BODY_60_79(71,B,C,D,E,T,A,X);
413 BODY_60_79(72,A,B,C,D,E,T,X);
414 BODY_60_79(73,T,A,B,C,D,E,X);
415 BODY_60_79(74,E,T,A,B,C,D,X);
416 BODY_60_79(75,D,E,T,A,B,C,X);
417 BODY_60_79(76,C,D,E,T,A,B,X);
418 BODY_60_79(77,B,C,D,E,T,A,X);
419 BODY_60_79(78,A,B,C,D,E,T,X);
420 BODY_60_79(79,T,A,B,C,D,E,X);
421
422 c->h0=(c->h0+E)&0xffffffffL;
423 c->h1=(c->h1+T)&0xffffffffL;
424 c->h2=(c->h2+A)&0xffffffffL;
425 c->h3=(c->h3+B)&0xffffffffL;
426 c->h4=(c->h4+C)&0xffffffffL;
427
428 if (--num <= 0) break;
429 65
430 A=c->h0; 66const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT;
431 B=c->h1;
432 C=c->h2;
433 D=c->h3;
434 E=c->h4;
435 67
436 W+=SHA_LBLOCK; /* Note! This can happen only when sizeof(SHA_LONG) 68/* The implementation is in ../md32_common.h */
437 * is 4. Whenever it's not the actual case this
438 * function is never called with num larger than 1
439 * and we never advance down here.
440 * <appro@fy.chalmers.se>
441 */
442 }
443 }
444#endif
445 69
446void SHA1_Final(unsigned char *md, SHA_CTX *c) 70#include "sha_locl.h"
447 {
448 register int i,j;
449 register SHA_LONG l;
450 register SHA_LONG *p;
451 static unsigned char end[4]={0x80,0x00,0x00,0x00};
452 unsigned char *cp=end;
453
454 /* c->num should definitly have room for at least one more byte. */
455 p=c->data;
456 j=c->num;
457 i=j>>2;
458#ifdef PURIFY
459 if ((j&0x03) == 0) p[i]=0;
460#endif
461 l=p[i];
462 M_p_c2nl(cp,l,j&0x03);
463 p[i]=l;
464 i++;
465 /* i is the next 'undefined word' */
466 if (c->num >= SHA_LAST_BLOCK)
467 {
468 for (; i<SHA_LBLOCK; i++)
469 p[i]=0;
470 sha1_block(c,p,1);
471 i=0;
472 }
473 for (; i<(SHA_LBLOCK-2); i++)
474 p[i]=0;
475 p[SHA_LBLOCK-2]=c->Nh;
476 p[SHA_LBLOCK-1]=c->Nl;
477#if SHA_LONG_LOG2==2
478#if !defined(B_ENDIAN) && defined(SHA1_ASM)
479 Endian_Reverse32(p[SHA_LBLOCK-2]);
480 Endian_Reverse32(p[SHA_LBLOCK-1]);
481#endif
482#endif
483 sha1_block(c,p,1);
484 cp=md;
485 l=c->h0; nl2c(l,cp);
486 l=c->h1; nl2c(l,cp);
487 l=c->h2; nl2c(l,cp);
488 l=c->h3; nl2c(l,cp);
489 l=c->h4; nl2c(l,cp);
490 71
491 c->num=0;
492 /* sha_block may be leaving some stuff on the stack
493 * but I'm not worried :-)
494 memset((void *)c,0,sizeof(SHA_CTX));
495 */
496 }
497#endif 72#endif
498 73
diff --git a/src/lib/libcrypto/sha/sha1s.cpp b/src/lib/libcrypto/sha/sha1s.cpp
index 3103e1871b..af23d1e0f2 100644
--- a/src/lib/libcrypto/sha/sha1s.cpp
+++ b/src/lib/libcrypto/sha/sha1s.cpp
@@ -34,6 +34,7 @@ void GetTSC(unsigned long& tsc)
34#include <stdlib.h> 34#include <stdlib.h>
35#include <openssl/sha.h> 35#include <openssl/sha.h>
36 36
37#define sha1_block_x86 sha1_block_asm_data_order
37extern "C" { 38extern "C" {
38void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num); 39void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num);
39} 40}
@@ -55,8 +56,10 @@ void main(int argc,char *argv[])
55 if (num == 0) num=16; 56 if (num == 0) num=16;
56 if (num > 250) num=16; 57 if (num > 250) num=16;
57 numm=num+2; 58 numm=num+2;
59#if 0
58 num*=64; 60 num*=64;
59 numm*=64; 61 numm*=64;
62#endif
60 63
61 for (j=0; j<6; j++) 64 for (j=0; j<6; j++)
62 { 65 {
@@ -72,7 +75,7 @@ void main(int argc,char *argv[])
72 sha1_block_x86(&ctx,buffer,num); 75 sha1_block_x86(&ctx,buffer,num);
73 } 76 }
74 77
75 printf("sha1 (%d bytes) %d %d (%.2f)\n",num, 78 printf("sha1 (%d bytes) %d %d (%.2f)\n",num*64,
76 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
77 } 80 }
78 } 81 }
diff --git a/src/lib/libcrypto/sha/sha1test.c b/src/lib/libcrypto/sha/sha1test.c
index 9400ad2a61..688d06c637 100644
--- a/src/lib/libcrypto/sha/sha1test.c
+++ b/src/lib/libcrypto/sha/sha1test.c
@@ -76,26 +76,26 @@ int main(int argc, char *argv[])
76#undef SHA_0 /* FIPS 180 */ 76#undef SHA_0 /* FIPS 180 */
77#define SHA_1 /* FIPS 180-1 */ 77#define SHA_1 /* FIPS 180-1 */
78 78
79char *test[]={ 79static char *test[]={
80 "abc", 80 "abc",
81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
82 NULL, 82 NULL,
83 }; 83 };
84 84
85#ifdef SHA_0 85#ifdef SHA_0
86char *ret[]={ 86static char *ret[]={
87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", 87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8", 88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
89 }; 89 };
90char *bigret= 90static char *bigret=
91 "3232affa48628a26653b5aaa44541fd90d690603"; 91 "3232affa48628a26653b5aaa44541fd90d690603";
92#endif 92#endif
93#ifdef SHA_1 93#ifdef SHA_1
94char *ret[]={ 94static char *ret[]={
95 "a9993e364706816aba3e25717850c26c9cd0d89d", 95 "a9993e364706816aba3e25717850c26c9cd0d89d",
96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1", 96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
97 }; 97 };
98char *bigret= 98static char *bigret=
99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; 99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
100#endif 100#endif
101 101
diff --git a/src/lib/libcrypto/sha/sha_dgst.c b/src/lib/libcrypto/sha/sha_dgst.c
index 4df535360f..894a96274a 100644
--- a/src/lib/libcrypto/sha/sha_dgst.c
+++ b/src/lib/libcrypto/sha/sha_dgst.c
@@ -1,4 +1,4 @@
1/* crypto/sha/sha_dgst.c */ 1/* crypto/sha/sha1dgst.c */
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 *
@@ -56,437 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h> 59#if !defined(NO_SHA0) && !defined(NO_SHA)
60#include <string.h>
61#define SHA_0
62#undef SHA_1
63#include <openssl/sha.h>
64#include "sha_locl.h"
65#include <openssl/opensslv.h>
66
67#ifndef NO_SHA0
68char *SHA_version="SHA" OPENSSL_VERSION_PTEXT;
69
70/* Implemented from SHA-0 document - The Secure Hash Algorithm
71 */
72
73#define INIT_DATA_h0 0x67452301UL
74#define INIT_DATA_h1 0xefcdab89UL
75#define INIT_DATA_h2 0x98badcfeUL
76#define INIT_DATA_h3 0x10325476UL
77#define INIT_DATA_h4 0xc3d2e1f0UL
78
79#define K_00_19 0x5a827999UL
80#define K_20_39 0x6ed9eba1UL
81#define K_40_59 0x8f1bbcdcUL
82#define K_60_79 0xca62c1d6UL
83
84static void sha_block(SHA_CTX *c, register SHA_LONG *p, int num);
85
86#if !defined(B_ENDIAN) && defined(SHA_ASM)
87# define M_c2nl c2l
88# define M_p_c2nl p_c2l
89# define M_c2nl_p c2l_p
90# define M_p_c2nl_p p_c2l_p
91# define M_nl2c l2c
92#else
93# define M_c2nl c2nl
94# define M_p_c2nl p_c2nl
95# define M_c2nl_p c2nl_p
96# define M_p_c2nl_p p_c2nl_p
97# define M_nl2c nl2c
98#endif
99
100void SHA_Init(SHA_CTX *c)
101 {
102 c->h0=INIT_DATA_h0;
103 c->h1=INIT_DATA_h1;
104 c->h2=INIT_DATA_h2;
105 c->h3=INIT_DATA_h3;
106 c->h4=INIT_DATA_h4;
107 c->Nl=0;
108 c->Nh=0;
109 c->num=0;
110 }
111 60
112void SHA_Update(SHA_CTX *c, register const unsigned char *data, 61#undef SHA_1
113 unsigned long len) 62#define SHA_0
114 {
115 register SHA_LONG *p;
116 int ew,ec,sw,sc;
117 SHA_LONG l;
118
119 if (len == 0) return;
120
121 l=(c->Nl+(len<<3))&0xffffffffL;
122 if (l < c->Nl) /* overflow */
123 c->Nh++;
124 c->Nh+=(len>>29);
125 c->Nl=l;
126
127 if (c->num != 0)
128 {
129 p=c->data;
130 sw=c->num>>2;
131 sc=c->num&0x03;
132
133 if ((c->num+len) >= SHA_CBLOCK)
134 {
135 l= p[sw];
136 M_p_c2nl(data,l,sc);
137 p[sw++]=l;
138 for (; sw<SHA_LBLOCK; sw++)
139 {
140 M_c2nl(data,l);
141 p[sw]=l;
142 }
143 len-=(SHA_CBLOCK-c->num);
144
145 sha_block(c,p,1);
146 c->num=0;
147 /* drop through and do the rest */
148 }
149 else
150 {
151 c->num+=(int)len;
152 if ((sc+len) < 4) /* ugly, add char's to a word */
153 {
154 l= p[sw];
155 M_p_c2nl_p(data,l,sc,len);
156 p[sw]=l;
157 }
158 else
159 {
160 ew=(c->num>>2);
161 ec=(c->num&0x03);
162 l= p[sw];
163 M_p_c2nl(data,l,sc);
164 p[sw++]=l;
165 for (; sw < ew; sw++)
166 { M_c2nl(data,l); p[sw]=l; }
167 if (ec)
168 {
169 M_c2nl_p(data,l,ec);
170 p[sw]=l;
171 }
172 }
173 return;
174 }
175 }
176 /* We can only do the following code for assember, the reason
177 * being that the sha_block 'C' version changes the values
178 * in the 'data' array. The assember code avoids this and
179 * copies it to a local array. I should be able to do this for
180 * the C version as well....
181 */
182#if SHA_LONG_LOG2==2
183#if defined(B_ENDIAN) || defined(SHA_ASM)
184 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
185 {
186 sw=len/SHA_CBLOCK;
187 if (sw)
188 {
189 sha_block(c,(SHA_LONG *)data,sw);
190 sw*=SHA_CBLOCK;
191 data+=sw;
192 len-=sw;
193 }
194 }
195#endif
196#endif
197 /* we now can process the input data in blocks of SHA_CBLOCK
198 * chars and save the leftovers to c->data. */
199 p=c->data;
200 while (len >= SHA_CBLOCK)
201 {
202#if SHA_LONG_LOG2==2
203#if defined(B_ENDIAN) || defined(SHA_ASM)
204#define SHA_NO_TAIL_CODE
205 /*
206 * Basically we get here only when data happens
207 * to be unaligned.
208 */
209 if (p != (SHA_LONG *)data)
210 memcpy(p,data,SHA_CBLOCK);
211 data+=SHA_CBLOCK;
212 sha_block(c,p=c->data,1);
213 len-=SHA_CBLOCK;
214#elif defined(L_ENDIAN)
215#define BE_COPY(dst,src,i) { \
216 l = ((SHA_LONG *)src)[i]; \
217 Endian_Reverse32(l); \
218 dst[i] = l; \
219 }
220 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
221 {
222 for (sw=(SHA_LBLOCK/4); sw; sw--)
223 {
224 BE_COPY(p,data,0);
225 BE_COPY(p,data,1);
226 BE_COPY(p,data,2);
227 BE_COPY(p,data,3);
228 p+=4;
229 data += 4*sizeof(SHA_LONG);
230 }
231 sha_block(c,p=c->data,1);
232 len-=SHA_CBLOCK;
233 continue;
234 }
235#endif
236#endif
237#ifndef SHA_NO_TAIL_CODE
238 /*
239 * In addition to "sizeof(SHA_LONG)!= 4" case the
240 * following code covers unaligned access cases on
241 * little-endian machines.
242 * <appro@fy.chalmers.se>
243 */
244 p=c->data;
245 for (sw=(SHA_LBLOCK/4); sw; sw--)
246 {
247 M_c2nl(data,l); p[0]=l;
248 M_c2nl(data,l); p[1]=l;
249 M_c2nl(data,l); p[2]=l;
250 M_c2nl(data,l); p[3]=l;
251 p+=4;
252 }
253 p=c->data;
254 sha_block(c,p,1);
255 len-=SHA_CBLOCK;
256#endif
257 }
258 ec=(int)len;
259 c->num=ec;
260 ew=(ec>>2);
261 ec&=0x03;
262 63
263 for (sw=0; sw < ew; sw++) 64#include <openssl/opensslv.h>
264 { M_c2nl(data,l); p[sw]=l; }
265 M_c2nl_p(data,l,ec);
266 p[sw]=l;
267 }
268
269void SHA_Transform(SHA_CTX *c, unsigned char *b)
270 {
271 SHA_LONG p[SHA_LBLOCK];
272
273#if SHA_LONG_LOG2==2
274#if defined(B_ENDIAN) || defined(SHA_ASM)
275 memcpy(p,b,SHA_CBLOCK);
276 sha_block(c,p,1);
277 return;
278#elif defined(L_ENDIAN)
279 if (((unsigned long)b%sizeof(SHA_LONG)) == 0)
280 {
281 SHA_LONG *q;
282 int i;
283
284 q=p;
285 for (i=(SHA_LBLOCK/4); i; i--)
286 {
287 unsigned long l;
288 BE_COPY(q,b,0); /* BE_COPY was defined above */
289 BE_COPY(q,b,1);
290 BE_COPY(q,b,2);
291 BE_COPY(q,b,3);
292 q+=4;
293 b+=4*sizeof(SHA_LONG);
294 }
295 sha_block(c,p,1);
296 return;
297 }
298#endif
299#endif
300#ifndef SHA_NO_TAIL_CODE /* defined above, see comment */
301 {
302 SHA_LONG *q;
303 int i;
304
305 q=p;
306 for (i=(SHA_LBLOCK/4); i; i--)
307 {
308 SHA_LONG l;
309 c2nl(b,l); *(q++)=l;
310 c2nl(b,l); *(q++)=l;
311 c2nl(b,l); *(q++)=l;
312 c2nl(b,l); *(q++)=l;
313 }
314 sha_block(c,p,1);
315 }
316#endif
317 }
318
319#ifndef SHA_ASM
320static void sha_block(SHA_CTX *c, register SHA_LONG *W, int num)
321 {
322 register SHA_LONG A,B,C,D,E,T;
323 SHA_LONG X[SHA_LBLOCK];
324
325 A=c->h0;
326 B=c->h1;
327 C=c->h2;
328 D=c->h3;
329 E=c->h4;
330
331 for (;;)
332 {
333 BODY_00_15( 0,A,B,C,D,E,T,W);
334 BODY_00_15( 1,T,A,B,C,D,E,W);
335 BODY_00_15( 2,E,T,A,B,C,D,W);
336 BODY_00_15( 3,D,E,T,A,B,C,W);
337 BODY_00_15( 4,C,D,E,T,A,B,W);
338 BODY_00_15( 5,B,C,D,E,T,A,W);
339 BODY_00_15( 6,A,B,C,D,E,T,W);
340 BODY_00_15( 7,T,A,B,C,D,E,W);
341 BODY_00_15( 8,E,T,A,B,C,D,W);
342 BODY_00_15( 9,D,E,T,A,B,C,W);
343 BODY_00_15(10,C,D,E,T,A,B,W);
344 BODY_00_15(11,B,C,D,E,T,A,W);
345 BODY_00_15(12,A,B,C,D,E,T,W);
346 BODY_00_15(13,T,A,B,C,D,E,W);
347 BODY_00_15(14,E,T,A,B,C,D,W);
348 BODY_00_15(15,D,E,T,A,B,C,W);
349 BODY_16_19(16,C,D,E,T,A,B,W,W,W,W);
350 BODY_16_19(17,B,C,D,E,T,A,W,W,W,W);
351 BODY_16_19(18,A,B,C,D,E,T,W,W,W,W);
352 BODY_16_19(19,T,A,B,C,D,E,W,W,W,X);
353
354 BODY_20_31(20,E,T,A,B,C,D,W,W,W,X);
355 BODY_20_31(21,D,E,T,A,B,C,W,W,W,X);
356 BODY_20_31(22,C,D,E,T,A,B,W,W,W,X);
357 BODY_20_31(23,B,C,D,E,T,A,W,W,W,X);
358 BODY_20_31(24,A,B,C,D,E,T,W,W,X,X);
359 BODY_20_31(25,T,A,B,C,D,E,W,W,X,X);
360 BODY_20_31(26,E,T,A,B,C,D,W,W,X,X);
361 BODY_20_31(27,D,E,T,A,B,C,W,W,X,X);
362 BODY_20_31(28,C,D,E,T,A,B,W,W,X,X);
363 BODY_20_31(29,B,C,D,E,T,A,W,W,X,X);
364 BODY_20_31(30,A,B,C,D,E,T,W,X,X,X);
365 BODY_20_31(31,T,A,B,C,D,E,W,X,X,X);
366 BODY_32_39(32,E,T,A,B,C,D,X);
367 BODY_32_39(33,D,E,T,A,B,C,X);
368 BODY_32_39(34,C,D,E,T,A,B,X);
369 BODY_32_39(35,B,C,D,E,T,A,X);
370 BODY_32_39(36,A,B,C,D,E,T,X);
371 BODY_32_39(37,T,A,B,C,D,E,X);
372 BODY_32_39(38,E,T,A,B,C,D,X);
373 BODY_32_39(39,D,E,T,A,B,C,X);
374
375 BODY_40_59(40,C,D,E,T,A,B,X);
376 BODY_40_59(41,B,C,D,E,T,A,X);
377 BODY_40_59(42,A,B,C,D,E,T,X);
378 BODY_40_59(43,T,A,B,C,D,E,X);
379 BODY_40_59(44,E,T,A,B,C,D,X);
380 BODY_40_59(45,D,E,T,A,B,C,X);
381 BODY_40_59(46,C,D,E,T,A,B,X);
382 BODY_40_59(47,B,C,D,E,T,A,X);
383 BODY_40_59(48,A,B,C,D,E,T,X);
384 BODY_40_59(49,T,A,B,C,D,E,X);
385 BODY_40_59(50,E,T,A,B,C,D,X);
386 BODY_40_59(51,D,E,T,A,B,C,X);
387 BODY_40_59(52,C,D,E,T,A,B,X);
388 BODY_40_59(53,B,C,D,E,T,A,X);
389 BODY_40_59(54,A,B,C,D,E,T,X);
390 BODY_40_59(55,T,A,B,C,D,E,X);
391 BODY_40_59(56,E,T,A,B,C,D,X);
392 BODY_40_59(57,D,E,T,A,B,C,X);
393 BODY_40_59(58,C,D,E,T,A,B,X);
394 BODY_40_59(59,B,C,D,E,T,A,X);
395
396 BODY_60_79(60,A,B,C,D,E,T,X);
397 BODY_60_79(61,T,A,B,C,D,E,X);
398 BODY_60_79(62,E,T,A,B,C,D,X);
399 BODY_60_79(63,D,E,T,A,B,C,X);
400 BODY_60_79(64,C,D,E,T,A,B,X);
401 BODY_60_79(65,B,C,D,E,T,A,X);
402 BODY_60_79(66,A,B,C,D,E,T,X);
403 BODY_60_79(67,T,A,B,C,D,E,X);
404 BODY_60_79(68,E,T,A,B,C,D,X);
405 BODY_60_79(69,D,E,T,A,B,C,X);
406 BODY_60_79(70,C,D,E,T,A,B,X);
407 BODY_60_79(71,B,C,D,E,T,A,X);
408 BODY_60_79(72,A,B,C,D,E,T,X);
409 BODY_60_79(73,T,A,B,C,D,E,X);
410 BODY_60_79(74,E,T,A,B,C,D,X);
411 BODY_60_79(75,D,E,T,A,B,C,X);
412 BODY_60_79(76,C,D,E,T,A,B,X);
413 BODY_60_79(77,B,C,D,E,T,A,X);
414 BODY_60_79(78,A,B,C,D,E,T,X);
415 BODY_60_79(79,T,A,B,C,D,E,X);
416
417 c->h0=(c->h0+E)&0xffffffffL;
418 c->h1=(c->h1+T)&0xffffffffL;
419 c->h2=(c->h2+A)&0xffffffffL;
420 c->h3=(c->h3+B)&0xffffffffL;
421 c->h4=(c->h4+C)&0xffffffffL;
422
423 if (--num <= 0) break;
424 65
425 A=c->h0; 66const char *SHA_version="SHA" OPENSSL_VERSION_PTEXT;
426 B=c->h1;
427 C=c->h2;
428 D=c->h3;
429 E=c->h4;
430 67
431 W+=SHA_LBLOCK; /* Note! This can happen only when sizeof(SHA_LONG) 68/* The implementation is in ../md32_common.h */
432 * is 4. Whenever it's not the actual case this
433 * function is never called with num larger than 1
434 * and we never advance down here.
435 * <appro@fy.chalmers.se>
436 */
437 }
438 }
439#endif
440 69
441void SHA_Final(unsigned char *md, SHA_CTX *c) 70#include "sha_locl.h"
442 {
443 register int i,j;
444 register SHA_LONG l;
445 register SHA_LONG *p;
446 static unsigned char end[4]={0x80,0x00,0x00,0x00};
447 unsigned char *cp=end;
448 71
449 /* c->num should definitly have room for at least one more byte. */
450 p=c->data;
451 j=c->num;
452 i=j>>2;
453#ifdef PURIFY
454 if ((j&0x03) == 0) p[i]=0;
455#endif
456 l=p[i];
457 M_p_c2nl(cp,l,j&0x03);
458 p[i]=l;
459 i++;
460 /* i is the next 'undefined word' */
461 if (c->num >= SHA_LAST_BLOCK)
462 {
463 for (; i<SHA_LBLOCK; i++)
464 p[i]=0;
465 sha_block(c,p,1);
466 i=0;
467 }
468 for (; i<(SHA_LBLOCK-2); i++)
469 p[i]=0;
470 p[SHA_LBLOCK-2]=c->Nh;
471 p[SHA_LBLOCK-1]=c->Nl;
472#if SHA_LONG_LOG2==2
473#if !defined(B_ENDIAN) && defined(SHA_ASM)
474 Endian_Reverse32(p[SHA_LBLOCK-2]);
475 Endian_Reverse32(p[SHA_LBLOCK-1]);
476#endif 72#endif
477#endif
478 sha_block(c,p,1);
479 cp=md;
480 l=c->h0; nl2c(l,cp);
481 l=c->h1; nl2c(l,cp);
482 l=c->h2; nl2c(l,cp);
483 l=c->h3; nl2c(l,cp);
484 l=c->h4; nl2c(l,cp);
485 73
486 c->num=0;
487 /* sha_block may be leaving some stuff on the stack
488 * but I'm not worried :-)
489 memset((void *)c,0,sizeof(SHA_CTX));
490 */
491 }
492#endif
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index 6646a8915b..3e6f489b87 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -60,180 +60,105 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63#include <openssl/sha.h>
64#ifdef undef
65/* one or the other needs to be defined */
66#ifndef SHA_1 /* FIPE 180-1 */
67#define SHA_0 /* FIPS 180 */
68#endif
69#endif
70
71#undef c2nl
72#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
73 l|=(((unsigned long)(*((c)++)))<<16), \
74 l|=(((unsigned long)(*((c)++)))<< 8), \
75 l|=(((unsigned long)(*((c)++))) ))
76
77#undef p_c2nl
78#define p_c2nl(c,l,n) { \
79 switch (n) { \
80 case 0: l =((unsigned long)(*((c)++)))<<24; \
81 case 1: l|=((unsigned long)(*((c)++)))<<16; \
82 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
83 case 3: l|=((unsigned long)(*((c)++))); \
84 } \
85 }
86
87#undef c2nl_p
88/* NOTE the pointer is not incremented at the end of this */
89#define c2nl_p(c,l,n) { \
90 l=0; \
91 (c)+=n; \
92 switch (n) { \
93 case 3: l =((unsigned long)(*(--(c))))<< 8; \
94 case 2: l|=((unsigned long)(*(--(c))))<<16; \
95 case 1: l|=((unsigned long)(*(--(c))))<<24; \
96 } \
97 }
98
99#undef p_c2nl_p
100#define p_c2nl_p(c,l,sc,len) { \
101 switch (sc) \
102 { \
103 case 0: l =((unsigned long)(*((c)++)))<<24; \
104 if (--len == 0) break; \
105 case 1: l|=((unsigned long)(*((c)++)))<<16; \
106 if (--len == 0) break; \
107 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
108 } \
109 }
110
111#undef nl2c
112#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
113 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
114 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
115 *((c)++)=(unsigned char)(((l) )&0xff))
116
117#undef c2l
118#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
119 l|=(((unsigned long)(*((c)++)))<< 8), \
120 l|=(((unsigned long)(*((c)++)))<<16), \
121 l|=(((unsigned long)(*((c)++)))<<24))
122
123#undef p_c2l
124#define p_c2l(c,l,n) { \
125 switch (n) { \
126 case 0: l =((unsigned long)(*((c)++))); \
127 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
128 case 2: l|=((unsigned long)(*((c)++)))<<16; \
129 case 3: l|=((unsigned long)(*((c)++)))<<24; \
130 } \
131 }
132
133#undef c2l_p
134/* NOTE the pointer is not incremented at the end of this */
135#define c2l_p(c,l,n) { \
136 l=0; \
137 (c)+=n; \
138 switch (n) { \
139 case 3: l =((unsigned long)(*(--(c))))<<16; \
140 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
141 case 1: l|=((unsigned long)(*(--(c)))); \
142 } \
143 }
144
145#undef p_c2l_p
146#define p_c2l_p(c,l,sc,len) { \
147 switch (sc) \
148 { \
149 case 0: l =((unsigned long)(*((c)++))); \
150 if (--len == 0) break; \
151 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
152 if (--len == 0) break; \
153 case 2: l|=((unsigned long)(*((c)++)))<<16; \
154 } \
155 }
156
157#undef l2c
158#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
159 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
160 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
161 *((c)++)=(unsigned char)(((l)>>24)&0xff))
162 64
163#ifndef SHA_LONG_LOG2 65#ifndef SHA_LONG_LOG2
164#define SHA_LONG_LOG2 2 /* default to 32 bits */ 66#define SHA_LONG_LOG2 2 /* default to 32 bits */
165#endif 67#endif
166 68
167#undef ROTATE 69#define DATA_ORDER_IS_BIG_ENDIAN
168#undef Endian_Reverse32 70
169#if defined(WIN32) 71#define HASH_LONG SHA_LONG
170#define ROTATE(a,n) _lrotl(a,n) 72#define HASH_LONG_LOG2 SHA_LONG_LOG2
171#elif defined(__GNUC__) && !defined(PEDANTIC) 73#define HASH_CTX SHA_CTX
172/* some inline assembler templates by <appro@fy.chalmers.se> */ 74#define HASH_CBLOCK SHA_CBLOCK
173#if defined(__i386) && !defined(NO_ASM) 75#define HASH_LBLOCK SHA_LBLOCK
174#define ROTATE(a,n) ({ register unsigned int ret; \ 76#define HASH_MAKE_STRING(c,s) do { \
175 asm ("roll %1,%0" \ 77 unsigned long ll; \
176 : "=r"(ret) \ 78 ll=(c)->h0; HOST_l2c(ll,(s)); \
177 : "I"(n), "0"(a) \ 79 ll=(c)->h1; HOST_l2c(ll,(s)); \
178 : "cc"); \ 80 ll=(c)->h2; HOST_l2c(ll,(s)); \
179 ret; \ 81 ll=(c)->h3; HOST_l2c(ll,(s)); \
180 }) 82 ll=(c)->h4; HOST_l2c(ll,(s)); \
181#ifndef I386_ONLY 83 } while (0)
182#define Endian_Reverse32(a) \ 84
183 { register unsigned int ltmp=(a); \ 85#if defined(SHA_0)
184 asm ("bswapl %0" \ 86
185 : "=r"(ltmp) : "0"(ltmp)); \ 87# define HASH_UPDATE SHA_Update
186 (a)=ltmp; \ 88# define HASH_TRANSFORM SHA_Transform
187 } 89# define HASH_FINAL SHA_Final
188#endif 90# define HASH_INIT SHA_Init
189#elif defined(__powerpc) 91# define HASH_BLOCK_HOST_ORDER sha_block_host_order
190#define ROTATE(a,n) ({ register unsigned int ret; \ 92# define HASH_BLOCK_DATA_ORDER sha_block_data_order
191 asm ("rlwinm %0,%1,%2,0,31" \ 93# define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id))
192 : "=r"(ret) \ 94
193 : "r"(a), "I"(n)); \ 95 void sha_block_host_order (SHA_CTX *c, const void *p,int num);
194 ret; \ 96 void sha_block_data_order (SHA_CTX *c, const void *p,int num);
195 }) 97
196/* Endian_Reverse32 is not needed for PowerPC */ 98#elif defined(SHA_1)
197#endif 99
198#endif 100# define HASH_UPDATE SHA1_Update
101# define HASH_TRANSFORM SHA1_Transform
102# define HASH_FINAL SHA1_Final
103# define HASH_INIT SHA1_Init
104# define HASH_BLOCK_HOST_ORDER sha1_block_host_order
105# define HASH_BLOCK_DATA_ORDER sha1_block_data_order
106# if defined(__MWERKS__) && defined(__MC68K__)
107 /* Metrowerks for Motorola fails otherwise:-( <appro@fy.chalmers.se> */
108# define Xupdate(a,ix,ia,ib,ic,id) do { (a)=(ia^ib^ic^id); \
109 ix=(a)=ROTATE((a),1); \
110 } while (0)
111# else
112# define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \
113 ix=(a)=ROTATE((a),1) \
114 )
115# endif
116
117# ifdef SHA1_ASM
118# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
119# define sha1_block_host_order sha1_block_asm_host_order
120# define DONT_IMPLEMENT_BLOCK_HOST_ORDER
121# define sha1_block_data_order sha1_block_asm_data_order
122# define DONT_IMPLEMENT_BLOCK_DATA_ORDER
123# define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order
124# endif
125# endif
126 void sha1_block_host_order (SHA_CTX *c, const void *p,int num);
127 void sha1_block_data_order (SHA_CTX *c, const void *p,int num);
199 128
200/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
201#ifdef ROTATE
202#ifndef Endian_Reverse32
203/* 5 instructions with rotate instruction, else 9 */
204#define Endian_Reverse32(a) \
205 { \
206 unsigned long t=(a); \
207 (a)=((ROTATE(t,8)&0x00FF00FF)|(ROTATE((t&0x00FF00FF),24))); \
208 }
209#endif
210#else 129#else
211#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) 130# error "Either SHA_0 or SHA_1 must be defined."
212#ifndef Endian_Reverse32
213/* 6 instructions with rotate instruction, else 8 */
214#define Endian_Reverse32(a) \
215 { \
216 unsigned long t=(a); \
217 t=(((t>>8)&0x00FF00FF)|((t&0x00FF00FF)<<8)); \
218 (a)=ROTATE(t,16); \
219 }
220#endif 131#endif
221/* 132
222 * Originally the middle line started with l=(((l&0xFF00FF00)>>8)|... 133#ifndef FLAT_INC
223 * It's rewritten as above for two reasons: 134#include "../md32_common.h"
224 * - RISCs aren't good at long constants and have to explicitely 135#else
225 * compose 'em with several (well, usually 2) instructions in a 136#include "md32_common.h"
226 * register before performing the actual operation and (as you
227 * already realized:-) having same constant should inspire the
228 * compiler to permanently allocate the only register for it;
229 * - most modern CPUs have two ALUs, but usually only one has
230 * circuitry for shifts:-( this minor tweak inspires compiler
231 * to schedule shift instructions in a better way...
232 *
233 * <appro@fy.chalmers.se>
234 */
235#endif 137#endif
236 138
139#define INIT_DATA_h0 0x67452301UL
140#define INIT_DATA_h1 0xefcdab89UL
141#define INIT_DATA_h2 0x98badcfeUL
142#define INIT_DATA_h3 0x10325476UL
143#define INIT_DATA_h4 0xc3d2e1f0UL
144
145void HASH_INIT (SHA_CTX *c)
146 {
147 c->h0=INIT_DATA_h0;
148 c->h1=INIT_DATA_h1;
149 c->h2=INIT_DATA_h2;
150 c->h3=INIT_DATA_h3;
151 c->h4=INIT_DATA_h4;
152 c->Nl=0;
153 c->Nh=0;
154 c->num=0;
155 }
156
157#define K_00_19 0x5a827999UL
158#define K_20_39 0x6ed9eba1UL
159#define K_40_59 0x8f1bbcdcUL
160#define K_60_79 0xca62c1d6UL
161
237/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be 162/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be
238 * simplified to the code in F_00_19. Wei attributes these optimisations 163 * simplified to the code in F_00_19. Wei attributes these optimisations
239 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. 164 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
@@ -246,43 +171,305 @@
246#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) 171#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
247#define F_60_79(b,c,d) F_20_39(b,c,d) 172#define F_60_79(b,c,d) F_20_39(b,c,d)
248 173
249#undef Xupdate 174#define BODY_00_15(i,a,b,c,d,e,f,xi) \
250#ifdef SHA_0 175 (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
251#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\
252 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);
253#endif
254#ifdef SHA_1
255#define Xupdate(a,i,ia,ib,ic,id) (a)=\
256 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\
257 X[(i)&0x0f]=(a)=ROTATE((a),1);
258#endif
259
260#define BODY_00_15(i,a,b,c,d,e,f,xa) \
261 (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
262 (b)=ROTATE((b),30); 176 (b)=ROTATE((b),30);
263 177
264#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \ 178#define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
265 Xupdate(f,i,xa,xb,xc,xd); \ 179 Xupdate(f,xi,xa,xb,xc,xd); \
266 (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ 180 (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
267 (b)=ROTATE((b),30); 181 (b)=ROTATE((b),30);
268 182
269#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \ 183#define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
270 Xupdate(f,i,xa,xb,xc,xd); \ 184 Xupdate(f,xi,xa,xb,xc,xd); \
271 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ 185 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
272 (b)=ROTATE((b),30); 186 (b)=ROTATE((b),30);
273 187
274#define BODY_32_39(i,a,b,c,d,e,f,xa) \ 188#define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \
275 Xupdate(f,i,xa,xa,xa,xa); \ 189 Xupdate(f,xa,xa,xb,xc,xd); \
276 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ 190 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
277 (b)=ROTATE((b),30); 191 (b)=ROTATE((b),30);
278 192
279#define BODY_40_59(i,a,b,c,d,e,f,xa) \ 193#define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \
280 Xupdate(f,i,xa,xa,xa,xa); \ 194 Xupdate(f,xa,xa,xb,xc,xd); \
281 (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ 195 (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
282 (b)=ROTATE((b),30); 196 (b)=ROTATE((b),30);
283 197
284#define BODY_60_79(i,a,b,c,d,e,f,xa) \ 198#define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \
285 Xupdate(f,i,xa,xa,xa,xa); \ 199 Xupdate(f,xa,xa,xb,xc,xd); \
286 (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ 200 (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
287 (b)=ROTATE((b),30); 201 (b)=ROTATE((b),30);
288 202
203#ifdef X
204#undef X
205#endif
206#ifndef MD32_XARRAY
207 /*
208 * Originally X was an array. As it's automatic it's natural
209 * to expect RISC compiler to accomodate at least part of it in
210 * the register bank, isn't it? Unfortunately not all compilers
211 * "find" this expectation reasonable:-( On order to make such
212 * compilers generate better code I replace X[] with a bunch of
213 * X0, X1, etc. See the function body below...
214 * <appro@fy.chalmers.se>
215 */
216# define X(i) XX##i
217#else
218 /*
219 * However! Some compilers (most notably HP C) get overwhelmed by
220 * that many local variables so that we have to have the way to
221 * fall down to the original behavior.
222 */
223# define X(i) XX[i]
224#endif
225
226#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
227void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
228 {
229 const SHA_LONG *W=d;
230 register unsigned long A,B,C,D,E,T;
231#ifndef MD32_XARRAY
232 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
233 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
234#else
235 SHA_LONG XX[16];
236#endif
237
238 A=c->h0;
239 B=c->h1;
240 C=c->h2;
241 D=c->h3;
242 E=c->h4;
243
244 for (;;)
245 {
246 BODY_00_15( 0,A,B,C,D,E,T,W[ 0]);
247 BODY_00_15( 1,T,A,B,C,D,E,W[ 1]);
248 BODY_00_15( 2,E,T,A,B,C,D,W[ 2]);
249 BODY_00_15( 3,D,E,T,A,B,C,W[ 3]);
250 BODY_00_15( 4,C,D,E,T,A,B,W[ 4]);
251 BODY_00_15( 5,B,C,D,E,T,A,W[ 5]);
252 BODY_00_15( 6,A,B,C,D,E,T,W[ 6]);
253 BODY_00_15( 7,T,A,B,C,D,E,W[ 7]);
254 BODY_00_15( 8,E,T,A,B,C,D,W[ 8]);
255 BODY_00_15( 9,D,E,T,A,B,C,W[ 9]);
256 BODY_00_15(10,C,D,E,T,A,B,W[10]);
257 BODY_00_15(11,B,C,D,E,T,A,W[11]);
258 BODY_00_15(12,A,B,C,D,E,T,W[12]);
259 BODY_00_15(13,T,A,B,C,D,E,W[13]);
260 BODY_00_15(14,E,T,A,B,C,D,W[14]);
261 BODY_00_15(15,D,E,T,A,B,C,W[15]);
262
263 BODY_16_19(16,C,D,E,T,A,B,X( 0),W[ 0],W[ 2],W[ 8],W[13]);
264 BODY_16_19(17,B,C,D,E,T,A,X( 1),W[ 1],W[ 3],W[ 9],W[14]);
265 BODY_16_19(18,A,B,C,D,E,T,X( 2),W[ 2],W[ 4],W[10],W[15]);
266 BODY_16_19(19,T,A,B,C,D,E,X( 3),W[ 3],W[ 5],W[11],X( 0));
267
268 BODY_20_31(20,E,T,A,B,C,D,X( 4),W[ 4],W[ 6],W[12],X( 1));
269 BODY_20_31(21,D,E,T,A,B,C,X( 5),W[ 5],W[ 7],W[13],X( 2));
270 BODY_20_31(22,C,D,E,T,A,B,X( 6),W[ 6],W[ 8],W[14],X( 3));
271 BODY_20_31(23,B,C,D,E,T,A,X( 7),W[ 7],W[ 9],W[15],X( 4));
272 BODY_20_31(24,A,B,C,D,E,T,X( 8),W[ 8],W[10],X( 0),X( 5));
273 BODY_20_31(25,T,A,B,C,D,E,X( 9),W[ 9],W[11],X( 1),X( 6));
274 BODY_20_31(26,E,T,A,B,C,D,X(10),W[10],W[12],X( 2),X( 7));
275 BODY_20_31(27,D,E,T,A,B,C,X(11),W[11],W[13],X( 3),X( 8));
276 BODY_20_31(28,C,D,E,T,A,B,X(12),W[12],W[14],X( 4),X( 9));
277 BODY_20_31(29,B,C,D,E,T,A,X(13),W[13],W[15],X( 5),X(10));
278 BODY_20_31(30,A,B,C,D,E,T,X(14),W[14],X( 0),X( 6),X(11));
279 BODY_20_31(31,T,A,B,C,D,E,X(15),W[15],X( 1),X( 7),X(12));
280
281 BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
282 BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
283 BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
284 BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
285 BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
286 BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
287 BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
288 BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
289
290 BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
291 BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
292 BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
293 BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
294 BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
295 BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
296 BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
297 BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
298 BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
299 BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
300 BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
301 BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
302 BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
303 BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
304 BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
305 BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
306 BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
307 BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
308 BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
309 BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
310
311 BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
312 BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
313 BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
314 BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
315 BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
316 BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
317 BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
318 BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
319 BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
320 BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
321 BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
322 BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
323 BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
324 BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
325 BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
326 BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
327 BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
328 BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
329 BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
330 BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
331
332 c->h0=(c->h0+E)&0xffffffffL;
333 c->h1=(c->h1+T)&0xffffffffL;
334 c->h2=(c->h2+A)&0xffffffffL;
335 c->h3=(c->h3+B)&0xffffffffL;
336 c->h4=(c->h4+C)&0xffffffffL;
337
338 if (--num <= 0) break;
339
340 A=c->h0;
341 B=c->h1;
342 C=c->h2;
343 D=c->h3;
344 E=c->h4;
345
346 W+=SHA_LBLOCK;
347 }
348 }
349#endif
350
351#ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
352void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num)
353 {
354 const unsigned char *data=p;
355 register unsigned long A,B,C,D,E,T,l;
356#ifndef MD32_XARRAY
357 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
358 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
359#else
360 SHA_LONG XX[16];
361#endif
362
363 A=c->h0;
364 B=c->h1;
365 C=c->h2;
366 D=c->h3;
367 E=c->h4;
368
369 for (;;)
370 {
371
372 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
373 BODY_00_15( 0,A,B,C,D,E,T,X( 0)); HOST_c2l(data,l); X( 2)=l;
374 BODY_00_15( 1,T,A,B,C,D,E,X( 1)); HOST_c2l(data,l); X( 3)=l;
375 BODY_00_15( 2,E,T,A,B,C,D,X( 2)); HOST_c2l(data,l); X( 4)=l;
376 BODY_00_15( 3,D,E,T,A,B,C,X( 3)); HOST_c2l(data,l); X( 5)=l;
377 BODY_00_15( 4,C,D,E,T,A,B,X( 4)); HOST_c2l(data,l); X( 6)=l;
378 BODY_00_15( 5,B,C,D,E,T,A,X( 5)); HOST_c2l(data,l); X( 7)=l;
379 BODY_00_15( 6,A,B,C,D,E,T,X( 6)); HOST_c2l(data,l); X( 8)=l;
380 BODY_00_15( 7,T,A,B,C,D,E,X( 7)); HOST_c2l(data,l); X( 9)=l;
381 BODY_00_15( 8,E,T,A,B,C,D,X( 8)); HOST_c2l(data,l); X(10)=l;
382 BODY_00_15( 9,D,E,T,A,B,C,X( 9)); HOST_c2l(data,l); X(11)=l;
383 BODY_00_15(10,C,D,E,T,A,B,X(10)); HOST_c2l(data,l); X(12)=l;
384 BODY_00_15(11,B,C,D,E,T,A,X(11)); HOST_c2l(data,l); X(13)=l;
385 BODY_00_15(12,A,B,C,D,E,T,X(12)); HOST_c2l(data,l); X(14)=l;
386 BODY_00_15(13,T,A,B,C,D,E,X(13)); HOST_c2l(data,l); X(15)=l;
387 BODY_00_15(14,E,T,A,B,C,D,X(14));
388 BODY_00_15(15,D,E,T,A,B,C,X(15));
389
390 BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13));
391 BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14));
392 BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15));
393 BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0));
394
395 BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1));
396 BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2));
397 BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3));
398 BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4));
399 BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5));
400 BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6));
401 BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7));
402 BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8));
403 BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9));
404 BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10));
405 BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11));
406 BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12));
407
408 BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
409 BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
410 BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
411 BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
412 BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
413 BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
414 BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
415 BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
416
417 BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
418 BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
419 BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
420 BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
421 BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
422 BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
423 BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
424 BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
425 BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
426 BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
427 BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
428 BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
429 BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
430 BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
431 BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
432 BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
433 BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
434 BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
435 BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
436 BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
437
438 BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
439 BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
440 BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
441 BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
442 BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
443 BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
444 BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
445 BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
446 BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
447 BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
448 BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
449 BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
450 BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
451 BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
452 BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
453 BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
454 BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
455 BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
456 BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
457 BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
458
459 c->h0=(c->h0+E)&0xffffffffL;
460 c->h1=(c->h1+T)&0xffffffffL;
461 c->h2=(c->h2+A)&0xffffffffL;
462 c->h3=(c->h3+B)&0xffffffffL;
463 c->h4=(c->h4+C)&0xffffffffL;
464
465 if (--num <= 0) break;
466
467 A=c->h0;
468 B=c->h1;
469 C=c->h2;
470 D=c->h3;
471 E=c->h4;
472
473 }
474 }
475#endif
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c
index 2b0744d937..a5786bbf76 100644
--- a/src/lib/libcrypto/sha/shatest.c
+++ b/src/lib/libcrypto/sha/shatest.c
@@ -76,26 +76,26 @@ int main(int argc, char *argv[])
76#define SHA_0 /* FIPS 180 */ 76#define SHA_0 /* FIPS 180 */
77#undef SHA_1 /* FIPS 180-1 */ 77#undef SHA_1 /* FIPS 180-1 */
78 78
79char *test[]={ 79static char *test[]={
80 "abc", 80 "abc",
81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
82 NULL, 82 NULL,
83 }; 83 };
84 84
85#ifdef SHA_0 85#ifdef SHA_0
86char *ret[]={ 86static char *ret[]={
87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", 87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8", 88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
89 }; 89 };
90char *bigret= 90static char *bigret=
91 "3232affa48628a26653b5aaa44541fd90d690603"; 91 "3232affa48628a26653b5aaa44541fd90d690603";
92#endif 92#endif
93#ifdef SHA_1 93#ifdef SHA_1
94char *ret[]={ 94static char *ret[]={
95 "a9993e364706816aba3e25717850c26c9cd0d89d", 95 "a9993e364706816aba3e25717850c26c9cd0d89d",
96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1", 96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
97 }; 97 };
98char *bigret= 98static char *bigret=
99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; 99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
100#endif 100#endif
101 101
diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl
index faed4d0364..64a93b33ac 100644
--- a/src/lib/libcrypto/stack/Makefile.ssl
+++ b/src/lib/libcrypto/stack/Makefile.ssl
@@ -82,4 +82,5 @@ stack.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82stack.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82stack.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84stack.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 84stack.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85stack.o: ../../include/openssl/stack.h ../cryptlib.h 85stack.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
86stack.o: ../cryptlib.h
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c
index 8b96713884..58e9126339 100644
--- a/src/lib/libcrypto/stack/stack.c
+++ b/src/lib/libcrypto/stack/stack.c
@@ -59,7 +59,7 @@
59/* Code for stacks 59/* Code for stacks
60 * Author - Eric Young v 1.0 60 * Author - Eric Young v 1.0
61 * 1.2 eay 12-Mar-97 - Modified sk_find so that it _DOES_ return the 61 * 1.2 eay 12-Mar-97 - Modified sk_find so that it _DOES_ return the
62 * lowest index for the seached item. 62 * lowest index for the searched item.
63 * 63 *
64 * 1.1 eay - Take from netdb and added to SSLeay 64 * 1.1 eay - Take from netdb and added to SSLeay
65 * 65 *
@@ -126,7 +126,7 @@ STACK *sk_new(int (*c)())
126 ret->sorted=0; 126 ret->sorted=0;
127 return(ret); 127 return(ret);
128err1: 128err1:
129 Free((char *)ret); 129 Free(ret);
130err0: 130err0:
131 return(NULL); 131 return(NULL);
132 } 132 }
@@ -276,8 +276,8 @@ void sk_pop_free(STACK *st, void (*func)())
276void sk_free(STACK *st) 276void sk_free(STACK *st)
277 { 277 {
278 if (st == NULL) return; 278 if (st == NULL) return;
279 if (st->data != NULL) Free((char *)st->data); 279 if (st->data != NULL) Free(st->data);
280 Free((char *)st); 280 Free(st);
281 } 281 }
282 282
283int sk_num(STACK *st) 283int sk_num(STACK *st)
diff --git a/src/lib/libcrypto/stack/stack.h b/src/lib/libcrypto/stack/stack.h
index 0f825cc0c4..a615d9b4c9 100644
--- a/src/lib/libcrypto/stack/stack.h
+++ b/src/lib/libcrypto/stack/stack.h
@@ -76,8 +76,8 @@ typedef struct stack_st
76 76
77#define sk_new_null() sk_new(NULL) 77#define sk_new_null() sk_new(NULL)
78 78
79#define M_sk_num(sk) ((sk)->num) 79#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
80#define M_sk_value(sk,n) ((sk)->data[n]) 80#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
81 81
82int sk_num(STACK *); 82int sk_num(STACK *);
83char *sk_value(STACK *, int); 83char *sk_value(STACK *, int);
diff --git a/src/lib/libcrypto/threads/README b/src/lib/libcrypto/threads/README
new file mode 100644
index 0000000000..df6b26e146
--- /dev/null
+++ b/src/lib/libcrypto/threads/README
@@ -0,0 +1,14 @@
1Mutithreading testing area.
2
3Since this stuff is very very platorm specific, this is not part of the
4normal build. Have a read of doc/threads.doc.
5
6mttest will do some testing and will currently build under Windows NT/95,
7Solaris and Linux. The IRIX stuff is not finished.
8
9I have tested this program on a 12 CPU ultra sparc box (solaris 2.5.1)
10and things seem to work ok.
11
12The Linux pthreads package can be retrieved from
13http://www.mit.edu:8001/people/proven/pthreads.html
14
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index 142623edda..24713a3157 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -74,26 +74,29 @@
74#include <ulocks.h> 74#include <ulocks.h>
75#include <sys/prctl.h> 75#include <sys/prctl.h>
76#endif 76#endif
77#ifdef PTHREADS
78#include <pthread.h>
79#endif
77#include <openssl/lhash.h> 80#include <openssl/lhash.h>
78#include <openssl/crypto.h> 81#include <openssl/crypto.h>
79#include <openssl/buffer.h> 82#include <openssl/buffer.h>
80#include "../e_os.h" 83#include "../../e_os.h"
81#include <openssl/x509.h> 84#include <openssl/x509.h>
82#include <openssl/ssl.h> 85#include <openssl/ssl.h>
83#include <openssl/err.h> 86#include <openssl/err.h>
87#include <openssl/rand.h>
84 88
85#ifdef NO_FP_API 89#ifdef NO_FP_API
86#define APPS_WIN16 90#define APPS_WIN16
87#include "../crypto/buffer/bss_file.c" 91#include "../buffer/bss_file.c"
88#endif 92#endif
89 93
90#define TEST_SERVER_CERT "../apps/server.pem" 94#define TEST_SERVER_CERT "../../apps/server.pem"
91#define TEST_CLIENT_CERT "../apps/client.pem" 95#define TEST_CLIENT_CERT "../../apps/client.pem"
92 96
93#define MAX_THREAD_NUMBER 100 97#define MAX_THREAD_NUMBER 100
94 98
95int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, 99int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs);
96 int error,char *arg);
97void thread_setup(void); 100void thread_setup(void);
98void thread_cleanup(void); 101void thread_cleanup(void);
99void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); 102void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx);
@@ -121,6 +124,8 @@ int number_of_loops=10;
121int reconnect=0; 124int reconnect=0;
122int cache_stats=0; 125int cache_stats=0;
123 126
127static const char rnd_seed[] = "string to make the random number generator think it has entropy";
128
124int doit(char *ctx[4]); 129int doit(char *ctx[4]);
125static void print_stats(FILE *fp, SSL_CTX *ctx) 130static void print_stats(FILE *fp, SSL_CTX *ctx)
126{ 131{
@@ -170,6 +175,8 @@ int main(int argc, char *argv[])
170 char *ccert=TEST_CLIENT_CERT; 175 char *ccert=TEST_CLIENT_CERT;
171 SSL_METHOD *ssl_method=SSLv23_method(); 176 SSL_METHOD *ssl_method=SSLv23_method();
172 177
178 RAND_seed(rnd_seed, sizeof rnd_seed);
179
173 if (bio_err == NULL) 180 if (bio_err == NULL)
174 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 181 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
175 if (bio_stdout == NULL) 182 if (bio_stdout == NULL)
@@ -244,7 +251,7 @@ bad:
244 if (cipher == NULL) cipher=getenv("SSL_CIPHER"); 251 if (cipher == NULL) cipher=getenv("SSL_CIPHER");
245 252
246 SSL_load_error_strings(); 253 SSL_load_error_strings();
247 SSLeay_add_ssl_algorithms(); 254 OpenSSL_add_ssl_algorithms();
248 255
249 c_ctx=SSL_CTX_new(ssl_method); 256 c_ctx=SSL_CTX_new(ssl_method);
250 s_ctx=SSL_CTX_new(ssl_method); 257 s_ctx=SSL_CTX_new(ssl_method);
@@ -259,8 +266,15 @@ bad:
259 SSL_CTX_set_session_cache_mode(c_ctx, 266 SSL_CTX_set_session_cache_mode(c_ctx,
260 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER); 267 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
261 268
262 SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM); 269 if (!SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM))
263 SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM); 270 {
271 ERR_print_errors(bio_err);
272 }
273 else if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM))
274 {
275 ERR_print_errors(bio_err);
276 goto end;
277 }
264 278
265 if (client_auth) 279 if (client_auth)
266 { 280 {
@@ -489,6 +503,7 @@ int doit(char *ctx[4])
489 else 503 else
490 { 504 {
491 fprintf(stderr,"ERROR in CLIENT\n"); 505 fprintf(stderr,"ERROR in CLIENT\n");
506 ERR_print_errors_fp(stderr);
492 return(1); 507 return(1);
493 } 508 }
494 } 509 }
@@ -520,6 +535,7 @@ int doit(char *ctx[4])
520 else 535 else
521 { 536 {
522 fprintf(stderr,"ERROR in CLIENT\n"); 537 fprintf(stderr,"ERROR in CLIENT\n");
538 ERR_print_errors_fp(stderr);
523 return(1); 539 return(1);
524 } 540 }
525 } 541 }
@@ -652,18 +668,23 @@ err:
652 return(0); 668 return(0);
653 } 669 }
654 670
655int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, 671int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
656 int error, char *arg)
657 { 672 {
658 char buf[256]; 673 char *s, buf[256];
659 674
660 if (verbose) 675 if (verbose)
661 { 676 {
662 X509_NAME_oneline(X509_get_subject_name(xs),buf,256); 677 s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),
663 if (ok) 678 buf,256);
664 fprintf(stderr,"depth=%d %s\n",depth,buf); 679 if (s != NULL)
665 else 680 {
666 fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf); 681 if (ok)
682 fprintf(stderr,"depth=%d %s\n",
683 ctx->error_depth,buf);
684 else
685 fprintf(stderr,"depth=%d error=%d %s\n",
686 ctx->error_depth,ctx->error,buf);
687 }
667 } 688 }
668 return(ok); 689 return(ok);
669 } 690 }
@@ -672,13 +693,14 @@ int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth,
672 693
673#ifdef WIN32 694#ifdef WIN32
674 695
675static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; 696static HANDLE *lock_cs;
676 697
677void thread_setup(void) 698void thread_setup(void)
678 { 699 {
679 int i; 700 int i;
680 701
681 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 702 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(HANDLE));
703 for (i=0; i<CRYPTO_num_locks(); i++)
682 { 704 {
683 lock_cs[i]=CreateMutex(NULL,FALSE,NULL); 705 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
684 } 706 }
@@ -692,8 +714,9 @@ void thread_cleanup(void)
692 int i; 714 int i;
693 715
694 CRYPTO_set_locking_callback(NULL); 716 CRYPTO_set_locking_callback(NULL);
695 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 717 for (i=0; i<CRYPTO_num_locks(); i++)
696 CloseHandle(lock_cs[i]); 718 CloseHandle(lock_cs[i]);
719 Free(lock_cs);
697 } 720 }
698 721
699void win32_locking_callback(int mode, int type, char *file, int line) 722void win32_locking_callback(int mode, int type, char *file, int line)
@@ -763,15 +786,17 @@ void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
763 786
764#ifdef SOLARIS 787#ifdef SOLARIS
765 788
766static mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 789static mutex_t *lock_cs;
767/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */ 790/*static rwlock_t *lock_cs; */
768static long lock_count[CRYPTO_NUM_LOCKS]; 791static long *lock_count;
769 792
770void thread_setup(void) 793void thread_setup(void)
771 { 794 {
772 int i; 795 int i;
773 796
774 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 797 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(mutex_t));
798 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
799 for (i=0; i<CRYPTO_num_locks(); i++)
775 { 800 {
776 lock_count[i]=0; 801 lock_count[i]=0;
777 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */ 802 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
@@ -787,31 +812,37 @@ void thread_cleanup(void)
787 int i; 812 int i;
788 813
789 CRYPTO_set_locking_callback(NULL); 814 CRYPTO_set_locking_callback(NULL);
790fprintf(stderr,"cleanup\n"); 815
791 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 816 fprintf(stderr,"cleanup\n");
817
818 for (i=0; i<CRYPTO_num_locks(); i++)
792 { 819 {
793 /* rwlock_destroy(&(lock_cs[i])); */ 820 /* rwlock_destroy(&(lock_cs[i])); */
794 mutex_destroy(&(lock_cs[i])); 821 mutex_destroy(&(lock_cs[i]));
795 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i)); 822 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
796 } 823 }
797fprintf(stderr,"done cleanup\n"); 824 Free(lock_cs);
825 Free(lock_count);
826
827 fprintf(stderr,"done cleanup\n");
828
798 } 829 }
799 830
800void solaris_locking_callback(int mode, int type, char *file, int line) 831void solaris_locking_callback(int mode, int type, char *file, int line)
801 { 832 {
802#ifdef undef 833#ifdef undef
803fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", 834 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
804 CRYPTO_thread_id(), 835 CRYPTO_thread_id(),
805 (mode&CRYPTO_LOCK)?"l":"u", 836 (mode&CRYPTO_LOCK)?"l":"u",
806 (type&CRYPTO_READ)?"r":"w",file,line); 837 (type&CRYPTO_READ)?"r":"w",file,line);
807#endif 838#endif
808 839
809/* 840 /*
810if (CRYPTO_LOCK_SSL_CERT == type) 841 if (CRYPTO_LOCK_SSL_CERT == type)
811 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n", 842 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
812 CRYPTO_thread_id(), 843 CRYPTO_thread_id(),
813 mode,file,line); 844 mode,file,line);
814*/ 845 */
815 if (mode & CRYPTO_LOCK) 846 if (mode & CRYPTO_LOCK)
816 { 847 {
817 /* if (mode & CRYPTO_READ) 848 /* if (mode & CRYPTO_READ)
@@ -871,7 +902,7 @@ unsigned long solaris_thread_id(void)
871 902
872 903
873static usptr_t *arena; 904static usptr_t *arena;
874static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; 905static usema_t **lock_cs;
875 906
876void thread_setup(void) 907void thread_setup(void)
877 { 908 {
@@ -888,7 +919,8 @@ void thread_setup(void)
888 arena=usinit(filename); 919 arena=usinit(filename);
889 unlink(filename); 920 unlink(filename);
890 921
891 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 922 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(usema_t *));
923 for (i=0; i<CRYPTO_num_locks(); i++)
892 { 924 {
893 lock_cs[i]=usnewsema(arena,1); 925 lock_cs[i]=usnewsema(arena,1);
894 } 926 }
@@ -902,7 +934,7 @@ void thread_cleanup(void)
902 int i; 934 int i;
903 935
904 CRYPTO_set_locking_callback(NULL); 936 CRYPTO_set_locking_callback(NULL);
905 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 937 for (i=0; i<CRYPTO_num_locks(); i++)
906 { 938 {
907 char buf[10]; 939 char buf[10];
908 940
@@ -910,6 +942,7 @@ void thread_cleanup(void)
910 usdumpsema(lock_cs[i],stdout,buf); 942 usdumpsema(lock_cs[i],stdout,buf);
911 usfreesema(lock_cs[i],arena); 943 usfreesema(lock_cs[i],arena);
912 } 944 }
945 Free(lock_cs);
913 } 946 }
914 947
915void irix_locking_callback(int mode, int type, char *file, int line) 948void irix_locking_callback(int mode, int type, char *file, int line)
@@ -962,14 +995,16 @@ unsigned long irix_thread_id(void)
962 995
963#ifdef PTHREADS 996#ifdef PTHREADS
964 997
965static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 998static pthread_mutex_t *lock_cs;
966static long lock_count[CRYPTO_NUM_LOCKS]; 999static long *lock_count;
967 1000
968void thread_setup(void) 1001void thread_setup(void)
969 { 1002 {
970 int i; 1003 int i;
971 1004
972 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 1005 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
1006 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
1007 for (i=0; i<CRYPTO_num_locks(); i++)
973 { 1008 {
974 lock_count[i]=0; 1009 lock_count[i]=0;
975 pthread_mutex_init(&(lock_cs[i]),NULL); 1010 pthread_mutex_init(&(lock_cs[i]),NULL);
@@ -985,12 +1020,15 @@ void thread_cleanup(void)
985 1020
986 CRYPTO_set_locking_callback(NULL); 1021 CRYPTO_set_locking_callback(NULL);
987 fprintf(stderr,"cleanup\n"); 1022 fprintf(stderr,"cleanup\n");
988 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 1023 for (i=0; i<CRYPTO_num_locks(); i++)
989 { 1024 {
990 pthread_mutex_destroy(&(lock_cs[i])); 1025 pthread_mutex_destroy(&(lock_cs[i]));
991 fprintf(stderr,"%8ld:%s\n",lock_count[i], 1026 fprintf(stderr,"%8ld:%s\n",lock_count[i],
992 CRYPTO_get_lock_name(i)); 1027 CRYPTO_get_lock_name(i));
993 } 1028 }
1029 Free(lock_cs);
1030 Free(lock_count);
1031
994 fprintf(stderr,"done cleanup\n"); 1032 fprintf(stderr,"done cleanup\n");
995 } 1033 }
996 1034
@@ -1045,7 +1083,7 @@ void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
1045 } 1083 }
1046 1084
1047 printf("pthreads threads done (%d,%d)\n", 1085 printf("pthreads threads done (%d,%d)\n",
1048 s_ctx->references,c_ctx->references); 1086 s_ctx->references,c_ctx->references);
1049 } 1087 }
1050 1088
1051unsigned long pthreads_thread_id(void) 1089unsigned long pthreads_thread_id(void)
diff --git a/src/lib/libcrypto/threads/profile.sh b/src/lib/libcrypto/threads/profile.sh
new file mode 100644
index 0000000000..6e3e342fc0
--- /dev/null
+++ b/src/lib/libcrypto/threads/profile.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -p -DSOLARIS -I../../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libcrypto/threads/ptest.bat b/src/lib/libcrypto/threads/ptest.bat
new file mode 100644
index 0000000000..4071b5ffea
--- /dev/null
+++ b/src/lib/libcrypto/threads/ptest.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3purify cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssl32.lib ..\..\out\crypt32.lib
4
diff --git a/src/lib/libcrypto/threads/pthread.sh b/src/lib/libcrypto/threads/pthread.sh
new file mode 100644
index 0000000000..f1c49821d2
--- /dev/null
+++ b/src/lib/libcrypto/threads/pthread.sh
@@ -0,0 +1,9 @@
1#!/bin/sh
2#
3# build using pthreads
4#
5# http://www.mit.edu:8001/people/proven/pthreads.html
6#
7/bin/rm -f mttest
8pgcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto
9
diff --git a/src/lib/libcrypto/threads/pthread2.sh b/src/lib/libcrypto/threads/pthread2.sh
new file mode 100644
index 0000000000..41264c6a50
--- /dev/null
+++ b/src/lib/libcrypto/threads/pthread2.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2#
3# build using pthreads where it's already built into the system
4#
5/bin/rm -f mttest
6gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread
7
diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com
new file mode 100644
index 0000000000..63f5b8cc2e
--- /dev/null
+++ b/src/lib/libcrypto/threads/pthreads-vms.com
@@ -0,0 +1,9 @@
1$! To compile mttest on VMS.
2$!
3$! WARNING: only tested with DEC C so far.
4$
5$ arch := vax
6$ if f$getsyi("CPU") .ge. 128 then arch := axp
7$ define/user openssl [--.include.openssl]
8$ cc/def=PTHREADS mttest.c
9$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib
diff --git a/src/lib/libcrypto/threads/purify.sh b/src/lib/libcrypto/threads/purify.sh
new file mode 100644
index 0000000000..6d44fe26b7
--- /dev/null
+++ b/src/lib/libcrypto/threads/purify.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3purify cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libcrypto/threads/solaris.sh b/src/lib/libcrypto/threads/solaris.sh
new file mode 100644
index 0000000000..bc93094a27
--- /dev/null
+++ b/src/lib/libcrypto/threads/solaris.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libcrypto/threads/th-lock.c b/src/lib/libcrypto/threads/th-lock.c
index afb4f4caf2..3ee978060c 100644
--- a/src/lib/libcrypto/threads/th-lock.c
+++ b/src/lib/libcrypto/threads/th-lock.c
@@ -74,6 +74,9 @@
74#include <ulocks.h> 74#include <ulocks.h>
75#include <sys/prctl.h> 75#include <sys/prctl.h>
76#endif 76#endif
77#ifdef PTHREADS
78#include <pthread.h>
79#endif
77#include <openssl/lhash.h> 80#include <openssl/lhash.h>
78#include <openssl/crypto.h> 81#include <openssl/crypto.h>
79#include <openssl/buffer.h> 82#include <openssl/buffer.h>
@@ -82,7 +85,7 @@
82#include <openssl/ssl.h> 85#include <openssl/ssl.h>
83#include <openssl/err.h> 86#include <openssl/err.h>
84 87
85int CRYPTO_thread_setup(void); 88void CRYPTO_thread_setup(void);
86void CRYPTO_thread_cleanup(void); 89void CRYPTO_thread_cleanup(void);
87 90
88static void irix_locking_callback(int mode,int type,char *file,int line); 91static void irix_locking_callback(int mode,int type,char *file,int line);
@@ -96,7 +99,7 @@ static unsigned long pthreads_thread_id(void );
96 99
97/* usage: 100/* usage:
98 * CRYPTO_thread_setup(); 101 * CRYPTO_thread_setup();
99 * applicaion code 102 * application code
100 * CRYPTO_thread_cleanup(); 103 * CRYPTO_thread_cleanup();
101 */ 104 */
102 105
@@ -104,13 +107,14 @@ static unsigned long pthreads_thread_id(void );
104 107
105#ifdef WIN32 108#ifdef WIN32
106 109
107static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; 110static HANDLE *lock_cs;
108 111
109int CRYPTO_thread_setup(void) 112void CRYPTO_thread_setup(void)
110 { 113 {
111 int i; 114 int i;
112 115
113 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 116 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(HANDLE));
117 for (i=0; i<CRYPTO_num_locks(); i++)
114 { 118 {
115 lock_cs[i]=CreateMutex(NULL,FALSE,NULL); 119 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
116 } 120 }
@@ -125,8 +129,9 @@ static void CRYPTO_thread_cleanup(void)
125 int i; 129 int i;
126 130
127 CRYPTO_set_locking_callback(NULL); 131 CRYPTO_set_locking_callback(NULL);
128 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 132 for (i=0; i<CRYPTO_num_locks(); i++)
129 CloseHandle(lock_cs[i]); 133 CloseHandle(lock_cs[i]);
134 Free(lock_cs);
130 } 135 }
131 136
132void win32_locking_callback(int mode, int type, char *file, int line) 137void win32_locking_callback(int mode, int type, char *file, int line)
@@ -147,18 +152,24 @@ void win32_locking_callback(int mode, int type, char *file, int line)
147 152
148#define USE_MUTEX 153#define USE_MUTEX
149 154
150static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
151#ifdef USE_MUTEX 155#ifdef USE_MUTEX
152static long lock_count[CRYPTO_NUM_LOCKS]; 156static mutex_t *lock_cs;
153#else 157#else
154static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; 158static rwlock_t *lock_cs;
155#endif 159#endif
160static long *lock_count;
156 161
157void CRYPTO_thread_setup(void) 162void CRYPTO_thread_setup(void)
158 { 163 {
159 int i; 164 int i;
160 165
161 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 166#ifdef USE_MUTEX
167 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(mutex_t));
168#else
169 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(rwlock_t));
170#endif
171 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
172 for (i=0; i<CRYPTO_num_locks(); i++)
162 { 173 {
163 lock_count[i]=0; 174 lock_count[i]=0;
164#ifdef USE_MUTEX 175#ifdef USE_MUTEX
@@ -177,7 +188,7 @@ void CRYPTO_thread_cleanup(void)
177 int i; 188 int i;
178 189
179 CRYPTO_set_locking_callback(NULL); 190 CRYPTO_set_locking_callback(NULL);
180 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 191 for (i=0; i<CRYPTO_num_locks(); i++)
181 { 192 {
182#ifdef USE_MUTEX 193#ifdef USE_MUTEX
183 mutex_destroy(&(lock_cs[i])); 194 mutex_destroy(&(lock_cs[i]));
@@ -185,6 +196,8 @@ void CRYPTO_thread_cleanup(void)
185 rwlock_destroy(&(lock_cs[i])); 196 rwlock_destroy(&(lock_cs[i]));
186#endif 197#endif
187 } 198 }
199 Free(lock_cs);
200 Free(lock_count);
188 } 201 }
189 202
190void solaris_locking_callback(int mode, int type, char *file, int line) 203void solaris_locking_callback(int mode, int type, char *file, int line)
@@ -237,7 +250,7 @@ unsigned long solaris_thread_id(void)
237/* I don't think this works..... */ 250/* I don't think this works..... */
238 251
239static usptr_t *arena; 252static usptr_t *arena;
240static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; 253static usema_t **lock_cs;
241 254
242void CRYPTO_thread_setup(void) 255void CRYPTO_thread_setup(void)
243 { 256 {
@@ -254,7 +267,8 @@ void CRYPTO_thread_setup(void)
254 arena=usinit(filename); 267 arena=usinit(filename);
255 unlink(filename); 268 unlink(filename);
256 269
257 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 270 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(usema_t *));
271 for (i=0; i<CRYPTO_num_locks(); i++)
258 { 272 {
259 lock_cs[i]=usnewsema(arena,1); 273 lock_cs[i]=usnewsema(arena,1);
260 } 274 }
@@ -268,7 +282,7 @@ void CRYPTO_thread_cleanup(void)
268 int i; 282 int i;
269 283
270 CRYPTO_set_locking_callback(NULL); 284 CRYPTO_set_locking_callback(NULL);
271 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 285 for (i=0; i<CRYPTO_num_locks(); i++)
272 { 286 {
273 char buf[10]; 287 char buf[10];
274 288
@@ -276,6 +290,7 @@ void CRYPTO_thread_cleanup(void)
276 usdumpsema(lock_cs[i],stdout,buf); 290 usdumpsema(lock_cs[i],stdout,buf);
277 usfreesema(lock_cs[i],arena); 291 usfreesema(lock_cs[i],arena);
278 } 292 }
293 Free(lock_cs);
279 } 294 }
280 295
281void irix_locking_callback(int mode, int type, char *file, int line) 296void irix_locking_callback(int mode, int type, char *file, int line)
@@ -302,14 +317,16 @@ unsigned long irix_thread_id(void)
302/* Linux and a few others */ 317/* Linux and a few others */
303#ifdef PTHREADS 318#ifdef PTHREADS
304 319
305static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 320static pthread_mutex_t *lock_cs;
306static long lock_count[CRYPTO_NUM_LOCKS]; 321static long *lock_count;
307 322
308void CRYPTO_thread_setup(void) 323void CRYPTO_thread_setup(void)
309 { 324 {
310 int i; 325 int i;
311 326
312 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 327 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
328 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
329 for (i=0; i<CRYPTO_num_locks(); i++)
313 { 330 {
314 lock_count[i]=0; 331 lock_count[i]=0;
315 pthread_mutex_init(&(lock_cs[i]),NULL); 332 pthread_mutex_init(&(lock_cs[i]),NULL);
@@ -324,10 +341,12 @@ void thread_cleanup(void)
324 int i; 341 int i;
325 342
326 CRYPTO_set_locking_callback(NULL); 343 CRYPTO_set_locking_callback(NULL);
327 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 344 for (i=0; i<CRYPTO_num_locks(); i++)
328 { 345 {
329 pthread_mutex_destroy(&(lock_cs[i])); 346 pthread_mutex_destroy(&(lock_cs[i]));
330 } 347 }
348 Free(lock_cs);
349 Free(lock_count);
331 } 350 }
332 351
333void pthreads_locking_callback(int mode, int type, char *file, 352void pthreads_locking_callback(int mode, int type, char *file,
diff --git a/src/lib/libcrypto/threads/win32.bat b/src/lib/libcrypto/threads/win32.bat
new file mode 100644
index 0000000000..ee6da80a07
--- /dev/null
+++ b/src/lib/libcrypto/threads/win32.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssleay32.lib ..\..\out\libeay32.lib
4
diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl
index 02b863bf89..a631dce6f2 100644
--- a/src/lib/libcrypto/txt_db/Makefile.ssl
+++ b/src/lib/libcrypto/txt_db/Makefile.ssl
@@ -82,5 +82,6 @@ txt_db.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82txt_db.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82txt_db.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 84txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
85txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 85txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
86txt_db.o: ../../include/openssl/txt_db.h ../cryptlib.h 86txt_db.o: ../../include/openssl/stack.h ../../include/openssl/txt_db.h
87txt_db.o: ../cryptlib.h
diff --git a/src/lib/libcrypto/txt_db/txt_db.c b/src/lib/libcrypto/txt_db/txt_db.c
index 9a9fa5ce55..33acc81f3f 100644
--- a/src/lib/libcrypto/txt_db/txt_db.c
+++ b/src/lib/libcrypto/txt_db/txt_db.c
@@ -181,7 +181,7 @@ err:
181#endif 181#endif
182 if (ret->data != NULL) sk_free(ret->data); 182 if (ret->data != NULL) sk_free(ret->data);
183 if (ret->index != NULL) Free(ret->index); 183 if (ret->index != NULL) Free(ret->index);
184 if (ret->qual != NULL) Free((char *)ret->qual); 184 if (ret->qual != NULL) Free(ret->qual);
185 if (ret != NULL) Free(ret); 185 if (ret != NULL) Free(ret);
186 return(NULL); 186 return(NULL);
187 } 187 }
@@ -205,7 +205,7 @@ char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
205 db->error=DB_ERROR_NO_INDEX; 205 db->error=DB_ERROR_NO_INDEX;
206 return(NULL); 206 return(NULL);
207 } 207 }
208 ret=(char **)lh_retrieve(lh,(char *)value); 208 ret=(char **)lh_retrieve(lh,value);
209 db->error=DB_ERROR_OK; 209 db->error=DB_ERROR_OK;
210 return(ret); 210 return(ret);
211 } 211 }
@@ -306,7 +306,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
306 { 306 {
307 if ((db->qual[i] != NULL) && 307 if ((db->qual[i] != NULL) &&
308 (db->qual[i](row) == 0)) continue; 308 (db->qual[i](row) == 0)) continue;
309 r=(char **)lh_retrieve(db->index[i],(char *)row); 309 r=(char **)lh_retrieve(db->index[i],row);
310 if (r != NULL) 310 if (r != NULL)
311 { 311 {
312 db->error=DB_ERROR_INDEX_CLASH; 312 db->error=DB_ERROR_INDEX_CLASH;
@@ -329,7 +329,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
329 { 329 {
330 if ((db->qual[i] != NULL) && 330 if ((db->qual[i] != NULL) &&
331 (db->qual[i](row) == 0)) continue; 331 (db->qual[i](row) == 0)) continue;
332 lh_insert(db->index[i],(char *)row); 332 lh_insert(db->index[i],row);
333 } 333 }
334 } 334 }
335 return(1); 335 return(1);
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd
index 324051f60b..9f75131f22 100644
--- a/src/lib/libcrypto/util/domd
+++ b/src/lib/libcrypto/util/domd
@@ -7,5 +7,5 @@ shift
7 7
8cp Makefile.ssl Makefile.save 8cp Makefile.ssl Makefile.save
9makedepend -f Makefile.ssl $@ 9makedepend -f Makefile.ssl $@
10$TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new 10perl $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new
11mv Makefile.new Makefile.ssl 11mv Makefile.new Makefile.ssl
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index 59c2040a29..e3818ef6e4 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -499,9 +499,9 @@ SHA1_Update 504
499SHA_Final 505 499SHA_Final 505
500SHA_Init 506 500SHA_Init 506
501SHA_Update 507 501SHA_Update 507
502SSLeay_add_all_algorithms 508 502OpenSSL_add_all_algorithms 508
503SSLeay_add_all_ciphers 509 503OpenSSL_add_all_ciphers 509
504SSLeay_add_all_digests 510 504OpenSSL_add_all_digests 510
505TXT_DB_create_index 511 505TXT_DB_create_index 511
506TXT_DB_free 512 506TXT_DB_free 512
507TXT_DB_get_by_index 513 507TXT_DB_get_by_index 513
@@ -1304,13 +1304,12 @@ i2d_SXNETID 1329
1304d2i_SXNETID 1330 1304d2i_SXNETID 1330
1305SXNETID_new 1331 1305SXNETID_new 1331
1306SXNETID_free 1332 1306SXNETID_free 1332
1307DSA_SIG_new 1333 1307DSA_SIG_new 1333
1308DSA_SIG_free 1334 1308DSA_SIG_free 1334
1309DSA_do_sign 1335 1309DSA_do_sign 1335
1310DSA_do_verify 1336 1310DSA_do_verify 1336
1311d2i_DSA_SIG 1337 1311d2i_DSA_SIG 1337
1312i2d_DSA_SIG 1338 1312i2d_DSA_SIG 1338
1313
1314i2d_ASN1_VISIBLESTRING 1339 1313i2d_ASN1_VISIBLESTRING 1339
1315d2i_ASN1_VISIBLESTRING 1340 1314d2i_ASN1_VISIBLESTRING 1340
1316i2d_ASN1_UTF8STRING 1341 1315i2d_ASN1_UTF8STRING 1341
@@ -1844,3 +1843,387 @@ sk_DIST_POINT_sort 1868
1844RSA_check_key 1869 1843RSA_check_key 1869
1845OBJ_obj2txt 1870 1844OBJ_obj2txt 1870
1846DSA_dup_DH 1871 1845DSA_dup_DH 1871
1846X509_REQ_get_extensions 1872
1847X509_REQ_set_extension_nids 1873
1848BIO_nwrite 1874
1849X509_REQ_extension_nid 1875
1850BIO_nread 1876
1851X509_REQ_get_extension_nids 1877
1852BIO_nwrite0 1878
1853X509_REQ_add_extensions_nid 1879
1854BIO_nread0 1880
1855X509_REQ_add_extensions 1881
1856BIO_new_mem_buf 1882
1857DH_set_ex_data 1883
1858DH_set_method 1884
1859DSA_OpenSSL 1885
1860DH_get_ex_data 1886
1861DH_get_ex_new_index 1887
1862DSA_new_method 1888
1863DH_new_method 1889
1864DH_OpenSSL 1890
1865DSA_get_ex_new_index 1891
1866DH_get_default_method 1892
1867DSA_set_ex_data 1893
1868DH_set_default_method 1894
1869DSA_get_ex_data 1895
1870X509V3_EXT_REQ_add_conf 1896
1871NETSCAPE_SPKI_print 1897
1872NETSCAPE_SPKI_set_pubkey 1898
1873NETSCAPE_SPKI_b64_encode 1899
1874NETSCAPE_SPKI_get_pubkey 1900
1875NETSCAPE_SPKI_b64_decode 1901
1876UTF8_putc 1902
1877UTF8_getc 1903
1878RSA_null_method 1904
1879ASN1_tag2str 1905
1880BIO_ctrl_reset_read_request 1906
1881DISPLAYTEXT_new 1907
1882ASN1_GENERALIZEDTIME_free 1908
1883X509_REVOKED_get_ext_d2i 1909
1884X509_set_ex_data 1910
1885X509_reject_set_bit_asc 1911
1886X509_NAME_add_entry_by_txt 1912
1887sk_X509_TRUST_pop 1913
1888X509_NAME_add_entry_by_NID 1914
1889X509_PURPOSE_get0 1915
1890sk_ACCESS_DESCRIPTION_shift 1916
1891PEM_read_X509_AUX 1917
1892d2i_AUTHORITY_INFO_ACCESS 1918
1893sk_X509_TRUST_set_cmp_func 1919
1894sk_X509_TRUST_free 1920
1895PEM_write_PUBKEY 1921
1896sk_X509_TRUST_num 1922
1897sk_ACCESS_DESCRIPTION_delete 1923
1898sk_ASN1_STRING_TABLE_value 1924
1899ACCESS_DESCRIPTION_new 1925
1900X509_CERT_AUX_free 1926
1901d2i_ACCESS_DESCRIPTION 1927
1902X509_trust_clear 1928
1903sk_X509_PURPOSE_value 1929
1904sk_X509_PURPOSE_zero 1930
1905X509_TRUST_add 1931
1906ASN1_VISIBLESTRING_new 1932
1907X509_alias_set1 1933
1908ASN1_PRINTABLESTRING_free 1934
1909EVP_PKEY_get1_DSA 1935
1910ASN1_BMPSTRING_new 1936
1911ASN1_mbstring_copy 1937
1912ASN1_UTF8STRING_new 1938
1913sk_ACCESS_DESCRIPTION_set 1939
1914sk_X509_PURPOSE_pop 1940
1915DSA_get_default_method 1941
1916sk_X509_PURPOSE_push 1942
1917sk_X509_PURPOSE_delete 1943
1918sk_X509_PURPOSE_num 1944
1919i2d_ASN1_SET_OF_ACCESS_DESCRIPTION 1945
1920ASN1_T61STRING_free 1946
1921sk_ACCESS_DESCRIPTION_free 1947
1922sk_ASN1_STRING_TABLE_pop 1948
1923DSA_set_method 1949
1924X509_get_ex_data 1950
1925ASN1_STRING_type 1951
1926X509_PURPOSE_get_by_sname 1952
1927sk_X509_PURPOSE_find 1953
1928ASN1_TIME_free 1954
1929ASN1_OCTET_STRING_cmp 1955
1930sk_ACCESS_DESCRIPTION_value 1956
1931ASN1_BIT_STRING_new 1957
1932X509_get_ext_d2i 1958
1933PEM_read_bio_X509_AUX 1959
1934ASN1_STRING_set_default_mask_asc 1960
1935PEM_write_bio_RSA_PUBKEY 1961
1936sk_ASN1_STRING_TABLE_num 1962
1937ASN1_INTEGER_cmp 1963
1938d2i_RSA_PUBKEY_fp 1964
1939sk_ACCESS_DESCRIPTION_unshift 1965
1940sk_ASN1_STRING_TABLE_delete_ptr 1966
1941X509_trust_set_bit_asc 1967
1942PEM_write_bio_DSA_PUBKEY 1968
1943X509_STORE_CTX_free 1969
1944EVP_PKEY_set1_DSA 1970
1945i2d_DSA_PUBKEY_fp 1971
1946X509_load_cert_crl_file 1972
1947ASN1_TIME_new 1973
1948i2d_RSA_PUBKEY 1974
1949sk_X509_TRUST_pop_free 1975
1950X509_STORE_CTX_purpose_inherit 1976
1951PEM_read_RSA_PUBKEY 1977
1952sk_X509_TRUST_zero 1978
1953sk_ACCESS_DESCRIPTION_pop_free 1979
1954d2i_X509_AUX 1980
1955i2d_DSA_PUBKEY 1981
1956X509_CERT_AUX_print 1982
1957sk_X509_PURPOSE_new_null 1983
1958PEM_read_DSA_PUBKEY 1984
1959i2d_RSA_PUBKEY_bio 1985
1960ASN1_BIT_STRING_num_asc 1986
1961i2d_PUBKEY 1987
1962ASN1_UTCTIME_free 1988
1963DSA_set_default_method 1989
1964X509_PURPOSE_get_by_id 1990
1965sk_X509_TRUST_push 1991
1966sk_ASN1_STRING_TABLE_sort 1992
1967sk_X509_PURPOSE_set_cmp_func 1993
1968ACCESS_DESCRIPTION_free 1994
1969PEM_read_bio_PUBKEY 1995
1970ASN1_STRING_set_by_NID 1996
1971X509_PURPOSE_get_id 1997
1972DISPLAYTEXT_free 1998
1973OTHERNAME_new 1999
1974sk_X509_TRUST_find 2000
1975X509_CERT_AUX_new 2001
1976sk_ACCESS_DESCRIPTION_dup 2002
1977sk_ASN1_STRING_TABLE_pop_free 2003
1978sk_ASN1_STRING_TABLE_unshift 2004
1979sk_X509_TRUST_shift 2005
1980sk_ACCESS_DESCRIPTION_zero 2006
1981X509_TRUST_cleanup 2007
1982X509_NAME_add_entry_by_OBJ 2008
1983X509_CRL_get_ext_d2i 2009
1984sk_X509_TRUST_set 2010
1985X509_PURPOSE_get0_name 2011
1986PEM_read_PUBKEY 2012
1987sk_ACCESS_DESCRIPTION_new 2013
1988i2d_DSA_PUBKEY_bio 2014
1989i2d_OTHERNAME 2015
1990ASN1_OCTET_STRING_free 2016
1991ASN1_BIT_STRING_set_asc 2017
1992sk_ACCESS_DESCRIPTION_push 2018
1993X509_get_ex_new_index 2019
1994ASN1_STRING_TABLE_cleanup 2020
1995X509_TRUST_get_by_id 2021
1996X509_PURPOSE_get_trust 2022
1997ASN1_STRING_length 2023
1998d2i_ASN1_SET_OF_ACCESS_DESCRIPTION 2024
1999ASN1_PRINTABLESTRING_new 2025
2000X509V3_get_d2i 2026
2001ASN1_ENUMERATED_free 2027
2002i2d_X509_CERT_AUX 2028
2003sk_ACCESS_DESCRIPTION_find 2029
2004X509_STORE_CTX_set_trust 2030
2005sk_X509_PURPOSE_unshift 2031
2006ASN1_STRING_set_default_mask 2032
2007X509_STORE_CTX_new 2033
2008EVP_PKEY_get1_RSA 2034
2009sk_X509_PURPOSE_set 2035
2010sk_ASN1_STRING_TABLE_insert 2036
2011sk_X509_PURPOSE_sort 2037
2012DIRECTORYSTRING_free 2038
2013PEM_write_X509_AUX 2039
2014ASN1_OCTET_STRING_set 2040
2015d2i_DSA_PUBKEY_fp 2041
2016sk_ASN1_STRING_TABLE_free 2042
2017sk_X509_TRUST_value 2043
2018d2i_RSA_PUBKEY 2044
2019sk_ASN1_STRING_TABLE_set 2045
2020X509_TRUST_get0_name 2046
2021X509_TRUST_get0 2047
2022AUTHORITY_INFO_ACCESS_free 2048
2023ASN1_IA5STRING_new 2049
2024d2i_DSA_PUBKEY 2050
2025X509_check_purpose 2051
2026ASN1_ENUMERATED_new 2052
2027d2i_RSA_PUBKEY_bio 2053
2028d2i_PUBKEY 2054
2029X509_TRUST_get_trust 2055
2030X509_TRUST_get_flags 2056
2031ASN1_BMPSTRING_free 2057
2032ASN1_T61STRING_new 2058
2033sk_X509_TRUST_unshift 2059
2034ASN1_UTCTIME_new 2060
2035sk_ACCESS_DESCRIPTION_pop 2061
2036i2d_AUTHORITY_INFO_ACCESS 2062
2037EVP_PKEY_set1_RSA 2063
2038X509_STORE_CTX_set_purpose 2064
2039ASN1_IA5STRING_free 2065
2040PEM_write_bio_X509_AUX 2066
2041X509_PURPOSE_get_count 2067
2042CRYPTO_add_info 2068
2043sk_ACCESS_DESCRIPTION_num 2069
2044sk_ASN1_STRING_TABLE_set_cmp_func 2070
2045X509_NAME_ENTRY_create_by_txt 2071
2046ASN1_STRING_get_default_mask 2072
2047sk_X509_TRUST_dup 2073
2048X509_alias_get0 2074
2049ASN1_STRING_data 2075
2050sk_X509_TRUST_insert 2076
2051i2d_ACCESS_DESCRIPTION 2077
2052X509_trust_set_bit 2078
2053sk_X509_PURPOSE_delete_ptr 2079
2054ASN1_BIT_STRING_free 2080
2055PEM_read_bio_RSA_PUBKEY 2081
2056X509_add1_reject_object 2082
2057X509_check_trust 2083
2058sk_X509_TRUST_new_null 2084
2059sk_ACCESS_DESCRIPTION_new_null 2085
2060sk_ACCESS_DESCRIPTION_delete_ptr 2086
2061sk_X509_TRUST_sort 2087
2062PEM_read_bio_DSA_PUBKEY 2088
2063sk_X509_TRUST_new 2089
2064X509_PURPOSE_add 2090
2065ASN1_STRING_TABLE_get 2091
2066ASN1_UTF8STRING_free 2092
2067d2i_DSA_PUBKEY_bio 2093
2068sk_ASN1_STRING_TABLE_delete 2094
2069PEM_write_RSA_PUBKEY 2095
2070d2i_OTHERNAME 2096
2071sk_ACCESS_DESCRIPTION_insert 2097
2072X509_reject_set_bit 2098
2073sk_X509_TRUST_delete_ptr 2099
2074sk_X509_PURPOSE_pop_free 2100
2075PEM_write_DSA_PUBKEY 2101
2076sk_X509_PURPOSE_free 2102
2077sk_X509_PURPOSE_dup 2103
2078sk_ASN1_STRING_TABLE_zero 2104
2079X509_PURPOSE_get0_sname 2105
2080sk_ASN1_STRING_TABLE_shift 2106
2081EVP_PKEY_set1_DH 2107
2082ASN1_OCTET_STRING_dup 2108
2083ASN1_BIT_STRING_set 2109
2084X509_TRUST_get_count 2110
2085ASN1_INTEGER_free 2111
2086OTHERNAME_free 2112
2087i2d_RSA_PUBKEY_fp 2113
2088ASN1_INTEGER_dup 2114
2089d2i_X509_CERT_AUX 2115
2090sk_ASN1_STRING_TABLE_new_null 2116
2091PEM_write_bio_PUBKEY 2117
2092ASN1_VISIBLESTRING_free 2118
2093X509_PURPOSE_cleanup 2119
2094sk_ASN1_STRING_TABLE_push 2120
2095sk_ASN1_STRING_TABLE_dup 2121
2096sk_X509_PURPOSE_shift 2122
2097ASN1_mbstring_ncopy 2123
2098sk_X509_PURPOSE_new 2124
2099sk_X509_PURPOSE_insert 2125
2100ASN1_GENERALIZEDTIME_new 2126
2101sk_ACCESS_DESCRIPTION_sort 2127
2102EVP_PKEY_get1_DH 2128
2103sk_ACCESS_DESCRIPTION_set_cmp_func 2129
2104ASN1_OCTET_STRING_new 2130
2105ASN1_INTEGER_new 2131
2106i2d_X509_AUX 2132
2107sk_ASN1_STRING_TABLE_find 2133
2108ASN1_BIT_STRING_name_print 2134
2109X509_cmp 2135
2110ASN1_STRING_length_set 2136
2111DIRECTORYSTRING_new 2137
2112sk_ASN1_STRING_TABLE_new 2138
2113sk_X509_TRUST_delete 2139
2114X509_add1_trust_object 2140
2115PKCS12_newpass 2141
2116SMIME_write_PKCS7 2142
2117SMIME_read_PKCS7 2143
2118des_set_key_checked 2144
2119PKCS7_verify 2145
2120PKCS7_encrypt 2146
2121des_set_key_unchecked 2147
2122SMIME_crlf_copy 2148
2123i2d_ASN1_PRINTABLESTRING 2149
2124PKCS7_get0_signers 2150
2125PKCS7_decrypt 2151
2126SMIME_text 2152
2127PKCS7_simple_smimecap 2153
2128PKCS7_get_smimecap 2154
2129PKCS7_sign 2155
2130PKCS7_add_attrib_smimecap 2156
2131CRYPTO_dbg_set_options 2157
2132CRYPTO_remove_all_info 2158
2133CRYPTO_get_mem_debug_functions 2159
2134CRYPTO_is_mem_check_on 2160
2135CRYPTO_set_mem_debug_functions 2161
2136CRYPTO_pop_info 2162
2137CRYPTO_push_info_ 2163
2138CRYPTO_set_mem_debug_options 2164
2139PEM_write_PKCS8PrivateKey_nid 2165
2140PEM_write_bio_PKCS8PrivateKey_nid 2166
2141d2i_PKCS8PrivateKey_bio 2167
2142ASN1_NULL_free 2168
2143d2i_ASN1_NULL 2169
2144ASN1_NULL_new 2170
2145i2d_PKCS8PrivateKey_bio 2171
2146i2d_PKCS8PrivateKey_fp 2172
2147i2d_ASN1_NULL 2173
2148i2d_PKCS8PrivateKey_nid_fp 2174
2149d2i_PKCS8PrivateKey_fp 2175
2150i2d_PKCS8PrivateKey_nid_bio 2176
2151i2d_PKCS8PrivateKeyInfo_fp 2177
2152i2d_PKCS8PrivateKeyInfo_bio 2178
2153PEM_cb 2179
2154i2d_PrivateKey_fp 2180
2155d2i_PrivateKey_bio 2181
2156d2i_PrivateKey_fp 2182
2157i2d_PrivateKey_bio 2183
2158X509_reject_clear 2184
2159X509_TRUST_set_default 2185
2160d2i_AutoPrivateKey 2186
2161X509_ATTRIBUTE_get0_type 2187
2162X509_ATTRIBUTE_set1_data 2188
2163X509at_get_attr 2189
2164X509at_get_attr_count 2190
2165X509_ATTRIBUTE_create_by_NID 2191
2166X509_ATTRIBUTE_set1_object 2192
2167X509_ATTRIBUTE_count 2193
2168X509_ATTRIBUTE_create_by_OBJ 2194
2169X509_ATTRIBUTE_get0_object 2195
2170X509at_get_attr_by_NID 2196
2171X509at_add1_attr 2197
2172X509_ATTRIBUTE_get0_data 2198
2173X509at_delete_attr 2199
2174X509at_get_attr_by_OBJ 2200
2175RAND_add 2201
2176BIO_number_written 2202
2177BIO_number_read 2203
2178X509_STORE_CTX_get1_chain 2204
2179ERR_load_RAND_strings 2205
2180RAND_pseudo_bytes 2206
2181X509_REQ_get_attr_by_NID 2207
2182X509_REQ_get_attr 2208
2183X509_REQ_add1_attr_by_NID 2209
2184X509_REQ_get_attr_by_OBJ 2210
2185X509at_add1_attr_by_NID 2211
2186X509_REQ_add1_attr_by_OBJ 2212
2187X509_REQ_get_attr_count 2213
2188X509_REQ_add1_attr 2214
2189X509_REQ_delete_attr 2215
2190X509at_add1_attr_by_OBJ 2216
2191X509_REQ_add1_attr_by_txt 2217
2192X509_ATTRIBUTE_create_by_txt 2218
2193X509at_add1_attr_by_txt 2219
2194sk_CRYPTO_EX_DATA_FUNCS_delete 2220
2195sk_CRYPTO_EX_DATA_FUNCS_set 2221
2196sk_CRYPTO_EX_DATA_FUNCS_unshift 2222
2197sk_CRYPTO_EX_DATA_FUNCS_new_null 2223
2198sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func 2224
2199sk_CRYPTO_EX_DATA_FUNCS_sort 2225
2200sk_CRYPTO_EX_DATA_FUNCS_dup 2226
2201sk_CRYPTO_EX_DATA_FUNCS_shift 2227
2202sk_CRYPTO_EX_DATA_FUNCS_value 2228
2203sk_CRYPTO_EX_DATA_FUNCS_pop 2229
2204sk_CRYPTO_EX_DATA_FUNCS_push 2230
2205sk_CRYPTO_EX_DATA_FUNCS_find 2231
2206sk_CRYPTO_EX_DATA_FUNCS_new 2232
2207sk_CRYPTO_EX_DATA_FUNCS_free 2233
2208sk_CRYPTO_EX_DATA_FUNCS_delete_ptr 2234
2209sk_CRYPTO_EX_DATA_FUNCS_num 2235
2210sk_CRYPTO_EX_DATA_FUNCS_pop_free 2236
2211sk_CRYPTO_EX_DATA_FUNCS_insert 2237
2212sk_CRYPTO_EX_DATA_FUNCS_zero 2238
2213BN_pseudo_rand 2239
2214BN_is_prime_fasttest 2240
2215BN_CTX_end 2241
2216BN_CTX_start 2242
2217BN_CTX_get 2243
2218EVP_PKEY2PKCS8_broken 2244
2219ASN1_STRING_TABLE_add 2245
2220CRYPTO_dbg_get_options 2246
2221AUTHORITY_INFO_ACCESS_new 2247
2222CRYPTO_get_mem_debug_options 2248
2223des_crypt 2249
2224PEM_write_bio_X509_REQ_NEW 2250
2225PEM_write_X509_REQ_NEW 2251
2226BIO_callback_ctrl 2252
2227RAND_egd 2253
2228RAND_status 2254
2229bn_dump1 2255
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
index 80384af325..4e2845a4e1 100644
--- a/src/lib/libcrypto/util/mkdef.pl
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -6,26 +6,34 @@
6# prototyped functions: it then prunes the output. 6# prototyped functions: it then prunes the output.
7# 7#
8 8
9$crypto_num="util/libeay.num"; 9my $crypto_num="util/libeay.num";
10$ssl_num= "util/ssleay.num"; 10my $ssl_num= "util/ssleay.num";
11 11
12my $do_update = 0; 12my $do_update = 0;
13my $do_crypto = 0; 13my $do_crypto = 0;
14my $do_ssl = 0; 14my $do_ssl = 0;
15$rsaref = 0; 15my $do_ctest = 0;
16my $rsaref = 0;
16 17
17$W32=1; 18my $W32=1;
18$NT=0; 19my $NT=0;
19# Set this to make typesafe STACK definitions appear in DEF 20# Set this to make typesafe STACK definitions appear in DEF
20$safe_stack_def = 1; 21my $safe_stack_def = 1;
21 22
22$options=""; 23my $options="";
23open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; 24open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
24while(<IN>) { 25while(<IN>) {
25 $options=$1 if (/^OPTIONS=(.*)$/); 26 $options=$1 if (/^OPTIONS=(.*)$/);
26} 27}
27close(IN); 28close(IN);
28 29
30# The following ciphers may be excluded (by Configure). This means functions
31# defined with ifndef(NO_XXX) are not included in the .def file, and everything
32# in directory xxx is ignored.
33my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
34my $no_cast; my $no_md2; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
35my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0;
36
29foreach (@ARGV, split(/ /, $options)) 37foreach (@ARGV, split(/ /, $options))
30 { 38 {
31 $W32=1 if $_ eq "32"; 39 $W32=1 if $_ eq "32";
@@ -39,6 +47,7 @@ foreach (@ARGV, split(/ /, $options))
39 $do_crypto=1 if $_ eq "libeay"; 47 $do_crypto=1 if $_ eq "libeay";
40 $do_crypto=1 if $_ eq "crypto"; 48 $do_crypto=1 if $_ eq "crypto";
41 $do_update=1 if $_ eq "update"; 49 $do_update=1 if $_ eq "update";
50 $do_ctest=1 if $_ eq "ctest";
42 $rsaref=1 if $_ eq "rsaref"; 51 $rsaref=1 if $_ eq "rsaref";
43 52
44 if (/^no-rc2$/) { $no_rc2=1; } 53 if (/^no-rc2$/) { $no_rc2=1; }
@@ -59,6 +68,7 @@ foreach (@ARGV, split(/ /, $options))
59 elsif (/^no-hmac$/) { $no_hmac=1; } 68 elsif (/^no-hmac$/) { $no_hmac=1; }
60 } 69 }
61 70
71
62if (!$do_ssl && !$do_crypto) 72if (!$do_ssl && !$do_crypto)
63 { 73 {
64 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n"; 74 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n";
@@ -70,9 +80,9 @@ $max_ssl = $max_num;
70%crypto_list=&load_numbers($crypto_num); 80%crypto_list=&load_numbers($crypto_num);
71$max_crypto = $max_num; 81$max_crypto = $max_num;
72 82
73$ssl="ssl/ssl.h"; 83my $ssl="ssl/ssl.h";
74 84
75$crypto ="crypto/crypto.h"; 85my $crypto ="crypto/crypto.h";
76$crypto.=" crypto/des/des.h" unless $no_des; 86$crypto.=" crypto/des/des.h" unless $no_des;
77$crypto.=" crypto/idea/idea.h" unless $no_idea; 87$crypto.=" crypto/idea/idea.h" unless $no_idea;
78$crypto.=" crypto/rc4/rc4.h" unless $no_rc4; 88$crypto.=" crypto/rc4/rc4.h" unless $no_rc4;
@@ -115,8 +125,8 @@ $crypto.=" crypto/rand/rand.h";
115$crypto.=" crypto/comp/comp.h"; 125$crypto.=" crypto/comp/comp.h";
116$crypto.=" crypto/tmdiff.h"; 126$crypto.=" crypto/tmdiff.h";
117 127
118@ssl_func = &do_defs("SSLEAY", $ssl); 128my @ssl_func = &do_defs("SSLEAY", $ssl);
119@crypto_func = &do_defs("LIBEAY", $crypto); 129my @crypto_func = &do_defs("LIBEAY", $crypto);
120 130
121 131
122if ($do_update) { 132if ($do_update) {
@@ -131,7 +141,26 @@ if($do_crypto == 1) {
131 open(OUT, ">>$crypto_num"); 141 open(OUT, ">>$crypto_num");
132 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func); 142 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func);
133 close OUT; 143 close OUT;
134} 144}
145
146} elsif ($do_ctest) {
147
148 print <<"EOF";
149
150/* Test file to check all DEF file symbols are present by trying
151 * to link to all of them. This is *not* intended to be run!
152 */
153
154int main()
155{
156EOF
157 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func)
158 if $do_ssl == 1;
159
160 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func)
161 if $do_crypto == 1;
162
163 print "}\n";
135 164
136} else { 165} else {
137 166
@@ -147,14 +176,15 @@ if($do_crypto == 1) {
147sub do_defs 176sub do_defs
148{ 177{
149 my($name,$files)=@_; 178 my($name,$files)=@_;
179 my $file;
150 my @ret; 180 my @ret;
151 my %funcs; 181 my %funcs;
182 my $cpp;
152 183
153 foreach $file (split(/\s+/,$files)) 184 foreach $file (split(/\s+/,$files))
154 { 185 {
155 open(IN,"<$file") || die "unable to open $file:$!\n"; 186 open(IN,"<$file") || die "unable to open $file:$!\n";
156 187 my $line = "", my $def= "";
157 my $line = "", $def= "";
158 my %tag = ( 188 my %tag = (
159 FreeBSD => 0, 189 FreeBSD => 0,
160 NOPROTO => 0, 190 NOPROTO => 0,
@@ -164,6 +194,22 @@ sub do_defs
164 NO_FP_API => 0, 194 NO_FP_API => 0,
165 CONST_STRICT => 0, 195 CONST_STRICT => 0,
166 TRUE => 1, 196 TRUE => 1,
197 NO_RC2 => 0,
198 NO_RC4 => 0,
199 NO_RC5 => 0,
200 NO_IDEA => 0,
201 NO_DES => 0,
202 NO_BF => 0,
203 NO_CAST => 0,
204 NO_MD2 => 0,
205 NO_MD5 => 0,
206 NO_SHA => 0,
207 NO_RIPEMD => 0,
208 NO_MDC2 => 0,
209 NO_RSA => 0,
210 NO_DSA => 0,
211 NO_DH => 0,
212 NO_HMAC => 0,
167 ); 213 );
168 while(<IN>) { 214 while(<IN>) {
169 last if (/BEGIN ERROR CODES/); 215 last if (/BEGIN ERROR CODES/);
@@ -214,6 +260,11 @@ sub do_defs
214 push(@tag,"TRUE"); 260 push(@tag,"TRUE");
215 $tag{"TRUE"}=1; 261 $tag{"TRUE"}=1;
216 next; 262 next;
263 } elsif (/^\#\s*if\s+0/) {
264 # Dummy tag
265 push(@tag,"TRUE");
266 $tag{"TRUE"}=-1;
267 next;
217 } elsif (/^\#/) { 268 } elsif (/^\#/) {
218 next; 269 next;
219 } 270 }
@@ -250,7 +301,20 @@ sub do_defs
250 } 301 }
251 $funcs{"PEM_read_bio_${1}"} = 1; 302 $funcs{"PEM_read_bio_${1}"} = 1;
252 $funcs{"PEM_write_bio_${1}"} = 1; 303 $funcs{"PEM_write_bio_${1}"} = 1;
253 } elsif ( 304 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
305 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
306 if($W32) {
307 $funcs{"PEM_write_${1}"} = 1;
308 }
309 $funcs{"PEM_write_bio_${1}"} = 1;
310 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
311 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
312 if($W32) {
313 $funcs{"PEM_read_${1}"} = 1;
314 }
315 $funcs{"PEM_read_bio_${1}"} = 1;
316 } elsif (
317 ($tag{'TRUE'} != -1) &&
254 ($tag{'FreeBSD'} != 1) && 318 ($tag{'FreeBSD'} != 1) &&
255 ($tag{'CONST_STRICT'} != 1) && 319 ($tag{'CONST_STRICT'} != 1) &&
256 (($W32 && ($tag{'WIN16'} != 1)) || 320 (($W32 && ($tag{'WIN16'} != 1)) ||
@@ -260,7 +324,23 @@ sub do_defs
260 ((!$W32 && $tag{'_WINDLL'} != -1) || 324 ((!$W32 && $tag{'_WINDLL'} != -1) ||
261 ($W32 && $tag{'_WINDLL'} != 1)) && 325 ($W32 && $tag{'_WINDLL'} != 1)) &&
262 ((($tag{'NO_FP_API'} != 1) && $W32) || 326 ((($tag{'NO_FP_API'} != 1) && $W32) ||
263 (($tag{'NO_FP_API'} != -1) && !$W32))) 327 (($tag{'NO_FP_API'} != -1) && !$W32)) &&
328 ($tag{'NO_RC2'} == 0 || !$no_rc2) &&
329 ($tag{'NO_RC4'} == 0 || !$no_rc4) &&
330 ($tag{'NO_RC5'} == 0 || !$no_rc5) &&
331 ($tag{'NO_IDEA'} == 0 || !$no_idea) &&
332 ($tag{'NO_DES'} == 0 || !$no_des) &&
333 ($tag{'NO_BF'} == 0 || !$no_bf) &&
334 ($tag{'NO_CAST'} == 0 || !$no_cast) &&
335 ($tag{'NO_MD2'} == 0 || !$no_md2) &&
336 ($tag{'NO_MD5'} == 0 || !$no_md5) &&
337 ($tag{'NO_SHA'} == 0 || !$no_sha) &&
338 ($tag{'NO_RIPEMD'} == 0 || !$no_ripemd) &&
339 ($tag{'NO_MDC2'} == 0 || !$no_mdc2) &&
340 ($tag{'NO_RSA'} == 0 || !$no_rsa) &&
341 ($tag{'NO_DSA'} == 0 || !$no_dsa) &&
342 ($tag{'NO_DH'} == 0 || !$no_dh) &&
343 ($tag{'NO_HMAC'} == 0 || !$no_hmac))
264 { 344 {
265 if (/{|\/\*/) { # } 345 if (/{|\/\*/) { # }
266 $line = $_; 346 $line = $_;
@@ -309,8 +389,8 @@ sub do_defs
309 # Prune the returned functions 389 # Prune the returned functions
310 390
311 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"}; 391 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"};
312 delete $funcs{"des_crypt"};
313 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref; 392 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref;
393 delete $funcs{"bn_dump1"};
314 394
315 if($W32) { 395 if($W32) {
316 delete $funcs{"BIO_s_file_internal"}; 396 delete $funcs{"BIO_s_file_internal"};
@@ -334,10 +414,31 @@ sub do_defs
334 return(@ret); 414 return(@ret);
335} 415}
336 416
417sub print_test_file
418{
419 (*OUT,my $name,*nums,my @functions)=@_;
420 my $n = 1; my @e; my @r;
421 my $func;
422
423 (@e)=grep(/^SSLeay/,@functions);
424 (@r)=grep(!/^SSLeay/,@functions);
425 @functions=((sort @e),(sort @r));
426
427 foreach $func (@functions) {
428 if (!defined($nums{$func})) {
429 printf STDERR "$func does not have a number assigned\n"
430 if(!$do_update);
431 } else {
432 $n=$nums{$func};
433 print OUT "\t$func();\n";
434 }
435 }
436}
437
337sub print_def_file 438sub print_def_file
338{ 439{
339 (*OUT,my $name,*nums,@functions)=@_; 440 (*OUT,my $name,*nums,my @functions)=@_;
340 my $n =1; 441 my $n = 1; my @e; my @r;
341 442
342 if ($W32) 443 if ($W32)
343 { $name.="32"; } 444 { $name.="32"; }
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
index 4b3bccb13e..ebc059ef22 100644
--- a/src/lib/libcrypto/util/mkerr.pl
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -450,7 +450,7 @@ void ERR_load_${lib}_strings(void)
450#ifdef ${lib}_LIB_NAME 450#ifdef ${lib}_LIB_NAME
451 ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0); 451 ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0);
452 ERR_load_strings(0,${lib}_lib_name); 452 ERR_load_strings(0,${lib}_lib_name);
453#endif; 453#endif
454 } 454 }
455 } 455 }
456 456
diff --git a/src/lib/libcrypto/util/pl/BC-32.pl b/src/lib/libcrypto/util/pl/BC-32.pl
index 09c45a21a6..df6e2c742e 100644
--- a/src/lib/libcrypto/util/pl/BC-32.pl
+++ b/src/lib/libcrypto/util/pl/BC-32.pl
@@ -19,7 +19,7 @@ $out_def="out32";
19$tmp_def="tmp32"; 19$tmp_def="tmp32";
20$inc_def="inc32"; 20$inc_def="inc32";
21#enable max error messages, disable most common warnings 21#enable max error messages, disable most common warnings
22$cflags="-DWIN32_LEAN_AND_MEAN -j255 -w-aus -w-par -w-inl -c -tWC -tWM -DWINDOWS -DWIN32 -DL_ENDIAN "; 22$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl -c -tWC -tWM -DWINDOWS -DWIN32 -DL_ENDIAN ";
23if ($debug) 23if ($debug)
24{ 24{
25 $cflags.="-Od -y -v -vi- -D_DEBUG"; 25 $cflags.="-Od -y -v -vi- -D_DEBUG";
diff --git a/src/lib/libcrypto/util/pl/Mingw32.pl b/src/lib/libcrypto/util/pl/Mingw32.pl
index 84c2a22db3..585cacd820 100644
--- a/src/lib/libcrypto/util/pl/Mingw32.pl
+++ b/src/lib/libcrypto/util/pl/Mingw32.pl
@@ -17,7 +17,7 @@ $mkdir='gmkdir';
17 17
18$cc='gcc'; 18$cc='gcc';
19if ($debug) 19if ($debug)
20 { $cflags="-g2 -ggdb"; } 20 { $cflags="-DL_ENDIAN -g2 -ggdb"; }
21else 21else
22 { $cflags="-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall"; } 22 { $cflags="-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall"; }
23 23
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
index 6db1c9fe23..046f0e253c 100644
--- a/src/lib/libcrypto/util/pl/VC-32.pl
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -22,7 +22,7 @@ $inc_def="inc32";
22 22
23if ($debug) 23if ($debug)
24 { 24 {
25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWINDOWS -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG"; 25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG";
26 $lflags.=" /debug"; 26 $lflags.=" /debug";
27 $mlflags.=' /debug'; 27 $mlflags.=' /debug';
28 } 28 }
diff --git a/src/lib/libcrypto/util/pod2man.pl b/src/lib/libcrypto/util/pod2man.pl
new file mode 100644
index 0000000000..f5ec0767ed
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2man.pl
@@ -0,0 +1,1181 @@
1: #!/usr/bin/perl-5.005
2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
4
5$DEF_PM_SECTION = '3pm' || '3';
6
7=head1 NAME
8
9pod2man - translate embedded Perl pod directives into man pages
10
11=head1 SYNOPSIS
12
13B<pod2man>
14[ B<--section=>I<manext> ]
15[ B<--release=>I<relpatch> ]
16[ B<--center=>I<string> ]
17[ B<--date=>I<string> ]
18[ B<--fixed=>I<font> ]
19[ B<--official> ]
20[ B<--lax> ]
21I<inputfile>
22
23=head1 DESCRIPTION
24
25B<pod2man> converts its input file containing embedded pod directives (see
26L<perlpod>) into nroff source suitable for viewing with nroff(1) or
27troff(1) using the man(7) macro set.
28
29Besides the obvious pod conversions, B<pod2man> also takes care of
30func(), func(n), and simple variable references like $foo or @bar so
31you don't have to use code escapes for them; complex expressions like
32C<$fred{'stuff'}> will still need to be escaped, though. Other nagging
33little roffish things that it catches include translating the minus in
34something like foo-bar, making a long dash--like this--into a real em
35dash, fixing up "paired quotes", putting a little space after the
36parens in something like func(), making C++ and PI look right, making
37double underbars have a little tiny space between them, making ALLCAPS
38a teeny bit smaller in troff(1), and escaping backslashes so you don't
39have to.
40
41=head1 OPTIONS
42
43=over 8
44
45=item center
46
47Set the centered header to a specific string. The default is
48"User Contributed Perl Documentation", unless the C<--official> flag is
49given, in which case the default is "Perl Programmers Reference Guide".
50
51=item date
52
53Set the left-hand footer string to this value. By default,
54the modification date of the input file will be used.
55
56=item fixed
57
58The fixed font to use for code refs. Defaults to CW.
59
60=item official
61
62Set the default header to indicate that this page is of
63the standard release in case C<--center> is not given.
64
65=item release
66
67Set the centered footer. By default, this is the current
68perl release.
69
70=item section
71
72Set the section for the C<.TH> macro. The standard conventions on
73sections are to use 1 for user commands, 2 for system calls, 3 for
74functions, 4 for devices, 5 for file formats, 6 for games, 7 for
75miscellaneous information, and 8 for administrator commands. This works
76best if you put your Perl man pages in a separate tree, like
77F</usr/local/perl/man/>. By default, section 1 will be used
78unless the file ends in F<.pm> in which case section 3 will be selected.
79
80=item lax
81
82Don't complain when required sections aren't present.
83
84=back
85
86=head1 Anatomy of a Proper Man Page
87
88For those not sure of the proper layout of a man page, here's
89an example of the skeleton of a proper man page. Head of the
90major headers should be setout as a C<=head1> directive, and
91are historically written in the rather startling ALL UPPER CASE
92format, although this is not mandatory.
93Minor headers may be included using C<=head2>, and are
94typically in mixed case.
95
96=over 10
97
98=item NAME
99
100Mandatory section; should be a comma-separated list of programs or
101functions documented by this podpage, such as:
102
103 foo, bar - programs to do something
104
105=item SYNOPSIS
106
107A short usage summary for programs and functions, which
108may someday be deemed mandatory.
109
110=item DESCRIPTION
111
112Long drawn out discussion of the program. It's a good idea to break this
113up into subsections using the C<=head2> directives, like
114
115 =head2 A Sample Subection
116
117 =head2 Yet Another Sample Subection
118
119=item OPTIONS
120
121Some people make this separate from the description.
122
123=item RETURN VALUE
124
125What the program or function returns if successful.
126
127=item ERRORS
128
129Exceptions, return codes, exit stati, and errno settings.
130
131=item EXAMPLES
132
133Give some example uses of the program.
134
135=item ENVIRONMENT
136
137Envariables this program might care about.
138
139=item FILES
140
141All files used by the program. You should probably use the FE<lt>E<gt>
142for these.
143
144=item SEE ALSO
145
146Other man pages to check out, like man(1), man(7), makewhatis(8), or catman(8).
147
148=item NOTES
149
150Miscellaneous commentary.
151
152=item CAVEATS
153
154Things to take special care with; sometimes called WARNINGS.
155
156=item DIAGNOSTICS
157
158All possible messages the program can print out--and
159what they mean.
160
161=item BUGS
162
163Things that are broken or just don't work quite right.
164
165=item RESTRICTIONS
166
167Bugs you don't plan to fix :-)
168
169=item AUTHOR
170
171Who wrote it (or AUTHORS if multiple).
172
173=item HISTORY
174
175Programs derived from other sources sometimes have this, or
176you might keep a modification log here.
177
178=back
179
180=head1 EXAMPLES
181
182 pod2man program > program.1
183 pod2man some_module.pm > /usr/perl/man/man3/some_module.3
184 pod2man --section=7 note.pod > note.7
185
186=head1 DIAGNOSTICS
187
188The following diagnostics are generated by B<pod2man>. Items
189marked "(W)" are non-fatal, whereas the "(F)" errors will cause
190B<pod2man> to immediately exit with a non-zero status.
191
192=over 4
193
194=item bad option in paragraph %d of %s: ``%s'' should be [%s]<%s>
195
196(W) If you start include an option, you should set it off
197as bold, italic, or code.
198
199=item can't open %s: %s
200
201(F) The input file wasn't available for the given reason.
202
203=item Improper man page - no dash in NAME header in paragraph %d of %s
204
205(W) The NAME header did not have an isolated dash in it. This is
206considered important.
207
208=item Invalid man page - no NAME line in %s
209
210(F) You did not include a NAME header, which is essential.
211
212=item roff font should be 1 or 2 chars, not `%s' (F)
213
214(F) The font specified with the C<--fixed> option was not
215a one- or two-digit roff font.
216
217=item %s is missing required section: %s
218
219(W) Required sections include NAME, DESCRIPTION, and if you're
220using a section starting with a 3, also a SYNOPSIS. Actually,
221not having a NAME is a fatal.
222
223=item Unknown escape: %s in %s
224
225(W) An unknown HTML entity (probably for an 8-bit character) was given via
226a C<EE<lt>E<gt>> directive. Besides amp, lt, gt, and quot, recognized
227entities are Aacute, aacute, Acirc, acirc, AElig, aelig, Agrave, agrave,
228Aring, aring, Atilde, atilde, Auml, auml, Ccedil, ccedil, Eacute, eacute,
229Ecirc, ecirc, Egrave, egrave, ETH, eth, Euml, euml, Iacute, iacute, Icirc,
230icirc, Igrave, igrave, Iuml, iuml, Ntilde, ntilde, Oacute, oacute, Ocirc,
231ocirc, Ograve, ograve, Oslash, oslash, Otilde, otilde, Ouml, ouml, szlig,
232THORN, thorn, Uacute, uacute, Ucirc, ucirc, Ugrave, ugrave, Uuml, uuml,
233Yacute, yacute, and yuml.
234
235=item Unmatched =back
236
237(W) You have a C<=back> without a corresponding C<=over>.
238
239=item Unrecognized pod directive: %s
240
241(W) You specified a pod directive that isn't in the known list of
242C<=head1>, C<=head2>, C<=item>, C<=over>, C<=back>, or C<=cut>.
243
244
245=back
246
247=head1 NOTES
248
249If you would like to print out a lot of man page continuously, you
250probably want to set the C and D registers to set contiguous page
251numbering and even/odd paging, at least on some versions of man(7).
252Settting the F register will get you some additional experimental
253indexing:
254
255 troff -man -rC1 -rD1 -rF1 perl.1 perldata.1 perlsyn.1 ...
256
257The indexing merely outputs messages via C<.tm> for each
258major page, section, subsection, item, and any C<XE<lt>E<gt>>
259directives.
260
261
262=head1 RESTRICTIONS
263
264None at this time.
265
266=head1 BUGS
267
268The =over and =back directives don't really work right. They
269take absolute positions instead of offsets, don't nest well, and
270making people count is suboptimal in any event.
271
272=head1 AUTHORS
273
274Original prototype by Larry Wall, but so massively hacked over by
275Tom Christiansen such that Larry probably doesn't recognize it anymore.
276
277=cut
278
279$/ = "";
280$cutting = 1;
281@Indices = ();
282
283# We try first to get the version number from a local binary, in case we're
284# running an installed version of Perl to produce documentation from an
285# uninstalled newer version's pod files.
286if ($^O ne 'plan9' and $^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32') {
287 my $perl = (-x './perl' && -f './perl' ) ?
288 './perl' :
289 ((-x '../perl' && -f '../perl') ?
290 '../perl' :
291 '');
292 ($version,$patch) = `$perl -e 'print $]'` =~ /^(\d\.\d{3})(\d{2})?/ if $perl;
293}
294# No luck; we'll just go with the running Perl's version
295($version,$patch) = $] =~ /^(.{5})(\d{2})?/ unless $version;
296$DEF_RELEASE = "perl $version";
297$DEF_RELEASE .= ", patch $patch" if $patch;
298
299
300sub makedate {
301 my $secs = shift;
302 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs);
303 my $mname = (qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec})[$mon];
304 $year += 1900;
305 return "$mday/$mname/$year";
306}
307
308use Getopt::Long;
309
310$DEF_SECTION = 1;
311$DEF_CENTER = "User Contributed Perl Documentation";
312$STD_CENTER = "Perl Programmers Reference Guide";
313$DEF_FIXED = 'CW';
314$DEF_LAX = 0;
315
316sub usage {
317 warn "$0: @_\n" if @_;
318 die <<EOF;
319usage: $0 [options] podpage
320Options are:
321 --section=manext (default "$DEF_SECTION")
322 --release=relpatch (default "$DEF_RELEASE")
323 --center=string (default "$DEF_CENTER")
324 --date=string (default "$DEF_DATE")
325 --fixed=font (default "$DEF_FIXED")
326 --official (default NOT)
327 --lax (default NOT)
328EOF
329}
330
331$uok = GetOptions( qw(
332 section=s
333 release=s
334 center=s
335 date=s
336 fixed=s
337 official
338 lax
339 help));
340
341$DEF_DATE = makedate((stat($ARGV[0]))[9] || time());
342
343usage("Usage error!") unless $uok;
344usage() if $opt_help;
345usage("Need one and only one podpage argument") unless @ARGV == 1;
346
347$section = $opt_section || ($ARGV[0] =~ /\.pm$/
348 ? $DEF_PM_SECTION : $DEF_SECTION);
349$RP = $opt_release || $DEF_RELEASE;
350$center = $opt_center || ($opt_official ? $STD_CENTER : $DEF_CENTER);
351$lax = $opt_lax || $DEF_LAX;
352
353$CFont = $opt_fixed || $DEF_FIXED;
354
355if (length($CFont) == 2) {
356 $CFont_embed = "\\f($CFont";
357}
358elsif (length($CFont) == 1) {
359 $CFont_embed = "\\f$CFont";
360}
361else {
362 die "roff font should be 1 or 2 chars, not `$CFont_embed'";
363}
364
365$date = $opt_date || $DEF_DATE;
366
367for (qw{NAME DESCRIPTION}) {
368# for (qw{NAME DESCRIPTION AUTHOR}) {
369 $wanna_see{$_}++;
370}
371$wanna_see{SYNOPSIS}++ if $section =~ /^3/;
372
373
374$name = @ARGV ? $ARGV[0] : "<STDIN>";
375$Filename = $name;
376if ($section =~ /^1/) {
377 require File::Basename;
378 $name = uc File::Basename::basename($name);
379}
380$name =~ s/\.(pod|p[lm])$//i;
381
382# Lose everything up to the first of
383# */lib/*perl* standard or site_perl module
384# */*perl*/lib from -D prefix=/opt/perl
385# */*perl*/ random module hierarchy
386# which works.
387$name =~ s-//+-/-g;
388if ($name =~ s-^.*?/lib/[^/]*perl[^/]*/--i
389 or $name =~ s-^.*?/[^/]*perl[^/]*/lib/--i
390 or $name =~ s-^.*?/[^/]*perl[^/]*/--i) {
391 # Lose ^site(_perl)?/.
392 $name =~ s-^site(_perl)?/--;
393 # Lose ^arch/. (XXX should we use Config? Just for archname?)
394 $name =~ s~^(.*-$^O|$^O-.*)/~~o;
395 # Lose ^version/.
396 $name =~ s-^\d+\.\d+/--;
397}
398
399# Translate Getopt/Long to Getopt::Long, etc.
400$name =~ s(/)(::)g;
401
402if ($name ne 'something') {
403 FCHECK: {
404 open(F, "< $ARGV[0]") || die "can't open $ARGV[0]: $!";
405 while (<F>) {
406 next unless /^=\b/;
407 if (/^=head1\s+NAME\s*$/) { # an /m would forgive mistakes
408 $_ = <F>;
409 unless (/\s*-+\s+/) {
410 $oops++;
411 warn "$0: Improper man page - no dash in NAME header in paragraph $. of $ARGV[0]\n"
412 } else {
413 my @n = split /\s+-+\s+/;
414 if (@n != 2) {
415 $oops++;
416 warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
417 }
418 else {
419 %namedesc = @n;
420 }
421 }
422 last FCHECK;
423 }
424 next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME
425 next if /^=pod\b/; # It is OK to have =pod before NAME
426 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
427 }
428 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
429 }
430 close F;
431}
432
433print <<"END";
434.rn '' }`
435''' \$RCSfile\$\$Revision\$\$Date\$
436'''
437''' \$Log\$
438'''
439.de Sh
440.br
441.if t .Sp
442.ne 5
443.PP
444\\fB\\\\\$1\\fR
445.PP
446..
447.de Sp
448.if t .sp .5v
449.if n .sp
450..
451.de Ip
452.br
453.ie \\\\n(.\$>=3 .ne \\\\\$3
454.el .ne 3
455.IP "\\\\\$1" \\\\\$2
456..
457.de Vb
458.ft $CFont
459.nf
460.ne \\\\\$1
461..
462.de Ve
463.ft R
464
465.fi
466..
467'''
468'''
469''' Set up \\*(-- to give an unbreakable dash;
470''' string Tr holds user defined translation string.
471''' Bell System Logo is used as a dummy character.
472'''
473.tr \\(*W-|\\(bv\\*(Tr
474.ie n \\{\\
475.ds -- \\(*W-
476.ds PI pi
477.if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
478.if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
479.ds L" ""
480.ds R" ""
481''' \\*(M", \\*(S", \\*(N" and \\*(T" are the equivalent of
482''' \\*(L" and \\*(R", except that they are used on ".xx" lines,
483''' such as .IP and .SH, which do another additional levels of
484''' double-quote interpretation
485.ds M" """
486.ds S" """
487.ds N" """""
488.ds T" """""
489.ds L' '
490.ds R' '
491.ds M' '
492.ds S' '
493.ds N' '
494.ds T' '
495'br\\}
496.el\\{\\
497.ds -- \\(em\\|
498.tr \\*(Tr
499.ds L" ``
500.ds R" ''
501.ds M" ``
502.ds S" ''
503.ds N" ``
504.ds T" ''
505.ds L' `
506.ds R' '
507.ds M' `
508.ds S' '
509.ds N' `
510.ds T' '
511.ds PI \\(*p
512'br\\}
513END
514
515print <<'END';
516.\" If the F register is turned on, we'll generate
517.\" index entries out stderr for the following things:
518.\" TH Title
519.\" SH Header
520.\" Sh Subsection
521.\" Ip Item
522.\" X<> Xref (embedded
523.\" Of course, you have to process the output yourself
524.\" in some meaninful fashion.
525.if \nF \{
526.de IX
527.tm Index:\\$1\t\\n%\t"\\$2"
528..
529.nr % 0
530.rr F
531.\}
532END
533
534print <<"END";
535.TH $name $section "$RP" "$date" "$center"
536.UC
537END
538
539push(@Indices, qq{.IX Title "$name $section"});
540
541while (($name, $desc) = each %namedesc) {
542 for ($name, $desc) { s/^\s+//; s/\s+$//; }
543 push(@Indices, qq(.IX Name "$name - $desc"\n));
544}
545
546print <<'END';
547.if n .hy 0
548.if n .na
549.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
550.de CQ \" put $1 in typewriter font
551END
552print ".ft $CFont\n";
553print <<'END';
554'if n "\c
555'if t \\&\\$1\c
556'if n \\&\\$1\c
557'if n \&"
558\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
559'.ft R
560..
561.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
562. \" AM - accent mark definitions
563.bd B 3
564. \" fudge factors for nroff and troff
565.if n \{\
566. ds #H 0
567. ds #V .8m
568. ds #F .3m
569. ds #[ \f1
570. ds #] \fP
571.\}
572.if t \{\
573. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
574. ds #V .6m
575. ds #F 0
576. ds #[ \&
577. ds #] \&
578.\}
579. \" simple accents for nroff and troff
580.if n \{\
581. ds ' \&
582. ds ` \&
583. ds ^ \&
584. ds , \&
585. ds ~ ~
586. ds ? ?
587. ds ! !
588. ds /
589. ds q
590.\}
591.if t \{\
592. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
593. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
594. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
595. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
596. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
597. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
598. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
599. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
600. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
601.\}
602. \" troff and (daisy-wheel) nroff accents
603.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
604.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
605.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
606.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
607.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
608.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
609.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
610.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
611.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
612.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
613.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
614.ds ae a\h'-(\w'a'u*4/10)'e
615.ds Ae A\h'-(\w'A'u*4/10)'E
616.ds oe o\h'-(\w'o'u*4/10)'e
617.ds Oe O\h'-(\w'O'u*4/10)'E
618. \" corrections for vroff
619.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
620.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
621. \" for low resolution devices (crt and lpr)
622.if \n(.H>23 .if \n(.V>19 \
623\{\
624. ds : e
625. ds 8 ss
626. ds v \h'-1'\o'\(aa\(ga'
627. ds _ \h'-1'^
628. ds . \h'-1'.
629. ds 3 3
630. ds o a
631. ds d- d\h'-1'\(ga
632. ds D- D\h'-1'\(hy
633. ds th \o'bp'
634. ds Th \o'LP'
635. ds ae ae
636. ds Ae AE
637. ds oe oe
638. ds Oe OE
639.\}
640.rm #[ #] #H #V #F C
641END
642
643$indent = 0;
644
645$begun = "";
646
647# Unrolling [^A-Z>]|[A-Z](?!<) gives: // MRE pp 165.
648my $nonest = '(?:[^A-Z>]*(?:[A-Z](?!<)[^A-Z>]*)*)';
649
650while (<>) {
651 if ($cutting) {
652 next unless /^=/;
653 $cutting = 0;
654 }
655 if ($begun) {
656 if (/^=end\s+$begun/) {
657 $begun = "";
658 }
659 elsif ($begun =~ /^(roff|man)$/) {
660 print STDOUT $_;
661 }
662 next;
663 }
664 chomp;
665
666 # Translate verbatim paragraph
667
668 if (/^\s/) {
669 @lines = split(/\n/);
670 for (@lines) {
671 1 while s
672 {^( [^\t]* ) \t ( \t* ) }
673 { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
674 s/\\/\\e/g;
675 s/\A/\\&/s;
676 }
677 $lines = @lines;
678 makespace() unless $verbatim++;
679 print ".Vb $lines\n";
680 print join("\n", @lines), "\n";
681 print ".Ve\n";
682 $needspace = 0;
683 next;
684 }
685
686 $verbatim = 0;
687
688 if (/^=for\s+(\S+)\s*/s) {
689 if ($1 eq "man" or $1 eq "roff") {
690 print STDOUT $',"\n\n";
691 } else {
692 # ignore unknown for
693 }
694 next;
695 }
696 elsif (/^=begin\s+(\S+)\s*/s) {
697 $begun = $1;
698 if ($1 eq "man" or $1 eq "roff") {
699 print STDOUT $'."\n\n";
700 }
701 next;
702 }
703
704 # check for things that'll hosed our noremap scheme; affects $_
705 init_noremap();
706
707 if (!/^=item/) {
708
709 # trofficate backslashes; must do it before what happens below
710 s/\\/noremap('\\e')/ge;
711
712 # protect leading periods and quotes against *roff
713 # mistaking them for directives
714 s/^(?:[A-Z]<)?[.']/\\&$&/gm;
715
716 # first hide the escapes in case we need to
717 # intuit something and get it wrong due to fmting
718
719 1 while s/([A-Z]<$nonest>)/noremap($1)/ge;
720
721 # func() is a reference to a perl function
722 s{
723 \b
724 (
725 [:\w]+ \(\)
726 )
727 } {I<$1>}gx;
728
729 # func(n) is a reference to a perl function or a man page
730 s{
731 ([:\w]+)
732 (
733 \( [^\051]+ \)
734 )
735 } {I<$1>\\|$2}gx;
736
737 # convert simple variable references
738 s/(\s+)([\$\@%][\w:]+)(?!\()/${1}C<$2>/g;
739
740 if (m{ (
741 [\-\w]+
742 \(
743 [^\051]*?
744 [\@\$,]
745 [^\051]*?
746 \)
747 )
748 }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
749 {
750 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [LCI]<$1>\n";
751 $oops++;
752 }
753
754 while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
755 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [CB]<$1>\n";
756 $oops++;
757 }
758
759 # put it back so we get the <> processed again;
760 clear_noremap(0); # 0 means leave the E's
761
762 } else {
763 # trofficate backslashes
764 s/\\/noremap('\\e')/ge;
765
766 }
767
768 # need to hide E<> first; they're processed in clear_noremap
769 s/(E<[^<>]+>)/noremap($1)/ge;
770
771
772 $maxnest = 10;
773 while ($maxnest-- && /[A-Z]</) {
774
775 # can't do C font here
776 s/([BI])<($nonest)>/font($1) . $2 . font('R')/eg;
777
778 # files and filelike refs in italics
779 s/F<($nonest)>/I<$1>/g;
780
781 # no break -- usually we want C<> for this
782 s/S<($nonest)>/nobreak($1)/eg;
783
784 # LREF: a la HREF L<show this text|man/section>
785 s:L<([^|>]+)\|[^>]+>:$1:g;
786
787 # LREF: a manpage(3f)
788 s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
789
790 # LREF: an =item on another manpage
791 s{
792 L<
793 ([^/]+)
794 /
795 (
796 [:\w]+
797 (\(\))?
798 )
799 >
800 } {the C<$2> entry in the I<$1> manpage}gx;
801
802 # LREF: an =item on this manpage
803 s{
804 ((?:
805 L<
806 /
807 (
808 [:\w]+
809 (\(\))?
810 )
811 >
812 (,?\s+(and\s+)?)?
813 )+)
814 } { internal_lrefs($1) }gex;
815
816 # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
817 # the "func" can disambiguate
818 s{
819 L<
820 (?:
821 ([a-zA-Z]\S+?) /
822 )?
823 "?(.*?)"?
824 >
825 }{
826 do {
827 $1 # if no $1, assume it means on this page.
828 ? "the section on I<$2> in the I<$1> manpage"
829 : "the section on I<$2>"
830 }
831 }gesx; # s in case it goes over multiple lines, so . matches \n
832
833 s/Z<>/\\&/g;
834
835 # comes last because not subject to reprocessing
836 s/C<($nonest)>/noremap("${CFont_embed}${1}\\fR")/eg;
837 }
838
839 if (s/^=//) {
840 $needspace = 0; # Assume this.
841
842 s/\n/ /g;
843
844 ($Cmd, $_) = split(' ', $_, 2);
845
846 $dotlevel = 1;
847 if ($Cmd eq 'head1') {
848 $dotlevel = 1;
849 }
850 elsif ($Cmd eq 'head2') {
851 $dotlevel = 1;
852 }
853 elsif ($Cmd eq 'item') {
854 $dotlevel = 2;
855 }
856
857 if (defined $_) {
858 &escapes($dotlevel);
859 s/"/""/g;
860 }
861
862 clear_noremap(1);
863
864 if ($Cmd eq 'cut') {
865 $cutting = 1;
866 }
867 elsif ($Cmd eq 'head1') {
868 s/\s+$//;
869 delete $wanna_see{$_} if exists $wanna_see{$_};
870 print qq{.SH "$_"\n};
871 push(@Indices, qq{.IX Header "$_"\n});
872 }
873 elsif ($Cmd eq 'head2') {
874 print qq{.Sh "$_"\n};
875 push(@Indices, qq{.IX Subsection "$_"\n});
876 }
877 elsif ($Cmd eq 'over') {
878 push(@indent,$indent);
879 $indent += ($_ + 0) || 5;
880 }
881 elsif ($Cmd eq 'back') {
882 $indent = pop(@indent);
883 warn "$0: Unmatched =back in paragraph $. of $ARGV\n" unless defined $indent;
884 $needspace = 1;
885 }
886 elsif ($Cmd eq 'item') {
887 s/^\*( |$)/\\(bu$1/g;
888 # if you know how to get ":s please do
889 s/\\\*\(L"([^"]+?)\\\*\(R"/'$1'/g;
890 s/\\\*\(L"([^"]+?)""/'$1'/g;
891 s/[^"]""([^"]+?)""[^"]/'$1'/g;
892 # here do something about the $" in perlvar?
893 print STDOUT qq{.Ip "$_" $indent\n};
894 push(@Indices, qq{.IX Item "$_"\n});
895 }
896 elsif ($Cmd eq 'pod') {
897 # this is just a comment
898 }
899 else {
900 warn "$0: Unrecognized pod directive in paragraph $. of $ARGV: $Cmd\n";
901 }
902 }
903 else {
904 if ($needspace) {
905 &makespace;
906 }
907 &escapes(0);
908 clear_noremap(1);
909 print $_, "\n";
910 $needspace = 1;
911 }
912}
913
914print <<"END";
915
916.rn }` ''
917END
918
919if (%wanna_see && !$lax) {
920 @missing = keys %wanna_see;
921 warn "$0: $Filename is missing required section"
922 . (@missing > 1 && "s")
923 . ": @missing\n";
924 $oops++;
925}
926
927foreach (@Indices) { print "$_\n"; }
928
929exit;
930#exit ($oops != 0);
931
932#########################################################################
933
934sub nobreak {
935 my $string = shift;
936 $string =~ s/ /\\ /g;
937 $string;
938}
939
940sub escapes {
941 my $indot = shift;
942
943 s/X<(.*?)>/mkindex($1)/ge;
944
945 # translate the minus in foo-bar into foo\-bar for roff
946 s/([^0-9a-z-])-([^-])/$1\\-$2/g;
947
948 # make -- into the string version \*(-- (defined above)
949 s/\b--\b/\\*(--/g;
950 s/"--([^"])/"\\*(--$1/g; # should be a better way
951 s/([^"])--"/$1\\*(--"/g;
952
953 # fix up quotes; this is somewhat tricky
954 my $dotmacroL = 'L';
955 my $dotmacroR = 'R';
956 if ( $indot == 1 ) {
957 $dotmacroL = 'M';
958 $dotmacroR = 'S';
959 }
960 elsif ( $indot >= 2 ) {
961 $dotmacroL = 'N';
962 $dotmacroR = 'T';
963 }
964 if (!/""/) {
965 s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
966 s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
967 }
968
969 #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
970 #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
971
972
973 # make sure that func() keeps a bit a space tween the parens
974 ### s/\b\(\)/\\|()/g;
975 ### s/\b\(\)/(\\|)/g;
976
977 # make C++ into \*C+, which is a squinched version (defined above)
978 s/\bC\+\+/\\*(C+/g;
979
980 # make double underbars have a little tiny space between them
981 s/__/_\\|_/g;
982
983 # PI goes to \*(PI (defined above)
984 s/\bPI\b/noremap('\\*(PI')/ge;
985
986 # make all caps a teeny bit smaller, but don't muck with embedded code literals
987 my $hidCFont = font('C');
988 if ($Cmd !~ /^head1/) { # SH already makes smaller
989 # /g isn't enough; 1 while or we'll be off
990
991# 1 while s{
992# (?!$hidCFont)(..|^.|^)
993# \b
994# (
995# [A-Z][\/A-Z+:\-\d_$.]+
996# )
997# (s?)
998# \b
999# } {$1\\s-1$2\\s0}gmox;
1000
1001 1 while s{
1002 (?!$hidCFont)(..|^.|^)
1003 (
1004 \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
1005 )
1006 } {
1007 $1 . noremap( '\\s-1' . $2 . '\\s0' )
1008 }egmox;
1009
1010 }
1011}
1012
1013# make troff just be normal, but make small nroff get quoted
1014# decided to just put the quotes in the text; sigh;
1015sub ccvt {
1016 local($_,$prev) = @_;
1017 noremap(qq{.CQ "$_" \n\\&});
1018}
1019
1020sub makespace {
1021 if ($indent) {
1022 print ".Sp\n";
1023 }
1024 else {
1025 print ".PP\n";
1026 }
1027}
1028
1029sub mkindex {
1030 my ($entry) = @_;
1031 my @entries = split m:\s*/\s*:, $entry;
1032 push @Indices, ".IX Xref " . join ' ', map {qq("$_")} @entries;
1033 return '';
1034}
1035
1036sub font {
1037 local($font) = shift;
1038 return '\\f' . noremap($font);
1039}
1040
1041sub noremap {
1042 local($thing_to_hide) = shift;
1043 $thing_to_hide =~ tr/\000-\177/\200-\377/;
1044 return $thing_to_hide;
1045}
1046
1047sub init_noremap {
1048 # escape high bit characters in input stream
1049 s/([\200-\377])/"E<".ord($1).">"/ge;
1050}
1051
1052sub clear_noremap {
1053 my $ready_to_print = $_[0];
1054
1055 tr/\200-\377/\000-\177/;
1056
1057 # trofficate backslashes
1058 # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
1059
1060 # now for the E<>s, which have been hidden until now
1061 # otherwise the interative \w<> processing would have
1062 # been hosed by the E<gt>
1063 s {
1064 E<
1065 (
1066 ( \d + )
1067 | ( [A-Za-z]+ )
1068 )
1069 >
1070 } {
1071 do {
1072 defined $2
1073 ? chr($2)
1074 :
1075 exists $HTML_Escapes{$3}
1076 ? do { $HTML_Escapes{$3} }
1077 : do {
1078 warn "$0: Unknown escape in paragraph $. of $ARGV: ``$&''\n";
1079 "E<$1>";
1080 }
1081 }
1082 }egx if $ready_to_print;
1083}
1084
1085sub internal_lrefs {
1086 local($_) = shift;
1087 local $trailing_and = s/and\s+$// ? "and " : "";
1088
1089 s{L</([^>]+)>}{$1}g;
1090 my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
1091 my $retstr = "the ";
1092 my $i;
1093 for ($i = 0; $i <= $#items; $i++) {
1094 $retstr .= "C<$items[$i]>";
1095 $retstr .= ", " if @items > 2 && $i != $#items;
1096 $retstr .= " and " if $i+2 == @items;
1097 }
1098
1099 $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
1100 . " elsewhere in this document";
1101 # terminal space to avoid words running together (pattern used
1102 # strips terminal spaces)
1103 $retstr .= " " if length $trailing_and;
1104 $retstr .= $trailing_and;
1105
1106 return $retstr;
1107
1108}
1109
1110BEGIN {
1111%HTML_Escapes = (
1112 'amp' => '&', # ampersand
1113 'lt' => '<', # left chevron, less-than
1114 'gt' => '>', # right chevron, greater-than
1115 'quot' => '"', # double quote
1116
1117 "Aacute" => "A\\*'", # capital A, acute accent
1118 "aacute" => "a\\*'", # small a, acute accent
1119 "Acirc" => "A\\*^", # capital A, circumflex accent
1120 "acirc" => "a\\*^", # small a, circumflex accent
1121 "AElig" => '\*(AE', # capital AE diphthong (ligature)
1122 "aelig" => '\*(ae', # small ae diphthong (ligature)
1123 "Agrave" => "A\\*`", # capital A, grave accent
1124 "agrave" => "A\\*`", # small a, grave accent
1125 "Aring" => 'A\\*o', # capital A, ring
1126 "aring" => 'a\\*o', # small a, ring
1127 "Atilde" => 'A\\*~', # capital A, tilde
1128 "atilde" => 'a\\*~', # small a, tilde
1129 "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
1130 "auml" => 'a\\*:', # small a, dieresis or umlaut mark
1131 "Ccedil" => 'C\\*,', # capital C, cedilla
1132 "ccedil" => 'c\\*,', # small c, cedilla
1133 "Eacute" => "E\\*'", # capital E, acute accent
1134 "eacute" => "e\\*'", # small e, acute accent
1135 "Ecirc" => "E\\*^", # capital E, circumflex accent
1136 "ecirc" => "e\\*^", # small e, circumflex accent
1137 "Egrave" => "E\\*`", # capital E, grave accent
1138 "egrave" => "e\\*`", # small e, grave accent
1139 "ETH" => '\\*(D-', # capital Eth, Icelandic
1140 "eth" => '\\*(d-', # small eth, Icelandic
1141 "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
1142 "euml" => "e\\*:", # small e, dieresis or umlaut mark
1143 "Iacute" => "I\\*'", # capital I, acute accent
1144 "iacute" => "i\\*'", # small i, acute accent
1145 "Icirc" => "I\\*^", # capital I, circumflex accent
1146 "icirc" => "i\\*^", # small i, circumflex accent
1147 "Igrave" => "I\\*`", # capital I, grave accent
1148 "igrave" => "i\\*`", # small i, grave accent
1149 "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
1150 "iuml" => "i\\*:", # small i, dieresis or umlaut mark
1151 "Ntilde" => 'N\*~', # capital N, tilde
1152 "ntilde" => 'n\*~', # small n, tilde
1153 "Oacute" => "O\\*'", # capital O, acute accent
1154 "oacute" => "o\\*'", # small o, acute accent
1155 "Ocirc" => "O\\*^", # capital O, circumflex accent
1156 "ocirc" => "o\\*^", # small o, circumflex accent
1157 "Ograve" => "O\\*`", # capital O, grave accent
1158 "ograve" => "o\\*`", # small o, grave accent
1159 "Oslash" => "O\\*/", # capital O, slash
1160 "oslash" => "o\\*/", # small o, slash
1161 "Otilde" => "O\\*~", # capital O, tilde
1162 "otilde" => "o\\*~", # small o, tilde
1163 "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
1164 "ouml" => "o\\*:", # small o, dieresis or umlaut mark
1165 "szlig" => '\*8', # small sharp s, German (sz ligature)
1166 "THORN" => '\\*(Th', # capital THORN, Icelandic
1167 "thorn" => '\\*(th',, # small thorn, Icelandic
1168 "Uacute" => "U\\*'", # capital U, acute accent
1169 "uacute" => "u\\*'", # small u, acute accent
1170 "Ucirc" => "U\\*^", # capital U, circumflex accent
1171 "ucirc" => "u\\*^", # small u, circumflex accent
1172 "Ugrave" => "U\\*`", # capital U, grave accent
1173 "ugrave" => "u\\*`", # small u, grave accent
1174 "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
1175 "uuml" => "u\\*:", # small u, dieresis or umlaut mark
1176 "Yacute" => "Y\\*'", # capital Y, acute accent
1177 "yacute" => "y\\*'", # small y, acute accent
1178 "yuml" => "y\\*:", # small y, dieresis or umlaut mark
1179);
1180}
1181
diff --git a/src/lib/libcrypto/util/selftest.pl b/src/lib/libcrypto/util/selftest.pl
new file mode 100644
index 0000000000..91e962a312
--- /dev/null
+++ b/src/lib/libcrypto/util/selftest.pl
@@ -0,0 +1,174 @@
1#!/usr/local/bin/perl -w
2#
3# Run the test suite and generate a report
4#
5
6if (! -f "Configure") {
7 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
8 exit 1;
9}
10
11my $report="testlog";
12my $os="??";
13my $version="??";
14my $platform0="??";
15my $platform="??";
16my $options="??";
17my $last="??";
18my $ok=0;
19my $cc="cc";
20my $cversion="??";
21my $sep="-----------------------------------------------------------------------------\n";
22
23open(OUT,">$report") or die;
24
25print OUT "OpenSSL self-test report:\n\n";
26
27$uname=`uname -a`;
28$uname="??" if $uname eq "";
29
30$c=`sh config -t`;
31foreach $_ (split("\n",$c)) {
32 $os=$1 if (/Operating system: (.*)$/);
33 $platform0=$1 if (/Configuring for (.*)$/);
34}
35
36system "sh config" if (! -f "Makefile.ssl");
37
38if (open(IN,"<Makefile.ssl")) {
39 while (<IN>) {
40 $version=$1 if (/^VERSION=(.*)$/);
41 $platform=$1 if (/^PLATFORM=(.*)$/);
42 $options=$1 if (/^OPTIONS=(.*)$/);
43 $cc=$1 if (/^CC= *(.*)$/);
44 }
45 close(IN);
46} else {
47 print OUT "Error running config!\n";
48}
49
50$cversion=`$cc -v 2>&1`;
51$cversion=`$cc -V 2>&1` if $cversion =~ "usage";
52$cversion=`$cc --version` if $cversion eq "";
53$cversion =~ s/Reading specs.*\n//;
54$cversion =~ s/usage.*\n//;
55chomp $cversion;
56
57if (open(IN,"<CHANGES")) {
58 while(<IN>) {
59 if (/\*\) (.{0,55})/) {
60 $last=$1;
61 last;
62 }
63 }
64 close(IN);
65}
66
67print OUT "OpenSSL version: $version\n";
68print OUT "Last change: $last...\n";
69print OUT "Options: $options\n" if $options ne "";
70print OUT "OS (uname): $uname";
71print OUT "OS (config): $os\n";
72print OUT "Target (default): $platform0\n";
73print OUT "Target: $platform\n";
74print OUT "Compiler: $cversion\n";
75print OUT "\n";
76
77print "Checking compiler...\n";
78if (open(TEST,">cctest.c")) {
79 print TEST "#include <stdio.h>\nmain(){printf(\"Hello world\\n\");}\n";
80 close(TEST);
81 system("$cc -o cctest cctest.c");
82 if (`./cctest` !~ /Hello world/) {
83 print OUT "Compiler doesn't work.\n";
84 goto err;
85 }
86} else {
87 print OUT "Can't create cctest.c\n";
88}
89if (open(TEST,">cctest.c")) {
90 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
91 close(TEST);
92 system("$cc -o cctest -Iinclude cctest.c");
93 $cctest = `./cctest`;
94 if ($cctest !~ /OpenSSL $version/) {
95 if ($cctest =~ /OpenSSL/) {
96 print OUT "#include uses headers from different OpenSSL version!\n";
97 } else {
98 print OUT "Can't compile test program!\n";
99 }
100 goto err;
101 }
102} else {
103 print OUT "Can't create cctest.c\n";
104}
105
106print "Running make...\n";
107if (system("make 2>&1 | tee make.log") > 255) {
108
109 print OUT "make failed!\n";
110 if (open(IN,"<make.log")) {
111 print OUT $sep;
112 while (<IN>) {
113 print OUT;
114 }
115 close(IN);
116 print OUT $sep;
117 } else {
118 print OUT "make.log not found!\n";
119 }
120 goto err;
121}
122
123$_=$options;
124s/no-asm//;
125if (/no-/)
126{
127 print OUT "Test skipped.\n";
128 goto err;
129}
130
131print "Running make test...\n";
132if (system("make test 2>&1 | tee make.log") > 255)
133 {
134 print OUT "make test failed!\n";
135} else {
136 $ok=1;
137}
138
139if ($ok and open(IN,"<make.log")) {
140 while (<IN>) {
141 $ok=2 if /^platform: $platform/;
142 }
143 close(IN);
144}
145
146if ($ok != 2) {
147 print OUT "Failure!\n";
148 if (open(IN,"<make.log")) {
149 print OUT $sep;
150 while (<IN>) {
151 print OUT;
152 }
153 close(IN);
154 print OUT $sep;
155 } else {
156 print OUT "make.log not found!\n";
157 }
158} else {
159 print OUT "Test passed.\n";
160}
161err:
162close(OUT);
163
164print "\n";
165open(IN,"<$report") or die;
166while (<IN>) {
167 if (/$sep/) {
168 print "[...]\n";
169 last;
170 }
171 print;
172}
173print "\nTest report in file $report\n";
174
diff --git a/src/lib/libcrypto/util/ssleay.num b/src/lib/libcrypto/util/ssleay.num
index 8121738bd6..32b2e960c4 100644
--- a/src/lib/libcrypto/util/ssleay.num
+++ b/src/lib/libcrypto/util/ssleay.num
@@ -215,3 +215,13 @@ SSL_CTX_set_cert_verify_callback 232
215sk_SSL_COMP_sort 233 215sk_SSL_COMP_sort 233
216sk_SSL_CIPHER_sort 234 216sk_SSL_CIPHER_sort 234
217SSL_CTX_set_default_passwd_cb_userdata 235 217SSL_CTX_set_default_passwd_cb_userdata 235
218SSL_set_purpose 236
219SSL_CTX_set_trust 237
220SSL_CTX_set_purpose 238
221SSL_set_trust 239
222SSL_get_finished 240
223SSL_get_peer_finished 241
224SSL_get1_session 242
225SSL_CTX_callback_ctrl 243
226SSL_callback_ctrl 244
227SSL_CTX_sessions 245
diff --git a/src/lib/libcrypto/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl
index c7ac35f6cc..48937b43af 100644
--- a/src/lib/libcrypto/x509/Makefile.ssl
+++ b/src/lib/libcrypto/x509/Makefile.ssl
@@ -23,17 +23,17 @@ APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \ 25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
26 x509_obj.c x509_req.c x509_vfy.c \ 26 x509_obj.c x509_req.c x509spki.c x509_vfy.c \
27 x509_set.c x509rset.c x509_err.c \ 27 x509_set.c x509rset.c x509_err.c \
28 x509name.c x509_v3.c x509_ext.c \ 28 x509name.c x509_v3.c x509_ext.c x509_att.c \
29 x509type.c x509_lu.c x_all.c x509_txt.c \ 29 x509type.c x509_lu.c x_all.c x509_txt.c \
30 by_file.c by_dir.c 30 x509_trs.c by_file.c by_dir.c
31LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \ 31LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
32 x509_obj.o x509_req.o x509_vfy.o \ 32 x509_obj.o x509_req.o x509spki.o x509_vfy.o \
33 x509_set.o x509rset.o x509_err.o \ 33 x509_set.o x509rset.o x509_err.o \
34 x509name.o x509_v3.o x509_ext.o \ 34 x509name.o x509_v3.o x509_ext.o x509_att.o \
35 x509type.o x509_lu.o x_all.o x509_txt.o \ 35 x509type.o x509_lu.o x_all.o x509_txt.o \
36 by_file.o by_dir.o 36 x509_trs.o by_file.o by_dir.o
37 37
38SRC= $(LIBSRC) 38SRC= $(LIBSRC)
39 39
@@ -123,14 +123,33 @@ by_file.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
123by_file.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 123by_file.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
124by_file.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 124by_file.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
125by_file.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 125by_file.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
126x509_att.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
127x509_att.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
128x509_att.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
129x509_att.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
130x509_att.o: ../../include/openssl/des.h ../../include/openssl/dh.h
131x509_att.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
132x509_att.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
133x509_att.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
134x509_att.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
135x509_att.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
136x509_att.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
137x509_att.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
138x509_att.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
139x509_att.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
140x509_att.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
141x509_att.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
142x509_att.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
143x509_att.o: ../../include/openssl/x509v3.h ../cryptlib.h
126x509_cmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 144x509_cmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
127x509_cmp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 145x509_cmp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
128x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 146x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
129x509_cmp.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 147x509_cmp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
130x509_cmp.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 148x509_cmp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
131x509_cmp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 149x509_cmp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
132x509_cmp.o: ../../include/openssl/err.h ../../include/openssl/evp.h 150x509_cmp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
133x509_cmp.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 151x509_cmp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
152x509_cmp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
134x509_cmp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 153x509_cmp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
135x509_cmp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 154x509_cmp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
136x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 155x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -139,7 +158,7 @@ x509_cmp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
139x509_cmp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 158x509_cmp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
140x509_cmp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 159x509_cmp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
141x509_cmp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 160x509_cmp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
142x509_cmp.o: ../cryptlib.h 161x509_cmp.o: ../../include/openssl/x509v3.h ../cryptlib.h
143x509_d2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 162x509_d2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
144x509_d2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 163x509_d2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
145x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 164x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -192,11 +211,12 @@ x509_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
192x509_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 211x509_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
193x509_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 212x509_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
194x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 213x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
195x509_ext.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 214x509_ext.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
196x509_ext.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 215x509_ext.o: ../../include/openssl/des.h ../../include/openssl/dh.h
197x509_ext.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 216x509_ext.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
198x509_ext.o: ../../include/openssl/err.h ../../include/openssl/evp.h 217x509_ext.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199x509_ext.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 218x509_ext.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
219x509_ext.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
200x509_ext.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 220x509_ext.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
201x509_ext.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 221x509_ext.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
202x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 222x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -205,7 +225,7 @@ x509_ext.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
205x509_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 225x509_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
206x509_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 226x509_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
207x509_ext.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 227x509_ext.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
208x509_ext.o: ../cryptlib.h 228x509_ext.o: ../../include/openssl/x509v3.h ../cryptlib.h
209x509_lu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 229x509_lu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
210x509_lu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 230x509_lu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
211x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 231x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -293,6 +313,24 @@ x509_set.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
293x509_set.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 313x509_set.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
294x509_set.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 314x509_set.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
295x509_set.o: ../cryptlib.h 315x509_set.o: ../cryptlib.h
316x509_trs.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
317x509_trs.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
318x509_trs.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
319x509_trs.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
320x509_trs.o: ../../include/openssl/des.h ../../include/openssl/dh.h
321x509_trs.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
322x509_trs.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
323x509_trs.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
324x509_trs.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
325x509_trs.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
326x509_trs.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
327x509_trs.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
328x509_trs.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
329x509_trs.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
330x509_trs.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
331x509_trs.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
332x509_trs.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
333x509_trs.o: ../../include/openssl/x509v3.h ../cryptlib.h
296x509_txt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 334x509_txt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
297x509_txt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 335x509_txt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
298x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 336x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -314,11 +352,12 @@ x509_txt.o: ../cryptlib.h
314x509_v3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 352x509_v3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
315x509_v3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 353x509_v3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
316x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 354x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
317x509_v3.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 355x509_v3.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
318x509_v3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 356x509_v3.o: ../../include/openssl/des.h ../../include/openssl/dh.h
319x509_v3.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 357x509_v3.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
320x509_v3.o: ../../include/openssl/err.h ../../include/openssl/evp.h 358x509_v3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
321x509_v3.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 359x509_v3.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
360x509_v3.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
322x509_v3.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 361x509_v3.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
323x509_v3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 362x509_v3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
324x509_v3.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 363x509_v3.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -327,25 +366,25 @@ x509_v3.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
327x509_v3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 366x509_v3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
328x509_v3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 367x509_v3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
329x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 368x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
330x509_v3.o: ../cryptlib.h 369x509_v3.o: ../../include/openssl/x509v3.h ../cryptlib.h
331x509_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 370x509_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
332x509_vfy.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 371x509_vfy.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
333x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 372x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
334x509_vfy.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 373x509_vfy.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
335x509_vfy.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 374x509_vfy.o: ../../include/openssl/des.h ../../include/openssl/dh.h
336x509_vfy.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 375x509_vfy.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
337x509_vfy.o: ../../include/openssl/err.h ../../include/openssl/evp.h 376x509_vfy.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
338x509_vfy.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 377x509_vfy.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
339x509_vfy.o: ../../include/openssl/md2.h ../../include/openssl/md5.h 378x509_vfy.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
340x509_vfy.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h 379x509_vfy.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
341x509_vfy.o: ../../include/openssl/opensslconf.h 380x509_vfy.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
342x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 381x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
343x509_vfy.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 382x509_vfy.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
344x509_vfy.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 383x509_vfy.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
345x509_vfy.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 384x509_vfy.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
346x509_vfy.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 385x509_vfy.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
347x509_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 386x509_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
348x509_vfy.o: ../cryptlib.h 387x509_vfy.o: ../../include/openssl/x509v3.h ../cryptlib.h
349x509name.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 388x509name.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
350x509name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 389x509name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
351x509name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 390x509name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -380,6 +419,24 @@ x509rset.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
380x509rset.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 419x509rset.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
381x509rset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 420x509rset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
382x509rset.o: ../cryptlib.h 421x509rset.o: ../cryptlib.h
422x509spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
423x509spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
424x509spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
425x509spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
426x509spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h
427x509spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
428x509spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
429x509spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
430x509spki.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
431x509spki.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
432x509spki.o: ../../include/openssl/opensslconf.h
433x509spki.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
434x509spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
435x509spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
436x509spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
437x509spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
438x509spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
439x509spki.o: ../cryptlib.h
383x509type.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 440x509type.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
384x509type.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 441x509type.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
385x509type.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 442x509type.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c
index 734e39ac77..14d12c56bd 100644
--- a/src/lib/libcrypto/x509/by_dir.c
+++ b/src/lib/libcrypto/x509/by_dir.c
@@ -59,10 +59,18 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64 62
65#include "cryptlib.h" 63#include "cryptlib.h"
64
65#ifndef NO_SYS_TYPES_H
66# include <sys/types.h>
67#endif
68#ifdef MAC_OS_pre_X
69# include <stat.h>
70#else
71# include <sys/stat.h>
72#endif
73
66#include <openssl/lhash.h> 74#include <openssl/lhash.h>
67#include <openssl/x509.h> 75#include <openssl/x509.h>
68 76
@@ -210,9 +218,9 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
210 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)* 218 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)*
211 sizeof(int)); 219 sizeof(int));
212 if (ctx->dirs != NULL) 220 if (ctx->dirs != NULL)
213 Free((char *)ctx->dirs); 221 Free(ctx->dirs);
214 if (ctx->dirs_type != NULL) 222 if (ctx->dirs_type != NULL)
215 Free((char *)ctx->dirs_type); 223 Free(ctx->dirs_type);
216 ctx->dirs=pp; 224 ctx->dirs=pp;
217 ctx->dirs_type=ip; 225 ctx->dirs_type=ip;
218 } 226 }
@@ -318,8 +326,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
318 /* we have added it to the cache so now pull 326 /* we have added it to the cache so now pull
319 * it out again */ 327 * it out again */
320 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); 328 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
321 tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs, 329 tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs,&stmp);
322 (char *)&stmp);
323 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); 330 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
324 331
325 if (tmp != NULL) 332 if (tmp != NULL)
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c
index 00ee5e8bbc..78e9240a8d 100644
--- a/src/lib/libcrypto/x509/by_file.c
+++ b/src/lib/libcrypto/x509/by_file.c
@@ -59,8 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64 62
65#include "cryptlib.h" 63#include "cryptlib.h"
66#include <openssl/lhash.h> 64#include <openssl/lhash.h>
@@ -94,7 +92,7 @@ X509_LOOKUP_METHOD *X509_LOOKUP_file(void)
94static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, 92static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
95 char **ret) 93 char **ret)
96 { 94 {
97 int ok=0,ok2=0; 95 int ok=0;
98 char *file; 96 char *file;
99 97
100 switch (cmd) 98 switch (cmd)
@@ -102,31 +100,30 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
102 case X509_L_FILE_LOAD: 100 case X509_L_FILE_LOAD:
103 if (argl == X509_FILETYPE_DEFAULT) 101 if (argl == X509_FILETYPE_DEFAULT)
104 { 102 {
105 ok=X509_load_cert_file(ctx,X509_get_default_cert_file(), 103 ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
106 X509_FILETYPE_PEM); 104 X509_FILETYPE_PEM) != 0);
107 ok2=X509_load_crl_file(ctx,X509_get_default_cert_file(), 105 if (!ok)
108 X509_FILETYPE_PEM);
109 if (!ok || !ok2)
110 { 106 {
111 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS); 107 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS);
112 } 108 }
113 else 109 else
114 { 110 {
115 file=(char *)Getenv(X509_get_default_cert_file_env()); 111 file=(char *)Getenv(X509_get_default_cert_file_env());
116 ok=X509_load_cert_file(ctx,file, 112 ok = (X509_load_cert_crl_file(ctx,file,
117 X509_FILETYPE_PEM); 113 X509_FILETYPE_PEM) != 0);
118 ok2=X509_load_crl_file(ctx,file,
119 X509_FILETYPE_PEM);
120 } 114 }
121 } 115 }
122 else 116 else
123 { 117 {
124 ok=X509_load_cert_file(ctx,argp,(int)argl); 118 if(argl == X509_FILETYPE_PEM)
125 ok2=X509_load_crl_file(ctx,argp,(int)argl); 119 ok = (X509_load_cert_crl_file(ctx,argp,
120 X509_FILETYPE_PEM) != 0);
121 else
122 ok = (X509_load_cert_file(ctx,argp,(int)argl) != 0);
126 } 123 }
127 break; 124 break;
128 } 125 }
129 return((ok && ok2)?ok:0); 126 return(ok);
130 } 127 }
131 128
132int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) 129int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
@@ -149,7 +146,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
149 { 146 {
150 for (;;) 147 for (;;)
151 { 148 {
152 x=PEM_read_bio_X509(in,NULL,NULL,NULL); 149 x=PEM_read_bio_X509_AUX(in,NULL,NULL,NULL);
153 if (x == NULL) 150 if (x == NULL)
154 { 151 {
155 if ((ERR_GET_REASON(ERR_peek_error()) == 152 if ((ERR_GET_REASON(ERR_peek_error()) ==
@@ -263,5 +260,39 @@ err:
263 return(ret); 260 return(ret);
264 } 261 }
265 262
263int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
264{
265 STACK_OF(X509_INFO) *inf;
266 X509_INFO *itmp;
267 BIO *in;
268 int i, count = 0;
269 if(type != X509_FILETYPE_PEM)
270 return X509_load_cert_file(ctx, file, type);
271 in = BIO_new_file(file, "r");
272 if(!in) {
273 X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_SYS_LIB);
274 return 0;
275 }
276 inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
277 BIO_free(in);
278 if(!inf) {
279 X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_PEM_LIB);
280 return 0;
281 }
282 for(i = 0; i < sk_X509_INFO_num(inf); i++) {
283 itmp = sk_X509_INFO_value(inf, i);
284 if(itmp->x509) {
285 X509_STORE_add_cert(ctx->store_ctx, itmp->x509);
286 count++;
287 } else if(itmp->crl) {
288 X509_STORE_add_crl(ctx->store_ctx, itmp->crl);
289 count++;
290 }
291 }
292 sk_X509_INFO_pop_free(inf, X509_INFO_free);
293 return count;
294}
295
296
266#endif /* NO_STDIO */ 297#endif /* NO_STDIO */
267 298
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index 35f9484f8b..d3336d9ceb 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -176,9 +176,8 @@ typedef struct X509_extension_st
176 short critical; 176 short critical;
177 short netscape_hack; 177 short netscape_hack;
178 ASN1_OCTET_STRING *value; 178 ASN1_OCTET_STRING *value;
179 long argl; /* used when decoding */ 179 struct v3_ext_method *method; /* V3 method to use */
180 char *argp; /* used when decoding */ 180 void *ext_val; /* extension value */
181 void (*ex_free)(); /* clear argp stuff */
182 } X509_EXTENSION; 181 } X509_EXTENSION;
183 182
184DECLARE_STACK_OF(X509_EXTENSION) 183DECLARE_STACK_OF(X509_EXTENSION)
@@ -231,6 +230,21 @@ typedef struct x509_cinf_st
231 STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ 230 STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */
232 } X509_CINF; 231 } X509_CINF;
233 232
233/* This stuff is certificate "auxiliary info"
234 * it contains details which are useful in certificate
235 * stores and databases. When used this is tagged onto
236 * the end of the certificate itself
237 */
238
239typedef struct x509_cert_aux_st
240 {
241 STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */
242 STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */
243 ASN1_UTF8STRING *alias; /* "friendly name" */
244 ASN1_OCTET_STRING *keyid; /* key id of private key */
245 STACK_OF(X509_ALGOR) *other; /* other unspecified info */
246 } X509_CERT_AUX;
247
234typedef struct x509_st 248typedef struct x509_st
235 { 249 {
236 X509_CINF *cert_info; 250 X509_CINF *cert_info;
@@ -239,11 +253,58 @@ typedef struct x509_st
239 int valid; 253 int valid;
240 int references; 254 int references;
241 char *name; 255 char *name;
256 CRYPTO_EX_DATA ex_data;
257 /* These contain copies of various extension values */
258 long ex_pathlen;
259 unsigned long ex_flags;
260 unsigned long ex_kusage;
261 unsigned long ex_xkusage;
262 unsigned long ex_nscert;
263#ifndef NO_SHA
264 unsigned char sha1_hash[SHA_DIGEST_LENGTH];
265#endif
266 X509_CERT_AUX *aux;
242 } X509; 267 } X509;
243 268
244DECLARE_STACK_OF(X509) 269DECLARE_STACK_OF(X509)
245DECLARE_ASN1_SET_OF(X509) 270DECLARE_ASN1_SET_OF(X509)
246 271
272/* This is used for a table of trust checking functions */
273
274typedef struct x509_trust_st {
275 int trust;
276 int flags;
277 int (*check_trust)(struct x509_trust_st *, X509 *, int);
278 char *name;
279 int arg1;
280 void *arg2;
281} X509_TRUST;
282
283DECLARE_STACK_OF(X509_TRUST)
284
285/* standard trust ids */
286
287#define X509_TRUST_ANY 1
288#define X509_TRUST_SSL_CLIENT 2
289#define X509_TRUST_SSL_SERVER 3
290#define X509_TRUST_EMAIL 4
291#define X509_TRUST_OBJECT_SIGN 5
292
293/* Keep these up to date! */
294#define X509_TRUST_MIN 1
295#define X509_TRUST_MAX 5
296
297
298/* trust_flags values */
299#define X509_TRUST_DYNAMIC 1
300#define X509_TRUST_DYNAMIC_NAME 2
301
302/* check_trust return codes */
303
304#define X509_TRUST_TRUSTED 1
305#define X509_TRUST_REJECTED 2
306#define X509_TRUST_UNTRUSTED 3
307
247typedef struct X509_revoked_st 308typedef struct X509_revoked_st
248 { 309 {
249 ASN1_INTEGER *serialNumber; 310 ASN1_INTEGER *serialNumber;
@@ -318,7 +379,7 @@ DECLARE_STACK_OF(X509_INFO)
318 379
319/* The next 2 structures and their 8 routines were sent to me by 380/* The next 2 structures and their 8 routines were sent to me by
320 * Pat Richard <patr@x509.com> and are used to manipulate 381 * Pat Richard <patr@x509.com> and are used to manipulate
321 * Netscapes spki strucutres - usefull if you are writing a CA web page 382 * Netscapes spki structures - useful if you are writing a CA web page
322 */ 383 */
323typedef struct Netscape_spkac_st 384typedef struct Netscape_spkac_st
324 { 385 {
@@ -372,8 +433,10 @@ X509_ALGOR *prf;
372typedef struct pkcs8_priv_key_info_st 433typedef struct pkcs8_priv_key_info_st
373 { 434 {
374 int broken; /* Flag for various broken formats */ 435 int broken; /* Flag for various broken formats */
375#define PKCS8_OK 0 436#define PKCS8_OK 0
376#define PKCS8_NO_OCTET 1 437#define PKCS8_NO_OCTET 1
438#define PKCS8_EMBEDDED_PARAM 2
439#define PKCS8_NS_DB 3
377 ASN1_INTEGER *version; 440 ASN1_INTEGER *version;
378 X509_ALGOR *pkeyalg; 441 X509_ALGOR *pkeyalg;
379 ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ 442 ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
@@ -552,13 +615,20 @@ int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
552int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); 615int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
553int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); 616int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
554 617
618NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
619char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
620EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
621int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
622
623int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
624
555int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); 625int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
556int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); 626int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
557int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); 627int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
558int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); 628int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
559 629
560int X509_digest(X509 *data,EVP_MD *type,unsigned char *md,unsigned int *len); 630int X509_digest(X509 *data,const EVP_MD *type,unsigned char *md,unsigned int *len);
561int X509_NAME_digest(X509_NAME *data,EVP_MD *type, 631int X509_NAME_digest(X509_NAME *data,const EVP_MD *type,
562 unsigned char *md,unsigned int *len); 632 unsigned char *md,unsigned int *len);
563#endif 633#endif
564 634
@@ -574,16 +644,23 @@ RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
574int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); 644int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
575RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); 645RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
576int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); 646int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
647RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
648int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
577#endif 649#endif
578#ifndef NO_DSA 650#ifndef NO_DSA
651DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
652int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
579DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); 653DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
580int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); 654int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
655#endif
581X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); 656X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
582int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); 657int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
583PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, 658PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
584 PKCS8_PRIV_KEY_INFO **p8inf); 659 PKCS8_PRIV_KEY_INFO **p8inf);
585int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); 660int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
586#endif 661int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
662int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
663EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
587#endif 664#endif
588 665
589#ifdef HEADER_BIO_H 666#ifdef HEADER_BIO_H
@@ -598,8 +675,12 @@ RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
598int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); 675int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
599RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); 676RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
600int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); 677int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
678RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
679int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
601#endif 680#endif
602#ifndef NO_DSA 681#ifndef NO_DSA
682DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
683int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
603DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); 684DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
604int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); 685int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
605#endif 686#endif
@@ -608,6 +689,9 @@ int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
608PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, 689PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
609 PKCS8_PRIV_KEY_INFO **p8inf); 690 PKCS8_PRIV_KEY_INFO **p8inf);
610int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); 691int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
692int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
693int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
694EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
611#endif 695#endif
612 696
613X509 *X509_dup(X509 *x509); 697X509 *X509_dup(X509 *x509);
@@ -635,7 +719,7 @@ const char * X509_get_default_cert_dir_env(void );
635const char * X509_get_default_cert_file_env(void ); 719const char * X509_get_default_cert_file_env(void );
636const char * X509_get_default_private_dir(void ); 720const char * X509_get_default_private_dir(void );
637 721
638X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, EVP_MD *md); 722X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
639X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); 723X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
640void ERR_load_X509_strings(void ); 724void ERR_load_X509_strings(void );
641 725
@@ -660,7 +744,19 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
660EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); 744EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
661int X509_get_pubkey_parameters(EVP_PKEY *pkey, 745int X509_get_pubkey_parameters(EVP_PKEY *pkey,
662 STACK_OF(X509) *chain); 746 STACK_OF(X509) *chain);
663 747int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
748EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,unsigned char **pp,
749 long length);
750#ifndef NO_RSA
751int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
752RSA * d2i_RSA_PUBKEY(RSA **a,unsigned char **pp,
753 long length);
754#endif
755#ifndef NO_DSA
756int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
757DSA * d2i_DSA_PUBKEY(DSA **a,unsigned char **pp,
758 long length);
759#endif
664 760
665X509_SIG * X509_SIG_new(void ); 761X509_SIG * X509_SIG_new(void );
666void X509_SIG_free(X509_SIG *a); 762void X509_SIG_free(X509_SIG *a);
@@ -714,6 +810,25 @@ X509 * X509_new(void);
714void X509_free(X509 *a); 810void X509_free(X509 *a);
715int i2d_X509(X509 *a,unsigned char **pp); 811int i2d_X509(X509 *a,unsigned char **pp);
716X509 * d2i_X509(X509 **a,unsigned char **pp,long length); 812X509 * d2i_X509(X509 **a,unsigned char **pp,long length);
813int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
814 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
815int X509_set_ex_data(X509 *r, int idx, void *arg);
816void *X509_get_ex_data(X509 *r, int idx);
817int i2d_X509_AUX(X509 *a,unsigned char **pp);
818X509 * d2i_X509_AUX(X509 **a,unsigned char **pp,long length);
819
820X509_CERT_AUX * X509_CERT_AUX_new(void);
821void X509_CERT_AUX_free(X509_CERT_AUX *a);
822int i2d_X509_CERT_AUX(X509_CERT_AUX *a,unsigned char **pp);
823X509_CERT_AUX * d2i_X509_CERT_AUX(X509_CERT_AUX **a,unsigned char **pp,
824 long length);
825int X509_alias_set1(X509 *x, unsigned char *name, int len);
826unsigned char * X509_alias_get0(X509 *x, int *len);
827int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
828int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
829int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
830void X509_trust_clear(X509 *x);
831void X509_reject_clear(X509 *x);
717 832
718X509_REVOKED * X509_REVOKED_new(void); 833X509_REVOKED * X509_REVOKED_new(void);
719void X509_REVOKED_free(X509_REVOKED *a); 834void X509_REVOKED_free(X509_REVOKED *a);
@@ -762,7 +877,7 @@ char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
762int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1, 877int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1,
763 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); 878 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
764 879
765int ASN1_digest(int (*i2d)(),EVP_MD *type,char *data, 880int ASN1_digest(int (*i2d)(),const EVP_MD *type,char *data,
766 unsigned char *md,unsigned int *len); 881 unsigned char *md,unsigned int *len);
767 882
768int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2, 883int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
@@ -787,6 +902,30 @@ int X509_REQ_set_version(X509_REQ *x,long version);
787int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); 902int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
788int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); 903int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
789EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); 904EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
905int X509_REQ_extension_nid(int nid);
906int * X509_REQ_get_extension_nids(void);
907void X509_REQ_set_extension_nids(int *nids);
908STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
909int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
910 int nid);
911int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
912int X509_REQ_get_attr_count(const X509_REQ *req);
913int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
914 int lastpos);
915int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
916 int lastpos);
917X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
918X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
919int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
920int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
921 ASN1_OBJECT *obj, int type,
922 unsigned char *bytes, int len);
923int X509_REQ_add1_attr_by_NID(X509_REQ *req,
924 int nid, int type,
925 unsigned char *bytes, int len);
926int X509_REQ_add1_attr_by_txt(X509_REQ *req,
927 char *attrname, int type,
928 unsigned char *bytes, int len);
790 929
791int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); 930int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
792 931
@@ -799,6 +938,7 @@ unsigned long X509_issuer_name_hash(X509 *a);
799int X509_subject_name_cmp(X509 *a,X509 *b); 938int X509_subject_name_cmp(X509 *a,X509 *b);
800unsigned long X509_subject_name_hash(X509 *x); 939unsigned long X509_subject_name_hash(X509 *x);
801 940
941int X509_cmp (X509 *a, X509 *b);
802int X509_NAME_cmp (X509_NAME *a, X509_NAME *b); 942int X509_NAME_cmp (X509_NAME *a, X509_NAME *b);
803unsigned long X509_NAME_hash(X509_NAME *x); 943unsigned long X509_NAME_hash(X509_NAME *x);
804 944
@@ -812,6 +952,7 @@ int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
812#ifdef HEADER_BIO_H 952#ifdef HEADER_BIO_H
813int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); 953int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
814int X509_print(BIO *bp,X509 *x); 954int X509_print(BIO *bp,X509 *x);
955int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
815int X509_CRL_print(BIO *bp,X509_CRL *x); 956int X509_CRL_print(BIO *bp,X509_CRL *x);
816int X509_REQ_print(BIO *bp,X509_REQ *req); 957int X509_REQ_print(BIO *bp,X509_REQ *req);
817#endif 958#endif
@@ -823,7 +964,7 @@ int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
823 char *buf,int len); 964 char *buf,int len);
824 965
825/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use 966/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use
826 * lastpos, seach after that position on. */ 967 * lastpos, search after that position on. */
827int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); 968int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
828int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, 969int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
829 int lastpos); 970 int lastpos);
@@ -831,8 +972,16 @@ X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
831X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); 972X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
832int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, 973int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
833 int loc, int set); 974 int loc, int set);
975int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
976 unsigned char *bytes, int len, int loc, int set);
977int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
978 unsigned char *bytes, int len, int loc, int set);
979X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
980 char *field, int type, unsigned char *bytes, int len);
834X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, 981X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
835 int type,unsigned char *bytes, int len); 982 int type,unsigned char *bytes, int len);
983int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type,
984 unsigned char *bytes, int len, int loc, int set);
836X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, 985X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
837 ASN1_OBJECT *obj, int type,unsigned char *bytes, 986 ASN1_OBJECT *obj, int type,unsigned char *bytes,
838 int len); 987 int len);
@@ -862,6 +1011,7 @@ int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
862X509_EXTENSION *X509_get_ext(X509 *x, int loc); 1011X509_EXTENSION *X509_get_ext(X509 *x, int loc);
863X509_EXTENSION *X509_delete_ext(X509 *x, int loc); 1012X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
864int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); 1013int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
1014void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
865 1015
866int X509_CRL_get_ext_count(X509_CRL *x); 1016int X509_CRL_get_ext_count(X509_CRL *x);
867int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); 1017int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
@@ -870,6 +1020,7 @@ int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
870X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); 1020X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
871X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); 1021X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
872int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); 1022int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
1023void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
873 1024
874int X509_REVOKED_get_ext_count(X509_REVOKED *x); 1025int X509_REVOKED_get_ext_count(X509_REVOKED *x);
875int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); 1026int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
@@ -878,6 +1029,7 @@ int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
878X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); 1029X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
879X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); 1030X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
880int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); 1031int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
1032void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
881 1033
882X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, 1034X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
883 int nid, int crit, ASN1_OCTET_STRING *data); 1035 int nid, int crit, ASN1_OCTET_STRING *data);
@@ -891,6 +1043,38 @@ ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
891ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); 1043ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
892int X509_EXTENSION_get_critical(X509_EXTENSION *ex); 1044int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
893 1045
1046int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
1047int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
1048 int lastpos);
1049int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
1050 int lastpos);
1051X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
1052X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
1053STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
1054 X509_ATTRIBUTE *attr);
1055STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
1056 ASN1_OBJECT *obj, int type,
1057 unsigned char *bytes, int len);
1058STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
1059 int nid, int type,
1060 unsigned char *bytes, int len);
1061STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
1062 char *attrname, int type,
1063 unsigned char *bytes, int len);
1064X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
1065 int atrtype, void *data, int len);
1066X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
1067 ASN1_OBJECT *obj, int atrtype, void *data, int len);
1068X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
1069 char *atrname, int type, unsigned char *bytes, int len);
1070int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj);
1071int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int len);
1072void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
1073 int atrtype, void *data);
1074int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
1075ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
1076ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
1077
894int X509_verify_cert(X509_STORE_CTX *ctx); 1078int X509_verify_cert(X509_STORE_CTX *ctx);
895 1079
896/* lookup a cert from a X509 STACK */ 1080/* lookup a cert from a X509 STACK */
@@ -926,8 +1110,20 @@ void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a);
926 1110
927EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); 1111EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
928PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); 1112PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
1113PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
929PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); 1114PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
930 1115
1116int X509_check_trust(X509 *x, int id, int flags);
1117int X509_TRUST_get_count(void);
1118X509_TRUST * X509_TRUST_get0(int idx);
1119int X509_TRUST_get_by_id(int id);
1120int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
1121 char *name, int arg1, void *arg2);
1122void X509_TRUST_cleanup(void);
1123int X509_TRUST_get_flags(X509_TRUST *xp);
1124char *X509_TRUST_get0_name(X509_TRUST *xp);
1125int X509_TRUST_get_trust(X509_TRUST *xp);
1126
931/* BEGIN ERROR CODES */ 1127/* BEGIN ERROR CODES */
932/* The following lines are auto generated by the script mkerr.pl. Any changes 1128/* The following lines are auto generated by the script mkerr.pl. Any changes
933 * made after this point may be overwritten when the script is next run. 1129 * made after this point may be overwritten when the script is next run.
@@ -940,15 +1136,25 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
940#define X509_F_BY_FILE_CTRL 101 1136#define X509_F_BY_FILE_CTRL 101
941#define X509_F_DIR_CTRL 102 1137#define X509_F_DIR_CTRL 102
942#define X509_F_GET_CERT_BY_SUBJECT 103 1138#define X509_F_GET_CERT_BY_SUBJECT 103
1139#define X509_F_NETSCAPE_SPKI_B64_DECODE 129
1140#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130
943#define X509_F_X509V3_ADD_EXT 104 1141#define X509_F_X509V3_ADD_EXT 104
1142#define X509_F_X509_ADD_ATTR 135
1143#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136
1144#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137
1145#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140
1146#define X509_F_X509_ATTRIBUTE_GET0_DATA 139
1147#define X509_F_X509_ATTRIBUTE_SET1_DATA 138
944#define X509_F_X509_CHECK_PRIVATE_KEY 128 1148#define X509_F_X509_CHECK_PRIVATE_KEY 128
945#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 1149#define X509_F_X509_EXTENSION_CREATE_BY_NID 108
946#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 1150#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
947#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 1151#define X509_F_X509_GET_PUBKEY_PARAMETERS 110
1152#define X509_F_X509_LOAD_CERT_CRL_FILE 132
948#define X509_F_X509_LOAD_CERT_FILE 111 1153#define X509_F_X509_LOAD_CERT_FILE 111
949#define X509_F_X509_LOAD_CRL_FILE 112 1154#define X509_F_X509_LOAD_CRL_FILE 112
950#define X509_F_X509_NAME_ADD_ENTRY 113 1155#define X509_F_X509_NAME_ADD_ENTRY 113
951#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 1156#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
1157#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131
952#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 1158#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
953#define X509_F_X509_NAME_ONELINE 116 1159#define X509_F_X509_NAME_ONELINE 116
954#define X509_F_X509_NAME_PRINT 117 1160#define X509_F_X509_NAME_PRINT 117
@@ -960,15 +1166,19 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
960#define X509_F_X509_REQ_TO_X509 123 1166#define X509_F_X509_REQ_TO_X509 123
961#define X509_F_X509_STORE_ADD_CERT 124 1167#define X509_F_X509_STORE_ADD_CERT 124
962#define X509_F_X509_STORE_ADD_CRL 125 1168#define X509_F_X509_STORE_ADD_CRL 125
1169#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
963#define X509_F_X509_TO_X509_REQ 126 1170#define X509_F_X509_TO_X509_REQ 126
1171#define X509_F_X509_TRUST_ADD 133
964#define X509_F_X509_VERIFY_CERT 127 1172#define X509_F_X509_VERIFY_CERT 127
965 1173
966/* Reason codes. */ 1174/* Reason codes. */
967#define X509_R_BAD_X509_FILETYPE 100 1175#define X509_R_BAD_X509_FILETYPE 100
1176#define X509_R_BASE64_DECODE_ERROR 118
968#define X509_R_CANT_CHECK_DH_KEY 114 1177#define X509_R_CANT_CHECK_DH_KEY 114
969#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 1178#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
970#define X509_R_ERR_ASN1_LIB 102 1179#define X509_R_ERR_ASN1_LIB 102
971#define X509_R_INVALID_DIRECTORY 113 1180#define X509_R_INVALID_DIRECTORY 113
1181#define X509_R_INVALID_FIELD_NAME 119
972#define X509_R_KEY_TYPE_MISMATCH 115 1182#define X509_R_KEY_TYPE_MISMATCH 115
973#define X509_R_KEY_VALUES_MISMATCH 116 1183#define X509_R_KEY_VALUES_MISMATCH 116
974#define X509_R_LOADING_CERT_DIR 103 1184#define X509_R_LOADING_CERT_DIR 103
@@ -979,8 +1189,11 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
979#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 1189#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
980#define X509_R_UNKNOWN_KEY_TYPE 117 1190#define X509_R_UNKNOWN_KEY_TYPE 117
981#define X509_R_UNKNOWN_NID 109 1191#define X509_R_UNKNOWN_NID 109
1192#define X509_R_UNKNOWN_PURPOSE_ID 121
1193#define X509_R_UNKNOWN_TRUST_ID 120
982#define X509_R_UNSUPPORTED_ALGORITHM 111 1194#define X509_R_UNSUPPORTED_ALGORITHM 111
983#define X509_R_WRONG_LOOKUP_TYPE 112 1195#define X509_R_WRONG_LOOKUP_TYPE 112
1196#define X509_R_WRONG_TYPE 122
984 1197
985#ifdef __cplusplus 1198#ifdef __cplusplus
986} 1199}
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c
new file mode 100644
index 0000000000..caafde658f
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509_att.c
@@ -0,0 +1,326 @@
1/* crypto/x509/x509_att.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <openssl/stack.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63#include <openssl/objects.h>
64#include <openssl/evp.h>
65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
67
68int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
69{
70 if (!x) return 0;
71 return(sk_X509_ATTRIBUTE_num(x));
72}
73
74int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
75 int lastpos)
76{
77 ASN1_OBJECT *obj;
78
79 obj=OBJ_nid2obj(nid);
80 if (obj == NULL) return(-2);
81 return(X509at_get_attr_by_OBJ(x,obj,lastpos));
82}
83
84int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
85 int lastpos)
86{
87 int n;
88 X509_ATTRIBUTE *ex;
89
90 if (sk == NULL) return(-1);
91 lastpos++;
92 if (lastpos < 0)
93 lastpos=0;
94 n=sk_X509_ATTRIBUTE_num(sk);
95 for ( ; lastpos < n; lastpos++)
96 {
97 ex=sk_X509_ATTRIBUTE_value(sk,lastpos);
98 if (OBJ_cmp(ex->object,obj) == 0)
99 return(lastpos);
100 }
101 return(-1);
102}
103
104X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
105{
106 if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
107 return NULL;
108 else
109 return sk_X509_ATTRIBUTE_value(x,loc);
110}
111
112X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc)
113{
114 X509_ATTRIBUTE *ret;
115
116 if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
117 return(NULL);
118 ret=sk_X509_ATTRIBUTE_delete(x,loc);
119 return(ret);
120}
121
122STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
123 X509_ATTRIBUTE *attr)
124{
125 X509_ATTRIBUTE *new_attr=NULL;
126 STACK_OF(X509_ATTRIBUTE) *sk=NULL;
127
128 if ((x != NULL) && (*x == NULL))
129 {
130 if ((sk=sk_X509_ATTRIBUTE_new_null()) == NULL)
131 goto err;
132 }
133 else
134 sk= *x;
135
136 if ((new_attr=X509_ATTRIBUTE_dup(attr)) == NULL)
137 goto err2;
138 if (!sk_X509_ATTRIBUTE_push(sk,new_attr))
139 goto err;
140 if ((x != NULL) && (*x == NULL))
141 *x=sk;
142 return(sk);
143err:
144 X509err(X509_F_X509_ADD_ATTR,ERR_R_MALLOC_FAILURE);
145err2:
146 if (new_attr != NULL) X509_ATTRIBUTE_free(new_attr);
147 if (sk != NULL) sk_X509_ATTRIBUTE_free(sk);
148 return(NULL);
149}
150
151STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
152 ASN1_OBJECT *obj, int type,
153 unsigned char *bytes, int len)
154{
155 X509_ATTRIBUTE *attr;
156 STACK_OF(X509_ATTRIBUTE) *ret;
157 attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len);
158 if(!attr) return 0;
159 ret = X509at_add1_attr(x, attr);
160 X509_ATTRIBUTE_free(attr);
161 return ret;
162}
163
164STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
165 int nid, int type,
166 unsigned char *bytes, int len)
167{
168 X509_ATTRIBUTE *attr;
169 STACK_OF(X509_ATTRIBUTE) *ret;
170 attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len);
171 if(!attr) return 0;
172 ret = X509at_add1_attr(x, attr);
173 X509_ATTRIBUTE_free(attr);
174 return ret;
175}
176
177STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
178 char *attrname, int type,
179 unsigned char *bytes, int len)
180{
181 X509_ATTRIBUTE *attr;
182 STACK_OF(X509_ATTRIBUTE) *ret;
183 attr = X509_ATTRIBUTE_create_by_txt(NULL, attrname, type, bytes, len);
184 if(!attr) return 0;
185 ret = X509at_add1_attr(x, attr);
186 X509_ATTRIBUTE_free(attr);
187 return ret;
188}
189
190X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
191 int atrtype, void *data, int len)
192{
193 ASN1_OBJECT *obj;
194 X509_ATTRIBUTE *ret;
195
196 obj=OBJ_nid2obj(nid);
197 if (obj == NULL)
198 {
199 X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_NID,X509_R_UNKNOWN_NID);
200 return(NULL);
201 }
202 ret=X509_ATTRIBUTE_create_by_OBJ(attr,obj,atrtype,data,len);
203 if (ret == NULL) ASN1_OBJECT_free(obj);
204 return(ret);
205}
206
207X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
208 ASN1_OBJECT *obj, int atrtype, void *data, int len)
209{
210 X509_ATTRIBUTE *ret;
211
212 if ((attr == NULL) || (*attr == NULL))
213 {
214 if ((ret=X509_ATTRIBUTE_new()) == NULL)
215 {
216 X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ,ERR_R_MALLOC_FAILURE);
217 return(NULL);
218 }
219 }
220 else
221 ret= *attr;
222
223 if (!X509_ATTRIBUTE_set1_object(ret,obj))
224 goto err;
225 if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len))
226 goto err;
227
228 if ((attr != NULL) && (*attr == NULL)) *attr=ret;
229 return(ret);
230err:
231 if ((attr == NULL) || (ret != *attr))
232 X509_ATTRIBUTE_free(ret);
233 return(NULL);
234}
235
236X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
237 char *atrname, int type, unsigned char *bytes, int len)
238 {
239 ASN1_OBJECT *obj;
240 X509_ATTRIBUTE *nattr;
241
242 obj=OBJ_txt2obj(atrname, 0);
243 if (obj == NULL)
244 {
245 X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_TXT,
246 X509_R_INVALID_FIELD_NAME);
247 ERR_add_error_data(2, "name=", atrname);
248 return(NULL);
249 }
250 nattr = X509_ATTRIBUTE_create_by_OBJ(attr,obj,type,bytes,len);
251 ASN1_OBJECT_free(obj);
252 return nattr;
253 }
254
255int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj)
256{
257 if ((attr == NULL) || (obj == NULL))
258 return(0);
259 ASN1_OBJECT_free(attr->object);
260 attr->object=OBJ_dup(obj);
261 return(1);
262}
263
264int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int len)
265{
266 ASN1_TYPE *ttmp;
267 ASN1_STRING *stmp;
268 int atype;
269 if (!attr) return 0;
270 if(attrtype & MBSTRING_FLAG) {
271 stmp = ASN1_STRING_set_by_NID(NULL, data, len, attrtype,
272 OBJ_obj2nid(attr->object));
273 if(!stmp) {
274 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_ASN1_LIB);
275 return 0;
276 }
277 atype = stmp->type;
278 } else {
279 if(!(stmp = ASN1_STRING_type_new(attrtype))) goto err;
280 if(!ASN1_STRING_set(stmp, data, len)) goto err;
281 atype = attrtype;
282 }
283 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
284 if(!(ttmp = ASN1_TYPE_new())) goto err;
285 if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err;
286 attr->set = 1;
287 ASN1_TYPE_set(ttmp, atype, stmp);
288 return 1;
289 err:
290 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
291 return 0;
292}
293
294int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr)
295{
296 if(attr->set) return sk_ASN1_TYPE_num(attr->value.set);
297 if(attr->value.single) return 1;
298 return 0;
299}
300
301ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr)
302{
303 if (attr == NULL) return(NULL);
304 return(attr->object);
305}
306
307void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
308 int atrtype, void *data)
309{
310 ASN1_TYPE *ttmp;
311 ttmp = X509_ATTRIBUTE_get0_type(attr, idx);
312 if(!ttmp) return NULL;
313 if(atrtype != ASN1_TYPE_get(ttmp)){
314 X509err(X509_F_X509_ATTRIBUTE_GET0_DATA, X509_R_WRONG_TYPE);
315 return NULL;
316 }
317 return ttmp->value.ptr;
318}
319
320ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx)
321{
322 if (attr == NULL) return(NULL);
323 if(idx >= X509_ATTRIBUTE_count(attr)) return NULL;
324 if(attr->set) return sk_ASN1_TYPE_value(attr->value.set, idx);
325 else return attr->value.single;
326}
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index 9a93bae3ff..a8a5ca8b03 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -57,12 +57,11 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <sys/stat.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/asn1.h> 61#include <openssl/asn1.h>
64#include <openssl/objects.h> 62#include <openssl/objects.h>
65#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
66 65
67int X509_issuer_and_serial_cmp(X509 *a, X509 *b) 66int X509_issuer_and_serial_cmp(X509 *a, X509 *b)
68 { 67 {
@@ -71,7 +70,7 @@ int X509_issuer_and_serial_cmp(X509 *a, X509 *b)
71 70
72 ai=a->cert_info; 71 ai=a->cert_info;
73 bi=b->cert_info; 72 bi=b->cert_info;
74 i=ASN1_INTEGER_cmp(ai->serialNumber,bi->serialNumber); 73 i=M_ASN1_INTEGER_cmp(ai->serialNumber,bi->serialNumber);
75 if (i) return(i); 74 if (i) return(i);
76 return(X509_NAME_cmp(ai->issuer,bi->issuer)); 75 return(X509_NAME_cmp(ai->issuer,bi->issuer));
77 } 76 }
@@ -138,6 +137,20 @@ unsigned long X509_subject_name_hash(X509 *x)
138 return(X509_NAME_hash(x->cert_info->subject)); 137 return(X509_NAME_hash(x->cert_info->subject));
139 } 138 }
140 139
140#ifndef NO_SHA
141/* Compare two certificates: they must be identical for
142 * this to work.
143 */
144int X509_cmp(X509 *a, X509 *b)
145{
146 /* ensure hash is valid */
147 X509_check_purpose(a, -1, 0);
148 X509_check_purpose(b, -1, 0);
149
150 return memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
151}
152#endif
153
141int X509_NAME_cmp(X509_NAME *a, X509_NAME *b) 154int X509_NAME_cmp(X509_NAME *a, X509_NAME *b)
142 { 155 {
143 int i,j; 156 int i,j;
@@ -175,7 +188,7 @@ int X509_NAME_cmp(X509_NAME *a, X509_NAME *b)
175 188
176#ifndef NO_MD5 189#ifndef NO_MD5
177/* I now DER encode the name and hash it. Since I cache the DER encoding, 190/* I now DER encode the name and hash it. Since I cache the DER encoding,
178 * this is reasonably effiecent. */ 191 * this is reasonably efficient. */
179unsigned long X509_NAME_hash(X509_NAME *x) 192unsigned long X509_NAME_hash(X509_NAME *x)
180 { 193 {
181 unsigned long ret=0; 194 unsigned long ret=0;
@@ -209,6 +222,8 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
209 X509_CINF cinf; 222 X509_CINF cinf;
210 X509 x,*x509=NULL; 223 X509 x,*x509=NULL;
211 224
225 if(!sk) return NULL;
226
212 x.cert_info= &cinf; 227 x.cert_info= &cinf;
213 cinf.serialNumber=serial; 228 cinf.serialNumber=serial;
214 cinf.issuer=name; 229 cinf.issuer=name;
diff --git a/src/lib/libcrypto/x509/x509_d2.c b/src/lib/libcrypto/x509/x509_d2.c
index 3e7ec5b432..753d53eb43 100644
--- a/src/lib/libcrypto/x509/x509_d2.c
+++ b/src/lib/libcrypto/x509/x509_d2.c
@@ -57,8 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <sys/stat.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/crypto.h> 61#include <openssl/crypto.h>
64#include <openssl/x509.h> 62#include <openssl/x509.h>
@@ -91,13 +89,15 @@ int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
91 { 89 {
92 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_file()); 90 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_file());
93 if (lookup == NULL) return(0); 91 if (lookup == NULL) return(0);
94 X509_LOOKUP_load_file(lookup,file,X509_FILETYPE_PEM); 92 if (X509_LOOKUP_load_file(lookup,file,X509_FILETYPE_PEM) != 1)
93 return(0);
95 } 94 }
96 if (path != NULL) 95 if (path != NULL)
97 { 96 {
98 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_hash_dir()); 97 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_hash_dir());
99 if (lookup == NULL) return(0); 98 if (lookup == NULL) return(0);
100 X509_LOOKUP_add_dir(lookup,path,X509_FILETYPE_PEM); 99 if (X509_LOOKUP_add_dir(lookup,path,X509_FILETYPE_PEM) != 1)
100 return(0);
101 } 101 }
102 if ((path == NULL) && (file == NULL)) 102 if ((path == NULL) && (file == NULL))
103 return(0); 103 return(0);
diff --git a/src/lib/libcrypto/x509/x509_def.c b/src/lib/libcrypto/x509/x509_def.c
index c4bee71569..e0ac151a76 100644
--- a/src/lib/libcrypto/x509/x509_def.c
+++ b/src/lib/libcrypto/x509/x509_def.c
@@ -57,8 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <sys/stat.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/crypto.h> 61#include <openssl/crypto.h>
64#include <openssl/x509.h> 62#include <openssl/x509.h>
diff --git a/src/lib/libcrypto/x509/x509_err.c b/src/lib/libcrypto/x509/x509_err.c
index 9afd4ccde5..fdedbdac34 100644
--- a/src/lib/libcrypto/x509/x509_err.c
+++ b/src/lib/libcrypto/x509/x509_err.c
@@ -69,15 +69,25 @@ static ERR_STRING_DATA X509_str_functs[]=
69{ERR_PACK(0,X509_F_BY_FILE_CTRL,0), "BY_FILE_CTRL"}, 69{ERR_PACK(0,X509_F_BY_FILE_CTRL,0), "BY_FILE_CTRL"},
70{ERR_PACK(0,X509_F_DIR_CTRL,0), "DIR_CTRL"}, 70{ERR_PACK(0,X509_F_DIR_CTRL,0), "DIR_CTRL"},
71{ERR_PACK(0,X509_F_GET_CERT_BY_SUBJECT,0), "GET_CERT_BY_SUBJECT"}, 71{ERR_PACK(0,X509_F_GET_CERT_BY_SUBJECT,0), "GET_CERT_BY_SUBJECT"},
72{ERR_PACK(0,X509_F_NETSCAPE_SPKI_B64_DECODE,0), "NETSCAPE_SPKI_b64_decode"},
73{ERR_PACK(0,X509_F_NETSCAPE_SPKI_B64_ENCODE,0), "NETSCAPE_SPKI_b64_encode"},
72{ERR_PACK(0,X509_F_X509V3_ADD_EXT,0), "X509v3_add_ext"}, 74{ERR_PACK(0,X509_F_X509V3_ADD_EXT,0), "X509v3_add_ext"},
75{ERR_PACK(0,X509_F_X509_ADD_ATTR,0), "X509_ADD_ATTR"},
76{ERR_PACK(0,X509_F_X509_ATTRIBUTE_CREATE_BY_NID,0), "X509_ATTRIBUTE_create_by_NID"},
77{ERR_PACK(0,X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ,0), "X509_ATTRIBUTE_create_by_OBJ"},
78{ERR_PACK(0,X509_F_X509_ATTRIBUTE_CREATE_BY_TXT,0), "X509_ATTRIBUTE_create_by_txt"},
79{ERR_PACK(0,X509_F_X509_ATTRIBUTE_GET0_DATA,0), "X509_ATTRIBUTE_get0_data"},
80{ERR_PACK(0,X509_F_X509_ATTRIBUTE_SET1_DATA,0), "X509_ATTRIBUTE_set1_data"},
73{ERR_PACK(0,X509_F_X509_CHECK_PRIVATE_KEY,0), "X509_check_private_key"}, 81{ERR_PACK(0,X509_F_X509_CHECK_PRIVATE_KEY,0), "X509_check_private_key"},
74{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_NID,0), "X509_EXTENSION_create_by_NID"}, 82{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_NID,0), "X509_EXTENSION_create_by_NID"},
75{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_OBJ,0), "X509_EXTENSION_create_by_OBJ"}, 83{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_OBJ,0), "X509_EXTENSION_create_by_OBJ"},
76{ERR_PACK(0,X509_F_X509_GET_PUBKEY_PARAMETERS,0), "X509_get_pubkey_parameters"}, 84{ERR_PACK(0,X509_F_X509_GET_PUBKEY_PARAMETERS,0), "X509_get_pubkey_parameters"},
85{ERR_PACK(0,X509_F_X509_LOAD_CERT_CRL_FILE,0), "X509_load_cert_crl_file"},
77{ERR_PACK(0,X509_F_X509_LOAD_CERT_FILE,0), "X509_load_cert_file"}, 86{ERR_PACK(0,X509_F_X509_LOAD_CERT_FILE,0), "X509_load_cert_file"},
78{ERR_PACK(0,X509_F_X509_LOAD_CRL_FILE,0), "X509_load_crl_file"}, 87{ERR_PACK(0,X509_F_X509_LOAD_CRL_FILE,0), "X509_load_crl_file"},
79{ERR_PACK(0,X509_F_X509_NAME_ADD_ENTRY,0), "X509_NAME_add_entry"}, 88{ERR_PACK(0,X509_F_X509_NAME_ADD_ENTRY,0), "X509_NAME_add_entry"},
80{ERR_PACK(0,X509_F_X509_NAME_ENTRY_CREATE_BY_NID,0), "X509_NAME_ENTRY_create_by_NID"}, 89{ERR_PACK(0,X509_F_X509_NAME_ENTRY_CREATE_BY_NID,0), "X509_NAME_ENTRY_create_by_NID"},
90{ERR_PACK(0,X509_F_X509_NAME_ENTRY_CREATE_BY_TXT,0), "X509_NAME_ENTRY_create_by_txt"},
81{ERR_PACK(0,X509_F_X509_NAME_ENTRY_SET_OBJECT,0), "X509_NAME_ENTRY_set_object"}, 91{ERR_PACK(0,X509_F_X509_NAME_ENTRY_SET_OBJECT,0), "X509_NAME_ENTRY_set_object"},
82{ERR_PACK(0,X509_F_X509_NAME_ONELINE,0), "X509_NAME_oneline"}, 92{ERR_PACK(0,X509_F_X509_NAME_ONELINE,0), "X509_NAME_oneline"},
83{ERR_PACK(0,X509_F_X509_NAME_PRINT,0), "X509_NAME_print"}, 93{ERR_PACK(0,X509_F_X509_NAME_PRINT,0), "X509_NAME_print"},
@@ -89,7 +99,9 @@ static ERR_STRING_DATA X509_str_functs[]=
89{ERR_PACK(0,X509_F_X509_REQ_TO_X509,0), "X509_REQ_to_X509"}, 99{ERR_PACK(0,X509_F_X509_REQ_TO_X509,0), "X509_REQ_to_X509"},
90{ERR_PACK(0,X509_F_X509_STORE_ADD_CERT,0), "X509_STORE_add_cert"}, 100{ERR_PACK(0,X509_F_X509_STORE_ADD_CERT,0), "X509_STORE_add_cert"},
91{ERR_PACK(0,X509_F_X509_STORE_ADD_CRL,0), "X509_STORE_add_crl"}, 101{ERR_PACK(0,X509_F_X509_STORE_ADD_CRL,0), "X509_STORE_add_crl"},
102{ERR_PACK(0,X509_F_X509_STORE_CTX_PURPOSE_INHERIT,0), "X509_STORE_CTX_purpose_inherit"},
92{ERR_PACK(0,X509_F_X509_TO_X509_REQ,0), "X509_to_X509_REQ"}, 103{ERR_PACK(0,X509_F_X509_TO_X509_REQ,0), "X509_to_X509_REQ"},
104{ERR_PACK(0,X509_F_X509_TRUST_ADD,0), "X509_TRUST_add"},
93{ERR_PACK(0,X509_F_X509_VERIFY_CERT,0), "X509_verify_cert"}, 105{ERR_PACK(0,X509_F_X509_VERIFY_CERT,0), "X509_verify_cert"},
94{0,NULL} 106{0,NULL}
95 }; 107 };
@@ -97,10 +109,12 @@ static ERR_STRING_DATA X509_str_functs[]=
97static ERR_STRING_DATA X509_str_reasons[]= 109static ERR_STRING_DATA X509_str_reasons[]=
98 { 110 {
99{X509_R_BAD_X509_FILETYPE ,"bad x509 filetype"}, 111{X509_R_BAD_X509_FILETYPE ,"bad x509 filetype"},
112{X509_R_BASE64_DECODE_ERROR ,"base64 decode error"},
100{X509_R_CANT_CHECK_DH_KEY ,"cant check dh key"}, 113{X509_R_CANT_CHECK_DH_KEY ,"cant check dh key"},
101{X509_R_CERT_ALREADY_IN_HASH_TABLE ,"cert already in hash table"}, 114{X509_R_CERT_ALREADY_IN_HASH_TABLE ,"cert already in hash table"},
102{X509_R_ERR_ASN1_LIB ,"err asn1 lib"}, 115{X509_R_ERR_ASN1_LIB ,"err asn1 lib"},
103{X509_R_INVALID_DIRECTORY ,"invalid directory"}, 116{X509_R_INVALID_DIRECTORY ,"invalid directory"},
117{X509_R_INVALID_FIELD_NAME ,"invalid field name"},
104{X509_R_KEY_TYPE_MISMATCH ,"key type mismatch"}, 118{X509_R_KEY_TYPE_MISMATCH ,"key type mismatch"},
105{X509_R_KEY_VALUES_MISMATCH ,"key values mismatch"}, 119{X509_R_KEY_VALUES_MISMATCH ,"key values mismatch"},
106{X509_R_LOADING_CERT_DIR ,"loading cert dir"}, 120{X509_R_LOADING_CERT_DIR ,"loading cert dir"},
@@ -111,8 +125,11 @@ static ERR_STRING_DATA X509_str_reasons[]=
111{X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY ,"unable to get certs public key"}, 125{X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY ,"unable to get certs public key"},
112{X509_R_UNKNOWN_KEY_TYPE ,"unknown key type"}, 126{X509_R_UNKNOWN_KEY_TYPE ,"unknown key type"},
113{X509_R_UNKNOWN_NID ,"unknown nid"}, 127{X509_R_UNKNOWN_NID ,"unknown nid"},
128{X509_R_UNKNOWN_PURPOSE_ID ,"unknown purpose id"},
129{X509_R_UNKNOWN_TRUST_ID ,"unknown trust id"},
114{X509_R_UNSUPPORTED_ALGORITHM ,"unsupported algorithm"}, 130{X509_R_UNSUPPORTED_ALGORITHM ,"unsupported algorithm"},
115{X509_R_WRONG_LOOKUP_TYPE ,"wrong lookup type"}, 131{X509_R_WRONG_LOOKUP_TYPE ,"wrong lookup type"},
132{X509_R_WRONG_TYPE ,"wrong type"},
116{0,NULL} 133{0,NULL}
117 }; 134 };
118 135
diff --git a/src/lib/libcrypto/x509/x509_ext.c b/src/lib/libcrypto/x509/x509_ext.c
index f8565a60b2..2955989807 100644
--- a/src/lib/libcrypto/x509/x509_ext.c
+++ b/src/lib/libcrypto/x509/x509_ext.c
@@ -63,6 +63,8 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
67
66 68
67int X509_CRL_get_ext_count(X509_CRL *x) 69int X509_CRL_get_ext_count(X509_CRL *x)
68 { 70 {
@@ -94,6 +96,11 @@ X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc)
94 return(X509v3_delete_ext(x->crl->extensions,loc)); 96 return(X509v3_delete_ext(x->crl->extensions,loc));
95 } 97 }
96 98
99void *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx)
100{
101 return X509V3_get_d2i(x->crl->extensions, nid, crit, idx);
102}
103
97int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) 104int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc)
98 { 105 {
99 return(X509v3_add_ext(&(x->crl->extensions),ex,loc) != NULL); 106 return(X509v3_add_ext(&(x->crl->extensions),ex,loc) != NULL);
@@ -134,6 +141,11 @@ int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc)
134 return(X509v3_add_ext(&(x->cert_info->extensions),ex,loc) != NULL); 141 return(X509v3_add_ext(&(x->cert_info->extensions),ex,loc) != NULL);
135 } 142 }
136 143
144void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
145{
146 return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx);
147}
148
137int X509_REVOKED_get_ext_count(X509_REVOKED *x) 149int X509_REVOKED_get_ext_count(X509_REVOKED *x)
138 { 150 {
139 return(X509v3_get_ext_count(x->extensions)); 151 return(X509v3_get_ext_count(x->extensions));
@@ -170,5 +182,10 @@ int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc)
170 return(X509v3_add_ext(&(x->extensions),ex,loc) != NULL); 182 return(X509v3_add_ext(&(x->extensions),ex,loc) != NULL);
171 } 183 }
172 184
185void *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx)
186{
187 return X509V3_get_d2i(x->extensions, nid, crit, idx);
188}
189
173IMPLEMENT_STACK_OF(X509_EXTENSION) 190IMPLEMENT_STACK_OF(X509_EXTENSION)
174IMPLEMENT_ASN1_SET_OF(X509_EXTENSION) 191IMPLEMENT_ASN1_SET_OF(X509_EXTENSION)
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c
index 18bfecb11e..a20006d67e 100644
--- a/src/lib/libcrypto/x509/x509_lu.c
+++ b/src/lib/libcrypto/x509/x509_lu.c
@@ -61,8 +61,8 @@
61#include <openssl/lhash.h> 61#include <openssl/lhash.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64static STACK *x509_store_meth=NULL; 64static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_meth=NULL;
65static STACK *x509_store_ctx_meth=NULL; 65static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_ctx_meth=NULL;
66 66
67X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) 67X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
68 { 68 {
@@ -244,7 +244,7 @@ void X509_STORE_free(X509_STORE *vfy)
244 } 244 }
245 sk_X509_LOOKUP_free(sk); 245 sk_X509_LOOKUP_free(sk);
246 246
247 CRYPTO_free_ex_data(x509_store_meth,(char *)vfy,&vfy->ex_data); 247 CRYPTO_free_ex_data(x509_store_meth,vfy,&vfy->ex_data);
248 lh_doall(vfy->certs,cleanup); 248 lh_doall(vfy->certs,cleanup);
249 lh_free(vfy->certs); 249 lh_free(vfy->certs);
250 Free(vfy); 250 Free(vfy);
@@ -377,10 +377,24 @@ X509_OBJECT *X509_OBJECT_retrieve_by_subject(LHASH *h, int type,
377 abort(); 377 abort();
378 } 378 }
379 379
380 tmp=(X509_OBJECT *)lh_retrieve(h,(char *)&stmp); 380 tmp=(X509_OBJECT *)lh_retrieve(h,&stmp);
381 return(tmp); 381 return(tmp);
382 } 382 }
383 383
384X509_STORE_CTX *X509_STORE_CTX_new(void)
385{
386 X509_STORE_CTX *ctx;
387 ctx = (X509_STORE_CTX *)Malloc(sizeof(X509_STORE_CTX));
388 if(ctx) memset(ctx, 0, sizeof(X509_STORE_CTX));
389 return ctx;
390}
391
392void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
393{
394 X509_STORE_CTX_cleanup(ctx);
395 Free(ctx);
396}
397
384void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, 398void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
385 STACK_OF(X509) *chain) 399 STACK_OF(X509) *chain)
386 { 400 {
@@ -389,6 +403,8 @@ void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
389 ctx->cert=x509; 403 ctx->cert=x509;
390 ctx->untrusted=chain; 404 ctx->untrusted=chain;
391 ctx->last_untrusted=0; 405 ctx->last_untrusted=0;
406 ctx->purpose=0;
407 ctx->trust=0;
392 ctx->valid=0; 408 ctx->valid=0;
393 ctx->chain=NULL; 409 ctx->chain=NULL;
394 ctx->depth=9; 410 ctx->depth=9;
@@ -404,7 +420,7 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
404 sk_X509_pop_free(ctx->chain,X509_free); 420 sk_X509_pop_free(ctx->chain,X509_free);
405 ctx->chain=NULL; 421 ctx->chain=NULL;
406 } 422 }
407 CRYPTO_free_ex_data(x509_store_ctx_meth,(char *)ctx,&(ctx->ex_data)); 423 CRYPTO_free_ex_data(x509_store_ctx_meth,ctx,&(ctx->ex_data));
408 memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA)); 424 memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA));
409 } 425 }
410 426
diff --git a/src/lib/libcrypto/x509/x509_r2x.c b/src/lib/libcrypto/x509/x509_r2x.c
index bb4697ae60..db051033d9 100644
--- a/src/lib/libcrypto/x509/x509_r2x.c
+++ b/src/lib/libcrypto/x509/x509_r2x.c
@@ -82,7 +82,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
82 82
83 if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) 83 if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0)
84 { 84 {
85 if ((xi->version=ASN1_INTEGER_new()) == NULL) goto err; 85 if ((xi->version=M_ASN1_INTEGER_new()) == NULL) goto err;
86 if (!ASN1_INTEGER_set(xi->version,2)) goto err; 86 if (!ASN1_INTEGER_set(xi->version,2)) goto err;
87/* xi->extensions=ri->attributes; <- bad, should not ever be done 87/* xi->extensions=ri->attributes; <- bad, should not ever be done
88 ri->attributes=NULL; */ 88 ri->attributes=NULL; */
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c
index 2ef94decd1..baef8790eb 100644
--- a/src/lib/libcrypto/x509/x509_req.c
+++ b/src/lib/libcrypto/x509/x509_req.c
@@ -66,7 +66,7 @@
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#include <openssl/pem.h> 67#include <openssl/pem.h>
68 68
69X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, EVP_MD *md) 69X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
70 { 70 {
71 X509_REQ *ret; 71 X509_REQ *ret;
72 X509_REQ_INFO *ri; 72 X509_REQ_INFO *ri;
@@ -113,3 +113,166 @@ EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
113 return(X509_PUBKEY_get(req->req_info->pubkey)); 113 return(X509_PUBKEY_get(req->req_info->pubkey));
114 } 114 }
115 115
116/* It seems several organisations had the same idea of including a list of
117 * extensions in a certificate request. There are at least two OIDs that are
118 * used and there may be more: so the list is configurable.
119 */
120
121static int ext_nid_list[] = { NID_ms_ext_req, NID_ext_req, NID_undef};
122
123static int *ext_nids = ext_nid_list;
124
125int X509_REQ_extension_nid(int req_nid)
126{
127 int i, nid;
128 for(i = 0; ; i++) {
129 nid = ext_nids[i];
130 if(nid == NID_undef) return 0;
131 else if (req_nid == nid) return 1;
132 }
133}
134
135int *X509_REQ_get_extension_nids(void)
136{
137 return ext_nids;
138}
139
140void X509_REQ_set_extension_nids(int *nids)
141{
142 ext_nids = nids;
143}
144
145STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
146{
147 X509_ATTRIBUTE *attr;
148 STACK_OF(X509_ATTRIBUTE) *sk;
149 ASN1_TYPE *ext = NULL;
150 int i;
151 unsigned char *p;
152 if ((req == NULL) || (req->req_info == NULL))
153 return(NULL);
154 sk=req->req_info->attributes;
155 if (!sk) return NULL;
156 for(i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) {
157 attr = sk_X509_ATTRIBUTE_value(sk, i);
158 if(X509_REQ_extension_nid(OBJ_obj2nid(attr->object))) {
159 if(attr->set && sk_ASN1_TYPE_num(attr->value.set))
160 ext = sk_ASN1_TYPE_value(attr->value.set, 0);
161 else ext = attr->value.single;
162 break;
163 }
164 }
165 if(!ext || (ext->type != V_ASN1_SEQUENCE)) return NULL;
166 p = ext->value.sequence->data;
167 return d2i_ASN1_SET_OF_X509_EXTENSION(NULL, &p,
168 ext->value.sequence->length,
169 d2i_X509_EXTENSION, X509_EXTENSION_free,
170 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
171}
172
173/* Add a STACK_OF extensions to a certificate request: allow alternative OIDs
174 * in case we want to create a non standard one.
175 */
176
177int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
178 int nid)
179{
180 unsigned char *p = NULL, *q;
181 long len;
182 ASN1_TYPE *at = NULL;
183 X509_ATTRIBUTE *attr = NULL;
184 if(!(at = ASN1_TYPE_new()) ||
185 !(at->value.sequence = ASN1_STRING_new())) goto err;
186
187 at->type = V_ASN1_SEQUENCE;
188 /* Generate encoding of extensions */
189 len = i2d_ASN1_SET_OF_X509_EXTENSION(exts, NULL, i2d_X509_EXTENSION,
190 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE);
191 if(!(p = Malloc(len))) goto err;
192 q = p;
193 i2d_ASN1_SET_OF_X509_EXTENSION(exts, &q, i2d_X509_EXTENSION,
194 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE);
195 at->value.sequence->data = p;
196 p = NULL;
197 at->value.sequence->length = len;
198 if(!(attr = X509_ATTRIBUTE_new())) 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;
201 at = NULL;
202 attr->set = 1;
203 attr->object = OBJ_nid2obj(nid);
204 if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err;
205 return 1;
206 err:
207 if(p) Free(p);
208 X509_ATTRIBUTE_free(attr);
209 ASN1_TYPE_free(at);
210 return 0;
211}
212/* This is the normal usage: use the "official" OID */
213int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts)
214{
215 return X509_REQ_add_extensions_nid(req, exts, NID_ext_req);
216}
217
218/* Request attribute functions */
219
220int X509_REQ_get_attr_count(const X509_REQ *req)
221{
222 return X509at_get_attr_count(req->req_info->attributes);
223}
224
225int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
226 int lastpos)
227{
228 return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos);
229}
230
231int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
232 int lastpos)
233{
234 return X509at_get_attr_by_OBJ(req->req_info->attributes, obj, lastpos);
235}
236
237X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc)
238{
239 return X509at_get_attr(req->req_info->attributes, loc);
240}
241
242X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc)
243{
244 return X509at_delete_attr(req->req_info->attributes, loc);
245}
246
247int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr)
248{
249 if(X509at_add1_attr(&req->req_info->attributes, attr)) return 1;
250 return 0;
251}
252
253int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
254 ASN1_OBJECT *obj, int type,
255 unsigned char *bytes, int len)
256{
257 if(X509at_add1_attr_by_OBJ(&req->req_info->attributes, obj,
258 type, bytes, len)) return 1;
259 return 0;
260}
261
262int X509_REQ_add1_attr_by_NID(X509_REQ *req,
263 int nid, int type,
264 unsigned char *bytes, int len)
265{
266 if(X509at_add1_attr_by_NID(&req->req_info->attributes, nid,
267 type, bytes, len)) return 1;
268 return 0;
269}
270
271int X509_REQ_add1_attr_by_txt(X509_REQ *req,
272 char *attrname, int type,
273 unsigned char *bytes, int len)
274{
275 if(X509at_add1_attr_by_txt(&req->req_info->attributes, attrname,
276 type, bytes, len)) return 1;
277 return 0;
278}
diff --git a/src/lib/libcrypto/x509/x509_set.c b/src/lib/libcrypto/x509/x509_set.c
index 5a6f7b414f..add842d17a 100644
--- a/src/lib/libcrypto/x509/x509_set.c
+++ b/src/lib/libcrypto/x509/x509_set.c
@@ -68,7 +68,7 @@ int X509_set_version(X509 *x, long version)
68 if (x == NULL) return(0); 68 if (x == NULL) return(0);
69 if (x->cert_info->version == NULL) 69 if (x->cert_info->version == NULL)
70 { 70 {
71 if ((x->cert_info->version=ASN1_INTEGER_new()) == NULL) 71 if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL)
72 return(0); 72 return(0);
73 } 73 }
74 return(ASN1_INTEGER_set(x->cert_info->version,version)); 74 return(ASN1_INTEGER_set(x->cert_info->version,version));
@@ -82,10 +82,10 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
82 in=x->cert_info->serialNumber; 82 in=x->cert_info->serialNumber;
83 if (in != serial) 83 if (in != serial)
84 { 84 {
85 in=ASN1_INTEGER_dup(serial); 85 in=M_ASN1_INTEGER_dup(serial);
86 if (in != NULL) 86 if (in != NULL)
87 { 87 {
88 ASN1_INTEGER_free(x->cert_info->serialNumber); 88 M_ASN1_INTEGER_free(x->cert_info->serialNumber);
89 x->cert_info->serialNumber=in; 89 x->cert_info->serialNumber=in;
90 } 90 }
91 } 91 }
@@ -112,10 +112,10 @@ int X509_set_notBefore(X509 *x, ASN1_UTCTIME *tm)
112 in=x->cert_info->validity->notBefore; 112 in=x->cert_info->validity->notBefore;
113 if (in != tm) 113 if (in != tm)
114 { 114 {
115 in=ASN1_UTCTIME_dup(tm); 115 in=M_ASN1_UTCTIME_dup(tm);
116 if (in != NULL) 116 if (in != NULL)
117 { 117 {
118 ASN1_UTCTIME_free(x->cert_info->validity->notBefore); 118 M_ASN1_UTCTIME_free(x->cert_info->validity->notBefore);
119 x->cert_info->validity->notBefore=in; 119 x->cert_info->validity->notBefore=in;
120 } 120 }
121 } 121 }
@@ -130,10 +130,10 @@ int X509_set_notAfter(X509 *x, ASN1_UTCTIME *tm)
130 in=x->cert_info->validity->notAfter; 130 in=x->cert_info->validity->notAfter;
131 if (in != tm) 131 if (in != tm)
132 { 132 {
133 in=ASN1_UTCTIME_dup(tm); 133 in=M_ASN1_UTCTIME_dup(tm);
134 if (in != NULL) 134 if (in != NULL)
135 { 135 {
136 ASN1_UTCTIME_free(x->cert_info->validity->notAfter); 136 M_ASN1_UTCTIME_free(x->cert_info->validity->notAfter);
137 x->cert_info->validity->notAfter=in; 137 x->cert_info->validity->notAfter=in;
138 } 138 }
139 } 139 }
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c
new file mode 100644
index 0000000000..9f7d67952d
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509_trs.c
@@ -0,0 +1,263 @@
1/* x509_trs.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/x509v3.h>
62
63
64static int tr_cmp(X509_TRUST **a, X509_TRUST **b);
65static void trtable_free(X509_TRUST *p);
66
67static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags);
68static int trust_any(X509_TRUST *trust, X509 *x, int flags);
69
70static int obj_trust(int id, X509 *x, int flags);
71static int (*default_trust)(int id, X509 *x, int flags) = obj_trust;
72
73/* WARNING: the following table should be kept in order of trust
74 * and without any gaps so we can just subtract the minimum trust
75 * value to get an index into the table
76 */
77
78static X509_TRUST trstandard[] = {
79{X509_TRUST_ANY, 0, trust_any, "Any", 0, NULL},
80{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL},
81{X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Client", NID_server_auth, NULL},
82{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL},
83};
84
85#define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST))
86
87IMPLEMENT_STACK_OF(X509_TRUST)
88
89static STACK_OF(X509_TRUST) *trtable = NULL;
90
91static int tr_cmp(X509_TRUST **a, X509_TRUST **b)
92{
93 return (*a)->trust - (*b)->trust;
94}
95
96int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int)
97{
98int (*oldtrust)(int , X509 *, int);
99oldtrust = default_trust;
100default_trust = trust;
101return oldtrust;
102}
103
104
105int X509_check_trust(X509 *x, int id, int flags)
106{
107 X509_TRUST *pt;
108 int idx;
109 if(id == -1) return 1;
110 if(!(idx = X509_TRUST_get_by_id(id)))
111 return default_trust(id, x, flags);
112 pt = X509_TRUST_get0(idx);
113 return pt->check_trust(pt, x, flags);
114}
115
116int X509_TRUST_get_count(void)
117{
118 if(!trtable) return X509_TRUST_COUNT;
119 return sk_X509_TRUST_num(trtable) + X509_TRUST_COUNT;
120}
121
122X509_TRUST * X509_TRUST_get0(int idx)
123{
124 if(idx < 0) return NULL;
125 if(idx < X509_TRUST_COUNT) return trstandard + idx;
126 return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT);
127}
128
129int X509_TRUST_get_by_id(int id)
130{
131 X509_TRUST tmp;
132 int idx;
133 if((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
134 return id - X509_TRUST_MIN;
135 tmp.trust = id;
136 if(!trtable) return -1;
137 idx = sk_X509_TRUST_find(trtable, &tmp);
138 if(idx == -1) return -1;
139 return idx + X509_TRUST_COUNT;
140}
141
142int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
143 char *name, int arg1, void *arg2)
144{
145 int idx;
146 X509_TRUST *trtmp;
147 /* This is set according to what we change: application can't set it */
148 flags &= ~X509_TRUST_DYNAMIC;
149 /* This will always be set for application modified trust entries */
150 flags |= X509_TRUST_DYNAMIC_NAME;
151 /* Get existing entry if any */
152 idx = X509_TRUST_get_by_id(id);
153 /* Need a new entry */
154 if(idx == -1) {
155 if(!(trtmp = Malloc(sizeof(X509_TRUST)))) {
156 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
157 return 0;
158 }
159 trtmp->flags = X509_TRUST_DYNAMIC;
160 } else trtmp = X509_TRUST_get0(idx);
161
162 /* Free existing name if dynamic */
163 if(trtmp->flags & X509_TRUST_DYNAMIC_NAME) Free(trtmp->name);
164 /* dup supplied name */
165 if(!(trtmp->name = BUF_strdup(name))) {
166 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
167 return 0;
168 }
169 /* Keep the dynamic flag of existing entry */
170 trtmp->flags &= X509_TRUST_DYNAMIC;
171 /* Set all other flags */
172 trtmp->flags |= flags;
173
174 trtmp->trust = id;
175 trtmp->check_trust = ck;
176 trtmp->arg1 = arg1;
177 trtmp->arg2 = arg2;
178
179 /* If its a new entry manage the dynamic table */
180 if(idx == -1) {
181 if(!trtable && !(trtable = sk_X509_TRUST_new(tr_cmp))) {
182 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
183 return 0;
184 }
185 if (!sk_X509_TRUST_push(trtable, trtmp)) {
186 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
187 return 0;
188 }
189 }
190 return 1;
191}
192
193static void trtable_free(X509_TRUST *p)
194 {
195 if(!p) return;
196 if (p->flags & X509_TRUST_DYNAMIC)
197 {
198 if (p->flags & X509_TRUST_DYNAMIC_NAME)
199 Free(p->name);
200 Free(p);
201 }
202 }
203
204void X509_TRUST_cleanup(void)
205{
206 int i;
207 for(i = 0; i < X509_TRUST_COUNT; i++) trtable_free(trstandard + i);
208 sk_X509_TRUST_pop_free(trtable, trtable_free);
209 trtable = NULL;
210}
211
212int X509_TRUST_get_flags(X509_TRUST *xp)
213{
214 return xp->flags;
215}
216
217char *X509_TRUST_get0_name(X509_TRUST *xp)
218{
219 return xp->name;
220}
221
222int X509_TRUST_get_trust(X509_TRUST *xp)
223{
224 return xp->trust;
225}
226
227static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags)
228{
229 if(x->aux) return obj_trust(trust->arg1, x, flags);
230 /* we don't have any trust settings: for compatibility
231 * we return trusted if it is self signed
232 */
233 X509_check_purpose(x, -1, 0);
234 if(x->ex_flags & EXFLAG_SS) return X509_TRUST_TRUSTED;
235 else return X509_TRUST_UNTRUSTED;
236}
237
238static int obj_trust(int id, X509 *x, int flags)
239{
240 ASN1_OBJECT *obj;
241 int i;
242 X509_CERT_AUX *ax;
243 ax = x->aux;
244 if(!ax) return X509_TRUST_UNTRUSTED;
245 if(ax->reject) {
246 for(i = 0; i < sk_ASN1_OBJECT_num(ax->reject); i++) {
247 obj = sk_ASN1_OBJECT_value(ax->reject, i);
248 if(OBJ_obj2nid(obj) == id) return X509_TRUST_REJECTED;
249 }
250 }
251 if(ax->trust) {
252 for(i = 0; i < sk_ASN1_OBJECT_num(ax->trust); i++) {
253 obj = sk_ASN1_OBJECT_value(ax->trust, i);
254 if(OBJ_obj2nid(obj) == id) return X509_TRUST_TRUSTED;
255 }
256 }
257 return X509_TRUST_UNTRUSTED;
258}
259
260static int trust_any(X509_TRUST *trust, X509 *x, int flags)
261{
262 return X509_TRUST_TRUSTED;
263}
diff --git a/src/lib/libcrypto/x509/x509_txt.c b/src/lib/libcrypto/x509/x509_txt.c
index 11a3d2012f..209cf53191 100644
--- a/src/lib/libcrypto/x509/x509_txt.c
+++ b/src/lib/libcrypto/x509/x509_txt.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63 62
64#include "cryptlib.h" 63#include "cryptlib.h"
65#include <openssl/lhash.h> 64#include <openssl/lhash.h>
@@ -121,6 +120,16 @@ const char *X509_verify_cert_error_string(long n)
121 return("certificate chain too long"); 120 return("certificate chain too long");
122 case X509_V_ERR_CERT_REVOKED: 121 case X509_V_ERR_CERT_REVOKED:
123 return("certificate revoked"); 122 return("certificate revoked");
123 case X509_V_ERR_INVALID_CA:
124 return ("invalid CA certificate");
125 case X509_V_ERR_PATH_LENGTH_EXCEEDED:
126 return ("path length constraint exceeded");
127 case X509_V_ERR_INVALID_PURPOSE:
128 return ("unsupported certificate purpose");
129 case X509_V_ERR_CERT_UNTRUSTED:
130 return ("certificate not trusted");
131 case X509_V_ERR_CERT_REJECTED:
132 return ("certificate rejected");
124 case X509_V_ERR_APPLICATION_VERIFICATION: 133 case X509_V_ERR_APPLICATION_VERIFICATION:
125 return("application verification failure"); 134 return("application verification failure");
126 default: 135 default:
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index dd2f9f1b17..52887986fe 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -63,6 +63,7 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
66 67
67int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) 68int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x)
68 { 69 {
@@ -242,7 +243,7 @@ int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data)
242 int i; 243 int i;
243 244
244 if (ex == NULL) return(0); 245 if (ex == NULL) return(0);
245 i=ASN1_OCTET_STRING_set(ex->value,data->data,data->length); 246 i=M_ASN1_OCTET_STRING_set(ex->value,data->data,data->length);
246 if (!i) return(0); 247 if (!i) return(0);
247 return(1); 248 return(1);
248 } 249 }
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index c72ee4a385..4fdff54124 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -59,23 +59,24 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64 62
65#include <openssl/crypto.h>
66#include "cryptlib.h" 63#include "cryptlib.h"
64#include <openssl/crypto.h>
67#include <openssl/lhash.h> 65#include <openssl/lhash.h>
68#include <openssl/buffer.h> 66#include <openssl/buffer.h>
69#include <openssl/evp.h> 67#include <openssl/evp.h>
70#include <openssl/asn1.h> 68#include <openssl/asn1.h>
71#include <openssl/x509.h> 69#include <openssl/x509.h>
70#include <openssl/x509v3.h>
72#include <openssl/objects.h> 71#include <openssl/objects.h>
73 72
74static int null_callback(int ok,X509_STORE_CTX *e); 73static int null_callback(int ok,X509_STORE_CTX *e);
74static int check_chain_purpose(X509_STORE_CTX *ctx);
75static int check_trust(X509_STORE_CTX *ctx);
75static int internal_verify(X509_STORE_CTX *ctx); 76static int internal_verify(X509_STORE_CTX *ctx);
76const char *X509_version="X.509" OPENSSL_VERSION_PTEXT; 77const char *X509_version="X.509" OPENSSL_VERSION_PTEXT;
77 78
78static STACK *x509_store_ctx_method=NULL; 79static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_ctx_method=NULL;
79static int x509_store_ctx_num=0; 80static int x509_store_ctx_num=0;
80#if 0 81#if 0
81static int x509_store_num=1; 82static int x509_store_num=1;
@@ -127,7 +128,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
127 ctx->last_untrusted=1; 128 ctx->last_untrusted=1;
128 } 129 }
129 130
130 /* We use a temporary so we can chop and hack at it */ 131 /* We use a temporary STACK so we can chop and hack at it */
131 if (ctx->untrusted != NULL 132 if (ctx->untrusted != NULL
132 && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL) 133 && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL)
133 { 134 {
@@ -184,17 +185,37 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
184 185
185 i=sk_X509_num(ctx->chain); 186 i=sk_X509_num(ctx->chain);
186 x=sk_X509_value(ctx->chain,i-1); 187 x=sk_X509_value(ctx->chain,i-1);
187 if (X509_NAME_cmp(X509_get_subject_name(x),X509_get_issuer_name(x)) 188 xn = X509_get_subject_name(x);
189 if (X509_NAME_cmp(xn,X509_get_issuer_name(x))
188 == 0) 190 == 0)
189 { 191 {
190 /* we have a self signed certificate */ 192 /* we have a self signed certificate */
191 if (sk_X509_num(ctx->chain) == 1) 193 if (sk_X509_num(ctx->chain) == 1)
192 { 194 {
193 ctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT; 195 /* We have a single self signed certificate: see if
194 ctx->current_cert=x; 196 * we can find it in the store. We must have an exact
195 ctx->error_depth=i-1; 197 * match to avoid possible impersonation.
196 ok=cb(0,ctx); 198 */
197 if (!ok) goto end; 199 ok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj);
200 if ((ok != X509_LU_X509) || X509_cmp(x, obj.data.x509))
201 {
202 ctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;
203 ctx->current_cert=x;
204 ctx->error_depth=i-1;
205 if(ok == X509_LU_X509) X509_OBJECT_free_contents(&obj);
206 ok=cb(0,ctx);
207 if (!ok) goto end;
208 }
209 else
210 {
211 /* We have a match: replace certificate with store version
212 * so we get any trust settings.
213 */
214 X509_free(x);
215 x = obj.data.x509;
216 sk_X509_set(ctx->chain, i - 1, x);
217 ctx->last_untrusted=0;
218 }
198 } 219 }
199 else 220 else
200 { 221 {
@@ -272,6 +293,17 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
272 if (!ok) goto end; 293 if (!ok) goto end;
273 } 294 }
274 295
296 /* We have the chain complete: now we need to check its purpose */
297 if(ctx->purpose > 0) ok = check_chain_purpose(ctx);
298
299 if(!ok) goto end;
300
301 /* The chain extensions are OK: check trust */
302
303 if(ctx->trust > 0) ok = check_trust(ctx);
304
305 if(!ok) goto end;
306
275 /* We may as well copy down any DSA parameters that are required */ 307 /* We may as well copy down any DSA parameters that are required */
276 X509_get_pubkey_parameters(NULL,ctx->chain); 308 X509_get_pubkey_parameters(NULL,ctx->chain);
277 309
@@ -290,6 +322,71 @@ end:
290 return(ok); 322 return(ok);
291 } 323 }
292 324
325/* Check a certificate chains extensions for consistency
326 * with the supplied purpose
327 */
328
329static int check_chain_purpose(X509_STORE_CTX *ctx)
330{
331#ifdef NO_CHAIN_VERIFY
332 return 1;
333#else
334 int i, ok=0;
335 X509 *x;
336 int (*cb)();
337 cb=ctx->ctx->verify_cb;
338 if (cb == NULL) cb=null_callback;
339 /* Check all untrusted certificates */
340 for(i = 0; i < ctx->last_untrusted; i++) {
341 x = sk_X509_value(ctx->chain, i);
342 if(!X509_check_purpose(x, ctx->purpose, i)) {
343 if(i) ctx->error = X509_V_ERR_INVALID_CA;
344 else ctx->error = X509_V_ERR_INVALID_PURPOSE;
345 ctx->error_depth = i;
346 ctx->current_cert = x;
347 ok=cb(0,ctx);
348 if(!ok) goto end;
349 }
350 /* Check pathlen */
351 if((i > 1) && (x->ex_pathlen != -1)
352 && (i > (x->ex_pathlen + 1))) {
353 ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED;
354 ctx->error_depth = i;
355 ctx->current_cert = x;
356 ok=cb(0,ctx);
357 if(!ok) goto end;
358 }
359 }
360 ok = 1;
361 end:
362 return(ok);
363#endif
364}
365
366static int check_trust(X509_STORE_CTX *ctx)
367{
368#ifdef NO_CHAIN_VERIFY
369 return 1;
370#else
371 int i, ok;
372 X509 *x;
373 int (*cb)();
374 cb=ctx->ctx->verify_cb;
375 if (cb == NULL) cb=null_callback;
376/* For now just check the last certificate in the chain */
377 i = sk_X509_num(ctx->chain) - 1;
378 x = sk_X509_value(ctx->chain, i);
379 ok = X509_check_trust(x, ctx->trust, 0);
380 if(ok == X509_TRUST_TRUSTED) return 1;
381 ctx->error_depth = sk_X509_num(ctx->chain) - 1;
382 ctx->current_cert = x;
383 if(ok == X509_TRUST_REJECTED) ctx->error = X509_V_ERR_CERT_REJECTED;
384 else ctx->error = X509_V_ERR_CERT_UNTRUSTED;
385 ok = cb(0, ctx);
386 return(ok);
387#endif
388}
389
293static int internal_verify(X509_STORE_CTX *ctx) 390static int internal_verify(X509_STORE_CTX *ctx)
294 { 391 {
295 int i,ok=0,n; 392 int i,ok=0,n;
@@ -439,7 +536,7 @@ int X509_cmp_current_time(ASN1_UTCTIME *ctm)
439 atm.length=sizeof(buff2); 536 atm.length=sizeof(buff2);
440 atm.data=(unsigned char *)buff2; 537 atm.data=(unsigned char *)buff2;
441 538
442 X509_gmtime_adj(&atm,-offset); 539 X509_gmtime_adj(&atm,-offset*60);
443 540
444 i=(buff1[0]-'0')*10+(buff1[1]-'0'); 541 i=(buff1[0]-'0')*10+(buff1[1]-'0');
445 if (i < 50) i+=100; /* cf. RFC 2459 */ 542 if (i < 50) i+=100; /* cf. RFC 2459 */
@@ -525,13 +622,13 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
525 622
526 X509_OBJECT_up_ref_count(obj); 623 X509_OBJECT_up_ref_count(obj);
527 624
528 r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj); 625 r=(X509_OBJECT *)lh_insert(ctx->certs,obj);
529 if (r != NULL) 626 if (r != NULL)
530 { /* oops, put it back */ 627 { /* oops, put it back */
531 lh_delete(ctx->certs,(char *)obj); 628 lh_delete(ctx->certs,obj);
532 X509_OBJECT_free_contents(obj); 629 X509_OBJECT_free_contents(obj);
533 Free(obj); 630 Free(obj);
534 lh_insert(ctx->certs,(char *)r); 631 lh_insert(ctx->certs,r);
535 X509err(X509_F_X509_STORE_ADD_CERT,X509_R_CERT_ALREADY_IN_HASH_TABLE); 632 X509err(X509_F_X509_STORE_ADD_CERT,X509_R_CERT_ALREADY_IN_HASH_TABLE);
536 ret=0; 633 ret=0;
537 } 634 }
@@ -560,13 +657,13 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
560 657
561 X509_OBJECT_up_ref_count(obj); 658 X509_OBJECT_up_ref_count(obj);
562 659
563 r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj); 660 r=(X509_OBJECT *)lh_insert(ctx->certs,obj);
564 if (r != NULL) 661 if (r != NULL)
565 { /* oops, put it back */ 662 { /* oops, put it back */
566 lh_delete(ctx->certs,(char *)obj); 663 lh_delete(ctx->certs,obj);
567 X509_OBJECT_free_contents(obj); 664 X509_OBJECT_free_contents(obj);
568 Free(obj); 665 Free(obj);
569 lh_insert(ctx->certs,(char *)r); 666 lh_insert(ctx->certs,r);
570 X509err(X509_F_X509_STORE_ADD_CRL,X509_R_CERT_ALREADY_IN_HASH_TABLE); 667 X509err(X509_F_X509_STORE_ADD_CRL,X509_R_CERT_ALREADY_IN_HASH_TABLE);
571 ret=0; 668 ret=0;
572 } 669 }
@@ -576,8 +673,8 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
576 return(ret); 673 return(ret);
577 } 674 }
578 675
579int X509_STORE_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), 676int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
580 int (*dup_func)(), void (*free_func)()) 677 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
581 { 678 {
582 x509_store_ctx_num++; 679 x509_store_ctx_num++;
583 return(CRYPTO_get_ex_new_index(x509_store_ctx_num-1, 680 return(CRYPTO_get_ex_new_index(x509_store_ctx_num-1,
@@ -620,6 +717,19 @@ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
620 return(ctx->chain); 717 return(ctx->chain);
621 } 718 }
622 719
720STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
721 {
722 int i;
723 X509 *x;
724 STACK_OF(X509) *chain;
725 if(!ctx->chain || !(chain = sk_X509_dup(ctx->chain))) return NULL;
726 for(i = 0; i < sk_X509_num(chain); i++) {
727 x = sk_X509_value(chain, i);
728 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
729 }
730 return(chain);
731 }
732
623void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x) 733void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
624 { 734 {
625 ctx->cert=x; 735 ctx->cert=x;
@@ -630,6 +740,62 @@ void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
630 ctx->untrusted=sk; 740 ctx->untrusted=sk;
631 } 741 }
632 742
743int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose)
744 {
745 return X509_STORE_CTX_purpose_inherit(ctx, 0, purpose, 0);
746 }
747
748int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust)
749 {
750 return X509_STORE_CTX_purpose_inherit(ctx, 0, 0, trust);
751 }
752
753/* This function is used to set the X509_STORE_CTX purpose and trust
754 * values. This is intended to be used when another structure has its
755 * own trust and purpose values which (if set) will be inherited by
756 * the ctx. If they aren't set then we will usually have a default
757 * purpose in mind which should then be used to set the trust value.
758 * An example of this is SSL use: an SSL structure will have its own
759 * purpose and trust settings which the application can set: if they
760 * aren't set then we use the default of SSL client/server.
761 */
762
763int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
764 int purpose, int trust)
765{
766 int idx;
767 /* If purpose not set use default */
768 if(!purpose) purpose = def_purpose;
769 /* If we have a purpose then check it is valid */
770 if(purpose) {
771 idx = X509_PURPOSE_get_by_id(purpose);
772 if(idx == -1) {
773 X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
774 X509_R_UNKNOWN_PURPOSE_ID);
775 return 0;
776 }
777 /* If trust not set then get from purpose default */
778 if(!trust) {
779 X509_PURPOSE *ptmp;
780 ptmp = X509_PURPOSE_get0(idx);
781 trust = ptmp->trust;
782 }
783 }
784 if(trust) {
785 idx = X509_TRUST_get_by_id(trust);
786 if(idx == -1) {
787 X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
788 X509_R_UNKNOWN_TRUST_ID);
789 return 0;
790 }
791 }
792
793 if(purpose) ctx->purpose = purpose;
794 if(trust) ctx->trust = trust;
795 return 1;
796}
797
798
633IMPLEMENT_STACK_OF(X509) 799IMPLEMENT_STACK_OF(X509)
634IMPLEMENT_ASN1_SET_OF(X509) 800IMPLEMENT_ASN1_SET_OF(X509)
635 801
diff --git a/src/lib/libcrypto/x509/x509_vfy.h b/src/lib/libcrypto/x509/x509_vfy.h
index ecfd4cf9ed..4637aecedf 100644
--- a/src/lib/libcrypto/x509/x509_vfy.h
+++ b/src/lib/libcrypto/x509/x509_vfy.h
@@ -202,6 +202,8 @@ struct x509_store_state_st /* X509_STORE_CTX */
202 /* The following are set by the caller */ 202 /* The following are set by the caller */
203 X509 *cert; /* The cert to check */ 203 X509 *cert; /* The cert to check */
204 STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ 204 STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */
205 int purpose; /* purpose to check untrusted certificates */
206 int trust; /* trust setting to check */
205 207
206 /* The following is built up */ 208 /* The following is built up */
207 int depth; /* how far to go looking up certs */ 209 int depth; /* how far to go looking up certs */
@@ -234,6 +236,7 @@ struct x509_store_state_st /* X509_STORE_CTX */
234 X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) 236 X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)
235 237
236#define X509_V_OK 0 238#define X509_V_OK 0
239/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */
237 240
238#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 241#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2
239#define X509_V_ERR_UNABLE_TO_GET_CRL 3 242#define X509_V_ERR_UNABLE_TO_GET_CRL 3
@@ -257,6 +260,11 @@ struct x509_store_state_st /* X509_STORE_CTX */
257#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 260#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21
258#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 261#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22
259#define X509_V_ERR_CERT_REVOKED 23 262#define X509_V_ERR_CERT_REVOKED 23
263#define X509_V_ERR_INVALID_CA 24
264#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25
265#define X509_V_ERR_INVALID_PURPOSE 26
266#define X509_V_ERR_CERT_UNTRUSTED 27
267#define X509_V_ERR_CERT_REJECTED 28
260 268
261/* The application is not happy */ 269/* The application is not happy */
262#define X509_V_ERR_APPLICATION_VERIFICATION 50 270#define X509_V_ERR_APPLICATION_VERIFICATION 50
@@ -284,6 +292,8 @@ void X509_OBJECT_free_contents(X509_OBJECT *a);
284X509_STORE *X509_STORE_new(void ); 292X509_STORE *X509_STORE_new(void );
285void X509_STORE_free(X509_STORE *v); 293void X509_STORE_free(X509_STORE *v);
286 294
295X509_STORE_CTX *X509_STORE_CTX_new(void);
296void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
287void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, 297void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
288 X509 *x509, STACK_OF(X509) *chain); 298 X509 *x509, STACK_OF(X509) *chain);
289void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); 299void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
@@ -305,6 +315,7 @@ int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
305#ifndef NO_STDIO 315#ifndef NO_STDIO
306int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); 316int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
307int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); 317int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
318int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
308#endif 319#endif
309 320
310 321
@@ -327,8 +338,8 @@ int X509_STORE_load_locations (X509_STORE *ctx,
327int X509_STORE_set_default_paths(X509_STORE *ctx); 338int X509_STORE_set_default_paths(X509_STORE *ctx);
328#endif 339#endif
329 340
330int X509_STORE_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), 341int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
331 int (*dup_func)(), void (*free_func)()); 342 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
332int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); 343int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
333void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); 344void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
334int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); 345int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
@@ -336,8 +347,13 @@ void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
336int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); 347int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
337X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); 348X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
338STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); 349STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
350STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
339void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); 351void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
340void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); 352void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk);
353int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
354int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
355int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
356 int purpose, int trust);
341 357
342#ifdef __cplusplus 358#ifdef __cplusplus
343} 359}
diff --git a/src/lib/libcrypto/x509/x509name.c b/src/lib/libcrypto/x509/x509name.c
index 2a422be350..cf2382d42c 100644
--- a/src/lib/libcrypto/x509/x509name.c
+++ b/src/lib/libcrypto/x509/x509name.c
@@ -171,6 +171,42 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)
171 return(ret); 171 return(ret);
172 } 172 }
173 173
174int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
175 unsigned char *bytes, int len, int loc, int set)
176{
177 X509_NAME_ENTRY *ne;
178 int ret;
179 ne = X509_NAME_ENTRY_create_by_OBJ(NULL, obj, type, bytes, len);
180 if(!ne) return 0;
181 ret = X509_NAME_add_entry(name, ne, loc, set);
182 X509_NAME_ENTRY_free(ne);
183 return ret;
184}
185
186int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
187 unsigned char *bytes, int len, int loc, int set)
188{
189 X509_NAME_ENTRY *ne;
190 int ret;
191 ne = X509_NAME_ENTRY_create_by_NID(NULL, nid, type, bytes, len);
192 if(!ne) return 0;
193 ret = X509_NAME_add_entry(name, ne, loc, set);
194 X509_NAME_ENTRY_free(ne);
195 return ret;
196}
197
198int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type,
199 unsigned char *bytes, int len, int loc, int set)
200{
201 X509_NAME_ENTRY *ne;
202 int ret;
203 ne = X509_NAME_ENTRY_create_by_txt(NULL, field, type, bytes, len);
204 if(!ne) return 0;
205 ret = X509_NAME_add_entry(name, ne, loc, set);
206 X509_NAME_ENTRY_free(ne);
207 return ret;
208}
209
174/* if set is -1, append to previous set, 0 'a new one', and 1, 210/* if set is -1, append to previous set, 0 'a new one', and 1,
175 * prepend to the guy we are about to stomp on. */ 211 * prepend to the guy we are about to stomp on. */
176int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, 212int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc,
@@ -236,10 +272,30 @@ err:
236 return(0); 272 return(0);
237 } 273 }
238 274
275X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
276 char *field, int type, unsigned char *bytes, int len)
277 {
278 ASN1_OBJECT *obj;
279 X509_NAME_ENTRY *nentry;
280
281 obj=OBJ_txt2obj(field, 0);
282 if (obj == NULL)
283 {
284 X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_TXT,
285 X509_R_INVALID_FIELD_NAME);
286 ERR_add_error_data(2, "name=", field);
287 return(NULL);
288 }
289 nentry = X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len);
290 ASN1_OBJECT_free(obj);
291 return nentry;
292 }
293
239X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, 294X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
240 int type, unsigned char *bytes, int len) 295 int type, unsigned char *bytes, int len)
241 { 296 {
242 ASN1_OBJECT *obj; 297 ASN1_OBJECT *obj;
298 X509_NAME_ENTRY *nentry;
243 299
244 obj=OBJ_nid2obj(nid); 300 obj=OBJ_nid2obj(nid);
245 if (obj == NULL) 301 if (obj == NULL)
@@ -247,7 +303,9 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
247 X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID,X509_R_UNKNOWN_NID); 303 X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID,X509_R_UNKNOWN_NID);
248 return(NULL); 304 return(NULL);
249 } 305 }
250 return(X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len)); 306 nentry = X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len);
307 ASN1_OBJECT_free(obj);
308 return nentry;
251 } 309 }
252 310
253X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, 311X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
@@ -267,7 +325,7 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
267 goto err; 325 goto err;
268 if (!X509_NAME_ENTRY_set_data(ret,type,bytes,len)) 326 if (!X509_NAME_ENTRY_set_data(ret,type,bytes,len))
269 goto err; 327 goto err;
270 328
271 if ((ne != NULL) && (*ne == NULL)) *ne=ret; 329 if ((ne != NULL) && (*ne == NULL)) *ne=ret;
272 return(ret); 330 return(ret);
273err: 331err:
@@ -294,6 +352,10 @@ int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
294 int i; 352 int i;
295 353
296 if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return(0); 354 if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return(0);
355 if(type & MBSTRING_FLAG)
356 return ASN1_STRING_set_by_NID(&ne->value, bytes,
357 len, type,
358 OBJ_obj2nid(ne->object)) ? 1 : 0;
297 if (len < 0) len=strlen((char *)bytes); 359 if (len < 0) len=strlen((char *)bytes);
298 i=ASN1_STRING_set(ne->value,bytes,len); 360 i=ASN1_STRING_set(ne->value,bytes,len);
299 if (!i) return(0); 361 if (!i) return(0);
diff --git a/src/lib/libcrypto/x509/x509spki.c b/src/lib/libcrypto/x509/x509spki.c
new file mode 100644
index 0000000000..b35c3f92e7
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509spki.c
@@ -0,0 +1,121 @@
1/* x509spki.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/x509.h>
62#include <openssl/asn1_mac.h>
63
64int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey)
65{
66 if ((x == NULL) || (x->spkac == NULL)) return(0);
67 return(X509_PUBKEY_set(&(x->spkac->pubkey),pkey));
68}
69
70EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x)
71{
72 if ((x == NULL) || (x->spkac == NULL))
73 return(NULL);
74 return(X509_PUBKEY_get(x->spkac->pubkey));
75}
76
77/* Load a Netscape SPKI from a base64 encoded string */
78
79NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len)
80{
81 unsigned char *spki_der, *p;
82 int spki_len;
83 NETSCAPE_SPKI *spki;
84 if(len <= 0) len = strlen(str);
85 if (!(spki_der = Malloc(len + 1))) {
86 X509err(X509_F_NETSCAPE_SPKI_B64_DECODE, ERR_R_MALLOC_FAILURE);
87 return NULL;
88 }
89 spki_len = EVP_DecodeBlock(spki_der, (const unsigned char *)str, len);
90 if(spki_len < 0) {
91 X509err(X509_F_NETSCAPE_SPKI_B64_DECODE,
92 X509_R_BASE64_DECODE_ERROR);
93 Free(spki_der);
94 return NULL;
95 }
96 p = spki_der;
97 spki = d2i_NETSCAPE_SPKI(NULL, &p, spki_len);
98 Free(spki_der);
99 return spki;
100}
101
102/* Generate a base64 encoded string from an SPKI */
103
104char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki)
105{
106 unsigned char *der_spki, *p;
107 char *b64_str;
108 int der_len;
109 der_len = i2d_NETSCAPE_SPKI(spki, NULL);
110 der_spki = Malloc(der_len);
111 b64_str = Malloc(der_len * 2);
112 if(!der_spki || !b64_str) {
113 X509err(X509_F_NETSCAPE_SPKI_B64_ENCODE, ERR_R_MALLOC_FAILURE);
114 return NULL;
115 }
116 p = der_spki;
117 i2d_NETSCAPE_SPKI(spki, &p);
118 EVP_EncodeBlock((unsigned char *)b64_str, der_spki, der_len);
119 Free(der_spki);
120 return b64_str;
121}
diff --git a/src/lib/libcrypto/x509/x_all.c b/src/lib/libcrypto/x509/x_all.c
index f2af895df0..d2bf3c8e1c 100644
--- a/src/lib/libcrypto/x509/x_all.c
+++ b/src/lib/libcrypto/x509/x_all.c
@@ -285,10 +285,22 @@ RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa)
285 (unsigned char **)(rsa))); 285 (unsigned char **)(rsa)));
286 } 286 }
287 287
288RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
289 {
290 return((RSA *)ASN1_d2i_fp((char *(*)())
291 RSA_new,(char *(*)())d2i_RSA_PUBKEY, (fp),
292 (unsigned char **)(rsa)));
293 }
294
288int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa) 295int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa)
289 { 296 {
290 return(ASN1_i2d_fp(i2d_RSAPublicKey,fp,(unsigned char *)rsa)); 297 return(ASN1_i2d_fp(i2d_RSAPublicKey,fp,(unsigned char *)rsa));
291 } 298 }
299
300int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
301 {
302 return(ASN1_i2d_fp(i2d_RSA_PUBKEY,fp,(unsigned char *)rsa));
303 }
292#endif 304#endif
293 305
294RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa) 306RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
@@ -310,10 +322,22 @@ RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa)
310 (unsigned char **)(rsa))); 322 (unsigned char **)(rsa)));
311 } 323 }
312 324
325RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
326 {
327 return((RSA *)ASN1_d2i_bio((char *(*)())
328 RSA_new,(char *(*)())d2i_RSA_PUBKEY, (bp),
329 (unsigned char **)(rsa)));
330 }
331
313int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa) 332int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa)
314 { 333 {
315 return(ASN1_i2d_bio(i2d_RSAPublicKey,bp,(unsigned char *)rsa)); 334 return(ASN1_i2d_bio(i2d_RSAPublicKey,bp,(unsigned char *)rsa));
316 } 335 }
336
337int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
338 {
339 return(ASN1_i2d_bio(i2d_RSA_PUBKEY,bp,(unsigned char *)rsa));
340 }
317#endif 341#endif
318 342
319#ifndef NO_DSA 343#ifndef NO_DSA
@@ -329,6 +353,18 @@ int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa)
329 { 353 {
330 return(ASN1_i2d_fp(i2d_DSAPrivateKey,fp,(unsigned char *)dsa)); 354 return(ASN1_i2d_fp(i2d_DSAPrivateKey,fp,(unsigned char *)dsa));
331 } 355 }
356
357DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa)
358 {
359 return((DSA *)ASN1_d2i_fp((char *(*)())
360 DSA_new,(char *(*)())d2i_DSA_PUBKEY, (fp),
361 (unsigned char **)(dsa)));
362 }
363
364int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa)
365 {
366 return(ASN1_i2d_fp(i2d_DSA_PUBKEY,fp,(unsigned char *)dsa));
367 }
332#endif 368#endif
333 369
334DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa) 370DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa)
@@ -342,6 +378,19 @@ int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa)
342 { 378 {
343 return(ASN1_i2d_bio(i2d_DSAPrivateKey,bp,(unsigned char *)dsa)); 379 return(ASN1_i2d_bio(i2d_DSAPrivateKey,bp,(unsigned char *)dsa));
344 } 380 }
381
382DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa)
383 {
384 return((DSA *)ASN1_d2i_bio((char *(*)())
385 DSA_new,(char *(*)())d2i_DSA_PUBKEY, (bp),
386 (unsigned char **)(dsa)));
387 }
388
389int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
390 {
391 return(ASN1_i2d_bio(i2d_DSA_PUBKEY,bp,(unsigned char *)dsa));
392 }
393
345#endif 394#endif
346 395
347X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn) 396X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn)
@@ -362,19 +411,19 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne)
362 (char *(*)())d2i_X509_NAME_ENTRY,(char *)ne)); 411 (char *(*)())d2i_X509_NAME_ENTRY,(char *)ne));
363 } 412 }
364 413
365int X509_digest(X509 *data, EVP_MD *type, unsigned char *md, 414int X509_digest(X509 *data, const EVP_MD *type, unsigned char *md,
366 unsigned int *len) 415 unsigned int *len)
367 { 416 {
368 return(ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)); 417 return(ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len));
369 } 418 }
370 419
371int X509_NAME_digest(X509_NAME *data, EVP_MD *type, unsigned char *md, 420int X509_NAME_digest(X509_NAME *data, const EVP_MD *type, unsigned char *md,
372 unsigned int *len) 421 unsigned int *len)
373 { 422 {
374 return(ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)); 423 return(ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len));
375 } 424 }
376 425
377int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, EVP_MD *type, 426int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type,
378 unsigned char *md, unsigned int *len) 427 unsigned char *md, unsigned int *len)
379 { 428 {
380 return(ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type, 429 return(ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,
@@ -420,6 +469,29 @@ int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf)
420 { 469 {
421 return(ASN1_i2d_fp(i2d_PKCS8_PRIV_KEY_INFO,fp,(unsigned char *)p8inf)); 470 return(ASN1_i2d_fp(i2d_PKCS8_PRIV_KEY_INFO,fp,(unsigned char *)p8inf));
422 } 471 }
472
473int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
474 {
475 PKCS8_PRIV_KEY_INFO *p8inf;
476 int ret;
477 p8inf = EVP_PKEY2PKCS8(key);
478 if(!p8inf) return 0;
479 ret = i2d_PKCS8_PRIV_KEY_INFO_fp(fp, p8inf);
480 PKCS8_PRIV_KEY_INFO_free(p8inf);
481 return ret;
482 }
483
484int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey)
485 {
486 return(ASN1_i2d_fp(i2d_PrivateKey,fp,(unsigned char *)pkey));
487 }
488
489EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a)
490{
491 return((EVP_PKEY *)ASN1_d2i_fp((char *(*)())EVP_PKEY_new,
492 (char *(*)())d2i_AutoPrivateKey, (fp),(unsigned char **)(a)));
493}
494
423#endif 495#endif
424 496
425PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, 497PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
@@ -435,3 +507,25 @@ int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf)
435 { 507 {
436 return(ASN1_i2d_bio(i2d_PKCS8_PRIV_KEY_INFO,bp,(unsigned char *)p8inf)); 508 return(ASN1_i2d_bio(i2d_PKCS8_PRIV_KEY_INFO,bp,(unsigned char *)p8inf));
437 } 509 }
510
511int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
512 {
513 PKCS8_PRIV_KEY_INFO *p8inf;
514 int ret;
515 p8inf = EVP_PKEY2PKCS8(key);
516 if(!p8inf) return 0;
517 ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
518 PKCS8_PRIV_KEY_INFO_free(p8inf);
519 return ret;
520 }
521
522int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey)
523 {
524 return(ASN1_i2d_bio(i2d_PrivateKey,bp,(unsigned char *)pkey));
525 }
526
527EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a)
528 {
529 return((EVP_PKEY *)ASN1_d2i_bio((char *(*)())EVP_PKEY_new,
530 (char *(*)())d2i_AutoPrivateKey, (bp),(unsigned char **)(a)));
531 }
diff --git a/src/lib/libcrypto/x509v3/Makefile.ssl b/src/lib/libcrypto/x509v3/Makefile.ssl
index 72871edbc1..1bb746d52d 100644
--- a/src/lib/libcrypto/x509v3/Makefile.ssl
+++ b/src/lib/libcrypto/x509v3/Makefile.ssl
@@ -24,10 +24,10 @@ APPS=
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c \ 25LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c \
26v3_lib.c v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.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_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.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
28LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \ 28LIBOBJ= 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 \ 29v3_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 30v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o
31 31
32SRC= $(LIBSRC) 32SRC= $(LIBSRC)
33 33
@@ -285,6 +285,25 @@ v3_ia5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
285v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 285v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
286v3_ia5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 286v3_ia5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
287v3_ia5.o: ../../include/openssl/x509v3.h ../cryptlib.h 287v3_ia5.o: ../../include/openssl/x509v3.h ../cryptlib.h
288v3_info.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
289v3_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
290v3_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
291v3_info.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
292v3_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
293v3_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
294v3_info.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
295v3_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h
296v3_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
297v3_info.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
298v3_info.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
299v3_info.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
300v3_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
301v3_info.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
302v3_info.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
303v3_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
304v3_info.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
305v3_info.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
306v3_info.o: ../cryptlib.h
288v3_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 307v3_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
289v3_int.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 308v3_int.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
290v3_int.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 309v3_int.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -320,7 +339,7 @@ v3_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
320v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 339v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
321v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 340v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
322v3_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 341v3_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
323v3_lib.o: ../../include/openssl/x509v3.h ../cryptlib.h 342v3_lib.o: ../../include/openssl/x509v3.h ../cryptlib.h ext_dat.h
324v3_pku.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 343v3_pku.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
325v3_pku.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 344v3_pku.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
326v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 345v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -358,6 +377,24 @@ v3_prn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
358v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 377v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
359v3_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 378v3_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
360v3_prn.o: ../../include/openssl/x509v3.h ../cryptlib.h 379v3_prn.o: ../../include/openssl/x509v3.h ../cryptlib.h
380v3_purp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
381v3_purp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
382v3_purp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
383v3_purp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
384v3_purp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
385v3_purp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
386v3_purp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
387v3_purp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
388v3_purp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
389v3_purp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
390v3_purp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
391v3_purp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
392v3_purp.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
393v3_purp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
394v3_purp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
395v3_purp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
396v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
397v3_purp.o: ../../include/openssl/x509v3.h ../cryptlib.h
361v3_skey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 398v3_skey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
362v3_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 399v3_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
363v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 400v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
diff --git a/src/lib/libcrypto/x509v3/README b/src/lib/libcrypto/x509v3/README
index 3b2cc047be..e69de29bb2 100644
--- a/src/lib/libcrypto/x509v3/README
+++ b/src/lib/libcrypto/x509v3/README
@@ -1,4 +0,0 @@
1WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
2
3This is ***VERY*** new experimental code and is likely to change
4considerably or vanish altogether.
diff --git a/src/lib/libcrypto/x509v3/ext_dat.h b/src/lib/libcrypto/x509v3/ext_dat.h
new file mode 100644
index 0000000000..801a585a52
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/ext_dat.h
@@ -0,0 +1,97 @@
1/* ext_dat.h */
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/* This file contains a table of "standard" extensions */
59
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;
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;
64
65/* This table will be searched using OBJ_bsearch so it *must* kept in
66 * order of the ext_nid values.
67 */
68
69static X509V3_EXT_METHOD *standard_exts[] = {
70&v3_nscert,
71&v3_ns_ia5_list[0],
72&v3_ns_ia5_list[1],
73&v3_ns_ia5_list[2],
74&v3_ns_ia5_list[3],
75&v3_ns_ia5_list[4],
76&v3_ns_ia5_list[5],
77&v3_ns_ia5_list[6],
78&v3_skey_id,
79&v3_key_usage,
80&v3_pkey_usage_period,
81&v3_alt[0],
82&v3_alt[1],
83&v3_bcons,
84&v3_crl_num,
85&v3_cpols,
86&v3_akey_id,
87&v3_crld,
88&v3_ext_ku,
89&v3_crl_reason,
90&v3_sxnet,
91&v3_info,
92};
93
94/* Number of standard extensions */
95
96#define STANDARD_EXTENSION_COUNT (sizeof(standard_exts)/sizeof(X509V3_EXT_METHOD *))
97
diff --git a/src/lib/libcrypto/x509v3/tabtest.c b/src/lib/libcrypto/x509v3/tabtest.c
new file mode 100644
index 0000000000..dad0d38dd5
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/tabtest.c
@@ -0,0 +1,88 @@
1/* tabtest.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59/* Simple program to check the ext_dat.h is correct and print out
60 * problems if it is not.
61 */
62
63#include <stdio.h>
64
65#include <openssl/x509v3.h>
66
67#include "ext_dat.h"
68
69main()
70{
71 int i, prev = -1, bad = 0;
72 X509V3_EXT_METHOD **tmp;
73 i = sizeof(standard_exts) / sizeof(X509V3_EXT_METHOD *);
74 if(i != STANDARD_EXTENSION_COUNT)
75 fprintf(stderr, "Extension number invalid expecting %d\n", i);
76 tmp = standard_exts;
77 for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) {
78 if((*tmp)->ext_nid < prev) bad = 1;
79 prev = (*tmp)->ext_nid;
80
81 }
82 if(bad) {
83 tmp = standard_exts;
84 fprintf(stderr, "Extensions out of order!\n");
85 for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
86 printf("%d : %s\n", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid));
87 } else fprintf(stderr, "Order OK\n");
88}
diff --git a/src/lib/libcrypto/x509v3/v3_akey.c b/src/lib/libcrypto/x509v3/v3_akey.c
index 4099e6019e..96c04fe4f5 100644
--- a/src/lib/libcrypto/x509v3/v3_akey.c
+++ b/src/lib/libcrypto/x509v3/v3_akey.c
@@ -129,10 +129,10 @@ AUTHORITY_KEYID *d2i_AUTHORITY_KEYID(AUTHORITY_KEYID **a, unsigned char **pp,
129void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a) 129void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a)
130{ 130{
131 if (a == NULL) return; 131 if (a == NULL) return;
132 ASN1_OCTET_STRING_free(a->keyid); 132 M_ASN1_OCTET_STRING_free(a->keyid);
133 sk_GENERAL_NAME_pop_free(a->issuer, GENERAL_NAME_free); 133 sk_GENERAL_NAME_pop_free(a->issuer, GENERAL_NAME_free);
134 ASN1_INTEGER_free (a->serial); 134 M_ASN1_INTEGER_free (a->serial);
135 Free ((char *)a); 135 Free (a);
136} 136}
137 137
138static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, 138static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
@@ -214,7 +214,7 @@ if(keyid) {
214 214
215if((issuer && !ikeyid) || (issuer == 2)) { 215if((issuer && !ikeyid) || (issuer == 2)) {
216 isname = X509_NAME_dup(X509_get_issuer_name(cert)); 216 isname = X509_NAME_dup(X509_get_issuer_name(cert));
217 serial = ASN1_INTEGER_dup(X509_get_serialNumber(cert)); 217 serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(cert));
218 if(!isname || !serial) { 218 if(!isname || !serial) {
219 X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS); 219 X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS);
220 goto err; 220 goto err;
@@ -241,8 +241,8 @@ return akeyid;
241 241
242err: 242err:
243X509_NAME_free(isname); 243X509_NAME_free(isname);
244ASN1_INTEGER_free(serial); 244M_ASN1_INTEGER_free(serial);
245ASN1_OCTET_STRING_free(ikeyid); 245M_ASN1_OCTET_STRING_free(ikeyid);
246return NULL; 246return NULL;
247 247
248} 248}
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index b5e1f8af96..5ccd1e0e3d 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -84,7 +84,6 @@ NULL, NULL,
84(X509V3_EXT_I2V)i2v_GENERAL_NAMES, 84(X509V3_EXT_I2V)i2v_GENERAL_NAMES,
85(X509V3_EXT_V2I)v2i_issuer_alt, 85(X509V3_EXT_V2I)v2i_issuer_alt,
86NULL, NULL, NULL}, 86NULL, NULL, NULL},
87EXT_END
88}; 87};
89 88
90STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 89STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
@@ -273,7 +272,7 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
273 while((i = X509_NAME_get_index_by_NID(nm, 272 while((i = X509_NAME_get_index_by_NID(nm,
274 NID_pkcs9_emailAddress, i)) > 0) { 273 NID_pkcs9_emailAddress, i)) > 0) {
275 ne = X509_NAME_get_entry(nm, i); 274 ne = X509_NAME_get_entry(nm, i);
276 email = ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne)); 275 email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne));
277 if(!email || !(gen = GENERAL_NAME_new())) { 276 if(!email || !(gen = GENERAL_NAME_new())) {
278 X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE); 277 X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE);
279 goto err; 278 goto err;
@@ -293,7 +292,7 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
293 292
294 err: 293 err:
295 GENERAL_NAME_free(gen); 294 GENERAL_NAME_free(gen);
296 ASN1_IA5STRING_free(email); 295 M_ASN1_IA5STRING_free(email);
297 return 0; 296 return 0;
298 297
299} 298}
@@ -371,7 +370,7 @@ if(!name_cmp(name, "email")) {
371 goto err; 370 goto err;
372 } 371 }
373 ip[0] = i1; ip[1] = i2 ; ip[2] = i3 ; ip[3] = i4; 372 ip[0] = i1; ip[1] = i2 ; ip[2] = i3 ; ip[3] = i4;
374 if(!(gen->d.ip = ASN1_OCTET_STRING_new()) || 373 if(!(gen->d.ip = M_ASN1_OCTET_STRING_new()) ||
375 !ASN1_STRING_set(gen->d.ip, ip, 4)) { 374 !ASN1_STRING_set(gen->d.ip, ip, 4)) {
376 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); 375 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE);
377 goto err; 376 goto err;
@@ -384,7 +383,7 @@ if(!name_cmp(name, "email")) {
384} 383}
385 384
386if(is_string) { 385if(is_string) {
387 if(!(gen->d.ia5 = ASN1_IA5STRING_new()) || 386 if(!(gen->d.ia5 = M_ASN1_IA5STRING_new()) ||
388 !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, 387 !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value,
389 strlen(value))) { 388 strlen(value))) {
390 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); 389 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/x509v3/v3_bcons.c b/src/lib/libcrypto/x509v3/v3_bcons.c
index de2f855c35..1e3edc205f 100644
--- a/src/lib/libcrypto/x509v3/v3_bcons.c
+++ b/src/lib/libcrypto/x509v3/v3_bcons.c
@@ -122,8 +122,8 @@ BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a,
122void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a) 122void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a)
123{ 123{
124 if (a == NULL) return; 124 if (a == NULL) return;
125 ASN1_INTEGER_free (a->pathlen); 125 M_ASN1_INTEGER_free (a->pathlen);
126 Free ((char *)a); 126 Free (a);
127} 127}
128 128
129static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 129static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509v3/v3_bitst.c b/src/lib/libcrypto/x509v3/v3_bitst.c
index 9828ba15b3..0e1167d05c 100644
--- a/src/lib/libcrypto/x509v3/v3_bitst.c
+++ b/src/lib/libcrypto/x509v3/v3_bitst.c
@@ -61,7 +61,6 @@
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
63 63
64static ASN1_BIT_STRING *asn1_bit_string_new(void);
65static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 64static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
66 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 65 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
67static 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,
@@ -97,11 +96,6 @@ static BIT_STRING_BITNAME key_usage_type_table[] = {
97X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table); 96X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table);
98X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table); 97X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table);
99 98
100static ASN1_BIT_STRING *asn1_bit_string_new(void)
101{
102 return ASN1_BIT_STRING_new();
103}
104
105static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 99static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
106 ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret) 100 ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret)
107{ 101{
@@ -120,7 +114,7 @@ static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
120 ASN1_BIT_STRING *bs; 114 ASN1_BIT_STRING *bs;
121 int i; 115 int i;
122 BIT_STRING_BITNAME *bnam; 116 BIT_STRING_BITNAME *bnam;
123 if(!(bs = ASN1_BIT_STRING_new())) { 117 if(!(bs = M_ASN1_BIT_STRING_new())) {
124 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,ERR_R_MALLOC_FAILURE); 118 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,ERR_R_MALLOC_FAILURE);
125 return NULL; 119 return NULL;
126 } 120 }
@@ -137,7 +131,7 @@ static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
137 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, 131 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,
138 X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); 132 X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT);
139 X509V3_conf_err(val); 133 X509V3_conf_err(val);
140 ASN1_BIT_STRING_free(bs); 134 M_ASN1_BIT_STRING_free(bs);
141 return NULL; 135 return NULL;
142 } 136 }
143 } 137 }
diff --git a/src/lib/libcrypto/x509v3/v3_conf.c b/src/lib/libcrypto/x509v3/v3_conf.c
index f19bb3ad84..b2f03010cc 100644
--- a/src/lib/libcrypto/x509v3/v3_conf.c
+++ b/src/lib/libcrypto/x509v3/v3_conf.c
@@ -170,13 +170,13 @@ static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
170 if(!(ext_der = Malloc(ext_len))) goto merr; 170 if(!(ext_der = Malloc(ext_len))) goto merr;
171 p = ext_der; 171 p = ext_der;
172 method->i2d(ext_struc, &p); 172 method->i2d(ext_struc, &p);
173 if(!(ext_oct = ASN1_OCTET_STRING_new())) goto merr; 173 if(!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr;
174 ext_oct->data = ext_der; 174 ext_oct->data = ext_der;
175 ext_oct->length = ext_len; 175 ext_oct->length = ext_len;
176 176
177 ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct); 177 ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct);
178 if(!ext) goto merr; 178 if(!ext) goto merr;
179 ASN1_OCTET_STRING_free(ext_oct); 179 M_ASN1_OCTET_STRING_free(ext_oct);
180 180
181 return ext; 181 return ext;
182 182
@@ -220,7 +220,7 @@ static int v3_check_generic(char **value)
220 return 1; 220 return 1;
221} 221}
222 222
223/* Create a generic extension: for now just handle RAW type */ 223/* Create a generic extension: for now just handle DER type */
224static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, 224static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
225 int crit, int type) 225 int crit, int type)
226{ 226{
@@ -241,7 +241,7 @@ if(!(ext_der = string_to_hex(value, &ext_len))) {
241 goto err; 241 goto err;
242} 242}
243 243
244if(!(oct = ASN1_OCTET_STRING_new())) { 244if(!(oct = M_ASN1_OCTET_STRING_new())) {
245 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE); 245 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE);
246 goto err; 246 goto err;
247} 247}
@@ -254,7 +254,7 @@ extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct);
254 254
255err: 255err:
256ASN1_OBJECT_free(obj); 256ASN1_OBJECT_free(obj);
257ASN1_OCTET_STRING_free(oct); 257M_ASN1_OCTET_STRING_free(oct);
258if(ext_der) Free(ext_der); 258if(ext_der) Free(ext_der);
259return extension; 259return extension;
260} 260}
@@ -302,6 +302,30 @@ int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
302 return 1; 302 return 1;
303} 303}
304 304
305/* Add extensions to certificate request */
306
307int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
308 X509_REQ *req)
309{
310 X509_EXTENSION *ext;
311 STACK_OF(X509_EXTENSION) *extlist = NULL;
312 STACK_OF(CONF_VALUE) *nval;
313 CONF_VALUE *val;
314 int i;
315 if(!(nval = CONF_get_section(conf, section))) return 0;
316 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
317 val = sk_CONF_VALUE_value(nval, i);
318 if(!(ext = X509V3_EXT_conf(conf, ctx, val->name, val->value)))
319 return 0;
320 if(!extlist) extlist = sk_X509_EXTENSION_new_null();
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);
326 return i;
327}
328
305/* Config database functions */ 329/* Config database functions */
306 330
307char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section) 331char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section)
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c
index b4d4883545..466713b50d 100644
--- a/src/lib/libcrypto/x509v3/v3_cpols.c
+++ b/src/lib/libcrypto/x509v3/v3_cpols.c
@@ -169,7 +169,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
169 if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) 169 if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual))
170 goto merr; 170 goto merr;
171 qual->pqualid = OBJ_nid2obj(NID_id_qt_cps); 171 qual->pqualid = OBJ_nid2obj(NID_id_qt_cps);
172 qual->d.cpsuri = ASN1_IA5STRING_new(); 172 qual->d.cpsuri = M_ASN1_IA5STRING_new();
173 if(!ASN1_STRING_set(qual->d.cpsuri, cnf->value, 173 if(!ASN1_STRING_set(qual->d.cpsuri, cnf->value,
174 strlen(cnf->value))) goto merr; 174 strlen(cnf->value))) goto merr;
175 } else if(!name_cmp(cnf->name, "userNotice")) { 175 } else if(!name_cmp(cnf->name, "userNotice")) {
@@ -229,7 +229,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
229 for(i = 0; i < sk_CONF_VALUE_num(unot); i++) { 229 for(i = 0; i < sk_CONF_VALUE_num(unot); i++) {
230 cnf = sk_CONF_VALUE_value(unot, i); 230 cnf = sk_CONF_VALUE_value(unot, i);
231 if(!strcmp(cnf->name, "explicitText")) { 231 if(!strcmp(cnf->name, "explicitText")) {
232 not->exptext = ASN1_VISIBLESTRING_new(); 232 not->exptext = M_ASN1_VISIBLESTRING_new();
233 if(!ASN1_STRING_set(not->exptext, cnf->value, 233 if(!ASN1_STRING_set(not->exptext, cnf->value,
234 strlen(cnf->value))) goto merr; 234 strlen(cnf->value))) goto merr;
235 } else if(!strcmp(cnf->name, "organization")) { 235 } else if(!strcmp(cnf->name, "organization")) {
@@ -238,8 +238,8 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
238 if(!(nref = NOTICEREF_new())) goto merr; 238 if(!(nref = NOTICEREF_new())) goto merr;
239 not->noticeref = nref; 239 not->noticeref = nref;
240 } else nref = not->noticeref; 240 } else nref = not->noticeref;
241 if(ia5org) nref->organization = ASN1_IA5STRING_new(); 241 if(ia5org) nref->organization = M_ASN1_IA5STRING_new();
242 else nref->organization = ASN1_VISIBLESTRING_new(); 242 else nref->organization = M_ASN1_VISIBLESTRING_new();
243 if(!ASN1_STRING_set(nref->organization, cnf->value, 243 if(!ASN1_STRING_set(nref->organization, cnf->value,
244 strlen(cnf->value))) goto merr; 244 strlen(cnf->value))) goto merr;
245 } else if(!strcmp(cnf->name, "noticeNumbers")) { 245 } else if(!strcmp(cnf->name, "noticeNumbers")) {
@@ -538,7 +538,7 @@ void POLICYQUALINFO_free(POLICYQUALINFO *a)
538 if (a == NULL) return; 538 if (a == NULL) return;
539 switch(OBJ_obj2nid(a->pqualid)) { 539 switch(OBJ_obj2nid(a->pqualid)) {
540 case NID_id_qt_cps: 540 case NID_id_qt_cps:
541 ASN1_IA5STRING_free(a->d.cpsuri); 541 M_ASN1_IA5STRING_free(a->d.cpsuri);
542 break; 542 break;
543 543
544 case NID_id_qt_unotice: 544 case NID_id_qt_unotice:
@@ -596,7 +596,7 @@ void USERNOTICE_free(USERNOTICE *a)
596{ 596{
597 if (a == NULL) return; 597 if (a == NULL) return;
598 NOTICEREF_free(a->noticeref); 598 NOTICEREF_free(a->noticeref);
599 DISPLAYTEXT_free(a->exptext); 599 M_DISPLAYTEXT_free(a->exptext);
600 Free (a); 600 Free (a);
601} 601}
602 602
@@ -646,7 +646,7 @@ NOTICEREF *d2i_NOTICEREF(NOTICEREF **a, unsigned char **pp,long length)
646void NOTICEREF_free(NOTICEREF *a) 646void NOTICEREF_free(NOTICEREF *a)
647{ 647{
648 if (a == NULL) return; 648 if (a == NULL) return;
649 DISPLAYTEXT_free(a->organization); 649 M_DISPLAYTEXT_free(a->organization);
650 sk_pop_free(a->noticenos, ASN1_STRING_free); 650 sk_pop_free(a->noticenos, ASN1_STRING_free);
651 Free (a); 651 Free (a);
652} 652}
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c
index 897ffb63e4..e459d2595a 100644
--- a/src/lib/libcrypto/x509v3/v3_crld.c
+++ b/src/lib/libcrypto/x509v3/v3_crld.c
@@ -211,20 +211,20 @@ void DIST_POINT_free(DIST_POINT *a)
211{ 211{
212 if (a == NULL) return; 212 if (a == NULL) return;
213 DIST_POINT_NAME_free(a->distpoint); 213 DIST_POINT_NAME_free(a->distpoint);
214 ASN1_BIT_STRING_free(a->reasons); 214 M_ASN1_BIT_STRING_free(a->reasons);
215 sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free); 215 sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free);
216 Free ((char *)a); 216 Free (a);
217} 217}
218 218
219int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) 219int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp)
220{ 220{
221 int v = 0;
222 M_ASN1_I2D_vars(a); 221 M_ASN1_I2D_vars(a);
223 222
224 if(a->fullname) { 223 if(a->fullname) {
225 M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES); 224 M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES);
226 } else { 225 } else {
227 M_ASN1_I2D_len_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); 226 M_ASN1_I2D_len_IMP_SET_opt_type(X509_NAME_ENTRY,
227 a->relativename, i2d_X509_NAME_ENTRY, 1);
228 } 228 }
229 229
230 /* Don't want a SEQUENCE so... */ 230 /* Don't want a SEQUENCE so... */
@@ -234,7 +234,8 @@ int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp)
234 if(a->fullname) { 234 if(a->fullname) {
235 M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0); 235 M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0);
236 } else { 236 } else {
237 M_ASN1_I2D_put_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); 237 M_ASN1_I2D_put_IMP_SET_opt_type(X509_NAME_ENTRY,
238 a->relativename, i2d_X509_NAME_ENTRY, 1);
238 } 239 }
239 M_ASN1_I2D_finish(); 240 M_ASN1_I2D_finish();
240} 241}
@@ -253,9 +254,9 @@ DIST_POINT_NAME *DIST_POINT_NAME_new(void)
253void DIST_POINT_NAME_free(DIST_POINT_NAME *a) 254void DIST_POINT_NAME_free(DIST_POINT_NAME *a)
254{ 255{
255 if (a == NULL) return; 256 if (a == NULL) return;
256 X509_NAME_free(a->relativename); 257 sk_X509_NAME_ENTRY_pop_free(a->relativename, X509_NAME_ENTRY_free);
257 sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free); 258 sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free);
258 Free ((char *)a); 259 Free (a);
259} 260}
260 261
261DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, 262DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
@@ -273,7 +274,8 @@ DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
273 M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES, 274 M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES,
274 V_ASN1_SEQUENCE); 275 V_ASN1_SEQUENCE);
275 } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) { 276 } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) {
276 M_ASN1_D2I_get_EXP_opt (ret->relativename, d2i_X509_NAME, 1); 277 M_ASN1_D2I_get_IMP_set_opt_type (X509_NAME_ENTRY,
278 ret->relativename, d2i_X509_NAME_ENTRY, X509_NAME_ENTRY_free, 1);
277 } else { 279 } else {
278 c.error = ASN1_R_BAD_TAG; 280 c.error = ASN1_R_BAD_TAG;
279 goto err; 281 goto err;
diff --git a/src/lib/libcrypto/x509v3/v3_enum.c b/src/lib/libcrypto/x509v3/v3_enum.c
index db423548ff..aecfdc87f8 100644
--- a/src/lib/libcrypto/x509v3/v3_enum.c
+++ b/src/lib/libcrypto/x509v3/v3_enum.c
@@ -60,8 +60,6 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ASN1_ENUMERATED *asn1_enumerated_new(void);
64
65static ENUMERATED_NAMES crl_reasons[] = { 63static ENUMERATED_NAMES crl_reasons[] = {
66{0, "Unspecified", "unspecified"}, 64{0, "Unspecified", "unspecified"},
67{1, "Key Compromise", "keyCompromise"}, 65{1, "Key Compromise", "keyCompromise"},
@@ -76,20 +74,15 @@ static ENUMERATED_NAMES crl_reasons[] = {
76 74
77X509V3_EXT_METHOD v3_crl_reason = { 75X509V3_EXT_METHOD v3_crl_reason = {
78NID_crl_reason, 0, 76NID_crl_reason, 0,
79(X509V3_EXT_NEW)asn1_enumerated_new, 77(X509V3_EXT_NEW)ASN1_ENUMERATED_new,
80(X509V3_EXT_FREE)ASN1_STRING_free, 78(X509V3_EXT_FREE)ASN1_ENUMERATED_free,
81(X509V3_EXT_D2I)d2i_ASN1_ENUMERATED, 79(X509V3_EXT_D2I)d2i_ASN1_ENUMERATED,
82(X509V3_EXT_I2D)i2d_ASN1_ENUMERATED, 80(X509V3_EXT_I2D)i2d_ASN1_ENUMERATED,
83(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, 81(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE,
84(X509V3_EXT_S2I)NULL, 82(X509V3_EXT_S2I)0,
85NULL, NULL, NULL, NULL, crl_reasons}; 83NULL, NULL, NULL, NULL, crl_reasons};
86 84
87 85
88static ASN1_ENUMERATED *asn1_enumerated_new(void)
89{
90 return ASN1_ENUMERATED_new();
91}
92
93char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, 86char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method,
94 ASN1_ENUMERATED *e) 87 ASN1_ENUMERATED *e)
95{ 88{
diff --git a/src/lib/libcrypto/x509v3/v3_genn.c b/src/lib/libcrypto/x509v3/v3_genn.c
index af716232f8..894afa7e03 100644
--- a/src/lib/libcrypto/x509v3/v3_genn.c
+++ b/src/lib/libcrypto/x509v3/v3_genn.c
@@ -88,12 +88,15 @@ int i2d_GENERAL_NAME(GENERAL_NAME *a, unsigned char **pp)
88 88
89 switch(a->type) { 89 switch(a->type) {
90 90
91 case GEN_OTHERNAME:
92 case GEN_X400: 91 case GEN_X400:
93 case GEN_EDIPARTY: 92 case GEN_EDIPARTY:
94 ret = i2d_ASN1_TYPE(a->d.other, pp); 93 ret = i2d_ASN1_TYPE(a->d.other, pp);
95 break; 94 break;
96 95
96 case GEN_OTHERNAME:
97 ret = i2d_OTHERNAME(a->d.otherName, pp);
98 break;
99
97 case GEN_EMAIL: 100 case GEN_EMAIL:
98 case GEN_DNS: 101 case GEN_DNS:
99 case GEN_URI: 102 case GEN_URI:
@@ -137,12 +140,15 @@ GENERAL_NAME *d2i_GENERAL_NAME(GENERAL_NAME **a, unsigned char **pp,
137 140
138 switch(ret->type) { 141 switch(ret->type) {
139 /* Just put these in a "blob" for now */ 142 /* Just put these in a "blob" for now */
140 case GEN_OTHERNAME:
141 case GEN_X400: 143 case GEN_X400:
142 case GEN_EDIPARTY: 144 case GEN_EDIPARTY:
143 M_ASN1_D2I_get_imp(ret->d.other, d2i_ASN1_TYPE,V_ASN1_SEQUENCE); 145 M_ASN1_D2I_get_imp(ret->d.other, d2i_ASN1_TYPE,V_ASN1_SEQUENCE);
144 break; 146 break;
145 147
148 case GEN_OTHERNAME:
149 M_ASN1_D2I_get_imp(ret->d.otherName, d2i_OTHERNAME,V_ASN1_SEQUENCE);
150 break;
151
146 case GEN_EMAIL: 152 case GEN_EMAIL:
147 case GEN_DNS: 153 case GEN_DNS:
148 case GEN_URI: 154 case GEN_URI:
@@ -176,17 +182,20 @@ void GENERAL_NAME_free(GENERAL_NAME *a)
176{ 182{
177 if (a == NULL) return; 183 if (a == NULL) return;
178 switch(a->type) { 184 switch(a->type) {
179 case GEN_OTHERNAME:
180 case GEN_X400: 185 case GEN_X400:
181 case GEN_EDIPARTY: 186 case GEN_EDIPARTY:
182 ASN1_TYPE_free(a->d.other); 187 ASN1_TYPE_free(a->d.other);
183 break; 188 break;
184 189
190 case GEN_OTHERNAME:
191 OTHERNAME_free(a->d.otherName);
192 break;
193
185 case GEN_EMAIL: 194 case GEN_EMAIL:
186 case GEN_DNS: 195 case GEN_DNS:
187 case GEN_URI: 196 case GEN_URI:
188 197
189 ASN1_IA5STRING_free(a->d.ia5); 198 M_ASN1_IA5STRING_free(a->d.ia5);
190 break; 199 break;
191 200
192 case GEN_DIRNAME: 201 case GEN_DIRNAME:
@@ -194,7 +203,7 @@ void GENERAL_NAME_free(GENERAL_NAME *a)
194 break; 203 break;
195 204
196 case GEN_IPADD: 205 case GEN_IPADD:
197 ASN1_OCTET_STRING_free(a->d.ip); 206 M_ASN1_OCTET_STRING_free(a->d.ip);
198 break; 207 break;
199 208
200 case GEN_RID: 209 case GEN_RID:
@@ -202,11 +211,11 @@ void GENERAL_NAME_free(GENERAL_NAME *a)
202 break; 211 break;
203 212
204 } 213 }
205 Free ((char *)a); 214 Free (a);
206} 215}
207 216
208/* Now the GeneralNames versions: a SEQUENCE OF GeneralName These are needed as 217/* Now the GeneralNames versions: a SEQUENCE OF GeneralName. These are needed as
209 * an explicit functions. 218 * explicit functions.
210 */ 219 */
211 220
212STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new() 221STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new()
@@ -235,3 +244,48 @@ return i2d_ASN1_SET_OF_GENERAL_NAME(a, pp, i2d_GENERAL_NAME, V_ASN1_SEQUENCE,
235IMPLEMENT_STACK_OF(GENERAL_NAME) 244IMPLEMENT_STACK_OF(GENERAL_NAME)
236IMPLEMENT_ASN1_SET_OF(GENERAL_NAME) 245IMPLEMENT_ASN1_SET_OF(GENERAL_NAME)
237 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 Free (a);
290}
291
diff --git a/src/lib/libcrypto/x509v3/v3_ia5.c b/src/lib/libcrypto/x509v3/v3_ia5.c
index 3446c5cd6a..af3525f33e 100644
--- a/src/lib/libcrypto/x509v3/v3_ia5.c
+++ b/src/lib/libcrypto/x509v3/v3_ia5.c
@@ -63,7 +63,6 @@
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static ASN1_IA5STRING *ia5string_new(void);
67static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); 66static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
68static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 67static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
69X509V3_EXT_METHOD v3_ns_ia5_list[] = { 68X509V3_EXT_METHOD v3_ns_ia5_list[] = {
@@ -78,11 +77,6 @@ EXT_END
78}; 77};
79 78
80 79
81static ASN1_IA5STRING *ia5string_new(void)
82{
83 return ASN1_IA5STRING_new();
84}
85
86static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, 80static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
87 ASN1_IA5STRING *ia5) 81 ASN1_IA5STRING *ia5)
88{ 82{
@@ -102,12 +96,15 @@ static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
102 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,X509V3_R_INVALID_NULL_ARGUMENT); 96 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,X509V3_R_INVALID_NULL_ARGUMENT);
103 return NULL; 97 return NULL;
104 } 98 }
105 if(!(ia5 = ASN1_IA5STRING_new())) goto err; 99 if(!(ia5 = M_ASN1_IA5STRING_new())) goto err;
106 if(!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str, 100 if(!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str,
107 strlen(str))) { 101 strlen(str))) {
108 ASN1_IA5STRING_free(ia5); 102 M_ASN1_IA5STRING_free(ia5);
109 goto err; 103 goto err;
110 } 104 }
105#ifdef CHARSET_EBCDIC
106 ebcdic2ascii(ia5->data, ia5->data, ia5->length);
107#endif /*CHARSET_EBCDIC*/
111 return ia5; 108 return ia5;
112 err: 109 err:
113 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE); 110 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c
new file mode 100644
index 0000000000..78d2135046
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_info.c
@@ -0,0 +1,236 @@
1/* v3_info.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/asn1_mac.h>
64#include <openssl/x509v3.h>
65
66static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
67 STACK_OF(ACCESS_DESCRIPTION) *ainfo,
68 STACK_OF(CONF_VALUE) *ret);
69static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
70 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
71
72X509V3_EXT_METHOD v3_info =
73{ NID_info_access, X509V3_EXT_MULTILINE,
74(X509V3_EXT_NEW)AUTHORITY_INFO_ACCESS_new,
75(X509V3_EXT_FREE)AUTHORITY_INFO_ACCESS_free,
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,
80(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
81NULL, NULL, NULL};
82
83static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
84 STACK_OF(ACCESS_DESCRIPTION) *ainfo,
85 STACK_OF(CONF_VALUE) *ret)
86{
87 ACCESS_DESCRIPTION *desc;
88 int i;
89 char objtmp[80], *ntmp;
90 CONF_VALUE *vtmp;
91 for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
92 desc = sk_ACCESS_DESCRIPTION_value(ainfo, i);
93 ret = i2v_GENERAL_NAME(method, desc->location, ret);
94 if(!ret) break;
95 vtmp = sk_CONF_VALUE_value(ret, i);
96 i2t_ASN1_OBJECT(objtmp, 80, desc->method);
97 ntmp = Malloc(strlen(objtmp) + strlen(vtmp->name) + 5);
98 if(!ntmp) {
99 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
100 ERR_R_MALLOC_FAILURE);
101 return NULL;
102 }
103 strcpy(ntmp, objtmp);
104 strcat(ntmp, " - ");
105 strcat(ntmp, vtmp->name);
106 Free(vtmp->name);
107 vtmp->name = ntmp;
108
109 }
110 if(!ret) return sk_CONF_VALUE_new_null();
111 return ret;
112}
113
114static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
115 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
116{
117 STACK_OF(ACCESS_DESCRIPTION) *ainfo = NULL;
118 CONF_VALUE *cnf, ctmp;
119 ACCESS_DESCRIPTION *acc;
120 int i, objlen;
121 char *objtmp, *ptmp;
122 if(!(ainfo = sk_ACCESS_DESCRIPTION_new(NULL))) {
123 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE);
124 return NULL;
125 }
126 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
127 cnf = sk_CONF_VALUE_value(nval, i);
128 if(!(acc = ACCESS_DESCRIPTION_new())
129 || !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) {
130 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE);
131 goto err;
132 }
133 ptmp = strchr(cnf->name, ';');
134 if(!ptmp) {
135 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,X509V3_R_INVALID_SYNTAX);
136 goto err;
137 }
138 objlen = ptmp - cnf->name;
139 ctmp.name = ptmp + 1;
140 ctmp.value = cnf->value;
141 if(!(acc->location = v2i_GENERAL_NAME(method, ctx, &ctmp)))
142 goto err;
143 if(!(objtmp = Malloc(objlen + 1))) {
144 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE);
145 goto err;
146 }
147 strncpy(objtmp, cnf->name, objlen);
148 objtmp[objlen] = 0;
149 acc->method = OBJ_txt2obj(objtmp, 0);
150 if(!acc->method) {
151 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,X509V3_R_BAD_OBJECT);
152 ERR_add_error_data(2, "value=", objtmp);
153 Free(objtmp);
154 goto err;
155 }
156 Free(objtmp);
157
158 }
159 return ainfo;
160 err:
161 sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free);
162 return NULL;
163}
164
165int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **pp)
166{
167 M_ASN1_I2D_vars(a);
168
169 M_ASN1_I2D_len(a->method, i2d_ASN1_OBJECT);
170 M_ASN1_I2D_len(a->location, i2d_GENERAL_NAME);
171
172 M_ASN1_I2D_seq_total();
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 Free (a);
208}
209
210STACK_OF(ACCESS_DESCRIPTION) *AUTHORITY_INFO_ACCESS_new(void)
211{
212 return sk_ACCESS_DESCRIPTION_new(NULL);
213}
214
215void AUTHORITY_INFO_ACCESS_free(STACK_OF(ACCESS_DESCRIPTION) *a)
216{
217 sk_ACCESS_DESCRIPTION_pop_free(a, ACCESS_DESCRIPTION_free);
218}
219
220STACK_OF(ACCESS_DESCRIPTION) *d2i_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) **a,
221 unsigned char **pp, long length)
222{
223return d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(a, pp, length, d2i_ACCESS_DESCRIPTION,
224 ACCESS_DESCRIPTION_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
225}
226
227int i2d_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) *a, unsigned char **pp)
228{
229return i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(a, pp, i2d_ACCESS_DESCRIPTION, V_ASN1_SEQUENCE,
230 V_ASN1_UNIVERSAL, IS_SEQUENCE);
231}
232
233IMPLEMENT_STACK_OF(ACCESS_DESCRIPTION)
234IMPLEMENT_ASN1_SET_OF(ACCESS_DESCRIPTION)
235
236
diff --git a/src/lib/libcrypto/x509v3/v3_int.c b/src/lib/libcrypto/x509v3/v3_int.c
index 637dd5e128..63c201e5f4 100644
--- a/src/lib/libcrypto/x509v3/v3_int.c
+++ b/src/lib/libcrypto/x509v3/v3_int.c
@@ -60,20 +60,13 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ASN1_INTEGER *asn1_integer_new(void);
64
65X509V3_EXT_METHOD v3_crl_num = { 63X509V3_EXT_METHOD v3_crl_num = {
66NID_crl_number, 0, 64NID_crl_number, 0,
67(X509V3_EXT_NEW)asn1_integer_new, 65(X509V3_EXT_NEW)ASN1_INTEGER_new,
68(X509V3_EXT_FREE)ASN1_STRING_free, 66(X509V3_EXT_FREE)ASN1_INTEGER_free,
69(X509V3_EXT_D2I)d2i_ASN1_INTEGER, 67(X509V3_EXT_D2I)d2i_ASN1_INTEGER,
70(X509V3_EXT_I2D)i2d_ASN1_INTEGER, 68(X509V3_EXT_I2D)i2d_ASN1_INTEGER,
71(X509V3_EXT_I2S)i2s_ASN1_INTEGER, 69(X509V3_EXT_I2S)i2s_ASN1_INTEGER,
72(X509V3_EXT_S2I)NULL, 70(X509V3_EXT_S2I)0,
73NULL, NULL, NULL, NULL, NULL}; 71NULL, NULL, NULL, NULL, NULL};
74 72
75
76static ASN1_INTEGER *asn1_integer_new(void)
77{
78 return ASN1_INTEGER_new();
79}
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c
index a0aa5de794..4242d130a2 100644
--- a/src/lib/libcrypto/x509v3/v3_lib.c
+++ b/src/lib/libcrypto/x509v3/v3_lib.c
@@ -62,6 +62,8 @@
62#include <openssl/conf.h> 62#include <openssl/conf.h>
63#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
64 64
65#include "ext_dat.h"
66
65static STACK *ext_list = NULL; 67static STACK *ext_list = NULL;
66 68
67static int ext_cmp(X509V3_EXT_METHOD **a, X509V3_EXT_METHOD **b); 69static int ext_cmp(X509V3_EXT_METHOD **a, X509V3_EXT_METHOD **b);
@@ -87,10 +89,15 @@ static int ext_cmp(X509V3_EXT_METHOD **a, X509V3_EXT_METHOD **b)
87 89
88X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) 90X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid)
89{ 91{
90 X509V3_EXT_METHOD tmp; 92 X509V3_EXT_METHOD tmp, *t = &tmp, **ret;
91 int idx; 93 int idx;
94 if(nid < 0) return NULL;
92 tmp.ext_nid = nid; 95 tmp.ext_nid = nid;
93 if(!ext_list || (tmp.ext_nid < 0) ) return NULL; 96 ret = (X509V3_EXT_METHOD **) OBJ_bsearch((char *)&t,
97 (char *)standard_exts, STANDARD_EXTENSION_COUNT,
98 sizeof(X509V3_EXT_METHOD *), (int (*)())ext_cmp);
99 if(ret) return *ret;
100 if(!ext_list) return NULL;
94 idx = sk_find(ext_list, (char *)&tmp); 101 idx = sk_find(ext_list, (char *)&tmp);
95 if(idx == -1) return NULL; 102 if(idx == -1) return NULL;
96 return (X509V3_EXT_METHOD *)sk_value(ext_list, idx); 103 return (X509V3_EXT_METHOD *)sk_value(ext_list, idx);
@@ -125,7 +132,7 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from)
125 *tmpext = *ext; 132 *tmpext = *ext;
126 tmpext->ext_nid = nid_to; 133 tmpext->ext_nid = nid_to;
127 tmpext->ext_flags |= X509V3_EXT_DYNAMIC; 134 tmpext->ext_flags |= X509V3_EXT_DYNAMIC;
128 return 1; 135 return X509V3_EXT_add(tmpext);
129} 136}
130 137
131void X509V3_EXT_cleanup(void) 138void X509V3_EXT_cleanup(void)
@@ -139,28 +146,12 @@ static void ext_list_free(X509V3_EXT_METHOD *ext)
139 if(ext->ext_flags & X509V3_EXT_DYNAMIC) Free(ext); 146 if(ext->ext_flags & X509V3_EXT_DYNAMIC) Free(ext);
140} 147}
141 148
142extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku; 149/* Legacy function: we don't need to add standard extensions
143extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet; 150 * any more because they are now kept in ext_dat.h.
144extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; 151 */
145
146extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_cpols, v3_crld;
147 152
148int X509V3_add_standard_extensions(void) 153int X509V3_add_standard_extensions(void)
149{ 154{
150 X509V3_EXT_add_list(v3_ns_ia5_list);
151 X509V3_EXT_add_list(v3_alt);
152 X509V3_EXT_add(&v3_bcons);
153 X509V3_EXT_add(&v3_nscert);
154 X509V3_EXT_add(&v3_key_usage);
155 X509V3_EXT_add(&v3_ext_ku);
156 X509V3_EXT_add(&v3_skey_id);
157 X509V3_EXT_add(&v3_akey_id);
158 X509V3_EXT_add(&v3_pkey_usage_period);
159 X509V3_EXT_add(&v3_crl_num);
160 X509V3_EXT_add(&v3_sxnet);
161 X509V3_EXT_add(&v3_crl_reason);
162 X509V3_EXT_add(&v3_cpols);
163 X509V3_EXT_add(&v3_crld);
164 return 1; 155 return 1;
165} 156}
166 157
@@ -175,3 +166,56 @@ void *X509V3_EXT_d2i(X509_EXTENSION *ext)
175 return method->d2i(NULL, &p, ext->value->length); 166 return method->d2i(NULL, &p, ext->value->length);
176} 167}
177 168
169/* Get critical flag and decoded version of extension from a NID.
170 * The "idx" variable returns the last found extension and can
171 * be used to retrieve multiple extensions of the same NID.
172 * However multiple extensions with the same NID is usually
173 * due to a badly encoded certificate so if idx is NULL we
174 * choke if multiple extensions exist.
175 * The "crit" variable is set to the critical value.
176 * The return value is the decoded extension or NULL on
177 * error. The actual error can have several different causes,
178 * the value of *crit reflects the cause:
179 * >= 0, extension found but not decoded (reflects critical value).
180 * -1 extension not found.
181 * -2 extension occurs more than once.
182 */
183
184void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx)
185{
186 int lastpos, i;
187 X509_EXTENSION *ex, *found_ex = NULL;
188 if(!x) {
189 if(idx) *idx = -1;
190 if(crit) *crit = -1;
191 return NULL;
192 }
193 if(idx) lastpos = *idx + 1;
194 else lastpos = 0;
195 if(lastpos < 0) lastpos = 0;
196 for(i = lastpos; i < sk_X509_EXTENSION_num(x); i++)
197 {
198 ex = sk_X509_EXTENSION_value(x, i);
199 if(OBJ_obj2nid(ex->object) == nid) {
200 if(idx) {
201 *idx = i;
202 break;
203 } else if(found_ex) {
204 /* Found more than one */
205 if(crit) *crit = -2;
206 return NULL;
207 }
208 found_ex = ex;
209 }
210 }
211 if(found_ex) {
212 /* Found it */
213 if(crit) *crit = found_ex->critical;
214 return X509V3_EXT_d2i(found_ex);
215 }
216
217 /* Extension not found */
218 if(idx) *idx = -1;
219 if(crit) *crit = -1;
220 return NULL;
221}
diff --git a/src/lib/libcrypto/x509v3/v3_pku.c b/src/lib/libcrypto/x509v3/v3_pku.c
index c13e7d8f45..30a62c6090 100644
--- a/src/lib/libcrypto/x509v3/v3_pku.c
+++ b/src/lib/libcrypto/x509v3/v3_pku.c
@@ -119,9 +119,9 @@ PKEY_USAGE_PERIOD *d2i_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD **a,
119void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a) 119void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a)
120{ 120{
121 if (a == NULL) return; 121 if (a == NULL) return;
122 ASN1_GENERALIZEDTIME_free(a->notBefore); 122 M_ASN1_GENERALIZEDTIME_free(a->notBefore);
123 ASN1_GENERALIZEDTIME_free(a->notAfter); 123 M_ASN1_GENERALIZEDTIME_free(a->notAfter);
124 Free ((char *)a); 124 Free (a);
125} 125}
126 126
127static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, 127static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index dc20c6bdba..bee624c6be 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -81,7 +81,15 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml)
81 nval = sk_CONF_VALUE_value(val, i); 81 nval = sk_CONF_VALUE_value(val, i);
82 if(!nval->name) BIO_puts(out, nval->value); 82 if(!nval->name) BIO_puts(out, nval->value);
83 else if(!nval->value) BIO_puts(out, nval->name); 83 else if(!nval->value) BIO_puts(out, nval->name);
84#ifndef CHARSET_EBCDIC
84 else BIO_printf(out, "%s:%s", nval->name, nval->value); 85 else BIO_printf(out, "%s:%s", nval->name, nval->value);
86#else
87 else {
88 char tmp[10240]; /* 10k is BIO_printf's limit anyway */
89 ascii2ebcdic(tmp, nval->value, strlen(nval->value)+1);
90 BIO_printf(out, "%s:%s", nval->name, tmp);
91 }
92#endif
85 if(ml) BIO_puts(out, "\n"); 93 if(ml) BIO_puts(out, "\n");
86 } 94 }
87} 95}
@@ -103,7 +111,15 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent)
103 ok = 0; 111 ok = 0;
104 goto err; 112 goto err;
105 } 113 }
114#ifndef CHARSET_EBCDIC
106 BIO_printf(out, "%*s%s", indent, "", value); 115 BIO_printf(out, "%*s%s", indent, "", value);
116#else
117 {
118 char tmp[10240]; /* 10k is BIO_printf's limit anyway */
119 ascii2ebcdic(tmp, value, strlen(value)+1);
120 BIO_printf(out, "%*s%s", indent, "", tmp);
121 }
122#endif
107 } else if(method->i2v) { 123 } else if(method->i2v) {
108 if(!(nval = method->i2v(method, ext_str, NULL))) { 124 if(!(nval = method->i2v(method, ext_str, NULL))) {
109 ok = 0; 125 ok = 0;
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
new file mode 100644
index 0000000000..b7494ebcd5
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -0,0 +1,456 @@
1/* v3_purp.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/x509v3.h>
62
63
64static void x509v3_cache_extensions(X509 *x);
65
66static int ca_check(X509 *x);
67static int check_purpose_ssl_client(X509_PURPOSE *xp, X509 *x, int ca);
68static int check_purpose_ssl_server(X509_PURPOSE *xp, X509 *x, int ca);
69static int check_purpose_ns_ssl_server(X509_PURPOSE *xp, X509 *x, int ca);
70static int purpose_smime(X509 *x, int ca);
71static int check_purpose_smime_sign(X509_PURPOSE *xp, X509 *x, int ca);
72static int check_purpose_smime_encrypt(X509_PURPOSE *xp, X509 *x, int ca);
73static int check_purpose_crl_sign(X509_PURPOSE *xp, X509 *x, int ca);
74
75static int xp_cmp(X509_PURPOSE **a, X509_PURPOSE **b);
76static void xptable_free(X509_PURPOSE *p);
77
78static X509_PURPOSE xstandard[] = {
79 {X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_client, "SSL client", "sslclient", NULL},
80 {X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_server, "SSL server", "sslserver", NULL},
81 {X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ssl_server, "Netscape SSL server", "nssslserver", NULL},
82 {X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, "S/MIME signing", "smimesign", NULL},
83 {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, "S/MIME encryption", "smimeencrypt", NULL},
84 {X509_PURPOSE_CRL_SIGN, X509_TRUST_ANY, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL},
85};
86
87#define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE))
88
89IMPLEMENT_STACK_OF(X509_PURPOSE)
90
91static STACK_OF(X509_PURPOSE) *xptable = NULL;
92
93static int xp_cmp(X509_PURPOSE **a, X509_PURPOSE **b)
94{
95 return (*a)->purpose - (*b)->purpose;
96}
97
98int X509_check_purpose(X509 *x, int id, int ca)
99{
100 int idx;
101 X509_PURPOSE *pt;
102 if(!(x->ex_flags & EXFLAG_SET)) {
103 CRYPTO_w_lock(CRYPTO_LOCK_X509);
104 x509v3_cache_extensions(x);
105 CRYPTO_w_unlock(CRYPTO_LOCK_X509);
106 }
107 if(id == -1) return 1;
108 idx = X509_PURPOSE_get_by_id(id);
109 if(idx == -1) return -1;
110 pt = X509_PURPOSE_get0(idx);
111 return pt->check_purpose(pt, x, ca);
112}
113
114int X509_PURPOSE_get_count(void)
115{
116 if(!xptable) return X509_PURPOSE_COUNT;
117 return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT;
118}
119
120X509_PURPOSE * X509_PURPOSE_get0(int idx)
121{
122 if(idx < 0) return NULL;
123 if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
124 return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
125}
126
127int X509_PURPOSE_get_by_sname(char *sname)
128{
129 int i;
130 X509_PURPOSE *xptmp;
131 for(i = 0; i < X509_PURPOSE_get_count(); i++) {
132 xptmp = X509_PURPOSE_get0(i);
133 if(!strcmp(xptmp->sname, sname)) return i;
134 }
135 return -1;
136}
137
138
139int X509_PURPOSE_get_by_id(int purpose)
140{
141 X509_PURPOSE tmp;
142 int idx;
143 if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
144 return purpose - X509_PURPOSE_MIN;
145 tmp.purpose = purpose;
146 if(!xptable) return -1;
147 idx = sk_X509_PURPOSE_find(xptable, &tmp);
148 if(idx == -1) return -1;
149 return idx + X509_PURPOSE_COUNT;
150}
151
152int X509_PURPOSE_add(int id, int trust, int flags,
153 int (*ck)(X509_PURPOSE *, X509 *, int),
154 char *name, char *sname, void *arg)
155{
156 int idx;
157 X509_PURPOSE *ptmp;
158 /* This is set according to what we change: application can't set it */
159 flags &= ~X509_PURPOSE_DYNAMIC;
160 /* This will always be set for application modified trust entries */
161 flags |= X509_PURPOSE_DYNAMIC_NAME;
162 /* Get existing entry if any */
163 idx = X509_PURPOSE_get_by_id(id);
164 /* Need a new entry */
165 if(idx == -1) {
166 if(!(ptmp = Malloc(sizeof(X509_PURPOSE)))) {
167 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
168 return 0;
169 }
170 ptmp->flags = X509_PURPOSE_DYNAMIC;
171 } else ptmp = X509_PURPOSE_get0(idx);
172
173 /* Free existing name if dynamic */
174 if(ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) {
175 Free(ptmp->name);
176 Free(ptmp->sname);
177 }
178 /* dup supplied name */
179 ptmp->name = BUF_strdup(name);
180 ptmp->sname = BUF_strdup(sname);
181 if(!ptmp->name || !ptmp->sname) {
182 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
183 return 0;
184 }
185 /* Keep the dynamic flag of existing entry */
186 ptmp->flags &= X509_PURPOSE_DYNAMIC;
187 /* Set all other flags */
188 ptmp->flags |= flags;
189
190 ptmp->purpose = id;
191 ptmp->trust = trust;
192 ptmp->check_purpose = ck;
193 ptmp->usr_data = arg;
194
195 /* If its a new entry manage the dynamic table */
196 if(idx == -1) {
197 if(!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) {
198 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
199 return 0;
200 }
201 if (!sk_X509_PURPOSE_push(xptable, ptmp)) {
202 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
203 return 0;
204 }
205 }
206 return 1;
207}
208
209static void xptable_free(X509_PURPOSE *p)
210 {
211 if(!p) return;
212 if (p->flags & X509_PURPOSE_DYNAMIC)
213 {
214 if (p->flags & X509_PURPOSE_DYNAMIC_NAME) {
215 Free(p->name);
216 Free(p->sname);
217 }
218 Free(p);
219 }
220 }
221
222void X509_PURPOSE_cleanup(void)
223{
224 int i;
225 sk_X509_PURPOSE_pop_free(xptable, xptable_free);
226 for(i = 0; i < X509_PURPOSE_COUNT; i++) xptable_free(xstandard + i);
227 xptable = NULL;
228}
229
230int X509_PURPOSE_get_id(X509_PURPOSE *xp)
231{
232 return xp->purpose;
233}
234
235char *X509_PURPOSE_get0_name(X509_PURPOSE *xp)
236{
237 return xp->name;
238}
239
240char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp)
241{
242 return xp->sname;
243}
244
245int X509_PURPOSE_get_trust(X509_PURPOSE *xp)
246{
247 return xp->trust;
248}
249
250#ifndef NO_SHA
251static void x509v3_cache_extensions(X509 *x)
252{
253 BASIC_CONSTRAINTS *bs;
254 ASN1_BIT_STRING *usage;
255 ASN1_BIT_STRING *ns;
256 STACK_OF(ASN1_OBJECT) *extusage;
257 int i;
258 if(x->ex_flags & EXFLAG_SET) return;
259 X509_digest(x, EVP_sha1(), x->sha1_hash, NULL);
260 /* Does subject name match issuer ? */
261 if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x)))
262 x->ex_flags |= EXFLAG_SS;
263 /* V1 should mean no extensions ... */
264 if(!X509_get_version(x)) x->ex_flags |= EXFLAG_V1;
265 /* Handle basic constraints */
266 if((bs=X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) {
267 if(bs->ca) x->ex_flags |= EXFLAG_CA;
268 if(bs->pathlen) {
269 if((bs->pathlen->type == V_ASN1_NEG_INTEGER)
270 || !bs->ca) {
271 x->ex_flags |= EXFLAG_INVALID;
272 x->ex_pathlen = 0;
273 } else x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen);
274 } else x->ex_pathlen = -1;
275 BASIC_CONSTRAINTS_free(bs);
276 x->ex_flags |= EXFLAG_BCONS;
277 }
278 /* Handle key usage */
279 if((usage=X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) {
280 if(usage->length > 0) {
281 x->ex_kusage = usage->data[0];
282 if(usage->length > 1)
283 x->ex_kusage |= usage->data[1] << 8;
284 } else x->ex_kusage = 0;
285 x->ex_flags |= EXFLAG_KUSAGE;
286 ASN1_BIT_STRING_free(usage);
287 }
288 x->ex_xkusage = 0;
289 if((extusage=X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) {
290 x->ex_flags |= EXFLAG_XKUSAGE;
291 for(i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) {
292 switch(OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage,i))) {
293 case NID_server_auth:
294 x->ex_xkusage |= XKU_SSL_SERVER;
295 break;
296
297 case NID_client_auth:
298 x->ex_xkusage |= XKU_SSL_CLIENT;
299 break;
300
301 case NID_email_protect:
302 x->ex_xkusage |= XKU_SMIME;
303 break;
304
305 case NID_code_sign:
306 x->ex_xkusage |= XKU_CODE_SIGN;
307 break;
308
309 case NID_ms_sgc:
310 case NID_ns_sgc:
311 x->ex_xkusage |= XKU_SGC;
312 }
313 }
314 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
315 }
316
317 if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) {
318 if(ns->length > 0) x->ex_nscert = ns->data[0];
319 else x->ex_nscert = 0;
320 x->ex_flags |= EXFLAG_NSCERT;
321 ASN1_BIT_STRING_free(ns);
322 }
323 x->ex_flags |= EXFLAG_SET;
324}
325#endif
326
327/* CA checks common to all purposes
328 * return codes:
329 * 0 not a CA
330 * 1 is a CA
331 * 2 basicConstraints absent so "maybe" a CA
332 * 3 basicConstraints absent but self signed V1.
333 */
334
335#define V1_ROOT (EXFLAG_V1|EXFLAG_SS)
336#define ku_reject(x, usage) \
337 (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage)))
338#define xku_reject(x, usage) \
339 (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage)))
340#define ns_reject(x, usage) \
341 (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage)))
342
343static int ca_check(X509 *x)
344{
345 /* keyUsage if present should allow cert signing */
346 if(ku_reject(x, KU_KEY_CERT_SIGN)) return 0;
347 if(x->ex_flags & EXFLAG_BCONS) {
348 if(x->ex_flags & EXFLAG_CA) return 1;
349 /* If basicConstraints says not a CA then say so */
350 else return 0;
351 } else {
352 if((x->ex_flags & V1_ROOT) == V1_ROOT) return 3;
353 else return 2;
354 }
355}
356
357
358static int check_purpose_ssl_client(X509_PURPOSE *xp, X509 *x, int ca)
359{
360 if(xku_reject(x,XKU_SSL_CLIENT)) return 0;
361 if(ca) {
362 int ca_ret;
363 ca_ret = ca_check(x);
364 if(!ca_ret) return 0;
365 /* check nsCertType if present */
366 if(x->ex_flags & EXFLAG_NSCERT) {
367 if(x->ex_nscert & NS_SSL_CA) return ca_ret;
368 return 0;
369 }
370 if(ca_ret != 2) return ca_ret;
371 else return 0;
372 }
373 /* We need to do digital signatures with it */
374 if(ku_reject(x,KU_DIGITAL_SIGNATURE)) return 0;
375 /* nsCertType if present should allow SSL client use */
376 if(ns_reject(x, NS_SSL_CLIENT)) return 0;
377 return 1;
378}
379
380static int check_purpose_ssl_server(X509_PURPOSE *xp, X509 *x, int ca)
381{
382 if(xku_reject(x,XKU_SSL_SERVER|XKU_SGC)) return 0;
383 /* Otherwise same as SSL client for a CA */
384 if(ca) return check_purpose_ssl_client(xp, x, 1);
385
386 if(ns_reject(x, NS_SSL_SERVER)) return 0;
387 /* Now as for keyUsage: we'll at least need to sign OR encipher */
388 if(ku_reject(x, KU_DIGITAL_SIGNATURE|KU_KEY_ENCIPHERMENT)) return 0;
389
390 return 1;
391
392}
393
394static int check_purpose_ns_ssl_server(X509_PURPOSE *xp, X509 *x, int ca)
395{
396 int ret;
397 ret = check_purpose_ssl_server(xp, x, ca);
398 if(!ret || ca) return ret;
399 /* We need to encipher or Netscape complains */
400 if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0;
401 return ret;
402}
403
404/* common S/MIME checks */
405static int purpose_smime(X509 *x, int ca)
406{
407 if(xku_reject(x,XKU_SMIME)) return 0;
408 if(ca) {
409 int ca_ret;
410 ca_ret = ca_check(x);
411 if(!ca_ret) return 0;
412 /* check nsCertType if present */
413 if(x->ex_flags & EXFLAG_NSCERT) {
414 if(x->ex_nscert & NS_SMIME_CA) return ca_ret;
415 return 0;
416 }
417 if(ca_ret != 2) return ca_ret;
418 else return 0;
419 }
420 if(x->ex_flags & EXFLAG_NSCERT) {
421 if(x->ex_nscert & NS_SMIME) return 1;
422 /* Workaround for some buggy certificates */
423 if(x->ex_nscert & NS_SSL_CLIENT) return 2;
424 return 0;
425 }
426 return 1;
427}
428
429static int check_purpose_smime_sign(X509_PURPOSE *xp, X509 *x, int ca)
430{
431 int ret;
432 ret = purpose_smime(x, ca);
433 if(!ret || ca) return ret;
434 if(ku_reject(x, KU_DIGITAL_SIGNATURE)) return 0;
435 return ret;
436}
437
438static int check_purpose_smime_encrypt(X509_PURPOSE *xp, X509 *x, int ca)
439{
440 int ret;
441 ret = purpose_smime(x, ca);
442 if(!ret || ca) return ret;
443 if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0;
444 return ret;
445}
446
447static int check_purpose_crl_sign(X509_PURPOSE *xp, X509 *x, int ca)
448{
449 if(ca) {
450 int ca_ret;
451 if((ca_ret = ca_check(x)) != 2) return ca_ret;
452 else return 0;
453 }
454 if(ku_reject(x, KU_CRL_SIGN)) return 0;
455 return 1;
456}
diff --git a/src/lib/libcrypto/x509v3/v3_skey.c b/src/lib/libcrypto/x509v3/v3_skey.c
index fb3e36014d..939845fa8f 100644
--- a/src/lib/libcrypto/x509v3/v3_skey.c
+++ b/src/lib/libcrypto/x509v3/v3_skey.c
@@ -61,24 +61,17 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
63 63
64static ASN1_OCTET_STRING *octet_string_new(void);
65static 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);
66X509V3_EXT_METHOD v3_skey_id = { 65X509V3_EXT_METHOD v3_skey_id = {
67NID_subject_key_identifier, 0, 66NID_subject_key_identifier, 0,
68(X509V3_EXT_NEW)octet_string_new, 67(X509V3_EXT_NEW)ASN1_OCTET_STRING_new,
69(X509V3_EXT_FREE)ASN1_STRING_free, 68(X509V3_EXT_FREE)ASN1_OCTET_STRING_free,
70(X509V3_EXT_D2I)d2i_ASN1_OCTET_STRING, 69(X509V3_EXT_D2I)d2i_ASN1_OCTET_STRING,
71(X509V3_EXT_I2D)i2d_ASN1_OCTET_STRING, 70(X509V3_EXT_I2D)i2d_ASN1_OCTET_STRING,
72(X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING, 71(X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING,
73(X509V3_EXT_S2I)s2i_skey_id, 72(X509V3_EXT_S2I)s2i_skey_id,
74NULL, NULL, NULL, NULL, NULL}; 73NULL, NULL, NULL, NULL, NULL};
75 74
76
77static ASN1_OCTET_STRING *octet_string_new(void)
78{
79 return ASN1_OCTET_STRING_new();
80}
81
82char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, 75char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
83 ASN1_OCTET_STRING *oct) 76 ASN1_OCTET_STRING *oct)
84{ 77{
@@ -91,13 +84,13 @@ ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
91 ASN1_OCTET_STRING *oct; 84 ASN1_OCTET_STRING *oct;
92 long length; 85 long length;
93 86
94 if(!(oct = ASN1_OCTET_STRING_new())) { 87 if(!(oct = M_ASN1_OCTET_STRING_new())) {
95 X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE); 88 X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);
96 return NULL; 89 return NULL;
97 } 90 }
98 91
99 if(!(oct->data = string_to_hex(str, &length))) { 92 if(!(oct->data = string_to_hex(str, &length))) {
100 ASN1_OCTET_STRING_free(oct); 93 M_ASN1_OCTET_STRING_free(oct);
101 return NULL; 94 return NULL;
102 } 95 }
103 96
@@ -118,7 +111,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
118 111
119 if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str); 112 if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str);
120 113
121 if(!(oct = ASN1_OCTET_STRING_new())) { 114 if(!(oct = M_ASN1_OCTET_STRING_new())) {
122 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); 115 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE);
123 return NULL; 116 return NULL;
124 } 117 }
@@ -143,7 +136,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
143 EVP_DigestUpdate(&md, pk->data, pk->length); 136 EVP_DigestUpdate(&md, pk->data, pk->length);
144 EVP_DigestFinal(&md, pkey_dig, &diglen); 137 EVP_DigestFinal(&md, pkey_dig, &diglen);
145 138
146 if(!ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) { 139 if(!M_ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) {
147 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); 140 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE);
148 goto err; 141 goto err;
149 } 142 }
@@ -151,6 +144,6 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
151 return oct; 144 return oct;
152 145
153 err: 146 err:
154 ASN1_OCTET_STRING_free(oct); 147 M_ASN1_OCTET_STRING_free(oct);
155 return NULL; 148 return NULL;
156} 149}
diff --git a/src/lib/libcrypto/x509v3/v3_sxnet.c b/src/lib/libcrypto/x509v3/v3_sxnet.c
index 0687bb4e3d..20ba8ac8d6 100644
--- a/src/lib/libcrypto/x509v3/v3_sxnet.c
+++ b/src/lib/libcrypto/x509v3/v3_sxnet.c
@@ -111,7 +111,7 @@ SXNET *SXNET_new(void)
111 SXNET *ret=NULL; 111 SXNET *ret=NULL;
112 ASN1_CTX c; 112 ASN1_CTX c;
113 M_ASN1_New_Malloc(ret, SXNET); 113 M_ASN1_New_Malloc(ret, SXNET);
114 M_ASN1_New(ret->version,ASN1_INTEGER_new); 114 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
115 M_ASN1_New(ret->ids,sk_SXNETID_new_null); 115 M_ASN1_New(ret->ids,sk_SXNETID_new_null);
116 return (ret); 116 return (ret);
117 M_ASN1_New_Error(ASN1_F_SXNET_NEW); 117 M_ASN1_New_Error(ASN1_F_SXNET_NEW);
@@ -130,7 +130,7 @@ SXNET *d2i_SXNET(SXNET **a, unsigned char **pp, long length)
130void SXNET_free(SXNET *a) 130void SXNET_free(SXNET *a)
131{ 131{
132 if (a == NULL) return; 132 if (a == NULL) return;
133 ASN1_INTEGER_free(a->version); 133 M_ASN1_INTEGER_free(a->version);
134 sk_SXNETID_pop_free(a->ids, SXNETID_free); 134 sk_SXNETID_pop_free(a->ids, SXNETID_free);
135 Free (a); 135 Free (a);
136} 136}
@@ -156,7 +156,7 @@ SXNETID *SXNETID_new(void)
156 ASN1_CTX c; 156 ASN1_CTX c;
157 M_ASN1_New_Malloc(ret, SXNETID); 157 M_ASN1_New_Malloc(ret, SXNETID);
158 ret->zone = NULL; 158 ret->zone = NULL;
159 M_ASN1_New(ret->user,ASN1_OCTET_STRING_new); 159 M_ASN1_New(ret->user,M_ASN1_OCTET_STRING_new);
160 return (ret); 160 return (ret);
161 M_ASN1_New_Error(ASN1_F_SXNETID_NEW); 161 M_ASN1_New_Error(ASN1_F_SXNETID_NEW);
162} 162}
@@ -174,8 +174,8 @@ SXNETID *d2i_SXNETID(SXNETID **a, unsigned char **pp, long length)
174void SXNETID_free(SXNETID *a) 174void SXNETID_free(SXNETID *a)
175{ 175{
176 if (a == NULL) return; 176 if (a == NULL) return;
177 ASN1_INTEGER_free(a->zone); 177 M_ASN1_INTEGER_free(a->zone);
178 ASN1_OCTET_STRING_free(a->user); 178 M_ASN1_OCTET_STRING_free(a->user);
179 Free (a); 179 Free (a);
180} 180}
181 181
@@ -193,7 +193,7 @@ static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out,
193 tmp = i2s_ASN1_INTEGER(NULL, id->zone); 193 tmp = i2s_ASN1_INTEGER(NULL, id->zone);
194 BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp); 194 BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp);
195 Free(tmp); 195 Free(tmp);
196 ASN1_OCTET_STRING_print(out, id->user); 196 M_ASN1_OCTET_STRING_print(out, id->user);
197 } 197 }
198 return 1; 198 return 1;
199} 199}
@@ -244,9 +244,9 @@ int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,
244 int userlen) 244 int userlen)
245{ 245{
246 ASN1_INTEGER *izone = NULL; 246 ASN1_INTEGER *izone = NULL;
247 if(!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { 247 if(!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
248 X509V3err(X509V3_F_SXNET_ADD_ID_ULONG,ERR_R_MALLOC_FAILURE); 248 X509V3err(X509V3_F_SXNET_ADD_ID_ULONG,ERR_R_MALLOC_FAILURE);
249 ASN1_INTEGER_free(izone); 249 M_ASN1_INTEGER_free(izone);
250 return 0; 250 return 0;
251 } 251 }
252 return SXNET_add_id_INTEGER(psx, izone, user, userlen); 252 return SXNET_add_id_INTEGER(psx, izone, user, userlen);
@@ -285,7 +285,7 @@ int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, char *user,
285 if(!(id = SXNETID_new())) goto err; 285 if(!(id = SXNETID_new())) goto err;
286 if(userlen == -1) userlen = strlen(user); 286 if(userlen == -1) userlen = strlen(user);
287 287
288 if(!ASN1_OCTET_STRING_set(id->user, user, userlen)) goto err; 288 if(!M_ASN1_OCTET_STRING_set(id->user, user, userlen)) goto err;
289 if(!sk_SXNETID_push(sx->ids, id)) goto err; 289 if(!sk_SXNETID_push(sx->ids, id)) goto err;
290 id->zone = zone; 290 id->zone = zone;
291 return 1; 291 return 1;
@@ -307,7 +307,7 @@ ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone)
307 return NULL; 307 return NULL;
308 } 308 }
309 oct = SXNET_get_id_INTEGER(sx, izone); 309 oct = SXNET_get_id_INTEGER(sx, izone);
310 ASN1_INTEGER_free(izone); 310 M_ASN1_INTEGER_free(izone);
311 return oct; 311 return oct;
312} 312}
313 313
@@ -315,13 +315,13 @@ ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone)
315{ 315{
316 ASN1_INTEGER *izone = NULL; 316 ASN1_INTEGER *izone = NULL;
317 ASN1_OCTET_STRING *oct; 317 ASN1_OCTET_STRING *oct;
318 if(!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { 318 if(!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
319 X509V3err(X509V3_F_SXNET_GET_ID_ULONG,ERR_R_MALLOC_FAILURE); 319 X509V3err(X509V3_F_SXNET_GET_ID_ULONG,ERR_R_MALLOC_FAILURE);
320 ASN1_INTEGER_free(izone); 320 M_ASN1_INTEGER_free(izone);
321 return NULL; 321 return NULL;
322 } 322 }
323 oct = SXNET_get_id_INTEGER(sx, izone); 323 oct = SXNET_get_id_INTEGER(sx, izone);
324 ASN1_INTEGER_free(izone); 324 M_ASN1_INTEGER_free(izone);
325 return oct; 325 return oct;
326} 326}
327 327
@@ -331,7 +331,7 @@ ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone)
331 int i; 331 int i;
332 for(i = 0; i < sk_SXNETID_num(sx->ids); i++) { 332 for(i = 0; i < sk_SXNETID_num(sx->ids); i++) {
333 id = sk_SXNETID_value(sx->ids, i); 333 id = sk_SXNETID_value(sx->ids, i);
334 if(!ASN1_INTEGER_cmp(id->zone, zone)) return id->user; 334 if(!M_ASN1_INTEGER_cmp(id->zone, zone)) return id->user;
335 } 335 }
336 return NULL; 336 return NULL;
337} 337}
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index 40f71c71b4..4c2c4a9483 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -104,7 +104,7 @@ void X509V3_conf_free(CONF_VALUE *conf)
104 if(conf->name) Free(conf->name); 104 if(conf->name) Free(conf->name);
105 if(conf->value) Free(conf->value); 105 if(conf->value) Free(conf->value);
106 if(conf->section) Free(conf->section); 106 if(conf->section) Free(conf->section);
107 Free((char *)conf); 107 Free(conf);
108} 108}
109 109
110int X509V3_add_value_bool(const char *name, int asn1_bool, 110int X509V3_add_value_bool(const char *name, int asn1_bool,
diff --git a/src/lib/libcrypto/x509v3/v3err.c b/src/lib/libcrypto/x509v3/v3err.c
index 50efa8d99d..b7d4e350c4 100644
--- a/src/lib/libcrypto/x509v3/v3err.c
+++ b/src/lib/libcrypto/x509v3/v3err.c
@@ -72,6 +72,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
72{ERR_PACK(0,X509V3_F_HEX_TO_STRING,0), "hex_to_string"}, 72{ERR_PACK(0,X509V3_F_HEX_TO_STRING,0), "hex_to_string"},
73{ERR_PACK(0,X509V3_F_I2S_ASN1_ENUMERATED,0), "i2s_ASN1_ENUMERATED"}, 73{ERR_PACK(0,X509V3_F_I2S_ASN1_ENUMERATED,0), "i2s_ASN1_ENUMERATED"},
74{ERR_PACK(0,X509V3_F_I2S_ASN1_INTEGER,0), "i2s_ASN1_INTEGER"}, 74{ERR_PACK(0,X509V3_F_I2S_ASN1_INTEGER,0), "i2s_ASN1_INTEGER"},
75{ERR_PACK(0,X509V3_F_I2V_AUTHORITY_INFO_ACCESS,0), "I2V_AUTHORITY_INFO_ACCESS"},
75{ERR_PACK(0,X509V3_F_NOTICE_SECTION,0), "NOTICE_SECTION"}, 76{ERR_PACK(0,X509V3_F_NOTICE_SECTION,0), "NOTICE_SECTION"},
76{ERR_PACK(0,X509V3_F_NREF_NOS,0), "NREF_NOS"}, 77{ERR_PACK(0,X509V3_F_NREF_NOS,0), "NREF_NOS"},
77{ERR_PACK(0,X509V3_F_POLICY_SECTION,0), "POLICY_SECTION"}, 78{ERR_PACK(0,X509V3_F_POLICY_SECTION,0), "POLICY_SECTION"},
@@ -87,6 +88,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
87{ERR_PACK(0,X509V3_F_SXNET_ADD_ID_ULONG,0), "SXNET_add_id_ulong"}, 88{ERR_PACK(0,X509V3_F_SXNET_ADD_ID_ULONG,0), "SXNET_add_id_ulong"},
88{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ASC,0), "SXNET_get_id_asc"}, 89{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ASC,0), "SXNET_get_id_asc"},
89{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ULONG,0), "SXNET_get_id_ulong"}, 90{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ULONG,0), "SXNET_get_id_ulong"},
91{ERR_PACK(0,X509V3_F_V2I_ACCESS_DESCRIPTION,0), "V2I_ACCESS_DESCRIPTION"},
90{ERR_PACK(0,X509V3_F_V2I_ASN1_BIT_STRING,0), "V2I_ASN1_BIT_STRING"}, 92{ERR_PACK(0,X509V3_F_V2I_ASN1_BIT_STRING,0), "V2I_ASN1_BIT_STRING"},
91{ERR_PACK(0,X509V3_F_V2I_AUTHORITY_KEYID,0), "V2I_AUTHORITY_KEYID"}, 93{ERR_PACK(0,X509V3_F_V2I_AUTHORITY_KEYID,0), "V2I_AUTHORITY_KEYID"},
92{ERR_PACK(0,X509V3_F_V2I_BASIC_CONSTRAINTS,0), "V2I_BASIC_CONSTRAINTS"}, 94{ERR_PACK(0,X509V3_F_V2I_BASIC_CONSTRAINTS,0), "V2I_BASIC_CONSTRAINTS"},
@@ -102,6 +104,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
102{ERR_PACK(0,X509V3_F_X509V3_EXT_I2D,0), "X509V3_EXT_i2d"}, 104{ERR_PACK(0,X509V3_F_X509V3_EXT_I2D,0), "X509V3_EXT_i2d"},
103{ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"}, 105{ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"},
104{ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"}, 106{ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"},
107{ERR_PACK(0,X509V3_F_X509_PURPOSE_ADD,0), "X509_PURPOSE_add"},
105{0,NULL} 108{0,NULL}
106 }; 109 };
107 110
@@ -132,6 +135,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
132{X509V3_R_INVALID_OPTION ,"invalid option"}, 135{X509V3_R_INVALID_OPTION ,"invalid option"},
133{X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"}, 136{X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"},
134{X509V3_R_INVALID_SECTION ,"invalid section"}, 137{X509V3_R_INVALID_SECTION ,"invalid section"},
138{X509V3_R_INVALID_SYNTAX ,"invalid syntax"},
135{X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"}, 139{X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"},
136{X509V3_R_MISSING_VALUE ,"missing value"}, 140{X509V3_R_MISSING_VALUE ,"missing value"},
137{X509V3_R_NEED_ORGANIZATION_AND_NUMBERS ,"need organization and numbers"}, 141{X509V3_R_NEED_ORGANIZATION_AND_NUMBERS ,"need organization and numbers"},
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h
index 4eb04a5a89..fe01755797 100644
--- a/src/lib/libcrypto/x509v3/x509v3.h
+++ b/src/lib/libcrypto/x509v3/x509v3.h
@@ -136,12 +136,6 @@ typedef struct v3_ext_ctx X509V3_CTX;
136#define X509V3_EXT_CTX_DEP 0x2 136#define X509V3_EXT_CTX_DEP 0x2
137#define X509V3_EXT_MULTILINE 0x4 137#define X509V3_EXT_MULTILINE 0x4
138 138
139typedef struct BIT_STRING_BITNAME_st {
140int bitnum;
141const char *lname;
142const char *sname;
143} BIT_STRING_BITNAME;
144
145typedef BIT_STRING_BITNAME ENUMERATED_NAMES; 139typedef BIT_STRING_BITNAME ENUMERATED_NAMES;
146 140
147typedef struct BASIC_CONSTRAINTS_st { 141typedef struct BASIC_CONSTRAINTS_st {
@@ -155,6 +149,11 @@ ASN1_GENERALIZEDTIME *notBefore;
155ASN1_GENERALIZEDTIME *notAfter; 149ASN1_GENERALIZEDTIME *notAfter;
156} PKEY_USAGE_PERIOD; 150} PKEY_USAGE_PERIOD;
157 151
152typedef struct otherName_st {
153ASN1_OBJECT *type_id;
154ASN1_TYPE *value;
155} OTHERNAME;
156
158typedef struct GENERAL_NAME_st { 157typedef struct GENERAL_NAME_st {
159 158
160#define GEN_OTHERNAME (0|V_ASN1_CONTEXT_SPECIFIC) 159#define GEN_OTHERNAME (0|V_ASN1_CONTEXT_SPECIFIC)
@@ -174,17 +173,26 @@ union {
174 ASN1_OCTET_STRING *ip; /* iPAddress */ 173 ASN1_OCTET_STRING *ip; /* iPAddress */
175 X509_NAME *dirn; /* dirn */ 174 X509_NAME *dirn; /* dirn */
176 ASN1_OBJECT *rid; /* registeredID */ 175 ASN1_OBJECT *rid; /* registeredID */
177 ASN1_TYPE *other; /* otherName, ediPartyName, x400Address */ 176 OTHERNAME *otherName; /* otherName */
177 ASN1_TYPE *other; /* ediPartyName, x400Address */
178} d; 178} d;
179} GENERAL_NAME; 179} GENERAL_NAME;
180 180
181typedef struct ACCESS_DESCRIPTION_st {
182ASN1_OBJECT *method;
183GENERAL_NAME *location;
184} ACCESS_DESCRIPTION;
185
181DECLARE_STACK_OF(GENERAL_NAME) 186DECLARE_STACK_OF(GENERAL_NAME)
182DECLARE_ASN1_SET_OF(GENERAL_NAME) 187DECLARE_ASN1_SET_OF(GENERAL_NAME)
183 188
189DECLARE_STACK_OF(ACCESS_DESCRIPTION)
190DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)
191
184typedef struct DIST_POINT_NAME_st { 192typedef struct DIST_POINT_NAME_st {
185/* NB: this is a CHOICE type and only one of these should be set */ 193/* NB: this is a CHOICE type and only one of these should be set */
186STACK_OF(GENERAL_NAME) *fullname; 194STACK_OF(GENERAL_NAME) *fullname;
187X509_NAME *relativename; 195STACK_OF(X509_NAME_ENTRY) *relativename;
188} DIST_POINT_NAME; 196} DIST_POINT_NAME;
189 197
190typedef struct DIST_POINT_st { 198typedef struct DIST_POINT_st {
@@ -255,8 +263,8 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
255#define X509V3_set_ctx_nodb(ctx) ctx->db = NULL; 263#define X509V3_set_ctx_nodb(ctx) ctx->db = NULL;
256 264
257#define EXT_BITSTRING(nid, table) { nid, 0, \ 265#define EXT_BITSTRING(nid, table) { nid, 0, \
258 (X509V3_EXT_NEW)asn1_bit_string_new, \ 266 (X509V3_EXT_NEW)ASN1_BIT_STRING_new, \
259 (X509V3_EXT_FREE)ASN1_STRING_free, \ 267 (X509V3_EXT_FREE)ASN1_BIT_STRING_free, \
260 (X509V3_EXT_D2I)d2i_ASN1_BIT_STRING, \ 268 (X509V3_EXT_D2I)d2i_ASN1_BIT_STRING, \
261 (X509V3_EXT_I2D)i2d_ASN1_BIT_STRING, \ 269 (X509V3_EXT_I2D)i2d_ASN1_BIT_STRING, \
262 NULL, NULL, \ 270 NULL, NULL, \
@@ -266,8 +274,8 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
266 (char *)table} 274 (char *)table}
267 275
268#define EXT_IA5STRING(nid) { nid, 0, \ 276#define EXT_IA5STRING(nid) { nid, 0, \
269 (X509V3_EXT_NEW)ia5string_new, \ 277 (X509V3_EXT_NEW)ASN1_IA5STRING_new, \
270 (X509V3_EXT_FREE)ASN1_STRING_free, \ 278 (X509V3_EXT_FREE)ASN1_IA5STRING_free, \
271 (X509V3_EXT_D2I)d2i_ASN1_IA5STRING, \ 279 (X509V3_EXT_D2I)d2i_ASN1_IA5STRING, \
272 (X509V3_EXT_I2D)i2d_ASN1_IA5STRING, \ 280 (X509V3_EXT_I2D)i2d_ASN1_IA5STRING, \
273 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ 281 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
@@ -279,6 +287,69 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
279 NULL, NULL, NULL, NULL, \ 287 NULL, NULL, NULL, NULL, \
280 NULL} 288 NULL}
281 289
290
291/* X509_PURPOSE stuff */
292
293#define EXFLAG_BCONS 0x1
294#define EXFLAG_KUSAGE 0x2
295#define EXFLAG_XKUSAGE 0x4
296#define EXFLAG_NSCERT 0x8
297
298#define EXFLAG_CA 0x10
299#define EXFLAG_SS 0x20
300#define EXFLAG_V1 0x40
301#define EXFLAG_INVALID 0x80
302#define EXFLAG_SET 0x100
303
304#define KU_DIGITAL_SIGNATURE 0x0080
305#define KU_NON_REPUDIATION 0x0040
306#define KU_KEY_ENCIPHERMENT 0x0020
307#define KU_DATA_ENCIPHERMENT 0x0010
308#define KU_KEY_AGREEMENT 0x0008
309#define KU_KEY_CERT_SIGN 0x0004
310#define KU_CRL_SIGN 0x0002
311#define KU_ENCIPHER_ONLY 0x0001
312#define KU_DECIPHER_ONLY 0x8000
313
314#define NS_SSL_CLIENT 0x80
315#define NS_SSL_SERVER 0x40
316#define NS_SMIME 0x20
317#define NS_OBJSIGN 0x10
318#define NS_SSL_CA 0x04
319#define NS_SMIME_CA 0x02
320#define NS_OBJSIGN_CA 0x01
321
322#define XKU_SSL_SERVER 0x1
323#define XKU_SSL_CLIENT 0x2
324#define XKU_SMIME 0x4
325#define XKU_CODE_SIGN 0x8
326#define XKU_SGC 0x10
327
328#define X509_PURPOSE_DYNAMIC 0x1
329#define X509_PURPOSE_DYNAMIC_NAME 0x2
330
331typedef struct x509_purpose_st {
332 int purpose;
333 int trust; /* Default trust ID */
334 int flags;
335 int (*check_purpose)(struct x509_purpose_st *, X509 *, int);
336 char *name;
337 char *sname;
338 void *usr_data;
339} X509_PURPOSE;
340
341#define X509_PURPOSE_SSL_CLIENT 1
342#define X509_PURPOSE_SSL_SERVER 2
343#define X509_PURPOSE_NS_SSL_SERVER 3
344#define X509_PURPOSE_SMIME_SIGN 4
345#define X509_PURPOSE_SMIME_ENCRYPT 5
346#define X509_PURPOSE_CRL_SIGN 6
347
348#define X509_PURPOSE_MIN 1
349#define X509_PURPOSE_MAX 6
350
351DECLARE_STACK_OF(X509_PURPOSE)
352
282void ERR_load_X509V3_strings(void); 353void ERR_load_X509V3_strings(void);
283int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp); 354int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp);
284BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, unsigned char **pp, long length); 355BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, unsigned char **pp, long length);
@@ -328,6 +399,11 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
328STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, 399STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
329 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 400 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
330 401
402int i2d_OTHERNAME(OTHERNAME *a, unsigned char **pp);
403OTHERNAME *OTHERNAME_new(void);
404OTHERNAME *d2i_OTHERNAME(OTHERNAME **a, unsigned char **pp, long length);
405void OTHERNAME_free(OTHERNAME *a);
406
331char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); 407char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
332ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 408ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
333 409
@@ -380,12 +456,27 @@ void DIST_POINT_NAME_free(DIST_POINT_NAME *a);
380DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, 456DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
381 long length); 457 long length);
382 458
459int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **pp);
460ACCESS_DESCRIPTION *ACCESS_DESCRIPTION_new(void);
461void ACCESS_DESCRIPTION_free(ACCESS_DESCRIPTION *a);
462ACCESS_DESCRIPTION *d2i_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION **a, unsigned char **pp,
463 long length);
464
465STACK_OF(ACCESS_DESCRIPTION) *AUTHORITY_INFO_ACCESS_new(void);
466void AUTHORITY_INFO_ACCESS_free(STACK_OF(ACCESS_DESCRIPTION) *a);
467STACK_OF(ACCESS_DESCRIPTION) *d2i_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) **a,
468 unsigned char **pp, long length);
469int i2d_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) *a, unsigned char **pp);
470
471
472
383#ifdef HEADER_CONF_H 473#ifdef HEADER_CONF_H
384GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf); 474GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf);
385void X509V3_conf_free(CONF_VALUE *val); 475void X509V3_conf_free(CONF_VALUE *val);
386X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); 476X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value);
387X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); 477X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value);
388int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); 478int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert);
479int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
389int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); 480int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
390int X509V3_add_value_bool_nf(char *name, int asn1_bool, 481int X509V3_add_value_bool_nf(char *name, int asn1_bool,
391 STACK_OF(CONF_VALUE) **extlist); 482 STACK_OF(CONF_VALUE) **extlist);
@@ -423,6 +514,8 @@ X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
423int X509V3_add_standard_extensions(void); 514int X509V3_add_standard_extensions(void);
424STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line); 515STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line);
425void *X509V3_EXT_d2i(X509_EXTENSION *ext); 516void *X509V3_EXT_d2i(X509_EXTENSION *ext);
517void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
518
426X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 519X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
427 520
428char *hex_to_string(unsigned char *buffer, long len); 521char *hex_to_string(unsigned char *buffer, long len);
@@ -434,6 +527,20 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
434int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent); 527int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent);
435int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); 528int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
436 529
530int X509_check_purpose(X509 *x, int id, int ca);
531int X509_PURPOSE_get_count(void);
532X509_PURPOSE * X509_PURPOSE_get0(int idx);
533int X509_PURPOSE_get_by_sname(char *sname);
534int X509_PURPOSE_get_by_id(int id);
535int X509_PURPOSE_add(int id, int trust, int flags,
536 int (*ck)(X509_PURPOSE *, X509 *, int),
537 char *name, char *sname, void *arg);
538char *X509_PURPOSE_get0_name(X509_PURPOSE *xp);
539char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);
540int X509_PURPOSE_get_trust(X509_PURPOSE *xp);
541void X509_PURPOSE_cleanup(void);
542int X509_PURPOSE_get_id(X509_PURPOSE *);
543
437/* BEGIN ERROR CODES */ 544/* BEGIN ERROR CODES */
438/* The following lines are auto generated by the script mkerr.pl. Any changes 545/* The following lines are auto generated by the script mkerr.pl. Any changes
439 * made after this point may be overwritten when the script is next run. 546 * made after this point may be overwritten when the script is next run.
@@ -449,6 +556,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
449#define X509V3_F_HEX_TO_STRING 111 556#define X509V3_F_HEX_TO_STRING 111
450#define X509V3_F_I2S_ASN1_ENUMERATED 121 557#define X509V3_F_I2S_ASN1_ENUMERATED 121
451#define X509V3_F_I2S_ASN1_INTEGER 120 558#define X509V3_F_I2S_ASN1_INTEGER 120
559#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138
452#define X509V3_F_NOTICE_SECTION 132 560#define X509V3_F_NOTICE_SECTION 132
453#define X509V3_F_NREF_NOS 133 561#define X509V3_F_NREF_NOS 133
454#define X509V3_F_POLICY_SECTION 131 562#define X509V3_F_POLICY_SECTION 131
@@ -464,6 +572,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
464#define X509V3_F_SXNET_ADD_ID_ULONG 127 572#define X509V3_F_SXNET_ADD_ID_ULONG 127
465#define X509V3_F_SXNET_GET_ID_ASC 128 573#define X509V3_F_SXNET_GET_ID_ASC 128
466#define X509V3_F_SXNET_GET_ID_ULONG 129 574#define X509V3_F_SXNET_GET_ID_ULONG 129
575#define X509V3_F_V2I_ACCESS_DESCRIPTION 139
467#define X509V3_F_V2I_ASN1_BIT_STRING 101 576#define X509V3_F_V2I_ASN1_BIT_STRING 101
468#define X509V3_F_V2I_AUTHORITY_KEYID 119 577#define X509V3_F_V2I_AUTHORITY_KEYID 119
469#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 578#define X509V3_F_V2I_BASIC_CONSTRAINTS 102
@@ -479,6 +588,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
479#define X509V3_F_X509V3_EXT_I2D 136 588#define X509V3_F_X509V3_EXT_I2D 136
480#define X509V3_F_X509V3_GET_VALUE_BOOL 110 589#define X509V3_F_X509V3_GET_VALUE_BOOL 110
481#define X509V3_F_X509V3_PARSE_LIST 109 590#define X509V3_F_X509V3_PARSE_LIST 109
591#define X509V3_F_X509_PURPOSE_ADD 137
482 592
483/* Reason codes. */ 593/* Reason codes. */
484#define X509V3_R_BAD_IP_ADDRESS 118 594#define X509V3_R_BAD_IP_ADDRESS 118
@@ -506,6 +616,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
506#define X509V3_R_INVALID_OPTION 138 616#define X509V3_R_INVALID_OPTION 138
507#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 617#define X509V3_R_INVALID_POLICY_IDENTIFIER 134
508#define X509V3_R_INVALID_SECTION 135 618#define X509V3_R_INVALID_SECTION 135
619#define X509V3_R_INVALID_SYNTAX 143
509#define X509V3_R_ISSUER_DECODE_ERROR 126 620#define X509V3_R_ISSUER_DECODE_ERROR 126
510#define X509V3_R_MISSING_VALUE 124 621#define X509V3_R_MISSING_VALUE 124
511#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 622#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142
diff --git a/src/lib/libssl/LICENSE b/src/lib/libssl/LICENSE
index b9e18d5e7b..bdd5f7bdd0 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-1999 The OpenSSL Project. All rights reserved. 15 * Copyright (c) 1998-2000 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/bio_ssl.c b/src/lib/libssl/bio_ssl.c
index f62cde4e5d..d73c41adcd 100644
--- a/src/lib/libssl/bio_ssl.c
+++ b/src/lib/libssl/bio_ssl.c
@@ -71,6 +71,7 @@ static int ssl_puts(BIO *h,char *str);
71static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2); 71static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2);
72static int ssl_new(BIO *h); 72static int ssl_new(BIO *h);
73static int ssl_free(BIO *data); 73static int ssl_free(BIO *data);
74static long ssl_callback_ctrl(BIO *h,int cmd,void (*fp)());
74typedef struct bio_ssl_st 75typedef struct bio_ssl_st
75 { 76 {
76 SSL *ssl; /* The ssl handle :-) */ 77 SSL *ssl; /* The ssl handle :-) */
@@ -92,6 +93,7 @@ static BIO_METHOD methods_sslp=
92 ssl_ctrl, 93 ssl_ctrl,
93 ssl_new, 94 ssl_new,
94 ssl_free, 95 ssl_free,
96 ssl_callback_ctrl,
95 }; 97 };
96 98
97BIO_METHOD *BIO_f_ssl(void) 99BIO_METHOD *BIO_f_ssl(void)
@@ -444,7 +446,14 @@ static long ssl_ctrl(BIO *b, int cmd, long num, char *ptr)
444 ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); 446 ret=BIO_ctrl(ssl->rbio,cmd,num,ptr);
445 break; 447 break;
446 case BIO_CTRL_SET_CALLBACK: 448 case BIO_CTRL_SET_CALLBACK:
447 SSL_set_info_callback(ssl,(void (*)())ptr); 449 {
450#if 0 /* FIXME: Should this be used? -- Richard Levitte */
451 BIOerr(SSL_F_SSL_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
452 ret = -1;
453#else
454 ret=0;
455#endif
456 }
448 break; 457 break;
449 case BIO_CTRL_GET_CALLBACK: 458 case BIO_CTRL_GET_CALLBACK:
450 { 459 {
@@ -461,6 +470,28 @@ static long ssl_ctrl(BIO *b, int cmd, long num, char *ptr)
461 return(ret); 470 return(ret);
462 } 471 }
463 472
473static long ssl_callback_ctrl(BIO *b, int cmd, void (*fp)())
474 {
475 SSL *ssl;
476 BIO_SSL *bs;
477 long ret=1;
478
479 bs=(BIO_SSL *)b->ptr;
480 ssl=bs->ssl;
481 switch (cmd)
482 {
483 case BIO_CTRL_SET_CALLBACK:
484 {
485 SSL_set_info_callback(ssl,fp);
486 }
487 break;
488 default:
489 ret=BIO_callback_ctrl(ssl->rbio,cmd,fp);
490 break;
491 }
492 return(ret);
493 }
494
464static int ssl_puts(BIO *bp, char *str) 495static int ssl_puts(BIO *bp, char *str)
465 { 496 {
466 int n,ret; 497 int n,ret;
diff --git a/src/lib/libssl/crypto-patent/Makefile b/src/lib/libssl/crypto-patent/Makefile
index 3d792a5a52..d97dd41bbd 100644
--- a/src/lib/libssl/crypto-patent/Makefile
+++ b/src/lib/libssl/crypto-patent/Makefile
@@ -18,13 +18,13 @@ CFLAGS+= -DL_ENDIAN
18CFLAGS+= -DB_ENDIAN 18CFLAGS+= -DB_ENDIAN
19.endif 19.endif
20.endif 20.endif
21.endif 21.endif
22 22
23CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE -DNO_ERR -DNO_WINDOWS_BRAINDEATH 23CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE -DNO_ERR -DNO_WINDOWS_BRAINDEATH
24CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST} 24CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST}
25CFLAGS+= -I${LCRYPTO_SRC} 25CFLAGS+= -I${LCRYPTO_SRC}
26CFLAGS+= -I${LCRYPTO_INC} 26CFLAGS+= -I${LCRYPTO_INC}
27SRCS+= cryptlib.c ex_data.c cpt_err.c mem.c tmdiff.c cversion.c 27SRCS+= cryptlib.c ex_data.c cpt_err.c mem.c mem_dbg.c tmdiff.c cversion.c
28CFLAGS+= -I${LCRYPTO_SRC}/md2 28CFLAGS+= -I${LCRYPTO_SRC}/md2
29SRCS+= md2_dgst.c md2_one.c 29SRCS+= md2_dgst.c md2_one.c
30CFLAGS+= -I${LCRYPTO_SRC}/md5 30CFLAGS+= -I${LCRYPTO_SRC}/md5
@@ -66,14 +66,14 @@ SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c
66SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c 66SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c
67SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_asm.c 67SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_asm.c
68#SRCS+= bn_comba.c d.c exp.c 68#SRCS+= bn_comba.c d.c exp.c
69SRCS+= bn_exp2.c 69SRCS+= bn_exp2.c bn_ctx.c
70CFLAGS+= -I${LCRYPTO_SRC}/rsa 70CFLAGS+= -I${LCRYPTO_SRC}/rsa
71SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c 71SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c
72SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c 72SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c
73SRCS+= rsa_none.c rsa_chk.c rsa_oaep.c 73SRCS+= rsa_none.c rsa_chk.c rsa_oaep.c rsa_null.c
74CFLAGS+= -I${LCRYPTO_SRC}/dsa 74CFLAGS+= -I${LCRYPTO_SRC}/dsa
75SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c 75SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c
76SRCS+= dsa_sign.c dsa_err.c dsa_asn1.c 76SRCS+= dsa_sign.c dsa_err.c dsa_asn1.c dsa_ossl.c
77CFLAGS+= -I${LCRYPTO_SRC}/dh 77CFLAGS+= -I${LCRYPTO_SRC}/dh
78SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c 78SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
79CFLAGS+= -I${LCRYPTO_SRC}/buffer 79CFLAGS+= -I${LCRYPTO_SRC}/buffer
@@ -89,7 +89,7 @@ SRCS+= stack.c
89CFLAGS+= -I${LCRYPTO_SRC}/lhash 89CFLAGS+= -I${LCRYPTO_SRC}/lhash
90SRCS+= lhash.c lh_stats.c 90SRCS+= lhash.c lh_stats.c
91CFLAGS+= -I${LCRYPTO_SRC}/rand 91CFLAGS+= -I${LCRYPTO_SRC}/rand
92SRCS+= md_rand.c randfile.c rand_lib.c 92SRCS+= md_rand.c randfile.c rand_lib.c rand_egd.c rand_err.c
93CFLAGS+= -I${LCRYPTO_SRC}/err 93CFLAGS+= -I${LCRYPTO_SRC}/err
94SRCS+= err.c err_all.c err_prn.c 94SRCS+= err.c err_all.c err_prn.c
95CFLAGS+= -I${LCRYPTO_SRC}/objects 95CFLAGS+= -I${LCRYPTO_SRC}/objects
@@ -108,7 +108,7 @@ SRCS+= m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c
108SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c 108SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c
109SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c 109SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c
110SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c 110SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c
111SRCS+= evp_err.c e_null.c c_all.c evp_lib.c 111SRCS+= evp_err.c e_null.c c_all.c c_allc.c c_alld.c evp_lib.c
112SRCS+= bio_ok.c evp_pbe.c evp_pkey.c p5_crpt.c p5_crpt2.c 112SRCS+= bio_ok.c evp_pbe.c evp_pkey.c p5_crpt.c p5_crpt2.c
113CFLAGS+= -I${LCRYPTO_SRC}/pem 113CFLAGS+= -I${LCRYPTO_SRC}/pem
114SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c 114SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c
@@ -133,30 +133,32 @@ SRCS+= a_bool.c x_exten.c asn1_par.c asn1_lib.c
133SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c 133SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c
134SRCS+= a_enum.c a_gentm.c a_time.c a_utf8.c a_vis.c 134SRCS+= a_enum.c a_gentm.c a_time.c a_utf8.c a_vis.c
135SRCS+= asn_pack.c f_enum.c nsseq.c p5_pbe.c p5_pbev2.c 135SRCS+= asn_pack.c f_enum.c nsseq.c p5_pbe.c p5_pbev2.c
136SRCS+= p8_pkey.c t_crl.c 136SRCS+= p8_pkey.c t_crl.c a_meth.c a_null.c a_strnid.c a_mbstr.c
137#SRCS+= p8_key.c t_bitst.c t_spki.c t_x509a.c x_x509a.c
138SRCS+= t_bitst.c t_spki.c t_x509a.c x_x509a.c
137CFLAGS+= -I${LCRYPTO_SRC}/x509 139CFLAGS+= -I${LCRYPTO_SRC}/x509
138SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c 140SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c
139SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c 141SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c
140SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c 142SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c
141SRCS+= x509_ext.c x509type.c x509_lu.c 143SRCS+= x509_ext.c x509type.c x509_lu.c x509_trs.c x509spki.c
142SRCS+= x_all.c x509_txt.c by_file.c by_dir.c 144SRCS+= x_all.c x509_txt.c by_file.c by_dir.c
143CFLAGS+= -I${LCRYPTO_SRC}/x509v3 145CFLAGS+= -I${LCRYPTO_SRC}/x509v3
144SRCS+= v3_akey.c v3_alt.c v3_bcons.c v3_bitst.c v3_conf.c v3_cpols.c 146SRCS+= v3_akey.c v3_alt.c v3_bcons.c v3_bitst.c v3_conf.c v3_cpols.c
145SRCS+= v3_crld.c v3_enum.c v3_extku.c v3_genn.c v3_ia5.c v3_int.c 147SRCS+= v3_crld.c v3_enum.c v3_extku.c v3_genn.c v3_ia5.c v3_int.c
146SRCS+= v3_lib.c v3_pku.c v3_prn.c v3_skey.c v3_sxnet.c v3_utl.c 148SRCS+= v3_lib.c v3_pku.c v3_prn.c v3_skey.c v3_sxnet.c v3_utl.c
147SRCS+= v3err.c 149SRCS+= v3err.c v3_info.c v3_purp.c
148CFLAGS+= -I${LCRYPTO_SRC}/conf 150CFLAGS+= -I${LCRYPTO_SRC}/conf
149SRCS+= conf.c conf_err.c 151SRCS+= conf.c conf_err.c
150CFLAGS+= -I${LCRYPTO_SRC}/txt_db 152CFLAGS+= -I${LCRYPTO_SRC}/txt_db
151SRCS+= txt_db.c 153SRCS+= txt_db.c
152CFLAGS+= -I${LCRYPTO_SRC}/pkcs7 154CFLAGS+= -I${LCRYPTO_SRC}/pkcs7
153SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c 155SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c pk7_attr.c pk7_mime.c pk7_smime.c
154CFLAGS+= -I${LCRYPTO_SRC}/comp 156CFLAGS+= -I${LCRYPTO_SRC}/comp
155SRCS+= c_rle.c c_zlib.c comp_err.c comp_lib.c 157SRCS+= c_rle.c c_zlib.c comp_err.c comp_lib.c
156CFLAGS+= -I${LCRYPTO_SRC}/pkcs12 158CFLAGS+= -I${LCRYPTO_SRC}/pkcs12
157SRCS+= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c 159SRCS+= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c
158SRCS+= p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c 160SRCS+= p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c
159SRCS+= p12_mutl.c p12_sbag.c p12_utl.c pk12err.c 161SRCS+= p12_mutl.c p12_sbag.c p12_utl.c pk12err.c p12_npas.c
160 162
161HDRS= asn1.h dh.h md5.h rc4.h stack.h asn1_mac.h dsa.h mdc2.h rc5.h \ 163HDRS= asn1.h dh.h md5.h rc4.h stack.h asn1_mac.h dsa.h mdc2.h rc5.h \
162 tls1.h bio.h e_os.h objects.h ripemd.h tmdiff.h blowfish.h \ 164 tls1.h bio.h e_os.h objects.h ripemd.h tmdiff.h blowfish.h \
diff --git a/src/lib/libssl/crypto-patent/shlib_version b/src/lib/libssl/crypto-patent/shlib_version
index c6e3f4d3fc..b363be4447 100644
--- a/src/lib/libssl/crypto-patent/shlib_version
+++ b/src/lib/libssl/crypto-patent/shlib_version
@@ -1,2 +1,2 @@
1major=2 1major=2
2minor=1 2minor=3
diff --git a/src/lib/libssl/crypto/Makefile b/src/lib/libssl/crypto/Makefile
index 1dea336f27..516217e648 100644
--- a/src/lib/libssl/crypto/Makefile
+++ b/src/lib/libssl/crypto/Makefile
@@ -24,7 +24,7 @@ CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE -DNO_ERR -DNO_WINDOWS_BRAINDEATH
24CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST} 24CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST}
25CFLAGS+= -I${LCRYPTO_SRC} 25CFLAGS+= -I${LCRYPTO_SRC}
26CFLAGS+= -I${LCRYPTO_INC} 26CFLAGS+= -I${LCRYPTO_INC}
27SRCS+= cryptlib.c ex_data.c cpt_err.c mem.c tmdiff.c cversion.c 27SRCS+= cryptlib.c ex_data.c cpt_err.c mem.c mem_dbg.c tmdiff.c cversion.c
28CFLAGS+= -I${LCRYPTO_SRC}/md2 28CFLAGS+= -I${LCRYPTO_SRC}/md2
29SRCS+= md2_dgst.c md2_one.c 29SRCS+= md2_dgst.c md2_one.c
30CFLAGS+= -I${LCRYPTO_SRC}/md5 30CFLAGS+= -I${LCRYPTO_SRC}/md5
@@ -66,14 +66,14 @@ SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c
66SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c 66SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c
67SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_asm.c 67SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_asm.c
68#SRCS+= bn_comba.c d.c exp.c 68#SRCS+= bn_comba.c d.c exp.c
69SRCS+= bn_exp2.c 69SRCS+= bn_exp2.c bn_ctx.c
70CFLAGS+= -I${LCRYPTO_SRC}/rsa 70CFLAGS+= -I${LCRYPTO_SRC}/rsa
71SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c 71SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c
72SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c 72SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c
73SRCS+= rsa_none.c rsa_chk.c rsa_oaep.c 73SRCS+= rsa_none.c rsa_chk.c rsa_oaep.c rsa_null.c
74CFLAGS+= -I${LCRYPTO_SRC}/dsa 74CFLAGS+= -I${LCRYPTO_SRC}/dsa
75SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c 75SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c
76SRCS+= dsa_sign.c dsa_err.c dsa_asn1.c 76SRCS+= dsa_sign.c dsa_err.c dsa_asn1.c dsa_ossl.c
77CFLAGS+= -I${LCRYPTO_SRC}/dh 77CFLAGS+= -I${LCRYPTO_SRC}/dh
78SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c 78SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
79CFLAGS+= -I${LCRYPTO_SRC}/buffer 79CFLAGS+= -I${LCRYPTO_SRC}/buffer
@@ -89,7 +89,7 @@ SRCS+= stack.c
89CFLAGS+= -I${LCRYPTO_SRC}/lhash 89CFLAGS+= -I${LCRYPTO_SRC}/lhash
90SRCS+= lhash.c lh_stats.c 90SRCS+= lhash.c lh_stats.c
91CFLAGS+= -I${LCRYPTO_SRC}/rand 91CFLAGS+= -I${LCRYPTO_SRC}/rand
92SRCS+= md_rand.c randfile.c rand_lib.c 92SRCS+= md_rand.c randfile.c rand_lib.c rand_egd.c rand_err.c
93CFLAGS+= -I${LCRYPTO_SRC}/err 93CFLAGS+= -I${LCRYPTO_SRC}/err
94SRCS+= err.c err_all.c err_prn.c 94SRCS+= err.c err_all.c err_prn.c
95CFLAGS+= -I${LCRYPTO_SRC}/objects 95CFLAGS+= -I${LCRYPTO_SRC}/objects
@@ -108,7 +108,7 @@ SRCS+= m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c
108SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c 108SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c
109SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c 109SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c
110SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c 110SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c
111SRCS+= evp_err.c e_null.c c_all.c evp_lib.c 111SRCS+= evp_err.c e_null.c c_all.c c_allc.c c_alld.c evp_lib.c
112SRCS+= bio_ok.c evp_pbe.c evp_pkey.c p5_crpt.c p5_crpt2.c 112SRCS+= bio_ok.c evp_pbe.c evp_pkey.c p5_crpt.c p5_crpt2.c
113CFLAGS+= -I${LCRYPTO_SRC}/pem 113CFLAGS+= -I${LCRYPTO_SRC}/pem
114SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c 114SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c
@@ -133,30 +133,32 @@ SRCS+= a_bool.c x_exten.c asn1_par.c asn1_lib.c
133SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c 133SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c
134SRCS+= a_enum.c a_gentm.c a_time.c a_utf8.c a_vis.c 134SRCS+= a_enum.c a_gentm.c a_time.c a_utf8.c a_vis.c
135SRCS+= asn_pack.c f_enum.c nsseq.c p5_pbe.c p5_pbev2.c 135SRCS+= asn_pack.c f_enum.c nsseq.c p5_pbe.c p5_pbev2.c
136SRCS+= p8_pkey.c t_crl.c 136SRCS+= p8_pkey.c t_crl.c a_meth.c a_null.c a_strnid.c a_mbstr.c
137#SRCS+= p8_key.c t_bitst.c t_spki.c t_x509a.c x_x509a.c
138SRCS+= t_bitst.c t_spki.c t_x509a.c x_x509a.c
137CFLAGS+= -I${LCRYPTO_SRC}/x509 139CFLAGS+= -I${LCRYPTO_SRC}/x509
138SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c 140SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c
139SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c 141SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c
140SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c 142SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c
141SRCS+= x509_ext.c x509type.c x509_lu.c 143SRCS+= x509_ext.c x509type.c x509_lu.c x509_trs.c x509spki.c
142SRCS+= x_all.c x509_txt.c by_file.c by_dir.c 144SRCS+= x_all.c x509_txt.c by_file.c by_dir.c
143CFLAGS+= -I${LCRYPTO_SRC}/x509v3 145CFLAGS+= -I${LCRYPTO_SRC}/x509v3
144SRCS+= v3_akey.c v3_alt.c v3_bcons.c v3_bitst.c v3_conf.c v3_cpols.c 146SRCS+= v3_akey.c v3_alt.c v3_bcons.c v3_bitst.c v3_conf.c v3_cpols.c
145SRCS+= v3_crld.c v3_enum.c v3_extku.c v3_genn.c v3_ia5.c v3_int.c 147SRCS+= v3_crld.c v3_enum.c v3_extku.c v3_genn.c v3_ia5.c v3_int.c
146SRCS+= v3_lib.c v3_pku.c v3_prn.c v3_skey.c v3_sxnet.c v3_utl.c 148SRCS+= v3_lib.c v3_pku.c v3_prn.c v3_skey.c v3_sxnet.c v3_utl.c
147SRCS+= v3err.c 149SRCS+= v3err.c v3_info.c v3_purp.c
148CFLAGS+= -I${LCRYPTO_SRC}/conf 150CFLAGS+= -I${LCRYPTO_SRC}/conf
149SRCS+= conf.c conf_err.c 151SRCS+= conf.c conf_err.c
150CFLAGS+= -I${LCRYPTO_SRC}/txt_db 152CFLAGS+= -I${LCRYPTO_SRC}/txt_db
151SRCS+= txt_db.c 153SRCS+= txt_db.c
152CFLAGS+= -I${LCRYPTO_SRC}/pkcs7 154CFLAGS+= -I${LCRYPTO_SRC}/pkcs7
153SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c 155SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c pk7_attr.c pk7_mime.c pk7_smime.c
154CFLAGS+= -I${LCRYPTO_SRC}/comp 156CFLAGS+= -I${LCRYPTO_SRC}/comp
155SRCS+= c_rle.c c_zlib.c comp_err.c comp_lib.c 157SRCS+= c_rle.c c_zlib.c comp_err.c comp_lib.c
156CFLAGS+= -I${LCRYPTO_SRC}/pkcs12 158CFLAGS+= -I${LCRYPTO_SRC}/pkcs12
157SRCS+= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c 159SRCS+= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c
158SRCS+= p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c 160SRCS+= p12_decr.c p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c
159SRCS+= p12_mutl.c p12_sbag.c p12_utl.c pk12err.c 161SRCS+= p12_mutl.c p12_sbag.c p12_utl.c pk12err.c p12_npas.c
160 162
161HDRS= asn1.h dh.h md5.h rc4.h stack.h asn1_mac.h dsa.h mdc2.h rc5.h \ 163HDRS= asn1.h dh.h md5.h rc4.h stack.h asn1_mac.h dsa.h mdc2.h rc5.h \
162 tls1.h bio.h e_os.h objects.h ripemd.h tmdiff.h blowfish.h \ 164 tls1.h bio.h e_os.h objects.h ripemd.h tmdiff.h blowfish.h \
diff --git a/src/lib/libssl/crypto/shlib_version b/src/lib/libssl/crypto/shlib_version
index b52599a164..ba5a3fee58 100644
--- a/src/lib/libssl/crypto/shlib_version
+++ b/src/lib/libssl/crypto/shlib_version
@@ -1,2 +1,2 @@
1major=2 1major=2
2minor=0 2minor=2
diff --git a/src/lib/libssl/doc/openssl.cnf b/src/lib/libssl/doc/openssl.cnf
index d70dd25622..dbe8cbefe0 100644
--- a/src/lib/libssl/doc/openssl.cnf
+++ b/src/lib/libssl/doc/openssl.cnf
@@ -3,8 +3,13 @@
3# This is mostly being used for generation of certificate requests. 3# This is mostly being used for generation of certificate requests.
4# 4#
5 5
6# This definition stops the following lines choking if HOME isn't
7# defined.
8HOME = .
6RANDFILE = $ENV::HOME/.rnd 9RANDFILE = $ENV::HOME/.rnd
7oid_file = $ENV::HOME/.oid 10
11# Extra OBJECT IDENTIFIER info:
12#oid_file = $ENV::HOME/.oid
8oid_section = new_oids 13oid_section = new_oids
9 14
10# To use this configuration file with the "-extfile" option of the 15# To use this configuration file with the "-extfile" option of the
@@ -86,6 +91,22 @@ distinguished_name = req_distinguished_name
86attributes = req_attributes 91attributes = req_attributes
87x509_extensions = v3_ca # The extentions to add to the self signed cert 92x509_extensions = v3_ca # The extentions to add to the self signed cert
88 93
94# Passwords for private keys if not present they will be prompted for
95# input_password = secret
96# output_password = secret
97
98# This sets a mask for permitted string types. There are several options.
99# default: PrintableString, T61String, BMPString.
100# pkix : PrintableString, BMPString.
101# utf8only: only UTF8Strings.
102# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
103# MASK:XXXX a literal mask value.
104# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
105# so use this option with caution!
106string_mask = nombstr
107
108# req_extensions = v3_req # The extensions to add to a certificate request
109
89[ req_distinguished_name ] 110[ req_distinguished_name ]
90countryName = Country Name (2 letter code) 111countryName = Country Name (2 letter code)
91countryName_default = AU 112countryName_default = AU
@@ -170,8 +191,16 @@ authorityKeyIdentifier=keyid,issuer:always
170#nsCaPolicyUrl 191#nsCaPolicyUrl
171#nsSslServerName 192#nsSslServerName
172 193
194[ v3_req ]
195
196# Extensions to add to a certificate request
197
198basicConstraints = CA:FALSE
199keyUsage = nonRepudiation, digitalSignature, keyEncipherment
200
173[ v3_ca ] 201[ v3_ca ]
174 202
203
175# Extensions for a typical CA 204# Extensions for a typical CA
176 205
177 206
@@ -200,10 +229,11 @@ basicConstraints = CA:true
200# Copy issuer details 229# Copy issuer details
201# issuerAltName=issuer:copy 230# issuerAltName=issuer:copy
202 231
203# RAW DER hex encoding of an extension: beware experts only! 232# DER hex encoding of an extension: beware experts only!
204# 1.2.3.5=RAW:02:03 233# obj=DER:02:03
234# Where 'obj' is a standard or added object
205# You can even override a supported extension: 235# You can even override a supported extension:
206# basicConstraints= critical, RAW:30:03:01:01:FF 236# basicConstraints= critical, DER:30:03:01:01:FF
207 237
208[ crl_ext ] 238[ crl_ext ]
209 239
diff --git a/src/lib/libssl/doc/openssl.txt b/src/lib/libssl/doc/openssl.txt
index 91b85e5f14..880eace4da 100644
--- a/src/lib/libssl/doc/openssl.txt
+++ b/src/lib/libssl/doc/openssl.txt
@@ -1,53 +1,12 @@
1 1
2This is some preliminary documentation for OpenSSL. 2This is some preliminary documentation for OpenSSL.
3 3
4============================================================================== 4Contents:
5 BUFFER Library
6==============================================================================
7
8The buffer library handles simple character arrays. Buffers are used for
9various purposes in the library, most notably memory BIOs.
10
11The library uses the BUF_MEM structure defined in buffer.h:
12
13typedef struct buf_mem_st
14{
15 int length; /* current number of bytes */
16 char *data;
17 int max; /* size of buffer */
18} BUF_MEM;
19
20'length' is the current size of the buffer in bytes, 'max' is the amount of
21memory allocated to the buffer. There are three functions which handle these
22and one "miscellaneous" function.
23
24BUF_MEM *BUF_MEM_new()
25
26This allocates a new buffer of zero size. Returns the buffer or NULL on error.
27
28void BUF_MEM_free(BUF_MEM *a)
29
30This frees up an already existing buffer. The data is zeroed before freeing
31up in case the buffer contains sensitive data.
32
33int BUF_MEM_grow(BUF_MEM *str, int len)
34
35This changes the size of an already existing buffer. It returns zero on error
36or the new size (i.e. 'len'). Any data already in the buffer is preserved if
37it increases in size.
38
39char * BUF_strdup(char *str)
40 5
41This is the previously mentioned strdup function: like the standard library 6 OpenSSL X509V3 extension configuration
42strdup() it copies a null terminated string into a block of allocated memory 7 X509V3 Extension code: programmers guide
43and returns a pointer to the allocated block. 8 PKCS#12 Library
44 9
45Unlike the standard C library strdup() this function uses Malloc() and so
46should be used in preference to the standard library strdup() because it can
47be used for memory leak checking or replacing the malloc() function.
48
49The memory allocated from BUF_strdup() should be freed up using the Free()
50function.
51 10
52============================================================================== 11==============================================================================
53 OpenSSL X509V3 extension configuration 12 OpenSSL X509V3 extension configuration
@@ -188,7 +147,7 @@ email.1=steve@here
188email.2=steve@there 147email.2=steve@there
189 148
190This is because the configuration file code cannot handle the same name 149This is because the configuration file code cannot handle the same name
191occurring twice in the same extension. 150occurring twice in the same section.
192 151
193The syntax of raw extensions is governed by the extension code: it can 152The syntax of raw extensions is governed by the extension code: it can
194for example contain data in multiple sections. The correct syntax to 153for example contain data in multiple sections. The correct syntax to
@@ -315,6 +274,41 @@ TRUE. An end user certificate MUST NOT have the CA value set to true.
315According to PKIX recommendations it should exclude the extension entirely, 274According to PKIX recommendations it should exclude the extension entirely,
316however some software may require CA set to FALSE for end entity certificates. 275however some software may require CA set to FALSE for end entity certificates.
317 276
277Extended Key Usage.
278
279This extensions consists of a list of usages.
280
281These can either be object short names of the dotted numerical form of OIDs.
282While any OID can be used only certain values make sense. In particular the
283following PKIX, NS and MS values are meaningful:
284
285Value Meaning
286----- -------
287serverAuth SSL/TLS Web Server Authentication.
288clientAuth SSL/TLS Web Client Authentication.
289codeSigning Code signing.
290emailProtection E-mail Protection (S/MIME).
291timeStamping Trusted Timestamping
292msCodeInd Microsoft Individual Code Signing (authenticode)
293msCodeCom Microsoft Commercial Code Signing (authenticode)
294msCTLSign Microsoft Trust List Signing
295msSGC Microsoft Server Gated Crypto
296msEFS Microsoft Encrypted File System
297nsSGC Netscape Server Gated Crypto
298
299For example, under IE5 a CA can be used for any purpose: by including a list
300of the above usages the CA can be restricted to only authorised uses.
301
302Note: software packages may place additional interpretations on certificate
303use, in particular some usages may only work for selected CAs. Don't for example
304expect just including msSGC or nsSGC will automatically mean that a certificate
305can be used for SGC ("step up" encryption) otherwise anyone could use it.
306
307Examples:
308
309extendedKeyUsage=critical,codeSigning,1.2.3.4
310extendedKeyUsage=nsSGC,msSGC
311
318Subject Key Identifier. 312Subject Key Identifier.
319 313
320This is really a string extension and can take two possible values. Either 314This is really a string extension and can take two possible values. Either
@@ -459,16 +453,16 @@ extension in a human or machine readable form.
459 453
4601. Initialisation and cleanup. 4541. Initialisation and cleanup.
461 455
462X509V3_add_standard_extensions(); 456No special initialisation is needed before calling the extension functions.
463 457You used to have to call X509V3_add_standard_extensions(); but this is no longer
464This function should be called before any other extension code. It adds support 458required and this function no longer does anything.
465for some common PKIX and Netscape extensions. Additional custom extensions can
466be added as well (see later).
467 459
468void X509V3_EXT_cleanup(void); 460void X509V3_EXT_cleanup(void);
469 461
470This function should be called last to cleanup the extension code. After this 462This function should be called to cleanup the extension code if any custom
471call no other extension calls should be made. 463extensions have been added. If no custom extensions have been added then this
464call does nothing. After this call all custom extension code is freed up but
465you can still use the standard extensions.
472 466
4732. Printing and parsing extensions. 4672. Printing and parsing extensions.
474 468
@@ -512,7 +506,7 @@ or CRL is due to be signed. Both return 0 on error on non zero for success.
512In each case 'conf' is the LHASH pointer of the configuration file to use 506In each case 'conf' is the LHASH pointer of the configuration file to use
513and 'section' is the section containing the extension details. 507and 'section' is the section containing the extension details.
514 508
515See the 'context functions' section for a description of the ctx paramater. 509See the 'context functions' section for a description of the ctx parameter.
516 510
517 511
518X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, 512X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name,
@@ -531,7 +525,7 @@ takes the NID of the extension rather than its name.
531For example to produce basicConstraints with the CA flag and a path length of 525For example to produce basicConstraints with the CA flag and a path length of
53210: 52610:
533 527
534x = X509V3_EXT_conf_nid(NULL, NULL, NID_basicConstraints, "CA:TRUE,pathlen:10"); 528x = X509V3_EXT_conf_nid(NULL, NULL, NID_basic_constraints,"CA:TRUE,pathlen:10");
535 529
536 530
537X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 531X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
@@ -659,7 +653,7 @@ The same as above but for an unsigned character value.
659int X509V3_add_value_bool(const char *name, int asn1_bool, 653int X509V3_add_value_bool(const char *name, int asn1_bool,
660 STACK_OF(CONF_VALUE) **extlist); 654 STACK_OF(CONF_VALUE) **extlist);
661 655
662This adds either "TRUE" or "FALSE" depending on the value of 'ans1_bool' 656This adds either "TRUE" or "FALSE" depending on the value of 'asn1_bool'
663 657
664int X509V3_add_value_bool_nf(char *name, int asn1_bool, 658int X509V3_add_value_bool_nf(char *name, int asn1_bool,
665 STACK_OF(CONF_VALUE) **extlist); 659 STACK_OF(CONF_VALUE) **extlist);
@@ -686,7 +680,7 @@ Multi value extensions are passed a STACK_OF(CONF_VALUE) name and value pairs
686or return a STACK_OF(CONF_VALUE). 680or return a STACK_OF(CONF_VALUE).
687 681
688Raw extensions are just passed a BIO or a value and it is the extensions 682Raw extensions are just passed a BIO or a value and it is the extensions
689responsiblity to handle all the necessary printing. 683responsibility to handle all the necessary printing.
690 684
691There are two ways to add an extension. One is simply as an alias to an already 685There are two ways to add an extension. One is simply as an alias to an already
692existing extension. An alias is an extension that is identical in ASN1 structure 686existing extension. An alias is an extension that is identical in ASN1 structure
@@ -811,7 +805,7 @@ int i2r(struct v3_ext_method *method, void *ext, BIO *out, int indent);
811 805
812This function is passed the internal extension structure in the ext parameter 806This function is passed the internal extension structure in the ext parameter
813and sends out a human readable version of the extension to out. The 'indent' 807and sends out a human readable version of the extension to out. The 'indent'
814paremeter should be noted to determine the necessary amount of indentation 808parameter should be noted to determine the necessary amount of indentation
815needed on the output. 809needed on the output.
816 810
817void * r2i(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str); 811void * r2i(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str);
@@ -882,7 +876,7 @@ d2i_PKCS12_fp(fp, p12)
882 876
883This is the same but for a FILE pointer. 877This is the same but for a FILE pointer.
884 878
8853. Parsing and creation functions. 8793. High level functions.
886 880
8873.1 Parsing with PKCS12_parse(). 8813.1 Parsing with PKCS12_parse().
888 882
@@ -920,6 +914,14 @@ p12 = PKCS12_create(pass, "My Certificate", pkey, cert, NULL, 0,0,0,0,0);
920i2d_PKCS12_fp(fp, p12); 914i2d_PKCS12_fp(fp, p12);
921PKCS12_free(p12); 915PKCS12_free(p12);
922 916
9173.3 Changing a PKCS#12 structure password.
918
919int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
920
921This changes the password of an already existing PKCS#12 structure. oldpass
922is the old password and newpass is the new one. An error occurs if the old
923password is incorrect.
924
923LOW LEVEL FUNCTIONS. 925LOW LEVEL FUNCTIONS.
924 926
925In some cases the high level functions do not provide the necessary 927In some cases the high level functions do not provide the necessary
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c
index 299d2ae5d2..aaedf6a9bb 100644
--- a/src/lib/libssl/s23_clnt.c
+++ b/src/lib/libssl/s23_clnt.c
@@ -68,8 +68,10 @@ 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 if (ver == SSL2_VERSION) 72 if (ver == SSL2_VERSION)
72 return(SSLv2_client_method()); 73 return(SSLv2_client_method());
74#endif
73 if (ver == SSL3_VERSION) 75 if (ver == SSL3_VERSION)
74 return(SSLv3_client_method()); 76 return(SSLv3_client_method());
75 else if (ver == TLS1_VERSION) 77 else if (ver == TLS1_VERSION)
@@ -102,7 +104,7 @@ int ssl23_connect(SSL *s)
102 int ret= -1; 104 int ret= -1;
103 int new_state,state; 105 int new_state,state;
104 106
105 RAND_seed(&Time,sizeof(Time)); 107 RAND_add(&Time,sizeof(Time),0);
106 ERR_clear_error(); 108 ERR_clear_error();
107 clear_sys_error(); 109 clear_sys_error();
108 110
@@ -222,7 +224,7 @@ static int ssl23_client_hello(SSL *s)
222#endif 224#endif
223 225
224 p=s->s3->client_random; 226 p=s->s3->client_random;
225 RAND_bytes(p,SSL3_RANDOM_SIZE); 227 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE);
226 228
227 /* Do the message type and length last */ 229 /* Do the message type and length last */
228 d= &(buf[2]); 230 d= &(buf[2]);
@@ -283,7 +285,7 @@ static int ssl23_client_hello(SSL *s)
283 i=ch_len; 285 i=ch_len;
284 s2n(i,d); 286 s2n(i,d);
285 memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE); 287 memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE);
286 RAND_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); 288 RAND_pseudo_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);
287 memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); 289 memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);
288 p+=i; 290 p+=i;
289 291
@@ -307,7 +309,7 @@ static int ssl23_get_server_hello(SSL *s)
307 { 309 {
308 char buf[8]; 310 char buf[8];
309 unsigned char *p; 311 unsigned char *p;
310 int i,ch_len; 312 int i;
311 int n; 313 int n;
312 314
313 n=ssl23_read_bytes(s,7); 315 n=ssl23_read_bytes(s,7);
@@ -320,9 +322,14 @@ static int ssl23_get_server_hello(SSL *s)
320 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && 322 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) &&
321 (p[5] == 0x00) && (p[6] == 0x02)) 323 (p[5] == 0x00) && (p[6] == 0x02))
322 { 324 {
325#ifdef NO_SSL2
326 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
327 goto err;
328#else
323 /* we are talking sslv2 */ 329 /* we are talking sslv2 */
324 /* we need to clean up the SSLv3 setup and put in the 330 /* we need to clean up the SSLv3 setup and put in the
325 * sslv2 stuff. */ 331 * sslv2 stuff. */
332 int ch_len;
326 333
327 if (s->options & SSL_OP_NO_SSLv2) 334 if (s->options & SSL_OP_NO_SSLv2)
328 { 335 {
@@ -375,6 +382,7 @@ static int ssl23_get_server_hello(SSL *s)
375 382
376 s->method=SSLv2_client_method(); 383 s->method=SSLv2_client_method();
377 s->handshake_func=s->method->ssl_connect; 384 s->handshake_func=s->method->ssl_connect;
385#endif
378 } 386 }
379 else if ((p[0] == SSL3_RT_HANDSHAKE) && 387 else if ((p[0] == SSL3_RT_HANDSHAKE) &&
380 (p[1] == SSL3_VERSION_MAJOR) && 388 (p[1] == SSL3_VERSION_MAJOR) &&
diff --git a/src/lib/libssl/s23_lib.c b/src/lib/libssl/s23_lib.c
index 822a395837..dded7a19c5 100644
--- a/src/lib/libssl/s23_lib.c
+++ b/src/lib/libssl/s23_lib.c
@@ -67,7 +67,7 @@ static int ssl23_write(SSL *s, const void *buf, int len);
67static long ssl23_default_timeout(void ); 67static long ssl23_default_timeout(void );
68static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); 68static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
69static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p); 69static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p);
70char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT; 70const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT;
71 71
72static SSL_METHOD SSLv23_data= { 72static SSL_METHOD SSLv23_data= {
73 TLS1_VERSION, 73 TLS1_VERSION,
@@ -92,6 +92,9 @@ static SSL_METHOD SSLv23_data= {
92 ssl_bad_method, 92 ssl_bad_method,
93 ssl23_default_timeout, 93 ssl23_default_timeout,
94 &ssl3_undef_enc_method, 94 &ssl3_undef_enc_method,
95 ssl_undefined_function,
96 ssl3_callback_ctrl,
97 ssl3_ctx_callback_ctrl,
95 }; 98 };
96 99
97static long ssl23_default_timeout(void) 100static long ssl23_default_timeout(void)
@@ -106,7 +109,11 @@ SSL_METHOD *sslv23_base_method(void)
106 109
107static int ssl23_num_ciphers(void) 110static int ssl23_num_ciphers(void)
108 { 111 {
109 return(ssl3_num_ciphers()+ssl2_num_ciphers()); 112 return(ssl3_num_ciphers()
113#ifndef NO_SSL2
114 + ssl2_num_ciphers()
115#endif
116 );
110 } 117 }
111 118
112static SSL_CIPHER *ssl23_get_cipher(unsigned int u) 119static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
@@ -116,7 +123,11 @@ static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
116 if (u < uu) 123 if (u < uu)
117 return(ssl3_get_cipher(u)); 124 return(ssl3_get_cipher(u));
118 else 125 else
126#ifndef NO_SSL2
119 return(ssl2_get_cipher(u-uu)); 127 return(ssl2_get_cipher(u-uu));
128#else
129 return(NULL);
130#endif
120 } 131 }
121 132
122/* This function needs to check if the ciphers required are actually 133/* This function needs to check if the ciphers required are actually
@@ -132,8 +143,10 @@ static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p)
132 ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; 143 ((unsigned long)p[1]<<8L)|(unsigned long)p[2];
133 c.id=id; 144 c.id=id;
134 cp=ssl3_get_cipher_by_char(p); 145 cp=ssl3_get_cipher_by_char(p);
146#ifndef NO_SSL2
135 if (cp == NULL) 147 if (cp == NULL)
136 cp=ssl2_get_cipher_by_char(p); 148 cp=ssl2_get_cipher_by_char(p);
149#endif
137 return(cp); 150 return(cp);
138 } 151 }
139 152
diff --git a/src/lib/libssl/s23_pkt.c b/src/lib/libssl/s23_pkt.c
index 8370ea508c..f45e1ce3d8 100644
--- a/src/lib/libssl/s23_pkt.c
+++ b/src/lib/libssl/s23_pkt.c
@@ -89,7 +89,7 @@ int ssl23_write_bytes(SSL *s)
89 } 89 }
90 } 90 }
91 91
92/* only return when we have read 'n' bytes */ 92/* return regularly only when we have read (at least) 'n' bytes */
93int ssl23_read_bytes(SSL *s, int n) 93int ssl23_read_bytes(SSL *s, int n)
94 { 94 {
95 unsigned char *p; 95 unsigned char *p;
diff --git a/src/lib/libssl/s23_srvr.c b/src/lib/libssl/s23_srvr.c
index e4122f2d78..6a3bbb10b9 100644
--- a/src/lib/libssl/s23_srvr.c
+++ b/src/lib/libssl/s23_srvr.c
@@ -67,8 +67,10 @@ static SSL_METHOD *ssl23_get_server_method(int ver);
67int ssl23_get_client_hello(SSL *s); 67int ssl23_get_client_hello(SSL *s);
68static SSL_METHOD *ssl23_get_server_method(int ver) 68static SSL_METHOD *ssl23_get_server_method(int ver)
69 { 69 {
70#ifndef NO_SSL2
70 if (ver == SSL2_VERSION) 71 if (ver == SSL2_VERSION)
71 return(SSLv2_server_method()); 72 return(SSLv2_server_method());
73#endif
72 if (ver == SSL3_VERSION) 74 if (ver == SSL3_VERSION)
73 return(SSLv3_server_method()); 75 return(SSLv3_server_method());
74 else if (ver == TLS1_VERSION) 76 else if (ver == TLS1_VERSION)
@@ -101,7 +103,7 @@ int ssl23_accept(SSL *s)
101 int ret= -1; 103 int ret= -1;
102 int new_state,state; 104 int new_state,state;
103 105
104 RAND_seed(&Time,sizeof(Time)); 106 RAND_add(&Time,sizeof(Time),0);
105 ERR_clear_error(); 107 ERR_clear_error();
106 clear_sys_error(); 108 clear_sys_error();
107 109
@@ -186,23 +188,39 @@ end:
186 188
187int ssl23_get_client_hello(SSL *s) 189int ssl23_get_client_hello(SSL *s)
188 { 190 {
189 char buf_space[8]; 191 char buf_space[11]; /* Request this many bytes in initial read.
192 * We can detect SSL 3.0/TLS 1.0 Client Hellos
193 * ('type == 3') correctly only when the following
194 * is in a single record, which is not guaranteed by
195 * the protocol specification:
196 * Byte Content
197 * 0 type \
198 * 1/2 version > record header
199 * 3/4 length /
200 * 5 msg_type \
201 * 6-8 length > Client Hello message
202 * 9/10 client_version /
203 */
190 char *buf= &(buf_space[0]); 204 char *buf= &(buf_space[0]);
191 unsigned char *p,*d,*dd; 205 unsigned char *p,*d,*dd;
192 unsigned int i; 206 unsigned int i;
193 unsigned int csl,sil,cl; 207 unsigned int csl,sil,cl;
194 int n=0,j,tls1=0; 208 int n=0,j;
195 int type=0,use_sslv2_strong=0; 209 int type=0;
196 int v[2]; 210 int v[2];
211#ifndef NO_RSA
212 int use_sslv2_strong=0;
213#endif
197 214
198 /* read the initial header */
199 v[0]=v[1]=0;
200 if (s->state == SSL23_ST_SR_CLNT_HELLO_A) 215 if (s->state == SSL23_ST_SR_CLNT_HELLO_A)
201 { 216 {
217 /* read the initial header */
218 v[0]=v[1]=0;
219
202 if (!ssl3_setup_buffers(s)) goto err; 220 if (!ssl3_setup_buffers(s)) goto err;
203 221
204 n=ssl23_read_bytes(s,7); 222 n=ssl23_read_bytes(s, sizeof buf_space);
205 if (n != 7) return(n); /* n == -1 || n == 0 */ 223 if (n != sizeof buf_space) return(n); /* n == -1 || n == 0 */
206 224
207 p=s->packet; 225 p=s->packet;
208 226
@@ -210,7 +228,9 @@ int ssl23_get_client_hello(SSL *s)
210 228
211 if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) 229 if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO))
212 { 230 {
213 /* SSLv2 header */ 231 /*
232 * SSLv2 header
233 */
214 if ((p[3] == 0x00) && (p[4] == 0x02)) 234 if ((p[3] == 0x00) && (p[4] == 0x02))
215 { 235 {
216 v[0]=p[3]; v[1]=p[4]; 236 v[0]=p[3]; v[1]=p[4];
@@ -226,11 +246,14 @@ int ssl23_get_client_hello(SSL *s)
226 { 246 {
227 if (!(s->options & SSL_OP_NO_TLSv1)) 247 if (!(s->options & SSL_OP_NO_TLSv1))
228 { 248 {
229 tls1=1; 249 s->version=TLS1_VERSION;
250 /* type=2; */ /* done later to survive restarts */
230 s->state=SSL23_ST_SR_CLNT_HELLO_B; 251 s->state=SSL23_ST_SR_CLNT_HELLO_B;
231 } 252 }
232 else if (!(s->options & SSL_OP_NO_SSLv3)) 253 else if (!(s->options & SSL_OP_NO_SSLv3))
233 { 254 {
255 s->version=SSL3_VERSION;
256 /* type=2; */
234 s->state=SSL23_ST_SR_CLNT_HELLO_B; 257 s->state=SSL23_ST_SR_CLNT_HELLO_B;
235 } 258 }
236 else if (!(s->options & SSL_OP_NO_SSLv2)) 259 else if (!(s->options & SSL_OP_NO_SSLv2))
@@ -239,12 +262,26 @@ int ssl23_get_client_hello(SSL *s)
239 } 262 }
240 } 263 }
241 else if (!(s->options & SSL_OP_NO_SSLv3)) 264 else if (!(s->options & SSL_OP_NO_SSLv3))
265 {
266 s->version=SSL3_VERSION;
267 /* type=2; */
242 s->state=SSL23_ST_SR_CLNT_HELLO_B; 268 s->state=SSL23_ST_SR_CLNT_HELLO_B;
269 }
243 else if (!(s->options & SSL_OP_NO_SSLv2)) 270 else if (!(s->options & SSL_OP_NO_SSLv2))
244 type=1; 271 type=1;
245 272
246 if (s->options & SSL_OP_NON_EXPORT_FIRST) 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 */
247 { 283 {
284#if 0
248 STACK_OF(SSL_CIPHER) *sk; 285 STACK_OF(SSL_CIPHER) *sk;
249 SSL_CIPHER *c; 286 SSL_CIPHER *c;
250 int ne2,ne3; 287 int ne2,ne3;
@@ -294,27 +331,51 @@ int ssl23_get_client_hello(SSL *s)
294 goto next_bit; 331 goto next_bit;
295 } 332 }
296 } 333 }
334#else
335 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_OPTION);
336 goto err;
337#endif
297 } 338 }
298 } 339 }
299 } 340 }
300 else if ((p[0] == SSL3_RT_HANDSHAKE) && 341 else if ((p[0] == SSL3_RT_HANDSHAKE) &&
301 (p[1] == SSL3_VERSION_MAJOR) && 342 (p[1] == SSL3_VERSION_MAJOR) &&
302 (p[5] == SSL3_MT_CLIENT_HELLO)) 343 (p[5] == SSL3_MT_CLIENT_HELLO) &&
344 ((p[3] == 0 && p[4] < 5 /* silly record length? */)
345 || (p[9] == p[1])))
303 { 346 {
304 v[0]=p[1]; v[1]=p[2]; 347 /*
305 /* true SSLv3 or tls1 */ 348 * SSLv3 or tls1 header
306 if (p[2] >= TLS1_VERSION_MINOR) 349 */
350
351 v[0]=p[1]; /* major version */
352 /* We must look at client_version inside the Client Hello message
353 * to get the correct minor version: */
354 v[1]=p[10];
355 /* However if we have only a pathologically small fragment of the
356 * Client Hello message, we simply use the version from the
357 * record header -- this is incorrect but unlikely to fail in
358 * practice */
359 if (p[3] == 0 && p[4] < 6)
360 v[1]=p[2];
361 if (v[1] >= TLS1_VERSION_MINOR)
307 { 362 {
308 if (!(s->options & SSL_OP_NO_TLSv1)) 363 if (!(s->options & SSL_OP_NO_TLSv1))
309 { 364 {
365 s->version=TLS1_VERSION;
310 type=3; 366 type=3;
311 tls1=1;
312 } 367 }
313 else if (!(s->options & SSL_OP_NO_SSLv3)) 368 else if (!(s->options & SSL_OP_NO_SSLv3))
369 {
370 s->version=SSL3_VERSION;
314 type=3; 371 type=3;
372 }
315 } 373 }
316 else if (!(s->options & SSL_OP_NO_SSLv3)) 374 else if (!(s->options & SSL_OP_NO_SSLv3))
375 {
376 s->version=SSL3_VERSION;
317 type=3; 377 type=3;
378 }
318 } 379 }
319 else if ((strncmp("GET ", (char *)p,4) == 0) || 380 else if ((strncmp("GET ", (char *)p,4) == 0) ||
320 (strncmp("POST ",(char *)p,5) == 0) || 381 (strncmp("POST ",(char *)p,5) == 0) ||
@@ -331,12 +392,16 @@ int ssl23_get_client_hello(SSL *s)
331 } 392 }
332 } 393 }
333 394
334next_bit:
335 if (s->state == SSL23_ST_SR_CLNT_HELLO_B) 395 if (s->state == SSL23_ST_SR_CLNT_HELLO_B)
336 { 396 {
337 /* we have a SSLv3/TLSv1 in a SSLv2 header */ 397 /* we have SSLv3/TLSv1 in an SSLv2 header
398 * (other cases skip this state) */
399
338 type=2; 400 type=2;
339 p=s->packet; 401 p=s->packet;
402 v[0] = p[3]; /* == SSL3_VERSION_MAJOR */
403 v[1] = p[4];
404
340 n=((p[0]&0x7f)<<8)|p[1]; 405 n=((p[0]&0x7f)<<8)|p[1];
341 if (n > (1024*4)) 406 if (n > (1024*4))
342 { 407 {
@@ -361,14 +426,11 @@ next_bit:
361 goto err; 426 goto err;
362 } 427 }
363 428
364 *(d++)=SSL3_VERSION_MAJOR; 429 *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */
365 if (tls1) 430 *(d++) = v[1];
366 *(d++)=TLS1_VERSION_MINOR;
367 else
368 *(d++)=SSL3_VERSION_MINOR;
369 431
370 /* lets populate the random area */ 432 /* lets populate the random area */
371 /* get the chalenge_length */ 433 /* get the challenge_length */
372 i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl; 434 i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl;
373 memset(d,0,SSL3_RANDOM_SIZE); 435 memset(d,0,SSL3_RANDOM_SIZE);
374 memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i); 436 memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i);
@@ -402,8 +464,15 @@ next_bit:
402 s->s3->tmp.message_size=i; 464 s->s3->tmp.message_size=i;
403 } 465 }
404 466
467 /* imaginary new state (for program structure): */
468 /* s->state = SSL23_SR_CLNT_HELLO_C */
469
405 if (type == 1) 470 if (type == 1)
406 { 471 {
472#ifdef NO_SSL2
473 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
474 goto err;
475#else
407 /* we are talking sslv2 */ 476 /* we are talking sslv2 */
408 /* we need to clean up the SSLv3/TLSv1 setup and put in the 477 /* we need to clean up the SSLv3/TLSv1 setup and put in the
409 * sslv2 stuff. */ 478 * sslv2 stuff. */
@@ -431,7 +500,7 @@ next_bit:
431 else 500 else
432 s->s2->ssl2_rollback=1; 501 s->s2->ssl2_rollback=1;
433 502
434 /* setup the 5 bytes we have read so we get them from 503 /* setup the n bytes we have read so we get them from
435 * the sslv2 buffer */ 504 * the sslv2 buffer */
436 s->rstate=SSL_ST_READ_HEADER; 505 s->rstate=SSL_ST_READ_HEADER;
437 s->packet_length=n; 506 s->packet_length=n;
@@ -442,11 +511,12 @@ next_bit:
442 511
443 s->method=SSLv2_server_method(); 512 s->method=SSLv2_server_method();
444 s->handshake_func=s->method->ssl_accept; 513 s->handshake_func=s->method->ssl_accept;
514#endif
445 } 515 }
446 516
447 if ((type == 2) || (type == 3)) 517 if ((type == 2) || (type == 3))
448 { 518 {
449 /* we have SSLv3/TLSv1 */ 519 /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */
450 520
451 if (!ssl_init_wbio_buffer(s,1)) goto err; 521 if (!ssl_init_wbio_buffer(s,1)) goto err;
452 522
@@ -471,17 +541,13 @@ next_bit:
471 s->s3->rbuf.offset=0; 541 s->s3->rbuf.offset=0;
472 } 542 }
473 543
474 if (tls1) 544 if (s->version == TLS1_VERSION)
475 { 545 s->method = TLSv1_server_method();
476 s->version=TLS1_VERSION;
477 s->method=TLSv1_server_method();
478 }
479 else 546 else
480 { 547 s->method = SSLv3_server_method();
481 s->version=SSL3_VERSION; 548#if 0 /* ssl3_get_client_hello does this */
482 s->method=SSLv3_server_method();
483 }
484 s->client_version=(v[0]<<8)|v[1]; 549 s->client_version=(v[0]<<8)|v[1];
550#endif
485 s->handshake_func=s->method->ssl_accept; 551 s->handshake_func=s->method->ssl_accept;
486 } 552 }
487 553
@@ -500,4 +566,3 @@ err:
500 if (buf != buf_space) Free(buf); 566 if (buf != buf_space) Free(buf);
501 return(-1); 567 return(-1);
502 } 568 }
503
diff --git a/src/lib/libssl/s3_both.c b/src/lib/libssl/s3_both.c
index f3f27715d5..03e0c38770 100644
--- a/src/lib/libssl/s3_both.c
+++ b/src/lib/libssl/s3_both.c
@@ -55,7 +55,61 @@
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 */
58 111
112#include <string.h>
59#include <stdio.h> 113#include <stdio.h>
60#include <openssl/buffer.h> 114#include <openssl/buffer.h>
61#include <openssl/rand.h> 115#include <openssl/rand.h>
@@ -64,8 +118,27 @@
64#include <openssl/x509.h> 118#include <openssl/x509.h>
65#include "ssl_locl.h" 119#include "ssl_locl.h"
66 120
67int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender, 121/* send s->init_buf in records of type 'type' */
68 int slen) 122int ssl3_do_write(SSL *s, int type)
123 {
124 int ret;
125
126 ret=ssl3_write_bytes(s,type,&s->init_buf->data[s->init_off],
127 s->init_num);
128 if (ret < 0) return(-1);
129 if (type == SSL3_RT_HANDSHAKE)
130 /* should not be done for 'Hello Request's, but in that case
131 * we'll ignore the result anyway */
132 ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret);
133
134 if (ret == s->init_num)
135 return(1);
136 s->init_off+=ret;
137 s->init_num-=ret;
138 return(0);
139 }
140
141int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen)
69 { 142 {
70 unsigned char *p,*d; 143 unsigned char *p,*d;
71 int i; 144 int i;
@@ -79,7 +152,9 @@ int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender,
79 i=s->method->ssl3_enc->final_finish_mac(s, 152 i=s->method->ssl3_enc->final_finish_mac(s,
80 &(s->s3->finish_dgst1), 153 &(s->s3->finish_dgst1),
81 &(s->s3->finish_dgst2), 154 &(s->s3->finish_dgst2),
82 sender,slen,p); 155 sender,slen,s->s3->tmp.finish_md);
156 s->s3->tmp.finish_md_len = i;
157 memcpy(p, s->s3->tmp.finish_md, i);
83 p+=i; 158 p+=i;
84 l=i; 159 l=i;
85 160
@@ -109,7 +184,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
109 unsigned char *p; 184 unsigned char *p;
110 185
111 /* the mac has already been generated when we received the 186 /* the mac has already been generated when we received the
112 * change cipher spec message and is in s->s3->tmp.in_dgst[12] 187 * change cipher spec message and is in s->s3->tmp.peer_finish_md
113 */ 188 */
114 189
115 n=ssl3_get_message(s, 190 n=ssl3_get_message(s,
@@ -121,7 +196,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
121 196
122 if (!ok) return((int)n); 197 if (!ok) return((int)n);
123 198
124 /* If this occurs if we has missed a message */ 199 /* If this occurs, we have missed a message */
125 if (!s->s3->change_cipher_spec) 200 if (!s->s3->change_cipher_spec)
126 { 201 {
127 al=SSL_AD_UNEXPECTED_MESSAGE; 202 al=SSL_AD_UNEXPECTED_MESSAGE;
@@ -130,9 +205,8 @@ int ssl3_get_finished(SSL *s, int a, int b)
130 } 205 }
131 s->s3->change_cipher_spec=0; 206 s->s3->change_cipher_spec=0;
132 207
133 p=(unsigned char *)s->init_buf->data; 208 p = (unsigned char *)s->init_buf->data;
134 209 i = s->s3->tmp.peer_finish_md_len;
135 i=s->method->ssl3_enc->finish_mac_length;
136 210
137 if (i != n) 211 if (i != n)
138 { 212 {
@@ -141,7 +215,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
141 goto f_err; 215 goto f_err;
142 } 216 }
143 217
144 if (memcmp( p, (char *)&(s->s3->tmp.finish_md[0]),i) != 0) 218 if (memcmp(p, s->s3->tmp.peer_finish_md, i) != 0)
145 { 219 {
146 al=SSL_AD_DECRYPT_ERROR; 220 al=SSL_AD_DECRYPT_ERROR;
147 SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED); 221 SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED);
@@ -255,6 +329,11 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
255 return(l); 329 return(l);
256 } 330 }
257 331
332/* Obtain handshake message of message type 'mt' (any if mt == -1),
333 * maximum acceptable body length 'max'.
334 * The first four bytes (msg_type and length) are read in state 'st1',
335 * the body is read in state 'stn'.
336 */
258long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) 337long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
259 { 338 {
260 unsigned char *p; 339 unsigned char *p;
@@ -277,15 +356,38 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
277 356
278 p=(unsigned char *)s->init_buf->data; 357 p=(unsigned char *)s->init_buf->data;
279 358
280 if (s->state == st1) 359 if (s->state == st1) /* s->init_num < 4 */
281 { 360 {
282 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num], 361 int skip_message;
283 4-s->init_num); 362
284 if (i < (4-s->init_num)) 363 do
285 { 364 {
286 *ok=0; 365 while (s->init_num < 4)
287 return(ssl3_part_read(s,i)); 366 {
367 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],
368 4 - s->init_num);
369 if (i <= 0)
370 {
371 s->rwstate=SSL_READING;
372 *ok = 0;
373 return i;
374 }
375 s->init_num+=i;
376 }
377
378 skip_message = 0;
379 if (!s->server)
380 if (p[0] == SSL3_MT_HELLO_REQUEST)
381 /* The server may always send 'Hello Request' messages --
382 * we are doing a handshake anyway now, so ignore them
383 * if their format is correct. Does not count for
384 * 'Finished' MAC. */
385 if (p[1] == 0 && p[2] == 0 &&p[3] == 0)
386 skip_message = 1;
288 } 387 }
388 while (skip_message);
389
390 /* s->init_num == 4 */
289 391
290 if ((mt >= 0) && (*p != mt)) 392 if ((mt >= 0) && (*p != mt))
291 { 393 {
@@ -293,6 +395,20 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
293 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE); 395 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE);
294 goto f_err; 396 goto f_err;
295 } 397 }
398 if ((mt < 0) && (*p == SSL3_MT_CLIENT_HELLO) &&
399 (st1 == SSL3_ST_SR_CERT_A) &&
400 (stn == SSL3_ST_SR_CERT_B))
401 {
402 /* At this point we have got an MS SGC second client
403 * hello (maybe we should always allow the client to
404 * start a new handshake?). We need to restart the mac.
405 * Don't increment {num,total}_renegotiations because
406 * we have not completed the handshake. */
407 ssl3_init_finished_mac(s);
408 }
409
410 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, 4);
411
296 s->s3->tmp.message_type= *(p++); 412 s->s3->tmp.message_type= *(p++);
297 413
298 n2l3(p,l); 414 n2l3(p,l);
@@ -316,17 +432,21 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
316 /* next state (stn) */ 432 /* next state (stn) */
317 p=(unsigned char *)s->init_buf->data; 433 p=(unsigned char *)s->init_buf->data;
318 n=s->s3->tmp.message_size; 434 n=s->s3->tmp.message_size;
319 if (n > 0) 435 while (n > 0)
320 { 436 {
321 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n); 437 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n);
322 if (i != (int)n) 438 if (i <= 0)
323 { 439 {
324 *ok=0; 440 s->rwstate=SSL_READING;
325 return(ssl3_part_read(s,i)); 441 *ok = 0;
442 return i;
326 } 443 }
444 s->init_num += i;
445 n -= i;
327 } 446 }
447 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num);
328 *ok=1; 448 *ok=1;
329 return(n); 449 return s->init_num;
330f_err: 450f_err:
331 ssl3_send_alert(s,SSL3_AL_FATAL,al); 451 ssl3_send_alert(s,SSL3_AL_FATAL,al);
332err: 452err:
@@ -447,7 +567,7 @@ int ssl3_setup_buffers(SSL *s)
447 extra=SSL3_RT_MAX_EXTRA; 567 extra=SSL3_RT_MAX_EXTRA;
448 else 568 else
449 extra=0; 569 extra=0;
450 if ((p=(unsigned char *)Malloc(SSL3_RT_MAX_PACKET_SIZE+extra)) 570 if ((p=Malloc(SSL3_RT_MAX_PACKET_SIZE+extra))
451 == NULL) 571 == NULL)
452 goto err; 572 goto err;
453 s->s3->rbuf.buf=p; 573 s->s3->rbuf.buf=p;
@@ -455,7 +575,7 @@ int ssl3_setup_buffers(SSL *s)
455 575
456 if (s->s3->wbuf.buf == NULL) 576 if (s->s3->wbuf.buf == NULL)
457 { 577 {
458 if ((p=(unsigned char *)Malloc(SSL3_RT_MAX_PACKET_SIZE)) 578 if ((p=Malloc(SSL3_RT_MAX_PACKET_SIZE))
459 == NULL) 579 == NULL)
460 goto err; 580 goto err;
461 s->s3->wbuf.buf=p; 581 s->s3->wbuf.buf=p;
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c
index d3e6b4d1e5..279d2c0198 100644
--- a/src/lib/libssl/s3_clnt.c
+++ b/src/lib/libssl/s3_clnt.c
@@ -110,7 +110,7 @@ int ssl3_connect(SSL *s)
110 int ret= -1; 110 int ret= -1;
111 int new_state,state,skip=0;; 111 int new_state,state,skip=0;;
112 112
113 RAND_seed(&Time,sizeof(Time)); 113 RAND_add(&Time,sizeof(Time),0);
114 ERR_clear_error(); 114 ERR_clear_error();
115 clear_sys_error(); 115 clear_sys_error();
116 116
@@ -325,8 +325,8 @@ int ssl3_connect(SSL *s)
325 case SSL3_ST_CW_FINISHED_B: 325 case SSL3_ST_CW_FINISHED_B:
326 ret=ssl3_send_finished(s, 326 ret=ssl3_send_finished(s,
327 SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B, 327 SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,
328 s->method->ssl3_enc->client_finished, 328 s->method->ssl3_enc->client_finished_label,
329 s->method->ssl3_enc->client_finished_len); 329 s->method->ssl3_enc->client_finished_label_len);
330 if (ret <= 0) goto end; 330 if (ret <= 0) goto end;
331 s->state=SSL3_ST_CW_FLUSH; 331 s->state=SSL3_ST_CW_FLUSH;
332 332
@@ -466,7 +466,7 @@ static int ssl3_client_hello(SSL *s)
466 p=s->s3->client_random; 466 p=s->s3->client_random;
467 Time=time(NULL); /* Time */ 467 Time=time(NULL); /* Time */
468 l2n(Time,p); 468 l2n(Time,p);
469 RAND_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); 469 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
470 470
471 /* Do the message type and length last */ 471 /* Do the message type and length last */
472 d=p= &(buf[4]); 472 d=p= &(buf[4]);
@@ -1053,15 +1053,15 @@ static int ssl3_get_key_exchange(SSL *s)
1053 q+=i; 1053 q+=i;
1054 j+=i; 1054 j+=i;
1055 } 1055 }
1056 i=RSA_public_decrypt((int)n,p,p,pkey->pkey.rsa, 1056 i=RSA_verify(NID_md5_sha1, md_buf, j, p, n,
1057 RSA_PKCS1_PADDING); 1057 pkey->pkey.rsa);
1058 if (i <= 0) 1058 if (i < 0)
1059 { 1059 {
1060 al=SSL_AD_DECRYPT_ERROR; 1060 al=SSL_AD_DECRYPT_ERROR;
1061 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); 1061 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT);
1062 goto f_err; 1062 goto f_err;
1063 } 1063 }
1064 if ((j != i) || (memcmp(p,md_buf,i) != 0)) 1064 if (i == 0)
1065 { 1065 {
1066 /* bad signature */ 1066 /* bad signature */
1067 al=SSL_AD_DECRYPT_ERROR; 1067 al=SSL_AD_DECRYPT_ERROR;
@@ -1225,7 +1225,7 @@ fclose(out);
1225 1225
1226 if ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL) 1226 if ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL)
1227 { 1227 {
1228 /* If netscape tollerance is on, ignore errors */ 1228 /* If netscape tolerance is on, ignore errors */
1229 if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG) 1229 if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG)
1230 goto cont; 1230 goto cont;
1231 else 1231 else
@@ -1258,7 +1258,7 @@ cont:
1258 ERR_clear_error(); 1258 ERR_clear_error();
1259 } 1259 }
1260 1260
1261 /* we should setup a certficate to return.... */ 1261 /* we should setup a certificate to return.... */
1262 s->s3->tmp.cert_req=1; 1262 s->s3->tmp.cert_req=1;
1263 s->s3->tmp.ctype_num=ctype_num; 1263 s->s3->tmp.ctype_num=ctype_num;
1264 if (s->s3->tmp.ca_names != NULL) 1264 if (s->s3->tmp.ca_names != NULL)
@@ -1341,7 +1341,8 @@ static int ssl3_send_client_key_exchange(SSL *s)
1341 1341
1342 tmp_buf[0]=s->client_version>>8; 1342 tmp_buf[0]=s->client_version>>8;
1343 tmp_buf[1]=s->client_version&0xff; 1343 tmp_buf[1]=s->client_version&0xff;
1344 RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2); 1344 if (RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2) <= 0)
1345 goto err;
1345 1346
1346 s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; 1347 s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH;
1347 1348
@@ -1460,7 +1461,7 @@ static int ssl3_send_client_verify(SSL *s)
1460 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 1461 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
1461 EVP_PKEY *pkey; 1462 EVP_PKEY *pkey;
1462#ifndef NO_RSA 1463#ifndef NO_RSA
1463 int i=0; 1464 unsigned u=0;
1464#endif 1465#endif
1465 unsigned long n; 1466 unsigned long n;
1466#ifndef NO_DSA 1467#ifndef NO_DSA
@@ -1481,17 +1482,15 @@ static int ssl3_send_client_verify(SSL *s)
1481 { 1482 {
1482 s->method->ssl3_enc->cert_verify_mac(s, 1483 s->method->ssl3_enc->cert_verify_mac(s,
1483 &(s->s3->finish_dgst1),&(data[0])); 1484 &(s->s3->finish_dgst1),&(data[0]));
1484 i=RSA_private_encrypt( 1485 if (RSA_sign(NID_md5_sha1, data,
1485 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, 1486 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
1486 data,&(p[2]),pkey->pkey.rsa, 1487 &(p[2]), &u, pkey->pkey.rsa) <= 0 )
1487 RSA_PKCS1_PADDING);
1488 if (i <= 0)
1489 { 1488 {
1490 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB); 1489 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB);
1491 goto err; 1490 goto err;
1492 } 1491 }
1493 s2n(i,p); 1492 s2n(u,p);
1494 n=i+2; 1493 n=u+2;
1495 } 1494 }
1496 else 1495 else
1497#endif 1496#endif
@@ -1689,13 +1688,13 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1689#endif 1688#endif
1690#endif 1689#endif
1691 1690
1692 if (SSL_IS_EXPORT(algs) && !has_bits(i,EVP_PKT_EXP)) 1691 if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP))
1693 { 1692 {
1694#ifndef NO_RSA 1693#ifndef NO_RSA
1695 if (algs & SSL_kRSA) 1694 if (algs & SSL_kRSA)
1696 { 1695 {
1697 if (rsa == NULL 1696 if (rsa == NULL
1698 || RSA_size(rsa) > SSL_EXPORT_PKEYLENGTH(algs)) 1697 || RSA_size(rsa) > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher))
1699 { 1698 {
1700 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY); 1699 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY);
1701 goto f_err; 1700 goto f_err;
@@ -1707,7 +1706,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1707 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1706 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1708 { 1707 {
1709 if (dh == NULL 1708 if (dh == NULL
1710 || DH_size(dh) > SSL_EXPORT_PKEYLENGTH(algs)) 1709 || DH_size(dh) > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher))
1711 { 1710 {
1712 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY); 1711 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY);
1713 goto f_err; 1712 goto f_err;
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index aeff6b5c5b..c4b49aaedf 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -75,18 +75,26 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
75 1, 75 1,
76 SSL3_TXT_RSA_NULL_MD5, 76 SSL3_TXT_RSA_NULL_MD5,
77 SSL3_CK_RSA_NULL_MD5, 77 SSL3_CK_RSA_NULL_MD5,
78 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3, 78 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_SSLV3,
79 SSL_NOT_EXP,
80 0,
81 0,
79 0, 82 0,
80 SSL_ALL_CIPHERS, 83 SSL_ALL_CIPHERS,
84 SSL_ALL_STRENGTHS,
81 }, 85 },
82/* Cipher 02 */ 86/* Cipher 02 */
83 { 87 {
84 1, 88 1,
85 SSL3_TXT_RSA_NULL_SHA, 89 SSL3_TXT_RSA_NULL_SHA,
86 SSL3_CK_RSA_NULL_SHA, 90 SSL3_CK_RSA_NULL_SHA,
87 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 91 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_SSLV3,
92 SSL_NOT_EXP,
93 0,
94 0,
88 0, 95 0,
89 SSL_ALL_CIPHERS, 96 SSL_ALL_CIPHERS,
97 SSL_ALL_STRENGTHS,
90 }, 98 },
91 99
92/* anon DH */ 100/* anon DH */
@@ -95,45 +103,65 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
95 1, 103 1,
96 SSL3_TXT_ADH_RC4_40_MD5, 104 SSL3_TXT_ADH_RC4_40_MD5,
97 SSL3_CK_ADH_RC4_40_MD5, 105 SSL3_CK_ADH_RC4_40_MD5,
98 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_EXP40|SSL_SSLV3, 106 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
107 SSL_EXPORT|SSL_EXP40,
99 0, 108 0,
109 40,
110 128,
100 SSL_ALL_CIPHERS, 111 SSL_ALL_CIPHERS,
112 SSL_ALL_STRENGTHS,
101 }, 113 },
102/* Cipher 18 */ 114/* Cipher 18 */
103 { 115 {
104 1, 116 1,
105 SSL3_TXT_ADH_RC4_128_MD5, 117 SSL3_TXT_ADH_RC4_128_MD5,
106 SSL3_CK_ADH_RC4_128_MD5, 118 SSL3_CK_ADH_RC4_128_MD5,
107 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3, 119 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
120 SSL_NOT_EXP,
108 0, 121 0,
122 128,
123 128,
109 SSL_ALL_CIPHERS, 124 SSL_ALL_CIPHERS,
125 SSL_ALL_STRENGTHS,
110 }, 126 },
111/* Cipher 19 */ 127/* Cipher 19 */
112 { 128 {
113 1, 129 1,
114 SSL3_TXT_ADH_DES_40_CBC_SHA, 130 SSL3_TXT_ADH_DES_40_CBC_SHA,
115 SSL3_CK_ADH_DES_40_CBC_SHA, 131 SSL3_CK_ADH_DES_40_CBC_SHA,
116 SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 132 SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_SSLV3,
133 SSL_EXPORT|SSL_EXP40,
117 0, 134 0,
135 40,
136 128,
118 SSL_ALL_CIPHERS, 137 SSL_ALL_CIPHERS,
138 SSL_ALL_STRENGTHS,
119 }, 139 },
120/* Cipher 1A */ 140/* Cipher 1A */
121 { 141 {
122 1, 142 1,
123 SSL3_TXT_ADH_DES_64_CBC_SHA, 143 SSL3_TXT_ADH_DES_64_CBC_SHA,
124 SSL3_CK_ADH_DES_64_CBC_SHA, 144 SSL3_CK_ADH_DES_64_CBC_SHA,
125 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 145 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3,
146 SSL_NOT_EXP,
126 0, 147 0,
148 56,
149 56,
127 SSL_ALL_CIPHERS, 150 SSL_ALL_CIPHERS,
151 SSL_ALL_STRENGTHS,
128 }, 152 },
129/* Cipher 1B */ 153/* Cipher 1B */
130 { 154 {
131 1, 155 1,
132 SSL3_TXT_ADH_DES_192_CBC_SHA, 156 SSL3_TXT_ADH_DES_192_CBC_SHA,
133 SSL3_CK_ADH_DES_192_CBC_SHA, 157 SSL3_CK_ADH_DES_192_CBC_SHA,
134 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 158 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3,
159 SSL_NOT_EXP,
135 0, 160 0,
161 168,
162 168,
136 SSL_ALL_CIPHERS, 163 SSL_ALL_CIPHERS,
164 SSL_ALL_STRENGTHS,
137 }, 165 },
138 166
139/* RSA again */ 167/* RSA again */
@@ -142,72 +170,104 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
142 1, 170 1,
143 SSL3_TXT_RSA_RC4_40_MD5, 171 SSL3_TXT_RSA_RC4_40_MD5,
144 SSL3_CK_RSA_RC4_40_MD5, 172 SSL3_CK_RSA_RC4_40_MD5,
145 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_EXP40|SSL_SSLV3, 173 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
174 SSL_EXPORT|SSL_EXP40,
146 0, 175 0,
176 40,
177 128,
147 SSL_ALL_CIPHERS, 178 SSL_ALL_CIPHERS,
179 SSL_ALL_STRENGTHS,
148 }, 180 },
149/* Cipher 04 */ 181/* Cipher 04 */
150 { 182 {
151 1, 183 1,
152 SSL3_TXT_RSA_RC4_128_MD5, 184 SSL3_TXT_RSA_RC4_128_MD5,
153 SSL3_CK_RSA_RC4_128_MD5, 185 SSL3_CK_RSA_RC4_128_MD5,
154 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, 186 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_SSLV3,
187 SSL_NOT_EXP|SSL_MEDIUM,
155 0, 188 0,
189 128,
190 128,
156 SSL_ALL_CIPHERS, 191 SSL_ALL_CIPHERS,
192 SSL_ALL_STRENGTHS,
157 }, 193 },
158/* Cipher 05 */ 194/* Cipher 05 */
159 { 195 {
160 1, 196 1,
161 SSL3_TXT_RSA_RC4_128_SHA, 197 SSL3_TXT_RSA_RC4_128_SHA,
162 SSL3_CK_RSA_RC4_128_SHA, 198 SSL3_CK_RSA_RC4_128_SHA,
163 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, 199 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_SSLV3,
200 SSL_NOT_EXP|SSL_MEDIUM,
164 0, 201 0,
202 128,
203 128,
165 SSL_ALL_CIPHERS, 204 SSL_ALL_CIPHERS,
205 SSL_ALL_STRENGTHS,
166 }, 206 },
167/* Cipher 06 */ 207/* Cipher 06 */
168 { 208 {
169 1, 209 1,
170 SSL3_TXT_RSA_RC2_40_MD5, 210 SSL3_TXT_RSA_RC2_40_MD5,
171 SSL3_CK_RSA_RC2_40_MD5, 211 SSL3_CK_RSA_RC2_40_MD5,
172 SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_EXP40|SSL_SSLV3, 212 SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_SSLV3,
213 SSL_EXPORT|SSL_EXP40,
173 0, 214 0,
215 40,
216 128,
174 SSL_ALL_CIPHERS, 217 SSL_ALL_CIPHERS,
218 SSL_ALL_STRENGTHS,
175 }, 219 },
176/* Cipher 07 */ 220/* Cipher 07 */
177 { 221 {
178 1, 222 1,
179 SSL3_TXT_RSA_IDEA_128_SHA, 223 SSL3_TXT_RSA_IDEA_128_SHA,
180 SSL3_CK_RSA_IDEA_128_SHA, 224 SSL3_CK_RSA_IDEA_128_SHA,
181 SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, 225 SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_SSLV3,
226 SSL_NOT_EXP|SSL_MEDIUM,
182 0, 227 0,
228 128,
229 128,
183 SSL_ALL_CIPHERS, 230 SSL_ALL_CIPHERS,
231 SSL_ALL_STRENGTHS,
184 }, 232 },
185/* Cipher 08 */ 233/* Cipher 08 */
186 { 234 {
187 1, 235 1,
188 SSL3_TXT_RSA_DES_40_CBC_SHA, 236 SSL3_TXT_RSA_DES_40_CBC_SHA,
189 SSL3_CK_RSA_DES_40_CBC_SHA, 237 SSL3_CK_RSA_DES_40_CBC_SHA,
190 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 238 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
239 SSL_EXPORT|SSL_EXP40,
191 0, 240 0,
241 40,
242 56,
192 SSL_ALL_CIPHERS, 243 SSL_ALL_CIPHERS,
244 SSL_ALL_STRENGTHS,
193 }, 245 },
194/* Cipher 09 */ 246/* Cipher 09 */
195 { 247 {
196 1, 248 1,
197 SSL3_TXT_RSA_DES_64_CBC_SHA, 249 SSL3_TXT_RSA_DES_64_CBC_SHA,
198 SSL3_CK_RSA_DES_64_CBC_SHA, 250 SSL3_CK_RSA_DES_64_CBC_SHA,
199 SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 251 SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
252 SSL_NOT_EXP|SSL_LOW,
200 0, 253 0,
254 56,
255 56,
201 SSL_ALL_CIPHERS, 256 SSL_ALL_CIPHERS,
257 SSL_ALL_STRENGTHS,
202 }, 258 },
203/* Cipher 0A */ 259/* Cipher 0A */
204 { 260 {
205 1, 261 1,
206 SSL3_TXT_RSA_DES_192_CBC3_SHA, 262 SSL3_TXT_RSA_DES_192_CBC3_SHA,
207 SSL3_CK_RSA_DES_192_CBC3_SHA, 263 SSL3_CK_RSA_DES_192_CBC3_SHA,
208 SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 264 SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
265 SSL_NOT_EXP|SSL_HIGH,
209 0, 266 0,
267 168,
268 168,
210 SSL_ALL_CIPHERS, 269 SSL_ALL_CIPHERS,
270 SSL_ALL_STRENGTHS,
211 }, 271 },
212 272
213/* The DH ciphers */ 273/* The DH ciphers */
@@ -216,54 +276,78 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
216 0, 276 0,
217 SSL3_TXT_DH_DSS_DES_40_CBC_SHA, 277 SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
218 SSL3_CK_DH_DSS_DES_40_CBC_SHA, 278 SSL3_CK_DH_DSS_DES_40_CBC_SHA,
219 SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 279 SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
280 SSL_EXPORT|SSL_EXP40,
220 0, 281 0,
282 40,
283 56,
221 SSL_ALL_CIPHERS, 284 SSL_ALL_CIPHERS,
285 SSL_ALL_STRENGTHS,
222 }, 286 },
223/* Cipher 0C */ 287/* Cipher 0C */
224 { 288 {
225 0, 289 0,
226 SSL3_TXT_DH_DSS_DES_64_CBC_SHA, 290 SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
227 SSL3_CK_DH_DSS_DES_64_CBC_SHA, 291 SSL3_CK_DH_DSS_DES_64_CBC_SHA,
228 SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 292 SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
293 SSL_NOT_EXP|SSL_LOW,
229 0, 294 0,
295 56,
296 56,
230 SSL_ALL_CIPHERS, 297 SSL_ALL_CIPHERS,
298 SSL_ALL_STRENGTHS,
231 }, 299 },
232/* Cipher 0D */ 300/* Cipher 0D */
233 { 301 {
234 0, 302 0,
235 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA, 303 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
236 SSL3_CK_DH_DSS_DES_192_CBC3_SHA, 304 SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
237 SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 305 SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
306 SSL_NOT_EXP|SSL_HIGH,
238 0, 307 0,
308 168,
309 168,
239 SSL_ALL_CIPHERS, 310 SSL_ALL_CIPHERS,
311 SSL_ALL_STRENGTHS,
240 }, 312 },
241/* Cipher 0E */ 313/* Cipher 0E */
242 { 314 {
243 0, 315 0,
244 SSL3_TXT_DH_RSA_DES_40_CBC_SHA, 316 SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
245 SSL3_CK_DH_RSA_DES_40_CBC_SHA, 317 SSL3_CK_DH_RSA_DES_40_CBC_SHA,
246 SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 318 SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
319 SSL_EXPORT|SSL_EXP40,
247 0, 320 0,
321 40,
322 56,
248 SSL_ALL_CIPHERS, 323 SSL_ALL_CIPHERS,
324 SSL_ALL_STRENGTHS,
249 }, 325 },
250/* Cipher 0F */ 326/* Cipher 0F */
251 { 327 {
252 0, 328 0,
253 SSL3_TXT_DH_RSA_DES_64_CBC_SHA, 329 SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
254 SSL3_CK_DH_RSA_DES_64_CBC_SHA, 330 SSL3_CK_DH_RSA_DES_64_CBC_SHA,
255 SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 331 SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
332 SSL_NOT_EXP|SSL_LOW,
256 0, 333 0,
334 56,
335 56,
257 SSL_ALL_CIPHERS, 336 SSL_ALL_CIPHERS,
337 SSL_ALL_STRENGTHS,
258 }, 338 },
259/* Cipher 10 */ 339/* Cipher 10 */
260 { 340 {
261 0, 341 0,
262 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA, 342 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
263 SSL3_CK_DH_RSA_DES_192_CBC3_SHA, 343 SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
264 SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 344 SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
345 SSL_NOT_EXP|SSL_HIGH,
265 0, 346 0,
347 168,
348 168,
266 SSL_ALL_CIPHERS, 349 SSL_ALL_CIPHERS,
350 SSL_ALL_STRENGTHS,
267 }, 351 },
268 352
269/* The Ephemeral DH ciphers */ 353/* The Ephemeral DH ciphers */
@@ -272,54 +356,78 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
272 1, 356 1,
273 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA, 357 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA,
274 SSL3_CK_EDH_DSS_DES_40_CBC_SHA, 358 SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
275 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 359 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_SSLV3,
360 SSL_EXPORT|SSL_EXP40,
276 0, 361 0,
362 40,
363 56,
277 SSL_ALL_CIPHERS, 364 SSL_ALL_CIPHERS,
365 SSL_ALL_STRENGTHS,
278 }, 366 },
279/* Cipher 12 */ 367/* Cipher 12 */
280 { 368 {
281 1, 369 1,
282 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA, 370 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
283 SSL3_CK_EDH_DSS_DES_64_CBC_SHA, 371 SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
284 SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 372 SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_SSLV3,
373 SSL_NOT_EXP|SSL_LOW,
285 0, 374 0,
375 56,
376 56,
286 SSL_ALL_CIPHERS, 377 SSL_ALL_CIPHERS,
378 SSL_ALL_STRENGTHS,
287 }, 379 },
288/* Cipher 13 */ 380/* Cipher 13 */
289 { 381 {
290 1, 382 1,
291 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA, 383 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
292 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA, 384 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
293 SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 385 SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_SSLV3,
386 SSL_NOT_EXP|SSL_HIGH,
294 0, 387 0,
388 168,
389 168,
295 SSL_ALL_CIPHERS, 390 SSL_ALL_CIPHERS,
391 SSL_ALL_STRENGTHS,
296 }, 392 },
297/* Cipher 14 */ 393/* Cipher 14 */
298 { 394 {
299 1, 395 1,
300 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA, 396 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
301 SSL3_CK_EDH_RSA_DES_40_CBC_SHA, 397 SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
302 SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 398 SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
399 SSL_EXPORT|SSL_EXP40,
303 0, 400 0,
401 40,
402 56,
304 SSL_ALL_CIPHERS, 403 SSL_ALL_CIPHERS,
404 SSL_ALL_STRENGTHS,
305 }, 405 },
306/* Cipher 15 */ 406/* Cipher 15 */
307 { 407 {
308 1, 408 1,
309 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA, 409 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
310 SSL3_CK_EDH_RSA_DES_64_CBC_SHA, 410 SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
311 SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 411 SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
412 SSL_NOT_EXP|SSL_LOW,
312 0, 413 0,
414 56,
415 56,
313 SSL_ALL_CIPHERS, 416 SSL_ALL_CIPHERS,
417 SSL_ALL_STRENGTHS,
314 }, 418 },
315/* Cipher 16 */ 419/* Cipher 16 */
316 { 420 {
317 1, 421 1,
318 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA, 422 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
319 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA, 423 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA,
320 SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 424 SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
425 SSL_NOT_EXP|SSL_HIGH,
321 0, 426 0,
427 168,
428 168,
322 SSL_ALL_CIPHERS, 429 SSL_ALL_CIPHERS,
430 SSL_ALL_STRENGTHS,
323 }, 431 },
324 432
325/* Fortezza */ 433/* Fortezza */
@@ -328,9 +436,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
328 0, 436 0,
329 SSL3_TXT_FZA_DMS_NULL_SHA, 437 SSL3_TXT_FZA_DMS_NULL_SHA,
330 SSL3_CK_FZA_DMS_NULL_SHA, 438 SSL3_CK_FZA_DMS_NULL_SHA,
331 SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 439 SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_SSLV3,
440 SSL_NOT_EXP,
441 0,
442 0,
332 0, 443 0,
333 SSL_ALL_CIPHERS, 444 SSL_ALL_CIPHERS,
445 SSL_ALL_STRENGTHS,
334 }, 446 },
335 447
336/* Cipher 1D */ 448/* Cipher 1D */
@@ -338,9 +450,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
338 0, 450 0,
339 SSL3_TXT_FZA_DMS_FZA_SHA, 451 SSL3_TXT_FZA_DMS_FZA_SHA,
340 SSL3_CK_FZA_DMS_FZA_SHA, 452 SSL3_CK_FZA_DMS_FZA_SHA,
341 SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 453 SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_SSLV3,
454 SSL_NOT_EXP,
455 0,
456 0,
342 0, 457 0,
343 SSL_ALL_CIPHERS, 458 SSL_ALL_CIPHERS,
459 SSL_ALL_STRENGTHS,
344 }, 460 },
345 461
346/* Cipher 1E */ 462/* Cipher 1E */
@@ -348,9 +464,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
348 0, 464 0,
349 SSL3_TXT_FZA_DMS_RC4_SHA, 465 SSL3_TXT_FZA_DMS_RC4_SHA,
350 SSL3_CK_FZA_DMS_RC4_SHA, 466 SSL3_CK_FZA_DMS_RC4_SHA,
351 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 467 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3,
468 SSL_NOT_EXP,
352 0, 469 0,
470 128,
471 128,
353 SSL_ALL_CIPHERS, 472 SSL_ALL_CIPHERS,
473 SSL_ALL_STRENGTHS,
354 }, 474 },
355 475
356#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 476#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
@@ -360,54 +480,78 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
360 1, 480 1,
361 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5, 481 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
362 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5, 482 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
363 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_EXP56|SSL_TLSV1, 483 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_TLSV1,
484 SSL_EXPORT|SSL_EXP56,
364 0, 485 0,
365 SSL_ALL_CIPHERS 486 56,
487 128,
488 SSL_ALL_CIPHERS,
489 SSL_ALL_STRENGTHS,
366 }, 490 },
367 /* Cipher 61 */ 491 /* Cipher 61 */
368 { 492 {
369 1, 493 1,
370 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5, 494 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
371 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5, 495 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
372 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_EXP56|SSL_TLSV1, 496 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_TLSV1,
497 SSL_EXPORT|SSL_EXP56,
373 0, 498 0,
374 SSL_ALL_CIPHERS 499 56,
500 128,
501 SSL_ALL_CIPHERS,
502 SSL_ALL_STRENGTHS,
375 }, 503 },
376 /* Cipher 62 */ 504 /* Cipher 62 */
377 { 505 {
378 1, 506 1,
379 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA, 507 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
380 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA, 508 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
381 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_EXP56|SSL_TLSV1, 509 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_TLSV1,
510 SSL_EXPORT|SSL_EXP56,
382 0, 511 0,
383 SSL_ALL_CIPHERS 512 56,
513 56,
514 SSL_ALL_CIPHERS,
515 SSL_ALL_STRENGTHS,
384 }, 516 },
385 /* Cipher 63 */ 517 /* Cipher 63 */
386 { 518 {
387 1, 519 1,
388 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, 520 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
389 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, 521 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
390 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_EXP56|SSL_TLSV1, 522 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_TLSV1,
523 SSL_EXPORT|SSL_EXP56,
391 0, 524 0,
392 SSL_ALL_CIPHERS 525 56,
526 56,
527 SSL_ALL_CIPHERS,
528 SSL_ALL_STRENGTHS,
393 }, 529 },
394 /* Cipher 64 */ 530 /* Cipher 64 */
395 { 531 {
396 1, 532 1,
397 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA, 533 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
398 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA, 534 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
399 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_EXP56|SSL_TLSV1, 535 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
536 SSL_EXPORT|SSL_EXP56,
400 0, 537 0,
401 SSL_ALL_CIPHERS 538 56,
539 128,
540 SSL_ALL_CIPHERS,
541 SSL_ALL_STRENGTHS,
402 }, 542 },
403 /* Cipher 65 */ 543 /* Cipher 65 */
404 { 544 {
405 1, 545 1,
406 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, 546 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
407 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, 547 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
408 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_EXP56|SSL_TLSV1, 548 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
549 SSL_EXPORT|SSL_EXP56,
409 0, 550 0,
410 SSL_ALL_CIPHERS 551 56,
552 128,
553 SSL_ALL_CIPHERS,
554 SSL_ALL_STRENGTHS,
411 }, 555 },
412 /* Cipher 66 */ 556 /* Cipher 66 */
413 { 557 {
@@ -415,8 +559,12 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
415 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA, 559 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
416 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA, 560 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
417 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1, 561 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
562 SSL_NOT_EXP,
418 0, 563 0,
419 SSL_ALL_CIPHERS 564 128,
565 128,
566 SSL_ALL_CIPHERS,
567 SSL_ALL_STRENGTHS
420 }, 568 },
421#endif 569#endif
422 570
@@ -460,6 +608,9 @@ static SSL_METHOD SSLv3_data= {
460 ssl_bad_method, 608 ssl_bad_method,
461 ssl3_default_timeout, 609 ssl3_default_timeout,
462 &SSLv3_enc_data, 610 &SSLv3_enc_data,
611 ssl_undefined_function,
612 ssl3_callback_ctrl,
613 ssl3_ctx_callback_ctrl,
463 }; 614 };
464 615
465static long ssl3_default_timeout(void) 616static long ssl3_default_timeout(void)
@@ -495,19 +646,12 @@ int ssl3_pending(SSL *s)
495 646
496int ssl3_new(SSL *s) 647int ssl3_new(SSL *s)
497 { 648 {
498 SSL3_CTX *s3; 649 SSL3_STATE *s3;
499 650
500 if ((s3=(SSL3_CTX *)Malloc(sizeof(SSL3_CTX))) == NULL) goto err; 651 if ((s3=Malloc(sizeof *s3)) == NULL) goto err;
501 memset(s3,0,sizeof(SSL3_CTX)); 652 memset(s3,0,sizeof *s3);
502 653
503 s->s3=s3; 654 s->s3=s3;
504 /*
505 s->s3->tmp.ca_names=NULL;
506 s->s3->tmp.key_block=NULL;
507 s->s3->tmp.key_block_length=0;
508 s->s3->rbuf.buf=NULL;
509 s->s3->wbuf.buf=NULL;
510 */
511 655
512 s->method->ssl_clear(s); 656 s->method->ssl_clear(s);
513 return(1); 657 return(1);
@@ -533,7 +677,7 @@ void ssl3_free(SSL *s)
533#endif 677#endif
534 if (s->s3->tmp.ca_names != NULL) 678 if (s->s3->tmp.ca_names != NULL)
535 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); 679 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
536 memset(s->s3,0,sizeof(SSL3_CTX)); 680 memset(s->s3,0,sizeof *s->s3);
537 Free(s->s3); 681 Free(s->s3);
538 s->s3=NULL; 682 s->s3=NULL;
539 } 683 }
@@ -551,11 +695,15 @@ void ssl3_clear(SSL *s)
551 Free(s->s3->rrec.comp); 695 Free(s->s3->rrec.comp);
552 s->s3->rrec.comp=NULL; 696 s->s3->rrec.comp=NULL;
553 } 697 }
698#ifndef NO_DH
699 if (s->s3->tmp.dh != NULL)
700 DH_free(s->s3->tmp.dh);
701#endif
554 702
555 rp=s->s3->rbuf.buf; 703 rp=s->s3->rbuf.buf;
556 wp=s->s3->wbuf.buf; 704 wp=s->s3->wbuf.buf;
557 705
558 memset(s->s3,0,sizeof(SSL3_CTX)); 706 memset(s->s3,0,sizeof *s->s3);
559 if (rp != NULL) s->s3->rbuf.buf=rp; 707 if (rp != NULL) s->s3->rbuf.buf=rp;
560 if (wp != NULL) s->s3->wbuf.buf=wp; 708 if (wp != NULL) s->s3->wbuf.buf=wp;
561 709
@@ -638,7 +786,10 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
638 } 786 }
639 break; 787 break;
640 case SSL_CTRL_SET_TMP_RSA_CB: 788 case SSL_CTRL_SET_TMP_RSA_CB:
641 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))parg; 789 {
790 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
791 return(ret);
792 }
642 break; 793 break;
643#endif 794#endif
644#ifndef NO_DH 795#ifndef NO_DH
@@ -665,7 +816,54 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
665 } 816 }
666 break; 817 break;
667 case SSL_CTRL_SET_TMP_DH_CB: 818 case SSL_CTRL_SET_TMP_DH_CB:
668 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))parg; 819 {
820 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
821 return(ret);
822 }
823 break;
824#endif
825 default:
826 break;
827 }
828 return(ret);
829 }
830
831long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
832 {
833 int ret=0;
834
835#if !defined(NO_DSA) || !defined(NO_RSA)
836 if (
837#ifndef NO_RSA
838 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
839#endif
840#ifndef NO_DSA
841 cmd == SSL_CTRL_SET_TMP_DH_CB ||
842#endif
843 0)
844 {
845 if (!ssl_cert_inst(&s->cert))
846 {
847 SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
848 return(0);
849 }
850 }
851#endif
852
853 switch (cmd)
854 {
855#ifndef NO_RSA
856 case SSL_CTRL_SET_TMP_RSA_CB:
857 {
858 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
859 }
860 break;
861#endif
862#ifndef NO_DH
863 case SSL_CTRL_SET_TMP_DH_CB:
864 {
865 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
866 }
669 break; 867 break;
670#endif 868#endif
671 default: 869 default:
@@ -721,7 +919,10 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
721 } 919 }
722 /* break; */ 920 /* break; */
723 case SSL_CTRL_SET_TMP_RSA_CB: 921 case SSL_CTRL_SET_TMP_RSA_CB:
724 cert->rsa_tmp_cb=(RSA *(*)(SSL *, int, int))parg; 922 {
923 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
924 return(0);
925 }
725 break; 926 break;
726#endif 927#endif
727#ifndef NO_DH 928#ifndef NO_DH
@@ -748,7 +949,10 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
748 } 949 }
749 /*break; */ 950 /*break; */
750 case SSL_CTRL_SET_TMP_DH_CB: 951 case SSL_CTRL_SET_TMP_DH_CB:
751 cert->dh_tmp_cb=(DH *(*)(SSL *, int, int))parg; 952 {
953 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
954 return(0);
955 }
752 break; 956 break;
753#endif 957#endif
754 /* A Thawte special :-) */ 958 /* A Thawte special :-) */
@@ -767,6 +971,34 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
767 return(1); 971 return(1);
768 } 972 }
769 973
974long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
975 {
976 CERT *cert;
977
978 cert=ctx->cert;
979
980 switch (cmd)
981 {
982#ifndef NO_RSA
983 case SSL_CTRL_SET_TMP_RSA_CB:
984 {
985 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
986 }
987 break;
988#endif
989#ifndef NO_DH
990 case SSL_CTRL_SET_TMP_DH_CB:
991 {
992 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
993 }
994 break;
995#endif
996 default:
997 return(0);
998 }
999 return(1);
1000 }
1001
770/* This function needs to check if the ciphers required are actually 1002/* This function needs to check if the ciphers required are actually
771 * available */ 1003 * available */
772SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) 1004SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
@@ -819,21 +1051,6 @@ int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
819 return(2); 1051 return(2);
820 } 1052 }
821 1053
822int ssl3_part_read(SSL *s, int i)
823 {
824 s->rwstate=SSL_READING;
825
826 if (i < 0)
827 {
828 return(i);
829 }
830 else
831 {
832 s->init_num+=i;
833 return(0);
834 }
835 }
836
837SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have, 1054SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
838 STACK_OF(SSL_CIPHER) *pref) 1055 STACK_OF(SSL_CIPHER) *pref)
839 { 1056 {
@@ -865,7 +1082,7 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
865 emask=cert->export_mask; 1082 emask=cert->export_mask;
866 1083
867 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK); 1084 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK);
868 if (SSL_IS_EXPORT(c->algorithms)) 1085 if (SSL_C_IS_EXPORT(c))
869 { 1086 {
870 ok=((alg & emask) == alg)?1:0; 1087 ok=((alg & emask) == alg)?1:0;
871#ifdef CIPHER_DEBUG 1088#ifdef CIPHER_DEBUG
@@ -1034,8 +1251,12 @@ int ssl3_read(SSL *s, void *buf, int len)
1034 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len); 1251 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len);
1035 if ((ret == -1) && (s->s3->in_read_app_data == 0)) 1252 if ((ret == -1) && (s->s3->in_read_app_data == 0))
1036 { 1253 {
1037 ERR_get_error(); /* clear the error */ 1254 /* ssl3_read_bytes decided to call s->handshake_func, which
1038 s->s3->in_read_app_data=0; 1255 * called ssl3_read_bytes to read handshake data.
1256 * However, ssl3_read_bytes actually found application data
1257 * and thinks that application data makes sense here (signalled
1258 * by resetting 'in_read_app_data', strangely); so disable
1259 * handshake processing and try to read application data again. */
1039 s->in_handshake++; 1260 s->in_handshake++;
1040 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len); 1261 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len);
1041 s->in_handshake--; 1262 s->in_handshake--;
@@ -1092,7 +1313,7 @@ int ssl3_renegotiate_check(SSL *s)
1092 { 1313 {
1093/* 1314/*
1094if we are the server, and we have sent a 'RENEGOTIATE' message, we 1315if we are the server, and we have sent a 'RENEGOTIATE' message, we
1095need to go to SSL_ST_ACCEPT. 1316need to go to SSL_ST_ACCEPT.
1096*/ 1317*/
1097 /* SSL_ST_ACCEPT */ 1318 /* SSL_ST_ACCEPT */
1098 s->state=SSL_ST_RENEGOTIATE; 1319 s->state=SSL_ST_RENEGOTIATE;
diff --git a/src/lib/libssl/s3_pkt.c b/src/lib/libssl/s3_pkt.c
index 7893d03123..eb965310d9 100644
--- a/src/lib/libssl/s3_pkt.c
+++ b/src/lib/libssl/s3_pkt.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-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 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <errno.h> 113#include <errno.h>
@@ -71,104 +124,98 @@ static int ssl3_get_record(SSL *s);
71static int do_compress(SSL *ssl); 124static int do_compress(SSL *ssl);
72static int do_uncompress(SSL *ssl); 125static int do_uncompress(SSL *ssl);
73static int do_change_cipher_spec(SSL *ssl); 126static int do_change_cipher_spec(SSL *ssl);
127
128/* used only by ssl3_get_record */
74static int ssl3_read_n(SSL *s, int n, int max, int extend) 129static int ssl3_read_n(SSL *s, int n, int max, int extend)
75 { 130 {
131 /* If extend == 0, obtain new n-byte packet; if extend == 1, increase
132 * packet by another n bytes.
133 * The packet will be in the sub-array of s->s3->rbuf.buf specified
134 * by s->packet and s->packet_length.
135 * (If s->read_ahead is set, 'max' bytes may be stored in rbuf
136 * [plus s->packet_length bytes if extend == 1].)
137 */
76 int i,off,newb; 138 int i,off,newb;
77 139
78 /* if there is stuff still in the buffer from a previous read, 140 if (!extend)
79 * and there is more than we want, take some. */ 141 {
142 /* start with empty packet ... */
143 if (s->s3->rbuf.left == 0)
144 s->s3->rbuf.offset = 0;
145 s->packet = s->s3->rbuf.buf + s->s3->rbuf.offset;
146 s->packet_length = 0;
147 /* ... now we can act as if 'extend' was set */
148 }
149
150 /* if there is enough in the buffer from a previous read, take some */
80 if (s->s3->rbuf.left >= (int)n) 151 if (s->s3->rbuf.left >= (int)n)
81 { 152 {
82 if (extend) 153 s->packet_length+=n;
83 s->packet_length+=n;
84 else
85 {
86 s->packet= &(s->s3->rbuf.buf[s->s3->rbuf.offset]);
87 s->packet_length=n;
88 }
89 s->s3->rbuf.left-=n; 154 s->s3->rbuf.left-=n;
90 s->s3->rbuf.offset+=n; 155 s->s3->rbuf.offset+=n;
91 return(n); 156 return(n);
92 } 157 }
93 158
94 /* else we need to read more data */ 159 /* else we need to read more data */
95 if (!s->read_ahead) max=n; 160 if (!s->read_ahead)
96 if (max > SSL3_RT_MAX_PACKET_SIZE) 161 max=n;
97 max=SSL3_RT_MAX_PACKET_SIZE;
98
99 /* First check if there is some left or we want to extend */
100 off=0;
101 if ( (s->s3->rbuf.left != 0) ||
102 ((s->packet_length != 0) && extend))
103 {
104 newb=s->s3->rbuf.left;
105 if (extend)
106 {
107 /* Copy bytes back to the front of the buffer
108 * Take the bytes already pointed to by 'packet'
109 * and take the extra ones on the end. */
110 off=s->packet_length;
111 if (s->packet != s->s3->rbuf.buf)
112 memcpy(s->s3->rbuf.buf,s->packet,newb+off);
113 }
114 else if (s->s3->rbuf.offset != 0)
115 { /* so the data is not at the start of the buffer */
116 memcpy(s->s3->rbuf.buf,
117 &(s->s3->rbuf.buf[s->s3->rbuf.offset]),newb);
118 s->s3->rbuf.offset=0;
119 }
120 162
121 s->s3->rbuf.left=0; 163 {
164 /* avoid buffer overflow */
165 int max_max = SSL3_RT_MAX_PACKET_SIZE - 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)
169 max = max_max;
170 }
171 if (n > max) /* does not happen */
172 {
173 SSLerr(SSL_F_SSL3_READ_N,SSL_R_INTERNAL_ERROR);
174 return -1;
122 } 175 }
123 else
124 newb=0;
125 176
126 /* So we now have 'newb' bytes at the front of 177 off = s->packet_length;
127 * s->s3->rbuf.buf and need to read some more in on the end 178 newb = s->s3->rbuf.left;
128 * We start reading into the buffer at 's->s3->rbuf.offset' 179 /* Move any available bytes to front of buffer:
129 */ 180 * 'off' bytes already pointed to by 'packet',
130 s->packet=s->s3->rbuf.buf; 181 * 'newb' extra ones at the end */
182 if (s->packet != s->s3->rbuf.buf)
183 {
184 /* off > 0 */
185 memmove(s->s3->rbuf.buf, s->packet, off+newb);
186 s->packet = s->s3->rbuf.buf;
187 }
131 188
132 while (newb < n) 189 while (newb < n)
133 { 190 {
191 /* Now we have off+newb bytes at the front of s->s3->rbuf.buf and need
192 * to read in more until we have off+n (up to off+max if possible) */
193
134 clear_sys_error(); 194 clear_sys_error();
135 if (s->rbio != NULL) 195 if (s->rbio != NULL)
136 { 196 {
137 s->rwstate=SSL_READING; 197 s->rwstate=SSL_READING;
138 i=BIO_read(s->rbio, 198 i=BIO_read(s->rbio, &(s->s3->rbuf.buf[off+newb]), max-newb);
139 (char *)&(s->s3->rbuf.buf[off+newb]),
140 max-newb);
141 } 199 }
142 else 200 else
143 { 201 {
144 SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET); 202 SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET);
145 i= -1; 203 i = -1;
146 } 204 }
147 205
148 if (i <= 0) 206 if (i <= 0)
149 { 207 {
150 s->s3->rbuf.left+=newb; 208 s->s3->rbuf.left = newb;
151 return(i); 209 return(i);
152 } 210 }
153 newb+=i; 211 newb+=i;
154 } 212 }
155 213
156 /* record used data read */ 214 /* done reading, now the book-keeping */
157 if (newb > n) 215 s->s3->rbuf.offset = off + n;
158 { 216 s->s3->rbuf.left = newb - n;
159 s->s3->rbuf.offset=n+off; 217 s->packet_length += n;
160 s->s3->rbuf.left=newb-n; 218 s->rwstate=SSL_NOTHING;
161 }
162 else
163 {
164 s->s3->rbuf.offset=0;
165 s->s3->rbuf.left=0;
166 }
167
168 if (extend)
169 s->packet_length+=n;
170 else
171 s->packet_length+=n;
172 return(n); 219 return(n);
173 } 220 }
174 221
@@ -176,15 +223,15 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
176 * It will return <= 0 if more data is needed, normally due to an error 223 * It will return <= 0 if more data is needed, normally due to an error
177 * or non-blocking IO. 224 * or non-blocking IO.
178 * When it finishes, one packet has been decoded and can be found in 225 * When it finishes, one packet has been decoded and can be found in
179 * ssl->s3->rrec.type - is the type of record 226 * ssl->s3->rrec.type - is the type of record
180 * ssl->s3->rrec.data, - data 227 * ssl->s3->rrec.data, - data
181 * ssl->s3->rrec.length, - number of bytes 228 * ssl->s3->rrec.length, - number of bytes
182 */ 229 */
230/* used only by ssl3_read_bytes */
183static int ssl3_get_record(SSL *s) 231static int ssl3_get_record(SSL *s)
184 { 232 {
185 int ssl_major,ssl_minor,al; 233 int ssl_major,ssl_minor,al;
186 int n,i,ret= -1; 234 int n,i,ret= -1;
187 SSL3_BUFFER *rb;
188 SSL3_RECORD *rr; 235 SSL3_RECORD *rr;
189 SSL_SESSION *sess; 236 SSL_SESSION *sess;
190 unsigned char *p; 237 unsigned char *p;
@@ -194,7 +241,6 @@ static int ssl3_get_record(SSL *s)
194 int clear=0,extra; 241 int clear=0,extra;
195 242
196 rr= &(s->s3->rrec); 243 rr= &(s->s3->rrec);
197 rb= &(s->s3->rbuf);
198 sess=s->session; 244 sess=s->session;
199 245
200 if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) 246 if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)
@@ -253,27 +299,26 @@ again:
253 goto f_err; 299 goto f_err;
254 } 300 }
255 301
256 s->rstate=SSL_ST_READ_BODY; 302 /* now s->rstate == SSL_ST_READ_BODY */
257 } 303 }
258 304
259 /* get and decode the data */ 305 /* s->rstate == SSL_ST_READ_BODY, get and decode the data */
260 if (s->rstate == SSL_ST_READ_BODY) 306
307 if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH))
261 { 308 {
262 if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH)) 309 /* now s->packet_length == SSL3_RT_HEADER_LENGTH */
263 { 310 i=rr->length;
264 i=rr->length; 311 n=ssl3_read_n(s,i,i,1);
265 /*-(s->packet_length-SSL3_RT_HEADER_LENGTH); */ 312 if (n <= 0) return(n); /* error or non-blocking io */
266 n=ssl3_read_n(s,i,i,1); 313 /* now n == rr->length,
267 if (n <= 0) return(n); /* error or non-blocking io */ 314 * and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */
268 }
269 s->rstate=SSL_ST_READ_HEADER;
270 } 315 }
271 316
272 /* At this point, we have the data in s->packet and there should be 317 s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */
273 * s->packet_length bytes, we must not 'overrun' this buffer :-)
274 * One of the following functions will copy the data from the
275 * s->packet buffer */
276 318
319 /* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length,
320 * and we have that many bytes in s->packet
321 */
277 rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]); 322 rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]);
278 323
279 /* ok, we can now read from 's->packet' data into 'rr' 324 /* ok, we can now read from 's->packet' data into 'rr'
@@ -283,13 +328,10 @@ again:
283 * When the data is 'copied' into the rr->data buffer, 328 * When the data is 'copied' into the rr->data buffer,
284 * rr->input will be pointed at the new buffer */ 329 * rr->input will be pointed at the new buffer */
285 330
286 /* Set the state for the following operations */
287 s->rstate=SSL_ST_READ_HEADER;
288
289 /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] 331 /* We now have - encrypted [ MAC [ compressed [ plain ] ] ]
290 * rr->length bytes of encrypted compressed stuff. */ 332 * rr->length bytes of encrypted compressed stuff. */
291 333
292 /* check is not needed I belive */ 334 /* check is not needed I believe */
293 if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) 335 if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
294 { 336 {
295 al=SSL_AD_RECORD_OVERFLOW; 337 al=SSL_AD_RECORD_OVERFLOW;
@@ -326,7 +368,7 @@ printf("\n");
326 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); 368 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
327 goto f_err; 369 goto f_err;
328 } 370 }
329 /* check MAC for rr->input' */ 371 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */
330 if (rr->length < mac_size) 372 if (rr->length < mac_size)
331 { 373 {
332 al=SSL_AD_DECODE_ERROR; 374 al=SSL_AD_DECODE_ERROR;
@@ -426,12 +468,12 @@ static int do_compress(SSL *ssl)
426 return(1); 468 return(1);
427 } 469 }
428 470
429/* Call this to write data 471/* Call this to write data in records of type 'type'
430 * It will return <= 0 if not all data has been sent or non-blocking IO. 472 * It will return <= 0 if not all data has been sent or non-blocking IO.
431 */ 473 */
432int ssl3_write_bytes(SSL *s, int type, const void *_buf, int len) 474int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
433 { 475 {
434 const unsigned char *buf=_buf; 476 const unsigned char *buf=buf_;
435 unsigned int tot,n,nw; 477 unsigned int tot,n,nw;
436 int i; 478 int i;
437 479
@@ -457,7 +499,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *_buf, int len)
457 nw=SSL3_RT_MAX_PLAIN_LENGTH; 499 nw=SSL3_RT_MAX_PLAIN_LENGTH;
458 else 500 else
459 nw=n; 501 nw=n;
460 502
461 i=do_ssl3_write(s,type,&(buf[tot]),nw); 503 i=do_ssl3_write(s,type,&(buf[tot]),nw);
462 if (i <= 0) 504 if (i <= 0)
463 { 505 {
@@ -465,9 +507,6 @@ int ssl3_write_bytes(SSL *s, int type, const void *_buf, int len)
465 return(i); 507 return(i);
466 } 508 }
467 509
468 if (type == SSL3_RT_HANDSHAKE)
469 ssl3_finish_mac(s,&(buf[tot]),i);
470
471 if ((i == (int)n) || 510 if ((i == (int)n) ||
472 (type == SSL3_RT_APPLICATION_DATA && 511 (type == SSL3_RT_APPLICATION_DATA &&
473 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) 512 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE)))
@@ -503,8 +542,8 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
503 /* if it went, fall through and send more stuff */ 542 /* if it went, fall through and send more stuff */
504 } 543 }
505 544
506 if (len <= 0) return(len); 545 if (len == 0) return(len);
507 546
508 wr= &(s->s3->wrec); 547 wr= &(s->s3->wrec);
509 wb= &(s->s3->wbuf); 548 wb= &(s->s3->wbuf);
510 sess=s->session; 549 sess=s->session;
@@ -527,11 +566,11 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
527 566
528 *(p++)=(s->version>>8); 567 *(p++)=(s->version>>8);
529 *(p++)=s->version&0xff; 568 *(p++)=s->version&0xff;
530 569
531 /* record where we are to write out packet length */ 570 /* record where we are to write out packet length */
532 plen=p; 571 plen=p;
533 p+=2; 572 p+=2;
534 573
535 /* lets setup the record stuff. */ 574 /* lets setup the record stuff. */
536 wr->data=p; 575 wr->data=p;
537 wr->length=(int)len; 576 wr->length=(int)len;
@@ -638,19 +677,75 @@ static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
638 } 677 }
639 } 678 }
640 679
680/* Return up to 'len' payload bytes received in 'type' records.
681 * 'type' is one of the following:
682 *
683 * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us)
684 * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us)
685 * - 0 (during a shutdown, no data has to be returned)
686 *
687 * If we don't have stored data to work from, read a SSL/TLS record first
688 * (possibly multiple records if we still don't have anything to return).
689 *
690 * This function must handle any surprises the peer may have for us, such as
691 * Alert records (e.g. close_notify), ChangeCipherSpec records (not really
692 * a surprise, but handled as if it were), or renegotiation requests.
693 * Also if record payloads contain fragments too small to process, we store
694 * them until there is enough for the respective protocol (the record protocol
695 * may use arbitrary fragmentation and even interleaving):
696 * Change cipher spec protocol
697 * just 1 byte needed, no need for keeping anything stored
698 * Alert protocol
699 * 2 bytes needed (AlertLevel, AlertDescription)
700 * Handshake protocol
701 * 4 bytes needed (HandshakeType, uint24 length) -- we just have
702 * to detect unexpected Client Hello and Hello Request messages
703 * here, anything else is handled by higher layers
704 * Application data protocol
705 * none of our business
706 */
641int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len) 707int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len)
642 { 708 {
643 int al,i,j,n,ret; 709 int al,i,j,ret;
710 unsigned int n;
644 SSL3_RECORD *rr; 711 SSL3_RECORD *rr;
645 void (*cb)()=NULL; 712 void (*cb)()=NULL;
646 BIO *bio;
647 713
648 if (s->s3->rbuf.buf == NULL) /* Not initialize yet */ 714 if (s->s3->rbuf.buf == NULL) /* Not initialized yet */
649 if (!ssl3_setup_buffers(s)) 715 if (!ssl3_setup_buffers(s))
650 return(-1); 716 return(-1);
651 717
718 if ((type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type)
719 {
720 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_INTERNAL_ERROR);
721 return -1;
722 }
723
724 if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0))
725 /* (partially) satisfy request from storage */
726 {
727 unsigned char *src = s->s3->handshake_fragment;
728 unsigned char *dst = buf;
729 unsigned int k;
730
731 n = 0;
732 while ((len > 0) && (s->s3->handshake_fragment_len > 0))
733 {
734 *dst++ = *src++;
735 len--; s->s3->handshake_fragment_len--;
736 n++;
737 }
738 /* move any remaining fragment bytes: */
739 for (k = 0; k < s->s3->handshake_fragment_len; k++)
740 s->s3->handshake_fragment[k] = *src++;
741 return n;
742 }
743
744 /* Now s->s3->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */
745
652 if (!s->in_handshake && SSL_in_init(s)) 746 if (!s->in_handshake && SSL_in_init(s))
653 { 747 {
748 /* type == SSL3_RT_APPLICATION_DATA */
654 i=s->handshake_func(s); 749 i=s->handshake_func(s);
655 if (i < 0) return(i); 750 if (i < 0) return(i);
656 if (i == 0) 751 if (i == 0)
@@ -662,11 +757,11 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len)
662start: 757start:
663 s->rwstate=SSL_NOTHING; 758 s->rwstate=SSL_NOTHING;
664 759
665 /* s->s3->rrec.type - is the type of record 760 /* s->s3->rrec.type - is the type of record
666 * s->s3->rrec.data, - data 761 * s->s3->rrec.data, - data
667 * s->s3->rrec.off, - ofset into 'data' for next read 762 * s->s3->rrec.off, - offset into 'data' for next read
668 * s->s3->rrec.length, - number of bytes. */ 763 * s->s3->rrec.length, - number of bytes. */
669 rr= &(s->s3->rrec); 764 rr = &(s->s3->rrec);
670 765
671 /* get new packet */ 766 /* get new packet */
672 if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) 767 if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY))
@@ -677,7 +772,9 @@ start:
677 772
678 /* we now have a packet which can be read and processed */ 773 /* we now have a packet which can be read and processed */
679 774
680 if (s->s3->change_cipher_spec && (rr->type != SSL3_RT_HANDSHAKE)) 775 if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec,
776 * reset by ssl3_get_finished */
777 && (rr->type != SSL3_RT_HANDSHAKE))
681 { 778 {
682 al=SSL_AD_UNEXPECTED_MESSAGE; 779 al=SSL_AD_UNEXPECTED_MESSAGE;
683 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); 780 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED);
@@ -692,16 +789,98 @@ start:
692 return(0); 789 return(0);
693 } 790 }
694 791
695 /* Check for an incoming 'Client Request' message */ 792
696 if ((rr->type == SSL3_RT_HANDSHAKE) && (rr->length == 4) && 793 if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */
697 (rr->data[0] == SSL3_MT_CLIENT_REQUEST) && 794 {
795 /* make sure that we are not getting application data when we
796 * are doing a handshake for the first time */
797 if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
798 (s->enc_read_ctx == NULL))
799 {
800 al=SSL_AD_UNEXPECTED_MESSAGE;
801 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE);
802 goto f_err;
803 }
804
805 if (len <= 0) return(len);
806
807 if ((unsigned int)len > rr->length)
808 n = rr->length;
809 else
810 n = (unsigned int)len;
811
812 memcpy(buf,&(rr->data[rr->off]),n);
813 rr->length-=n;
814 rr->off+=n;
815 if (rr->length == 0)
816 {
817 s->rstate=SSL_ST_READ_HEADER;
818 rr->off=0;
819 }
820 return(n);
821 }
822
823
824 /* If we get here, then type != rr->type; if we have a handshake
825 * message, then it was unexpected (Hello Request or Client Hello). */
826
827 /* In case of record types for which we have 'fragment' storage,
828 * fill that so that we can process the data at a fixed place.
829 */
830 {
831 unsigned int dest_maxlen = 0;
832 unsigned char *dest = NULL;
833 unsigned int *dest_len = NULL;
834
835 if (rr->type == SSL3_RT_HANDSHAKE)
836 {
837 dest_maxlen = sizeof s->s3->handshake_fragment;
838 dest = s->s3->handshake_fragment;
839 dest_len = &s->s3->handshake_fragment_len;
840 }
841 else if (rr->type == SSL3_RT_ALERT)
842 {
843 dest_maxlen = sizeof s->s3->alert_fragment;
844 dest = s->s3->alert_fragment;
845 dest_len = &s->s3->alert_fragment_len;
846 }
847
848 if (dest_maxlen > 0)
849 {
850 n = dest_maxlen - *dest_len; /* available space in 'dest' */
851 if (rr->length < n)
852 n = rr->length; /* available bytes */
853
854 /* now move 'n' bytes: */
855 while (n-- > 0)
856 {
857 dest[(*dest_len)++] = rr->data[rr->off++];
858 rr->length--;
859 }
860
861 if (*dest_len < dest_maxlen)
862 goto start; /* fragment was too small */
863 }
864 }
865
866 /* s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE;
867 * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT.
868 * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) */
869
870 /* If we are a client, check for an incoming 'Hello Request': */
871 if ((!s->server) &&
872 (s->s3->handshake_fragment_len >= 4) &&
873 (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) &&
698 (s->session != NULL) && (s->session->cipher != NULL)) 874 (s->session != NULL) && (s->session->cipher != NULL))
699 { 875 {
700 if ((rr->data[1] != 0) || (rr->data[2] != 0) || 876 s->s3->handshake_fragment_len = 0;
701 (rr->data[3] != 0)) 877
878 if ((s->s3->handshake_fragment[1] != 0) ||
879 (s->s3->handshake_fragment[2] != 0) ||
880 (s->s3->handshake_fragment[3] != 0))
702 { 881 {
703 al=SSL_AD_DECODE_ERROR; 882 al=SSL_AD_DECODE_ERROR;
704 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CLIENT_REQUEST); 883 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_HELLO_REQUEST);
705 goto err; 884 goto err;
706 } 885 }
707 886
@@ -712,220 +891,209 @@ start:
712 ssl3_renegotiate(s); 891 ssl3_renegotiate(s);
713 if (ssl3_renegotiate_check(s)) 892 if (ssl3_renegotiate_check(s))
714 { 893 {
715 n=s->handshake_func(s); 894 i=s->handshake_func(s);
716 if (n < 0) return(n); 895 if (i < 0) return(i);
717 if (n == 0) 896 if (i == 0)
718 { 897 {
719 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); 898 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
720 return(-1); 899 return(-1);
721 } 900 }
901
902 if (s->s3->rbuf.left == 0) /* no read-ahead left? */
903 {
904 BIO *bio;
905 /* In the case where we try to read application data
906 * the first time, but we trigger an SSL handshake, we
907 * return -1 with the retry option set. I do this
908 * otherwise renegotiation can cause nasty problems
909 * in the blocking world */ /* ? */
910 s->rwstate=SSL_READING;
911 bio=SSL_get_rbio(s);
912 BIO_clear_retry_flags(bio);
913 BIO_set_retry_read(bio);
914 return(-1);
915 }
722 } 916 }
723 } 917 }
724 rr->length=0; 918 /* we either finished a handshake or ignored the request,
725/* ZZZ */ goto start; 919 * now try again to obtain the (application) data we were asked for */
920 goto start;
726 } 921 }
727 922
728 /* if it is not the type we want, or we have shutdown and want 923 if (s->s3->alert_fragment_len >= 2)
729 * the peer shutdown */
730 if ((rr->type != type) || (s->shutdown & SSL_SENT_SHUTDOWN))
731 { 924 {
732 if (rr->type == SSL3_RT_ALERT) 925 int alert_level = s->s3->alert_fragment[0];
733 { 926 int alert_descr = s->s3->alert_fragment[1];
734 if ((rr->length != 2) || (rr->off != 0))
735 {
736 al=SSL_AD_DECODE_ERROR;
737 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_ALERT_RECORD);
738 goto f_err;
739 }
740 927
741 i=rr->data[0]; 928 s->s3->alert_fragment_len = 0;
742 n=rr->data[1];
743 929
744 /* clear from buffer */ 930 if (s->info_callback != NULL)
745 rr->length=0; 931 cb=s->info_callback;
746 932 else if (s->ctx->info_callback != NULL)
747 if (s->info_callback != NULL) 933 cb=s->ctx->info_callback;
748 cb=s->info_callback;
749 else if (s->ctx->info_callback != NULL)
750 cb=s->ctx->info_callback;
751 934
752 if (cb != NULL) 935 if (cb != NULL)
753 { 936 {
754 j=(i<<8)|n; 937 j = (alert_level << 8) | alert_descr;
755 cb(s,SSL_CB_READ_ALERT,j); 938 cb(s, SSL_CB_READ_ALERT, j);
756 } 939 }
757 940
758 if (i == 1) 941 if (alert_level == 1) /* warning */
759 { 942 {
760 s->s3->warn_alert=n; 943 s->s3->warn_alert = alert_descr;
761 if (n == SSL_AD_CLOSE_NOTIFY) 944 if (alert_descr == SSL_AD_CLOSE_NOTIFY)
762 {
763 s->shutdown|=SSL_RECEIVED_SHUTDOWN;
764 return(0);
765 }
766 }
767 else if (i == 2)
768 { 945 {
769 char tmp[16]; 946 s->shutdown |= SSL_RECEIVED_SHUTDOWN;
770
771 s->rwstate=SSL_NOTHING;
772 s->s3->fatal_alert=n;
773 SSLerr(SSL_F_SSL3_READ_BYTES,
774 SSL_AD_REASON_OFFSET+n);
775 sprintf(tmp,"%d",n);
776 ERR_add_error_data(2,"SSL alert number ",tmp);
777 s->shutdown|=SSL_RECEIVED_SHUTDOWN;
778 SSL_CTX_remove_session(s->ctx,s->session);
779 return(0); 947 return(0);
780 } 948 }
781 else
782 {
783 al=SSL_AD_ILLEGAL_PARAMETER;
784 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE);
785 goto f_err;
786 }
787
788 rr->length=0;
789 goto start;
790 } 949 }
791 950 else if (alert_level == 2) /* fatal */
792 if (s->shutdown & SSL_SENT_SHUTDOWN)
793 { 951 {
952 char tmp[16];
953
794 s->rwstate=SSL_NOTHING; 954 s->rwstate=SSL_NOTHING;
795 rr->length=0; 955 s->s3->fatal_alert = alert_descr;
956 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr);
957 sprintf(tmp,"%d",alert_descr);
958 ERR_add_error_data(2,"SSL alert number ",tmp);
959 s->shutdown|=SSL_RECEIVED_SHUTDOWN;
960 SSL_CTX_remove_session(s->ctx,s->session);
796 return(0); 961 return(0);
797 } 962 }
798 963 else
799 if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC)
800 { 964 {
801 if ( (rr->length != 1) || (rr->off != 0) || 965 al=SSL_AD_ILLEGAL_PARAMETER;
802 (rr->data[0] != SSL3_MT_CCS)) 966 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE);
803 { 967 goto f_err;
804 i=SSL_AD_ILLEGAL_PARAMETER; 968 }
805 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC);
806 goto err;
807 }
808 969
809 rr->length=0; 970 goto start;
810 s->s3->change_cipher_spec=1; 971 }
811 if (!do_change_cipher_spec(s)) 972
812 goto err; 973 if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */
813 else 974 {
814 goto start; 975 s->rwstate=SSL_NOTHING;
976 rr->length=0;
977 return(0);
978 }
979
980 if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC)
981 {
982 /* 'Change Cipher Spec' is just a single byte, so we know
983 * exactly what the record payload has to look like */
984 if ( (rr->length != 1) || (rr->off != 0) ||
985 (rr->data[0] != SSL3_MT_CCS))
986 {
987 i=SSL_AD_ILLEGAL_PARAMETER;
988 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC);
989 goto err;
815 } 990 }
816 991
817 /* else we have a handshake */ 992 rr->length=0;
818 if ((rr->type == SSL3_RT_HANDSHAKE) && 993 s->s3->change_cipher_spec=1;
819 !s->in_handshake) 994 if (!do_change_cipher_spec(s))
995 goto err;
996 else
997 goto start;
998 }
999
1000 /* Unexpected handshake message (Client Hello, or protocol violation) */
1001 if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake)
1002 {
1003 if (((s->state&SSL_ST_MASK) == SSL_ST_OK) &&
1004 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS))
820 { 1005 {
821 if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && 1006#if 0 /* worked only because C operator preferences are not as expected (and
822 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) 1007 * because this is not really needed for clients except for detecting
823 { 1008 * protocol violations): */
824 s->state=SSL_ST_BEFORE|(s->server) 1009 s->state=SSL_ST_BEFORE|(s->server)
825 ?SSL_ST_ACCEPT 1010 ?SSL_ST_ACCEPT
826 :SSL_ST_CONNECT; 1011 :SSL_ST_CONNECT;
827 s->new_session=1; 1012#else
828 } 1013 s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT;
829 n=s->handshake_func(s); 1014#endif
830 if (n < 0) return(n); 1015 s->new_session=1;
831 if (n == 0) 1016 }
832 { 1017 i=s->handshake_func(s);
833 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); 1018 if (i < 0) return(i);
834 return(-1); 1019 if (i == 0)
835 } 1020 {
1021 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
1022 return(-1);
1023 }
836 1024
1025 if (s->s3->rbuf.left == 0) /* no read-ahead left? */
1026 {
1027 BIO *bio;
837 /* In the case where we try to read application data 1028 /* In the case where we try to read application data
838 * the first time, but we trigger an SSL handshake, we 1029 * the first time, but we trigger an SSL handshake, we
839 * return -1 with the retry option set. I do this 1030 * return -1 with the retry option set. I do this
840 * otherwise renegotiation can cause nasty problems 1031 * otherwise renegotiation can cause nasty problems
841 * in the non-blocking world */ 1032 * in the blocking world */ /* ? */
842
843 s->rwstate=SSL_READING; 1033 s->rwstate=SSL_READING;
844 bio=SSL_get_rbio(s); 1034 bio=SSL_get_rbio(s);
845 BIO_clear_retry_flags(bio); 1035 BIO_clear_retry_flags(bio);
846 BIO_set_retry_read(bio); 1036 BIO_set_retry_read(bio);
847 return(-1); 1037 return(-1);
848 } 1038 }
1039 goto start;
1040 }
849 1041
850 switch (rr->type) 1042 switch (rr->type)
851 { 1043 {
852 default: 1044 default:
853#ifndef NO_TLS 1045#ifndef NO_TLS
854 /* TLS just ignores unknown message types */ 1046 /* TLS just ignores unknown message types */
855 if (s->version == TLS1_VERSION) 1047 if (s->version == TLS1_VERSION)
856 { 1048 {
857 goto start; 1049 goto start;
858 } 1050 }
859#endif 1051#endif
860 case SSL3_RT_CHANGE_CIPHER_SPEC: 1052 al=SSL_AD_UNEXPECTED_MESSAGE;
861 case SSL3_RT_ALERT: 1053 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);
862 case SSL3_RT_HANDSHAKE: 1054 goto f_err;
1055 case SSL3_RT_CHANGE_CIPHER_SPEC:
1056 case SSL3_RT_ALERT:
1057 case SSL3_RT_HANDSHAKE:
1058 /* we already handled all of these, with the possible exception
1059 * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that
1060 * should not happen when type != rr->type */
1061 al=SSL_AD_UNEXPECTED_MESSAGE;
1062 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_INTERNAL_ERROR);
1063 goto f_err;
1064 case SSL3_RT_APPLICATION_DATA:
1065 /* At this point, we were expecting handshake data,
1066 * but have application data. If the library was
1067 * running inside ssl3_read() (i.e. in_read_app_data
1068 * is set) and it makes sense to read application data
1069 * at this point (session renegotiation not yet started),
1070 * we will indulge it.
1071 */
1072 if (s->s3->in_read_app_data &&
1073 (s->s3->total_renegotiations != 0) &&
1074 ((
1075 (s->state & SSL_ST_CONNECT) &&
1076 (s->state >= SSL3_ST_CW_CLNT_HELLO_A) &&
1077 (s->state <= SSL3_ST_CR_SRVR_HELLO_A)
1078 ) || (
1079 (s->state & SSL_ST_ACCEPT) &&
1080 (s->state <= SSL3_ST_SW_HELLO_REQ_A) &&
1081 (s->state >= SSL3_ST_SR_CLNT_HELLO_A)
1082 )
1083 ))
1084 {
1085 s->s3->in_read_app_data=0;
1086 return(-1);
1087 }
1088 else
1089 {
863 al=SSL_AD_UNEXPECTED_MESSAGE; 1090 al=SSL_AD_UNEXPECTED_MESSAGE;
864 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); 1091 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);
865 goto f_err; 1092 goto f_err;
866 case SSL3_RT_APPLICATION_DATA:
867 /* At this point, we were expecting something else,
868 * but have application data. What we do is set the
869 * error, and return -1. On the way out, if the
870 * library was running inside ssl3_read() and it makes
871 * sense to read application data at this point, we
872 * will indulge it. This will mostly happen during
873 * session renegotiation.
874 */
875 if (s->s3->in_read_app_data &&
876 (s->s3->total_renegotiations != 0) &&
877 ((
878 (s->state & SSL_ST_CONNECT) &&
879 (s->state >= SSL3_ST_CW_CLNT_HELLO_A) &&
880 (s->state <= SSL3_ST_CR_SRVR_HELLO_A)
881 ) || (
882 (s->state & SSL_ST_ACCEPT) &&
883 (s->state <= SSL3_ST_SW_HELLO_REQ_A) &&
884 (s->state >= SSL3_ST_SR_CLNT_HELLO_A)
885 )
886 ))
887 {
888 s->s3->in_read_app_data=0;
889 return(-1);
890 }
891 else
892 {
893 al=SSL_AD_UNEXPECTED_MESSAGE;
894 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);
895 goto f_err;
896 }
897 } 1093 }
898 } 1094 }
1095 /* not reached */
899 1096
900 /* make sure that we are not getting application data when we
901 * are doing a handshake for the first time */
902 if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
903 (s->enc_read_ctx == NULL))
904 {
905 al=SSL_AD_UNEXPECTED_MESSAGE;
906 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE);
907 goto f_err;
908 }
909
910 if (len <= 0) return(len);
911
912 if ((unsigned int)len > rr->length)
913 n=rr->length;
914 else
915 n=len;
916
917 memcpy(buf,&(rr->data[rr->off]),(unsigned int)n);
918 rr->length-=n;
919 rr->off+=n;
920 if (rr->length <= 0)
921 {
922 s->rstate=SSL_ST_READ_HEADER;
923 rr->off=0;
924 }
925
926 if (type == SSL3_RT_HANDSHAKE)
927 ssl3_finish_mac(s,buf,n);
928 return(n);
929f_err: 1097f_err:
930 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1098 ssl3_send_alert(s,SSL3_AL_FATAL,al);
931err: 1099err:
@@ -935,7 +1103,7 @@ err:
935static int do_change_cipher_spec(SSL *s) 1103static int do_change_cipher_spec(SSL *s)
936 { 1104 {
937 int i; 1105 int i;
938 unsigned char *sender; 1106 const char *sender;
939 int slen; 1107 int slen;
940 1108
941 if (s->state & SSL_ST_ACCEPT) 1109 if (s->state & SSL_ST_ACCEPT)
@@ -957,37 +1125,23 @@ static int do_change_cipher_spec(SSL *s)
957 * the finished message */ 1125 * the finished message */
958 if (s->state & SSL_ST_CONNECT) 1126 if (s->state & SSL_ST_CONNECT)
959 { 1127 {
960 sender=s->method->ssl3_enc->server_finished; 1128 sender=s->method->ssl3_enc->server_finished_label;
961 slen=s->method->ssl3_enc->server_finished_len; 1129 slen=s->method->ssl3_enc->server_finished_label_len;
962 } 1130 }
963 else 1131 else
964 { 1132 {
965 sender=s->method->ssl3_enc->client_finished; 1133 sender=s->method->ssl3_enc->client_finished_label;
966 slen=s->method->ssl3_enc->client_finished_len; 1134 slen=s->method->ssl3_enc->client_finished_label_len;
967 } 1135 }
968 1136
969 s->method->ssl3_enc->final_finish_mac(s, 1137 s->s3->tmp.peer_finish_md_len = s->method->ssl3_enc->final_finish_mac(s,
970 &(s->s3->finish_dgst1), 1138 &(s->s3->finish_dgst1),
971 &(s->s3->finish_dgst2), 1139 &(s->s3->finish_dgst2),
972 sender,slen,&(s->s3->tmp.finish_md[0])); 1140 sender,slen,s->s3->tmp.peer_finish_md);
973 1141
974 return(1); 1142 return(1);
975 } 1143 }
976 1144
977int ssl3_do_write(SSL *s, int type)
978 {
979 int ret;
980
981 ret=ssl3_write_bytes(s,type,&s->init_buf->data[s->init_off],
982 s->init_num);
983 if (ret == s->init_num)
984 return(1);
985 if (ret < 0) return(-1);
986 s->init_off+=ret;
987 s->init_num-=ret;
988 return(0);
989 }
990
991void ssl3_send_alert(SSL *s, int level, int desc) 1145void ssl3_send_alert(SSL *s, int level, int desc)
992 { 1146 {
993 /* Map tls/ssl alert value to correct one */ 1147 /* Map tls/ssl alert value to correct one */
@@ -1029,7 +1183,7 @@ int ssl3_dispatch_alert(SSL *s)
1029 cb=s->info_callback; 1183 cb=s->info_callback;
1030 else if (s->ctx->info_callback != NULL) 1184 else if (s->ctx->info_callback != NULL)
1031 cb=s->ctx->info_callback; 1185 cb=s->ctx->info_callback;
1032 1186
1033 if (cb != NULL) 1187 if (cb != NULL)
1034 { 1188 {
1035 j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; 1189 j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1];
@@ -1038,4 +1192,3 @@ int ssl3_dispatch_alert(SSL *s)
1038 } 1192 }
1039 return(i); 1193 return(i);
1040 } 1194 }
1041
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c
index e003d88357..90806e2d99 100644
--- a/src/lib/libssl/s3_srvr.c
+++ b/src/lib/libssl/s3_srvr.c
@@ -57,6 +57,8 @@
57 */ 57 */
58 58
59#define REUSE_CIPHER_BUG 59#define REUSE_CIPHER_BUG
60#define NETSCAPE_HANG_BUG
61
60 62
61#include <stdio.h> 63#include <stdio.h>
62#include <openssl/buffer.h> 64#include <openssl/buffer.h>
@@ -70,13 +72,14 @@
70 72
71static SSL_METHOD *ssl3_get_server_method(int ver); 73static SSL_METHOD *ssl3_get_server_method(int ver);
72static int ssl3_get_client_hello(SSL *s); 74static int ssl3_get_client_hello(SSL *s);
75static int ssl3_check_client_hello(SSL *s);
73static int ssl3_send_server_hello(SSL *s); 76static int ssl3_send_server_hello(SSL *s);
74static int ssl3_send_server_key_exchange(SSL *s); 77static int ssl3_send_server_key_exchange(SSL *s);
75static int ssl3_send_certificate_request(SSL *s); 78static int ssl3_send_certificate_request(SSL *s);
76static int ssl3_send_server_done(SSL *s); 79static int ssl3_send_server_done(SSL *s);
77static int ssl3_get_cert_verify(SSL *s);
78static int ssl3_get_client_key_exchange(SSL *s); 80static int ssl3_get_client_key_exchange(SSL *s);
79static int ssl3_get_client_certificate(SSL *s); 81static int ssl3_get_client_certificate(SSL *s);
82static int ssl3_get_cert_verify(SSL *s);
80static int ssl3_send_hello_request(SSL *s); 83static int ssl3_send_hello_request(SSL *s);
81 84
82static SSL_METHOD *ssl3_get_server_method(int ver) 85static SSL_METHOD *ssl3_get_server_method(int ver)
@@ -112,7 +115,7 @@ int ssl3_accept(SSL *s)
112 int ret= -1; 115 int ret= -1;
113 int new_state,state,skip=0; 116 int new_state,state,skip=0;
114 117
115 RAND_seed(&Time,sizeof(Time)); 118 RAND_add(&Time,sizeof(Time),0);
116 ERR_clear_error(); 119 ERR_clear_error();
117 clear_sys_error(); 120 clear_sys_error();
118 121
@@ -151,7 +154,6 @@ int ssl3_accept(SSL *s)
151 154
152 if ((s->version>>8) != 3) 155 if ((s->version>>8) != 3)
153 abort(); 156 abort();
154 /* s->version=SSL3_VERSION; */
155 s->type=SSL_ST_ACCEPT; 157 s->type=SSL_ST_ACCEPT;
156 158
157 if (s->init_buf == NULL) 159 if (s->init_buf == NULL)
@@ -184,8 +186,8 @@ int ssl3_accept(SSL *s)
184 186
185 if (s->state != SSL_ST_RENEGOTIATE) 187 if (s->state != SSL_ST_RENEGOTIATE)
186 { 188 {
187 s->state=SSL3_ST_SR_CLNT_HELLO_A;
188 ssl3_init_finished_mac(s); 189 ssl3_init_finished_mac(s);
190 s->state=SSL3_ST_SR_CLNT_HELLO_A;
189 s->ctx->stats.sess_accept++; 191 s->ctx->stats.sess_accept++;
190 } 192 }
191 else 193 else
@@ -268,8 +270,8 @@ int ssl3_accept(SSL *s)
268 || (l & (SSL_DH|SSL_kFZA)) 270 || (l & (SSL_DH|SSL_kFZA))
269 || ((l & SSL_kRSA) 271 || ((l & SSL_kRSA)
270 && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL 272 && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL
271 || (SSL_IS_EXPORT(l) 273 || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)
272 && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_EXPORT_PKEYLENGTH(l) 274 && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)
273 ) 275 )
274 ) 276 )
275 ) 277 )
@@ -287,9 +289,19 @@ int ssl3_accept(SSL *s)
287 289
288 case SSL3_ST_SW_CERT_REQ_A: 290 case SSL3_ST_SW_CERT_REQ_A:
289 case SSL3_ST_SW_CERT_REQ_B: 291 case SSL3_ST_SW_CERT_REQ_B:
290 if (!(s->verify_mode & SSL_VERIFY_PEER) || 292 if (/* don't request cert unless asked for it: */
293 !(s->verify_mode & SSL_VERIFY_PEER) ||
294 /* if SSL_VERIFY_CLIENT_ONCE is set,
295 * don't request cert during re-negotiation: */
291 ((s->session->peer != NULL) && 296 ((s->session->peer != NULL) &&
292 (s->verify_mode & SSL_VERIFY_CLIENT_ONCE))) 297 (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
298 /* never request cert in anonymous ciphersuites
299 * (see section "Certificate request" in SSL 3 drafts
300 * and in RFC 2246): */
301 ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) &&
302 /* ... except when the application insists on verification
303 * (against the specs, but s3_clnt.c accepts this for SSL 3) */
304 !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)))
293 { 305 {
294 /* no cert request */ 306 /* no cert request */
295 skip=1; 307 skip=1;
@@ -301,7 +313,12 @@ int ssl3_accept(SSL *s)
301 s->s3->tmp.cert_request=1; 313 s->s3->tmp.cert_request=1;
302 ret=ssl3_send_certificate_request(s); 314 ret=ssl3_send_certificate_request(s);
303 if (ret <= 0) goto end; 315 if (ret <= 0) goto end;
316#ifndef NETSCAPE_HANG_BUG
304 s->state=SSL3_ST_SW_SRVR_DONE_A; 317 s->state=SSL3_ST_SW_SRVR_DONE_A;
318#else
319 s->state=SSL3_ST_SW_FLUSH;
320 s->s3->tmp.next_state=SSL3_ST_SR_CERT_A;
321#endif
305 s->init_num=0; 322 s->init_num=0;
306 } 323 }
307 break; 324 break;
@@ -331,12 +348,20 @@ int ssl3_accept(SSL *s)
331 348
332 case SSL3_ST_SR_CERT_A: 349 case SSL3_ST_SR_CERT_A:
333 case SSL3_ST_SR_CERT_B: 350 case SSL3_ST_SR_CERT_B:
334 /* could be sent for a DH cert, even if we 351 /* Check for second client hello (MS SGC) */
335 * have not asked for it :-) */ 352 ret = ssl3_check_client_hello(s);
336 ret=ssl3_get_client_certificate(s); 353 if (ret <= 0)
337 if (ret <= 0) goto end; 354 goto end;
338 s->init_num=0; 355 if (ret == 2)
339 s->state=SSL3_ST_SR_KEY_EXCH_A; 356 s->state = SSL3_ST_SR_CLNT_HELLO_C;
357 else {
358 /* could be sent for a DH cert, even if we
359 * have not asked for it :-) */
360 ret=ssl3_get_client_certificate(s);
361 if (ret <= 0) goto end;
362 s->init_num=0;
363 s->state=SSL3_ST_SR_KEY_EXCH_A;
364 }
340 break; 365 break;
341 366
342 case SSL3_ST_SR_KEY_EXCH_A: 367 case SSL3_ST_SR_KEY_EXCH_A:
@@ -350,10 +375,10 @@ int ssl3_accept(SSL *s)
350 * a client cert, it can be verified */ 375 * a client cert, it can be verified */
351 s->method->ssl3_enc->cert_verify_mac(s, 376 s->method->ssl3_enc->cert_verify_mac(s,
352 &(s->s3->finish_dgst1), 377 &(s->s3->finish_dgst1),
353 &(s->s3->tmp.finish_md[0])); 378 &(s->s3->tmp.cert_verify_md[0]));
354 s->method->ssl3_enc->cert_verify_mac(s, 379 s->method->ssl3_enc->cert_verify_mac(s,
355 &(s->s3->finish_dgst2), 380 &(s->s3->finish_dgst2),
356 &(s->s3->tmp.finish_md[MD5_DIGEST_LENGTH])); 381 &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]));
357 382
358 break; 383 break;
359 384
@@ -407,8 +432,8 @@ int ssl3_accept(SSL *s)
407 case SSL3_ST_SW_FINISHED_B: 432 case SSL3_ST_SW_FINISHED_B:
408 ret=ssl3_send_finished(s, 433 ret=ssl3_send_finished(s,
409 SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, 434 SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B,
410 s->method->ssl3_enc->server_finished, 435 s->method->ssl3_enc->server_finished_label,
411 s->method->ssl3_enc->server_finished_len); 436 s->method->ssl3_enc->server_finished_label_len);
412 if (ret <= 0) goto end; 437 if (ret <= 0) goto end;
413 s->state=SSL3_ST_SW_FLUSH; 438 s->state=SSL3_ST_SW_FLUSH;
414 if (s->hit) 439 if (s->hit)
@@ -485,7 +510,7 @@ static int ssl3_send_hello_request(SSL *s)
485 if (s->state == SSL3_ST_SW_HELLO_REQ_A) 510 if (s->state == SSL3_ST_SW_HELLO_REQ_A)
486 { 511 {
487 p=(unsigned char *)s->init_buf->data; 512 p=(unsigned char *)s->init_buf->data;
488 *(p++)=SSL3_MT_CLIENT_REQUEST; 513 *(p++)=SSL3_MT_HELLO_REQUEST;
489 *(p++)=0; 514 *(p++)=0;
490 *(p++)=0; 515 *(p++)=0;
491 *(p++)=0; 516 *(p++)=0;
@@ -500,6 +525,37 @@ static int ssl3_send_hello_request(SSL *s)
500 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); 525 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE));
501 } 526 }
502 527
528static int ssl3_check_client_hello(SSL *s)
529 {
530 int ok;
531 long n;
532
533 n=ssl3_get_message(s,
534 SSL3_ST_SR_CERT_A,
535 SSL3_ST_SR_CERT_B,
536 -1,
537 SSL3_RT_MAX_PLAIN_LENGTH,
538 &ok);
539 if (!ok) return((int)n);
540 s->s3->tmp.reuse_message = 1;
541 if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO)
542 {
543 /* Throw away what we have done so far in the current handshake,
544 * which will now be aborted. (A full SSL_clear would be too much.)
545 * I hope that tmp.dh is the only thing that may need to be cleared
546 * when a handshake is not completed ... */
547#ifndef NO_DH
548 if (s->s3->tmp.dh != NULL)
549 {
550 DH_free(s->s3->tmp.dh);
551 s->s3->tmp.dh = NULL;
552 }
553#endif
554 return 2;
555 }
556 return 1;
557}
558
503static int ssl3_get_client_hello(SSL *s) 559static int ssl3_get_client_hello(SSL *s)
504 { 560 {
505 int i,j,ok,al,ret= -1; 561 int i,j,ok,al,ret= -1;
@@ -531,10 +587,9 @@ static int ssl3_get_client_hello(SSL *s)
531 if (!ok) return((int)n); 587 if (!ok) return((int)n);
532 d=p=(unsigned char *)s->init_buf->data; 588 d=p=(unsigned char *)s->init_buf->data;
533 589
534 /* The version number has already been checked in ssl3_get_message. 590 /* use version from inside client hello, not from record header
535 * I a native TLSv1/SSLv3 method, the match must be correct except 591 * (may differ: see RFC 2246, Appendix E, second paragraph) */
536 * perhaps for the first message */ 592 s->client_version=(((int)p[0])<<8)|(int)p[1];
537/* s->client_version=(((int)p[0])<<8)|(int)p[1]; */
538 p+=2; 593 p+=2;
539 594
540 /* load the client random */ 595 /* load the client random */
@@ -754,7 +809,7 @@ static int ssl3_get_client_hello(SSL *s)
754 * compression - basically ignored right now 809 * compression - basically ignored right now
755 * ssl version is set - sslv3 810 * ssl version is set - sslv3
756 * s->session - The ssl session has been setup. 811 * s->session - The ssl session has been setup.
757 * s->hit - sesson reuse flag 812 * s->hit - session reuse flag
758 * s->tmp.new_cipher - the new cipher to use. 813 * s->tmp.new_cipher - the new cipher to use.
759 */ 814 */
760 815
@@ -782,7 +837,7 @@ static int ssl3_send_server_hello(SSL *s)
782 p=s->s3->server_random; 837 p=s->s3->server_random;
783 Time=time(NULL); /* Time */ 838 Time=time(NULL); /* Time */
784 l2n(Time,p); 839 l2n(Time,p);
785 RAND_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); 840 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
786 /* Do the message type and length last */ 841 /* Do the message type and length last */
787 d=p= &(buf[4]); 842 d=p= &(buf[4]);
788 843
@@ -866,9 +921,10 @@ static int ssl3_send_server_key_exchange(SSL *s)
866 int j,num; 921 int j,num;
867 RSA *rsa; 922 RSA *rsa;
868 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 923 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
924 unsigned int u;
869#endif 925#endif
870#ifndef NO_DH 926#ifndef NO_DH
871 DH *dh,*dhp; 927 DH *dh=NULL,*dhp;
872#endif 928#endif
873 EVP_PKEY *pkey; 929 EVP_PKEY *pkey;
874 unsigned char *p,*d; 930 unsigned char *p,*d;
@@ -899,6 +955,12 @@ static int ssl3_send_server_key_exchange(SSL *s)
899 rsa=s->cert->rsa_tmp_cb(s, 955 rsa=s->cert->rsa_tmp_cb(s,
900 SSL_C_IS_EXPORT(s->s3->tmp.new_cipher), 956 SSL_C_IS_EXPORT(s->s3->tmp.new_cipher),
901 SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)); 957 SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher));
958 if(rsa == NULL)
959 {
960 al=SSL_AD_HANDSHAKE_FAILURE;
961 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY);
962 goto f_err;
963 }
902 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 964 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA);
903 cert->rsa_tmp=rsa; 965 cert->rsa_tmp=rsa;
904 } 966 }
@@ -928,6 +990,14 @@ static int ssl3_send_server_key_exchange(SSL *s)
928 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY); 990 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY);
929 goto f_err; 991 goto f_err;
930 } 992 }
993
994 if (s->s3->tmp.dh != NULL)
995 {
996 DH_free(dh);
997 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_INTERNAL_ERROR);
998 goto err;
999 }
1000
931 if ((dh=DHparams_dup(dhp)) == NULL) 1001 if ((dh=DHparams_dup(dhp)) == NULL)
932 { 1002 {
933 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB); 1003 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB);
@@ -1027,15 +1097,14 @@ static int ssl3_send_server_key_exchange(SSL *s)
1027 q+=i; 1097 q+=i;
1028 j+=i; 1098 j+=i;
1029 } 1099 }
1030 i=RSA_private_encrypt(j,md_buf,&(p[2]), 1100 if (RSA_sign(NID_md5_sha1, md_buf, j,
1031 pkey->pkey.rsa,RSA_PKCS1_PADDING); 1101 &(p[2]), &u, pkey->pkey.rsa) <= 0)
1032 if (i <= 0)
1033 { 1102 {
1034 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_RSA); 1103 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_RSA);
1035 goto err; 1104 goto err;
1036 } 1105 }
1037 s2n(i,p); 1106 s2n(u,p);
1038 n+=i+2; 1107 n+=u+2;
1039 } 1108 }
1040 else 1109 else
1041#endif 1110#endif
@@ -1075,7 +1144,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
1075 s->init_off=0; 1144 s->init_off=0;
1076 } 1145 }
1077 1146
1078 /* SSL3_ST_SW_KEY_EXCH_B */ 1147 s->state = SSL3_ST_SW_KEY_EXCH_B;
1079 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); 1148 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE));
1080f_err: 1149f_err:
1081 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1150 ssl3_send_alert(s,SSL3_AL_FATAL,al);
@@ -1152,6 +1221,17 @@ static int ssl3_send_certificate_request(SSL *s)
1152 1221
1153 s->init_num=n+4; 1222 s->init_num=n+4;
1154 s->init_off=0; 1223 s->init_off=0;
1224#ifdef NETSCAPE_HANG_BUG
1225 p=(unsigned char *)s->init_buf->data + s->init_num;
1226
1227 /* do the header */
1228 *(p++)=SSL3_MT_SERVER_DONE;
1229 *(p++)=0;
1230 *(p++)=0;
1231 *(p++)=0;
1232 s->init_num += 4;
1233#endif
1234
1155 } 1235 }
1156 1236
1157 /* SSL3_ST_SW_CERT_REQ_B */ 1237 /* SSL3_ST_SW_CERT_REQ_B */
@@ -1239,31 +1319,6 @@ static int ssl3_get_client_key_exchange(SSL *s)
1239 1319
1240 i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); 1320 i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING);
1241 1321
1242#if 1
1243 /* If a bad decrypt, use a random master key */
1244 if ((i != SSL_MAX_MASTER_KEY_LENGTH) ||
1245 ((p[0] != (s->client_version>>8)) ||
1246 (p[1] != (s->client_version & 0xff))))
1247 {
1248 int bad=1;
1249
1250 if ((i == SSL_MAX_MASTER_KEY_LENGTH) &&
1251 (p[0] == (s->version>>8)) &&
1252 (p[1] == 0))
1253 {
1254 if (s->options & SSL_OP_TLS_ROLLBACK_BUG)
1255 bad=0;
1256 }
1257 if (bad)
1258 {
1259 p[0]=(s->version>>8);
1260 p[1]=(s->version & 0xff);
1261 RAND_bytes(&(p[2]),SSL_MAX_MASTER_KEY_LENGTH-2);
1262 i=SSL_MAX_MASTER_KEY_LENGTH;
1263 }
1264 /* else, an SSLeay bug, ssl only server, tls client */
1265 }
1266#else
1267 if (i != SSL_MAX_MASTER_KEY_LENGTH) 1322 if (i != SSL_MAX_MASTER_KEY_LENGTH)
1268 { 1323 {
1269 al=SSL_AD_DECODE_ERROR; 1324 al=SSL_AD_DECODE_ERROR;
@@ -1271,13 +1326,12 @@ static int ssl3_get_client_key_exchange(SSL *s)
1271 goto f_err; 1326 goto f_err;
1272 } 1327 }
1273 1328
1274 if ((p[0] != (s->version>>8)) || (p[1] != (s->version & 0xff))) 1329 if ((p[0] != (s->client_version>>8)) || (p[1] != (s->client_version & 0xff)))
1275 { 1330 {
1276 al=SSL_AD_DECODE_ERROR; 1331 al=SSL_AD_DECODE_ERROR;
1277 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); 1332 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER);
1278 goto f_err; 1333 goto f_err;
1279 } 1334 }
1280#endif
1281 1335
1282 s->session->master_key_length= 1336 s->session->master_key_length=
1283 s->method->ssl3_enc->generate_master_secret(s, 1337 s->method->ssl3_enc->generate_master_secret(s,
@@ -1450,16 +1504,16 @@ static int ssl3_get_cert_verify(SSL *s)
1450#ifndef NO_RSA 1504#ifndef NO_RSA
1451 if (pkey->type == EVP_PKEY_RSA) 1505 if (pkey->type == EVP_PKEY_RSA)
1452 { 1506 {
1453 i=RSA_public_decrypt(i,p,p,pkey->pkey.rsa,RSA_PKCS1_PADDING); 1507 i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,
1508 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, p, i,
1509 pkey->pkey.rsa);
1454 if (i < 0) 1510 if (i < 0)
1455 { 1511 {
1456 al=SSL_AD_DECRYPT_ERROR; 1512 al=SSL_AD_DECRYPT_ERROR;
1457 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT); 1513 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT);
1458 goto f_err; 1514 goto f_err;
1459 } 1515 }
1460 if ((i != (MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH)) || 1516 if (i == 0)
1461 memcmp(&(s->s3->tmp.finish_md[0]),p,
1462 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH))
1463 { 1517 {
1464 al=SSL_AD_DECRYPT_ERROR; 1518 al=SSL_AD_DECRYPT_ERROR;
1465 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE); 1519 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE);
@@ -1472,7 +1526,7 @@ static int ssl3_get_cert_verify(SSL *s)
1472 if (pkey->type == EVP_PKEY_DSA) 1526 if (pkey->type == EVP_PKEY_DSA)
1473 { 1527 {
1474 j=DSA_verify(pkey->save_type, 1528 j=DSA_verify(pkey->save_type,
1475 &(s->s3->tmp.finish_md[MD5_DIGEST_LENGTH]), 1529 &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]),
1476 SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa); 1530 SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa);
1477 if (j <= 0) 1531 if (j <= 0)
1478 { 1532 {
@@ -1532,7 +1586,7 @@ static int ssl3_get_client_certificate(SSL *s)
1532 al=SSL_AD_HANDSHAKE_FAILURE; 1586 al=SSL_AD_HANDSHAKE_FAILURE;
1533 goto f_err; 1587 goto f_err;
1534 } 1588 }
1535 /* If tls asked for a client cert we must return a 0 list */ 1589 /* If tls asked for a client cert, the client must return a 0 list */
1536 if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) 1590 if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request)
1537 { 1591 {
1538 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST); 1592 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST);
@@ -1628,6 +1682,7 @@ static int ssl3_get_client_certificate(SSL *s)
1628 if (s->session->peer != NULL) /* This should not be needed */ 1682 if (s->session->peer != NULL) /* This should not be needed */
1629 X509_free(s->session->peer); 1683 X509_free(s->session->peer);
1630 s->session->peer=sk_X509_shift(sk); 1684 s->session->peer=sk_X509_shift(sk);
1685 s->session->verify_result = s->verify_result;
1631 1686
1632 /* With the current implementation, sess_cert will always be NULL 1687 /* With the current implementation, sess_cert will always be NULL
1633 * when we arrive here. */ 1688 * when we arrive here. */
diff --git a/src/lib/libssl/shlib_version b/src/lib/libssl/shlib_version
index b52599a164..ba5a3fee58 100644
--- a/src/lib/libssl/shlib_version
+++ b/src/lib/libssl/shlib_version
@@ -1,2 +1,2 @@
1major=2 1major=2
2minor=0 2minor=2
diff --git a/src/lib/libssl/src/CHANGES b/src/lib/libssl/src/CHANGES
index d0db7eaf61..bf61913d7b 100644
--- a/src/lib/libssl/src/CHANGES
+++ b/src/lib/libssl/src/CHANGES
@@ -2,6 +2,1104 @@
2 OpenSSL CHANGES 2 OpenSSL CHANGES
3 _______________ 3 _______________
4 4
5 Changes between 0.9.4 and 0.9.5 [28 Feb 2000]
6
7 *) PKCS7_encrypt() was adding text MIME headers twice because they
8 were added manually and by SMIME_crlf_copy().
9 [Steve Henson]
10
11 *) In bntest.c don't call BN_rand with zero bits argument.
12 [Steve Henson, pointed out by Andrew W. Gray <agray@iconsinc.com>]
13
14 *) BN_mul bugfix: In bn_mul_part_recursion() only the a>a[n] && b>b[n]
15 case was implemented. This caused BN_div_recp() to fail occasionally.
16 [Ulf Möller]
17
18 *) Add an optional second argument to the set_label() in the perl
19 assembly language builder. If this argument exists and is set
20 to 1 it signals that the assembler should use a symbol whose
21 scope is the entire file, not just the current function. This
22 is needed with MASM which uses the format label:: for this scope.
23 [Steve Henson, pointed out by Peter Runestig <peter@runestig.com>]
24
25 *) Change the ASN1 types so they are typedefs by default. Before
26 almost all types were #define'd to ASN1_STRING which was causing
27 STACK_OF() problems: you couldn't declare STACK_OF(ASN1_UTF8STRING)
28 for example.
29 [Steve Henson]
30
31 *) Change names of new functions to the new get1/get0 naming
32 convention: After 'get1', the caller owns a reference count
33 and has to call ..._free; 'get0' returns a pointer to some
34 data structure without incrementing reference counters.
35 (Some of the existing 'get' functions increment a reference
36 counter, some don't.)
37 Similarly, 'set1' and 'add1' functions increase reference
38 counters or duplicate objects.
39 [Steve Henson]
40
41 *) Allow for the possibility of temp RSA key generation failure:
42 the code used to assume it always worked and crashed on failure.
43 [Steve Henson]
44
45 *) Fix potential buffer overrun problem in BIO_printf().
46 [Ulf Möller, using public domain code by Patrick Powell; problem
47 pointed out by David Sacerdote <das33@cornell.edu>]
48
49 *) Support EGD <http://www.lothar.com/tech/crypto/>. New functions
50 RAND_egd() and RAND_status(). In the command line application,
51 the EGD socket can be specified like a seed file using RANDFILE
52 or -rand.
53 [Ulf Möller]
54
55 *) Allow the string CERTIFICATE to be tolerated in PKCS#7 structures.
56 Some CAs (e.g. Verisign) distribute certificates in this form.
57 [Steve Henson]
58
59 *) Remove the SSL_ALLOW_ADH compile option and set the default cipher
60 list to exclude them. This means that no special compilation option
61 is needed to use anonymous DH: it just needs to be included in the
62 cipher list.
63 [Steve Henson]
64
65 *) Change the EVP_MD_CTX_type macro so its meaning consistent with
66 EVP_MD_type. The old functionality is available in a new macro called
67 EVP_MD_md(). Change code that uses it and update docs.
68 [Steve Henson]
69
70 *) ..._ctrl functions now have corresponding ..._callback_ctrl functions
71 where the 'void *' argument is replaced by a function pointer argument.
72 Previously 'void *' was abused to point to functions, which works on
73 many platforms, but is not correct. As these functions are usually
74 called by macros defined in OpenSSL header files, most source code
75 should work without changes.
76 [Richard Levitte]
77
78 *) <openssl/opensslconf.h> (which is created by Configure) now contains
79 sections with information on -D... compiler switches used for
80 compiling the library so that applications can see them. To enable
81 one of these sections, a pre-processor symbol OPENSSL_..._DEFINES
82 must be defined. E.g.,
83 #define OPENSSL_ALGORITHM_DEFINES
84 #include <openssl/opensslconf.h>
85 defines all pertinent NO_<algo> symbols, such as NO_IDEA, NO_RSA, etc.
86 [Richard Levitte, Ulf and Bodo Möller]
87
88 *) Bugfix: Tolerate fragmentation and interleaving in the SSL 3/TLS
89 record layer.
90 [Bodo Moeller]
91
92 *) Change the 'other' type in certificate aux info to a STACK_OF
93 X509_ALGOR. Although not an AlgorithmIdentifier as such it has
94 the required ASN1 format: arbitrary types determined by an OID.
95 [Steve Henson]
96
97 *) Add some PEM_write_X509_REQ_NEW() functions and a command line
98 argument to 'req'. This is not because the function is newer or
99 better than others it just uses the work 'NEW' in the certificate
100 request header lines. Some software needs this.
101 [Steve Henson]
102
103 *) Reorganise password command line arguments: now passwords can be
104 obtained from various sources. Delete the PEM_cb function and make
105 it the default behaviour: i.e. if the callback is NULL and the
106 usrdata argument is not NULL interpret it as a null terminated pass
107 phrase. If usrdata and the callback are NULL then the pass phrase
108 is prompted for as usual.
109 [Steve Henson]
110
111 *) Add support for the Compaq Atalla crypto accelerator. If it is installed,
112 the support is automatically enabled. The resulting binaries will
113 autodetect the card and use it if present.
114 [Ben Laurie and Compaq Inc.]
115
116 *) Work around for Netscape hang bug. This sends certificate request
117 and server done in one record. Since this is perfectly legal in the
118 SSL/TLS protocol it isn't a "bug" option and is on by default. See
119 the bugs/SSLv3 entry for more info.
120 [Steve Henson]
121
122 *) HP-UX tune-up: new unified configs, HP C compiler bug workaround.
123 [Andy Polyakov]
124
125 *) Add -rand argument to smime and pkcs12 applications and read/write
126 of seed file.
127 [Steve Henson]
128
129 *) New 'passwd' tool for crypt(3) and apr1 password hashes.
130 [Bodo Moeller]
131
132 *) Add command line password options to the remaining applications.
133 [Steve Henson]
134
135 *) Bug fix for BN_div_recp() for numerators with an even number of
136 bits.
137 [Ulf Möller]
138
139 *) More tests in bntest.c, and changed test_bn output.
140 [Ulf Möller]
141
142 *) ./config recognizes MacOS X now.
143 [Andy Polyakov]
144
145 *) Bug fix for BN_div() when the first words of num and divsor are
146 equal (it gave wrong results if (rem=(n1-q*d0)&BN_MASK2) < d0).
147 [Ulf Möller]
148
149 *) Add support for various broken PKCS#8 formats, and command line
150 options to produce them.
151 [Steve Henson]
152
153 *) New functions BN_CTX_start(), BN_CTX_get() and BT_CTX_end() to
154 get temporary BIGNUMs from a BN_CTX.
155 [Ulf Möller]
156
157 *) Correct return values in BN_mod_exp_mont() and BN_mod_exp2_mont()
158 for p == 0.
159 [Ulf Möller]
160
161 *) Change the SSLeay_add_all_*() functions to OpenSSL_add_all_*() and
162 include a #define from the old name to the new. The original intent
163 was that statically linked binaries could for example just call
164 SSLeay_add_all_ciphers() to just add ciphers to the table and not
165 link with digests. This never worked becayse SSLeay_add_all_digests()
166 and SSLeay_add_all_ciphers() were in the same source file so calling
167 one would link with the other. They are now in separate source files.
168 [Steve Henson]
169
170 *) Add a new -notext option to 'ca' and a -pubkey option to 'spkac'.
171 [Steve Henson]
172
173 *) Use a less unusual form of the Miller-Rabin primality test (it used
174 a binary algorithm for exponentiation integrated into the Miller-Rabin
175 loop, our standard modexp algorithms are faster).
176 [Bodo Moeller]
177
178 *) Support for the EBCDIC character set completed.
179 [Martin Kraemer <Martin.Kraemer@Mch.SNI.De>]
180
181 *) Source code cleanups: use const where appropriate, eliminate casts,
182 use void * instead of char * in lhash.
183 [Ulf Möller]
184
185 *) Bugfix: ssl3_send_server_key_exchange was not restartable
186 (the state was not changed to SSL3_ST_SW_KEY_EXCH_B, and because of
187 this the server could overwrite ephemeral keys that the client
188 has already seen).
189 [Bodo Moeller]
190
191 *) Turn DSA_is_prime into a macro that calls BN_is_prime,
192 using 50 iterations of the Rabin-Miller test.
193
194 DSA_generate_parameters now uses BN_is_prime_fasttest (with 50
195 iterations of the Rabin-Miller test as required by the appendix
196 to FIPS PUB 186[-1]) instead of DSA_is_prime.
197 As BN_is_prime_fasttest includes trial division, DSA parameter
198 generation becomes much faster.
199
200 This implies a change for the callback functions in DSA_is_prime
201 and DSA_generate_parameters: The callback function is called once
202 for each positive witness in the Rabin-Miller test, not just
203 occasionally in the inner loop; and the parameters to the
204 callback function now provide an iteration count for the outer
205 loop rather than for the current invocation of the inner loop.
206 DSA_generate_parameters additionally can call the callback
207 function with an 'iteration count' of -1, meaning that a
208 candidate has passed the trial division test (when q is generated
209 from an application-provided seed, trial division is skipped).
210 [Bodo Moeller]
211
212 *) New function BN_is_prime_fasttest that optionally does trial
213 division before starting the Rabin-Miller test and has
214 an additional BN_CTX * argument (whereas BN_is_prime always
215 has to allocate at least one BN_CTX).
216 'callback(1, -1, cb_arg)' is called when a number has passed the
217 trial division stage.
218 [Bodo Moeller]
219
220 *) Fix for bug in CRL encoding. The validity dates weren't being handled
221 as ASN1_TIME.
222 [Steve Henson]
223
224 *) New -pkcs12 option to CA.pl script to write out a PKCS#12 file.
225 [Steve Henson]
226
227 *) New function BN_pseudo_rand().
228 [Ulf Möller]
229
230 *) Clean up BN_mod_mul_montgomery(): replace the broken (and unreadable)
231 bignum version of BN_from_montgomery() with the working code from
232 SSLeay 0.9.0 (the word based version is faster anyway), and clean up
233 the comments.
234 [Ulf Möller]
235
236 *) Avoid a race condition in s2_clnt.c (function get_server_hello) that
237 made it impossible to use the same SSL_SESSION data structure in
238 SSL2 clients in multiple threads.
239 [Bodo Moeller]
240
241 *) The return value of RAND_load_file() no longer counts bytes obtained
242 by stat(). RAND_load_file(..., -1) is new and uses the complete file
243 to seed the PRNG (previously an explicit byte count was required).
244 [Ulf Möller, Bodo Möller]
245
246 *) Clean up CRYPTO_EX_DATA functions, some of these didn't have prototypes
247 used (char *) instead of (void *) and had casts all over the place.
248 [Steve Henson]
249
250 *) Make BN_generate_prime() return NULL on error if ret!=NULL.
251 [Ulf Möller]
252
253 *) Retain source code compatibility for BN_prime_checks macro:
254 BN_is_prime(..., BN_prime_checks, ...) now uses
255 BN_prime_checks_for_size to determine the appropriate number of
256 Rabin-Miller iterations.
257 [Ulf Möller]
258
259 *) Diffie-Hellman uses "safe" primes: DH_check() return code renamed to
260 DH_CHECK_P_NOT_SAFE_PRIME.
261 (Check if this is true? OpenPGP calls them "strong".)
262 [Ulf Möller]
263
264 *) Merge the functionality of "dh" and "gendh" programs into a new program
265 "dhparam". The old programs are retained for now but will handle DH keys
266 (instead of parameters) in future.
267 [Steve Henson]
268
269 *) Make the ciphers, s_server and s_client programs check the return values
270 when a new cipher list is set.
271 [Steve Henson]
272
273 *) Enhance the SSL/TLS cipher mechanism to correctly handle the TLS 56bit
274 ciphers. Before when the 56bit ciphers were enabled the sorting was
275 wrong.
276
277 The syntax for the cipher sorting has been extended to support sorting by
278 cipher-strength (using the strength_bits hard coded in the tables).
279 The new command is "@STRENGTH" (see also doc/apps/ciphers.pod).
280
281 Fix a bug in the cipher-command parser: when supplying a cipher command
282 string with an "undefined" symbol (neither command nor alphanumeric
283 [A-Za-z0-9], ssl_set_cipher_list used to hang in an endless loop. Now
284 an error is flagged.
285
286 Due to the strength-sorting extension, the code of the
287 ssl_create_cipher_list() function was completely rearranged. I hope that
288 the readability was also increased :-)
289 [Lutz Jaenicke <Lutz.Jaenicke@aet.TU-Cottbus.DE>]
290
291 *) Minor change to 'x509' utility. The -CAcreateserial option now uses 1
292 for the first serial number and places 2 in the serial number file. This
293 avoids problems when the root CA is created with serial number zero and
294 the first user certificate has the same issuer name and serial number
295 as the root CA.
296 [Steve Henson]
297
298 *) Fixes to X509_ATTRIBUTE utilities, change the 'req' program so it uses
299 the new code. Add documentation for this stuff.
300 [Steve Henson]
301
302 *) Changes to X509_ATTRIBUTE utilities. These have been renamed from
303 X509_*() to X509at_*() on the grounds that they don't handle X509
304 structures and behave in an analagous way to the X509v3 functions:
305 they shouldn't be called directly but wrapper functions should be used
306 instead.
307
308 So we also now have some wrapper functions that call the X509at functions
309 when passed certificate requests. (TO DO: similar things can be done with
310 PKCS#7 signed and unsigned attributes, PKCS#12 attributes and a few other
311 things. Some of these need some d2i or i2d and print functionality
312 because they handle more complex structures.)
313 [Steve Henson]
314
315 *) Add missing #ifndefs that caused missing symbols when building libssl
316 as a shared library without RSA. Use #ifndef NO_SSL2 instead of
317 NO_RSA in ssl/s2*.c.
318 [Kris Kennaway <kris@hub.freebsd.org>, modified by Ulf Möller]
319
320 *) Precautions against using the PRNG uninitialized: RAND_bytes() now
321 has a return value which indicates the quality of the random data
322 (1 = ok, 0 = not seeded). Also an error is recorded on the thread's
323 error queue. New function RAND_pseudo_bytes() generates output that is
324 guaranteed to be unique but not unpredictable. RAND_add is like
325 RAND_seed, but takes an extra argument for an entropy estimate
326 (RAND_seed always assumes full entropy).
327 [Ulf Möller]
328
329 *) Do more iterations of Rabin-Miller probable prime test (specifically,
330 3 for 1024-bit primes, 6 for 512-bit primes, 12 for 256-bit primes
331 instead of only 2 for all lengths; see BN_prime_checks_for_size definition
332 in crypto/bn/bn_prime.c for the complete table). This guarantees a
333 false-positive rate of at most 2^-80 for random input.
334 [Bodo Moeller]
335
336 *) Rewrite ssl3_read_n (ssl/s3_pkt.c) avoiding a couple of bugs.
337 [Bodo Moeller]
338
339 *) New function X509_CTX_rget_chain() (renamed to X509_CTX_get1_chain
340 in the 0.9.5 release), this returns the chain
341 from an X509_CTX structure with a dup of the stack and all
342 the X509 reference counts upped: so the stack will exist
343 after X509_CTX_cleanup() has been called. Modify pkcs12.c
344 to use this.
345
346 Also make SSL_SESSION_print() print out the verify return
347 code.
348 [Steve Henson]
349
350 *) Add manpage for the pkcs12 command. Also change the default
351 behaviour so MAC iteration counts are used unless the new
352 -nomaciter option is used. This improves file security and
353 only older versions of MSIE (4.0 for example) need it.
354 [Steve Henson]
355
356 *) Honor the no-xxx Configure options when creating .DEF files.
357 [Ulf Möller]
358
359 *) Add PKCS#10 attributes to field table: challengePassword,
360 unstructuredName and unstructuredAddress. These are taken from
361 draft PKCS#9 v2.0 but are compatible with v1.2 provided no
362 international characters are used.
363
364 More changes to X509_ATTRIBUTE code: allow the setting of types
365 based on strings. Remove the 'loc' parameter when adding
366 attributes because these will be a SET OF encoding which is sorted
367 in ASN1 order.
368 [Steve Henson]
369
370 *) Initial changes to the 'req' utility to allow request generation
371 automation. This will allow an application to just generate a template
372 file containing all the field values and have req construct the
373 request.
374
375 Initial support for X509_ATTRIBUTE handling. Stacks of these are
376 used all over the place including certificate requests and PKCS#7
377 structures. They are currently handled manually where necessary with
378 some primitive wrappers for PKCS#7. The new functions behave in a
379 manner analogous to the X509 extension functions: they allow
380 attributes to be looked up by NID and added.
381
382 Later something similar to the X509V3 code would be desirable to
383 automatically handle the encoding, decoding and printing of the
384 more complex types. The string types like challengePassword can
385 be handled by the string table functions.
386
387 Also modified the multi byte string table handling. Now there is
388 a 'global mask' which masks out certain types. The table itself
389 can use the flag STABLE_NO_MASK to ignore the mask setting: this
390 is useful when for example there is only one permissible type
391 (as in countryName) and using the mask might result in no valid
392 types at all.
393 [Steve Henson]
394
395 *) Clean up 'Finished' handling, and add functions SSL_get_finished and
396 SSL_get_peer_finished to allow applications to obtain the latest
397 Finished messages sent to the peer or expected from the peer,
398 respectively. (SSL_get_peer_finished is usually the Finished message
399 actually received from the peer, otherwise the protocol will be aborted.)
400
401 As the Finished message are message digests of the complete handshake
402 (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
403 be used for external authentication procedures when the authentication
404 provided by SSL/TLS is not desired or is not enough.
405 [Bodo Moeller]
406
407 *) Enhanced support for Alpha Linux is added. Now ./config checks if
408 the host supports BWX extension and if Compaq C is present on the
409 $PATH. Just exploiting of the BWX extension results in 20-30%
410 performance kick for some algorithms, e.g. DES and RC4 to mention
411 a couple. Compaq C in turn generates ~20% faster code for MD5 and
412 SHA1.
413 [Andy Polyakov]
414
415 *) Add support for MS "fast SGC". This is arguably a violation of the
416 SSL3/TLS protocol. Netscape SGC does two handshakes: the first with
417 weak crypto and after checking the certificate is SGC a second one
418 with strong crypto. MS SGC stops the first handshake after receiving
419 the server certificate message and sends a second client hello. Since
420 a server will typically do all the time consuming operations before
421 expecting any further messages from the client (server key exchange
422 is the most expensive) there is little difference between the two.
423
424 To get OpenSSL to support MS SGC we have to permit a second client
425 hello message after we have sent server done. In addition we have to
426 reset the MAC if we do get this second client hello.
427 [Steve Henson]
428
429 *) Add a function 'd2i_AutoPrivateKey()' this will automatically decide
430 if a DER encoded private key is RSA or DSA traditional format. Changed
431 d2i_PrivateKey_bio() to use it. This is only needed for the "traditional"
432 format DER encoded private key. Newer code should use PKCS#8 format which
433 has the key type encoded in the ASN1 structure. Added DER private key
434 support to pkcs8 application.
435 [Steve Henson]
436
437 *) SSL 3/TLS 1 servers now don't request certificates when an anonymous
438 ciphersuites has been selected (as required by the SSL 3/TLS 1
439 specifications). Exception: When SSL_VERIFY_FAIL_IF_NO_PEER_CERT
440 is set, we interpret this as a request to violate the specification
441 (the worst that can happen is a handshake failure, and 'correct'
442 behaviour would result in a handshake failure anyway).
443 [Bodo Moeller]
444
445 *) In SSL_CTX_add_session, take into account that there might be multiple
446 SSL_SESSION structures with the same session ID (e.g. when two threads
447 concurrently obtain them from an external cache).
448 The internal cache can handle only one SSL_SESSION with a given ID,
449 so if there's a conflict, we now throw out the old one to achieve
450 consistency.
451 [Bodo Moeller]
452
453 *) Add OIDs for idea and blowfish in CBC mode. This will allow both
454 to be used in PKCS#5 v2.0 and S/MIME. Also add checking to
455 some routines that use cipher OIDs: some ciphers do not have OIDs
456 defined and so they cannot be used for S/MIME and PKCS#5 v2.0 for
457 example.
458 [Steve Henson]
459
460 *) Simplify the trust setting structure and code. Now we just have
461 two sequences of OIDs for trusted and rejected settings. These will
462 typically have values the same as the extended key usage extension
463 and any application specific purposes.
464
465 The trust checking code now has a default behaviour: it will just
466 check for an object with the same NID as the passed id. Functions can
467 be provided to override either the default behaviour or the behaviour
468 for a given id. SSL client, server and email already have functions
469 in place for compatibility: they check the NID and also return "trusted"
470 if the certificate is self signed.
471 [Steve Henson]
472
473 *) Add d2i,i2d bio/fp functions for PrivateKey: these convert the
474 traditional format into an EVP_PKEY structure.
475 [Steve Henson]
476
477 *) Add a password callback function PEM_cb() which either prompts for
478 a password if usr_data is NULL or otherwise assumes it is a null
479 terminated password. Allow passwords to be passed on command line
480 environment or config files in a few more utilities.
481 [Steve Henson]
482
483 *) Add a bunch of DER and PEM functions to handle PKCS#8 format private
484 keys. Add some short names for PKCS#8 PBE algorithms and allow them
485 to be specified on the command line for the pkcs8 and pkcs12 utilities.
486 Update documentation.
487 [Steve Henson]
488
489 *) Support for ASN1 "NULL" type. This could be handled before by using
490 ASN1_TYPE but there wasn't any function that would try to read a NULL
491 and produce an error if it couldn't. For compatibility we also have
492 ASN1_NULL_new() and ASN1_NULL_free() functions but these are faked and
493 don't allocate anything because they don't need to.
494 [Steve Henson]
495
496 *) Initial support for MacOS is now provided. Examine INSTALL.MacOS
497 for details.
498 [Andy Polyakov, Roy Woods <roy@centicsystems.ca>]
499
500 *) Rebuild of the memory allocation routines used by OpenSSL code and
501 possibly others as well. The purpose is to make an interface that
502 provide hooks so anyone can build a separate set of allocation and
503 deallocation routines to be used by OpenSSL, for example memory
504 pool implementations, or something else, which was previously hard
505 since Malloc(), Realloc() and Free() were defined as macros having
506 the values malloc, realloc and free, respectively (except for Win32
507 compilations). The same is provided for memory debugging code.
508 OpenSSL already comes with functionality to find memory leaks, but
509 this gives people a chance to debug other memory problems.
510
511 With these changes, a new set of functions and macros have appeared:
512
513 CRYPTO_set_mem_debug_functions() [F]
514 CRYPTO_get_mem_debug_functions() [F]
515 CRYPTO_dbg_set_options() [F]
516 CRYPTO_dbg_get_options() [F]
517 CRYPTO_malloc_debug_init() [M]
518
519 The memory debug functions are NULL by default, unless the library
520 is compiled with CRYPTO_MDEBUG or friends is defined. If someone
521 wants to debug memory anyway, CRYPTO_malloc_debug_init() (which
522 gives the standard debugging functions that come with OpenSSL) or
523 CRYPTO_set_mem_debug_functions() (tells OpenSSL to use functions
524 provided by the library user) must be used. When the standard
525 debugging functions are used, CRYPTO_dbg_set_options can be used to
526 request additional information:
527 CRYPTO_dbg_set_options(V_CYRPTO_MDEBUG_xxx) corresponds to setting
528 the CRYPTO_MDEBUG_xxx macro when compiling the library.
529
530 Also, things like CRYPTO_set_mem_functions will always give the
531 expected result (the new set of functions is used for allocation
532 and deallocation) at all times, regardless of platform and compiler
533 options.
534
535 To finish it up, some functions that were never use in any other
536 way than through macros have a new API and new semantic:
537
538 CRYPTO_dbg_malloc()
539 CRYPTO_dbg_realloc()
540 CRYPTO_dbg_free()
541
542 All macros of value have retained their old syntax.
543 [Richard Levitte and Bodo Moeller]
544
545 *) Some S/MIME fixes. The OID for SMIMECapabilities was wrong, the
546 ordering of SMIMECapabilities wasn't in "strength order" and there
547 was a missing NULL in the AlgorithmIdentifier for the SHA1 signature
548 algorithm.
549 [Steve Henson]
550
551 *) Some ASN1 types with illegal zero length encoding (INTEGER,
552 ENUMERATED and OBJECT IDENTIFIER) choked the ASN1 routines.
553 [Frans Heymans <fheymans@isaserver.be>, modified by Steve Henson]
554
555 *) Merge in my S/MIME library for OpenSSL. This provides a simple
556 S/MIME API on top of the PKCS#7 code, a MIME parser (with enough
557 functionality to handle multipart/signed properly) and a utility
558 called 'smime' to call all this stuff. This is based on code I
559 originally wrote for Celo who have kindly allowed it to be
560 included in OpenSSL.
561 [Steve Henson]
562
563 *) Add variants des_set_key_checked and des_set_key_unchecked of
564 des_set_key (aka des_key_sched). Global variable des_check_key
565 decides which of these is called by des_set_key; this way
566 des_check_key behaves as it always did, but applications and
567 the library itself, which was buggy for des_check_key == 1,
568 have a cleaner way to pick the version they need.
569 [Bodo Moeller]
570
571 *) New function PKCS12_newpass() which changes the password of a
572 PKCS12 structure.
573 [Steve Henson]
574
575 *) Modify X509_TRUST and X509_PURPOSE so it also uses a static and
576 dynamic mix. In both cases the ids can be used as an index into the
577 table. Also modified the X509_TRUST_add() and X509_PURPOSE_add()
578 functions so they accept a list of the field values and the
579 application doesn't need to directly manipulate the X509_TRUST
580 structure.
581 [Steve Henson]
582
583 *) Modify the ASN1_STRING_TABLE stuff so it also uses bsearch and doesn't
584 need initialising.
585 [Steve Henson]
586
587 *) Modify the way the V3 extension code looks up extensions. This now
588 works in a similar way to the object code: we have some "standard"
589 extensions in a static table which is searched with OBJ_bsearch()
590 and the application can add dynamic ones if needed. The file
591 crypto/x509v3/ext_dat.h now has the info: this file needs to be
592 updated whenever a new extension is added to the core code and kept
593 in ext_nid order. There is a simple program 'tabtest.c' which checks
594 this. New extensions are not added too often so this file can readily
595 be maintained manually.
596
597 There are two big advantages in doing things this way. The extensions
598 can be looked up immediately and no longer need to be "added" using
599 X509V3_add_standard_extensions(): this function now does nothing.
600 [Side note: I get *lots* of email saying the extension code doesn't
601 work because people forget to call this function]
602 Also no dynamic allocation is done unless new extensions are added:
603 so if we don't add custom extensions there is no need to call
604 X509V3_EXT_cleanup().
605 [Steve Henson]
606
607 *) Modify enc utility's salting as follows: make salting the default. Add a
608 magic header, so unsalted files fail gracefully instead of just decrypting
609 to garbage. This is because not salting is a big security hole, so people
610 should be discouraged from doing it.
611 [Ben Laurie]
612
613 *) Fixes and enhancements to the 'x509' utility. It allowed a message
614 digest to be passed on the command line but it only used this
615 parameter when signing a certificate. Modified so all relevant
616 operations are affected by the digest parameter including the
617 -fingerprint and -x509toreq options. Also -x509toreq choked if a
618 DSA key was used because it didn't fix the digest.
619 [Steve Henson]
620
621 *) Initial certificate chain verify code. Currently tests the untrusted
622 certificates for consistency with the verify purpose (which is set
623 when the X509_STORE_CTX structure is set up) and checks the pathlength.
624
625 There is a NO_CHAIN_VERIFY compilation option to keep the old behaviour:
626 this is because it will reject chains with invalid extensions whereas
627 every previous version of OpenSSL and SSLeay made no checks at all.
628
629 Trust code: checks the root CA for the relevant trust settings. Trust
630 settings have an initial value consistent with the verify purpose: e.g.
631 if the verify purpose is for SSL client use it expects the CA to be
632 trusted for SSL client use. However the default value can be changed to
633 permit custom trust settings: one example of this would be to only trust
634 certificates from a specific "secure" set of CAs.
635
636 Also added X509_STORE_CTX_new() and X509_STORE_CTX_free() functions
637 which should be used for version portability: especially since the
638 verify structure is likely to change more often now.
639
640 SSL integration. Add purpose and trust to SSL_CTX and SSL and functions
641 to set them. If not set then assume SSL clients will verify SSL servers
642 and vice versa.
643
644 Two new options to the verify program: -untrusted allows a set of
645 untrusted certificates to be passed in and -purpose which sets the
646 intended purpose of the certificate. If a purpose is set then the
647 new chain verify code is used to check extension consistency.
648 [Steve Henson]
649
650 *) Support for the authority information access extension.
651 [Steve Henson]
652
653 *) Modify RSA and DSA PEM read routines to transparently handle
654 PKCS#8 format private keys. New *_PUBKEY_* functions that handle
655 public keys in a format compatible with certificate
656 SubjectPublicKeyInfo structures. Unfortunately there were already
657 functions called *_PublicKey_* which used various odd formats so
658 these are retained for compatibility: however the DSA variants were
659 never in a public release so they have been deleted. Changed dsa/rsa
660 utilities to handle the new format: note no releases ever handled public
661 keys so we should be OK.
662
663 The primary motivation for this change is to avoid the same fiasco
664 that dogs private keys: there are several incompatible private key
665 formats some of which are standard and some OpenSSL specific and
666 require various evil hacks to allow partial transparent handling and
667 even then it doesn't work with DER formats. Given the option anything
668 other than PKCS#8 should be dumped: but the other formats have to
669 stay in the name of compatibility.
670
671 With public keys and the benefit of hindsight one standard format
672 is used which works with EVP_PKEY, RSA or DSA structures: though
673 it clearly returns an error if you try to read the wrong kind of key.
674
675 Added a -pubkey option to the 'x509' utility to output the public key.
676 Also rename the EVP_PKEY_get_*() to EVP_PKEY_rget_*()
677 (renamed to EVP_PKEY_get1_*() in the OpenSSL 0.9.5 release) and add
678 EVP_PKEY_rset_*() functions (renamed to EVP_PKEY_set1_*())
679 that do the same as the EVP_PKEY_assign_*() except they up the
680 reference count of the added key (they don't "swallow" the
681 supplied key).
682 [Steve Henson]
683
684 *) Fixes to crypto/x509/by_file.c the code to read in certificates and
685 CRLs would fail if the file contained no certificates or no CRLs:
686 added a new function to read in both types and return the number
687 read: this means that if none are read it will be an error. The
688 DER versions of the certificate and CRL reader would always fail
689 because it isn't possible to mix certificates and CRLs in DER format
690 without choking one or the other routine. Changed this to just read
691 a certificate: this is the best we can do. Also modified the code
692 in apps/verify.c to take notice of return codes: it was previously
693 attempting to read in certificates from NULL pointers and ignoring
694 any errors: this is one reason why the cert and CRL reader seemed
695 to work. It doesn't check return codes from the default certificate
696 routines: these may well fail if the certificates aren't installed.
697 [Steve Henson]
698
699 *) Code to support otherName option in GeneralName.
700 [Steve Henson]
701
702 *) First update to verify code. Change the verify utility
703 so it warns if it is passed a self signed certificate:
704 for consistency with the normal behaviour. X509_verify
705 has been modified to it will now verify a self signed
706 certificate if *exactly* the same certificate appears
707 in the store: it was previously impossible to trust a
708 single self signed certificate. This means that:
709 openssl verify ss.pem
710 now gives a warning about a self signed certificate but
711 openssl verify -CAfile ss.pem ss.pem
712 is OK.
713 [Steve Henson]
714
715 *) For servers, store verify_result in SSL_SESSION data structure
716 (and add it to external session representation).
717 This is needed when client certificate verifications fails,
718 but an application-provided verification callback (set by
719 SSL_CTX_set_cert_verify_callback) allows accepting the session
720 anyway (i.e. leaves x509_store_ctx->error != X509_V_OK
721 but returns 1): When the session is reused, we have to set
722 ssl->verify_result to the appropriate error code to avoid
723 security holes.
724 [Bodo Moeller, problem pointed out by Lutz Jaenicke]
725
726 *) Fix a bug in the new PKCS#7 code: it didn't consider the
727 case in PKCS7_dataInit() where the signed PKCS7 structure
728 didn't contain any existing data because it was being created.
729 [Po-Cheng Chen <pocheng@nst.com.tw>, slightly modified by Steve Henson]
730
731 *) Add a salt to the key derivation routines in enc.c. This
732 forms the first 8 bytes of the encrypted file. Also add a
733 -S option to allow a salt to be input on the command line.
734 [Steve Henson]
735
736 *) New function X509_cmp(). Oddly enough there wasn't a function
737 to compare two certificates. We do this by working out the SHA1
738 hash and comparing that. X509_cmp() will be needed by the trust
739 code.
740 [Steve Henson]
741
742 *) SSL_get1_session() is like SSL_get_session(), but increments
743 the reference count in the SSL_SESSION returned.
744 [Geoff Thorpe <geoff@eu.c2.net>]
745
746 *) Fix for 'req': it was adding a null to request attributes.
747 Also change the X509_LOOKUP and X509_INFO code to handle
748 certificate auxiliary information.
749 [Steve Henson]
750
751 *) Add support for 40 and 64 bit RC2 and RC4 algorithms: document
752 the 'enc' command.
753 [Steve Henson]
754
755 *) Add the possibility to add extra information to the memory leak
756 detecting output, to form tracebacks, showing from where each
757 allocation was originated: CRYPTO_push_info("constant string") adds
758 the string plus current file name and line number to a per-thread
759 stack, CRYPTO_pop_info() does the obvious, CRYPTO_remove_all_info()
760 is like calling CYRPTO_pop_info() until the stack is empty.
761 Also updated memory leak detection code to be multi-thread-safe.
762 [Richard Levitte]
763
764 *) Add options -text and -noout to pkcs7 utility and delete the
765 encryption options which never did anything. Update docs.
766 [Steve Henson]
767
768 *) Add options to some of the utilities to allow the pass phrase
769 to be included on either the command line (not recommended on
770 OSes like Unix) or read from the environment. Update the
771 manpages and fix a few bugs.
772 [Steve Henson]
773
774 *) Add a few manpages for some of the openssl commands.
775 [Steve Henson]
776
777 *) Fix the -revoke option in ca. It was freeing up memory twice,
778 leaking and not finding already revoked certificates.
779 [Steve Henson]
780
781 *) Extensive changes to support certificate auxiliary information.
782 This involves the use of X509_CERT_AUX structure and X509_AUX
783 functions. An X509_AUX function such as PEM_read_X509_AUX()
784 can still read in a certificate file in the usual way but it
785 will also read in any additional "auxiliary information". By
786 doing things this way a fair degree of compatibility can be
787 retained: existing certificates can have this information added
788 using the new 'x509' options.
789
790 Current auxiliary information includes an "alias" and some trust
791 settings. The trust settings will ultimately be used in enhanced
792 certificate chain verification routines: currently a certificate
793 can only be trusted if it is self signed and then it is trusted
794 for all purposes.
795 [Steve Henson]
796
797 *) Fix assembler for Alpha (tested only on DEC OSF not Linux or *BSD).
798 The problem was that one of the replacement routines had not been working
799 since SSLeay releases. For now the offending routine has been replaced
800 with non-optimised assembler. Even so, this now gives around 95%
801 performance improvement for 1024 bit RSA signs.
802 [Mark Cox]
803
804 *) Hack to fix PKCS#7 decryption when used with some unorthodox RC2
805 handling. Most clients have the effective key size in bits equal to
806 the key length in bits: so a 40 bit RC2 key uses a 40 bit (5 byte) key.
807 A few however don't do this and instead use the size of the decrypted key
808 to determine the RC2 key length and the AlgorithmIdentifier to determine
809 the effective key length. In this case the effective key length can still
810 be 40 bits but the key length can be 168 bits for example. This is fixed
811 by manually forcing an RC2 key into the EVP_PKEY structure because the
812 EVP code can't currently handle unusual RC2 key sizes: it always assumes
813 the key length and effective key length are equal.
814 [Steve Henson]
815
816 *) Add a bunch of functions that should simplify the creation of
817 X509_NAME structures. Now you should be able to do:
818 X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC, "Steve", -1, -1, 0);
819 and have it automatically work out the correct field type and fill in
820 the structures. The more adventurous can try:
821 X509_NAME_add_entry_by_txt(nm, field, MBSTRING_UTF8, str, -1, -1, 0);
822 and it will (hopefully) work out the correct multibyte encoding.
823 [Steve Henson]
824
825 *) Change the 'req' utility to use the new field handling and multibyte
826 copy routines. Before the DN field creation was handled in an ad hoc
827 way in req, ca, and x509 which was rather broken and didn't support
828 BMPStrings or UTF8Strings. Since some software doesn't implement
829 BMPStrings or UTF8Strings yet, they can be enabled using the config file
830 using the dirstring_type option. See the new comment in the default
831 openssl.cnf for more info.
832 [Steve Henson]
833
834 *) Make crypto/rand/md_rand.c more robust:
835 - Assure unique random numbers after fork().
836 - Make sure that concurrent threads access the global counter and
837 md serializably so that we never lose entropy in them
838 or use exactly the same state in multiple threads.
839 Access to the large state is not always serializable because
840 the additional locking could be a performance killer, and
841 md should be large enough anyway.
842 [Bodo Moeller]
843
844 *) New file apps/app_rand.c with commonly needed functionality
845 for handling the random seed file.
846
847 Use the random seed file in some applications that previously did not:
848 ca,
849 dsaparam -genkey (which also ignored its '-rand' option),
850 s_client,
851 s_server,
852 x509 (when signing).
853 Except on systems with /dev/urandom, it is crucial to have a random
854 seed file at least for key creation, DSA signing, and for DH exchanges;
855 for RSA signatures we could do without one.
856
857 gendh and gendsa (unlike genrsa) used to read only the first byte
858 of each file listed in the '-rand' option. The function as previously
859 found in genrsa is now in app_rand.c and is used by all programs
860 that support '-rand'.
861 [Bodo Moeller]
862
863 *) In RAND_write_file, use mode 0600 for creating files;
864 don't just chmod when it may be too late.
865 [Bodo Moeller]
866
867 *) Report an error from X509_STORE_load_locations
868 when X509_LOOKUP_load_file or X509_LOOKUP_add_dir failed.
869 [Bill Perry]
870
871 *) New function ASN1_mbstring_copy() this copies a string in either
872 ASCII, Unicode, Universal (4 bytes per character) or UTF8 format
873 into an ASN1_STRING type. A mask of permissible types is passed
874 and it chooses the "minimal" type to use or an error if not type
875 is suitable.
876 [Steve Henson]
877
878 *) Add function equivalents to the various macros in asn1.h. The old
879 macros are retained with an M_ prefix. Code inside the library can
880 use the M_ macros. External code (including the openssl utility)
881 should *NOT* in order to be "shared library friendly".
882 [Steve Henson]
883
884 *) Add various functions that can check a certificate's extensions
885 to see if it usable for various purposes such as SSL client,
886 server or S/MIME and CAs of these types. This is currently
887 VERY EXPERIMENTAL but will ultimately be used for certificate chain
888 verification. Also added a -purpose flag to x509 utility to
889 print out all the purposes.
890 [Steve Henson]
891
892 *) Add a CRYPTO_EX_DATA to X509 certificate structure and associated
893 functions.
894 [Steve Henson]
895
896 *) New X509V3_{X509,CRL,REVOKED}_get_d2i() functions. These will search
897 for, obtain and decode and extension and obtain its critical flag.
898 This allows all the necessary extension code to be handled in a
899 single function call.
900 [Steve Henson]
901
902 *) RC4 tune-up featuring 30-40% performance improvement on most RISC
903 platforms. See crypto/rc4/rc4_enc.c for further details.
904 [Andy Polyakov]
905
906 *) New -noout option to asn1parse. This causes no output to be produced
907 its main use is when combined with -strparse and -out to extract data
908 from a file (which may not be in ASN.1 format).
909 [Steve Henson]
910
911 *) Fix for pkcs12 program. It was hashing an invalid certificate pointer
912 when producing the local key id.
913 [Richard Levitte <levitte@stacken.kth.se>]
914
915 *) New option -dhparam in s_server. This allows a DH parameter file to be
916 stated explicitly. If it is not stated then it tries the first server
917 certificate file. The previous behaviour hard coded the filename
918 "server.pem".
919 [Steve Henson]
920
921 *) Add -pubin and -pubout options to the rsa and dsa commands. These allow
922 a public key to be input or output. For example:
923 openssl rsa -in key.pem -pubout -out pubkey.pem
924 Also added necessary DSA public key functions to handle this.
925 [Steve Henson]
926
927 *) Fix so PKCS7_dataVerify() doesn't crash if no certificates are contained
928 in the message. This was handled by allowing
929 X509_find_by_issuer_and_serial() to tolerate a NULL passed to it.
930 [Steve Henson, reported by Sampo Kellomaki <sampo@mail.neuronio.pt>]
931
932 *) Fix for bug in d2i_ASN1_bytes(): other ASN1 functions add an extra null
933 to the end of the strings whereas this didn't. This would cause problems
934 if strings read with d2i_ASN1_bytes() were later modified.
935 [Steve Henson, reported by Arne Ansper <arne@ats.cyber.ee>]
936
937 *) Fix for base64 decode bug. When a base64 bio reads only one line of
938 data and it contains EOF it will end up returning an error. This is
939 caused by input 46 bytes long. The cause is due to the way base64
940 BIOs find the start of base64 encoded data. They do this by trying a
941 trial decode on each line until they find one that works. When they
942 do a flag is set and it starts again knowing it can pass all the
943 data directly through the decoder. Unfortunately it doesn't reset
944 the context it uses. This means that if EOF is reached an attempt
945 is made to pass two EOFs through the context and this causes the
946 resulting error. This can also cause other problems as well. As is
947 usual with these problems it takes *ages* to find and the fix is
948 trivial: move one line.
949 [Steve Henson, reported by ian@uns.ns.ac.yu (Ivan Nejgebauer) ]
950
951 *) Ugly workaround to get s_client and s_server working under Windows. The
952 old code wouldn't work because it needed to select() on sockets and the
953 tty (for keypresses and to see if data could be written). Win32 only
954 supports select() on sockets so we select() with a 1s timeout on the
955 sockets and then see if any characters are waiting to be read, if none
956 are present then we retry, we also assume we can always write data to
957 the tty. This isn't nice because the code then blocks until we've
958 received a complete line of data and it is effectively polling the
959 keyboard at 1s intervals: however it's quite a bit better than not
960 working at all :-) A dedicated Windows application might handle this
961 with an event loop for example.
962 [Steve Henson]
963
964 *) Enhance RSA_METHOD structure. Now there are two extra methods, rsa_sign
965 and rsa_verify. When the RSA_FLAGS_SIGN_VER option is set these functions
966 will be called when RSA_sign() and RSA_verify() are used. This is useful
967 if rsa_pub_dec() and rsa_priv_enc() equivalents are not available.
968 For this to work properly RSA_public_decrypt() and RSA_private_encrypt()
969 should *not* be used: RSA_sign() and RSA_verify() must be used instead.
970 This necessitated the support of an extra signature type NID_md5_sha1
971 for SSL signatures and modifications to the SSL library to use it instead
972 of calling RSA_public_decrypt() and RSA_private_encrypt().
973 [Steve Henson]
974
975 *) Add new -verify -CAfile and -CApath options to the crl program, these
976 will lookup a CRL issuers certificate and verify the signature in a
977 similar way to the verify program. Tidy up the crl program so it
978 no longer accesses structures directly. Make the ASN1 CRL parsing a bit
979 less strict. It will now permit CRL extensions even if it is not
980 a V2 CRL: this will allow it to tolerate some broken CRLs.
981 [Steve Henson]
982
983 *) Initialize all non-automatic variables each time one of the openssl
984 sub-programs is started (this is necessary as they may be started
985 multiple times from the "OpenSSL>" prompt).
986 [Lennart Bang, Bodo Moeller]
987
988 *) Preliminary compilation option RSA_NULL which disables RSA crypto without
989 removing all other RSA functionality (this is what NO_RSA does). This
990 is so (for example) those in the US can disable those operations covered
991 by the RSA patent while allowing storage and parsing of RSA keys and RSA
992 key generation.
993 [Steve Henson]
994
995 *) Non-copying interface to BIO pairs.
996 (still largely untested)
997 [Bodo Moeller]
998
999 *) New function ANS1_tag2str() to convert an ASN1 tag to a descriptive
1000 ASCII string. This was handled independently in various places before.
1001 [Steve Henson]
1002
1003 *) New functions UTF8_getc() and UTF8_putc() that parse and generate
1004 UTF8 strings a character at a time.
1005 [Steve Henson]
1006
1007 *) Use client_version from client hello to select the protocol
1008 (s23_srvr.c) and for RSA client key exchange verification
1009 (s3_srvr.c), as required by the SSL 3.0/TLS 1.0 specifications.
1010 [Bodo Moeller]
1011
1012 *) Add various utility functions to handle SPKACs, these were previously
1013 handled by poking round in the structure internals. Added new function
1014 NETSCAPE_SPKI_print() to print out SPKAC and a new utility 'spkac' to
1015 print, verify and generate SPKACs. Based on an original idea from
1016 Massimiliano Pala <madwolf@comune.modena.it> but extensively modified.
1017 [Steve Henson]
1018
1019 *) RIPEMD160 is operational on all platforms and is back in 'make test'.
1020 [Andy Polyakov]
1021
1022 *) Allow the config file extension section to be overwritten on the
1023 command line. Based on an original idea from Massimiliano Pala
1024 <madwolf@comune.modena.it>. The new option is called -extensions
1025 and can be applied to ca, req and x509. Also -reqexts to override
1026 the request extensions in req and -crlexts to override the crl extensions
1027 in ca.
1028 [Steve Henson]
1029
1030 *) Add new feature to the SPKAC handling in ca. Now you can include
1031 the same field multiple times by preceding it by "XXXX." for example:
1032 1.OU="Unit name 1"
1033 2.OU="Unit name 2"
1034 this is the same syntax as used in the req config file.
1035 [Steve Henson]
1036
1037 *) Allow certificate extensions to be added to certificate requests. These
1038 are specified in a 'req_extensions' option of the req section of the
1039 config file. They can be printed out with the -text option to req but
1040 are otherwise ignored at present.
1041 [Steve Henson]
1042
1043 *) Fix a horrible bug in enc_read() in crypto/evp/bio_enc.c: if the first
1044 data read consists of only the final block it would not decrypted because
1045 EVP_CipherUpdate() would correctly report zero bytes had been decrypted.
1046 A misplaced 'break' also meant the decrypted final block might not be
1047 copied until the next read.
1048 [Steve Henson]
1049
1050 *) Initial support for DH_METHOD. Again based on RSA_METHOD. Also added
1051 a few extra parameters to the DH structure: these will be useful if
1052 for example we want the value of 'q' or implement X9.42 DH.
1053 [Steve Henson]
1054
1055 *) Initial support for DSA_METHOD. This is based on the RSA_METHOD and
1056 provides hooks that allow the default DSA functions or functions on a
1057 "per key" basis to be replaced. This allows hardware acceleration and
1058 hardware key storage to be handled without major modification to the
1059 library. Also added low level modexp hooks and CRYPTO_EX structure and
1060 associated functions.
1061 [Steve Henson]
1062
1063 *) Add a new flag to memory BIOs, BIO_FLAG_MEM_RDONLY. This marks the BIO
1064 as "read only": it can't be written to and the buffer it points to will
1065 not be freed. Reading from a read only BIO is much more efficient than
1066 a normal memory BIO. This was added because there are several times when
1067 an area of memory needs to be read from a BIO. The previous method was
1068 to create a memory BIO and write the data to it, this results in two
1069 copies of the data and an O(n^2) reading algorithm. There is a new
1070 function BIO_new_mem_buf() which creates a read only memory BIO from
1071 an area of memory. Also modified the PKCS#7 routines to use read only
1072 memory BIOs.
1073 [Steve Henson]
1074
1075 *) Bugfix: ssl23_get_client_hello did not work properly when called in
1076 state SSL23_ST_SR_CLNT_HELLO_B, i.e. when the first 7 bytes of
1077 a SSLv2-compatible client hello for SSLv3 or TLSv1 could be read,
1078 but a retry condition occured while trying to read the rest.
1079 [Bodo Moeller]
1080
1081 *) The PKCS7_ENC_CONTENT_new() function was setting the content type as
1082 NID_pkcs7_encrypted by default: this was wrong since this should almost
1083 always be NID_pkcs7_data. Also modified the PKCS7_set_type() to handle
1084 the encrypted data type: this is a more sensible place to put it and it
1085 allows the PKCS#12 code to be tidied up that duplicated this
1086 functionality.
1087 [Steve Henson]
1088
1089 *) Changed obj_dat.pl script so it takes its input and output files on
1090 the command line. This should avoid shell escape redirection problems
1091 under Win32.
1092 [Steve Henson]
1093
1094 *) Initial support for certificate extension requests, these are included
1095 in things like Xenroll certificate requests. Included functions to allow
1096 extensions to be obtained and added.
1097 [Steve Henson]
1098
1099 *) -crlf option to s_client and s_server for sending newlines as
1100 CRLF (as required by many protocols).
1101 [Bodo Moeller]
1102
5 Changes between 0.9.3a and 0.9.4 [09 Aug 1999] 1103 Changes between 0.9.3a and 0.9.4 [09 Aug 1999]
6 1104
7 *) Install libRSAglue.a when OpenSSL is built with RSAref. 1105 *) Install libRSAglue.a when OpenSSL is built with RSAref.
@@ -49,9 +1147,9 @@
49 method only got called if p,q,dmp1,dmq1,iqmp components were present, 1147 method only got called if p,q,dmp1,dmq1,iqmp components were present,
50 otherwise bn_mod_exp was called. In the case of hardware keys for example 1148 otherwise bn_mod_exp was called. In the case of hardware keys for example
51 no private key components need be present and it might store extra data 1149 no private key components need be present and it might store extra data
52 in the RSA structure, which cannot be accessed from bn_mod_exp. By setting 1150 in the RSA structure, which cannot be accessed from bn_mod_exp.
53 RSA_FLAG_EXT_PKEY rsa_mod_exp will always be called for private key 1151 By setting RSA_FLAG_EXT_PKEY rsa_mod_exp will always be called for
54 operations. 1152 private key operations.
55 [Steve Henson] 1153 [Steve Henson]
56 1154
57 *) Added support for SPARC Linux. 1155 *) Added support for SPARC Linux.
@@ -65,7 +1163,7 @@
65 The PEM[_ASN1]_{read,write}... functions and macros now take an 1163 The PEM[_ASN1]_{read,write}... functions and macros now take an
66 additional void * argument, which is just handed through whenever 1164 additional void * argument, which is just handed through whenever
67 the password callback is called. 1165 the password callback is called.
68 [Damien Miller <dmiller@ilogic.com.au>, with tiny changes by Bodo Moeller] 1166 [Damien Miller <dmiller@ilogic.com.au>; tiny changes by Bodo Moeller]
69 1167
70 New function SSL_CTX_set_default_passwd_cb_userdata. 1168 New function SSL_CTX_set_default_passwd_cb_userdata.
71 1169
diff --git a/src/lib/libssl/src/Configure b/src/lib/libssl/src/Configure
index fdad0c238c..8c795f9799 100644
--- a/src/lib/libssl/src/Configure
+++ b/src/lib/libssl/src/Configure
@@ -51,6 +51,10 @@ my $usage="Usage: Configure [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [rsaref] [no
51# RC4_LONG use 'long' instead of 'int' for RC4_INT in crypto/rc4/rc4.h 51# RC4_LONG use 'long' instead of 'int' for RC4_INT in crypto/rc4/rc4.h
52# RC4_INDEX define RC4_INDEX in crypto/rc4/rc4_locl.h. This turns on 52# RC4_INDEX define RC4_INDEX in crypto/rc4/rc4_locl.h. This turns on
53# array lookups instead of pointer use. 53# array lookups instead of pointer use.
54# RC4_CHUNK enables code that handles data aligned at long (natural CPU
55# word) boundary.
56# RC4_CHUNK_LL enables code that handles data aligned at long long boundary
57# (intended for 64-bit CPUs running 32-bit OS).
54# BF_PTR use 'pointer arithmatic' for Blowfish (unsafe on Alpha). 58# BF_PTR use 'pointer arithmatic' for Blowfish (unsafe on Alpha).
55# BF_PTR2 intel specific version (generic version is more efficient). 59# BF_PTR2 intel specific version (generic version is more efficient).
56# MD5_ASM use some extra md5 assember, 60# MD5_ASM use some extra md5 assember,
@@ -82,8 +86,8 @@ my $x86_bsdi_asm="asm/bn86bsdi.o asm/co86bsdi.o:asm/dx86bsdi.o asm/yx86bsdi.o:as
82# -DB_ENDIAN slows things down on a sparc for md5, but helps sha1. 86# -DB_ENDIAN slows things down on a sparc for md5, but helps sha1.
83# So the md5_locl.h file has an undef B_ENDIAN if sun is defined 87# So the md5_locl.h file has an undef B_ENDIAN if sun is defined
84 88
85#config-string CC : CFLAGS : LDFLAGS : special header file mods:bn_asm \ 89#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
86# des_asm:bf_asm 90
87my %table=( 91my %table=(
88#"b", "$tcc:$tflags::$tlib:$bits1:$tbn_mul::", 92#"b", "$tcc:$tflags::$tlib:$bits1:$tbn_mul::",
89#"bl-4c-2c", "$tcc:$tflags::$tlib:${bits1}BN_LLONG RC4_CHAR MD2_CHAR:$tbn_mul::", 93#"bl-4c-2c", "$tcc:$tflags::$tlib:${bits1}BN_LLONG RC4_CHAR MD2_CHAR:$tbn_mul::",
@@ -92,80 +96,123 @@ my %table=(
92 96
93# Our development configs 97# Our development configs
94"purify", "purify gcc:-g -DPURIFY -Wall::(unknown):-lsocket -lnsl::::", 98"purify", "purify gcc:-g -DPURIFY -Wall::(unknown):-lsocket -lnsl::::",
95"debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown):-lefence::::", 99"debug", "gcc:-DBN_DEBUG -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown):-lefence::::",
96"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -DPEDANTIC -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::", 100"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::",
97"debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::", 101"debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::",
98"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown):::::", 102"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown):::::",
99"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", 103"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
100"debug-bodo", "gcc:-DBIO_PAIR_DEBUG -DL_ENDIAN -DREF_CHECK -DCRYPTO_MDEBUG_ALL -g -m486 -Wall::-D_REENTRANT::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", 104"debug-bodo", "gcc:-DBIO_PAIR_DEBUG -DL_ENDIAN -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -m486 -pedantic -Wshadow -Wall::-D_REENTRANT::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
105"debug-ulf", "gcc:-DL_ENDIAN -DREF_CHECK -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",
106"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -O2 -m486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::$x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
107"debug-levitte-linux-elf","gcc:-DRL_DEBUG -DREF_CHECK -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:::",
101"dist", "cc:-O::(unknown):::::", 108"dist", "cc:-O::(unknown):::::",
102 109
103# Basic configs that should work on any box 110# Basic configs that should work on any (32 and less bit) box
104"gcc", "gcc:-O3::(unknown)::BN_LLONG:::", 111"gcc", "gcc:-O3::(unknown)::BN_LLONG:::",
105"cc", "cc:-O::(unknown):::::", 112"cc", "cc:-O::(unknown):::::",
106 113
107#### Solaris x86 setups 114#### Solaris x86 setups
108"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_sol_asm", 115# -DNO_INLINE_ASM switches off inline assembler. We have to do it
116# here because whenever GNU C instantiates an assembler template it
117# surrounds it with #APP #NO_APP comment pair which (at least Solaris
118# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic"
119# error message.
120"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DNO_INLINE_ASM::-D_REENTRANT:-lsocket -lnsl:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_sol_asm",
109 121
110#### SPARC Solaris with GNU C setups 122#### SPARC Solaris with GNU C setups
111"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:::", 123"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
112"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8.o::", 124"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o::",
113"solaris-sparcv9-gcc","gcc:-mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:", 125"solaris-sparcv9-gcc","gcc:-mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:",
114# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8 126# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8
115# but keep the assembler modules. 127# but keep the assembler modules.
116"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o:", 128"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o:",
117#### 129####
118"debug-solaris-sparcv8-gcc","gcc:-DREF_CHECK -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:::", 130"debug-solaris-sparcv8-gcc","gcc:-DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o::",
119"debug-solaris-sparcv9-gcc","gcc:-DREF_CHECK -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus.o::", 131"debug-solaris-sparcv9-gcc","gcc:-DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o::",
120 132
121#### SPARC Solaris with Sun C setups 133#### SPARC Solaris with Sun C setups
122# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests 134# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests
123"solaris-sparc-sc3","cc:-fast -O -Xa -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_PTR DES_UNROLL BF_PTR:::", 135"solaris-sparc-sc3","cc:-fast -O -Xa -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR:::",
124# SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2. 136# SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2.
125# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8 137# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8
126# SC5.0 note: Compiler common patch 107357-01 or later is required! 138# SC5.0 note: Compiler common patch 107357-01 or later is required!
127"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:::", 139"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:::",
128"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o::", 140"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o::",
129"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:", 141"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:",
130"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:SIXTY_FOUR_BIT_LONG RC4_CHAR DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:", 142"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:",
143####
144"debug-solaris-sparcv8-cc","cc:-DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o::",
145"debug-solaris-sparcv9-cc","cc:-DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:",
131 146
132#### SPARC Linux setups 147#### SPARC Linux setups
133"linux-sparcv7","gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG RC4_CHAR DES_UNROLL BF_PTR::", 148"linux-sparcv7","gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::",
134# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently 149# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently
135# assisted with debugging of following two configs. 150# assisted with debugging of following two configs.
136"linux-sparcv8","gcc:-mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8.o::::", 151"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::::",
137# it's a real mess with -mcpu=ultrasparc option under Linux, but 152# it's a real mess with -mcpu=ultrasparc option under Linux, but
138# -Wa,-Av8plus should do the trick no matter what. 153# -Wa,-Av8plus should do the trick no matter what.
139"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DULTRASPARC -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:", 154"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:",
140# !!!Folowing can't be even tested yet!!! 155# !!!Folowing can't be even tested yet!!!
141# We have to wait till 64-bit glibc for SPARC is operational!!! 156# We have to wait till 64-bit glibc for SPARC is operational!!!
142#"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 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:", 157#"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:",
143 158
144# Sunos configs, assuming sparc for the gcc one. 159# Sunos configs, assuming sparc for the gcc one.
145##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown)::DES_UNROLL:::", 160##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown)::DES_UNROLL:::",
146"sunos-gcc","gcc:-O3 -mv8::(unknown)::BN_LLONG RC4_CHAR DES_UNROLL DES_PTR DES_RISC1:::", 161"sunos-gcc","gcc:-O3 -mv8::(unknown)::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1:::",
147 162
148#### IRIX 5.x configs 163#### IRIX 5.x configs
149# -mips2 flag is added by ./config when appropriate. 164# -mips2 flag is added by ./config when appropriate.
150"irix-gcc","gcc:-O3 -DTERMIOS -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR:::", 165"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:::",
151"irix-cc", "cc:-O2 -use_readonly_const -DTERMIOS -DB_ENDIAN::(unknown)::BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR:::", 166"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:::",
152#### IRIX 6.x configs 167#### IRIX 6.x configs
153# Only N32 and N64 ABIs are supported. If you need O32 ABI build, invoke 168# Only N32 and N64 ABIs are supported. If you need O32 ABI build, invoke
154# './Configure irix-[g]cc' manually. 169# './Configure irix-[g]cc' manually.
155# -mips4 flag is added by ./config when appropriate. 170# -mips4 flag is added by ./config when appropriate.
156"irix-mips3-gcc","gcc:-mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN::(unknown)::MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:asm/mips3.o::", 171"irix-mips3-gcc","gcc:-mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::(unknown)::MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:asm/mips3.o::",
157"irix-mips3-cc", "cc:-n32 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN::(unknown)::DES_PTR DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:asm/mips3.o::", 172"irix-mips3-cc", "cc:-n32 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::(unknown)::DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:asm/mips3.o::",
158# N64 ABI builds. 173# N64 ABI builds.
159"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN::(unknown)::DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:asm/mips3.o::", 174"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::(unknown)::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:asm/mips3.o::",
160"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN::(unknown)::DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:asm/mips3.o::", 175"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::(unknown)::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:asm/mips3.o::",
176
177#### Unified HP-UX ANSI C configs.
178# Special notes:
179# - Originally we were optimizing at +O4 level. It should be noted
180# that the only difference between +O3 and +O4 is global inter-
181# procedural analysis. As it has to be performed during the link
182# stage the compiler leaves behind certain pseudo-code in lib*.a
183# which might be release or even patch level specific. Generating
184# the machine code for and analyzing the *whole* program appears
185# to be *extremely* memory demanding while the performance gain is
186# actually questionable. The situation is intensified by the default
187# HP-UX data set size limit (infamous 'maxdsiz' tunable) of 64MB
188# which is way too low for +O4. In other words, doesn't +O3 make
189# more sense?
190# - Keep in mind that the HP compiler by default generates code
191# suitable for execution on the host you're currently compiling at.
192# If the toolkit is ment to be used on various PA-RISC processors
193# consider './config +Dportable'.
194# - +DD64 is chosen in favour of +DA2.0W because it's ment to be
195# compatible with *future* releases.
196# - If you run ./Configure hpux-parisc-[g]cc manually don't forget to
197# pass -D_REENTRANT on HP-UX 10 and later.
198# - -DMD32_XARRAY triggers workaround for compiler bug we ran into in
199# 32-bit message digests. (For the moment of this writing) HP C
200# doesn't seem to "digest" too many local variables (they make "him"
201# chew forever:-). For more details look-up MD32_XARRAY comment in
202# crypto/sha/sha_lcl.h.
203# <appro@fy.chalmers.se>
204#
205"hpux-parisc-cc","cc:-Ae +O3 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
206"hpux-parisc-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
207"hpux64-parisc-cc","cc:-Ae +DD64 +O3 +ESlit -z -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:::",
161 208
162# HPUX 9.X config. 209# HPUX 9.X config.
163# Don't use the bundled cc. It is broken. Use HP ANSI C if possible, or 210# Don't use the bundled cc. It is broken. Use HP ANSI C if possible, or
164# egcs. gcc 2.8.1 is also broken. 211# egcs. gcc 2.8.1 is also broken.
165 212
166"hpux-cc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O4 -z::(unknown)::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::", 213"hpux-cc", "cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z::(unknown)::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
167# If hpux-cc fails (e.g. during "make test"), try the next one; otherwise, 214# If hpux-cc fails (e.g. during "make test"), try the next one; otherwise,
168# please report your OS and compiler version to the bugs@openssl.org 215# please report your OS and compiler version to the openssl-bugs@openssl.org
169# mailing list. 216# mailing list.
170"hpux-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::(unknown)::DES_PTR DES_UNROLL DES_RISC1:::", 217"hpux-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::(unknown)::DES_PTR DES_UNROLL DES_RISC1:::",
171 218
@@ -174,7 +221,7 @@ my %table=(
174"hpux-brokengcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown)::DES_PTR DES_UNROLL DES_RISC1:::", 221"hpux-brokengcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown)::DES_PTR DES_UNROLL DES_RISC1:::",
175 222
176# HPUX 10.X config. Supports threads. 223# HPUX 10.X config. Supports threads.
177"hpux10-cc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O4 -z::-D_REENTRANT::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::", 224"hpux10-cc", "cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z::-D_REENTRANT::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
178# If hpux10-cc fails, try this one (if still fails, try deleting BN_LLONG): 225# If hpux10-cc fails, try this one (if still fails, try deleting BN_LLONG):
179"hpux10-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::-D_REENTRANT::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::", 226"hpux10-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::-D_REENTRANT::BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
180 227
@@ -184,30 +231,46 @@ my %table=(
184 231
185# HPUX 11.X from www.globus.org. 232# HPUX 11.X from www.globus.org.
186# Only works on PA-RISC 2.0 cpus, and not optimized. Why? 233# Only works on PA-RISC 2.0 cpus, and not optimized. Why?
187"hpux11-32bit-cc","cc:+DA2.0 -DB_ENDIAN -D_HPUX_SOURCE -Aa -Ae +ESlit::-D_REENTRANT::DES_PTR DES_UNROLL DES_RISC1:::", 234#"hpux11-32bit-cc","cc:+DA2.0 -DB_ENDIAN -D_HPUX_SOURCE -Aa -Ae +ESlit::-D_REENTRANT::DES_PTR DES_UNROLL DES_RISC1:::",
188"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 :::", 235#"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 :::",
236# Use unified settings above instead.
189 237
190# Dec Alpha, OSF/1 - the alpha164-cc is the flags for a 21164A with 238# Dec Alpha, OSF/1 - the alpha164-cc is the flags for a 21164A with
191# the new compiler 239# the new compiler
192# For gcc, the following gave a %50 speedup on a 164 over the 'DES_INT' version 240# For gcc, the following gave a %50 speedup on a 164 over the 'DES_INT' version
193"alpha-gcc","gcc:-O3::(unknown)::SIXTY_FOUR_BIT_LONG DES_UNROLL DES_RISC1:::", 241"alpha-gcc","gcc:-O3::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_RISC1:asm/alpha.o::",
194"alpha-cc", "cc:-std1 -tune host -O4 -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG:::", 242"alpha-cc", "cc:-std1 -tune host -O4 -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK:asm/alpha.o::",
195"alpha164-cc", "cc:-std1 -tune host -fast -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG:::", 243"alpha164-cc", "cc:-std1 -tune host -fast -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK:asm/alpha.o::",
196"FreeBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2:::", 244"FreeBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2:::",
245
246#### Alpha Linux with GNU C and Compaq C setups
247# Special notes:
248# - linux-alpha+bwx-gcc is ment to be used from ./config only. If you
249# ought to run './Configure linux-alpha+bwx-gcc' manually, do
250# complement the command line with -mcpu=ev56, -mcpu=ev6 or whatever
251# which is appropriate.
252# - If you use ccc keep in mind that -fast implies -arch host and the
253# compiler is free to issue instructions which gonna make elder CPU
254# choke. If you wish to build "blended" toolkit, add -arch generic
255# *after* -fast and invoke './Configure linux-alpha-ccc' manually.
256#
257# <appro@fy.chalmers.se>
258#
259"linux-alpha-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL:asm/alpha.o::",
260"linux-alpha+bwx-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:asm/alpha.o::",
261"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:asm/alpha.o::",
262"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:asm/alpha.o::",
197 263
198# assembler versions -- currently defunct: 264# assembler versions -- currently defunct:
199##"alpha-gcc","gcc:-O3::(unknown)::SIXTY_FOUR_BIT_LONG DES_UNROLL DES_RISC1:asm/alpha.o::",
200##"alpha-cc", "cc:-tune host -O4 -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG:asm/alpha.o::",
201##"alpha164-cc", "cc:-tune host -fast -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG:asm/alpha.o::",
202##"OpenBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2:asm/alpha.o::", 265##"OpenBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2:asm/alpha.o::",
203 266
204# The intel boxes :-), It would be worth seeing if bsdi-gcc can use the 267# The intel boxes :-), It would be worth seeing if bsdi-gcc can use the
205# bn86-elf.o file file since it is hand tweaked assembler. 268# bn86-elf.o file file since it is hand tweaked assembler.
206"linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", 269"linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
207"debug-linux-elf","gcc:-DREF_CHECK -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-lefence:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", 270"debug-linux-elf","gcc:-DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-lefence:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
208"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm", 271"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
209"linux-mips", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown)::BN_LLONG:::", 272"linux-mips", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown)::BN_LLONG:::",
210"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown)::::", 273"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG::",
211"NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::", 274"NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
212"NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::", 275"NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
213"NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:", 276"NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:",
@@ -224,6 +287,9 @@ my %table=(
224"unixware-2.0","cc:-O -DFILIO_H::(unknown):-lsocket -lnsl:$x86_gcc_des ${x86_gcc_opts}:::", 287"unixware-2.0","cc:-O -DFILIO_H::(unknown):-lsocket -lnsl:$x86_gcc_des ${x86_gcc_opts}:::",
225"unixware-2.0-pentium","cc:-O -DFILIO_H -Kpentium -Kthread::(unknown):-lsocket -lnsl:MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 288"unixware-2.0-pentium","cc:-O -DFILIO_H -Kpentium -Kthread::(unknown):-lsocket -lnsl:MD2_CHAR RC4_INDEX ${x86_gcc_des}::",
226 289
290# UnixWare 7
291"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread:-lsocket -lnsl:MD2_CHAR RC4_INDEX ${x86_gcc_des}::",
292
227# IBM's AIX. 293# IBM's AIX.
228"aix-cc", "cc:-O -DAIX -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR:::", 294"aix-cc", "cc:-O -DAIX -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR:::",
229"aix-gcc", "gcc:-O3 -DAIX -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR:::", 295"aix-gcc", "gcc:-O3 -DAIX -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR:::",
@@ -249,7 +315,7 @@ my %table=(
249# for some st_addr stuff, and then sizeof and address-of fails 315# for some st_addr stuff, and then sizeof and address-of fails
250# I could not use the ams/alpha.o option because the Cray assembler, 'cam' 316# I could not use the ams/alpha.o option because the Cray assembler, 'cam'
251# did not like it. 317# did not like it.
252"cray-t3e", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown)::SIXTY_FOUR_BIT_LONG DES_INT:::", 318"cray-t3e", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:::",
253 319
254# DGUX, 88100. 320# DGUX, 88100.
255"dgux-R3-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::RC4_INDEX DES_UNROLL:::", 321"dgux-R3-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::RC4_INDEX DES_UNROLL:::",
@@ -268,7 +334,7 @@ my %table=(
268"SINIX-N","/usr/ucb/cc:-O2 -misaligned::(unknown):-lucb:RC4_INDEX RC4_CHAR:::", 334"SINIX-N","/usr/ucb/cc:-O2 -misaligned::(unknown):-lucb:RC4_INDEX RC4_CHAR:::",
269 335
270# SIEMENS BS2000/OSD: an EBCDIC-based mainframe 336# SIEMENS BS2000/OSD: an EBCDIC-based mainframe
271"BS2000-OSD","c89:-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:::", 337"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:::",
272 338
273# Windows NT, Microsoft Visual C++ 4.0 339# Windows NT, Microsoft Visual C++ 4.0
274 340
@@ -301,6 +367,9 @@ my %table=(
301"OpenBSD", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL:::", 367"OpenBSD", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL:::",
302"OpenBSD-mips","gcc:-O2 -DL_ENDIAN::(unknown):BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR::::", 368"OpenBSD-mips","gcc:-O2 -DL_ENDIAN::(unknown):BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR::::",
303 369
370##### MacOS X (a.k.a. Rhapsody) setup
371"rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
372
304); 373);
305 374
306my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32 375my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32
@@ -337,12 +406,16 @@ my $ranlib;
337my $perl; 406my $perl;
338 407
339$ranlib=&which("ranlib") or $ranlib="true"; 408$ranlib=&which("ranlib") or $ranlib="true";
340$perl=&which("perl5") or $perl=&which("perl") or $perl="perl"; 409$perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl")
410 or $perl="perl";
341 411
342&usage if ($#ARGV < 0); 412&usage if ($#ARGV < 0);
343 413
344my $flags=""; 414my $flags="";
345my $depflags=""; 415my $depflags="";
416my $openssl_algorithm_defines="";
417my $openssl_thread_defines="";
418my $openssl_other_defines="";
346my $libs=""; 419my $libs="";
347my $target=""; 420my $target="";
348my $options=""; 421my $options="";
@@ -352,6 +425,7 @@ foreach (@ARGV)
352 { 425 {
353 $no_asm=1; 426 $no_asm=1;
354 $flags .= "-DNO_ASM "; 427 $flags .= "-DNO_ASM ";
428 $openssl_other_defines .= "#define NO_ASM\n";
355 } 429 }
356 elsif (/^no-threads$/) 430 elsif (/^no-threads$/)
357 { $no_threads=1; } 431 { $no_threads=1; }
@@ -364,11 +438,14 @@ foreach (@ARGV)
364 $algo =~ tr/[a-z]/[A-Z]/; 438 $algo =~ tr/[a-z]/[A-Z]/;
365 $flags .= "-DNO_$algo "; 439 $flags .= "-DNO_$algo ";
366 $depflags .= "-DNO_$algo "; 440 $depflags .= "-DNO_$algo ";
441 $openssl_algorithm_defines .= "#define NO_$algo\n";
367 if ($algo eq "DES") 442 if ($algo eq "DES")
368 { 443 {
444 push @skip, "mdc2";
369 $options .= " no-mdc2"; 445 $options .= " no-mdc2";
370 $flags .= "-DNO_MDC2 "; 446 $flags .= "-DNO_MDC2 ";
371 $depflags .= "-DNO_MDC2 "; 447 $depflags .= "-DNO_MDC2 ";
448 $openssl_algorithm_defines .= "#define NO_MDC2\n";
372 } 449 }
373 } 450 }
374 elsif (/^386$/) 451 elsif (/^386$/)
@@ -377,6 +454,7 @@ foreach (@ARGV)
377 { 454 {
378 $libs.= "-lRSAglue -lrsaref "; 455 $libs.= "-lRSAglue -lrsaref ";
379 $flags.= "-DRSAref "; 456 $flags.= "-DRSAref ";
457 $openssl_other_defines .= "#define RSAref\n";
380 } 458 }
381 elsif (/^[-+]/) 459 elsif (/^[-+]/)
382 { 460 {
@@ -432,6 +510,14 @@ if ($target eq "TABLE") {
432 exit 0; 510 exit 0;
433} 511}
434 512
513if ($target eq "LIST") {
514 foreach (sort keys %table) {
515 print;
516 print "\n";
517 }
518 exit 0;
519}
520
435&usage if (!defined($table{$target})); 521&usage if (!defined($table{$target}));
436 522
437my $IsWindows=scalar grep /^$target$/,@WinTargets; 523my $IsWindows=scalar grep /^$target$/,@WinTargets;
@@ -454,6 +540,7 @@ print "IsWindows=$IsWindows\n";
454$cflags="$flags$cflags" if ($flags ne ""); 540$cflags="$flags$cflags" if ($flags ne "");
455 541
456my $thread_cflags; 542my $thread_cflags;
543my $thread_defines;
457if ($thread_cflag ne "(unknown)" && !$no_threads) 544if ($thread_cflag ne "(unknown)" && !$no_threads)
458 { 545 {
459 # If we know how to do it, support threads by default. 546 # If we know how to do it, support threads by default.
@@ -463,11 +550,21 @@ if ($thread_cflag eq "(unknown)")
463 { 550 {
464 # If the user asked for "threads", hopefully they also provided 551 # If the user asked for "threads", hopefully they also provided
465 # any system-dependent compiler options that are necessary. 552 # any system-dependent compiler options that are necessary.
466 $thread_cflags="-DTHREADS $cflags" 553 $thread_cflags="-DTHREADS $cflags" ;
554 $thread_defines .= "#define THREADS\n";
467 } 555 }
468else 556else
469 { 557 {
470 $thread_cflags="-DTHREADS $thread_cflag $cflags" 558 $thread_cflags="-DTHREADS $thread_cflag $cflags";
559 $thread_defines .= "#define THREADS\n";
560# my $def;
561# foreach $def (split ' ',$thread_cflag)
562# {
563# if ($def =~ s/^-D// && $def !~ /^_/)
564# {
565# $thread_defines .= "#define $def\n";
566# }
567# }
471 } 568 }
472 569
473$lflags="$libs$lflags"if ($libs ne ""); 570$lflags="$libs$lflags"if ($libs ne "");
@@ -481,6 +578,7 @@ if ($no_asm)
481if ($threads) 578if ($threads)
482 { 579 {
483 $cflags=$thread_cflags; 580 $cflags=$thread_cflags;
581 $openssl_thread_defines .= $thread_defines;
484 } 582 }
485 583
486#my ($bn1)=split(/\s+/,$bn_obj); 584#my ($bn1)=split(/\s+/,$bn_obj);
@@ -530,6 +628,7 @@ if ($version =~ /(^[0-9]*)\.([0-9\.]*)/)
530 628
531open(IN,'<Makefile.org') || die "unable to read Makefile.org:$!\n"; 629open(IN,'<Makefile.org') || die "unable to read Makefile.org:$!\n";
532open(OUT,">$Makefile") || die "unable to create $Makefile:$!\n"; 630open(OUT,">$Makefile") || die "unable to create $Makefile:$!\n";
631print OUT "### Generated automatically from Makefile.org by Configure.\n\n";
533my $sdirs=0; 632my $sdirs=0;
534while (<IN>) 633while (<IN>)
535 { 634 {
@@ -598,6 +697,7 @@ my $md2_int=$def_int;
598my $idea_int=$def_int; 697my $idea_int=$def_int;
599my $rc2_int=$def_int; 698my $rc2_int=$def_int;
600my $rc4_idx=0; 699my $rc4_idx=0;
700my $rc4_chunk=0;
601my $bf_ptr=0; 701my $bf_ptr=0;
602my @type=("char","short","int","long"); 702my @type=("char","short","int","long");
603my ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0); 703my ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0);
@@ -615,6 +715,8 @@ foreach (sort split(/\s+/,$bn_ops))
615 $rc4_int=0 if /RC4_CHAR/; 715 $rc4_int=0 if /RC4_CHAR/;
616 $rc4_int=3 if /RC4_LONG/; 716 $rc4_int=3 if /RC4_LONG/;
617 $rc4_idx=1 if /RC4_INDEX/; 717 $rc4_idx=1 if /RC4_INDEX/;
718 $rc4_chunk=1 if /RC4_CHUNK/;
719 $rc4_chunk=2 if /RC4_CHUNK_LL/;
618 $md2_int=0 if /MD2_CHAR/; 720 $md2_int=0 if /MD2_CHAR/;
619 $md2_int=3 if /MD2_LONG/; 721 $md2_int=3 if /MD2_LONG/;
620 $idea_int=1 if /IDEA_SHORT/; 722 $idea_int=1 if /IDEA_SHORT/;
@@ -632,6 +734,18 @@ foreach (sort split(/\s+/,$bn_ops))
632 734
633open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n"; 735open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
634open(OUT,'>crypto/opensslconf.h') || die "unable to create crypto/opensslconf.h:$!\n"; 736open(OUT,'>crypto/opensslconf.h') || die "unable to create crypto/opensslconf.h:$!\n";
737print OUT "/* opensslconf.h */\n";
738print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
739
740print OUT "/* OpenSSL was configured with the following options: */\n";
741$openssl_algorithm_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n# define $1\n# endif/mg;
742$openssl_algorithm_defines = " /* no ciphers excluded */\n" if $openssl_algorithm_defines eq "";
743$openssl_thread_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n# define $1\n# endif/mg;
744$openssl_other_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n# define $1\n# endif/mg;
745print OUT "#ifdef OPENSSL_ALGORITHM_DEFINES\n$openssl_algorithm_defines#endif\n";
746print OUT "#ifdef OPENSSL_THREAD_DEFINES\n$openssl_thread_defines#endif\n";
747print OUT "#ifdef OPENSSL_OTHER_DEFINES\n$openssl_other_defines#endif\n\n";
748
635while (<IN>) 749while (<IN>)
636 { 750 {
637 if (/^#define\s+OPENSSLDIR/) 751 if (/^#define\s+OPENSSLDIR/)
@@ -666,6 +780,12 @@ while (<IN>)
666 { printf OUT "#%s DES_UNROLL\n",($des_unroll)?'define':'undef'; } 780 { printf OUT "#%s DES_UNROLL\n",($des_unroll)?'define':'undef'; }
667 elsif (/^#define\s+RC4_INT\s/) 781 elsif (/^#define\s+RC4_INT\s/)
668 { printf OUT "#define RC4_INT unsigned %s\n",$type[$rc4_int]; } 782 { printf OUT "#define RC4_INT unsigned %s\n",$type[$rc4_int]; }
783 elsif (/^#undef\s+RC4_CHUNK/)
784 {
785 printf OUT "#undef RC4_CHUNK\n" if $rc4_chunk==0;
786 printf OUT "#define RC4_CHUNK unsigned long\n" if $rc4_chunk==1;
787 printf OUT "#define RC4_CHUNK unsigned long long\n" if $rc4_chunk==2;
788 }
669 elsif (/^#((define)|(undef))\s+RC4_INDEX/) 789 elsif (/^#((define)|(undef))\s+RC4_INDEX/)
670 { printf OUT "#%s RC4_INDEX\n",($rc4_idx)?"define":"undef"; } 790 { printf OUT "#%s RC4_INDEX\n",($rc4_idx)?"define":"undef"; }
671 elsif (/^#(define|undef)\s+I386_ONLY/) 791 elsif (/^#(define|undef)\s+I386_ONLY/)
@@ -705,6 +825,9 @@ print "DES_INT used\n" if $des_int;
705print "BN_LLONG mode\n" if $bn_ll; 825print "BN_LLONG mode\n" if $bn_ll;
706print "RC4 uses u$type[$rc4_int]\n" if $rc4_int != $def_int; 826print "RC4 uses u$type[$rc4_int]\n" if $rc4_int != $def_int;
707print "RC4_INDEX mode\n" if $rc4_idx; 827print "RC4_INDEX mode\n" if $rc4_idx;
828print "RC4_CHUNK is undefined\n" if $rc4_chunk==0;
829print "RC4_CHUNK is unsigned long\n" if $rc4_chunk==1;
830print "RC4_CHUNK is unsigned long long\n" if $rc4_chunk==2;
708print "MD2 uses u$type[$md2_int]\n" if $md2_int != $def_int; 831print "MD2 uses u$type[$md2_int]\n" if $md2_int != $def_int;
709print "IDEA uses u$type[$idea_int]\n" if $idea_int != $def_int; 832print "IDEA uses u$type[$idea_int]\n" if $idea_int != $def_int;
710print "RC2 uses u$type[$rc2_int]\n" if $rc2_int != $def_int; 833print "RC2 uses u$type[$rc2_int]\n" if $rc2_int != $def_int;
@@ -723,8 +846,6 @@ if($IsWindows) {
723#endif 846#endif
724EOF 847EOF
725 close(OUT); 848 close(OUT);
726
727 system "perl crypto/objects/obj_dat.pl <crypto\\objects\\objects.h >crypto\\objects\\obj_dat.h";
728} else { 849} else {
729 (system "make -f Makefile.ssl PERL=\'$perl\' links") == 0 or exit $?; 850 (system "make -f Makefile.ssl PERL=\'$perl\' links") == 0 or exit $?;
730 ### (system 'make depend') == 0 or exit $? if $depflags ne ""; 851 ### (system 'make depend') == 0 or exit $? if $depflags ne "";
@@ -733,43 +854,20 @@ EOF
733 &dofile("tools/c_rehash",$openssldir,'^DIR=', 'DIR=%s',); 854 &dofile("tools/c_rehash",$openssldir,'^DIR=', 'DIR=%s',);
734 if ( $perl =~ m@^/@) { 855 if ( $perl =~ m@^/@) {
735 &dofile("apps/der_chop",$perl,'^#!/', '#!%s'); 856 &dofile("apps/der_chop",$perl,'^#!/', '#!%s');
857 &dofile("apps/CA.pl",$perl,'^#!/', '#!%s');
736 } else { 858 } else {
737 # No path for Perl known ... 859 # No path for Perl known ...
738 &dofile("apps/der_chop",'/usr/local/bin/perl','^#!/', '#!%s'); 860 &dofile("apps/der_chop",'/usr/local/bin/perl','^#!/', '#!%s');
861 &dofile("apps/CA.pl",'/usr/local/bin/perl','^#!/', '#!%s');
739 } 862 }
740} 863}
741 864
742my $pwd;
743
744if($IsWindows) {
745 $pwd="(current directory)";
746} else {
747 $pwd =`pwd`;
748 chop($pwd);
749}
750print <<EOF; 865print <<EOF;
751 866
752NOTE: The OpenSSL header files have been moved from include/*.h 867Configured for $target.
753to include/openssl/*.h. To include OpenSSL header files, now
754directives of the form
755 #include <openssl/foo.h>
756should be used instead of #include <foo.h>.
757These new file locations allow installing the OpenSSL header
758files in /usr/local/include/openssl/ and should help avoid
759conflicts with other libraries.
760
761To compile programs that use the old form <foo.h>,
762usually an additional compiler option will suffice: E.g., add
763 -I$prefix/include/openssl
764or
765 -I$pwd/include/openssl
766to the CFLAGS in the Makefile of the program that you want to compile
767(and leave all the original -I...'s in place!).
768
769Please make sure that no old OpenSSL header files are around:
770The include directory should now be empty except for the openssl
771subdirectory.
772 868
869NOTE: OpenSSL header files were moved from <*.h> to <openssl/*.h>;
870see file INSTALL for hints on coping with compatibility problems.
773EOF 871EOF
774 872
775print <<\EOF if (!$no_threads && !$threads); 873print <<\EOF if (!$no_threads && !$threads);
@@ -777,7 +875,6 @@ print <<\EOF if (!$no_threads && !$threads);
777The library could not be configured for supporting multi-threaded 875The library could not be configured for supporting multi-threaded
778applications as the compiler options required on this system are not known. 876applications as the compiler options required on this system are not known.
779See file INSTALL for details if you need multi-threading. 877See file INSTALL for details if you need multi-threading.
780
781EOF 878EOF
782 879
783exit(0); 880exit(0);
@@ -785,22 +882,33 @@ exit(0);
785sub usage 882sub usage
786 { 883 {
787 print STDERR $usage; 884 print STDERR $usage;
788 print STDERR "pick os/compiler from:"; 885 print STDERR "\npick os/compiler from:\n";
789 my $j=0; 886 my $j=0;
790 my $i; 887 my $i;
888 my $k=0;
791 foreach $i (sort keys %table) 889 foreach $i (sort keys %table)
792 { 890 {
793 next if $i =~ /^debug/; 891 next if $i =~ /^debug/;
794 print STDERR "\n" if ($j++ % 4) == 0; 892 $k += length($i) + 1;
795 printf(STDERR "%-18s ",$i); 893 if ($k > 78)
894 {
895 print STDERR "\n";
896 $k=length($i);
897 }
898 print STDERR $i . " ";
796 } 899 }
797 foreach $i (sort keys %table) 900 foreach $i (sort keys %table)
798 { 901 {
799 next if $i !~ /^debug/; 902 next if $i !~ /^debug/;
800 print STDERR "\n" if ($j++ % 4) == 0; 903 $k += length($i) + 1;
801 printf(STDERR "%-18s ",$i); 904 if ($k > 78)
905 {
906 print STDERR "\n";
907 $k=length($i);
908 }
909 print STDERR $i . " ";
802 } 910 }
803 print STDERR "\n"; 911 print STDERR "\n\nNOTE: If in doubt, on Unix-ish systems use './config'.\n";
804 exit(1); 912 exit(1);
805 } 913 }
806 914
diff --git a/src/lib/libssl/src/FAQ b/src/lib/libssl/src/FAQ
new file mode 100644
index 0000000000..ab84a3f9e8
--- /dev/null
+++ b/src/lib/libssl/src/FAQ
@@ -0,0 +1,130 @@
1OpenSSL - Frequently Asked Questions
2--------------------------------------
3
4* Which is the current version of OpenSSL?
5* Where is the documentation?
6* How can I contact the OpenSSL developers?
7* Do I need patent licenses to use OpenSSL?
8* Is OpenSSL thread-safe?
9* Why do I get a "PRNG not seeded" error message?
10* Why does the linker complain about undefined symbols?
11* Where can I get a compiled version of OpenSSL?
12
13
14* Which is the current version of OpenSSL?
15
16The current version is available from <URL: http://www.openssl.org>.
17OpenSSL 0.9.5 was released on February 28th, 2000.
18
19In addition to the current stable release, you can also access daily
20snapshots of the OpenSSL development version at <URL:
21ftp://ftp.openssl.org/snapshot/>, or get it by anonymous CVS access.
22
23
24* Where is the documentation?
25
26OpenSSL is a library that provides cryptographic functionality to
27applications such as secure web servers. Be sure to read the
28documentation of the application you want to use. The INSTALL file
29explains how to install this library.
30
31OpenSSL includes a command line utility that can be used to perform a
32variety of cryptographic functions. It is described in the openssl(1)
33manpage. Documentation for developers is currently being written. A
34few manual pages already are available; overviews over libcrypto and
35libssl are given in the crypto(3) and ssl(3) manpages.
36
37The OpenSSL manpages are installed in /usr/local/ssl/man/ (or a
38different directory if you specified one as described in INSTALL).
39In addition, you can read the most current versions at
40<URL: http://www.openssl.org/docs/>.
41
42For information on parts of libcrypto that are not yet documented, you
43might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
44predecessor, at <URL: http://www.columbia.edu/~ariel/ssleay/>. Much
45of this still applies to OpenSSL.
46
47There is some documentation about certificate extensions and PKCS#12
48in doc/openssl.txt
49
50The original SSLeay documentation is included in OpenSSL as
51doc/ssleay.txt. It may be useful when none of the other resources
52help, but please note that it reflects the obsolete version SSLeay
530.6.6.
54
55
56* How can I contact the OpenSSL developers?
57
58The README file describes how to submit bug reports and patches to
59OpenSSL. Information on the OpenSSL mailing lists is available from
60<URL: http://www.openssl.org>.
61
62
63* Do I need patent licenses to use OpenSSL?
64
65The patents section of the README file lists patents that may apply to
66you if you want to use OpenSSL. For information on intellectual
67property rights, please consult a lawyer. The OpenSSL team does not
68offer legal advice.
69
70You can configure OpenSSL so as not to use RC5 and IDEA by using
71 ./config no-rc5 no-idea
72
73Until the RSA patent expires, U.S. users may want to use
74 ./config no-rc5 no-idea no-rsa
75
76Please note that you will *not* be able to communicate with most of
77the popular web browsers without RSA support.
78
79
80* Is OpenSSL thread-safe?
81
82Yes. On Windows and many Unix systems, OpenSSL automatically uses the
83multi-threaded versions of the standard libraries. If your platform
84is not one of these, consult the INSTALL file.
85
86Multi-threaded applications must provide two callback functions to
87OpenSSL. This is described in the threads(3) manpage.
88
89
90* Why do I get a "PRNG not seeded" error message?
91
92Cryptographic software needs a source of unpredictable data to work
93correctly. Many open source operating systems provide a "randomness
94device" that serves this purpose. On other systems, applications have
95to call the RAND_add() or RAND_seed() function with appropriate data
96before generating keys or performing public key encryption.
97
98Some broken applications do not do this. As of version 0.9.5, the
99OpenSSL functions that need randomness report an error if the random
100number generator has not been seeded with at least 128 bits of
101randomness. If this error occurs, please contact the author of the
102application you are using. It is likely that it never worked
103correctly. OpenSSL 0.9.5 makes the error visible by refusing to
104perform potentially insecure encryption.
105
106
107* Why does the linker complain about undefined symbols?
108
109Maybe the compilation was interrupted, and make doesn't notice that
110something is missing. Run "make clean; make".
111
112If you used ./Configure instead of ./config, make sure that you
113selected the right target. File formats may differ slightly between
114OS versions (for example sparcv8/sparcv9, or a.out/elf).
115
116If that doesn't help, you may want to try using the current snapshot.
117If the problem persists, please submit a bug report.
118
119
120* Where can I get a compiled version of OpenSSL?
121
122Some applications that use OpenSSL are distributed in binary form.
123When using such an application, you don't need to install OpenSSL
124yourself; the application will include the required parts (e.g. DLLs).
125
126If you want to install OpenSSL on a Windows system and you don't have
127a C compiler, read the "Mingw32" section of INSTALL.W32 for information
128on how to obtain and install the free GNU C compiler.
129
130A number of Linux and *BSD distributions include OpenSSL.
diff --git a/src/lib/libssl/src/INSTALL b/src/lib/libssl/src/INSTALL
index 6066fddc4a..57a6c808d8 100644
--- a/src/lib/libssl/src/INSTALL
+++ b/src/lib/libssl/src/INSTALL
@@ -77,8 +77,9 @@
77 77
78 This guesses at your operating system (and compiler, if necessary) and 78 This guesses at your operating system (and compiler, if necessary) and
79 configures OpenSSL based on this guess. Run ./config -t to see 79 configures OpenSSL based on this guess. Run ./config -t to see
80 if it guessed correctly. If it did not get it correct or you want to 80 if it guessed correctly. If you want to use a different compiler, you
81 use a different compiler then go to step 1b. Otherwise go to step 2. 81 are cross-compiling for another platform, or the ./config guess was
82 wrong for other reasons, go to step 1b. Otherwise go to step 2.
82 83
83 On some systems, you can include debugging information as follows: 84 On some systems, you can include debugging information as follows:
84 85
@@ -101,7 +102,8 @@
101 102
102 If your system is not available, you will have to edit the Configure 103 If your system is not available, you will have to edit the Configure
103 program and add the correct configuration for your system. The 104 program and add the correct configuration for your system. The
104 generic configurations "cc" or "gcc" should usually work. 105 generic configurations "cc" or "gcc" should usually work on 32 bit
106 systems.
105 107
106 Configure creates the file Makefile.ssl from Makefile.org and 108 Configure creates the file Makefile.ssl from Makefile.org and
107 defines various macros in crypto/opensslconf.h (generated from 109 defines various macros in crypto/opensslconf.h (generated from
@@ -115,14 +117,12 @@
115 OpenSSL binary ("openssl"). The libraries will be built in the top-level 117 OpenSSL binary ("openssl"). The libraries will be built in the top-level
116 directory, and the binary will be in the "apps" directory. 118 directory, and the binary will be in the "apps" directory.
117 119
118 If "make" fails, please report the problem to <openssl-bugs@openssl.org>. 120 If "make" fails, please report the problem to <openssl-bugs@openssl.org>
119 Include the output of "./config -t" and the OpenSSL version 121 (note that your message will be forwarded to a public mailing list).
120 number in your message. 122 Include the output of "make report" in your message.
121 123
122 [If you encounter assembler error messages, try the "no-asm" 124 [If you encounter assembler error messages, try the "no-asm"
123 configuration option as an immediate fix. Note that on Solaris x86 125 configuration option as an immediate fix.]
124 (not on Sparcs!) you may have to install the GNU assembler to use
125 OpenSSL assembler code -- /usr/ccs/bin/as won't do.]
126 126
127 Compiling parts of OpenSSL with gcc and others with the system 127 Compiling parts of OpenSSL with gcc and others with the system
128 compiler will result in unresolved symbols on some systems. 128 compiler will result in unresolved symbols on some systems.
@@ -134,7 +134,7 @@
134 If a test fails, try removing any compiler optimization flags from 134 If a test fails, try removing any compiler optimization flags from
135 the CFLAGS line in Makefile.ssl and run "make clean; make". Please 135 the CFLAGS line in Makefile.ssl and run "make clean; make". Please
136 send a bug report to <openssl-bugs@openssl.org>, including the 136 send a bug report to <openssl-bugs@openssl.org>, including the
137 output of "openssl version -a" and of the failed test. 137 output of "make report".
138 138
139 4. If everything tests ok, install OpenSSL with 139 4. If everything tests ok, install OpenSSL with
140 140
@@ -145,11 +145,13 @@
145 145
146 certs Initially empty, this is the default location 146 certs Initially empty, this is the default location
147 for certificate files. 147 for certificate files.
148 man/man1 Manual pages for the 'openssl' command line tool
149 man/man3 Manual pages for the libraries (very incomplete)
148 misc Various scripts. 150 misc Various scripts.
149 private Initially empty, this is the default location 151 private Initially empty, this is the default location
150 for private key files. 152 for private key files.
151 153
152 If you didn't chose a different installation prefix, the 154 If you didn't choose a different installation prefix, the
153 following additional subdirectories will be created: 155 following additional subdirectories will be created:
154 156
155 bin Contains the openssl binary and a few other 157 bin Contains the openssl binary and a few other
@@ -250,138 +252,3 @@
250 you can still use "no-threads" to suppress an annoying warning message 252 you can still use "no-threads" to suppress an annoying warning message
251 from the Configure script.) 253 from the Configure script.)
252 254
253
254--------------------------------------------------------------------------------
255The orignal Unix build instructions from SSLeay follow.
256Note: some of this may be out of date and no longer applicable
257--------------------------------------------------------------------------------
258
259# When bringing the SSLeay distribution back from the evil intel world
260# of Windows NT, do the following to make it nice again under unix :-)
261# You don't normally need to run this.
262sh util/fixNT.sh # This only works for NT now - eay - 21-Jun-1996
263
264# If you have perl, and it is not in /usr/local/bin, you can run
265perl util/perlpath.pl /new/path
266# and this will fix the paths in all the scripts. DO NOT put
267# /new/path/perl, just /new/path. The build
268# environment always run scripts as 'perl perlscript.pl' but some of the
269# 'applications' are easier to usr with the path fixed.
270
271# Edit crypto/cryptlib.h, tools/c_rehash, and Makefile.ssl
272# to set the install locations if you don't like
273# the default location of /usr/local/ssl
274# Do this by running
275perl util/ssldir.pl /new/ssl/home
276# if you have perl, or by hand if not.
277
278# If things have been stuffed up with the sym links, run
279make -f Makefile.ssl links
280# This will re-populate lib/include with symlinks and for each
281# directory, link Makefile to Makefile.ssl
282
283# Setup the machine dependent stuff for the top level makefile
284# and some select .h files
285# If you don't have perl, this will bomb, in which case just edit the
286# top level Makefile.ssl
287./Configure 'system type'
288
289# The 'Configure' command contains default configuration parameters
290# for lots of machines. Configure edits 5 lines in the top level Makefile
291# It modifies the following values in the following files
292Makefile.ssl CC CFLAG EX_LIBS BN_MULW
293crypto/des/des.h DES_LONG
294crypto/des/des_locl.h DES_PTR
295crypto/md2/md2.h MD2_INT
296crypto/rc4/rc4.h RC4_INT
297crypto/rc4/rc4_enc.c RC4_INDEX
298crypto/rc2/rc2.h RC2_INT
299crypto/bf/bf_locl.h BF_INT
300crypto/idea/idea.h IDEA_INT
301crypto/bn/bn.h BN_LLONG (and defines one of SIXTY_FOUR_BIT,
302 SIXTY_FOUR_BIT_LONG, THIRTY_TWO_BIT,
303 SIXTEEN_BIT or EIGHT_BIT)
304Please remember that all these files are actually copies of the file with
305a .org extention. So if you change crypto/des/des.h, the next time
306you run Configure, it will be runover by a 'configured' version of
307crypto/des/des.org. So to make the changer the default, change the .org
308files. The reason these files have to be edited is because most of
309these modifications change the size of fundamental data types.
310While in theory this stuff is optional, it often makes a big
311difference in performance and when using assember, it is importaint
312for the 'Bignum bits' match those required by the assember code.
313A warning for people using gcc with sparc cpu's. Gcc needs the -mv8
314flag to use the hardware multiply instruction which was not present in
315earlier versions of the sparc CPU. I define it by default. If you
316have an old sparc, and it crashes, try rebuilding with this flag
317removed. I am leaving this flag on by default because it makes
318things run 4 times faster :-)
319
320# clean out all the old stuff
321make clean
322
323# Do a make depend only if you have the makedepend command installed
324# This is not needed but it does make things nice when developing.
325make depend
326
327# make should build everything
328make
329
330# fix up the demo certificate hash directory if it has been stuffed up.
331make rehash
332
333# test everything
334make test
335
336# install the lot
337make install
338
339# It is worth noting that all the applications are built into the one
340# program, ssleay, which is then has links from the other programs
341# names to it.
342# The applicatons can be built by themselves, just don't define the
343# 'MONOLITH' flag. So to build the 'enc' program stand alone,
344gcc -O2 -Iinclude apps/enc.c apps/apps.c libcrypto.a
345
346# Other useful make options are
347make makefile.one
348# which generate a 'makefile.one' file which will build the complete
349# SSLeay distribution with temp. files in './tmp' and 'installable' files
350# in './out'
351
352# Have a look at running
353perl util/mk1mf.pl help
354# this can be used to generate a single makefile and is about the only
355# way to generate makefiles for windows.
356
357# There is actually a final way of building SSLeay.
358gcc -O2 -c -Icrypto -Iinclude crypto/crypto.c
359gcc -O2 -c -Issl -Iinclude ssl/ssl.c
360# and you now have the 2 libraries as single object files :-).
361# If you want to use the assember code for your particular platform
362# (DEC alpha/x86 are the main ones, the other assember is just the
363# output from gcc) you will need to link the assember with the above generated
364# object file and also do the above compile as
365gcc -O2 -DBN_ASM -c -Icrypto -Iinclude crypto/crypto.c
366
367This last option is probably the best way to go when porting to another
368platform or building shared libraries. It is not good for development so
369I don't normally use it.
370
371To build shared libararies under unix, have a look in shlib, basically
372you are on your own, but it is quite easy and all you have to do
373is compile 2 (or 3) files.
374
375For mult-threading, have a read of doc/threads.doc. Again it is quite
376easy and normally only requires some extra callbacks to be defined
377by the application.
378The examples for solaris and windows NT/95 are in the mt directory.
379
380have fun
381
382eric 25-Jun-1997
383
384IRIX 5.x will build as a 32 bit system with mips1 assember.
385IRIX 6.x will build as a 64 bit system with mips3 assember. It conforms
386to n32 standards. In theory you can compile the 64 bit assember under
387IRIX 5.x but you will have to have the correct system software installed.
diff --git a/src/lib/libssl/src/INSTALL.MacOS b/src/lib/libssl/src/INSTALL.MacOS
new file mode 100644
index 0000000000..a8c4f7f1da
--- /dev/null
+++ b/src/lib/libssl/src/INSTALL.MacOS
@@ -0,0 +1,72 @@
1OpenSSL - Port To The Macintosh
2===============================
3
4Thanks to Roy Wood <roy@centricsystems.ca> initial support for MacOS (pre
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
7get one sample application which fetches a page over HTTPS(*) and dumps it
8in a window. We don't even build the test applications so that we can't
9guarantee that all algorithms are operational.
10
11Required software:
12
13- StuffIt Expander 5.5 or later, alternatively MacGzip and SUNtar;
14- Scriptable Finder;
15- CodeWarrior Pro 5;
16
17Installation procedure:
18
19- fetch the source at ftp://ftp.openssl.org/ (well, you probably already
20 did, huh?)
21- unpack the .tar.gz file:
22 - if you have StuffIt Expander then just drag it over it;
23 - otherwise uncompress it with MacGzip and then unpack with SUNtar;
24- locate MacOS folder in OpenSSL source tree and open it;
25- unbinhex mklinks.as.hqx and OpenSSL.mcp.hqx if present (**), do it
26 "in-place", i.e. unpacked files should end-up in the very same folder;
27- execute mklinks.as;
28- open OpenSSL.mcp(***) and build 'GetHTTPS PPC' target(****);
29- that's it for now;
30
31(*) URL is hardcoded into ./MacOS/GetHTTPS.src/GetHTTPS.cpp, lines 40
32 to 42, change appropriately.
33(**) If you use SUNtar, then it might have already unbinhexed the files
34 in question.
35(***) The project file was saved with CW Pro 5.3. If you have earlier
36 version and it refuses to open it, then download
37 http://www.openssl.org/~appro/OpenSSL.mcp.xml and import it
38 overwriting the original OpenSSL.mcp.
39(****) Other targets are work in progress. If you feel like giving 'em a
40 shot, then you should know that OpenSSL* and Lib* targets are
41 supposed to be built with the GUSI, MacOS library which mimics
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,
44 i.e. in the parent directory to the one where this very file,
45 namely INSTALL.MacOS. For more informations about GUSI, see
46 http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html
47
48Finally some essential comments from our generous contributor:-)
49
50"I've gotten OpenSSL working on the Macintosh. It's probably a bit of a
51hack, but it works for what I'm doing. If you don't like the way I've done
52it, then feel free to change what I've done. I freely admit that I've done
53some less-than-ideal things in my port, and if you don't like the way I've
54done something, then feel free to change it-- I won't be offended!
55
56... I've tweaked "bss_sock.c" a little to call routines in a "MacSocket"
57library I wrote. My MacSocket library is a wrapper around OpenTransport,
58handling stuff like endpoint creation, reading, writing, etc. It is not
59designed as a high-performance package such as you'd use in a webserver,
60but is fine for lots of other applications. MacSocket also uses some other
61code libraries I've written to deal with string manipulations and error
62handling. Feel free to use these things in your own code, but give me
63credit and/or send me free stuff in appreciation! :-)
64
65...
66
67If you have any questions, feel free to email me as the following:
68
69roy@centricsystems.ca
70
71-Roy Wood"
72
diff --git a/src/lib/libssl/src/INSTALL.VMS b/src/lib/libssl/src/INSTALL.VMS
index 4c01560d3d..0a25324033 100644
--- a/src/lib/libssl/src/INSTALL.VMS
+++ b/src/lib/libssl/src/INSTALL.VMS
@@ -8,13 +8,44 @@ Intro:
8 8
9This file is divided in the following parts: 9This file is divided in the following parts:
10 10
11 Checking the distribution - Mandatory reading.
11 Compilation - Mandatory reading. 12 Compilation - Mandatory reading.
13 Logical names - Mandatory reading.
12 Test - Mandatory reading. 14 Test - Mandatory reading.
13 Installation - Mandatory reading. 15 Installation - Mandatory reading.
14 Backward portability - Read if it's an issue. 16 Backward portability - Read if it's an issue.
15 Possible bugs or quirks - A few warnings on things that 17 Possible bugs or quirks - A few warnings on things that
16 may go wrong or may surprise you. 18 may go wrong or may surprise you.
17 Report - How to get in touch with me. 19 TODO - Things that are to come.
20
21
22Checking the distribution:
23==========================
24
25There have been reports of places where the distribution didn't quite get
26through, for example if you've copied the tree from a NFS-mounted unix
27mount point.
28
29The easiest way to check if everything got through as it should is to check
30for oen of the following files:
31
32 [.CRYPTO]OPENSSLCONF.H_IN
33 [.CRYPTO]OPENSSLCONF_H.IN
34
35They should never exist both at once, but one of them should (preferably
36the first variant). If you can't find any of those two, something went
37wrong.
38
39The best way to get a correct distribution is to download the gzipped tar
40file from ftp://ftp.openssl.org/source/, use GUNZIP to uncompress it and
41use VMSTAR to unpack the resulting tar file.
42
43GUNZIP is available in many places on the net. One of the distribution
44points is the WKU software archive, ftp://ftp.wku.edu/vms/fileserv/ .
45
46VMSTAR is also available in many places on the net. The recommended place
47to find information about it is http://www.free.lp.se/vmstar/ .
48
18 49
19Compilation: 50Compilation:
20============ 51============
@@ -35,26 +66,28 @@ directory. The syntax is trhe following:
35<option> must be one of the following: 66<option> must be one of the following:
36 67
37 ALL Just build "everything". 68 ALL Just build "everything".
38 DATE Just build the "[.INCLUDE]DATE.H" file. 69 CONFIG Just build the "[.CRYPTO]OPENSSLCONF.H" file.
70 BUILDINF Just build the "[.INCLUDE]BUILDINF.H" file.
39 SOFTLINKS Just copies some files, to simulate Unix soft links. 71 SOFTLINKS Just copies some files, to simulate Unix soft links.
72 BUILDALL Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done.
40 RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library. 73 RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library.
41 CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library. 74 CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
42 SSL Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library. 75 SSL Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library.
43 SSL_TASK Just build the "[.xxx.EXE.SSL]SSL_TASK.EXE" program. 76 SSL_TASK Just build the "[.xxx.EXE.SSL]SSL_TASK.EXE" program.
44 TEST Just build the "test" programs for OpenSSL. 77 TEST Just build the "[.xxx.EXE.TEST]" test programs for OpenSSL.
45 APPS Just build the "application" programs for OpenSSL. 78 APPS Just build the "[.xxx.EXE.APPS]" application programs for OpenSSL.
46 79
47<rsaref-p> must be one of the following: 80<rsaref-p> must be one of the following:
48 81
49 RSAREF compile using the RSAREF Library 82 RSAREF compile using the RSAREF Library
50 NORSAREF compile without using RSAREF 83 NORSAREF compile without using RSAREF
51 84
52Note: The RSAREF libraries are NOT INCLUDED and you have to 85Note 1: The RSAREF libraries are NOT INCLUDED and you have to
53 download it from "ftp://ftp.rsa.com/rsaref". You have to 86 download it from "ftp://ftp.rsa.com/rsaref". You have to
54 get the ".tar-Z" file as the ".zip" file dosen't have the 87 get the ".tar-Z" file as the ".zip" file doesn't have the
55 directory structure stored. You have to extract the file 88 directory structure stored. You have to extract the file
56 into the [.RSAREF] directory as that is where the scripts 89 into the [.RSAREF] directory as that is where the scripts
57 will look for the files. 90 will look for the files.
58 91
59Note 2: I have never done this, so I've no idea if it works or not. 92Note 2: I have never done this, so I've no idea if it works or not.
60 93
@@ -65,7 +98,6 @@ Note 2: I have never done this, so I've no idea if it works or not.
65 98
66<compiler> must be one of the following: 99<compiler> must be one of the following:
67 100
68 VAXC For VAX C.
69 DECC For DEC C. 101 DECC For DEC C.
70 GNUC For GNU C. 102 GNUC For GNU C.
71 103
@@ -77,15 +109,33 @@ named LIBSSL.OLB, and you will find a bunch of useful programs in
77just to test them. For production use, make sure you install first, see 109just to test them. For production use, make sure you install first, see
78Installation below. 110Installation below.
79 111
80Note: Some programs in this package require a TCP/IP library. 112Note 1: Some programs in this package require a TCP/IP library.
81 113
82Note 2: if you want to compile the crypto library only, please make sure 114Note 2: if you want to compile the crypto library only, please make sure
83 you have at least done a @MAKEVMS DATE and a @MAKEVMS SOFTLINKS. 115 you have at least done a @MAKEVMS CONFIG, a @MAKEVMS BUILDINF and
84 A lot of things will break if you don't. 116 a @MAKEVMS SOFTLINKS. A lot of things will break if you don't.
117
118
119Logical names:
120==============
121
122There are a few things that can't currently be given through the command
123line. Instead, logical names are used.
124
125Currently, the logical names supported are:
126
127 OPENSSL_NO_ASM with value YES, the assembler parts of OpenSSL will
128 not be used. Instead, plain C implementations are
129 used. This is good to try if something doesn't work.
130 OPENSSL_NO_'alg' with value YES, the corresponding crypto algorithm
131 will not be implemented. Supported algorithms to
132 do this with are: RSA, DSA, DH, MD2, MD5, RIPEMD,
133 SHA, DES, MDC2, CR2, RC4, RC5, IDEA, BF, CAST, HMAC,
134 SSL2. So, for example, having the logical name
135 OPENSSL_NO_RSA with the value YES means that the
136 LIBCRYPTO.OLB library will not contain an RSA
137 implementation.
85 138
86Note 3: Alpha users will get a number of informational messages when
87 compiling the [.asm]vms.mar file in the BN (bignum) part of
88 the crypto library. These can be safely ignored.
89 139
90Test: 140Test:
91===== 141=====
@@ -99,6 +149,7 @@ it's an ugly hack!) and rebuild. Please send a bug report to
99<openssl-bugs@openssl.org>, including the output of "openssl version -a" 149<openssl-bugs@openssl.org>, including the output of "openssl version -a"
100and of the failed test. 150and of the failed test.
101 151
152
102Installation: 153Installation:
103============= 154=============
104 155
@@ -158,6 +209,7 @@ The logical names that are set up are the following:
158 (the NOTE in section 4 of "Installation in Detail"). 209 (the NOTE in section 4 of "Installation in Detail").
159 You don't need to "deleting old header files"!!! 210 You don't need to "deleting old header files"!!!
160 211
212
161Backward portability: 213Backward portability:
162===================== 214=====================
163 215
@@ -175,7 +227,7 @@ dependent on the OpenVMS version or the C library version, *and* you
175can use those macros to simulate older OpenVMS or C library versions, 227can use those macros to simulate older OpenVMS or C library versions,
176by defining the macros _VMS_V6_SOURCE, __VMS_VER and __CTRL_VER with 228by defining the macros _VMS_V6_SOURCE, __VMS_VER and __CTRL_VER with
177correct values. In the compilation scripts, I've provided the possibility 229correct values. In the compilation scripts, I've provided the possibility
178for the user to influense the creation of such macros, through a bunch of 230for the user to influence the creation of such macros, through a bunch of
179symbols, all having names starting with USER_. Here's the list of them: 231symbols, all having names starting with USER_. Here's the list of them:
180 232
181 USER_CCFLAGS - Used to give additional qualifiers to the 233 USER_CCFLAGS - Used to give additional qualifiers to the
@@ -212,19 +264,6 @@ directory by default, it may very well be that you have to give them
212extra arguments. Please experiment. 264extra arguments. Please experiment.
213 265
214 266
215Report:
216=======
217
218I maintain a few mailinglists for bug reports and such on software that
219I develop/port/enhance/destroy. Please look at http://www.free.lp.se/
220for further info.
221
222
223--
224Richard Levitte <richard@levitte.org>
2251999-03-09
226
227
228TODO: 267TODO:
229===== 268=====
230 269
@@ -242,4 +281,4 @@ have any ideas.
242 281
243-- 282--
244Richard Levitte <richard@levitte.org> 283Richard Levitte <richard@levitte.org>
2451999-05-24 2842000-02-27
diff --git a/src/lib/libssl/src/INSTALL.W32 b/src/lib/libssl/src/INSTALL.W32
index 4550aa0621..8c8008b4ad 100644
--- a/src/lib/libssl/src/INSTALL.W32
+++ b/src/lib/libssl/src/INSTALL.W32
@@ -4,7 +4,7 @@
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 of
6 this is tested on Win32 but it may also work in Win 3.1 with some 6 this is tested on Win32 but it may also work in Win 3.1 with some
7 modification. See the end of this file for Eric's original comments. 7 modification.
8 8
9 You need Perl for Win32 (available from http://www.activestate.com/ActivePerl) 9 You need Perl for Win32 (available from http://www.activestate.com/ActivePerl)
10 and one of the following C compilers: 10 and one of the following C compilers:
@@ -21,10 +21,12 @@
21 * Microsoft MASM (aka "ml") 21 * Microsoft MASM (aka "ml")
22 * Free Netwide Assembler NASM. 22 * Free Netwide Assembler NASM.
23 23
24 MASM was I believe distributed in the past with VC++ and it is also part of 24 MASM was at one point distributed with VC++. It is now distributed with some
25 the MSDN SDKs. It is no longer distributed as part of VC++ and can be hard 25 Microsoft DDKs, for example the Windows NT 4.0 DDK and the Windows 98 DDK. If
26 to get hold of. It can be purchased: see Microsoft's site for details at: 26 you do not have either of these DDKs then you can just download the binaries
27 http://www.microsoft.com/ 27 for the Windows 98 DDK and extract and rename the two files XXXXXml.exe and
28 XXXXXml.err, to ml.exe and ml.err and install somewhere on your PATH. Both
29 DDKs can be downloaded from the Microsoft developers site www.msdn.com.
28 30
29 NASM is freely available. Version 0.98 was used during testing: other versions 31 NASM is freely available. Version 0.98 was used during testing: other versions
30 may also work. It is available from many places, see for example: 32 may also work. It is available from many places, see for example:
@@ -59,7 +61,7 @@
59 > ms\do_ms 61 > ms\do_ms
60 62
61 If you get errors about things not having numbers assigned then check the 63 If you get errors about things not having numbers assigned then check the
62 troubleshooting section: you probably wont be able to compile it as it 64 troubleshooting section: you probably won't be able to compile it as it
63 stands. 65 stands.
64 66
65 Then from the VC++ environment at a prompt do: 67 Then from the VC++ environment at a prompt do:
@@ -145,12 +147,16 @@
145 assigned in the CVS tree: so anything linked against this version of the 147 assigned in the CVS tree: so anything linked against this version of the
146 library may need to be recompiled. 148 library may need to be recompiled.
147 149
148 If you get errors about unresolved externals then this means that either you 150 If you get errors about unresolved symbols there are several possible
149 didn't read the note above about functions not having numbers assigned or 151 causes.
150 someone forgot to add a function to the header file.
151 152
152 In this latter case check out the header file to see if the function is 153 If this happens when the DLL is being linked and you have disabled some
153 defined in the header file. 154 ciphers then it is possible the DEF file generator hasn't removed all
155 the disabled symbols: the easiest solution is to edit the DEF files manually
156 to delete them. The DEF files are ms\libeay32.def ms\ssleay32.def.
157
158 Another cause is if you missed or ignored the errors about missing numbers
159 mentioned above.
154 160
155 If you get warnings in the code then the compilation will halt. 161 If you get warnings in the code then the compilation will halt.
156 162
@@ -165,159 +171,13 @@
165 171
166 One final comment about compiling applications linked to the OpenSSL library. 172 One final comment about compiling applications linked to the OpenSSL library.
167 If you don't use the multithreaded DLL runtime library (/MD option) your 173 If you don't use the multithreaded DLL runtime library (/MD option) your
168 program will almost certainly crash: see the original SSLeay description 174 program will almost certainly crash because malloc gets confused -- the
169 below for more details. 175 OpenSSL DLLs are statically linked to one version, the application must
170 176 not use a different one. You might be able to work around such problems
171-------------------------------------------------------------------------------- 177 by adding CRYPTO_malloc_init() to your program before any calls to the
172The orignal Windows build instructions from SSLeay follow. 178 OpenSSL libraries: This tells the OpenSSL libraries to use the same
173Note: some of this may be out of date and no longer applicable. In particular 179 malloc(), free() and realloc() as the application. However there are many
174the Crypto_malloc_init() comment appears to be wrong: you always need to use 180 standard library functions used by OpenSSL that call malloc() internally
175the same runtime library as the DLL itself. 181 (e.g. fopen()), and OpenSSL cannot change these; so in general you cannot
176-------------------------------------------------------------------------------- 182 rely on CYRPTO_malloc_init() solving your problem, and you should
177 183 consistently use the multithreaded library.
178The Microsoft World.
179
180The good news, to build SSLeay for the Microsft World
181
182Windows 3.1 DLL's
183perl Configure VC-WIN16
184nmake -f ms\w31dll.mak
185
186Windows NT/95 DLL's
187perl Configure VC-WIN32
188nmake -f ms\ntdll.mak
189
190Now the bad news
191All builds were done using Microsofts Visual C++ 1.52c and [45].x.
192If you are a borland person, you are probably going to have to help me
193finish the stuff in util/pl/BC*pl
194
195All builds were made under Windows NT - this means long filenames, so
196you may have problems under Windows 3.1 but probably not under 95.
197
198Because file pointers don't work in DLL's under Windows 3.1 (well at
199least stdin/stdout don't and I don't like having to differentiate
200between these and other file pointers), I now use the BIO file-pointer
201module, which needs to be linked into your application. You can either
202use the memory buffer BIO for IO, or compile bss_file.c into your
203application, it is in the apps directory and is just a copy of
204crypto/buffer/bss_file.c with #define APPS_WIN16 added.
205I have not yet automated the makefile to automatically copy it into 'out'
206for a win 3.1 build....
207
208All callbacks passed into SSLeay for Windows 3.1 need to be of type
209_far _loadds.
210
211I don't support building with the pascal calling convention.
212
213The DLL and static builds are large memory model.
214
215To build static libraries for NT/95 or win 3.1
216
217perl util/mk1mf.pl VC-WIN32 > mf-stat.nt
218perl util/mk1mf.pl VC-WIN16 > mf-stat.w31
219for DLL's
220perl util/mk1mf.pl dll VC-WIN32 > mf-dll.nt
221perl util/mk1mf.pl dll VC-WIN16 > mf-dll.w31
222
223Again you will notice that if you dont have perl, you cannot do this.
224
225Now the next importaint issue. Running Configure!
226I have small assember code files for critical big number library operation
227in crypto/bn/asm. There is, asm code, object files and uuencode
228object files. They are
229x86nt32.asm - 32bit flat memory model assember - suitable Win32
230x86w16.asm - 16bit assember - used in the msdos build.
231x86w32.asm - 32bit assember, win 3.1 segments, used for win16 build.
232
233If you feel compelled to build the 16bit maths routines in the windows 3.1
234build,
235perl Configure VC-W31-16
236perl util/mk1mf.pl dll VC-W31-16 > mf-dll.w31
237
238If you hate assember and don't want anything to do with it,
239perl util/mk1mf.pl no-asm VC-WIN16 > mf-dll.w31
240will work for any of the makefile generations.
241
242There are more options to mk1mf.pl but these all leave the temporary
243files in 'tmp' and the output files in 'out' by default.
244
245The NT build is done for console mode.
246
247The Windows 3.1 version of SSLeay uses quickwin, the interface is ugly
248but it is better than nothing. If you want ugly, try doing anything
249that involves getting a password. I decided to be ugly instead of
250echoing characters. For Windows 3.1 I would just sugest using the
251msdos version of the ssleay application for command line work.
252The QuickWin build is primarily for testing.
253
254For both NT and Windows 3.1, I have not written the code so that
255s_client, s_server can take input from the keyboard. You can happily
256start applications up in separate windows, watch them handshake, and then sit
257there for-ever. I have not had the time to get this working, and I've
258been able to test things from a unix box to the NT box :-).
259Try running ssleay s_server on the windows box
260(with either -cert ../apps/server.pem -www)
261and run ssleay s_time from another window.
262This often stuffs up on Windows 3.1, but I'm not worried since this is
263probably a problem with my demo applications, not the libraries.
264
265After a build of one of the version of microsoft SSLeay,
266'cd ms' and then run 'test'. This should check everything out and
267even does a trial run of generating certificates.
268'test.bat' requires that perl be install, you be in the ms directory
269(not the test directory, thats for unix so stay out :-) and that the
270build output directory be ../out
271
272On a last note, you will probably get division by zero errors and
273stuff after a build. This is due to your own inability to follow
274instructions :-).
275
276The reasons for the problem is probably one of the following.
277
2781) You did not run Configure. This is critical for windows 3.1 when
279 using assember. The values in crypto/bn/bn.h must match the
280 ones requred for the assember code. (remember that if you
281 edit crypto/bn/bn.h by hand, it will be clobered the next time
282 you run Configure by the contents of crypto/bn/bn.org).
283 SSLeay version -o will list the compile options.
284 For VC-WIN32 you need bn(64,32) or bn(32,32)
285 For VC-W31-32/VC-WIN16 you need bn(32,32)
286 For VC-W31-16 you need bn(32,16) or bn(16,16)
287 For VC-MSDOS you need bn(32,16) or bn(16,16).
288
289 The first number will be 2 times bigger than the second if
290 BN_LLONG is defined in bn.h and the size of the second number
291 depends on the 'bits' defined at the start of bn.h. Have a
292 look, it's all reasonably clear.
293 If you want to start messing with 8 bit builds and things like
294 that, build without the assember by re-generating a makefile
295 via 'perl util/mk1mf.pl no-asm'.
2962) You tried to build under MS-DOS or Windows 3.1 using the /G3
297 option. Don't. It is buggy (thats why you just got that
298 error) and unless you want to work out which optimising flag
299 to turn off, I'm not going to help you :-). I also noticed
300 that code often ran slower when compiled with /G3.
3013) Under NT/95, malloc goes stupid. You are probably linking with
302 the wrong library, there are problems if you mix the threaded
303 and non-threaded libraries (due to the DLL being staticly
304 linked with one and the applicaion using another.
305
306Well hopefully thats most of the MS issues handled, see you in ssl-users :-).
307
308eric 30-Aug-1996
309
310SSLeay 0.6.5
311For Windows 95/NT, add CRYPTO_malloc_init() to your program before any
312calls to the SSLeay libraries. This function will insert callbacks so that
313the SSLeay libraries will use the same malloc(), free() and realloc() as
314your application so 'problem 3)' mentioned above will go away.
315
316There is now DES assember for Windows NT/95. The file is
317crypto/des/asm/win32.asm and replaces crypto/des/des_enc.c in the build.
318
319There is also Blowfish assember for Windows NT/95. The file is
320crypto/bf/asm/win32.asm and replaces crypto/bf/bf_enc.c in the build.
321
322eric 25-Jun-1997
323
diff --git a/src/lib/libssl/src/LICENSE b/src/lib/libssl/src/LICENSE
index b9e18d5e7b..bdd5f7bdd0 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-1999 The OpenSSL Project. All rights reserved. 15 * Copyright (c) 1998-2000 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/GUSI_Init.cpp b/src/lib/libssl/src/MacOS/GUSI_Init.cpp
new file mode 100644
index 0000000000..d8223dba2c
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GUSI_Init.cpp
@@ -0,0 +1,62 @@
1/**************** BEGIN GUSI CONFIGURATION ****************************
2 *
3 * GUSI Configuration section generated by GUSI Configurator
4 * last modified: Wed Jan 5 20:33:51 2000
5 *
6 * This section will be overwritten by the next run of Configurator.
7 */
8
9#define GUSI_SOURCE
10#include <GUSIConfig.h>
11#include <sys/cdefs.h>
12
13/* Declarations of Socket Factories */
14
15__BEGIN_DECLS
16void GUSIwithInetSockets();
17void GUSIwithLocalSockets();
18void GUSIwithMTInetSockets();
19void GUSIwithMTTcpSockets();
20void GUSIwithMTUdpSockets();
21void GUSIwithOTInetSockets();
22void GUSIwithOTTcpSockets();
23void GUSIwithOTUdpSockets();
24void GUSIwithPPCSockets();
25void GUSISetupFactories();
26__END_DECLS
27
28/* Configure Socket Factories */
29
30void GUSISetupFactories()
31{
32#ifdef GUSISetupFactories_BeginHook
33 GUSISetupFactories_BeginHook
34#endif
35 GUSIwithInetSockets();
36#ifdef GUSISetupFactories_EndHook
37 GUSISetupFactories_EndHook
38#endif
39}
40
41/* Declarations of File Devices */
42
43__BEGIN_DECLS
44void GUSIwithDConSockets();
45void GUSIwithNullSockets();
46void GUSISetupDevices();
47__END_DECLS
48
49/* Configure File Devices */
50
51void GUSISetupDevices()
52{
53#ifdef GUSISetupDevices_BeginHook
54 GUSISetupDevices_BeginHook
55#endif
56 GUSIwithNullSockets();
57#ifdef GUSISetupDevices_EndHook
58 GUSISetupDevices_EndHook
59#endif
60}
61
62/**************** END GUSI CONFIGURATION *************************/
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.cpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.cpp
new file mode 100644
index 0000000000..617aae2c70
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.cpp
@@ -0,0 +1,2753 @@
1/* ====================================================================
2 * Copyright (c) 1998-1999 The OpenSSL Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55
56
57 #include "CPStringUtils.hpp"
58#include "ErrorHandling.hpp"
59
60
61
62#define kNumberFormatString "\p########0.00#######;-########0.00#######"
63
64
65
66// Useful utility functions which could be optimized a whole lot
67
68
69void CopyPStrToCStr(const unsigned char *thePStr,char *theCStr,const int maxCStrLength)
70{
71int i,numPChars;
72
73
74 if (thePStr != nil && theCStr != nil && maxCStrLength > 0)
75 {
76 numPChars = thePStr[0];
77
78 for (i = 0;;i++)
79 {
80 if (i >= numPChars || i >= maxCStrLength - 1)
81 {
82 theCStr[i] = 0;
83
84 break;
85 }
86
87 else
88 {
89 theCStr[i] = thePStr[i + 1];
90 }
91 }
92 }
93}
94
95
96void CopyPStrToPStr(const unsigned char *theSrcPStr,unsigned char *theDstPStr,const int maxDstStrLength)
97{
98int theMaxDstStrLength;
99
100
101 theMaxDstStrLength = maxDstStrLength;
102
103
104 if (theDstPStr != nil && theSrcPStr != nil && theMaxDstStrLength > 0)
105 {
106 if (theMaxDstStrLength > 255)
107 {
108 theMaxDstStrLength = 255;
109 }
110
111
112 if (theMaxDstStrLength - 1 < theSrcPStr[0])
113 {
114 BlockMove(theSrcPStr + 1,theDstPStr + 1,theMaxDstStrLength - 1);
115
116 theDstPStr[0] = theMaxDstStrLength - 1;
117 }
118
119 else
120 {
121 BlockMove(theSrcPStr,theDstPStr,theSrcPStr[0] + 1);
122 }
123 }
124}
125
126
127void CopyCStrToCStr(const char *theSrcCStr,char *theDstCStr,const int maxDstStrLength)
128{
129int i;
130
131
132 if (theDstCStr != nil && theSrcCStr != nil && maxDstStrLength > 0)
133 {
134 for (i = 0;;i++)
135 {
136 if (theSrcCStr[i] == 0 || i >= maxDstStrLength - 1)
137 {
138 theDstCStr[i] = 0;
139
140 break;
141 }
142
143 else
144 {
145 theDstCStr[i] = theSrcCStr[i];
146 }
147 }
148 }
149}
150
151
152
153void CopyCSubstrToCStr(const char *theSrcCStr,const int maxCharsToCopy,char *theDstCStr,const int maxDstStrLength)
154{
155int i;
156
157
158 if (theDstCStr != nil && theSrcCStr != nil && maxDstStrLength > 0)
159 {
160 for (i = 0;;i++)
161 {
162 if (theSrcCStr[i] == 0 || i >= maxDstStrLength - 1 || i >= maxCharsToCopy)
163 {
164 theDstCStr[i] = 0;
165
166 break;
167 }
168
169 else
170 {
171 theDstCStr[i] = theSrcCStr[i];
172 }
173 }
174 }
175}
176
177
178
179void CopyCSubstrToPStr(const char *theSrcCStr,const int maxCharsToCopy,unsigned char *theDstPStr,const int maxDstStrLength)
180{
181int i;
182int theMaxDstStrLength;
183
184
185 theMaxDstStrLength = maxDstStrLength;
186
187 if (theDstPStr != nil && theSrcCStr != nil && theMaxDstStrLength > 0)
188 {
189 if (theMaxDstStrLength > 255)
190 {
191 theMaxDstStrLength = 255;
192 }
193
194
195 for (i = 0;;i++)
196 {
197 if (theSrcCStr[i] == 0 || i >= theMaxDstStrLength - 1 || i >= maxCharsToCopy)
198 {
199 theDstPStr[0] = i;
200
201 break;
202 }
203
204 else
205 {
206 theDstPStr[i + 1] = theSrcCStr[i];
207 }
208 }
209 }
210}
211
212
213
214void CopyCStrToPStr(const char *theSrcCStr,unsigned char *theDstPStr,const int maxDstStrLength)
215{
216int i;
217int theMaxDstStrLength;
218
219
220 theMaxDstStrLength = maxDstStrLength;
221
222 if (theDstPStr != nil && theSrcCStr != nil && theMaxDstStrLength > 0)
223 {
224 if (theMaxDstStrLength > 255)
225 {
226 theMaxDstStrLength = 255;
227 }
228
229
230 for (i = 0;;i++)
231 {
232 if (i >= theMaxDstStrLength - 1 || theSrcCStr[i] == 0)
233 {
234 theDstPStr[0] = i;
235
236 break;
237 }
238
239 else
240 {
241 theDstPStr[i + 1] = theSrcCStr[i];
242 }
243 }
244 }
245}
246
247
248void ConcatPStrToCStr(const unsigned char *thePStr,char *theCStr,const int maxCStrLength)
249{
250int i,numPChars,cStrLength;
251
252
253 if (thePStr != nil && theCStr != nil && maxCStrLength > 0)
254 {
255 for (cStrLength = 0;theCStr[cStrLength] != 0;cStrLength++)
256 {
257
258 }
259
260
261 numPChars = thePStr[0];
262
263
264 for (i = 0;;i++)
265 {
266 if (i >= numPChars || cStrLength >= maxCStrLength - 1)
267 {
268 theCStr[cStrLength++] = 0;
269
270 break;
271 }
272
273 else
274 {
275 theCStr[cStrLength++] = thePStr[i + 1];
276 }
277 }
278 }
279}
280
281
282
283void ConcatPStrToPStr(const unsigned char *theSrcPStr,unsigned char *theDstPStr,const int maxDstStrLength)
284{
285int theMaxDstStrLength;
286
287
288 theMaxDstStrLength = maxDstStrLength;
289
290 if (theSrcPStr != nil && theDstPStr != nil && theMaxDstStrLength > 0)
291 {
292 if (theMaxDstStrLength > 255)
293 {
294 theMaxDstStrLength = 255;
295 }
296
297
298 if (theMaxDstStrLength - theDstPStr[0] - 1 < theSrcPStr[0])
299 {
300 BlockMove(theSrcPStr + 1,theDstPStr + theDstPStr[0] + 1,theMaxDstStrLength - 1 - theDstPStr[0]);
301
302 theDstPStr[0] = theMaxDstStrLength - 1;
303 }
304
305 else
306 {
307 BlockMove(theSrcPStr + 1,theDstPStr + theDstPStr[0] + 1,theSrcPStr[0]);
308
309 theDstPStr[0] += theSrcPStr[0];
310 }
311 }
312}
313
314
315
316void ConcatCStrToPStr(const char *theSrcCStr,unsigned char *theDstPStr,const int maxDstStrLength)
317{
318int i,thePStrLength;
319int theMaxDstStrLength;
320
321
322 theMaxDstStrLength = maxDstStrLength;
323
324 if (theSrcCStr != nil && theDstPStr != nil && theMaxDstStrLength > 0)
325 {
326 if (theMaxDstStrLength > 255)
327 {
328 theMaxDstStrLength = 255;
329 }
330
331
332 thePStrLength = theDstPStr[0];
333
334 for (i = 0;;i++)
335 {
336 if (theSrcCStr[i] == 0 || thePStrLength >= theMaxDstStrLength - 1)
337 {
338 theDstPStr[0] = thePStrLength;
339
340 break;
341 }
342
343 else
344 {
345 theDstPStr[thePStrLength + 1] = theSrcCStr[i];
346
347 thePStrLength++;
348 }
349 }
350 }
351}
352
353
354
355void ConcatCStrToCStr(const char *theSrcCStr,char *theDstCStr,const int maxCStrLength)
356{
357int cStrLength;
358
359
360 if (theSrcCStr != nil && theDstCStr != nil && maxCStrLength > 0)
361 {
362 for (cStrLength = 0;theDstCStr[cStrLength] != 0;cStrLength++)
363 {
364
365 }
366
367
368 for (;;)
369 {
370 if (*theSrcCStr == 0 || cStrLength >= maxCStrLength - 1)
371 {
372 theDstCStr[cStrLength++] = 0;
373
374 break;
375 }
376
377 else
378 {
379 theDstCStr[cStrLength++] = *theSrcCStr++;
380 }
381 }
382 }
383}
384
385
386
387void ConcatCharToCStr(const char theChar,char *theDstCStr,const int maxCStrLength)
388{
389int cStrLength;
390
391
392 if (theDstCStr != nil && maxCStrLength > 0)
393 {
394 cStrLength = CStrLength(theDstCStr);
395
396 if (cStrLength < maxCStrLength - 1)
397 {
398 theDstCStr[cStrLength++] = theChar;
399 theDstCStr[cStrLength++] = '\0';
400 }
401 }
402}
403
404
405
406void ConcatCharToPStr(const char theChar,unsigned char *theDstPStr,const int maxPStrLength)
407{
408int pStrLength;
409
410
411 if (theDstPStr != nil && maxPStrLength > 0)
412 {
413 pStrLength = PStrLength(theDstPStr);
414
415 if (pStrLength < maxPStrLength - 1 && pStrLength < 255)
416 {
417 theDstPStr[pStrLength + 1] = theChar;
418 theDstPStr[0] += 1;
419 }
420 }
421}
422
423
424
425
426int CompareCStrs(const char *theFirstCStr,const char *theSecondCStr,const Boolean ignoreCase)
427{
428int returnValue;
429char firstChar,secondChar;
430
431
432 returnValue = 0;
433
434
435 if (theFirstCStr != nil && theSecondCStr != nil)
436 {
437 for (;;)
438 {
439 firstChar = *theFirstCStr;
440 secondChar = *theSecondCStr;
441
442 if (ignoreCase == true)
443 {
444 if (firstChar >= 'A' && firstChar <= 'Z')
445 {
446 firstChar = 'a' + (firstChar - 'A');
447 }
448
449 if (secondChar >= 'A' && secondChar <= 'Z')
450 {
451 secondChar = 'a' + (secondChar - 'A');
452 }
453 }
454
455
456 if (firstChar == 0 && secondChar != 0)
457 {
458 returnValue = -1;
459
460 break;
461 }
462
463 else if (firstChar != 0 && secondChar == 0)
464 {
465 returnValue = 1;
466
467 break;
468 }
469
470 else if (firstChar == 0 && secondChar == 0)
471 {
472 returnValue = 0;
473
474 break;
475 }
476
477 else if (firstChar < secondChar)
478 {
479 returnValue = -1;
480
481 break;
482 }
483
484 else if (firstChar > secondChar)
485 {
486 returnValue = 1;
487
488 break;
489 }
490
491 theFirstCStr++;
492 theSecondCStr++;
493 }
494 }
495
496
497 return(returnValue);
498}
499
500
501
502Boolean CStrsAreEqual(const char *theFirstCStr,const char *theSecondCStr,const Boolean ignoreCase)
503{
504 if (CompareCStrs(theFirstCStr,theSecondCStr,ignoreCase) == 0)
505 {
506 return true;
507 }
508
509 else
510 {
511 return false;
512 }
513}
514
515
516Boolean PStrsAreEqual(const unsigned char *theFirstPStr,const unsigned char *theSecondPStr,const Boolean ignoreCase)
517{
518 if (ComparePStrs(theFirstPStr,theSecondPStr,ignoreCase) == 0)
519 {
520 return true;
521 }
522
523 else
524 {
525 return false;
526 }
527}
528
529
530
531int ComparePStrs(const unsigned char *theFirstPStr,const unsigned char *theSecondPStr,const Boolean ignoreCase)
532{
533int i,returnValue;
534char firstChar,secondChar;
535
536
537 returnValue = 0;
538
539
540 if (theFirstPStr != nil && theSecondPStr != nil)
541 {
542 for (i = 1;;i++)
543 {
544 firstChar = theFirstPStr[i];
545 secondChar = theSecondPStr[i];
546
547 if (ignoreCase == true)
548 {
549 if (firstChar >= 'A' && firstChar <= 'Z')
550 {
551 firstChar = 'a' + (firstChar - 'A');
552 }
553
554 if (secondChar >= 'A' && secondChar <= 'Z')
555 {
556 secondChar = 'a' + (secondChar - 'A');
557 }
558 }
559
560
561 if (theFirstPStr[0] < i && theSecondPStr[0] >= i)
562 {
563 returnValue = -1;
564
565 break;
566 }
567
568 else if (theFirstPStr[0] >= i && theSecondPStr[0] < i)
569 {
570 returnValue = 1;
571
572 break;
573 }
574
575 else if (theFirstPStr[0] < i && theSecondPStr[0] < i)
576 {
577 returnValue = 0;
578
579 break;
580 }
581
582 else if (firstChar < secondChar)
583 {
584 returnValue = -1;
585
586 break;
587 }
588
589 else if (firstChar > secondChar)
590 {
591 returnValue = 1;
592
593 break;
594 }
595 }
596 }
597
598
599 return(returnValue);
600}
601
602
603
604int CompareCStrToPStr(const char *theCStr,const unsigned char *thePStr,const Boolean ignoreCase)
605{
606int returnValue;
607char tempString[256];
608
609
610 returnValue = 0;
611
612 if (theCStr != nil && thePStr != nil)
613 {
614 CopyPStrToCStr(thePStr,tempString,sizeof(tempString));
615
616 returnValue = CompareCStrs(theCStr,tempString,ignoreCase);
617 }
618
619
620 return(returnValue);
621}
622
623
624
625void ConcatLongIntToCStr(const long theNum,char *theCStr,const int maxCStrLength,const int numDigits)
626{
627Str255 theStr255;
628
629
630 NumToString(theNum,theStr255);
631
632
633 if (numDigits > 0)
634 {
635 int charsToInsert;
636
637
638 charsToInsert = numDigits - PStrLength(theStr255);
639
640 if (charsToInsert > 0)
641 {
642 char tempString[256];
643
644 CopyCStrToCStr("",tempString,sizeof(tempString));
645
646 for (;charsToInsert > 0;charsToInsert--)
647 {
648 ConcatCStrToCStr("0",tempString,sizeof(tempString));
649 }
650
651 ConcatPStrToCStr(theStr255,tempString,sizeof(tempString));
652
653 CopyCStrToPStr(tempString,theStr255,sizeof(theStr255));
654 }
655 }
656
657
658 ConcatPStrToCStr(theStr255,theCStr,maxCStrLength);
659}
660
661
662
663
664void ConcatLongIntToPStr(const long theNum,unsigned char *thePStr,const int maxPStrLength,const int numDigits)
665{
666Str255 theStr255;
667
668
669 NumToString(theNum,theStr255);
670
671
672 if (numDigits > 0)
673 {
674 int charsToInsert;
675
676
677 charsToInsert = numDigits - PStrLength(theStr255);
678
679 if (charsToInsert > 0)
680 {
681 char tempString[256];
682
683 CopyCStrToCStr("",tempString,sizeof(tempString));
684
685 for (;charsToInsert > 0;charsToInsert--)
686 {
687 ConcatCStrToCStr("0",tempString,sizeof(tempString));
688 }
689
690 ConcatPStrToCStr(theStr255,tempString,sizeof(tempString));
691
692 CopyCStrToPStr(tempString,theStr255,sizeof(theStr255));
693 }
694 }
695
696
697 ConcatPStrToPStr(theStr255,thePStr,maxPStrLength);
698}
699
700
701
702void CopyCStrAndConcatLongIntToCStr(const char *theSrcCStr,const long theNum,char *theDstCStr,const int maxDstStrLength)
703{
704 CopyCStrToCStr(theSrcCStr,theDstCStr,maxDstStrLength);
705
706 ConcatLongIntToCStr(theNum,theDstCStr,maxDstStrLength);
707}
708
709
710
711void CopyLongIntToCStr(const long theNum,char *theCStr,const int maxCStrLength,const int numDigits)
712{
713Str255 theStr255;
714
715
716 NumToString(theNum,theStr255);
717
718
719 if (numDigits > 0)
720 {
721 int charsToInsert;
722
723
724 charsToInsert = numDigits - PStrLength(theStr255);
725
726 if (charsToInsert > 0)
727 {
728 char tempString[256];
729
730 CopyCStrToCStr("",tempString,sizeof(tempString));
731
732 for (;charsToInsert > 0;charsToInsert--)
733 {
734 ConcatCStrToCStr("0",tempString,sizeof(tempString));
735 }
736
737 ConcatPStrToCStr(theStr255,tempString,sizeof(tempString));
738
739 CopyCStrToPStr(tempString,theStr255,sizeof(theStr255));
740 }
741 }
742
743
744 CopyPStrToCStr(theStr255,theCStr,maxCStrLength);
745}
746
747
748
749
750
751void CopyUnsignedLongIntToCStr(const unsigned long theNum,char *theCStr,const int maxCStrLength)
752{
753char tempString[256];
754int srcCharIndex,dstCharIndex;
755unsigned long tempNum,quotient,remainder;
756
757
758 if (theNum == 0)
759 {
760 CopyCStrToCStr("0",theCStr,maxCStrLength);
761 }
762
763 else
764 {
765 srcCharIndex = 0;
766
767 tempNum = theNum;
768
769 for (;;)
770 {
771 if (srcCharIndex >= sizeof(tempString) - 1 || tempNum == 0)
772 {
773 for (dstCharIndex = 0;;)
774 {
775 if (dstCharIndex >= maxCStrLength - 1 || srcCharIndex <= 0)
776 {
777 theCStr[dstCharIndex] = 0;
778
779 break;
780 }
781
782 theCStr[dstCharIndex++] = tempString[--srcCharIndex];
783 }
784
785 break;
786 }
787
788
789 quotient = tempNum / 10;
790
791 remainder = tempNum - (quotient * 10);
792
793 tempString[srcCharIndex] = '0' + remainder;
794
795 srcCharIndex++;
796
797 tempNum = quotient;
798 }
799 }
800}
801
802
803
804
805void CopyLongIntToPStr(const long theNum,unsigned char *thePStr,const int maxPStrLength,const int numDigits)
806{
807char tempString[256];
808
809
810 CopyLongIntToCStr(theNum,tempString,sizeof(tempString),numDigits);
811
812 CopyCStrToPStr(tempString,thePStr,maxPStrLength);
813}
814
815
816
817OSErr CopyLongIntToNewHandle(const long inTheLongInt,Handle *theHandle)
818{
819OSErr errCode = noErr;
820char tempString[32];
821
822
823 CopyLongIntToCStr(inTheLongInt,tempString,sizeof(tempString));
824
825 errCode = CopyCStrToNewHandle(tempString,theHandle);
826
827 return(errCode);
828}
829
830
831OSErr CopyLongIntToExistingHandle(const long inTheLongInt,Handle theHandle)
832{
833OSErr errCode = noErr;
834char tempString[32];
835
836
837 CopyLongIntToCStr(inTheLongInt,tempString,sizeof(tempString));
838
839 errCode = CopyCStrToExistingHandle(tempString,theHandle);
840
841 return(errCode);
842}
843
844
845
846
847OSErr CopyCStrToExistingHandle(const char *theCString,Handle theHandle)
848{
849OSErr errCode = noErr;
850long stringLength;
851
852
853 if (theCString == nil)
854 {
855 SetErrorMessageAndBail(("CopyCStrToExistingHandle: Bad parameter, theCString == nil"));
856 }
857
858 if (theHandle == nil)
859 {
860 SetErrorMessageAndBail(("CopyCStrToExistingHandle: Bad parameter, theHandle == nil"));
861 }
862
863 if (*theHandle == nil)
864 {
865 SetErrorMessageAndBail(("CopyCStrToExistingHandle: Bad parameter, *theHandle == nil"));
866 }
867
868
869
870 stringLength = CStrLength(theCString) + 1;
871
872 SetHandleSize(theHandle,stringLength);
873
874 if (GetHandleSize(theHandle) < stringLength)
875 {
876 SetErrorMessageAndLongIntAndBail("CopyCStrToExistingHandle: Can't set Handle size, MemError() = ",MemError());
877 }
878
879
880 ::BlockMove(theCString,*theHandle,stringLength);
881
882
883EXITPOINT:
884
885 return(errCode);
886}
887
888
889
890
891
892OSErr CopyCStrToNewHandle(const char *theCString,Handle *theHandle)
893{
894OSErr errCode = noErr;
895long stringLength;
896
897
898 if (theCString == nil)
899 {
900 SetErrorMessageAndBail(("CopyCStrToNewHandle: Bad parameter, theCString == nil"));
901 }
902
903 if (theHandle == nil)
904 {
905 SetErrorMessageAndBail(("CopyCStrToNewHandle: Bad parameter, theHandle == nil"));
906 }
907
908
909
910 stringLength = CStrLength(theCString) + 1;
911
912 *theHandle = NewHandle(stringLength);
913
914 if (*theHandle == nil)
915 {
916 SetErrorMessageAndLongIntAndBail("CopyCStrToNewHandle: Can't allocate Handle, MemError() = ",MemError());
917 }
918
919
920 ::BlockMove(theCString,**theHandle,stringLength);
921
922
923EXITPOINT:
924
925 return(errCode);
926}
927
928
929
930OSErr CopyPStrToNewHandle(const unsigned char *thePString,Handle *theHandle)
931{
932OSErr errCode = noErr;
933long stringLength;
934
935
936 if (thePString == nil)
937 {
938 SetErrorMessageAndBail(("CopyPStrToNewHandle: Bad parameter, thePString == nil"));
939 }
940
941 if (theHandle == nil)
942 {
943 SetErrorMessageAndBail(("CopyPStrToNewHandle: Bad parameter, theHandle == nil"));
944 }
945
946
947
948 stringLength = PStrLength(thePString) + 1;
949
950 *theHandle = NewHandle(stringLength);
951
952 if (*theHandle == nil)
953 {
954 SetErrorMessageAndLongIntAndBail("CopyPStrToNewHandle: Can't allocate Handle, MemError() = ",MemError());
955 }
956
957
958 if (stringLength > 1)
959 {
960 BlockMove(thePString + 1,**theHandle,stringLength - 1);
961 }
962
963 (**theHandle)[stringLength - 1] = 0;
964
965
966EXITPOINT:
967
968 return(errCode);
969}
970
971
972OSErr AppendPStrToHandle(const unsigned char *thePString,Handle theHandle,long *currentLength)
973{
974OSErr errCode = noErr;
975char tempString[256];
976
977
978 CopyPStrToCStr(thePString,tempString,sizeof(tempString));
979
980 errCode = AppendCStrToHandle(tempString,theHandle,currentLength);
981
982
983EXITPOINT:
984
985 return(errCode);
986}
987
988
989
990OSErr AppendCStrToHandle(const char *theCString,Handle theHandle,long *currentLength,long *maxLength)
991{
992OSErr errCode = noErr;
993long handleMaxLength,handleCurrentLength,stringLength,byteCount;
994
995
996 if (theCString == nil)
997 {
998 SetErrorMessageAndBail(("AppendCStrToHandle: Bad parameter, theCString == nil"));
999 }
1000
1001 if (theHandle == nil)
1002 {
1003 SetErrorMessageAndBail(("AppendCStrToHandle: Bad parameter, theHandle == nil"));
1004 }
1005
1006
1007 if (maxLength != nil)
1008 {
1009 handleMaxLength = *maxLength;
1010 }
1011
1012 else
1013 {
1014 handleMaxLength = GetHandleSize(theHandle);
1015 }
1016
1017
1018 if (currentLength != nil && *currentLength >= 0)
1019 {
1020 handleCurrentLength = *currentLength;
1021 }
1022
1023 else
1024 {
1025 handleCurrentLength = CStrLength(*theHandle);
1026 }
1027
1028
1029 stringLength = CStrLength(theCString);
1030
1031 byteCount = handleCurrentLength + stringLength + 1;
1032
1033 if (byteCount > handleMaxLength)
1034 {
1035 SetHandleSize(theHandle,handleCurrentLength + stringLength + 1);
1036
1037 if (maxLength != nil)
1038 {
1039 *maxLength = GetHandleSize(theHandle);
1040
1041 handleMaxLength = *maxLength;
1042 }
1043
1044 else
1045 {
1046 handleMaxLength = GetHandleSize(theHandle);
1047 }
1048
1049 if (byteCount > handleMaxLength)
1050 {
1051 SetErrorMessageAndLongIntAndBail("AppendCStrToHandle: Can't increase Handle allocation, MemError() = ",MemError());
1052 }
1053 }
1054
1055
1056 BlockMove(theCString,*theHandle + handleCurrentLength,stringLength + 1);
1057
1058
1059 if (currentLength != nil)
1060 {
1061 *currentLength += stringLength;
1062 }
1063
1064
1065 errCode = noErr;
1066
1067
1068EXITPOINT:
1069
1070 return(errCode);
1071}
1072
1073
1074
1075OSErr AppendCharsToHandle(const char *theChars,const int numChars,Handle theHandle,long *currentLength,long *maxLength)
1076{
1077OSErr errCode = noErr;
1078long handleMaxLength,handleCurrentLength,byteCount;
1079
1080
1081 if (theChars == nil)
1082 {
1083 SetErrorMessageAndBail(("AppendCharsToHandle: Bad parameter, theChars == nil"));
1084 }
1085
1086 if (theHandle == nil)
1087 {
1088 SetErrorMessageAndBail(("AppendCharsToHandle: Bad parameter, theHandle == nil"));
1089 }
1090
1091
1092 if (maxLength != nil)
1093 {
1094 handleMaxLength = *maxLength;
1095 }
1096
1097 else
1098 {
1099 handleMaxLength = GetHandleSize(theHandle);
1100 }
1101
1102
1103 if (currentLength != nil && *currentLength >= 0)
1104 {
1105 handleCurrentLength = *currentLength;
1106 }
1107
1108 else
1109 {
1110 handleCurrentLength = CStrLength(*theHandle);
1111 }
1112
1113
1114 byteCount = handleCurrentLength + numChars + 1;
1115
1116 if (byteCount > handleMaxLength)
1117 {
1118 SetHandleSize(theHandle,handleCurrentLength + numChars + 1);
1119
1120 if (maxLength != nil)
1121 {
1122 *maxLength = GetHandleSize(theHandle);
1123
1124 handleMaxLength = *maxLength;
1125 }
1126
1127 else
1128 {
1129 handleMaxLength = GetHandleSize(theHandle);
1130 }
1131
1132 if (byteCount > handleMaxLength)
1133 {
1134 SetErrorMessageAndLongIntAndBail("AppendCharsToHandle: Can't increase Handle allocation, MemError() = ",MemError());
1135 }
1136 }
1137
1138
1139 BlockMove(theChars,*theHandle + handleCurrentLength,numChars);
1140
1141 (*theHandle)[handleCurrentLength + numChars] = '\0';
1142
1143 if (currentLength != nil)
1144 {
1145 *currentLength += numChars;
1146 }
1147
1148
1149 errCode = noErr;
1150
1151
1152EXITPOINT:
1153
1154 return(errCode);
1155}
1156
1157
1158
1159OSErr AppendLongIntToHandle(const long inTheLongInt,Handle theHandle,long *currentLength)
1160{
1161OSErr errCode = noErr;
1162char tempString[32];
1163
1164
1165 CopyLongIntToCStr(inTheLongInt,tempString,sizeof(tempString));
1166
1167 errCode = AppendCStrToHandle(tempString,theHandle,currentLength);
1168
1169 return(errCode);
1170}
1171
1172
1173
1174
1175long CStrLength(const char *theCString)
1176{
1177long cStrLength = 0;
1178
1179
1180 if (theCString != nil)
1181 {
1182 for (cStrLength = 0;theCString[cStrLength] != 0;cStrLength++)
1183 {
1184
1185 }
1186 }
1187
1188
1189 return(cStrLength);
1190}
1191
1192
1193
1194long PStrLength(const unsigned char *thePString)
1195{
1196long pStrLength = 0;
1197
1198
1199 if (thePString != nil)
1200 {
1201 pStrLength = thePString[0];
1202 }
1203
1204
1205 return(pStrLength);
1206}
1207
1208
1209
1210
1211
1212void ZeroMem(void *theMemPtr,const unsigned long numBytes)
1213{
1214unsigned char *theBytePtr;
1215unsigned long *theLongPtr;
1216unsigned long numSingleBytes;
1217unsigned long theNumBytes;
1218
1219
1220 theNumBytes = numBytes;
1221
1222 if (theMemPtr != nil && theNumBytes > 0)
1223 {
1224 theBytePtr = (unsigned char *) theMemPtr;
1225
1226 numSingleBytes = (unsigned long) theBytePtr & 0x0003;
1227
1228 while (numSingleBytes > 0)
1229 {
1230 *theBytePtr++ = 0;
1231
1232 theNumBytes--;
1233 numSingleBytes--;
1234 }
1235
1236
1237 theLongPtr = (unsigned long *) theBytePtr;
1238
1239 while (theNumBytes >= 4)
1240 {
1241 *theLongPtr++ = 0;
1242
1243 theNumBytes -= 4;
1244 }
1245
1246
1247 theBytePtr = (unsigned char *) theLongPtr;
1248
1249 while (theNumBytes > 0)
1250 {
1251 *theBytePtr++ = 0;
1252
1253 theNumBytes--;
1254 }
1255 }
1256}
1257
1258
1259
1260
1261char *FindCharInCStr(const char theChar,const char *theCString)
1262{
1263char *theStringSearchPtr;
1264
1265
1266 theStringSearchPtr = (char *) theCString;
1267
1268 if (theStringSearchPtr != nil)
1269 {
1270 while (*theStringSearchPtr != '\0' && *theStringSearchPtr != theChar)
1271 {
1272 theStringSearchPtr++;
1273 }
1274
1275 if (*theStringSearchPtr == '\0')
1276 {
1277 theStringSearchPtr = nil;
1278 }
1279 }
1280
1281 return(theStringSearchPtr);
1282}
1283
1284
1285
1286long FindCharOffsetInCStr(const char theChar,const char *theCString,const Boolean inIgnoreCase)
1287{
1288long theOffset = -1;
1289
1290
1291 if (theCString != nil)
1292 {
1293 theOffset = 0;
1294
1295
1296 if (inIgnoreCase)
1297 {
1298 char searchChar = theChar;
1299
1300 if (searchChar >= 'a' && searchChar <= 'z')
1301 {
1302 searchChar = searchChar - 'a' + 'A';
1303 }
1304
1305
1306 while (*theCString != 0)
1307 {
1308 char currentChar = *theCString;
1309
1310 if (currentChar >= 'a' && currentChar <= 'z')
1311 {
1312 currentChar = currentChar - 'a' + 'A';
1313 }
1314
1315 if (currentChar == searchChar)
1316 {
1317 break;
1318 }
1319
1320 theCString++;
1321 theOffset++;
1322 }
1323 }
1324
1325 else
1326 {
1327 while (*theCString != 0 && *theCString != theChar)
1328 {
1329 theCString++;
1330 theOffset++;
1331 }
1332 }
1333
1334 if (*theCString == 0)
1335 {
1336 theOffset = -1;
1337 }
1338 }
1339
1340 return(theOffset);
1341}
1342
1343
1344long FindCStrOffsetInCStr(const char *theCSubstring,const char *theCString,const Boolean inIgnoreCase)
1345{
1346long theOffset = -1;
1347
1348
1349 if (theCSubstring != nil && theCString != nil)
1350 {
1351 for (theOffset = 0;;theOffset++)
1352 {
1353 if (theCString[theOffset] == 0)
1354 {
1355 theOffset = -1;
1356
1357 goto EXITPOINT;
1358 }
1359
1360
1361 for (const char *tempSubstringPtr = theCSubstring,*tempCStringPtr = theCString + theOffset;;tempSubstringPtr++,tempCStringPtr++)
1362 {
1363 if (*tempSubstringPtr == 0)
1364 {
1365 goto EXITPOINT;
1366 }
1367
1368 else if (*tempCStringPtr == 0)
1369 {
1370 break;
1371 }
1372
1373 char searchChar = *tempSubstringPtr;
1374 char currentChar = *tempCStringPtr;
1375
1376 if (inIgnoreCase && searchChar >= 'a' && searchChar <= 'z')
1377 {
1378 searchChar = searchChar - 'a' + 'A';
1379 }
1380
1381 if (inIgnoreCase && currentChar >= 'a' && currentChar <= 'z')
1382 {
1383 currentChar = currentChar - 'a' + 'A';
1384 }
1385
1386 if (currentChar != searchChar)
1387 {
1388 break;
1389 }
1390 }
1391 }
1392
1393 theOffset = -1;
1394 }
1395
1396
1397EXITPOINT:
1398
1399 return(theOffset);
1400}
1401
1402
1403
1404void InsertCStrIntoCStr(const char *theSrcCStr,const int theInsertionOffset,char *theDstCStr,const int maxDstStrLength)
1405{
1406int currentLength;
1407int insertLength;
1408int numCharsToInsert;
1409int numCharsToShift;
1410
1411
1412 if (theDstCStr != nil && theSrcCStr != nil && maxDstStrLength > 0 && theInsertionOffset < maxDstStrLength - 1)
1413 {
1414 currentLength = CStrLength(theDstCStr);
1415
1416 insertLength = CStrLength(theSrcCStr);
1417
1418
1419 if (theInsertionOffset + insertLength < maxDstStrLength - 1)
1420 {
1421 numCharsToInsert = insertLength;
1422 }
1423
1424 else
1425 {
1426 numCharsToInsert = maxDstStrLength - 1 - theInsertionOffset;
1427 }
1428
1429
1430 if (numCharsToInsert + currentLength < maxDstStrLength - 1)
1431 {
1432 numCharsToShift = currentLength - theInsertionOffset;
1433 }
1434
1435 else
1436 {
1437 numCharsToShift = maxDstStrLength - 1 - theInsertionOffset - numCharsToInsert;
1438 }
1439
1440
1441 if (numCharsToShift > 0)
1442 {
1443 BlockMove(theDstCStr + theInsertionOffset,theDstCStr + theInsertionOffset + numCharsToInsert,numCharsToShift);
1444 }
1445
1446 if (numCharsToInsert > 0)
1447 {
1448 BlockMove(theSrcCStr,theDstCStr + theInsertionOffset,numCharsToInsert);
1449 }
1450
1451 theDstCStr[theInsertionOffset + numCharsToInsert + numCharsToShift] = 0;
1452 }
1453}
1454
1455
1456
1457void InsertPStrIntoCStr(const unsigned char *theSrcPStr,const int theInsertionOffset,char *theDstCStr,const int maxDstStrLength)
1458{
1459int currentLength;
1460int insertLength;
1461int numCharsToInsert;
1462int numCharsToShift;
1463
1464
1465 if (theDstCStr != nil && theSrcPStr != nil && maxDstStrLength > 0 && theInsertionOffset < maxDstStrLength - 1)
1466 {
1467 currentLength = CStrLength(theDstCStr);
1468
1469 insertLength = PStrLength(theSrcPStr);
1470
1471
1472 if (theInsertionOffset + insertLength < maxDstStrLength - 1)
1473 {
1474 numCharsToInsert = insertLength;
1475 }
1476
1477 else
1478 {
1479 numCharsToInsert = maxDstStrLength - 1 - theInsertionOffset;
1480 }
1481
1482
1483 if (numCharsToInsert + currentLength < maxDstStrLength - 1)
1484 {
1485 numCharsToShift = currentLength - theInsertionOffset;
1486 }
1487
1488 else
1489 {
1490 numCharsToShift = maxDstStrLength - 1 - theInsertionOffset - numCharsToInsert;
1491 }
1492
1493
1494 if (numCharsToShift > 0)
1495 {
1496 BlockMove(theDstCStr + theInsertionOffset,theDstCStr + theInsertionOffset + numCharsToInsert,numCharsToShift);
1497 }
1498
1499 if (numCharsToInsert > 0)
1500 {
1501 BlockMove(theSrcPStr + 1,theDstCStr + theInsertionOffset,numCharsToInsert);
1502 }
1503
1504 theDstCStr[theInsertionOffset + numCharsToInsert + numCharsToShift] = 0;
1505 }
1506}
1507
1508
1509
1510OSErr InsertCStrIntoHandle(const char *theCString,Handle theHandle,const long inInsertOffset)
1511{
1512OSErr errCode;
1513int currentLength;
1514int insertLength;
1515
1516
1517 SetErrorMessageAndBailIfNil(theCString,"InsertCStrIntoHandle: Bad parameter, theCString == nil");
1518
1519 SetErrorMessageAndBailIfNil(theHandle,"InsertCStrIntoHandle: Bad parameter, theHandle == nil");
1520
1521 currentLength = CStrLength(*theHandle);
1522
1523 if (currentLength + 1 > ::GetHandleSize(theHandle))
1524 {
1525 SetErrorMessageAndBail("InsertCStrIntoHandle: Handle has been overflowed");
1526 }
1527
1528 if (inInsertOffset > currentLength)
1529 {
1530 SetErrorMessageAndBail("InsertCStrIntoHandle: Insertion offset is greater than string length");
1531 }
1532
1533 insertLength = CStrLength(theCString);
1534
1535 ::SetHandleSize(theHandle,currentLength + 1 + insertLength);
1536
1537 if (::GetHandleSize(theHandle) < currentLength + 1 + insertLength)
1538 {
1539 SetErrorMessageAndLongIntAndBail("InsertCStrIntoHandle: Can't expand storage for Handle, MemError() = ",MemError());
1540 }
1541
1542 ::BlockMove(*theHandle + inInsertOffset,*theHandle + inInsertOffset + insertLength,currentLength - inInsertOffset + 1);
1543
1544 ::BlockMove(theCString,*theHandle + inInsertOffset,insertLength);
1545
1546
1547 errCode = noErr;
1548
1549
1550EXITPOINT:
1551
1552 return(errCode);
1553}
1554
1555
1556
1557
1558void CopyCStrAndInsert1LongIntIntoCStr(const char *theSrcCStr,const long theNum,char *theDstCStr,const int maxDstStrLength)
1559{
1560 CopyCStrAndInsertCStrLongIntIntoCStr(theSrcCStr,nil,theNum,theDstCStr,maxDstStrLength);
1561}
1562
1563
1564void CopyCStrAndInsert2LongIntsIntoCStr(const char *theSrcCStr,const long long1,const long long2,char *theDstCStr,const int maxDstStrLength)
1565{
1566const long theLongInts[] = { long1,long2 };
1567
1568 CopyCStrAndInsertCStrsLongIntsIntoCStr(theSrcCStr,nil,theLongInts,theDstCStr,maxDstStrLength);
1569}
1570
1571
1572void CopyCStrAndInsert3LongIntsIntoCStr(const char *theSrcCStr,const long long1,const long long2,const long long3,char *theDstCStr,const int maxDstStrLength)
1573{
1574const long theLongInts[] = { long1,long2,long3 };
1575
1576 CopyCStrAndInsertCStrsLongIntsIntoCStr(theSrcCStr,nil,theLongInts,theDstCStr,maxDstStrLength);
1577}
1578
1579
1580void CopyCStrAndInsertCStrIntoCStr(const char *theSrcCStr,const char *theInsertCStr,char *theDstCStr,const int maxDstStrLength)
1581{
1582const char *theCStrs[2] = { theInsertCStr,nil };
1583
1584 CopyCStrAndInsertCStrsLongIntsIntoCStr(theSrcCStr,theCStrs,nil,theDstCStr,maxDstStrLength);
1585}
1586
1587
1588
1589void CopyCStrAndInsertCStrLongIntIntoCStr(const char *theSrcCStr,const char *theInsertCStr,const long theNum,char *theDstCStr,const int maxDstStrLength)
1590{
1591const char *theCStrs[2] = { theInsertCStr,nil };
1592const long theLongInts[1] = { theNum };
1593
1594 CopyCStrAndInsertCStrsLongIntsIntoCStr(theSrcCStr,theCStrs,theLongInts,theDstCStr,maxDstStrLength);
1595}
1596
1597
1598
1599void CopyCStrAndInsertCStrsLongIntsIntoCStr(const char *theSrcCStr,const char **theInsertCStrs,const long *theLongInts,char *theDstCStr,const int maxDstStrLength)
1600{
1601int dstCharIndex,srcCharIndex,theMaxDstStrLength;
1602int theCStrIndex = 0;
1603int theLongIntIndex = 0;
1604
1605
1606 theMaxDstStrLength = maxDstStrLength;
1607
1608 if (theDstCStr != nil && theSrcCStr != nil && theMaxDstStrLength > 0)
1609 {
1610 dstCharIndex = 0;
1611
1612 srcCharIndex = 0;
1613
1614
1615 // Allow room for NULL at end of string
1616
1617 theMaxDstStrLength--;
1618
1619
1620 for (;;)
1621 {
1622 // Hit end of buffer?
1623
1624 if (dstCharIndex >= theMaxDstStrLength)
1625 {
1626 theDstCStr[dstCharIndex++] = 0;
1627
1628 goto EXITPOINT;
1629 }
1630
1631 // End of source string?
1632
1633 else if (theSrcCStr[srcCharIndex] == 0)
1634 {
1635 theDstCStr[dstCharIndex++] = 0;
1636
1637 goto EXITPOINT;
1638 }
1639
1640 // Did we find a '%s'?
1641
1642 else if (theInsertCStrs != nil && theInsertCStrs[theCStrIndex] != nil && theSrcCStr[srcCharIndex] == '%' && theSrcCStr[srcCharIndex + 1] == 's')
1643 {
1644 // Skip over the '%s'
1645
1646 srcCharIndex += 2;
1647
1648
1649 // Terminate the dest string and then concat the string
1650
1651 theDstCStr[dstCharIndex] = 0;
1652
1653 ConcatCStrToCStr(theInsertCStrs[theCStrIndex],theDstCStr,theMaxDstStrLength);
1654
1655 dstCharIndex = CStrLength(theDstCStr);
1656
1657 theCStrIndex++;
1658 }
1659
1660 // Did we find a '%ld'?
1661
1662 else if (theLongInts != nil && theSrcCStr[srcCharIndex] == '%' && theSrcCStr[srcCharIndex + 1] == 'l' && theSrcCStr[srcCharIndex + 2] == 'd')
1663 {
1664 // Skip over the '%ld'
1665
1666 srcCharIndex += 3;
1667
1668
1669 // Terminate the dest string and then concat the number
1670
1671 theDstCStr[dstCharIndex] = 0;
1672
1673 ConcatLongIntToCStr(theLongInts[theLongIntIndex],theDstCStr,theMaxDstStrLength);
1674
1675 theLongIntIndex++;
1676
1677 dstCharIndex = CStrLength(theDstCStr);
1678 }
1679
1680 else
1681 {
1682 theDstCStr[dstCharIndex++] = theSrcCStr[srcCharIndex++];
1683 }
1684 }
1685 }
1686
1687
1688
1689EXITPOINT:
1690
1691 return;
1692}
1693
1694
1695
1696
1697
1698OSErr CopyCStrAndInsertCStrLongIntIntoHandle(const char *theSrcCStr,const char *theInsertCStr,const long theNum,Handle *theHandle)
1699{
1700OSErr errCode;
1701long byteCount;
1702
1703
1704 if (theHandle != nil)
1705 {
1706 byteCount = CStrLength(theSrcCStr) + CStrLength(theInsertCStr) + 32;
1707
1708 *theHandle = NewHandle(byteCount);
1709
1710 if (*theHandle == nil)
1711 {
1712 SetErrorMessageAndLongIntAndBail("CopyCStrAndInsertCStrLongIntIntoHandle: Can't allocate Handle, MemError() = ",MemError());
1713 }
1714
1715
1716 HLock(*theHandle);
1717
1718 CopyCStrAndInsertCStrLongIntIntoCStr(theSrcCStr,theInsertCStr,theNum,**theHandle,byteCount);
1719
1720 HUnlock(*theHandle);
1721 }
1722
1723 errCode = noErr;
1724
1725
1726EXITPOINT:
1727
1728 return(errCode);
1729}
1730
1731
1732
1733
1734
1735OSErr CopyIndexedWordToCStr(char *theSrcCStr,int whichWord,char *theDstCStr,int maxDstCStrLength)
1736{
1737OSErr errCode;
1738char *srcCharPtr,*dstCharPtr;
1739int wordCount;
1740int byteCount;
1741
1742
1743 if (theSrcCStr == nil)
1744 {
1745 SetErrorMessageAndBail(("CopyIndexedWordToCStr: Bad parameter, theSrcCStr == nil"));
1746 }
1747
1748 if (theDstCStr == nil)
1749 {
1750 SetErrorMessageAndBail(("CopyIndexedWordToCStr: Bad parameter, theDstCStr == nil"));
1751 }
1752
1753 if (whichWord < 0)
1754 {
1755 SetErrorMessageAndBail(("CopyIndexedWordToCStr: Bad parameter, whichWord < 0"));
1756 }
1757
1758 if (maxDstCStrLength <= 0)
1759 {
1760 SetErrorMessageAndBail(("CopyIndexedWordToCStr: Bad parameter, maxDstCStrLength <= 0"));
1761 }
1762
1763
1764 *theDstCStr = '\0';
1765
1766 srcCharPtr = theSrcCStr;
1767
1768 while (*srcCharPtr == ' ' || *srcCharPtr == '\t')
1769 {
1770 srcCharPtr++;
1771 }
1772
1773
1774 for (wordCount = 0;wordCount < whichWord;wordCount++)
1775 {
1776 while (*srcCharPtr != ' ' && *srcCharPtr != '\t' && *srcCharPtr != '\r' && *srcCharPtr != '\n' && *srcCharPtr != '\0')
1777 {
1778 srcCharPtr++;
1779 }
1780
1781 if (*srcCharPtr == '\r' || *srcCharPtr == '\n' || *srcCharPtr == '\0')
1782 {
1783 errCode = noErr;
1784
1785 goto EXITPOINT;
1786 }
1787
1788 while (*srcCharPtr == ' ' || *srcCharPtr == '\t')
1789 {
1790 srcCharPtr++;
1791 }
1792
1793 if (*srcCharPtr == '\r' || *srcCharPtr == '\n' || *srcCharPtr == '\0')
1794 {
1795 errCode = noErr;
1796
1797 goto EXITPOINT;
1798 }
1799 }
1800
1801
1802 dstCharPtr = theDstCStr;
1803 byteCount = 0;
1804
1805
1806 for(;;)
1807 {
1808 if (byteCount >= maxDstCStrLength - 1 || *srcCharPtr == '\0' || *srcCharPtr == ' ' || *srcCharPtr == '\t' || *srcCharPtr == '\r' || *srcCharPtr == '\n')
1809 {
1810 *dstCharPtr = '\0';
1811 break;
1812 }
1813
1814 *dstCharPtr++ = *srcCharPtr++;
1815
1816 byteCount++;
1817 }
1818
1819
1820 errCode = noErr;
1821
1822
1823EXITPOINT:
1824
1825 return(errCode);
1826}
1827
1828
1829
1830
1831
1832OSErr CopyIndexedWordToNewHandle(char *theSrcCStr,int whichWord,Handle *outTheHandle)
1833{
1834OSErr errCode;
1835char *srcCharPtr;
1836int wordCount;
1837int byteCount;
1838
1839
1840 if (theSrcCStr == nil)
1841 {
1842 SetErrorMessageAndBail(("CopyIndexedWordToNewHandle: Bad parameter, theSrcCStr == nil"));
1843 }
1844
1845 if (outTheHandle == nil)
1846 {
1847 SetErrorMessageAndBail(("CopyIndexedWordToNewHandle: Bad parameter, outTheHandle == nil"));
1848 }
1849
1850 if (whichWord < 0)
1851 {
1852 SetErrorMessageAndBail(("CopyIndexedWordToNewHandle: Bad parameter, whichWord < 0"));
1853 }
1854
1855
1856 *outTheHandle = nil;
1857
1858
1859 srcCharPtr = theSrcCStr;
1860
1861 while (*srcCharPtr == ' ' || *srcCharPtr == '\t')
1862 {
1863 srcCharPtr++;
1864 }
1865
1866
1867 for (wordCount = 0;wordCount < whichWord;wordCount++)
1868 {
1869 while (*srcCharPtr != ' ' && *srcCharPtr != '\t' && *srcCharPtr != '\r' && *srcCharPtr != '\n' && *srcCharPtr != '\0')
1870 {
1871 srcCharPtr++;
1872 }
1873
1874 if (*srcCharPtr == '\r' || *srcCharPtr == '\n' || *srcCharPtr == '\0')
1875 {
1876 break;
1877 }
1878
1879 while (*srcCharPtr == ' ' || *srcCharPtr == '\t')
1880 {
1881 srcCharPtr++;
1882 }
1883
1884 if (*srcCharPtr == '\r' || *srcCharPtr == '\n' || *srcCharPtr == '\0')
1885 {
1886 break;
1887 }
1888 }
1889
1890
1891 for (byteCount = 0;;byteCount++)
1892 {
1893 if (srcCharPtr[byteCount] == ' ' || srcCharPtr[byteCount] == '\t' || srcCharPtr[byteCount] == '\r' || srcCharPtr[byteCount] == '\n' || srcCharPtr[byteCount] == '\0')
1894 {
1895 break;
1896 }
1897 }
1898
1899
1900 *outTheHandle = NewHandle(byteCount + 1);
1901
1902 if (*outTheHandle == nil)
1903 {
1904 SetErrorMessageAndLongIntAndBail("CopyIndexedWordToNewHandle: Can't allocate Handle, MemError() = ",MemError());
1905 }
1906
1907
1908 ::BlockMove(srcCharPtr,**outTheHandle,byteCount);
1909
1910 (**outTheHandle)[byteCount] = '\0';
1911
1912 errCode = noErr;
1913
1914
1915EXITPOINT:
1916
1917 return(errCode);
1918}
1919
1920
1921
1922OSErr CopyIndexedLineToCStr(const char *theSrcCStr,int inWhichLine,int *lineEndIndex,Boolean *gotLastLine,char *theDstCStr,const int maxDstCStrLength)
1923{
1924OSErr errCode;
1925int theCurrentLine;
1926int theCurrentLineOffset;
1927int theEOSOffset;
1928
1929
1930 if (theSrcCStr == nil)
1931 {
1932 SetErrorMessageAndBail(("CopyIndexedLineToCStr: Bad parameter, theSrcCStr == nil"));
1933 }
1934
1935 if (theDstCStr == nil)
1936 {
1937 SetErrorMessageAndBail(("CopyIndexedLineToCStr: Bad parameter, theDstCStr == nil"));
1938 }
1939
1940 if (inWhichLine < 0)
1941 {
1942 SetErrorMessageAndBail(("CopyIndexedLineToCStr: Bad parameter, inWhichLine < 0"));
1943 }
1944
1945 if (maxDstCStrLength <= 0)
1946 {
1947 SetErrorMessageAndBail(("CopyIndexedLineToCStr: Bad parameter, maxDstCStrLength <= 0"));
1948 }
1949
1950
1951 if (gotLastLine != nil)
1952 {
1953 *gotLastLine = false;
1954 }
1955
1956
1957 *theDstCStr = 0;
1958
1959 theCurrentLineOffset = 0;
1960
1961 theCurrentLine = 0;
1962
1963
1964 while (theCurrentLine < inWhichLine)
1965 {
1966 while (theSrcCStr[theCurrentLineOffset] != '\r' && theSrcCStr[theCurrentLineOffset] != 0)
1967 {
1968 theCurrentLineOffset++;
1969 }
1970
1971 if (theSrcCStr[theCurrentLineOffset] == 0)
1972 {
1973 break;
1974 }
1975
1976 theCurrentLineOffset++;
1977 theCurrentLine++;
1978 }
1979
1980 if (theSrcCStr[theCurrentLineOffset] == 0)
1981 {
1982 SetErrorMessageAndLongIntAndBail("CopyIndexedLineToCStr: Too few lines in source text, can't get line ",inWhichLine);
1983 }
1984
1985
1986 theEOSOffset = FindCharOffsetInCStr('\r',theSrcCStr + theCurrentLineOffset);
1987
1988 if (theEOSOffset >= 0)
1989 {
1990 CopyCSubstrToCStr(theSrcCStr + theCurrentLineOffset,theEOSOffset,theDstCStr,maxDstCStrLength);
1991
1992 if (gotLastLine != nil)
1993 {
1994 *gotLastLine = false;
1995 }
1996
1997 if (lineEndIndex != nil)
1998 {
1999 *lineEndIndex = theEOSOffset;
2000 }
2001 }
2002
2003 else
2004 {
2005 theEOSOffset = CStrLength(theSrcCStr + theCurrentLineOffset);
2006
2007 CopyCSubstrToCStr(theSrcCStr + theCurrentLineOffset,theEOSOffset,theDstCStr,maxDstCStrLength);
2008
2009 if (gotLastLine != nil)
2010 {
2011 *gotLastLine = true;
2012 }
2013
2014 if (lineEndIndex != nil)
2015 {
2016 *lineEndIndex = theEOSOffset;
2017 }
2018 }
2019
2020
2021 errCode = noErr;
2022
2023
2024EXITPOINT:
2025
2026 return(errCode);
2027}
2028
2029
2030
2031OSErr CopyIndexedLineToNewHandle(const char *theSrcCStr,int inWhichLine,Handle *outNewHandle)
2032{
2033OSErr errCode;
2034int theCurrentLine;
2035int theCurrentLineOffset;
2036int byteCount;
2037
2038
2039 SetErrorMessageAndBailIfNil(theSrcCStr,"CopyIndexedLineToNewHandle: Bad parameter, theSrcCStr == nil");
2040 SetErrorMessageAndBailIfNil(outNewHandle,"CopyIndexedLineToNewHandle: Bad parameter, outNewHandle == nil");
2041
2042 if (inWhichLine < 0)
2043 {
2044 SetErrorMessageAndBail(("CopyIndexedLineToNewHandle: Bad parameter, inWhichLine < 0"));
2045 }
2046
2047
2048 theCurrentLineOffset = 0;
2049
2050 theCurrentLine = 0;
2051
2052
2053 while (theCurrentLine < inWhichLine)
2054 {
2055 while (theSrcCStr[theCurrentLineOffset] != '\r' && theSrcCStr[theCurrentLineOffset] != '\0')
2056 {
2057 theCurrentLineOffset++;
2058 }
2059
2060 if (theSrcCStr[theCurrentLineOffset] == '\0')
2061 {
2062 break;
2063 }
2064
2065 theCurrentLineOffset++;
2066 theCurrentLine++;
2067 }
2068
2069 if (theSrcCStr[theCurrentLineOffset] == '\0')
2070 {
2071 SetErrorMessageAndLongIntAndBail("CopyIndexedLineToNewHandle: Too few lines in source text, can't get line #",inWhichLine);
2072 }
2073
2074
2075 byteCount = 0;
2076
2077 while (theSrcCStr[theCurrentLineOffset + byteCount] != '\r' && theSrcCStr[theCurrentLineOffset + byteCount] != '\0')
2078 {
2079 byteCount++;
2080 }
2081
2082
2083 *outNewHandle = NewHandle(byteCount + 1);
2084
2085 if (*outNewHandle == nil)
2086 {
2087 SetErrorMessageAndLongIntAndBail("CopyIndexedLineToNewHandle: Can't allocate Handle, MemError() = ",MemError());
2088 }
2089
2090 ::BlockMove(theSrcCStr + theCurrentLineOffset,**outNewHandle,byteCount);
2091
2092 (**outNewHandle)[byteCount] = '\0';
2093
2094 errCode = noErr;
2095
2096
2097EXITPOINT:
2098
2099 return(errCode);
2100}
2101
2102
2103
2104
2105OSErr CountDigits(const char *inCStr,int *outNumIntegerDigits,int *outNumFractDigits)
2106{
2107OSErr errCode = noErr;
2108int numIntDigits = 0;
2109int numFractDigits = 0;
2110int digitIndex = 0;
2111
2112
2113 SetErrorMessageAndBailIfNil(inCStr,"CountDigits: Bad parameter, theSrcCStr == nil");
2114 SetErrorMessageAndBailIfNil(outNumIntegerDigits,"CountDigits: Bad parameter, outNumIntegerDigits == nil");
2115 SetErrorMessageAndBailIfNil(outNumFractDigits,"CountDigits: Bad parameter, outNumFractDigits == nil");
2116
2117 digitIndex = 0;
2118
2119 while (inCStr[digitIndex] >= '0' && inCStr[digitIndex] <= '9')
2120 {
2121 digitIndex++;
2122 numIntDigits++;
2123 }
2124
2125 if (inCStr[digitIndex] == '.')
2126 {
2127 digitIndex++;
2128
2129 while (inCStr[digitIndex] >= '0' && inCStr[digitIndex] <= '9')
2130 {
2131 digitIndex++;
2132 numFractDigits++;
2133 }
2134 }
2135
2136 *outNumIntegerDigits = numIntDigits;
2137
2138 *outNumFractDigits = numFractDigits;
2139
2140 errCode = noErr;
2141
2142EXITPOINT:
2143
2144 return(errCode);
2145}
2146
2147
2148
2149OSErr ExtractIntFromCStr(const char *theSrcCStr,int *outInt,Boolean skipLeadingSpaces)
2150{
2151OSErr errCode;
2152int theCharIndex;
2153
2154
2155 if (theSrcCStr == nil)
2156 {
2157 SetErrorMessageAndBail(("ExtractIntFromCStr: Bad parameter, theSrcCStr == nil"));
2158 }
2159
2160 if (outInt == nil)
2161 {
2162 SetErrorMessageAndBail(("ExtractIntFromCStr: Bad parameter, outInt == nil"));
2163 }
2164
2165
2166 *outInt = 0;
2167
2168 theCharIndex = 0;
2169
2170 if (skipLeadingSpaces == true)
2171 {
2172 while (theSrcCStr[theCharIndex] == ' ')
2173 {
2174 theCharIndex++;
2175 }
2176 }
2177
2178 if (theSrcCStr[theCharIndex] < '0' || theSrcCStr[theCharIndex] > '9')
2179 {
2180 SetErrorMessageAndBail(("ExtractIntFromCStr: Bad parameter, theSrcCStr contains a bogus numeric representation"));
2181 }
2182
2183
2184 while (theSrcCStr[theCharIndex] >= '0' && theSrcCStr[theCharIndex] <= '9')
2185 {
2186 *outInt = (*outInt * 10) + (theSrcCStr[theCharIndex] - '0');
2187
2188 theCharIndex++;
2189 }
2190
2191
2192 errCode = noErr;
2193
2194
2195EXITPOINT:
2196
2197 return(errCode);
2198}
2199
2200
2201
2202OSErr ExtractIntFromPStr(const unsigned char *theSrcPStr,int *outInt,Boolean skipLeadingSpaces)
2203{
2204OSErr errCode;
2205char theCStr[256];
2206
2207
2208 if (theSrcPStr == nil)
2209 {
2210 SetErrorMessageAndBail(("ExtractIntFromPStr: Bad parameter, theSrcPStr == nil"));
2211 }
2212
2213 if (outInt == nil)
2214 {
2215 SetErrorMessageAndBail(("ExtractIntFromPStr: Bad parameter, outInt == nil"));
2216 }
2217
2218
2219 CopyPStrToCStr(theSrcPStr,theCStr,sizeof(theCStr));
2220
2221
2222 errCode = ExtractIntFromCStr(theCStr,outInt,skipLeadingSpaces);
2223
2224
2225EXITPOINT:
2226
2227 return(errCode);
2228}
2229
2230
2231
2232int CountOccurencesOfCharInCStr(const char inChar,const char *inSrcCStr)
2233{
2234int theSrcCharIndex;
2235int numOccurrences = -1;
2236
2237
2238 if (inSrcCStr != nil && inChar != '\0')
2239 {
2240 numOccurrences = 0;
2241
2242 for (theSrcCharIndex = 0;inSrcCStr[theSrcCharIndex] != '\0';theSrcCharIndex++)
2243 {
2244 if (inSrcCStr[theSrcCharIndex] == inChar)
2245 {
2246 numOccurrences++;
2247 }
2248 }
2249 }
2250
2251 return(numOccurrences);
2252}
2253
2254
2255int CountWordsInCStr(const char *inSrcCStr)
2256{
2257int numWords = -1;
2258
2259
2260 if (inSrcCStr != nil)
2261 {
2262 numWords = 0;
2263
2264 // Skip lead spaces
2265
2266 while (*inSrcCStr == ' ')
2267 {
2268 inSrcCStr++;
2269 }
2270
2271 while (*inSrcCStr != '\0')
2272 {
2273 numWords++;
2274
2275 while (*inSrcCStr != ' ' && *inSrcCStr != '\0')
2276 {
2277 inSrcCStr++;
2278 }
2279
2280 while (*inSrcCStr == ' ')
2281 {
2282 inSrcCStr++;
2283 }
2284 }
2285 }
2286
2287 return(numWords);
2288}
2289
2290
2291
2292
2293void ConvertCStrToUpperCase(char *theSrcCStr)
2294{
2295char *theCharPtr;
2296
2297
2298 if (theSrcCStr != nil)
2299 {
2300 theCharPtr = theSrcCStr;
2301
2302 while (*theCharPtr != 0)
2303 {
2304 if (*theCharPtr >= 'a' && *theCharPtr <= 'z')
2305 {
2306 *theCharPtr = *theCharPtr - 'a' + 'A';
2307 }
2308
2309 theCharPtr++;
2310 }
2311 }
2312}
2313
2314
2315
2316
2317
2318
2319
2320void ExtractCStrItemFromCStr(const char *inSrcCStr,const char inItemDelimiter,const int inItemNumber,Boolean *foundItem,char *outDstCharPtr,const int inDstCharPtrMaxLength,const Boolean inTreatMultipleDelimsAsSingleDelim)
2321{
2322int theItem;
2323int theSrcCharIndex;
2324int theDstCharIndex;
2325
2326
2327 if (foundItem != nil)
2328 {
2329 *foundItem = false;
2330 }
2331
2332
2333 if (outDstCharPtr != nil && inDstCharPtrMaxLength > 0 && inItemNumber >= 0 && inItemDelimiter != 0)
2334 {
2335 *outDstCharPtr = 0;
2336
2337
2338 theSrcCharIndex = 0;
2339
2340 for (theItem = 0;theItem < inItemNumber;theItem++)
2341 {
2342 while (inSrcCStr[theSrcCharIndex] != inItemDelimiter && inSrcCStr[theSrcCharIndex] != '\0')
2343 {
2344 theSrcCharIndex++;
2345 }
2346
2347 if (inSrcCStr[theSrcCharIndex] == inItemDelimiter)
2348 {
2349 theSrcCharIndex++;
2350
2351 if (inTreatMultipleDelimsAsSingleDelim)
2352 {
2353 while (inSrcCStr[theSrcCharIndex] == inItemDelimiter)
2354 {
2355 theSrcCharIndex++;
2356 }
2357 }
2358 }
2359
2360
2361 if (inSrcCStr[theSrcCharIndex] == '\0')
2362 {
2363 goto EXITPOINT;
2364 }
2365 }
2366
2367
2368 if (foundItem != nil)
2369 {
2370 *foundItem = true;
2371 }
2372
2373
2374 theDstCharIndex = 0;
2375
2376 for (;;)
2377 {
2378 if (inSrcCStr[theSrcCharIndex] == 0 || inSrcCStr[theSrcCharIndex] == inItemDelimiter || theDstCharIndex >= inDstCharPtrMaxLength - 1)
2379 {
2380 outDstCharPtr[theDstCharIndex] = 0;
2381
2382 break;
2383 }
2384
2385 outDstCharPtr[theDstCharIndex++] = inSrcCStr[theSrcCharIndex++];
2386 }
2387 }
2388
2389
2390EXITPOINT:
2391
2392 return;
2393}
2394
2395
2396
2397OSErr ExtractCStrItemFromCStrIntoNewHandle(const char *inSrcCStr,const char inItemDelimiter,const int inItemNumber,Boolean *foundItem,Handle *outNewHandle,const Boolean inTreatMultipleDelimsAsSingleDelim)
2398{
2399OSErr errCode;
2400int theItem;
2401int theSrcCharIndex;
2402int theItemLength;
2403
2404
2405 if (inSrcCStr == nil)
2406 {
2407 SetErrorMessage("ExtractCStrItemFromCStrIntoNewHandle: Bad parameter, inSrcCStr == nil");
2408 errCode = kGenericError;
2409 goto EXITPOINT;
2410 }
2411
2412 if (outNewHandle == nil)
2413 {
2414 SetErrorMessage("ExtractCStrItemFromCStrIntoNewHandle: Bad parameter, outNewHandle == nil");
2415 errCode = kGenericError;
2416 goto EXITPOINT;
2417 }
2418
2419 if (foundItem == nil)
2420 {
2421 SetErrorMessage("ExtractCStrItemFromCStrIntoNewHandle: Bad parameter, foundItem == nil");
2422 errCode = kGenericError;
2423 goto EXITPOINT;
2424 }
2425
2426 if (inItemNumber < 0)
2427 {
2428 SetErrorMessage("ExtractCStrItemFromCStrIntoNewHandle: Bad parameter, inItemNumber < 0");
2429 errCode = kGenericError;
2430 goto EXITPOINT;
2431 }
2432
2433 if (inItemDelimiter == 0)
2434 {
2435 SetErrorMessage("ExtractCStrItemFromCStrIntoNewHandle: Bad parameter, inItemDelimiter == 0");
2436 errCode = kGenericError;
2437 goto EXITPOINT;
2438 }
2439
2440
2441 *foundItem = false;
2442
2443 theSrcCharIndex = 0;
2444
2445 for (theItem = 0;theItem < inItemNumber;theItem++)
2446 {
2447 while (inSrcCStr[theSrcCharIndex] != inItemDelimiter && inSrcCStr[theSrcCharIndex] != '\0')
2448 {
2449 theSrcCharIndex++;
2450 }
2451
2452 if (inSrcCStr[theSrcCharIndex] == inItemDelimiter)
2453 {
2454 theSrcCharIndex++;
2455
2456 if (inTreatMultipleDelimsAsSingleDelim)
2457 {
2458 while (inSrcCStr[theSrcCharIndex] == inItemDelimiter)
2459 {
2460 theSrcCharIndex++;
2461 }
2462 }
2463 }
2464
2465
2466 if (inSrcCStr[theSrcCharIndex] == '\0')
2467 {
2468 errCode = noErr;
2469
2470 goto EXITPOINT;
2471 }
2472 }
2473
2474
2475 *foundItem = true;
2476
2477
2478 for (theItemLength = 0;;theItemLength++)
2479 {
2480 if (inSrcCStr[theSrcCharIndex + theItemLength] == 0 || inSrcCStr[theSrcCharIndex + theItemLength] == inItemDelimiter)
2481 {
2482 break;
2483 }
2484 }
2485
2486
2487 *outNewHandle = NewHandle(theItemLength + 1);
2488
2489 if (*outNewHandle == nil)
2490 {
2491 SetErrorMessageAndLongIntAndBail("ExtractCStrItemFromCStrIntoNewHandle: Can't allocate Handle, MemError() = ",MemError());
2492 }
2493
2494
2495 BlockMove(inSrcCStr + theSrcCharIndex,**outNewHandle,theItemLength);
2496
2497 (**outNewHandle)[theItemLength] = 0;
2498
2499 errCode = noErr;
2500
2501
2502EXITPOINT:
2503
2504 return(errCode);
2505}
2506
2507
2508
2509
2510
2511
2512OSErr ExtractFloatFromCStr(const char *inCString,extended80 *outFloat)
2513{
2514OSErr errCode;
2515Str255 theStr255;
2516Handle theNumberPartsTableHandle = nil;
2517long theNumberPartsOffset,theNumberPartsLength;
2518FormatResultType theFormatResultType;
2519NumberParts theNumberPartsTable;
2520NumFormatStringRec theNumFormatStringRec;
2521
2522
2523 if (inCString == nil)
2524 {
2525 SetErrorMessage("ExtractFloatFromCStr: Bad parameter, inCString == nil");
2526 errCode = kGenericError;
2527 goto EXITPOINT;
2528 }
2529
2530 if (outFloat == nil)
2531 {
2532 SetErrorMessage("ExtractFloatFromCStr: Bad parameter, outFloat == nil");
2533 errCode = kGenericError;
2534 goto EXITPOINT;
2535 }
2536
2537
2538// GetIntlResourceTable(smRoman,smNumberPartsTable,&theNumberPartsTableHandle,&theNumberPartsOffset,&theNumberPartsLength);
2539
2540 GetIntlResourceTable(GetScriptManagerVariable(smSysScript),smNumberPartsTable,&theNumberPartsTableHandle,&theNumberPartsOffset,&theNumberPartsLength);
2541
2542 if (theNumberPartsTableHandle == nil)
2543 {
2544 SetErrorMessage("ExtractFloatFromCStr: Can't get number parts table for converting string representations to/from numeric representations");
2545 errCode = kGenericError;
2546 goto EXITPOINT;
2547 }
2548
2549 if (theNumberPartsLength > sizeof(theNumberPartsTable))
2550 {
2551 SetErrorMessage("ExtractFloatFromCStr: Number parts table has bad length");
2552 errCode = kGenericError;
2553 goto EXITPOINT;
2554 }
2555
2556
2557 BlockMove(*theNumberPartsTableHandle + theNumberPartsOffset,&theNumberPartsTable,theNumberPartsLength);
2558
2559
2560 theFormatResultType = (FormatResultType) StringToFormatRec(kNumberFormatString,&theNumberPartsTable,&theNumFormatStringRec);
2561
2562 if (theFormatResultType != fFormatOK)
2563 {
2564 SetErrorMessage("ExtractFloatFromCStr: StringToFormatRec() != fFormatOK");
2565 errCode = kGenericError;
2566 goto EXITPOINT;
2567 }
2568
2569
2570 CopyCStrToPStr(inCString,theStr255,sizeof(theStr255));
2571
2572
2573 theFormatResultType = (FormatResultType) StringToExtended(theStr255,&theNumFormatStringRec,&theNumberPartsTable,outFloat);
2574
2575 if (theFormatResultType != fFormatOK && theFormatResultType != fBestGuess)
2576 {
2577 SetErrorMessageAndLongIntAndBail("ExtractFloatFromCStr: StringToExtended() = ",theFormatResultType);
2578 }
2579
2580
2581 errCode = noErr;
2582
2583
2584EXITPOINT:
2585
2586 return(errCode);
2587}
2588
2589
2590
2591OSErr CopyFloatToCStr(const extended80 *theFloat,char *theCStr,const int maxCStrLength,const int inMaxNumIntDigits,const int inMaxNumFractDigits)
2592{
2593OSErr errCode;
2594Str255 theStr255;
2595Handle theNumberPartsTableHandle = nil;
2596long theNumberPartsOffset,theNumberPartsLength;
2597FormatResultType theFormatResultType;
2598NumberParts theNumberPartsTable;
2599NumFormatStringRec theNumFormatStringRec;
2600
2601
2602 if (theCStr == nil)
2603 {
2604 SetErrorMessage("CopyFloatToCStr: Bad parameter, theCStr == nil");
2605 errCode = kGenericError;
2606 goto EXITPOINT;
2607 }
2608
2609 if (theFloat == nil)
2610 {
2611 SetErrorMessage("CopyFloatToCStr: Bad parameter, theFloat == nil");
2612 errCode = kGenericError;
2613 goto EXITPOINT;
2614 }
2615
2616
2617// GetIntlResourceTable(smRoman,smNumberPartsTable,&theNumberPartsTableHandle,&theNumberPartsOffset,&theNumberPartsLength);
2618
2619 GetIntlResourceTable(GetScriptManagerVariable(smSysScript),smNumberPartsTable,&theNumberPartsTableHandle,&theNumberPartsOffset,&theNumberPartsLength);
2620
2621 if (theNumberPartsTableHandle == nil)
2622 {
2623 SetErrorMessage("CopyFloatToCStr: Can't get number parts table for converting string representations to/from numeric representations");
2624 errCode = kGenericError;
2625 goto EXITPOINT;
2626 }
2627
2628 if (theNumberPartsLength > sizeof(theNumberPartsTable))
2629 {
2630 SetErrorMessage("CopyFloatToCStr: Number parts table has bad length");
2631 errCode = kGenericError;
2632 goto EXITPOINT;
2633 }
2634
2635
2636 BlockMove(*theNumberPartsTableHandle + theNumberPartsOffset,&theNumberPartsTable,theNumberPartsLength);
2637
2638
2639 if (inMaxNumIntDigits >= 0 || inMaxNumFractDigits >= 0)
2640 {
2641 char numberFormat[64];
2642 int numberFormatLength = 0;
2643
2644 for (int i = 0;i < inMaxNumIntDigits && numberFormatLength < sizeof(numberFormat) - 1;i++)
2645 {
2646 numberFormat[numberFormatLength++] = '0';
2647 }
2648
2649 if (inMaxNumFractDigits > 0 && numberFormatLength < sizeof(numberFormat) - 1)
2650 {
2651 numberFormat[numberFormatLength++] = '.';
2652
2653 for (int i = 0;i < inMaxNumFractDigits && numberFormatLength < sizeof(numberFormat) - 1;i++)
2654 {
2655 numberFormat[numberFormatLength++] = '0';
2656 }
2657 }
2658
2659
2660 if (numberFormatLength < sizeof(numberFormat) - 1)
2661 {
2662 numberFormat[numberFormatLength++] = ';';
2663 }
2664
2665 if (numberFormatLength < sizeof(numberFormat) - 1)
2666 {
2667 numberFormat[numberFormatLength++] = '-';
2668 }
2669
2670
2671 for (int i = 0;i < inMaxNumIntDigits && numberFormatLength < sizeof(numberFormat) - 1;i++)
2672 {
2673 numberFormat[numberFormatLength++] = '0';
2674 }
2675
2676 if (inMaxNumFractDigits > 0 && numberFormatLength < sizeof(numberFormat) - 1)
2677 {
2678 numberFormat[numberFormatLength++] = '.';
2679
2680 for (int i = 0;i < inMaxNumFractDigits && numberFormatLength < sizeof(numberFormat) - 1;i++)
2681 {
2682 numberFormat[numberFormatLength++] = '0';
2683 }
2684 }
2685
2686 numberFormat[numberFormatLength] = '\0';
2687
2688
2689 Str255 tempStr255;
2690
2691 CopyCStrToPStr(numberFormat,tempStr255,sizeof(tempStr255));
2692
2693 theFormatResultType = (FormatResultType) StringToFormatRec(tempStr255,&theNumberPartsTable,&theNumFormatStringRec);
2694 }
2695
2696 else
2697 {
2698 theFormatResultType = (FormatResultType) StringToFormatRec(kNumberFormatString,&theNumberPartsTable,&theNumFormatStringRec);
2699 }
2700
2701 if (theFormatResultType != fFormatOK)
2702 {
2703 SetErrorMessage("CopyFloatToCStr: StringToFormatRec() != fFormatOK");
2704 errCode = kGenericError;
2705 goto EXITPOINT;
2706 }
2707
2708
2709 theFormatResultType = (FormatResultType) ExtendedToString(theFloat,&theNumFormatStringRec,&theNumberPartsTable,theStr255);
2710
2711 if (theFormatResultType != fFormatOK)
2712 {
2713 SetErrorMessage("CopyFloatToCStr: ExtendedToString() != fFormatOK");
2714 errCode = kGenericError;
2715 goto EXITPOINT;
2716 }
2717
2718
2719 CopyPStrToCStr(theStr255,theCStr,maxCStrLength);
2720
2721 errCode = noErr;
2722
2723
2724EXITPOINT:
2725
2726 return(errCode);
2727}
2728
2729
2730
2731
2732
2733void SkipWhiteSpace(char **ioSrcCharPtr,const Boolean inStopAtEOL)
2734{
2735 if (ioSrcCharPtr != nil && *ioSrcCharPtr != nil)
2736 {
2737 if (inStopAtEOL)
2738 {
2739 while ((**ioSrcCharPtr == ' ' || **ioSrcCharPtr == '\t') && **ioSrcCharPtr != '\r' && **ioSrcCharPtr != '\n')
2740 {
2741 *ioSrcCharPtr++;
2742 }
2743 }
2744
2745 else
2746 {
2747 while (**ioSrcCharPtr == ' ' || **ioSrcCharPtr == '\t')
2748 {
2749 *ioSrcCharPtr++;
2750 }
2751 }
2752 }
2753}
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.hpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.hpp
new file mode 100644
index 0000000000..5045c41019
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/CPStringUtils.hpp
@@ -0,0 +1,104 @@
1#pragma once
2
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7void CopyPStrToCStr(const unsigned char *thePStr,char *theCStr,const int maxCStrLength);
8void CopyPStrToPStr(const unsigned char *theSrcPStr,unsigned char *theDstPStr,const int maxDstStrLength);
9void CopyCStrToCStr(const char *theSrcCStr,char *theDstCStr,const int maxDstStrLength);
10void CopyCStrToPStr(const char *theSrcCStr,unsigned char *theDstPStr,const int maxDstStrLength);
11void ConcatPStrToCStr(const unsigned char *thePStr,char *theCStr,const int maxCStrLength);
12void ConcatPStrToPStr(const unsigned char *theSrcPStr,unsigned char *theDstPStr,const int maxDstStrLength);
13void ConcatCStrToPStr(const char *theSrcCStr,unsigned char *theDstPStr,const int maxDstStrLength);
14void ConcatCStrToCStr(const char *theSrcCStr,char *theDstCStr,const int maxCStrLength);
15
16void ConcatCharToCStr(const char theChar,char *theDstCStr,const int maxCStrLength);
17void ConcatCharToPStr(const char theChar,unsigned char *theDstPStr,const int maxPStrLength);
18
19int ComparePStrs(const unsigned char *theFirstPStr,const unsigned char *theSecondPStr,const Boolean ignoreCase = true);
20int CompareCStrs(const char *theFirstCStr,const char *theSecondCStr,const Boolean ignoreCase = true);
21int CompareCStrToPStr(const char *theCStr,const unsigned char *thePStr,const Boolean ignoreCase = true);
22
23Boolean CStrsAreEqual(const char *theFirstCStr,const char *theSecondCStr,const Boolean ignoreCase = true);
24Boolean PStrsAreEqual(const unsigned char *theFirstCStr,const unsigned char *theSecondCStr,const Boolean ignoreCase = true);
25
26void CopyLongIntToCStr(const long theNum,char *theCStr,const int maxCStrLength,const int numDigits = -1);
27void CopyUnsignedLongIntToCStr(const unsigned long theNum,char *theCStr,const int maxCStrLength);
28void ConcatLongIntToCStr(const long theNum,char *theCStr,const int maxCStrLength,const int numDigits = -1);
29void CopyCStrAndConcatLongIntToCStr(const char *theSrcCStr,const long theNum,char *theDstCStr,const int maxDstStrLength);
30
31void CopyLongIntToPStr(const long theNum,unsigned char *thePStr,const int maxPStrLength,const int numDigits = -1);
32void ConcatLongIntToPStr(const long theNum,unsigned char *thePStr,const int maxPStrLength,const int numDigits = -1);
33
34long CStrLength(const char *theCString);
35long PStrLength(const unsigned char *thePString);
36
37OSErr CopyCStrToExistingHandle(const char *theCString,Handle theHandle);
38OSErr CopyLongIntToExistingHandle(const long inTheLongInt,Handle theHandle);
39
40OSErr CopyCStrToNewHandle(const char *theCString,Handle *theHandle);
41OSErr CopyPStrToNewHandle(const unsigned char *thePString,Handle *theHandle);
42OSErr CopyLongIntToNewHandle(const long inTheLongInt,Handle *theHandle);
43
44OSErr AppendCStrToHandle(const char *theCString,Handle theHandle,long *currentLength = nil,long *maxLength = nil);
45OSErr AppendCharsToHandle(const char *theChars,const int numChars,Handle theHandle,long *currentLength = nil,long *maxLength = nil);
46OSErr AppendPStrToHandle(const unsigned char *thePString,Handle theHandle,long *currentLength = nil);
47OSErr AppendLongIntToHandle(const long inTheLongInt,Handle theHandle,long *currentLength = nil);
48
49void ZeroMem(void *theMemPtr,const unsigned long numBytes);
50
51char *FindCharInCStr(const char theChar,const char *theCString);
52long FindCharOffsetInCStr(const char theChar,const char *theCString,const Boolean inIgnoreCase = false);
53long FindCStrOffsetInCStr(const char *theCSubstring,const char *theCString,const Boolean inIgnoreCase = false);
54
55void CopyCSubstrToCStr(const char *theSrcCStr,const int maxCharsToCopy,char *theDstCStr,const int maxDstStrLength);
56void CopyCSubstrToPStr(const char *theSrcCStr,const int maxCharsToCopy,unsigned char *theDstPStr,const int maxDstStrLength);
57
58void InsertCStrIntoCStr(const char *theSrcCStr,const int theInsertionOffset,char *theDstCStr,const int maxDstStrLength);
59void InsertPStrIntoCStr(const unsigned char *theSrcPStr,const int theInsertionOffset,char *theDstCStr,const int maxDstStrLength);
60OSErr InsertCStrIntoHandle(const char *theCString,Handle theHandle,const long inInsertOffset);
61
62void CopyCStrAndInsertCStrIntoCStr(const char *theSrcCStr,const char *theInsertCStr,char *theDstCStr,const int maxDstStrLength);
63
64void CopyCStrAndInsertCStrsLongIntsIntoCStr(const char *theSrcCStr,const char **theInsertCStrs,const long *theLongInts,char *theDstCStr,const int maxDstStrLength);
65
66void CopyCStrAndInsert1LongIntIntoCStr(const char *theSrcCStr,const long theNum,char *theDstCStr,const int maxDstStrLength);
67void CopyCStrAndInsert2LongIntsIntoCStr(const char *theSrcCStr,const long long1,const long long2,char *theDstCStr,const int maxDstStrLength);
68void CopyCStrAndInsert3LongIntsIntoCStr(const char *theSrcCStr,const long long1,const long long2,const long long3,char *theDstCStr,const int maxDstStrLength);
69
70void CopyCStrAndInsertCStrLongIntIntoCStr(const char *theSrcCStr,const char *theInsertCStr,const long theNum,char *theDstCStr,const int maxDstStrLength);
71OSErr CopyCStrAndInsertCStrLongIntIntoHandle(const char *theSrcCStr,const char *theInsertCStr,const long theNum,Handle *theHandle);
72
73
74OSErr CopyIndexedWordToCStr(char *theSrcCStr,int whichWord,char *theDstCStr,int maxDstCStrLength);
75OSErr CopyIndexedWordToNewHandle(char *theSrcCStr,int whichWord,Handle *outTheHandle);
76
77OSErr CopyIndexedLineToCStr(const char *theSrcCStr,int inWhichLine,int *lineEndIndex,Boolean *gotLastLine,char *theDstCStr,const int maxDstCStrLength);
78OSErr CopyIndexedLineToNewHandle(const char *theSrcCStr,int inWhichLine,Handle *outNewHandle);
79
80OSErr ExtractIntFromCStr(const char *theSrcCStr,int *outInt,Boolean skipLeadingSpaces = true);
81OSErr ExtractIntFromPStr(const unsigned char *theSrcPStr,int *outInt,Boolean skipLeadingSpaces = true);
82
83
84void ConvertCStrToUpperCase(char *theSrcCStr);
85
86
87int CountOccurencesOfCharInCStr(const char inChar,const char *inSrcCStr);
88int CountWordsInCStr(const char *inSrcCStr);
89
90OSErr CountDigits(const char *inCStr,int *outNumIntegerDigits,int *outNumFractDigits);
91
92void ExtractCStrItemFromCStr(const char *inSrcCStr,const char inItemDelimiter,const int inItemNumber,Boolean *foundItem,char *outDstCharPtr,const int inDstCharPtrMaxLength,const Boolean inTreatMultipleDelimsAsSingleDelim = false);
93OSErr ExtractCStrItemFromCStrIntoNewHandle(const char *inSrcCStr,const char inItemDelimiter,const int inItemNumber,Boolean *foundItem,Handle *outNewHandle,const Boolean inTreatMultipleDelimsAsSingleDelim = false);
94
95
96OSErr ExtractFloatFromCStr(const char *inCString,extended80 *outFloat);
97OSErr CopyFloatToCStr(const extended80 *theFloat,char *theCStr,const int maxCStrLength,const int inMaxNumIntDigits = -1,const int inMaxNumFractDigits = -1);
98
99void SkipWhiteSpace(char **ioSrcCharPtr,const Boolean inStopAtEOL = false);
100
101
102#ifdef __cplusplus
103}
104#endif
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.cpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.cpp
new file mode 100644
index 0000000000..80b6a675f4
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.cpp
@@ -0,0 +1,170 @@
1/* ====================================================================
2 * Copyright (c) 1998-1999 The OpenSSL Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55
56
57 #include "ErrorHandling.hpp"
58#include "CPStringUtils.hpp"
59
60#ifdef __EXCEPTIONS_ENABLED__
61 #include "CMyException.hpp"
62#endif
63
64
65static char gErrorMessageBuffer[512];
66
67char *gErrorMessage = gErrorMessageBuffer;
68int gErrorMessageMaxLength = sizeof(gErrorMessageBuffer);
69
70
71
72void SetErrorMessage(const char *theErrorMessage)
73{
74 if (theErrorMessage != nil)
75 {
76 CopyCStrToCStr(theErrorMessage,gErrorMessage,gErrorMessageMaxLength);
77 }
78}
79
80
81void SetErrorMessageAndAppendLongInt(const char *theErrorMessage,const long theLongInt)
82{
83 if (theErrorMessage != nil)
84 {
85 CopyCStrAndConcatLongIntToCStr(theErrorMessage,theLongInt,gErrorMessage,gErrorMessageMaxLength);
86 }
87}
88
89void SetErrorMessageAndCStrAndLongInt(const char *theErrorMessage,const char * theCStr,const long theLongInt)
90{
91 if (theErrorMessage != nil)
92 {
93 CopyCStrAndInsertCStrLongIntIntoCStr(theErrorMessage,theCStr,theLongInt,gErrorMessage,gErrorMessageMaxLength);
94 }
95
96}
97
98void SetErrorMessageAndCStr(const char *theErrorMessage,const char * theCStr)
99{
100 if (theErrorMessage != nil)
101 {
102 CopyCStrAndInsertCStrLongIntIntoCStr(theErrorMessage,theCStr,-1,gErrorMessage,gErrorMessageMaxLength);
103 }
104}
105
106
107void AppendCStrToErrorMessage(const char *theErrorMessage)
108{
109 if (theErrorMessage != nil)
110 {
111 ConcatCStrToCStr(theErrorMessage,gErrorMessage,gErrorMessageMaxLength);
112 }
113}
114
115
116void AppendLongIntToErrorMessage(const long theLongInt)
117{
118 ConcatLongIntToCStr(theLongInt,gErrorMessage,gErrorMessageMaxLength);
119}
120
121
122
123char *GetErrorMessage(void)
124{
125 return gErrorMessage;
126}
127
128
129OSErr GetErrorMessageInNewHandle(Handle *inoutHandle)
130{
131OSErr errCode;
132
133
134 errCode = CopyCStrToNewHandle(gErrorMessage,inoutHandle);
135
136 return(errCode);
137}
138
139
140OSErr GetErrorMessageInExistingHandle(Handle inoutHandle)
141{
142OSErr errCode;
143
144
145 errCode = CopyCStrToExistingHandle(gErrorMessage,inoutHandle);
146
147 return(errCode);
148}
149
150
151
152OSErr AppendErrorMessageToHandle(Handle inoutHandle)
153{
154OSErr errCode;
155
156
157 errCode = AppendCStrToHandle(gErrorMessage,inoutHandle,nil);
158
159 return(errCode);
160}
161
162
163#ifdef __EXCEPTIONS_ENABLED__
164
165void ThrowErrorMessageException(void)
166{
167 ThrowDescriptiveException(gErrorMessage);
168}
169
170#endif
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.hpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.hpp
new file mode 100644
index 0000000000..3036df7ee0
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/ErrorHandling.hpp
@@ -0,0 +1,147 @@
1#ifdef __cplusplus
2extern "C" {
3#endif
4
5#ifndef kGenericError
6 #define kGenericError -1
7#endif
8
9extern char *gErrorMessage;
10
11
12void SetErrorMessage(const char *theErrorMessage);
13void SetErrorMessageAndAppendLongInt(const char *theErrorMessage,const long theLongInt);
14void SetErrorMessageAndCStrAndLongInt(const char *theErrorMessage,const char * theCStr,const long theLongInt);
15void SetErrorMessageAndCStr(const char *theErrorMessage,const char * theCStr);
16void AppendCStrToErrorMessage(const char *theErrorMessage);
17void AppendLongIntToErrorMessage(const long theLongInt);
18
19
20char *GetErrorMessage(void);
21OSErr GetErrorMessageInNewHandle(Handle *inoutHandle);
22OSErr GetErrorMessageInExistingHandle(Handle inoutHandle);
23OSErr AppendErrorMessageToHandle(Handle inoutHandle);
24
25
26#ifdef __EXCEPTIONS_ENABLED__
27 void ThrowErrorMessageException(void);
28#endif
29
30
31
32// A bunch of evil macros that would be uneccessary if I were always using C++ !
33
34#define SetErrorMessageAndBailIfNil(theArg,theMessage) \
35{ \
36 if (theArg == nil) \
37 { \
38 SetErrorMessage(theMessage); \
39 errCode = kGenericError; \
40 goto EXITPOINT; \
41 } \
42}
43
44
45#define SetErrorMessageAndBail(theMessage) \
46{ \
47 SetErrorMessage(theMessage); \
48 errCode = kGenericError; \
49 goto EXITPOINT; \
50}
51
52
53#define SetErrorMessageAndLongIntAndBail(theMessage,theLongInt) \
54{ \
55 SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \
56 errCode = kGenericError; \
57 goto EXITPOINT; \
58}
59
60
61#define SetErrorMessageAndLongIntAndBailIfError(theErrCode,theMessage,theLongInt) \
62{ \
63 if (theErrCode != noErr) \
64 { \
65 SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \
66 errCode = theErrCode; \
67 goto EXITPOINT; \
68 } \
69}
70
71
72#define SetErrorMessageCStrLongIntAndBailIfError(theErrCode,theMessage,theCStr,theLongInt) \
73{ \
74 if (theErrCode != noErr) \
75 { \
76 SetErrorMessageAndCStrAndLongInt(theMessage,theCStr,theLongInt); \
77 errCode = theErrCode; \
78 goto EXITPOINT; \
79 } \
80}
81
82
83#define SetErrorMessageAndCStrAndBail(theMessage,theCStr) \
84{ \
85 SetErrorMessageAndCStr(theMessage,theCStr); \
86 errCode = kGenericError; \
87 goto EXITPOINT; \
88}
89
90
91#define SetErrorMessageAndBailIfError(theErrCode,theMessage) \
92{ \
93 if (theErrCode != noErr) \
94 { \
95 SetErrorMessage(theMessage); \
96 errCode = theErrCode; \
97 goto EXITPOINT; \
98 } \
99}
100
101
102#define SetErrorMessageAndLongIntAndBailIfNil(theArg,theMessage,theLongInt) \
103{ \
104 if (theArg == nil) \
105 { \
106 SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \
107 errCode = kGenericError; \
108 goto EXITPOINT; \
109 } \
110}
111
112
113#define BailIfError(theErrCode) \
114{ \
115 if ((theErrCode) != noErr) \
116 { \
117 goto EXITPOINT; \
118 } \
119}
120
121
122#define SetErrCodeAndBail(theErrCode) \
123{ \
124 errCode = theErrCode; \
125 \
126 goto EXITPOINT; \
127}
128
129
130#define SetErrorCodeAndMessageAndBail(theErrCode,theMessage) \
131{ \
132 SetErrorMessage(theMessage); \
133 errCode = theErrCode; \
134 goto EXITPOINT; \
135}
136
137
138#define BailNow() \
139{ \
140 errCode = kGenericError; \
141 goto EXITPOINT; \
142}
143
144
145#ifdef __cplusplus
146}
147#endif
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp
new file mode 100644
index 0000000000..ed8e1cc962
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp
@@ -0,0 +1,215 @@
1/*
2 * An demo illustrating how to retrieve a URI from a secure HTTP server.
3 *
4 * Author: Roy Wood
5 * Date: September 7, 1999
6 * Comments: This relies heavily on my MacSockets library.
7 * This project is also set up so that it expects the OpenSSL source folder (0.9.4 as I write this)
8 * to live in a folder called "OpenSSL-0.9.4" in this project's parent folder. For example:
9 *
10 * Macintosh HD:
11 * Development:
12 * OpenSSL-0.9.4:
13 * (OpenSSL sources here)
14 * OpenSSL Example:
15 * (OpenSSL example junk here)
16 *
17 *
18 * Also-- before attempting to compile this, make sure the aliases in "OpenSSL-0.9.4:include:openssl"
19 * are installed! Use the AppleScript applet in the "openssl-0.9.4" folder to do this!
20 */
21/* modified to seed the PRNG */
22
23
24// Include some funky libs I've developed over time
25
26#include "CPStringUtils.hpp"
27#include "ErrorHandling.hpp"
28#include "MacSocket.h"
29
30
31// We use the OpenSSL implementation of SSL....
32// This was a lot of work to finally get going, though you wouldn't know it by the results!
33
34#include <openssl/ssl.h>
35#include <openssl/err.h>
36#include <openssl/rand.h>
37
38#include <timer.h>
39
40// Let's try grabbing some data from here:
41
42#define kHTTPS_DNS "www.apache-ssl.org"
43#define kHTTPS_Port 443
44#define kHTTPS_URI "/"
45
46
47// Forward-declare this
48
49OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr);
50
51
52
53
54
55// My idle-wait callback. Doesn't do much, does it? Silly cooperative multitasking.
56
57OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr)
58{
59#pragma unused(inUserRefPtr)
60
61EventRecord theEvent;
62
63 ::EventAvail(everyEvent,&theEvent);
64
65 return(noErr);
66}
67
68
69
70// Finally!
71
72void main(void)
73{
74OSErr errCode;
75int theSocket = -1;
76int theTimeout = 30;
77
78SSL_CTX *ssl_ctx = nil;
79SSL *ssl = nil;
80
81char tempString[256];
82UnsignedWide microTickCount;
83
84#warning -- USE A TRUE RANDOM SEED, AND ADD ENTROPY WHENEVER POSSIBLE. --
85const char seed[] = "uyq9,7-b(VHGT^%$&^F/,876;,;./lkJHGFUY{PO*"; // Just gobbledygook
86
87 printf("OpenSSL Demo by Roy Wood, roy@centricsystems.ca\n\n");
88
89 BailIfError(errCode = MacSocket_Startup());
90
91
92
93 // Create a socket-like object
94
95 BailIfError(errCode = MacSocket_socket(&theSocket,false,theTimeout * 60,MyMacSocket_IdleWaitCallback,nil));
96
97
98 // Set up the connect string and try to connect
99
100 CopyCStrAndInsertCStrLongIntIntoCStr("%s:%ld",kHTTPS_DNS,kHTTPS_Port,tempString,sizeof(tempString));
101
102 printf("Connecting to %s....\n",tempString);
103
104 BailIfError(errCode = MacSocket_connect(theSocket,tempString));
105
106
107 // Init SSL stuff
108
109 SSL_load_error_strings();
110
111 SSLeay_add_ssl_algorithms();
112
113
114 // Pick the SSL method
115
116// ssl_ctx = SSL_CTX_new(SSLv2_client_method());
117 ssl_ctx = SSL_CTX_new(SSLv23_client_method());
118// ssl_ctx = SSL_CTX_new(SSLv3_client_method());
119
120
121 RAND_seed (seed, sizeof (seed));
122 Microseconds (&microTickCount);
123 RAND_add (&microTickCount, sizeof (microTickCount), 0); // Entropy is actually > 0, needs an estimate
124
125 // Create an SSL thingey and try to negotiate the connection
126
127 ssl = SSL_new(ssl_ctx);
128
129 SSL_set_fd(ssl,theSocket);
130
131 errCode = SSL_connect(ssl);
132
133 if (errCode < 0)
134 {
135 SetErrorMessageAndLongIntAndBail("OpenSSL: Can't initiate SSL connection, SSL_connect() = ",errCode);
136 }
137
138 // Request the URI from the host
139
140 CopyCStrToCStr("GET ",tempString,sizeof(tempString));
141 ConcatCStrToCStr(kHTTPS_URI,tempString,sizeof(tempString));
142 ConcatCStrToCStr(" HTTP/1.0\r\n\r\n",tempString,sizeof(tempString));
143
144
145 errCode = SSL_write(ssl,tempString,CStrLength(tempString));
146
147 if (errCode < 0)
148 {
149 SetErrorMessageAndLongIntAndBail("OpenSSL: Error writing data via ssl, SSL_write() = ",errCode);
150 }
151
152
153 for (;;)
154 {
155 char tempString[256];
156 int bytesRead;
157
158
159 // Read some bytes and dump them to the console
160
161 bytesRead = SSL_read(ssl,tempString,sizeof(tempString) - 1);
162
163 if (bytesRead == 0 && MacSocket_RemoteEndIsClosing(theSocket))
164 {
165 break;
166 }
167
168 else if (bytesRead < 0)
169 {
170 SetErrorMessageAndLongIntAndBail("OpenSSL: Error reading data via ssl, SSL_read() = ",bytesRead);
171 }
172
173
174 tempString[bytesRead] = '\0';
175
176 printf(tempString);
177 }
178
179 printf("\n\n\n");
180
181 // All done!
182
183 errCode = noErr;
184
185
186EXITPOINT:
187
188 // Clean up and go home
189
190 if (theSocket >= 0)
191 {
192 MacSocket_close(theSocket);
193 }
194
195 if (ssl != nil)
196 {
197 SSL_free(ssl);
198 }
199
200 if (ssl_ctx != nil)
201 {
202 SSL_CTX_free(ssl_ctx);
203 }
204
205
206 if (errCode != noErr)
207 {
208 printf("An error occurred:\n");
209
210 printf(GetErrorMessage());
211 }
212
213
214 MacSocket_Shutdown();
215}
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp
new file mode 100644
index 0000000000..aaf2a68ca9
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.cpp
@@ -0,0 +1,1607 @@
1/*
2 * A simple socket-like package.
3 * This could undoubtedly be improved, since it does polling and busy-waiting.
4 * At least it uses asynch I/O and implements timeouts!
5 *
6 * Other funkiness includes the use of my own (possibly brain-damaged) error-handling infrastructure.
7 *
8 * -Roy Wood (roy@centricsystems.ca)
9 *
10 */
11
12
13/* ====================================================================
14 * Copyright (c) 1998-1999 The OpenSSL Project. All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 *
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 *
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in
25 * the documentation and/or other materials provided with the
26 * distribution.
27 *
28 * 3. All advertising materials mentioning features or use of this
29 * software must display the following acknowledgment:
30 * "This product includes software developed by the OpenSSL Project
31 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
32 *
33 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
34 * endorse or promote products derived from this software without
35 * prior written permission. For written permission, please contact
36 * openssl-core@openssl.org.
37 *
38 * 5. Products derived from this software may not be called "OpenSSL"
39 * nor may "OpenSSL" appear in their names without prior written
40 * permission of the OpenSSL Project.
41 *
42 * 6. Redistributions of any form whatsoever must retain the following
43 * acknowledgment:
44 * "This product includes software developed by the OpenSSL Project
45 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
48 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
51 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58 * OF THE POSSIBILITY OF SUCH DAMAGE.
59 * ====================================================================
60 *
61 * This product includes cryptographic software written by Eric Young
62 * (eay@cryptsoft.com). This product includes software written by Tim
63 * Hudson (tjh@cryptsoft.com).
64 *
65 */
66
67
68
69
70
71#include "MacSocket.h"
72
73#include <Threads.h>
74
75#include <OpenTransport.h>
76#include <OpenTpTInternet.h>
77#include <OpenTptClient.h>
78
79
80
81#include "CPStringUtils.hpp"
82#include "ErrorHandling.hpp"
83
84
85// #define MACSOCKET_DEBUG 1
86
87#ifdef MACSOCKET_DEBUG
88 #include <stdio.h>
89#endif
90
91
92
93extern int errno;
94
95
96#define kMaxNumSockets 4
97
98
99struct SocketStruct
100{
101 Boolean mIsInUse;
102
103 Boolean mEndpointIsBound;
104
105 Boolean mLocalEndIsConnected;
106 Boolean mRemoteEndIsConnected;
107
108 Boolean mReceivedTOpenComplete;
109 Boolean mReceivedTBindComplete;
110 Boolean mReceivedTConnect;
111 Boolean mReceivedTListen;
112 Boolean mReceivedTPassCon;
113 Boolean mReceivedTDisconnect;
114 Boolean mReceivedTOrdRel;
115 Boolean mReceivedTDisconnectComplete;
116
117 long mTimeoutTicks;
118 long mOperationStartTicks;
119
120 MacSocket_IdleWaitCallback mIdleWaitCallback;
121 void *mUserRefPtr;
122
123 OTEventCode mExpectedCode;
124 OTResult mAsyncOperationResult;
125
126 EndpointRef mEndPointRef;
127 TBind *mBindRequestedAddrInfo;
128 TBind *mAssignedAddrInfo;
129 TCall *mRemoteAddrInfo;
130
131 Boolean mReadyToReadData;
132 Boolean mReadyToWriteData;
133
134 Ptr mReadBuffer;
135 Ptr mWriteBuffer;
136
137 int mLastError;
138 char mErrMessage[256];
139};
140
141typedef struct SocketStruct SocketStruct;
142
143
144static SocketStruct sSockets[kMaxNumSockets];
145static Boolean sSocketsSetup = false;
146
147
148
149
150static OSErr MyBusyWait(SocketStruct *ioSocket,Boolean returnImmediatelyOnError,OTResult *outOTResult,Boolean *inAsyncOperationCompleteFlag);
151
152static pascal void OTNonYieldingNotifier(void *contextPtr,OTEventCode code,OTResult result,void *cookie);
153
154static Boolean SocketIndexIsValid(const int inSocketNum);
155
156static void InitSocket(SocketStruct *ioSocket);
157
158static void PrepareForAsyncOperation(SocketStruct *ioSocket,const OTEventCode inExpectedCode);
159
160static Boolean TimeoutElapsed(const SocketStruct *inSocket);
161
162static OSStatus NegotiateIPReuseAddrOption(EndpointRef inEndpoint,const Boolean inEnableReuseIP);
163
164
165
166void MacSocket_GetSocketErrorInfo(const int inSocketNum,int *outSocketErrCode,char *outSocketErrString,const int inSocketErrStringMaxLength)
167{
168 if (outSocketErrCode != nil)
169 {
170 *outSocketErrCode = -1;
171 }
172
173 if (outSocketErrString != nil)
174 {
175 CopyCStrToCStr("",outSocketErrString,inSocketErrStringMaxLength);
176 }
177
178
179 if (SocketIndexIsValid(inSocketNum))
180 {
181 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
182
183
184 if (outSocketErrCode != nil)
185 {
186 *outSocketErrCode = theSocketStruct->mLastError;
187 }
188
189 if (outSocketErrString != nil)
190 {
191 CopyCStrToCStr(theSocketStruct->mErrMessage,outSocketErrString,inSocketErrStringMaxLength);
192 }
193 }
194}
195
196
197void MacSocket_SetUserRefPtr(const int inSocketNum,void *inNewRefPtr)
198{
199 if (SocketIndexIsValid(inSocketNum))
200 {
201 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
202
203 theSocketStruct->mUserRefPtr = inNewRefPtr;
204 }
205}
206
207
208
209void MacSocket_GetLocalIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength)
210{
211 if (outIPAndPort != nil && SocketIndexIsValid(inSocketNum))
212 {
213 char tempString[256];
214 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
215
216
217 CopyCStrToCStr("",tempString,sizeof(tempString));
218
219 if (theSocketStruct->mAssignedAddrInfo != nil)
220 {
221 InetAddress *theInetAddress = (InetAddress *) theSocketStruct->mAssignedAddrInfo->addr.buf;
222 InetHost theInetHost = theInetAddress->fHost;
223
224 if (theInetHost == 0)
225 {
226 InetInterfaceInfo theInetInterfaceInfo;
227
228 if (::OTInetGetInterfaceInfo(&theInetInterfaceInfo,kDefaultInetInterface) == noErr)
229 {
230 theInetHost = theInetInterfaceInfo.fAddress;
231 }
232 }
233
234 ::OTInetHostToString(theInetHost,tempString);
235
236 ConcatCStrToCStr(":",tempString,sizeof(tempString));
237 ConcatLongIntToCStr(theInetAddress->fPort,tempString,sizeof(tempString));
238 }
239
240 CopyCStrToCStr(tempString,outIPAndPort,inIPAndPortLength);
241 }
242}
243
244
245
246void MacSocket_GetRemoteIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength)
247{
248 if (outIPAndPort != nil && SocketIndexIsValid(inSocketNum))
249 {
250 char tempString[256];
251 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
252
253
254 CopyCStrToCStr("",tempString,sizeof(tempString));
255
256 if (theSocketStruct->mRemoteAddrInfo != nil)
257 {
258 InetAddress *theInetAddress = (InetAddress *) theSocketStruct->mRemoteAddrInfo->addr.buf;
259 InetHost theInetHost = theInetAddress->fHost;
260
261 if (theInetHost == 0)
262 {
263 InetInterfaceInfo theInetInterfaceInfo;
264
265 if (::OTInetGetInterfaceInfo(&theInetInterfaceInfo,kDefaultInetInterface) == noErr)
266 {
267 theInetHost = theInetInterfaceInfo.fAddress;
268 }
269 }
270
271 ::OTInetHostToString(theInetHost,tempString);
272
273 ConcatCStrToCStr(":",tempString,sizeof(tempString));
274 ConcatLongIntToCStr(theInetAddress->fPort,tempString,sizeof(tempString));
275 }
276
277 CopyCStrToCStr(tempString,outIPAndPort,inIPAndPortLength);
278 }
279}
280
281
282
283Boolean MacSocket_RemoteEndIsClosing(const int inSocketNum)
284{
285Boolean theResult = false;
286
287 if (SocketIndexIsValid(inSocketNum))
288 {
289 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
290
291 theResult = theSocketStruct->mReceivedTOrdRel;
292 }
293
294 return(theResult);
295}
296
297
298
299Boolean MacSocket_ListenCompleted(const int inSocketNum)
300{
301Boolean theResult = false;
302
303 if (SocketIndexIsValid(inSocketNum))
304 {
305 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
306
307 theResult = theSocketStruct->mReceivedTPassCon;
308 }
309
310 return(theResult);
311}
312
313
314
315Boolean MacSocket_RemoteEndIsOpen(const int inSocketNum)
316{
317 if (SocketIndexIsValid(inSocketNum))
318 {
319 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
320
321 return(theSocketStruct->mRemoteEndIsConnected);
322 }
323
324 else
325 {
326 return(false);
327 }
328}
329
330
331
332Boolean MacSocket_LocalEndIsOpen(const int inSocketNum)
333{
334 if (SocketIndexIsValid(inSocketNum))
335 {
336 SocketStruct *theSocketStruct = &(sSockets[inSocketNum]);
337
338 return(theSocketStruct->mLocalEndIsConnected);
339 }
340
341 else
342 {
343 return(false);
344 }
345}
346
347
348
349static Boolean TimeoutElapsed(const SocketStruct *inSocket)
350{
351Boolean timeIsUp = false;
352
353 if (inSocket != nil && inSocket->mTimeoutTicks > 0 && ::TickCount() > inSocket->mOperationStartTicks + inSocket->mTimeoutTicks)
354 {
355 timeIsUp = true;
356 }
357
358
359 return(timeIsUp);
360}
361
362
363
364static Boolean SocketIndexIsValid(const int inSocketNum)
365{
366 if (inSocketNum >= 0 && inSocketNum < kMaxNumSockets && sSockets[inSocketNum].mEndPointRef != kOTInvalidEndpointRef)
367 {
368 return(true);
369 }
370
371 else
372 {
373 return(false);
374 }
375}
376
377
378
379static void InitSocket(SocketStruct *ioSocket)
380{
381 ioSocket->mIsInUse = false;
382
383 ioSocket->mEndpointIsBound = false;
384
385 ioSocket->mLocalEndIsConnected = false;
386 ioSocket->mRemoteEndIsConnected = false;
387
388 ioSocket->mReceivedTOpenComplete = false;
389 ioSocket->mReceivedTBindComplete = false;
390 ioSocket->mReceivedTConnect = false;
391 ioSocket->mReceivedTListen = false;
392 ioSocket->mReceivedTPassCon = false;
393 ioSocket->mReceivedTDisconnect = false;
394 ioSocket->mReceivedTOrdRel = false;
395 ioSocket->mReceivedTDisconnectComplete = false;
396
397 ioSocket->mTimeoutTicks = 30 * 60;
398 ioSocket->mOperationStartTicks = -1;
399
400 ioSocket->mIdleWaitCallback = nil;
401 ioSocket->mUserRefPtr = nil;
402
403 ioSocket->mExpectedCode = 0;
404 ioSocket->mAsyncOperationResult = noErr;
405
406 ioSocket->mEndPointRef = kOTInvalidEndpointRef;
407
408 ioSocket->mBindRequestedAddrInfo = nil;
409 ioSocket->mAssignedAddrInfo = nil;
410 ioSocket->mRemoteAddrInfo = nil;
411
412 ioSocket->mReadyToReadData = false;
413 ioSocket->mReadyToWriteData = true;
414
415 ioSocket->mReadBuffer = nil;
416 ioSocket->mWriteBuffer = nil;
417
418 ioSocket->mLastError = noErr;
419 CopyCStrToCStr("",ioSocket->mErrMessage,sizeof(ioSocket->mErrMessage));
420}
421
422
423
424static void PrepareForAsyncOperation(SocketStruct *ioSocket,const OTEventCode inExpectedCode)
425{
426 ioSocket->mOperationStartTicks = ::TickCount();
427
428 ioSocket->mAsyncOperationResult = noErr;
429
430 ioSocket->mExpectedCode = inExpectedCode;
431}
432
433
434// The wait function....
435
436static OSErr MyBusyWait(SocketStruct *ioSocket,Boolean returnImmediatelyOnError,OTResult *outOTResult,Boolean *inAsyncOperationCompleteFlag)
437{
438OSErr errCode = noErr;
439OTResult theOTResult = noErr;
440
441
442 SetErrorMessageAndBailIfNil(ioSocket,"MyBusyWait: Bad parameter, ioSocket = nil");
443 SetErrorMessageAndBailIfNil(inAsyncOperationCompleteFlag,"MyBusyWait: Bad parameter, inAsyncOperationCompleteFlag = nil");
444
445 for (;;)
446 {
447 if (*inAsyncOperationCompleteFlag)
448 {
449 theOTResult = ioSocket->mAsyncOperationResult;
450
451 break;
452 }
453
454 if (ioSocket->mIdleWaitCallback != nil)
455 {
456 theOTResult = (*(ioSocket->mIdleWaitCallback))(ioSocket->mUserRefPtr);
457
458 if (theOTResult != noErr && returnImmediatelyOnError)
459 {
460 break;
461 }
462 }
463
464 if (TimeoutElapsed(ioSocket))
465 {
466 theOTResult = kMacSocket_TimeoutErr;
467
468 break;
469 }
470 }
471
472
473EXITPOINT:
474
475 if (outOTResult != nil)
476 {
477 *outOTResult = theOTResult;
478 }
479
480 return(errCode);
481}
482
483
484
485// I used to do thread switching, but stopped. It could easily be rolled back in though....
486
487static pascal void OTNonYieldingNotifier(void *contextPtr,OTEventCode code,OTResult result,void *cookie)
488{
489SocketStruct *theSocketStruct = (SocketStruct *) contextPtr;
490
491 if (theSocketStruct != nil)
492 {
493 if (theSocketStruct->mExpectedCode != 0 && code == theSocketStruct->mExpectedCode)
494 {
495 theSocketStruct->mAsyncOperationResult = result;
496
497 theSocketStruct->mExpectedCode = 0;
498 }
499
500
501 switch (code)
502 {
503 case T_OPENCOMPLETE:
504 {
505 theSocketStruct->mReceivedTOpenComplete = true;
506
507 theSocketStruct->mEndPointRef = (EndpointRef) cookie;
508
509 break;
510 }
511
512
513 case T_BINDCOMPLETE:
514 {
515 theSocketStruct->mReceivedTBindComplete = true;
516
517 break;
518 }
519
520
521 case T_CONNECT:
522 {
523 theSocketStruct->mReceivedTConnect = true;
524
525 theSocketStruct->mLocalEndIsConnected = true;
526
527 theSocketStruct->mRemoteEndIsConnected = true;
528
529 break;
530 }
531
532
533 case T_LISTEN:
534 {
535 theSocketStruct->mReceivedTListen = true;
536
537 break;
538 }
539
540
541 case T_PASSCON:
542 {
543 theSocketStruct->mReceivedTPassCon = true;
544
545 theSocketStruct->mLocalEndIsConnected = true;
546
547 theSocketStruct->mRemoteEndIsConnected = true;
548
549 break;
550 }
551
552
553 case T_DATA:
554 {
555 theSocketStruct->mReadyToReadData = true;
556
557 break;
558 }
559
560 case T_GODATA:
561 {
562 theSocketStruct->mReadyToWriteData = true;
563
564 break;
565 }
566
567 case T_DISCONNECT:
568 {
569 theSocketStruct->mReceivedTDisconnect = true;
570
571 theSocketStruct->mRemoteEndIsConnected = false;
572
573 theSocketStruct->mLocalEndIsConnected = false;
574
575 ::OTRcvDisconnect(theSocketStruct->mEndPointRef,nil);
576
577 break;
578 }
579
580 case T_ORDREL:
581 {
582 theSocketStruct->mReceivedTOrdRel = true;
583
584 // We can still write data, so don't clear mRemoteEndIsConnected
585
586 ::OTRcvOrderlyDisconnect(theSocketStruct->mEndPointRef);
587
588 break;
589 }
590
591 case T_DISCONNECTCOMPLETE:
592 {
593 theSocketStruct->mReceivedTDisconnectComplete = true;
594
595 theSocketStruct->mRemoteEndIsConnected = false;
596
597 theSocketStruct->mLocalEndIsConnected = false;
598
599 break;
600 }
601 }
602 }
603/*
604T_LISTEN OTListen
605T_CONNECT OTRcvConnect
606T_DATA OTRcv, OTRcvUData
607T_DISCONNECT OTRcvDisconnect
608T_ORDREL OTRcvOrderlyDisconnect
609T_GODATA OTSnd, OTSndUData, OTLook
610T_PASSCON none
611
612T_EXDATA OTRcv
613T_GOEXDATA OTSnd, OTLook
614T_UDERR OTRcvUDErr
615*/
616}
617
618
619
620// Initialize the main socket data structure
621
622OSErr MacSocket_Startup(void)
623{
624 if (!sSocketsSetup)
625 {
626 for (int i = 0;i < kMaxNumSockets;i++)
627 {
628 InitSocket(&(sSockets[i]));
629 }
630
631 ::InitOpenTransport();
632
633 sSocketsSetup = true;
634 }
635
636
637 return(noErr);
638}
639
640
641
642// Cleanup before exiting
643
644OSErr MacSocket_Shutdown(void)
645{
646 if (sSocketsSetup)
647 {
648 for (int i = 0;i < kMaxNumSockets;i++)
649 {
650 SocketStruct *theSocketStruct = &(sSockets[i]);
651
652 if (theSocketStruct->mIsInUse)
653 {
654 if (theSocketStruct->mEndPointRef != kOTInvalidEndpointRef)
655 {
656 OTResult theOTResult;
657
658
659 // Since we're killing the endpoint, I don't bother to send the disconnect (sorry!)
660
661/*
662 if (theSocketStruct->mLocalEndIsConnected)
663 {
664 // This is an abortive action, so we do a hard disconnect instead of an OTSndOrderlyDisconnect
665
666 theOTResult = ::OTSndDisconnect(theSocketStruct->mEndPointRef, nil);
667
668 // Now we have to watch for T_DISCONNECTCOMPLETE event
669
670 theSocketStruct->mLocalEndIsConnected = false;
671 }
672*/
673
674 theOTResult = ::OTCloseProvider(theSocketStruct->mEndPointRef);
675
676
677 theSocketStruct->mEndPointRef = kOTInvalidEndpointRef;
678 }
679
680 if (theSocketStruct->mBindRequestedAddrInfo != nil)
681 {
682 ::OTFree((void *) theSocketStruct->mBindRequestedAddrInfo,T_BIND);
683
684 theSocketStruct->mBindRequestedAddrInfo = nil;
685 }
686
687 if (theSocketStruct->mAssignedAddrInfo != nil)
688 {
689 ::OTFree((void *) theSocketStruct->mAssignedAddrInfo,T_BIND);
690
691 theSocketStruct->mAssignedAddrInfo = nil;
692 }
693
694 if (theSocketStruct->mRemoteAddrInfo != nil)
695 {
696 ::OTFree((void *) theSocketStruct->mRemoteAddrInfo,T_CALL);
697
698 theSocketStruct->mRemoteAddrInfo = nil;
699 }
700
701
702 }
703 }
704
705 ::CloseOpenTransport();
706
707 sSocketsSetup = false;
708 }
709
710 return(noErr);
711}
712
713
714
715
716
717
718// Allocate a socket
719
720OSErr MacSocket_socket(int *outSocketNum,const Boolean inDoThreadSwitching,const long inTimeoutTicks,MacSocket_IdleWaitCallback inIdleWaitCallback,void *inUserRefPtr)
721{
722// Gotta roll support back in for threads eventually.....
723
724#pragma unused(inDoThreadSwitching)
725
726
727OSErr errCode = noErr;
728
729
730 SetErrorMessageAndBailIfNil(outSocketNum,"MacSocket_socket: Bad parameter, outSocketNum == nil");
731
732 *outSocketNum = -1;
733
734
735 // Find an unused socket
736
737 for (int i = 0;i < kMaxNumSockets;i++)
738 {
739 if (sSockets[i].mIsInUse == false)
740 {
741 OTResult theOTResult;
742 SocketStruct *theSocketStruct = &(sSockets[i]);
743
744
745 InitSocket(theSocketStruct);
746
747 theSocketStruct->mIdleWaitCallback = inIdleWaitCallback;
748 theSocketStruct->mUserRefPtr = inUserRefPtr;
749
750 theSocketStruct->mTimeoutTicks = inTimeoutTicks;
751
752
753 // Set up OT endpoint
754
755 PrepareForAsyncOperation(theSocketStruct,T_OPENCOMPLETE);
756
757 theOTResult = ::OTAsyncOpenEndpoint(OTCreateConfiguration(kTCPName),0,nil,OTNonYieldingNotifier,(void *) theSocketStruct);
758
759 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_socket: Can't create OT endpoint, OTAsyncOpenEndpoint() = ",theOTResult);
760
761 BailIfError(MyBusyWait(theSocketStruct,false,&theOTResult,&(theSocketStruct->mReceivedTOpenComplete)));
762
763 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_socket: Can't create OT endpoint, OTAsyncOpenEndpoint() = ",theOTResult);
764
765
766 *outSocketNum = i;
767
768 errCode = noErr;
769
770 theSocketStruct->mIsInUse = true;
771
772 break;
773 }
774
775 else if (i == kMaxNumSockets - 1)
776 {
777 SetErrorMessageAndBail("MacSocket_socket: No sockets available");
778 }
779 }
780
781
782EXITPOINT:
783
784 errno = errCode;
785
786 return(errCode);
787}
788
789
790
791
792OSErr MacSocket_listen(const int inSocketNum,const int inPortNum)
793{
794OSErr errCode = noErr;
795SocketStruct *theSocketStruct = nil;
796
797
798 if (!SocketIndexIsValid(inSocketNum))
799 {
800 SetErrorMessageAndBail("MacSocket_listen: Invalid socket number specified");
801 }
802
803
804 theSocketStruct = &(sSockets[inSocketNum]);
805
806
807OTResult theOTResult;
808
809
810 if (theSocketStruct->mBindRequestedAddrInfo == nil)
811 {
812 theSocketStruct->mBindRequestedAddrInfo = (TBind *) ::OTAlloc(theSocketStruct->mEndPointRef,T_BIND,T_ADDR,&theOTResult);
813
814 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't allocate OT T_BIND structure, OTAlloc() = ",theOTResult);
815 SetErrorMessageAndBailIfNil(theSocketStruct->mBindRequestedAddrInfo,"MacSocket_listen: Can't allocate OT T_BIND structure, OTAlloc() returned nil");
816 }
817
818 if (theSocketStruct->mAssignedAddrInfo == nil)
819 {
820 theSocketStruct->mAssignedAddrInfo = (TBind *) ::OTAlloc(theSocketStruct->mEndPointRef,T_BIND,T_ADDR,&theOTResult);
821
822 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't allocate OT T_BIND structure, OTAlloc() = ",theOTResult);
823 SetErrorMessageAndBailIfNil(theSocketStruct->mAssignedAddrInfo,"MacSocket_listen: Can't allocate OT T_BIND structure, OTAlloc() returned nil");
824 }
825
826 if (theSocketStruct->mRemoteAddrInfo == nil)
827 {
828 theSocketStruct->mRemoteAddrInfo = (TCall *) ::OTAlloc(theSocketStruct->mEndPointRef,T_CALL,T_ADDR,&theOTResult);
829
830 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't allocate OT T_CALL structure, OTAlloc() = ",theOTResult);
831 SetErrorMessageAndBailIfNil(theSocketStruct->mRemoteAddrInfo,"MacSocket_listen: Can't allocate OT T_CALL structure, OTAlloc() returned nil");
832 }
833
834
835 if (!theSocketStruct->mEndpointIsBound)
836 {
837 InetInterfaceInfo theInetInterfaceInfo;
838
839 theOTResult = ::OTInetGetInterfaceInfo(&theInetInterfaceInfo,kDefaultInetInterface);
840
841 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't determine OT interface info, OTInetGetInterfaceInfo() = ",theOTResult);
842
843
844 InetAddress *theInetAddress = (InetAddress *) theSocketStruct->mBindRequestedAddrInfo->addr.buf;
845
846// theInetAddress->fAddressType = AF_INET;
847// theInetAddress->fPort = inPortNum;
848// theInetAddress->fHost = theInetInterfaceInfo.fAddress;
849
850 ::OTInitInetAddress(theInetAddress,inPortNum,theInetInterfaceInfo.fAddress);
851
852 theSocketStruct->mBindRequestedAddrInfo->addr.len = sizeof(InetAddress);
853
854 theSocketStruct->mBindRequestedAddrInfo->qlen = 1;
855
856
857 theOTResult = ::OTSetSynchronous(theSocketStruct->mEndPointRef);
858
859 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't set OT endpoint mode, OTSetSynchronous() = ",theOTResult);
860
861 theOTResult = NegotiateIPReuseAddrOption(theSocketStruct->mEndPointRef,true);
862
863 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't set OT IP address reuse flag, NegotiateIPReuseAddrOption() = ",theOTResult);
864
865 theOTResult = ::OTSetAsynchronous(theSocketStruct->mEndPointRef);
866
867 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't set OT endpoint mode, OTSetAsynchronous() = ",theOTResult);
868
869
870 PrepareForAsyncOperation(theSocketStruct,T_BINDCOMPLETE);
871
872 theOTResult = ::OTBind(theSocketStruct->mEndPointRef,theSocketStruct->mBindRequestedAddrInfo,theSocketStruct->mAssignedAddrInfo);
873
874 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't bind OT endpoint, OTBind() = ",theOTResult);
875
876 BailIfError(MyBusyWait(theSocketStruct,false,&theOTResult,&(theSocketStruct->mReceivedTBindComplete)));
877
878 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't bind OT endpoint, OTBind() = ",theOTResult);
879
880
881 theSocketStruct->mEndpointIsBound = true;
882 }
883
884
885 PrepareForAsyncOperation(theSocketStruct,T_LISTEN);
886
887 theOTResult = ::OTListen(theSocketStruct->mEndPointRef,theSocketStruct->mRemoteAddrInfo);
888
889 if (theOTResult == noErr)
890 {
891 PrepareForAsyncOperation(theSocketStruct,T_PASSCON);
892
893 theOTResult = ::OTAccept(theSocketStruct->mEndPointRef,theSocketStruct->mEndPointRef,theSocketStruct->mRemoteAddrInfo);
894
895 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't begin OT accept, OTAccept() = ",theOTResult);
896
897 BailIfError(MyBusyWait(theSocketStruct,false,&theOTResult,&(theSocketStruct->mReceivedTPassCon)));
898
899 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_listen: Can't accept OT connection, OTAccept() = ",theOTResult);
900 }
901
902 else if (theOTResult == kOTNoDataErr)
903 {
904 theOTResult = noErr;
905 }
906
907 else
908 {
909 SetErrorMessageAndLongIntAndBail("MacSocket_listen: Can't begin OT listen, OTListen() = ",theOTResult);
910 }
911
912
913 errCode = noErr;
914
915
916EXITPOINT:
917
918 if (theSocketStruct != nil)
919 {
920 theSocketStruct->mLastError = noErr;
921
922 CopyCStrToCStr("",theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
923
924 if (errCode != noErr)
925 {
926 theSocketStruct->mLastError = errCode;
927
928 CopyCStrToCStr(GetErrorMessage(),theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
929 }
930 }
931
932 errno = errCode;
933
934 return(errCode);
935}
936
937
938
939
940OSErr MacSocket_connect(const int inSocketNum,char *inTargetAddressAndPort)
941{
942OSErr errCode = noErr;
943SocketStruct *theSocketStruct = nil;
944
945
946 if (!SocketIndexIsValid(inSocketNum))
947 {
948 SetErrorMessageAndBail("MacSocket_connect: Invalid socket number specified");
949 }
950
951 theSocketStruct = &(sSockets[inSocketNum]);
952
953 if (theSocketStruct->mEndpointIsBound)
954 {
955 SetErrorMessageAndBail("MacSocket_connect: Socket previously bound");
956 }
957
958
959OTResult theOTResult;
960
961 theSocketStruct->mBindRequestedAddrInfo = (TBind *) ::OTAlloc(theSocketStruct->mEndPointRef,T_BIND,T_ADDR,&theOTResult);
962
963 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't allocate OT T_BIND structure, OTAlloc() = ",theOTResult);
964 SetErrorMessageAndBailIfNil(theSocketStruct->mBindRequestedAddrInfo,"MacSocket_connect: Can't allocate OT T_BIND structure, OTAlloc() returned nil");
965
966
967 theSocketStruct->mAssignedAddrInfo = (TBind *) ::OTAlloc(theSocketStruct->mEndPointRef,T_BIND,T_ADDR,&theOTResult);
968
969 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't allocate OT T_BIND structure, OTAlloc() = ",theOTResult);
970 SetErrorMessageAndBailIfNil(theSocketStruct->mAssignedAddrInfo,"MacSocket_connect: Can't allocate OT T_BIND structure, OTAlloc() returned nil");
971
972
973 theSocketStruct->mRemoteAddrInfo = (TCall *) ::OTAlloc(theSocketStruct->mEndPointRef,T_CALL,T_ADDR,&theOTResult);
974
975 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't allocate OT T_CALL structure, OTAlloc() = ",theOTResult);
976 SetErrorMessageAndBailIfNil(theSocketStruct->mRemoteAddrInfo,"MacSocket_connect: Can't allocate OT T_CALL structure, OTAlloc() returned nil");
977
978
979 PrepareForAsyncOperation(theSocketStruct,T_BINDCOMPLETE);
980
981 theOTResult = ::OTBind(theSocketStruct->mEndPointRef,nil,theSocketStruct->mAssignedAddrInfo);
982
983 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't bind OT endpoint, OTBind() = ",theOTResult);
984
985 BailIfError(MyBusyWait(theSocketStruct,false,&theOTResult,&(theSocketStruct->mReceivedTBindComplete)));
986
987 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't bind OT endpoint, OTBind() = ",theOTResult);
988
989 theSocketStruct->mEndpointIsBound = true;
990
991
992TCall sndCall;
993DNSAddress hostDNSAddress;
994
995 // Set up target address
996
997 sndCall.addr.buf = (UInt8 *) &hostDNSAddress;
998 sndCall.addr.len = ::OTInitDNSAddress(&hostDNSAddress,inTargetAddressAndPort);
999 sndCall.opt.buf = nil;
1000 sndCall.opt.len = 0;
1001 sndCall.udata.buf = nil;
1002 sndCall.udata.len = 0;
1003 sndCall.sequence = 0;
1004
1005 // Connect!
1006
1007 PrepareForAsyncOperation(theSocketStruct,T_CONNECT);
1008
1009 theOTResult = ::OTConnect(theSocketStruct->mEndPointRef,&sndCall,nil);
1010
1011 if (theOTResult == kOTNoDataErr)
1012 {
1013 theOTResult = noErr;
1014 }
1015
1016 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't connect OT endpoint, OTConnect() = ",theOTResult);
1017
1018 BailIfError(MyBusyWait(theSocketStruct,false,&theOTResult,&(theSocketStruct->mReceivedTConnect)));
1019
1020 if (theOTResult == kMacSocket_TimeoutErr)
1021 {
1022 SetErrorMessageAndBail("MacSocket_connect: Can't connect OT endpoint, OTConnect() = kMacSocket_TimeoutErr");
1023 }
1024
1025 else
1026 {
1027 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't connect OT endpoint, OTConnect() = ",theOTResult);
1028 }
1029
1030 theOTResult = ::OTRcvConnect(theSocketStruct->mEndPointRef,nil);
1031
1032 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_connect: Can't complete connect on OT endpoint, OTRcvConnect() = ",theOTResult);
1033
1034
1035 errCode = noErr;
1036
1037
1038#ifdef MACSOCKET_DEBUG
1039 printf("MacSocket_connect: connect completed\n");
1040#endif
1041
1042EXITPOINT:
1043
1044 if (theSocketStruct != nil)
1045 {
1046 theSocketStruct->mLastError = noErr;
1047
1048 CopyCStrToCStr("",theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1049
1050 if (errCode != noErr)
1051 {
1052 theSocketStruct->mLastError = errCode;
1053
1054 CopyCStrToCStr(GetErrorMessage(),theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1055 }
1056 }
1057
1058 errno = errCode;
1059
1060 return(errCode);
1061}
1062
1063
1064
1065
1066// Close a connection
1067
1068OSErr MacSocket_close(const int inSocketNum)
1069{
1070OSErr errCode = noErr;
1071SocketStruct *theSocketStruct = nil;
1072
1073
1074 if (!SocketIndexIsValid(inSocketNum))
1075 {
1076 SetErrorMessageAndBail("MacSocket_close: Invalid socket number specified");
1077 }
1078
1079
1080 theSocketStruct = &(sSockets[inSocketNum]);
1081
1082 if (theSocketStruct->mEndPointRef != kOTInvalidEndpointRef)
1083 {
1084 OTResult theOTResult = noErr;
1085
1086 // Try to play nice
1087
1088 if (theSocketStruct->mReceivedTOrdRel)
1089 {
1090 // Already did an OTRcvOrderlyDisconnect() in the notifier
1091
1092 if (theSocketStruct->mLocalEndIsConnected)
1093 {
1094 theOTResult = ::OTSndOrderlyDisconnect(theSocketStruct->mEndPointRef);
1095
1096 theSocketStruct->mLocalEndIsConnected = false;
1097 }
1098 }
1099
1100 else if (theSocketStruct->mLocalEndIsConnected)
1101 {
1102 theOTResult = ::OTSndOrderlyDisconnect(theSocketStruct->mEndPointRef);
1103
1104 theSocketStruct->mLocalEndIsConnected = false;
1105
1106 // Wait for other end to hang up too!
1107
1108// PrepareForAsyncOperation(theSocketStruct,T_ORDREL);
1109//
1110// errCode = MyBusyWait(theSocketStruct,false,&theOTResult,&(theSocketStruct->mReceivedTOrdRel));
1111 }
1112
1113
1114 if (theOTResult != noErr)
1115 {
1116 ::OTCloseProvider(theSocketStruct->mEndPointRef);
1117 }
1118
1119 else
1120 {
1121 theOTResult = ::OTCloseProvider(theSocketStruct->mEndPointRef);
1122 }
1123
1124 theSocketStruct->mEndPointRef = kOTInvalidEndpointRef;
1125
1126 errCode = theOTResult;
1127 }
1128
1129
1130 theSocketStruct->mIsInUse = false;
1131
1132
1133EXITPOINT:
1134
1135 if (theSocketStruct != nil)
1136 {
1137 theSocketStruct->mLastError = noErr;
1138
1139 CopyCStrToCStr("",theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1140
1141 if (errCode != noErr)
1142 {
1143 theSocketStruct->mLastError = errCode;
1144
1145 CopyCStrToCStr(GetErrorMessage(),theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1146 }
1147 }
1148
1149 errno = errCode;
1150
1151 return(errCode);
1152}
1153
1154
1155
1156
1157// Receive some bytes
1158
1159int MacSocket_recv(const int inSocketNum,void *outBuff,int outBuffLength,const Boolean inBlock)
1160{
1161OSErr errCode = noErr;
1162int totalBytesRead = 0;
1163SocketStruct *theSocketStruct = nil;
1164
1165
1166 SetErrorMessageAndBailIfNil(outBuff,"MacSocket_recv: Bad parameter, outBuff = nil");
1167
1168 if (outBuffLength <= 0)
1169 {
1170 SetErrorMessageAndBail("MacSocket_recv: Bad parameter, outBuffLength <= 0");
1171 }
1172
1173 if (!SocketIndexIsValid(inSocketNum))
1174 {
1175 SetErrorMessageAndBail("MacSocket_recv: Invalid socket number specified");
1176 }
1177
1178 theSocketStruct = &(sSockets[inSocketNum]);
1179
1180 if (!theSocketStruct->mLocalEndIsConnected)
1181 {
1182 SetErrorMessageAndBail("MacSocket_recv: Socket not connected");
1183 }
1184
1185 if (theSocketStruct->mReceivedTOrdRel)
1186 {
1187 totalBytesRead = 0;
1188
1189 goto EXITPOINT;
1190 }
1191
1192
1193 PrepareForAsyncOperation(theSocketStruct,0);
1194
1195 for (;;)
1196 {
1197 int bytesRead;
1198 OTResult theOTResult;
1199
1200
1201 theOTResult = ::OTRcv(theSocketStruct->mEndPointRef,(void *) ((unsigned long) outBuff + (unsigned long) totalBytesRead),outBuffLength - totalBytesRead,nil);
1202
1203 if (theOTResult >= 0)
1204 {
1205 bytesRead = theOTResult;
1206
1207#ifdef MACSOCKET_DEBUG
1208 printf("MacSocket_recv: read %d bytes in part\n",bytesRead);
1209#endif
1210 }
1211
1212 else if (theOTResult == kOTNoDataErr)
1213 {
1214 bytesRead = 0;
1215 }
1216
1217 else
1218 {
1219 SetErrorMessageAndLongIntAndBail("MacSocket_recv: Can't receive OT data, OTRcv() = ",theOTResult);
1220 }
1221
1222
1223 totalBytesRead += bytesRead;
1224
1225
1226 if (totalBytesRead <= 0)
1227 {
1228 if (theSocketStruct->mReceivedTOrdRel)
1229 {
1230 break;
1231 }
1232
1233 // This seems pretty stupid to me now. Maybe I'll delete this blocking garbage.
1234
1235 if (inBlock)
1236 {
1237 if (TimeoutElapsed(theSocketStruct))
1238 {
1239 SetErrorCodeAndMessageAndBail(kMacSocket_TimeoutErr,"MacSocket_recv: Receive operation timed-out");
1240 }
1241
1242 if (theSocketStruct->mIdleWaitCallback != nil)
1243 {
1244 theOTResult = (*(theSocketStruct->mIdleWaitCallback))(theSocketStruct->mUserRefPtr);
1245
1246 SetErrorMessageAndBailIfError(theOTResult,"MacSocket_recv: User cancelled operation");
1247 }
1248
1249 continue;
1250 }
1251 }
1252
1253
1254 break;
1255 }
1256
1257 errCode = noErr;
1258
1259
1260#ifdef MACSOCKET_DEBUG
1261 printf("MacSocket_recv: read %d bytes in total\n",totalBytesRead);
1262#endif
1263
1264
1265EXITPOINT:
1266
1267 if (theSocketStruct != nil)
1268 {
1269 theSocketStruct->mLastError = noErr;
1270
1271 CopyCStrToCStr("",theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1272
1273 if (errCode != noErr)
1274 {
1275 theSocketStruct->mLastError = errCode;
1276
1277 CopyCStrToCStr(GetErrorMessage(),theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1278 }
1279 }
1280
1281 errno = errCode;
1282
1283 return(totalBytesRead);
1284}
1285
1286
1287
1288// Send some bytes
1289
1290int MacSocket_send(const int inSocketNum,void *inBuff,int inBuffLength)
1291{
1292OSErr errCode = noErr;
1293int bytesSent = 0;
1294SocketStruct *theSocketStruct = nil;
1295
1296
1297 SetErrorMessageAndBailIfNil(inBuff,"MacSocket_send: Bad parameter, inBuff = nil");
1298
1299 if (inBuffLength <= 0)
1300 {
1301 SetErrorMessageAndBail("MacSocket_send: Bad parameter, inBuffLength <= 0");
1302 }
1303
1304 if (!SocketIndexIsValid(inSocketNum))
1305 {
1306 SetErrorMessageAndBail("MacSocket_send: Invalid socket number specified");
1307 }
1308
1309
1310 theSocketStruct = &(sSockets[inSocketNum]);
1311
1312 if (!theSocketStruct->mLocalEndIsConnected)
1313 {
1314 SetErrorMessageAndBail("MacSocket_send: Socket not connected");
1315 }
1316
1317
1318OTResult theOTResult;
1319
1320
1321 PrepareForAsyncOperation(theSocketStruct,0);
1322
1323 while (bytesSent < inBuffLength)
1324 {
1325 if (theSocketStruct->mIdleWaitCallback != nil)
1326 {
1327 theOTResult = (*(theSocketStruct->mIdleWaitCallback))(theSocketStruct->mUserRefPtr);
1328
1329 SetErrorMessageAndBailIfError(theOTResult,"MacSocket_send: User cancelled");
1330 }
1331
1332
1333 theOTResult = ::OTSnd(theSocketStruct->mEndPointRef,(void *) ((unsigned long) inBuff + bytesSent),inBuffLength - bytesSent,0);
1334
1335 if (theOTResult >= 0)
1336 {
1337 bytesSent += theOTResult;
1338
1339 theOTResult = noErr;
1340
1341 // Reset timer....
1342
1343 PrepareForAsyncOperation(theSocketStruct,0);
1344 }
1345
1346 if (theOTResult == kOTFlowErr)
1347 {
1348 if (TimeoutElapsed(theSocketStruct))
1349 {
1350 SetErrorCodeAndMessageAndBail(kMacSocket_TimeoutErr,"MacSocket_send: Send timed-out")
1351 }
1352
1353 theOTResult = noErr;
1354 }
1355
1356 SetErrorMessageAndLongIntAndBailIfError(theOTResult,"MacSocket_send: Can't send OT data, OTSnd() = ",theOTResult);
1357 }
1358
1359
1360 errCode = noErr;
1361
1362#ifdef MACSOCKET_DEBUG
1363 printf("MacSocket_send: sent %d bytes\n",bytesSent);
1364#endif
1365
1366
1367EXITPOINT:
1368
1369 if (theSocketStruct != nil)
1370 {
1371 theSocketStruct->mLastError = noErr;
1372
1373 CopyCStrToCStr("",theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1374
1375 if (errCode != noErr)
1376 {
1377 theSocketStruct->mLastError = errCode;
1378
1379 CopyCStrToCStr(GetErrorMessage(),theSocketStruct->mErrMessage,sizeof(theSocketStruct->mErrMessage));
1380 }
1381 }
1382
1383 if (errCode != noErr)
1384 {
1385 ::SysBeep(1);
1386 }
1387
1388 errno = errCode;
1389
1390 return(bytesSent);
1391}
1392
1393
1394
1395
1396
1397static OSStatus NegotiateIPReuseAddrOption(EndpointRef inEndpoint,const Boolean inEnableReuseIP)
1398{
1399OSStatus errCode;
1400UInt8 buf[kOTFourByteOptionSize];
1401TOption* theOTOption;
1402TOptMgmt theOTRequest;
1403TOptMgmt theOTResult;
1404
1405
1406 if (!OTIsSynchronous(inEndpoint))
1407 {
1408 SetErrorMessageAndBail("NegotiateIPReuseAddrOption: Open Transport endpoint is not synchronous");
1409 }
1410
1411 theOTRequest.opt.buf = buf;
1412 theOTRequest.opt.len = sizeof(buf);
1413 theOTRequest.flags = T_NEGOTIATE;
1414
1415 theOTResult.opt.buf = buf;
1416 theOTResult.opt.maxlen = kOTFourByteOptionSize;
1417
1418
1419 theOTOption = (TOption *) buf;
1420
1421 theOTOption->level = INET_IP;
1422 theOTOption->name = IP_REUSEADDR;
1423 theOTOption->len = kOTFourByteOptionSize;
1424 theOTOption->status = 0;
1425 *((UInt32 *) (theOTOption->value)) = inEnableReuseIP;
1426
1427 errCode = ::OTOptionManagement(inEndpoint,&theOTRequest,&theOTResult);
1428
1429 if (errCode == kOTNoError)
1430 {
1431 if (theOTOption->status != T_SUCCESS)
1432 {
1433 errCode = theOTOption->status;
1434 }
1435
1436 else
1437 {
1438 errCode = kOTNoError;
1439 }
1440 }
1441
1442
1443EXITPOINT:
1444
1445 errno = errCode;
1446
1447 return(errCode);
1448}
1449
1450
1451
1452
1453
1454// Some rough notes....
1455
1456
1457
1458// OTAckSends(ep);
1459// OTAckSends(ep) // enable AckSend option
1460// ......
1461// buf = OTAllocMem( nbytes); // Allocate nbytes of memory from OT
1462// OTSnd(ep, buf, nbytes, 0); // send a packet
1463// ......
1464// NotifyProc( .... void* theParam) // Notifier Proc
1465// case T_MEMORYRELEASED: // process event
1466// OTFreeMem( theParam); // free up memory
1467// break;
1468
1469
1470
1471/*
1472struct InetInterfaceInfo
1473{
1474 InetHost fAddress;
1475 InetHost fNetmask;
1476 InetHost fBroadcastAddr;
1477 InetHost fDefaultGatewayAddr;
1478 InetHost fDNSAddr;
1479 UInt16 fVersion;
1480 UInt16 fHWAddrLen;
1481 UInt8* fHWAddr;
1482 UInt32 fIfMTU;
1483 UInt8* fReservedPtrs[2];
1484 InetDomainName fDomainName;
1485 UInt32 fIPSecondaryCount;
1486 UInt8 fReserved[252];
1487};
1488typedef struct InetInterfaceInfo InetInterfaceInfo;
1489
1490
1491
1492((InetAddress *) addr.buf)->fHost
1493
1494struct TBind
1495{
1496 TNetbuf addr;
1497 OTQLen qlen;
1498};
1499
1500typedef struct TBind TBind;
1501
1502struct TNetbuf
1503{
1504 size_t maxlen;
1505 size_t len;
1506 UInt8* buf;
1507};
1508
1509typedef struct TNetbuf TNetbuf;
1510
1511
1512 struct InetAddress
1513{
1514 OTAddressType fAddressType; // always AF_INET
1515 InetPort fPort; // Port number
1516 InetHost fHost; // Host address in net byte order
1517 UInt8 fUnused[8]; // Traditional unused bytes
1518};
1519typedef struct InetAddress InetAddress;
1520*/
1521
1522
1523
1524/*
1525static pascal void Notifier(void* context, OTEventCode event, OTResult result, void* cookie)
1526{
1527EPInfo* epi = (EPInfo*) context;
1528
1529 switch (event)
1530 {
1531 case T_LISTEN:
1532 {
1533 DoListenAccept();
1534 return;
1535 }
1536
1537 case T_ACCEPTCOMPLETE:
1538 {
1539 if (result != kOTNoError)
1540 DBAlert1("Notifier: T_ACCEPTCOMPLETE - result %d",result);
1541 return;
1542 }
1543
1544 case T_PASSCON:
1545 {
1546 if (result != kOTNoError)
1547 {
1548 DBAlert1("Notifier: T_PASSCON result %d", result);
1549 return;
1550 }
1551
1552 OTAtomicAdd32(1, &gCntrConnections);
1553 OTAtomicAdd32(1, &gCntrTotalConnections);
1554 OTAtomicAdd32(1, &gCntrIntervalConnects);
1555
1556 if ( OTAtomicSetBit(&epi->stateFlags, kPassconBit) != 0 )
1557 {
1558 ReadData(epi);
1559 }
1560
1561 return;
1562 }
1563
1564 case T_DATA:
1565 {
1566 if ( OTAtomicSetBit(&epi->stateFlags, kPassconBit) != 0 )
1567 {
1568 ReadData(epi);
1569 }
1570
1571 return;
1572 }
1573
1574 case T_GODATA:
1575 {
1576 SendData(epi);
1577 return;
1578 }
1579
1580 case T_DISCONNECT:
1581 {
1582 DoRcvDisconnect(epi);
1583 return;
1584 }
1585
1586 case T_DISCONNECTCOMPLETE:
1587 {
1588 if (result != kOTNoError)
1589 DBAlert1("Notifier: T_DISCONNECT_COMPLETE result %d",result);
1590
1591 return;
1592 }
1593
1594 case T_MEMORYRELEASED:
1595 {
1596 OTAtomicAdd32(-1, &epi->outstandingSends);
1597 return;
1598 }
1599
1600 default:
1601 {
1602 DBAlert1("Notifier: unknown event <%x>", event);
1603 return;
1604 }
1605 }
1606}
1607*/
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h
new file mode 100644
index 0000000000..6e90a5bb44
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/MacSocket.h
@@ -0,0 +1,103 @@
1#pragma once
2
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8
9
10enum
11{
12 kMacSocket_TimeoutErr = -2
13};
14
15
16// Since MacSocket does busy waiting, I do a callback while waiting
17
18typedef OSErr (*MacSocket_IdleWaitCallback)(void *);
19
20
21// Call this before anything else!
22
23OSErr MacSocket_Startup(void);
24
25
26// Call this to cleanup before quitting
27
28OSErr MacSocket_Shutdown(void);
29
30
31// Call this to allocate a "socket" (reference number is returned in outSocketNum)
32// Note that inDoThreadSwitching is pretty much irrelevant right now, since I ignore it
33// The inTimeoutTicks parameter is applied during reads/writes of data
34// The inIdleWaitCallback parameter specifies a callback which is called during busy-waiting periods
35// The inUserRefPtr parameter is passed back to the idle-wait callback
36
37OSErr MacSocket_socket(int *outSocketNum,const Boolean inDoThreadSwitching,const long inTimeoutTicks,MacSocket_IdleWaitCallback inIdleWaitCallback,void *inUserRefPtr);
38
39
40// Call this to connect to an IP/DNS address
41// Note that inTargetAddressAndPort is in "IP:port" format-- e.g. 10.1.1.1:123
42
43OSErr MacSocket_connect(const int inSocketNum,char *inTargetAddressAndPort);
44
45
46// Call this to listen on a port
47// Since this a low-performance implementation, I allow a maximum of 1 (one!) incoming request when I listen
48
49OSErr MacSocket_listen(const int inSocketNum,const int inPortNum);
50
51
52// Call this to close a socket
53
54OSErr MacSocket_close(const int inSocketNum);
55
56
57// Call this to receive data on a socket
58// Most parameters' purpose are obvious-- except maybe "inBlock" which controls whether I wait for data or return immediately
59
60int MacSocket_recv(const int inSocketNum,void *outBuff,int outBuffLength,const Boolean inBlock);
61
62
63// Call this to send data on a socket
64
65int MacSocket_send(const int inSocketNum,void *inBuff,int inBuffLength);
66
67
68// If zero bytes were read in a call to MacSocket_recv(), it may be that the remote end has done a half-close
69// This function will let you check whether that's true or not
70
71Boolean MacSocket_RemoteEndIsClosing(const int inSocketNum);
72
73
74// Call this to see if the listen has completed after a call to MacSocket_listen()
75
76Boolean MacSocket_ListenCompleted(const int inSocketNum);
77
78
79// These really aren't very useful anymore
80
81Boolean MacSocket_LocalEndIsOpen(const int inSocketNum);
82Boolean MacSocket_RemoteEndIsOpen(const int inSocketNum);
83
84
85// You may wish to change the userRefPtr for a socket callback-- use this to do it
86
87void MacSocket_SetUserRefPtr(const int inSocketNum,void *inNewRefPtr);
88
89
90// Call these to get the socket's IP:port descriptor
91
92void MacSocket_GetLocalIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength);
93void MacSocket_GetRemoteIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength);
94
95
96// Call this to get error info from a socket
97
98void MacSocket_GetSocketErrorInfo(const int inSocketNum,int *outSocketErrCode,char *outSocketErrString,const int inSocketErrStringMaxLength);
99
100
101#ifdef __cplusplus
102}
103#endif
diff --git a/src/lib/libssl/src/MacOS/OpenSSL.mcp.hqx b/src/lib/libssl/src/MacOS/OpenSSL.mcp.hqx
new file mode 100644
index 0000000000..2efa49ac01
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/OpenSSL.mcp.hqx
@@ -0,0 +1,4880 @@
1(This file must be converted with BinHex 4.0)
2
3:#dp`C@j68d`ZE@0`!%e08(*$9dP&!!!!!j)H!!!!!)X-Bfp[E!!!!!-!!!%S!!0
4ipJ!$HKi!!"J!!!!"!!%#!3!!!!!!!!!!!%0[C'9ABA*bD@pb)&"bEfTPBh3!!!!
5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"(CA4)9&4
1038b"38%-k4'9LG@GRCA)J8R9ZG'PYC3"(CA4)9&438b"38%-k8fpeFQ0P)&4bC@9
11c!%GPG%K89&"6)&"33cT$GA0dEfdJ5f9jGfpbC(-!4f9d5&488&-J8&"$1N&MBf9
12cFb"3BA4SF`"(CA4)9&438b"38%-k9'&bCf9d)&0PG(4TEQGc!%GPG%K89&"6)&"
1333cT'D@aP)%eKF("TEQGc!%GPG%K89&"6)&"33cT#G@PXC#"&H(4bBA-!4f9d5&4
1488&-J8&"$1N4PBR9RCf9b)&4KFQGPG!"(CA4)9&438b"38%-k0MK,)%0[C'9(C@i
15!4f9d5&488&-J8&"$1MBi5b"%DA0KFh0PE@*XCA)!4f9d5&488&-J8&"$1MBi5b"
16(E'pLB@`J6h"dD@eTHQ9b!%GPG%K89&"6)&"33cSf1%XJ6'P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a&!3!!r8C*6%8"!!$r4NP-43%!!3C'58a&!3!""dC*6%8"!!%
4601)4NP-43%!!3P'58a&!3!""8C*6%8"!!%%4NP-43%!!30'58a&!3!!cdC*6%8"!!$
460204NP-43%!!-j'58a&!3!!e8C*6%8"!!$[4NP-43%!!0&'58a&!3!!edC*6%8"!!$
460334NP-43%!!0P'58a&!3!!f%C*6%8"!!'A4NP-43%!!CK(8P93!!!!!!!!!"3%D'e
4604KB`!!!!&'58a&!3!"#NG599!!!!!!!!!!&34TC'9K!!!!"8C*6%8"!!%,4NP-43%
4605!!3a'58a&!3!"$NC*6%8"!!%04NP-43%!!3p(8P93!!!!!!!!!"B&E'KKFfJ!!!!
4606#4NP-43%!!4"'58a&!3!"%8G599!!!!!!!!!!&`0YC$)!!!!#4NP-43%!!4*'58a
4607&!3!"%dG599!!!!!!!!!!'!0YC$8!!!!#4NP-43%!!44'58a&!3!"&8G599!!!!!
4608!!!!!'34YC'-b!!!!!NC*6%8"!!%@4NP-43%!!4G(8P93!!!!!!!!!"S(Ef*UC@0
4609dF`!!!!4'58a&!3!"'dC*6%8"!!%B4NP-43%!!4T'58a&!3!"'8G599!!!!!!!!!
4610!'`0`C@d!!!!'4NP-43%!!5&'58a&!3!")%C*6%8"!!%H4NP-43%!!4p'58a&!3!
4611"(%C*6%8"!!%G4e*98!!!!!!!!!!F"R"VBh-a-J!!!""'58a&!3!")NC*6%8"!!%
4612M4NP-43%!!54'58a&!3!"*8C*6%8"!!%Q4NP-43%!!5G'58a&!3!"+%C*6%8"!!%
4613T4NP-43%!!5T'58a&!3!"+dC*6%8"!!%X4NP-43%!!5e'58a&!3!",NC*6%8"!!%
4614[4NP-43%!!CP'58a&!3!"-%G599!!!!!!!!!!(39`Df0c0`!!!!C'58a&!3!"-NC
4615*6%8"!!%c4NP-43%!!6&'58a&!3!"R%C*6%8"!!'D4NP-43%!!CY(8P93!!!!!!!
4616!!"i%FQ&ZC!!!!!4'58a&!3!"0%C*6%8"!!%e4NP-43%!!6C'58a&!3!"TdG599!
4617!!!!!!!!!(`0bBc)!!!!&4NP-43%!!6T'58a&!3!"1dC*6%8"!!%j4NP-43%!!6G
4618'58a&!3!"1%G599!!!!!!!!!!)!0bBc3!!!!#4NP-43%!!6e'58a&!3!"2%G599!
4619!!!!!!!!!)30bBc8!!!!&4NP-43%!!8*'58a&!3!"3%C*6%8"!!&"4NP-43%!!6j
4620'58a&!3!"2dG599!!!!!!!!!!)JCbDA"PE@3!!!!#4NP-43%!!80'58a&!3!"4%G
4621599!!!!!!!!!!)`0bFf%!!!!-4NP-43%!!89'58a&!3!"4dC*6%8"!!&)4NP-43%
4622!!8e'58a&!3!"6%C*6%8"!!&'4NP-43%!!8Y'58a&!3!"6NC*6%8"!!&*4NP-43%
4623!!8T'58a&!3!"R8C*6%8"!!'H4e*98!!!!!!!!!!N!h0SB3!!!!4'58a&!3!"88C
4624*6%8"!!&24NP-43%!!9*'58a&!3!"8%G599!!!!!!!!!!*39cG'&MD`!!!!&'58a
4625&!3!"8dG599!!!!!!!!!!*JCdH(4IC')!!!!"4NP-43%!!94(8P93!!!!!!!!!#F
4626%H$8`13!!!"9'58a&!3!"A%C*6%8"!!&E4NP-43%!!@&'58a&!3!"@NC*6%8"!!&
4627J4NP-43%!!@*'58a&!3!"JdC*6%8"!!&Q4NP-43%!!@0'58a&!3!"@%C*6%8"!!&
4628G4NP-43%!!9G'58a&!3!"C8C*6%8"!!&H4NP-43%!!9P'58a&!3!"AdC*6%8"!!&
4629R4NP-43%!!@4'58a&!3!"K%C*6%8"!!&94NP-43%!!9C(8P93!!!!!!!!!#J'H$8
4630`1ABc!!!!&8C*6%8"!!&V4NP-43%!!@a'58a&!3!"E8C*6%8"!!&a4NP-43%!!A0
4631'58a&!3!"G8C*6%8"!!&h4NP-43%!!AT'58a&!3!"D%C*6%8"!!&b4NP-43%!!@T
4632'58a&!3!"H%C*6%8"!!&T4NP-43%!!AC'58a&!3!"G%C*6%8"!!&`4NP-43%!!AP
4633'58a&!3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!!!!!!$2(J!!!!3EA4`D3!!!!J
4874!!!!!!!!!!!!$2)J!!!!JEA4cE!!!!!J!!!!!!!!!!!!$2+J!!!A8EA4XE`!!!!J
4875!!!!!!!!!!!!$D9S!!"$%EA4RE!!!!qJ!!!!!!!!!!!!$8d!!!!!XE@pdD3!!!!!
4876!!!!!!!!!!!!$8f`!!"1!8%acG!!19TJ!!!$*!!!!!!!"&P)!!!)XEA"cD3!!!qJ
4877!!!!!!!!!!!!$D1S!!!!3EA0dF!!!!!)!!!!!!!!!!!!$D2S!!!!3EA0dF!!!!!8
4878!!!!!!!!!!!!!@NJ!!!!SEA0dD3!!!qJ!!!!!!!!!!!!$D6)!!!!SEA0dD3!!!!!
4879!!!!!!!!!!!!!@R!!!!!-E@&XE!!!!!!!!!!!!!!!!!!$6(`!!!$%E@&`E!!!!!!
4880!!!!!!!!!!-eY!!!:
diff --git a/src/lib/libssl/src/MacOS/TODO b/src/lib/libssl/src/MacOS/TODO
new file mode 100644
index 0000000000..903eb133de
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/TODO
@@ -0,0 +1,18 @@
1-------------------------------------------------------------------
2Verify server certificate
3-------------------------------------------------------------------
4Currently omitted from the project:
5
6 crypto/tmdiff.c
7 crypto/bio/bss_conn.c
8 crypto/bio/b_sock.c
9 crypto/bio/bss_acpt.c
10 crypto/bio/bss_log.h
11
12-------------------------------------------------------------------
13Build libraries to link with...
14-------------------------------------------------------------------
15Port openssl application.
16-------------------------------------------------------------------
17BN optimizations (currently PPC version is compiled with BN_LLONG)
18-------------------------------------------------------------------
diff --git a/src/lib/libssl/src/MacOS/_MWERKS_GUSI_prefix.h b/src/lib/libssl/src/MacOS/_MWERKS_GUSI_prefix.h
new file mode 100644
index 0000000000..fe6b5387d6
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/_MWERKS_GUSI_prefix.h
@@ -0,0 +1,9 @@
1#include <MacHeaders.h>
2#define B_ENDIAN
3#ifdef __POWERPC__
4#pragma longlong on
5#endif
6#if 1
7#define MAC_OS_GUSI_SOURCE
8#endif
9#define MONOLITH
diff --git a/src/lib/libssl/src/MacOS/_MWERKS_prefix.h b/src/lib/libssl/src/MacOS/_MWERKS_prefix.h
new file mode 100644
index 0000000000..2189da753b
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/_MWERKS_prefix.h
@@ -0,0 +1,9 @@
1#include <MacHeaders.h>
2#define B_ENDIAN
3#ifdef __POWERPC__
4#pragma longlong on
5#endif
6#if 0
7#define MAC_OS_GUSI_SOURCE
8#endif
9#define MONOLITH
diff --git a/src/lib/libssl/src/MacOS/buildinf.h b/src/lib/libssl/src/MacOS/buildinf.h
new file mode 100644
index 0000000000..90875b6e2f
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/buildinf.h
@@ -0,0 +1,5 @@
1#ifndef MK1MF_BUILD
2# define CFLAGS "-DB_ENDIAN"
3# define PLATFORM "macos"
4# define DATE "Sun Feb 27 19:44:16 MET 2000"
5#endif
diff --git a/src/lib/libssl/src/MacOS/mklinks.as.hqx b/src/lib/libssl/src/MacOS/mklinks.as.hqx
new file mode 100644
index 0000000000..fe3e7d53da
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/mklinks.as.hqx
@@ -0,0 +1,820 @@
1(This file must be converted with BinHex 4.0)
2
3:#QeVE'PZDh-ZBA-!39"36'&`E(3J!!!!!!!!!*LiI6m!!!!!!3!!!*G#!!#@3J!
4!!AChFQPd!!!!K3)"!3m(Fh9`F'pbG!!!!)B#!3%$"(0eFQ8!!!#(!J-%"!3("3C
5cGfPdBfJ!!!#)!J%"#39cH@jMD!!!!)N#"J%$!`-&"3-'FhPcG'9Y!!!!LJ)&"3)
6%!J8("!-#!`4dB@*X!!!!L`))!3-$!`-$!`-$"(4PE'`!!!#-!J)"#38$G'KP!!!
7!M3))(J)@!Ki#!J))!K)#!`)B!Kd%G'KPE3!!!)i#!J%&#`4dD'9j!!!!M`)#!J)
8#$3TdD(*[G@GSEh9d!!!!N!!#!3%&"(4TCQ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PC#"QEfaNCA)!!J!!$!5h!%i!5%e
810KBfPZG'pcD#")4$T%CA0VG'p`)%C[E'4PFMT*EQ0[E@PZCcT[F'9ZFh0X,90139!
811Y-6Nj16%b-6%kBh*jF(4[1RJe-$Pf-`!#!!!"r,%!!!(mX!!!!Ib[!!!"r+i!!'&
812cBh)!!3!-qYlHV3!!!3!!!*G#!!#@3J!!!AB!!$-8-0J!!!!F!AB!$h0MFhS!!!#
813#6Np853!!!)jcBh"d!!!!QP4&@&3!!3#QFh4jE!!!!,j$6d4&!!%!bN*14%`!!!$
814LBA"XG!!!!1j'8N9'!!!!qNP$6L-!!!%'D@0X0!!!!4*TBh-M!!!"(QPMFc3!!!%
815UD'CNFJ!!!6C659T&!!!"3PG3Eh-!!!&1!!$rr`!!!!!!!!!!!)$rre!!!"i!!!!
816!!)$rr`!!"cJ#DH#m"'Mrr`!!!*S!!!!!%iRrr`!!"Pi!!!!!"'Mrr`!!!53!!!!
817!!!$rrb!!!9)!!!!!!!(rra3!!@i#DG`%!)$rr`!!!Pi#DH"X!!$rr`!!!Ri!!!!
818!!)$rr`!!!S-#DH"d!*Err`!!!Si!!!!!!*Err`!!!j)!!!!!!*Err`!!"CB#DH%
819i!*Err`!!"GS#DH%dkF$rr`!!"[`!!!!!rrrrr`!!"a)!!!!!!)$rr`!!"b!!!!!
820!*4S:
diff --git a/src/lib/libssl/src/MacOS/opensslconf.h b/src/lib/libssl/src/MacOS/opensslconf.h
new file mode 100644
index 0000000000..ad557cc06a
--- /dev/null
+++ b/src/lib/libssl/src/MacOS/opensslconf.h
@@ -0,0 +1,116 @@
1/* MacOS/opensslconf.h */
2
3#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
4#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/usr/local/ssl"
6#endif
7#endif
8
9#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
10#define IDEA_INT unsigned int
11#endif
12
13#if defined(HEADER_MD2_H) && !defined(MD2_INT)
14#define MD2_INT unsigned int
15#endif
16
17#if defined(HEADER_RC2_H) && !defined(RC2_INT)
18/* I need to put in a mod for the alpha - eay */
19#define RC2_INT unsigned int
20#endif
21
22#if defined(HEADER_RC4_H)
23#if !defined(RC4_INT)
24/* using int types make the structure larger but make the code faster
25 * on most boxes I have tested - up to %20 faster. */
26/*
27 * I don't know what does "most" mean, but declaring "int" is a must on:
28 * - Intel P6 because partial register stalls are very expensive;
29 * - elder Alpha because it lacks byte load/store instructions;
30 */
31#define RC4_INT unsigned char
32#endif
33#if !defined(RC4_CHUNK)
34/*
35 * This enables code handling data aligned at natural CPU word
36 * boundary. See crypto/rc4/rc4_enc.c for further details.
37 */
38#define RC4_CHUNK unsigned long
39#endif
40#endif
41
42#if defined(HEADER_DES_H) && !defined(DES_LONG)
43/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
44 * %20 speed up (longs are 8 bytes, int's are 4). */
45#ifndef DES_LONG
46#define DES_LONG unsigned long
47#endif
48#endif
49
50#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
51#define CONFIG_HEADER_BN_H
52#if __option(longlong)
53# define BN_LLONG
54#else
55# undef BN_LLONG
56#endif
57
58/* Should we define BN_DIV2W here? */
59
60/* Only one for the following should be defined */
61/* The prime number generation stuff may not work when
62 * EIGHT_BIT but I don't care since I've only used this mode
63 * for debuging the bignum libraries */
64#undef SIXTY_FOUR_BIT_LONG
65#undef SIXTY_FOUR_BIT
66#define THIRTY_TWO_BIT
67#undef SIXTEEN_BIT
68#undef EIGHT_BIT
69#endif
70
71#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
72#define CONFIG_HEADER_RC4_LOCL_H
73/* if this is defined data[i] is used instead of *data, this is a %20
74 * speedup on x86 */
75#undef RC4_INDEX
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#define BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85/* the following is tweaked from a config script, that is why it is a
86 * protected undef/define */
87#ifndef DES_PTR
88#define DES_PTR
89#endif
90
91/* This helps C compiler generate the correct code for multiple functional
92 * units. It reduces register dependancies at the expense of 2 more
93 * registers */
94#ifndef DES_RISC1
95#define DES_RISC1
96#endif
97
98#ifndef DES_RISC2
99#undef DES_RISC2
100#endif
101
102#if defined(DES_RISC1) && defined(DES_RISC2)
103YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
104#endif
105
106/* Unroll the inner loop, this sometimes helps, sometimes hinders.
107 * Very mucy CPU dependant */
108#ifndef DES_UNROLL
109#define DES_UNROLL
110#endif
111
112#endif /* HEADER_DES_LOCL_H */
113
114#ifndef __POWERPC__
115#define MD32_XARRAY
116#endif
diff --git a/src/lib/libssl/src/Makefile.org b/src/lib/libssl/src/Makefile.org
index 1dd3d81b6d..be6894426f 100644
--- a/src/lib/libssl/src/Makefile.org
+++ b/src/lib/libssl/src/Makefile.org
@@ -56,6 +56,8 @@ EX_LIBS=
56AR=ar r 56AR=ar r
57RANLIB= ranlib 57RANLIB= ranlib
58PERL= perl 58PERL= perl
59TAR= tar
60TARFLAGS= --norecurse
59 61
60# Set BN_ASM to bn_asm.o if you want to use the C version 62# Set BN_ASM to bn_asm.o if you want to use the C version
61BN_ASM= bn_asm.o 63BN_ASM= bn_asm.o
@@ -156,6 +158,7 @@ SDIRS= \
156MAKEFILE= Makefile.ssl 158MAKEFILE= Makefile.ssl
157MAKE= make -f Makefile.ssl 159MAKE= make -f Makefile.ssl
158 160
161MANDIR=$(OPENSSLDIR)/man
159MAN1=1 162MAN1=1
160MAN3=3 163MAN3=3
161SHELL=/bin/sh 164SHELL=/bin/sh
@@ -180,6 +183,7 @@ all: Makefile.ssl
180 (cd $$i && echo "making all in $$i..." && \ 183 (cd $$i && echo "making all in $$i..." && \
181 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' 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}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' SDIRS='${SDIRS}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' all ) || exit 1; \ 184 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' 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}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' SDIRS='${SDIRS}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' all ) || exit 1; \
182 done 185 done
186 -@# cd crypto; $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' 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}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' SDIRS='${SDIRS}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' testapps
183 -@# cd perl; $(PERL) Makefile.PL; make 187 -@# cd perl; $(PERL) Makefile.PL; make
184 188
185sub_all: 189sub_all:
@@ -215,7 +219,7 @@ libclean:
215 rm -f *.a */lib */*/lib 219 rm -f *.a */lib */*/lib
216 220
217clean: 221clean:
218 rm -f shlib/*.o *.o core a.out fluff *.map 222 rm -f shlib/*.o *.o core a.out fluff *.map rehash.time testlog make.log cctest cctest.c
219 @for i in $(DIRS) ;\ 223 @for i in $(DIRS) ;\
220 do \ 224 do \
221 (cd $$i && echo "making clean in $$i..." && \ 225 (cd $$i && echo "making clean in $$i..." && \
@@ -242,7 +246,7 @@ files:
242 done; 246 done;
243 247
244links: 248links:
245 @$(SHELL) $(TOP)/util/point.sh Makefile.ssl Makefile 249 @$(TOP)/util/point.sh Makefile.ssl Makefile
246 @$(PERL) $(TOP)/util/mkdir-p.pl include/openssl 250 @$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
247 @$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER) 251 @$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
248 @for i in $(DIRS); do \ 252 @for i in $(DIRS); do \
@@ -258,8 +262,10 @@ dclean:
258 $(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' dclean ) || exit 1; \ 262 $(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' dclean ) || exit 1; \
259 done; 263 done;
260 264
261rehash: 265rehash: rehash.time
266rehash.time: certs
262 @(OPENSSL="`pwd`/apps/openssl"; export OPENSSL; sh tools/c_rehash certs) 267 @(OPENSSL="`pwd`/apps/openssl"; export OPENSSL; sh tools/c_rehash certs)
268 touch rehash.time
263 269
264test: tests 270test: tests
265 271
@@ -268,6 +274,9 @@ tests: rehash
268 $(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}' tests ); 274 $(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}' tests );
269 @apps/openssl version -a 275 @apps/openssl version -a
270 276
277report:
278 @$(PERL) util/selftest.pl
279
271depend: 280depend:
272 @for i in $(DIRS) ;\ 281 @for i in $(DIRS) ;\
273 do \ 282 do \
@@ -298,14 +307,17 @@ util/libeay.num::
298util/ssleay.num:: 307util/ssleay.num::
299 perl util/mkdef.pl ssl update 308 perl util/mkdef.pl ssl update
300 309
310crypto/objects/obj_dat.h: crypto/objects/objects.h crypto/objects/obj_dat.pl
311 perl crypto/objects/obj_dat.pl crypto/objects/objects.h crypto/objects/obj_dat.h
312
301TABLE: Configure 313TABLE: Configure
302 (echo 'Output of `Configure TABLE'"':"; \ 314 (echo 'Output of `Configure TABLE'"':"; \
303 perl Configure TABLE) > TABLE 315 perl Configure TABLE) > TABLE
304 316
305update: depend errors util/libeay.num util/ssleay.num TABLE 317update: depend errors util/libeay.num util/ssleay.num crypto/objects/obj_dat.h TABLE
306 318
307tar: 319tar:
308 @tar --norecurse -cvf - \ 320 @$(TAR) $(TARFLAGS) -cvf - \
309 `find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort` |\ 321 `find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort` |\
310 tardy --user_number=0 --user_name=openssl \ 322 tardy --user_number=0 --user_name=openssl \
311 --group_number=0 --group_name=openssl \ 323 --group_number=0 --group_name=openssl \
@@ -322,7 +334,7 @@ dist:
322dist_pem_h: 334dist_pem_h:
323 (cd crypto/pem; $(MAKE) CC='${CC}' SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean) 335 (cd crypto/pem; $(MAKE) CC='${CC}' SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean)
324 336
325install: all 337install: all install_docs
326 @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ 338 @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
327 $(INSTALL_PREFIX)$(INSTALLTOP)/lib \ 339 $(INSTALL_PREFIX)$(INSTALLTOP)/lib \
328 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \ 340 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
@@ -338,7 +350,7 @@ install: all
338 @for i in $(DIRS) ;\ 350 @for i in $(DIRS) ;\
339 do \ 351 do \
340 (cd $$i; echo "installing $$i..."; \ 352 (cd $$i; echo "installing $$i..."; \
341 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' install ); \ 353 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' RANLIB='${RANLIB}' install ); \
342 done 354 done
343 @for i in $(LIBS) ;\ 355 @for i in $(LIBS) ;\
344 do \ 356 do \
@@ -348,4 +360,29 @@ install: all
348 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ 360 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
349 done 361 done
350 362
363install_docs:
364 @$(PERL) $(TOP)/util/mkdir-p.pl \
365 $(INSTALL_PREFIX)$(MANDIR)/man1 \
366 $(INSTALL_PREFIX)$(MANDIR)/man3 \
367 $(INSTALL_PREFIX)$(MANDIR)/man5 \
368 $(INSTALL_PREFIX)$(MANDIR)/man7
369 @echo installing man 1 and man 5
370 @for i in doc/apps/*.pod; do \
371 (cd `dirname $$i`; \
372 fn=`basename $$i .pod`; \
373 sec=`[ "$$fn" = "config" ] && echo 5 || echo 1`; \
374 $(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
375 --release=$(VERSION) `basename $$i` \
376 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec); \
377 done
378 @echo installing man 3 and man 7
379 @for i in doc/crypto/*.pod doc/ssl/*.pod; do \
380 (cd `dirname $$i`; \
381 fn=`basename $$i .pod`; \
382 sec=`[ "$$fn" = "des_modes" ] && echo 7 || echo 3`; \
383 $(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
384 --release=$(VERSION) `basename $$i` \
385 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec); \
386 done
387
351# DO NOT DELETE THIS LINE -- make depend depends on it. 388# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/NEWS b/src/lib/libssl/src/NEWS
index c152b7155d..a2084af8e6 100644
--- a/src/lib/libssl/src/NEWS
+++ b/src/lib/libssl/src/NEWS
@@ -5,6 +5,42 @@
5 This file gives a brief overview of the major changes between each OpenSSL 5 This file gives a brief overview of the major changes between each OpenSSL
6 release. For more details please read the CHANGES file. 6 release. For more details please read the CHANGES file.
7 7
8 Major changes between OpenSSL 0.9.4 and OpenSSL 0.9.5:
9
10 o S/MIME support in new 'smime' command
11 o Documentation for the OpenSSL command line application
12 o Automation of 'req' application
13 o Fixes to make s_client, s_server work under Windows
14 o Support for multiple fieldnames in SPKACs
15 o New SPKAC command line utilty and associated library functions
16 o Options to allow passwords to be obtained from various sources
17 o New public key PEM format and options to handle it
18 o Many other fixes and enhancements to command line utilities
19 o Usable certificate chain verification
20 o Certificate purpose checking
21 o Certificate trust settings
22 o Support of authority information access extension
23 o Extensions in certificate requests
24 o Simplified X509 name and attribute routines
25 o Initial (incomplete) support for international character sets
26 o New DH_METHOD, DSA_METHOD and enhanced RSA_METHOD
27 o Read only memory BIOs and simplified creation function
28 o TLS/SSL protocol bugfixes: Accept TLS 'client hello' in SSL 3.0
29 record; allow fragmentation and interleaving of handshake and other
30 data
31 o TLS/SSL code now "tolerates" MS SGC
32 o Work around for Netscape client certificate hang bug
33 o RSA_NULL option that removes RSA patent code but keeps other
34 RSA functionality
35 o Memory leak detection now allows applications to add extra information
36 via a per-thread stack
37 o PRNG robustness improved
38 o EGD support
39 o BIGNUM library bug fixes
40 o Faster DSA parameter generation
41 o Enhanced support for Alpha Linux
42 o Experimental MacOS support
43
8 Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4: 44 Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4:
9 45
10 o Transparent support for PKCS#8 format private keys: these are used 46 o Transparent support for PKCS#8 format private keys: these are used
diff --git a/src/lib/libssl/src/README b/src/lib/libssl/src/README
index d7682e8a2f..7ef77c83c6 100644
--- a/src/lib/libssl/src/README
+++ b/src/lib/libssl/src/README
@@ -1,7 +1,7 @@
1 1
2 OpenSSL 0.9.4 09 Aug 1999 2 OpenSSL 0.9.5 28 Feb 2000
3 3
4 Copyright (c) 1998-1999 The OpenSSL Project 4 Copyright (c) 1998-2000 The OpenSSL Project
5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson 5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
6 All rights reserved. 6 All rights reserved.
7 7
@@ -80,40 +80,14 @@
80 A Configuration loader that uses a format similar to MS .ini files. 80 A Configuration loader that uses a format similar to MS .ini files.
81 81
82 openssl: 82 openssl:
83 A command line tool which provides the following functions: 83 A command line tool that can be used for:
84 84 Creation of RSA, DH and DSA key parameters
85 enc - a general encryption program that can encrypt/decrypt using 85 Creation of X.509 certificates, CSRs and CRLs
86 one of 17 different cipher/mode combinations. The 86 Calculation of Message Digests
87 input/output can also be converted to/from base64 87 Encryption and Decryption with Ciphers
88 ascii encoding. 88 SSL/TLS Client and Server Tests
89 dgst - a generate message digesting program that will generate 89 Handling of S/MIME signed or encrypted mail
90 message digests for any of md2, md5, sha (sha-0 or sha-1) 90
91 or mdc2.
92 asn1parse - parse and display the structure of an asn1 encoded
93 binary file.
94 rsa - Manipulate RSA private keys.
95 dsa - Manipulate DSA private keys.
96 dh - Manipulate Diffie-Hellman parameter files.
97 dsaparam- Manipulate and generate DSA parameter files.
98 crl - Manipulate certificate revocation lists.
99 crt2pkcs7- Generate a pkcs7 object containing a crl and a certificate.
100 x509 - Manipulate x509 certificates, self-sign certificates.
101 req - Manipulate PKCS#10 certificate requests and also
102 generate certificate requests.
103 genrsa - Generates an arbitrary sized RSA private key.
104 gendsa - Generates DSA parameters.
105 gendh - Generates a set of Diffie-Hellman parameters, the prime
106 will be a strong prime.
107 ca - Create certificates from PKCS#10 certificate requests.
108 This program also maintains a database of certificates
109 issued.
110 verify - Check x509 certificate signatures.
111 speed - Benchmark OpenSSL's ciphers.
112 s_server- A test SSL server.
113 s_client- A test SSL client.
114 s_time - Benchmark SSL performance of SSL server programs.
115 errstr - Convert from OpenSSL hex error codes to a readable form.
116 nseq - Netscape certificate sequence utility
117 91
118 PATENTS 92 PATENTS
119 ------- 93 -------
@@ -157,43 +131,40 @@
157 If you have any problems with OpenSSL then please take the following steps 131 If you have any problems with OpenSSL then please take the following steps
158 first: 132 first:
159 133
134 - Download the current snapshot from ftp://ftp.openssl.org/snapshot/
135 to see if the problem has already been addressed
160 - Remove ASM versions of libraries 136 - Remove ASM versions of libraries
161 - Remove compiler optimisation flags 137 - Remove compiler optimisation flags
162 - Add compiler debug flags (if using gcc then remove -fomit-frame-pointer
163 before you try to debug things)
164 138
165 If you wish to report a bug then please include the following information in 139 If you wish to report a bug then please include the following information in
166 any bug report: 140 any bug report:
167 141
168 OpenSSL Details 142 - On Unix systems:
169 - Version, most of these details can be got from the 143 Self-test report generated by 'make report'
170 'openssl version -a' command. 144 - On other systems:
171 Operating System Details 145 OpenSSL version: output of 'openssl version -a'
172 - On Unix systems: Output of './config -t' 146 OS Name, Version, Hardware platform
173 - OS Name, Version 147 Compiler Details (name, version)
174 - Hardware platform 148 - Application Details (name, version)
175 Compiler Details 149 - Problem Description (steps that will reproduce the problem, if known)
176 - Name 150 - Stack Traceback (if the application dumps core)
177 - Version
178 Application Details
179 - Name
180 - Version
181 Problem Description
182 - include steps that will reproduce the problem (if known)
183 Stack Traceback (if the application dumps core)
184 151
185 Report the bug to the OpenSSL project at: 152 Report the bug to the OpenSSL project at:
186 153
187 openssl-bugs@openssl.org 154 openssl-bugs@openssl.org
188 155
156 Note that mail to openssl-bugs@openssl.org is forwarded to a public
157 mailing list. Confidential mail may be sent to openssl-security@openssl.org
158 (PGP key available from the key servers).
159
189 HOW TO CONTRIBUTE TO OpenSSL 160 HOW TO CONTRIBUTE TO OpenSSL
190 ---------------------------- 161 ----------------------------
191 162
192 Development is coordinated on the openssl-dev mailing list (see 163 Development is coordinated on the openssl-dev mailing list (see
193 http://www.openssl.org for information on subscribing). If you 164 http://www.openssl.org for information on subscribing). If you
194 would like to submit a patch, send it to openssl-dev@openssl.org. 165 would like to submit a patch, send it to openssl-dev@openssl.org with
195 Please be sure to include a textual explanation of what your patch 166 the string "[PATCH]" in the subject. Please be sure to include a
196 does. 167 textual explanation of what your patch does.
197 168
198 The preferred format for changes is "diff -u" output. You might 169 The preferred format for changes is "diff -u" output. You might
199 generate it like this: 170 generate it like this:
diff --git a/src/lib/libssl/src/VMS/install.com b/src/lib/libssl/src/VMS/install.com
index d941392c23..1664d769e2 100644
--- a/src/lib/libssl/src/VMS/install.com
+++ b/src/lib/libssl/src/VMS/install.com
@@ -37,6 +37,7 @@ $
37$ EXHEADER := vms_idhacks.h 37$ EXHEADER := vms_idhacks.h
38$ 38$
39$ COPY 'EXHEADER' WRK_SSLINCLUDE: /LOG 39$ COPY 'EXHEADER' WRK_SSLINCLUDE: /LOG
40$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'EXHEADER'
40$ 41$
41$ OPEN/WRITE SF WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM 42$ OPEN/WRITE SF WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM
42$ WRITE SYS$OUTPUT "%OPEN-I-CREATED, ",F$SEARCH("WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM")," created." 43$ WRITE SYS$OUTPUT "%OPEN-I-CREATED, ",F$SEARCH("WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM")," created."
@@ -65,7 +66,9 @@ $ WRITE SF " @SSLROOT:[VMS]OPENSSL_SYSTARTUP.COM"
65$ WRITE SF "$" 66$ WRITE SF "$"
66$ WRITE SF "$ EXIT" 67$ WRITE SF "$ EXIT"
67$ CLOSE SF 68$ CLOSE SF
69$ SET FILE/PROT=WORLD:RE WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM
68$ 70$
69$ COPY OPENSSL_UTILS.COM WRK_SSLROOT:[VMS]/LOG 71$ COPY OPENSSL_UTILS.COM WRK_SSLROOT:[VMS]/LOG
72$ SET FILE/PROT=WORLD:RE WRK_SSLROOT:[VMS]OPENSSL_UTILS.COM
70$ 73$
71$ EXIT 74$ EXIT
diff --git a/src/lib/libssl/src/VMS/test-includes.com b/src/lib/libssl/src/VMS/test-includes.com
new file mode 100644
index 0000000000..c1d7ccd0ee
--- /dev/null
+++ b/src/lib/libssl/src/VMS/test-includes.com
@@ -0,0 +1,28 @@
1$! Quick script to check how well including individual header files works
2$! on VMS, even when the VMS macro isn't defined.
3$
4$ sav_def = f$env("DEFAULT")
5$ here = f$parse("A.;0",f$ENV("PROCEDURE")) - "A.;0"
6$ set default 'here'
7$ set default [-.include.openssl]
8$ define openssl 'f$env("DEFAULT")'
9$ set default [--]
10$
11$ loop:
12$ f = f$search("openssl:*.h")
13$ if f .eqs. "" then goto loop_end
14$ write sys$output "Checking ",f
15$ open/write foo foo.c
16$ write foo "#undef VMS"
17$ write foo "#include <stdio.h>"
18$ write foo "#include <openssl/",f$parse(f,,,"NAME"),".h>"
19$ write foo "main()"
20$ write foo "{printf(""foo\n"");}"
21$ close foo
22$ cc/STANDARD=ANSI89/NOLIST/PREFIX=ALL foo.c
23$ delete foo.c;
24$ goto loop
25$ loop_end:
26$ set default 'save_def'
27$ exit
28
diff --git a/src/lib/libssl/src/VMS/vms_idhacks.h b/src/lib/libssl/src/VMS/vms_idhacks.h
index 8cf9e9c61f..c2010c91e4 100644
--- a/src/lib/libssl/src/VMS/vms_idhacks.h
+++ b/src/lib/libssl/src/VMS/vms_idhacks.h
@@ -57,55 +57,124 @@
57 57
58#ifdef VMS 58#ifdef VMS
59 59
60/* Hack a long name in crypto/asn1/a_mbstr.c */
61#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc
60/* Hack the names created with DECLARE_STACK_OF(PKCS7_SIGNER_INFO) */ 62/* Hack the names created with DECLARE_STACK_OF(PKCS7_SIGNER_INFO) */
61#define sk_PKCS7_SIGNER_INFO_new sk_PKCS7_SIGINF_new 63#define sk_PKCS7_SIGNER_INFO_new sk_PKCS7_SIGINF_new
62#define sk_PKCS7_SIGNER_INFO_new_null sk_PKCS7_SIGINF_new_null 64#define sk_PKCS7_SIGNER_INFO_new_null sk_PKCS7_SIGINF_new_null
63#define sk_PKCS7_SIGNER_INFO_free sk_PKCS7_SIGINF_free 65#define sk_PKCS7_SIGNER_INFO_free sk_PKCS7_SIGINF_free
64#define sk_PKCS7_SIGNER_INFO_num sk_PKCS7_SIGINF_num 66#define sk_PKCS7_SIGNER_INFO_num sk_PKCS7_SIGINF_num
65#define sk_PKCS7_SIGNER_INFO_value sk_PKCS7_SIGINF_value 67#define sk_PKCS7_SIGNER_INFO_value sk_PKCS7_SIGINF_value
66#define sk_PKCS7_SIGNER_INFO_set sk_PKCS7_SIGINF_set 68#define sk_PKCS7_SIGNER_INFO_set sk_PKCS7_SIGINF_set
67#define sk_PKCS7_SIGNER_INFO_zero sk_PKCS7_SIGINF_zero 69#define sk_PKCS7_SIGNER_INFO_zero sk_PKCS7_SIGINF_zero
68#define sk_PKCS7_SIGNER_INFO_push sk_PKCS7_SIGINF_push 70#define sk_PKCS7_SIGNER_INFO_push sk_PKCS7_SIGINF_push
69#define sk_PKCS7_SIGNER_INFO_unshift sk_PKCS7_SIGINF_unshift 71#define sk_PKCS7_SIGNER_INFO_unshift sk_PKCS7_SIGINF_unshift
70#define sk_PKCS7_SIGNER_INFO_find sk_PKCS7_SIGINF_find 72#define sk_PKCS7_SIGNER_INFO_find sk_PKCS7_SIGINF_find
71#define sk_PKCS7_SIGNER_INFO_delete sk_PKCS7_SIGINF_delete 73#define sk_PKCS7_SIGNER_INFO_delete sk_PKCS7_SIGINF_delete
72#define sk_PKCS7_SIGNER_INFO_delete_ptr sk_PKCS7_SIGINF_delete_ptr 74#define sk_PKCS7_SIGNER_INFO_delete_ptr sk_PKCS7_SIGINF_delete_ptr
73#define sk_PKCS7_SIGNER_INFO_insert sk_PKCS7_SIGINF_insert 75#define sk_PKCS7_SIGNER_INFO_insert sk_PKCS7_SIGINF_insert
74#define sk_PKCS7_SIGNER_INFO_set_cmp_func sk_PKCS7_SIGINF_set_cmp_func 76#define sk_PKCS7_SIGNER_INFO_set_cmp_func sk_PKCS7_SIGINF_set_cmp_func
75#define sk_PKCS7_SIGNER_INFO_dup sk_PKCS7_SIGINF_dup 77#define sk_PKCS7_SIGNER_INFO_dup sk_PKCS7_SIGINF_dup
76#define sk_PKCS7_SIGNER_INFO_pop_free sk_PKCS7_SIGINF_pop_free 78#define sk_PKCS7_SIGNER_INFO_pop_free sk_PKCS7_SIGINF_pop_free
77#define sk_PKCS7_SIGNER_INFO_shift sk_PKCS7_SIGINF_shift 79#define sk_PKCS7_SIGNER_INFO_shift sk_PKCS7_SIGINF_shift
78#define sk_PKCS7_SIGNER_INFO_pop sk_PKCS7_SIGINF_pop 80#define sk_PKCS7_SIGNER_INFO_pop sk_PKCS7_SIGINF_pop
79#define sk_PKCS7_SIGNER_INFO_sort sk_PKCS7_SIGINF_sort 81#define sk_PKCS7_SIGNER_INFO_sort sk_PKCS7_SIGINF_sort
80 82
81/* Hack the names created with DECLARE_STACK_OF(PKCS7_RECIP_INFO) */ 83/* Hack the names created with DECLARE_STACK_OF(PKCS7_RECIP_INFO) */
82#define sk_PKCS7_RECIP_INFO_new sk_PKCS7_RECINF_new 84#define sk_PKCS7_RECIP_INFO_new sk_PKCS7_RECINF_new
83#define sk_PKCS7_RECIP_INFO_new_null sk_PKCS7_RECINF_new_null 85#define sk_PKCS7_RECIP_INFO_new_null sk_PKCS7_RECINF_new_null
84#define sk_PKCS7_RECIP_INFO_free sk_PKCS7_RECINF_free 86#define sk_PKCS7_RECIP_INFO_free sk_PKCS7_RECINF_free
85#define sk_PKCS7_RECIP_INFO_num sk_PKCS7_RECINF_num 87#define sk_PKCS7_RECIP_INFO_num sk_PKCS7_RECINF_num
86#define sk_PKCS7_RECIP_INFO_value sk_PKCS7_RECINF_value 88#define sk_PKCS7_RECIP_INFO_value sk_PKCS7_RECINF_value
87#define sk_PKCS7_RECIP_INFO_set sk_PKCS7_RECINF_set 89#define sk_PKCS7_RECIP_INFO_set sk_PKCS7_RECINF_set
88#define sk_PKCS7_RECIP_INFO_zero sk_PKCS7_RECINF_zero 90#define sk_PKCS7_RECIP_INFO_zero sk_PKCS7_RECINF_zero
89#define sk_PKCS7_RECIP_INFO_push sk_PKCS7_RECINF_push 91#define sk_PKCS7_RECIP_INFO_push sk_PKCS7_RECINF_push
90#define sk_PKCS7_RECIP_INFO_unshift sk_PKCS7_RECINF_unshift 92#define sk_PKCS7_RECIP_INFO_unshift sk_PKCS7_RECINF_unshift
91#define sk_PKCS7_RECIP_INFO_find sk_PKCS7_RECINF_find 93#define sk_PKCS7_RECIP_INFO_find sk_PKCS7_RECINF_find
92#define sk_PKCS7_RECIP_INFO_delete sk_PKCS7_RECINF_delete 94#define sk_PKCS7_RECIP_INFO_delete sk_PKCS7_RECINF_delete
93#define sk_PKCS7_RECIP_INFO_delete_ptr sk_PKCS7_RECINF_delete_ptr 95#define sk_PKCS7_RECIP_INFO_delete_ptr sk_PKCS7_RECINF_delete_ptr
94#define sk_PKCS7_RECIP_INFO_insert sk_PKCS7_RECINF_insert 96#define sk_PKCS7_RECIP_INFO_insert sk_PKCS7_RECINF_insert
95#define sk_PKCS7_RECIP_INFO_set_cmp_func sk_PKCS7_RECINF_set_cmp_func 97#define sk_PKCS7_RECIP_INFO_set_cmp_func sk_PKCS7_RECINF_set_cmp_func
96#define sk_PKCS7_RECIP_INFO_dup sk_PKCS7_RECINF_dup 98#define sk_PKCS7_RECIP_INFO_dup sk_PKCS7_RECINF_dup
97#define sk_PKCS7_RECIP_INFO_pop_free sk_PKCS7_RECINF_pop_free 99#define sk_PKCS7_RECIP_INFO_pop_free sk_PKCS7_RECINF_pop_free
98#define sk_PKCS7_RECIP_INFO_shift sk_PKCS7_RECINF_shift 100#define sk_PKCS7_RECIP_INFO_shift sk_PKCS7_RECINF_shift
99#define sk_PKCS7_RECIP_INFO_pop sk_PKCS7_RECINF_pop 101#define sk_PKCS7_RECIP_INFO_pop sk_PKCS7_RECINF_pop
100#define sk_PKCS7_RECIP_INFO_sort sk_PKCS7_RECINF_sort 102#define sk_PKCS7_RECIP_INFO_sort sk_PKCS7_RECINF_sort
103
104/* Hack the names created with DECLARE_STACK_OF(ASN1_STRING_TABLE) */
105#define sk_ASN1_STRING_TABLE_new sk_ASN1_STRTAB_new
106#define sk_ASN1_STRING_TABLE_new_null sk_ASN1_STRTAB_new_null
107#define sk_ASN1_STRING_TABLE_free sk_ASN1_STRTAB_free
108#define sk_ASN1_STRING_TABLE_num sk_ASN1_STRTAB_num
109#define sk_ASN1_STRING_TABLE_value sk_ASN1_STRTAB_value
110#define sk_ASN1_STRING_TABLE_set sk_ASN1_STRTAB_set
111#define sk_ASN1_STRING_TABLE_zero sk_ASN1_STRTAB_zero
112#define sk_ASN1_STRING_TABLE_push sk_ASN1_STRTAB_push
113#define sk_ASN1_STRING_TABLE_unshift sk_ASN1_STRTAB_unshift
114#define sk_ASN1_STRING_TABLE_find sk_ASN1_STRTAB_find
115#define sk_ASN1_STRING_TABLE_delete sk_ASN1_STRTAB_delete
116#define sk_ASN1_STRING_TABLE_delete_ptr sk_ASN1_STRTAB_delete_ptr
117#define sk_ASN1_STRING_TABLE_insert sk_ASN1_STRTAB_insert
118#define sk_ASN1_STRING_TABLE_set_cmp_func sk_ASN1_STRTAB_set_cmp_func
119#define sk_ASN1_STRING_TABLE_dup sk_ASN1_STRTAB_dup
120#define sk_ASN1_STRING_TABLE_pop_free sk_ASN1_STRTAB_pop_free
121#define sk_ASN1_STRING_TABLE_shift sk_ASN1_STRTAB_shift
122#define sk_ASN1_STRING_TABLE_pop sk_ASN1_STRTAB_pop
123#define sk_ASN1_STRING_TABLE_sort sk_ASN1_STRTAB_sort
124
125/* Hack the names created with DECLARE_STACK_OF(ACCESS_DESCRIPTION) */
126#define sk_ACCESS_DESCRIPTION_new sk_ACC_DESC_new
127#define sk_ACCESS_DESCRIPTION_new_null sk_ACC_DESC_new_null
128#define sk_ACCESS_DESCRIPTION_free sk_ACC_DESC_free
129#define sk_ACCESS_DESCRIPTION_num sk_ACC_DESC_num
130#define sk_ACCESS_DESCRIPTION_value sk_ACC_DESC_value
131#define sk_ACCESS_DESCRIPTION_set sk_ACC_DESC_set
132#define sk_ACCESS_DESCRIPTION_zero sk_ACC_DESC_zero
133#define sk_ACCESS_DESCRIPTION_push sk_ACC_DESC_push
134#define sk_ACCESS_DESCRIPTION_unshift sk_ACC_DESC_unshift
135#define sk_ACCESS_DESCRIPTION_find sk_ACC_DESC_find
136#define sk_ACCESS_DESCRIPTION_delete sk_ACC_DESC_delete
137#define sk_ACCESS_DESCRIPTION_delete_ptr sk_ACC_DESC_delete_ptr
138#define sk_ACCESS_DESCRIPTION_insert sk_ACC_DESC_insert
139#define sk_ACCESS_DESCRIPTION_set_cmp_func sk_ACC_DESC_set_cmp_func
140#define sk_ACCESS_DESCRIPTION_dup sk_ACC_DESC_dup
141#define sk_ACCESS_DESCRIPTION_pop_free sk_ACC_DESC_pop_free
142#define sk_ACCESS_DESCRIPTION_shift sk_ACC_DESC_shift
143#define sk_ACCESS_DESCRIPTION_pop sk_ACC_DESC_pop
144#define sk_ACCESS_DESCRIPTION_sort sk_ACC_DESC_sort
145
146/* Hack the names created with DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) */
147#define sk_CRYPTO_EX_DATA_FUNCS_new sk_CRYPT_EX_DATFNS_new
148#define sk_CRYPTO_EX_DATA_FUNCS_new_null sk_CRYPT_EX_DATFNS_new_null
149#define sk_CRYPTO_EX_DATA_FUNCS_free sk_CRYPT_EX_DATFNS_free
150#define sk_CRYPTO_EX_DATA_FUNCS_num sk_CRYPT_EX_DATFNS_num
151#define sk_CRYPTO_EX_DATA_FUNCS_value sk_CRYPT_EX_DATFNS_value
152#define sk_CRYPTO_EX_DATA_FUNCS_set sk_CRYPT_EX_DATFNS_set
153#define sk_CRYPTO_EX_DATA_FUNCS_zero sk_CRYPT_EX_DATFNS_zero
154#define sk_CRYPTO_EX_DATA_FUNCS_push sk_CRYPT_EX_DATFNS_push
155#define sk_CRYPTO_EX_DATA_FUNCS_unshift sk_CRYPT_EX_DATFNS_unshift
156#define sk_CRYPTO_EX_DATA_FUNCS_find sk_CRYPT_EX_DATFNS_find
157#define sk_CRYPTO_EX_DATA_FUNCS_delete sk_CRYPT_EX_DATFNS_delete
158#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr sk_CRYPT_EX_DATFNS_delete_ptr
159#define sk_CRYPTO_EX_DATA_FUNCS_insert sk_CRYPT_EX_DATFNS_insert
160#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func sk_CRYPT_EX_DATFNS_set_cmp_func
161#define sk_CRYPTO_EX_DATA_FUNCS_dup sk_CRYPT_EX_DATFNS_dup
162#define sk_CRYPTO_EX_DATA_FUNCS_pop_free sk_CRYPT_EX_DATFNS_pop_free
163#define sk_CRYPTO_EX_DATA_FUNCS_shift sk_CRYPT_EX_DATFNS_shift
164#define sk_CRYPTO_EX_DATA_FUNCS_pop sk_CRYPT_EX_DATFNS_pop
165#define sk_CRYPTO_EX_DATA_FUNCS_sort sk_CRYPT_EX_DATFNS_sort
101 166
102/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ 167/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */
103#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF 168#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF
104#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF 169#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF
105 170
106/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ 171/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */
107#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECGINF 172#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECGINF
108#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECGINF 173#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECGINF
174
175/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */
176#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC
177#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC
109 178
110/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ 179/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */
111#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQUENCE 180#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQUENCE
@@ -119,7 +188,10 @@
119#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO 188#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO
120#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO 189#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO
121#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO 190#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO
122#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_write_cb_bio_P8_PRIV_KEY_INFO 191#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO
192
193/* Hack other PEM names */
194#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid
123 195
124#endif /* defined VMS */ 196#endif /* defined VMS */
125 197
diff --git a/src/lib/libssl/src/apps/CA.com b/src/lib/libssl/src/apps/CA.com
index f324788eca..02682e424a 100644
--- a/src/lib/libssl/src/apps/CA.com
+++ b/src/lib/libssl/src/apps/CA.com
@@ -35,6 +35,7 @@ $ REQ = openssl + " req " + SSLEAY_CONFIG
35$ CA = openssl + " ca " + SSLEAY_CONFIG 35$ CA = openssl + " ca " + SSLEAY_CONFIG
36$ VERIFY = openssl + " verify" 36$ VERIFY = openssl + " verify"
37$ X509 = openssl + " x509" 37$ X509 = openssl + " x509"
38$ PKCS12 = openssl + " pkcs12"
38$ echo = "write sys$Output" 39$ echo = "write sys$Output"
39$! 40$!
40$ s = F$PARSE(F$ENVIRONMENT("DEFAULT"),"[]") - "].;" 41$ s = F$PARSE(F$ENVIRONMENT("DEFAULT"),"[]") - "].;"
@@ -96,10 +97,18 @@ $ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.certs]
96$ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.crl] 97$ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.crl]
97$ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.newcerts] 98$ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.newcerts]
98$ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.private] 99$ CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.private]
100$
99$ OPEN /WRITE ser_file 'CATOP']serial. 101$ OPEN /WRITE ser_file 'CATOP']serial.
100$ WRITE ser_file "01" 102$ WRITE ser_file "01"
101$ CLOSE ser_file 103$ CLOSE ser_file
102$ APPEND/NEW NL: 'CATOP']index.txt 104$ APPEND/NEW NL: 'CATOP']index.txt
105$
106$ ! The following is to make sure access() doesn't get confused. It
107$ ! really needs one file in the directory to give correct answers...
108$ COPY NLA0: 'CATOP'.certs].;
109$ COPY NLA0: 'CATOP'.crl].;
110$ COPY NLA0: 'CATOP'.newcerts].;
111$ COPY NLA0: 'CATOP'.private].;
103$ ENDIF 112$ ENDIF
104$! 113$!
105$ IF F$SEARCH(CATOP+".private"+CAKEY) .EQS. "" 114$ IF F$SEARCH(CATOP+".private"+CAKEY) .EQS. ""
@@ -121,6 +130,17 @@ $ ENDIF
121$ GOTO opt_loop_continue 130$ GOTO opt_loop_continue
122$ ENDIF 131$ ENDIF
123$! 132$!
133$ IF (prog_opt .EQS. "-pkcs12")
134$ THEN
135$ i = i + 1
136$ cname = P'i'
137$ IF cname .EQS. "" THEN cname = "My certificate"
138$ PKCS12 -in newcert.pem -inkey newreq.pem -certfile 'CATOP''CACERT -
139 -out newcert.p12 -export -name "''cname'"
140$ RET=$STATUS
141$ exit RET
142$ ENDIF
143$!
124$ IF (prog_opt .EQS. "-xsign") 144$ IF (prog_opt .EQS. "-xsign")
125$ THEN 145$ THEN
126$! 146$!
diff --git a/src/lib/libssl/src/apps/CA.pl b/src/lib/libssl/src/apps/CA.pl
index 7c023ae71f..beebee7ffe 100644
--- a/src/lib/libssl/src/apps/CA.pl
+++ b/src/lib/libssl/src/apps/CA.pl
@@ -1,4 +1,4 @@
1#!/usr/local/bin/perl 1#!/sw/bin/perl
2# 2#
3# CA - wrapper around ca to make it easier to use ... basically ca requires 3# CA - wrapper around ca to make it easier to use ... basically ca requires
4# some setup stuff to be done before you can use it and this makes 4# some setup stuff to be done before you can use it and this makes
@@ -41,6 +41,7 @@ $REQ="openssl req $SSLEAY_CONFIG";
41$CA="openssl ca $SSLEAY_CONFIG"; 41$CA="openssl ca $SSLEAY_CONFIG";
42$VERIFY="openssl verify"; 42$VERIFY="openssl verify";
43$X509="openssl x509"; 43$X509="openssl x509";
44$PKCS12="openssl pkcs12";
44 45
45$CATOP="./demoCA"; 46$CATOP="./demoCA";
46$CAKEY="cakey.pem"; 47$CAKEY="cakey.pem";
@@ -65,7 +66,7 @@ foreach (@ARGV) {
65 $RET=$?; 66 $RET=$?;
66 print "Request (and private key) is in newreq.pem\n"; 67 print "Request (and private key) is in newreq.pem\n";
67 } elsif (/^-newca$/) { 68 } elsif (/^-newca$/) {
68 # if explictly asked for or it doesn't exist then setup the 69 # if explicitly asked for or it doesn't exist then setup the
69 # directory structure that Eric likes to manage things 70 # directory structure that Eric likes to manage things
70 $NEW="1"; 71 $NEW="1";
71 if ( "$NEW" || ! -f "${CATOP}/serial" ) { 72 if ( "$NEW" || ! -f "${CATOP}/serial" ) {
@@ -99,6 +100,14 @@ foreach (@ARGV) {
99 $RET=$?; 100 $RET=$?;
100 } 101 }
101 } 102 }
103 } elsif (/^-pkcs12$/) {
104 my $cname = $ARGV[1];
105 $cname = "My Certificate" unless defined $cname;
106 system ("$PKCS12 -in newcert.pem -inkey newreq.pem " .
107 "-certfile ${CATOP}/$CACERT -out newcert.p12 " .
108 "-export -name \"$cname\"");
109 $RET=$?;
110 exit $RET;
102 } elsif (/^-xsign$/) { 111 } elsif (/^-xsign$/) {
103 system ("$CA -policy policy_anything -infiles newreq.pem"); 112 system ("$CA -policy policy_anything -infiles newreq.pem");
104 $RET=$?; 113 $RET=$?;
diff --git a/src/lib/libssl/src/apps/CA.pl.in b/src/lib/libssl/src/apps/CA.pl.in
new file mode 100644
index 0000000000..4eef57e6e3
--- /dev/null
+++ b/src/lib/libssl/src/apps/CA.pl.in
@@ -0,0 +1,162 @@
1#!/usr/local/bin/perl
2#
3# CA - wrapper around ca to make it easier to use ... basically ca requires
4# some setup stuff to be done before you can use it and this makes
5# things easier between now and when Eric is convinced to fix it :-)
6#
7# CA -newca ... will setup the right stuff
8# CA -newreq ... will generate a certificate request
9# CA -sign ... will sign the generated request and output
10#
11# At the end of that grab newreq.pem and newcert.pem (one has the key
12# and the other the certificate) and cat them together and that is what
13# you want/need ... I'll make even this a little cleaner later.
14#
15#
16# 12-Jan-96 tjh Added more things ... including CA -signcert which
17# converts a certificate to a request and then signs it.
18# 10-Jan-96 eay Fixed a few more bugs and added the SSLEAY_CONFIG
19# environment variable so this can be driven from
20# a script.
21# 25-Jul-96 eay Cleaned up filenames some more.
22# 11-Jun-96 eay Fixed a few filename missmatches.
23# 03-May-96 eay Modified to use 'ssleay cmd' instead of 'cmd'.
24# 18-Apr-96 tjh Original hacking
25#
26# Tim Hudson
27# tjh@cryptsoft.com
28#
29
30# 27-Apr-98 snh Translation into perl, fix existing CA bug.
31#
32#
33# Steve Henson
34# shenson@bigfoot.com
35
36# default openssl.cnf file has setup as per the following
37# demoCA ... where everything is stored
38
39$DAYS="-days 365";
40$REQ="openssl req $SSLEAY_CONFIG";
41$CA="openssl ca $SSLEAY_CONFIG";
42$VERIFY="openssl verify";
43$X509="openssl x509";
44$PKCS12="openssl pkcs12";
45
46$CATOP="./demoCA";
47$CAKEY="cakey.pem";
48$CACERT="cacert.pem";
49
50$DIRMODE = 0777;
51
52$RET = 0;
53
54foreach (@ARGV) {
55 if ( /^(-\?|-h|-help)$/ ) {
56 print STDERR "usage: CA -newcert|-newreq|-newca|-sign|-verify\n";
57 exit 0;
58 } elsif (/^-newcert$/) {
59 # create a certificate
60 system ("$REQ -new -x509 -keyout newreq.pem -out newreq.pem $DAYS");
61 $RET=$?;
62 print "Certificate (and private key) is in newreq.pem\n"
63 } elsif (/^-newreq$/) {
64 # create a certificate request
65 system ("$REQ -new -keyout newreq.pem -out newreq.pem $DAYS");
66 $RET=$?;
67 print "Request (and private key) is in newreq.pem\n";
68 } elsif (/^-newca$/) {
69 # if explicitly asked for or it doesn't exist then setup the
70 # directory structure that Eric likes to manage things
71 $NEW="1";
72 if ( "$NEW" || ! -f "${CATOP}/serial" ) {
73 # create the directory hierarchy
74 mkdir $CATOP, $DIRMODE;
75 mkdir "${CATOP}/certs", $DIRMODE;
76 mkdir "${CATOP}/crl", $DIRMODE ;
77 mkdir "${CATOP}/newcerts", $DIRMODE;
78 mkdir "${CATOP}/private", $DIRMODE;
79 open OUT, ">${CATOP}/serial";
80 print OUT "01\n";
81 close OUT;
82 open OUT, ">${CATOP}/index.txt";
83 close OUT;
84 }
85 if ( ! -f "${CATOP}/private/$CAKEY" ) {
86 print "CA certificate filename (or enter to create)\n";
87 $FILE = <STDIN>;
88
89 chop $FILE;
90
91 # ask user for existing CA certificate
92 if ($FILE) {
93 cp_pem($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
94 cp_pem($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
95 $RET=$?;
96 } else {
97 print "Making CA certificate ...\n";
98 system ("$REQ -new -x509 -keyout " .
99 "${CATOP}/private/$CAKEY -out ${CATOP}/$CACERT $DAYS");
100 $RET=$?;
101 }
102 }
103 } elsif (/^-pkcs12$/) {
104 my $cname = $ARGV[1];
105 $cname = "My Certificate" unless defined $cname;
106 system ("$PKCS12 -in newcert.pem -inkey newreq.pem " .
107 "-certfile ${CATOP}/$CACERT -out newcert.p12 " .
108 "-export -name \"$cname\"");
109 $RET=$?;
110 exit $RET;
111 } elsif (/^-xsign$/) {
112 system ("$CA -policy policy_anything -infiles newreq.pem");
113 $RET=$?;
114 } elsif (/^(-sign|-signreq)$/) {
115 system ("$CA -policy policy_anything -out newcert.pem " .
116 "-infiles newreq.pem");
117 $RET=$?;
118 print "Signed certificate is in newcert.pem\n";
119 } elsif (/^-signcert$/) {
120 system ("$X509 -x509toreq -in newreq.pem -signkey newreq.pem " .
121 "-out tmp.pem");
122 system ("$CA -policy policy_anything -out newcert.pem " .
123 "-infiles tmp.pem");
124 $RET = $?;
125 print "Signed certificate is in newcert.pem\n";
126 } elsif (/^-verify$/) {
127 if (shift) {
128 foreach $j (@ARGV) {
129 system ("$VERIFY -CAfile $CATOP/$CACERT $j");
130 $RET=$? if ($? != 0);
131 }
132 exit $RET;
133 } else {
134 system ("$VERIFY -CAfile $CATOP/$CACERT newcert.pem");
135 $RET=$?;
136 exit 0;
137 }
138 } else {
139 print STDERR "Unknown arg $_\n";
140 print STDERR "usage: CA -newcert|-newreq|-newca|-sign|-verify\n";
141 exit 1;
142 }
143}
144
145exit $RET;
146
147sub cp_pem {
148my ($infile, $outfile, $bound) = @_;
149open IN, $infile;
150open OUT, ">$outfile";
151my $flag = 0;
152while (<IN>) {
153 $flag = 1 if (/^-----BEGIN.*$bound/) ;
154 print OUT $_ if ($flag);
155 if (/^-----END.*$bound/) {
156 close IN;
157 close OUT;
158 return;
159 }
160}
161}
162
diff --git a/src/lib/libssl/src/apps/CA.sh b/src/lib/libssl/src/apps/CA.sh
index 728f5bf4d8..d9f3069fb2 100644
--- a/src/lib/libssl/src/apps/CA.sh
+++ b/src/lib/libssl/src/apps/CA.sh
@@ -60,7 +60,7 @@ case $i in
60 echo "Request (and private key) is in newreq.pem" 60 echo "Request (and private key) is in newreq.pem"
61 ;; 61 ;;
62-newca) 62-newca)
63 # if explictly asked for or it doesn't exist then setup the directory 63 # if explicitly asked for or it doesn't exist then setup the directory
64 # structure that Eric likes to manage things 64 # structure that Eric likes to manage things
65 NEW="1" 65 NEW="1"
66 if [ "$NEW" -o ! -f ${CATOP}/serial ]; then 66 if [ "$NEW" -o ! -f ${CATOP}/serial ]; then
diff --git a/src/lib/libssl/src/apps/Makefile.ssl b/src/lib/libssl/src/apps/Makefile.ssl
index 8e382701b1..f97154ba03 100644
--- a/src/lib/libssl/src/apps/Makefile.ssl
+++ b/src/lib/libssl/src/apps/Makefile.ssl
@@ -13,6 +13,7 @@ OPENSSLDIR= /usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPEND= $(TOP)/util/domd $(TOP)
15MAKEFILE= Makefile.ssl 15MAKEFILE= Makefile.ssl
16PERL=/usr/local/bin/perl
16RM= rm -f 17RM= rm -f
17 18
18PEX_LIBS= 19PEX_LIBS=
@@ -33,11 +34,11 @@ SCRIPTS=CA.sh CA.pl der_chop
33 34
34EXE= $(PROGRAM) 35EXE= $(PROGRAM)
35 36
36E_EXE= verify asn1pars req dgst dh enc gendh errstr ca crl \ 37E_EXE= verify asn1pars req dgst dh dhparam enc passwd gendh errstr \
37 rsa dsa dsaparam \ 38 ca crl rsa dsa dsaparam \
38 x509 genrsa gendsa s_server s_client speed \ 39 x509 genrsa gendsa s_server s_client speed \
39 s_time version pkcs7 crl2pkcs7 sess_id ciphers nseq pkcs12 \ 40 s_time version pkcs7 crl2pkcs7 sess_id ciphers nseq pkcs12 \
40 pkcs8 41 pkcs8 spkac smime
41 42
42PROGS= $(PROGRAM).c 43PROGS= $(PROGRAM).c
43 44
@@ -45,22 +46,24 @@ A_OBJ=apps.o
45A_SRC=apps.c 46A_SRC=apps.c
46S_OBJ= s_cb.o s_socket.o 47S_OBJ= s_cb.o s_socket.o
47S_SRC= s_cb.c s_socket.c 48S_SRC= s_cb.c s_socket.c
49RAND_OBJ=app_rand.o
50RAND_SRC=app_rand.c
48 51
49E_OBJ= verify.o asn1pars.o req.o dgst.o dh.o enc.o gendh.o errstr.o ca.o \ 52E_OBJ= verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o \
50 pkcs7.o crl2p7.o crl.o \ 53 ca.o pkcs7.o crl2p7.o crl.o \
51 rsa.o dsa.o dsaparam.o \ 54 rsa.o dsa.o dsaparam.o \
52 x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o \ 55 x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o \
53 s_time.o $(A_OBJ) $(S_OBJ) version.o sess_id.o \ 56 s_time.o $(A_OBJ) $(S_OBJ) $(RAND_OBJ) version.o sess_id.o \
54 ciphers.o nseq.o pkcs12.o pkcs8.o 57 ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o
55 58
56# pem_mail.o 59# pem_mail.o
57 60
58E_SRC= verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c \ 61E_SRC= verify.c asn1pars.c req.c dgst.c dh.c enc.c passwd.c gendh.c errstr.c ca.c \
59 pkcs7.c crl2p7.c crl.c \ 62 pkcs7.c crl2p7.c crl.c \
60 rsa.c dsa.c dsaparam.c \ 63 rsa.c dsa.c dsaparam.c \
61 x509.c genrsa.c gendsa.c s_server.c s_client.c speed.c \ 64 x509.c genrsa.c gendsa.c s_server.c s_client.c speed.c \
62 s_time.c $(A_SRC) $(S_SRC) version.c sess_id.c \ 65 s_time.c $(A_SRC) $(S_SRC) $(RAND_SRC) version.c sess_id.c \
63 ciphers.c nseq.c pkcs12.c pkcs8.c 66 ciphers.c nseq.c pkcs12.c pkcs8.c spkac.c smime.c
64 67
65# pem_mail.c 68# pem_mail.c
66 69
@@ -81,7 +84,7 @@ all: exe
81exe: $(EXE) 84exe: $(EXE)
82 85
83req: sreq.o $(A_OBJ) $(DLIBCRYPTO) 86req: sreq.o $(A_OBJ) $(DLIBCRYPTO)
84 $(CC) -o req $(CFLAG) sreq.o $(A_OBJ) $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 87 $(CC) -o req $(CFLAG) sreq.o $(A_OBJ) $(RAND_OBJ) $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
85 88
86sreq.o: req.c 89sreq.o: req.c
87 $(CC) -c $(INCLUDES) $(CFLAG) -o sreq.o req.c 90 $(CC) -c $(INCLUDES) $(CFLAG) -o sreq.o req.c
@@ -138,16 +141,44 @@ $(PROGRAM): progs.h $(E_OBJ) $(PROGRAM).o $(DLIBCRYPTO) $(DLIBSSL)
138 $(CC) -o $(PROGRAM) $(CFLAGS) $(PROGRAM).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) 141 $(CC) -o $(PROGRAM) $(CFLAGS) $(PROGRAM).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS)
139 @(cd ..; OPENSSL="`pwd`/apps/openssl"; export OPENSSL; sh tools/c_rehash certs) 142 @(cd ..; OPENSSL="`pwd`/apps/openssl"; export OPENSSL; sh tools/c_rehash certs)
140 143
141progs.h: 144progs.h: progs.pl
142 $(PERL) ./progs.pl $(E_EXE) >progs.h 145 $(PERL) progs.pl $(E_EXE) >progs.h
143 $(RM) $(PROGRAM).o 146 $(RM) $(PROGRAM).o
144 147
145# DO NOT DELETE THIS LINE -- make depend depends on it. 148# DO NOT DELETE THIS LINE -- make depend depends on it.
146 149
147apps.o: ../include/openssl/bio.h ../include/openssl/buffer.h 150app_rand.o: ../include/openssl/asn1.h ../include/openssl/bio.h
148apps.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 151app_rand.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
149apps.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h 152app_rand.o: ../include/openssl/buffer.h ../include/openssl/cast.h
150apps.o: ../include/openssl/opensslv.h ../include/openssl/stack.h apps.h progs.h 153app_rand.o: ../include/openssl/crypto.h ../include/openssl/des.h
154app_rand.o: ../include/openssl/dh.h ../include/openssl/dsa.h
155app_rand.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
156app_rand.o: ../include/openssl/evp.h ../include/openssl/idea.h
157app_rand.o: ../include/openssl/md2.h ../include/openssl/md5.h
158app_rand.o: ../include/openssl/mdc2.h ../include/openssl/objects.h
159app_rand.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
160app_rand.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
161app_rand.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
162app_rand.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
163app_rand.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
164app_rand.o: ../include/openssl/sha.h ../include/openssl/stack.h
165app_rand.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
166apps.o: ../include/openssl/asn1.h ../include/openssl/bio.h
167apps.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
168apps.o: ../include/openssl/buffer.h ../include/openssl/cast.h
169apps.o: ../include/openssl/crypto.h ../include/openssl/des.h
170apps.o: ../include/openssl/dh.h ../include/openssl/dsa.h
171apps.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
172apps.o: ../include/openssl/evp.h ../include/openssl/idea.h
173apps.o: ../include/openssl/md2.h ../include/openssl/md5.h
174apps.o: ../include/openssl/mdc2.h ../include/openssl/objects.h
175apps.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
176apps.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h
177apps.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
178apps.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
179apps.o: ../include/openssl/safestack.h ../include/openssl/sha.h
180apps.o: ../include/openssl/stack.h ../include/openssl/x509.h
181apps.o: ../include/openssl/x509_vfy.h apps.h
151asn1pars.o: ../include/openssl/asn1.h ../include/openssl/bio.h 182asn1pars.o: ../include/openssl/asn1.h ../include/openssl/bio.h
152asn1pars.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 183asn1pars.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
153asn1pars.o: ../include/openssl/buffer.h ../include/openssl/cast.h 184asn1pars.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -165,7 +196,6 @@ asn1pars.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
165asn1pars.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 196asn1pars.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
166asn1pars.o: ../include/openssl/sha.h ../include/openssl/stack.h 197asn1pars.o: ../include/openssl/sha.h ../include/openssl/stack.h
167asn1pars.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 198asn1pars.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
168asn1pars.o: progs.h
169ca.o: ../include/openssl/asn1.h ../include/openssl/bio.h 199ca.o: ../include/openssl/asn1.h ../include/openssl/bio.h
170ca.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 200ca.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
171ca.o: ../include/openssl/buffer.h ../include/openssl/cast.h 201ca.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -184,7 +214,7 @@ ca.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
184ca.o: ../include/openssl/safestack.h ../include/openssl/sha.h 214ca.o: ../include/openssl/safestack.h ../include/openssl/sha.h
185ca.o: ../include/openssl/stack.h ../include/openssl/txt_db.h 215ca.o: ../include/openssl/stack.h ../include/openssl/txt_db.h
186ca.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 216ca.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
187ca.o: ../include/openssl/x509v3.h apps.h progs.h 217ca.o: ../include/openssl/x509v3.h apps.h
188ciphers.o: ../include/openssl/asn1.h ../include/openssl/bio.h 218ciphers.o: ../include/openssl/asn1.h ../include/openssl/bio.h
189ciphers.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 219ciphers.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
190ciphers.o: ../include/openssl/buffer.h ../include/openssl/cast.h 220ciphers.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -205,7 +235,6 @@ ciphers.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
205ciphers.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 235ciphers.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
206ciphers.o: ../include/openssl/stack.h ../include/openssl/tls1.h 236ciphers.o: ../include/openssl/stack.h ../include/openssl/tls1.h
207ciphers.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 237ciphers.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
208ciphers.o: progs.h
209crl.o: ../include/openssl/asn1.h ../include/openssl/bio.h 238crl.o: ../include/openssl/asn1.h ../include/openssl/bio.h
210crl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 239crl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
211crl.o: ../include/openssl/buffer.h ../include/openssl/cast.h 240crl.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -224,7 +253,7 @@ crl.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
224crl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 253crl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
225crl.o: ../include/openssl/sha.h ../include/openssl/stack.h 254crl.o: ../include/openssl/sha.h ../include/openssl/stack.h
226crl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 255crl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
227crl.o: ../include/openssl/x509v3.h apps.h progs.h 256crl.o: ../include/openssl/x509v3.h apps.h
228crl2p7.o: ../include/openssl/asn1.h ../include/openssl/bio.h 257crl2p7.o: ../include/openssl/asn1.h ../include/openssl/bio.h
229crl2p7.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 258crl2p7.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
230crl2p7.o: ../include/openssl/buffer.h ../include/openssl/cast.h 259crl2p7.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -242,7 +271,6 @@ crl2p7.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
242crl2p7.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 271crl2p7.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
243crl2p7.o: ../include/openssl/sha.h ../include/openssl/stack.h 272crl2p7.o: ../include/openssl/sha.h ../include/openssl/stack.h
244crl2p7.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 273crl2p7.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
245crl2p7.o: progs.h
246dgst.o: ../include/openssl/asn1.h ../include/openssl/bio.h 274dgst.o: ../include/openssl/asn1.h ../include/openssl/bio.h
247dgst.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 275dgst.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
248dgst.o: ../include/openssl/buffer.h ../include/openssl/cast.h 276dgst.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -259,7 +287,7 @@ dgst.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
259dgst.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 287dgst.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
260dgst.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 288dgst.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
261dgst.o: ../include/openssl/sha.h ../include/openssl/stack.h 289dgst.o: ../include/openssl/sha.h ../include/openssl/stack.h
262dgst.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 290dgst.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
263dh.o: ../include/openssl/asn1.h ../include/openssl/bio.h 291dh.o: ../include/openssl/asn1.h ../include/openssl/bio.h
264dh.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 292dh.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
265dh.o: ../include/openssl/buffer.h ../include/openssl/cast.h 293dh.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -276,7 +304,7 @@ dh.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
276dh.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 304dh.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
277dh.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 305dh.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
278dh.o: ../include/openssl/sha.h ../include/openssl/stack.h 306dh.o: ../include/openssl/sha.h ../include/openssl/stack.h
279dh.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 307dh.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
280dsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 308dsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h
281dsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 309dsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
282dsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h 310dsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -293,7 +321,7 @@ dsa.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
293dsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 321dsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
294dsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 322dsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
295dsa.o: ../include/openssl/sha.h ../include/openssl/stack.h 323dsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
296dsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 324dsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
297dsaparam.o: ../include/openssl/asn1.h ../include/openssl/bio.h 325dsaparam.o: ../include/openssl/asn1.h ../include/openssl/bio.h
298dsaparam.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 326dsaparam.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
299dsaparam.o: ../include/openssl/buffer.h ../include/openssl/cast.h 327dsaparam.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -306,12 +334,11 @@ dsaparam.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
306dsaparam.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 334dsaparam.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
307dsaparam.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 335dsaparam.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
308dsaparam.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 336dsaparam.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
309dsaparam.o: ../include/openssl/rand.h ../include/openssl/rc2.h 337dsaparam.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
310dsaparam.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 338dsaparam.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
311dsaparam.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 339dsaparam.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
312dsaparam.o: ../include/openssl/safestack.h ../include/openssl/sha.h 340dsaparam.o: ../include/openssl/sha.h ../include/openssl/stack.h
313dsaparam.o: ../include/openssl/stack.h ../include/openssl/x509.h 341dsaparam.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
314dsaparam.o: ../include/openssl/x509_vfy.h apps.h progs.h
315enc.o: ../include/openssl/asn1.h ../include/openssl/bio.h 342enc.o: ../include/openssl/asn1.h ../include/openssl/bio.h
316enc.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 343enc.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
317enc.o: ../include/openssl/buffer.h ../include/openssl/cast.h 344enc.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -324,11 +351,12 @@ enc.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
324enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 351enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
325enc.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 352enc.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
326enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 353enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
327enc.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 354enc.o: ../include/openssl/rand.h ../include/openssl/rc2.h
328enc.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 355enc.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
329enc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 356enc.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
330enc.o: ../include/openssl/sha.h ../include/openssl/stack.h 357enc.o: ../include/openssl/safestack.h ../include/openssl/sha.h
331enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 358enc.o: ../include/openssl/stack.h ../include/openssl/x509.h
359enc.o: ../include/openssl/x509_vfy.h apps.h
332errstr.o: ../include/openssl/asn1.h ../include/openssl/bio.h 360errstr.o: ../include/openssl/asn1.h ../include/openssl/bio.h
333errstr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 361errstr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
334errstr.o: ../include/openssl/buffer.h ../include/openssl/cast.h 362errstr.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -349,7 +377,6 @@ errstr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
349errstr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 377errstr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
350errstr.o: ../include/openssl/stack.h ../include/openssl/tls1.h 378errstr.o: ../include/openssl/stack.h ../include/openssl/tls1.h
351errstr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 379errstr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
352errstr.o: progs.h
353gendh.o: ../include/openssl/asn1.h ../include/openssl/bio.h 380gendh.o: ../include/openssl/asn1.h ../include/openssl/bio.h
354gendh.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 381gendh.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
355gendh.o: ../include/openssl/buffer.h ../include/openssl/cast.h 382gendh.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -367,7 +394,7 @@ gendh.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
367gendh.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 394gendh.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
368gendh.o: ../include/openssl/safestack.h ../include/openssl/sha.h 395gendh.o: ../include/openssl/safestack.h ../include/openssl/sha.h
369gendh.o: ../include/openssl/stack.h ../include/openssl/x509.h 396gendh.o: ../include/openssl/stack.h ../include/openssl/x509.h
370gendh.o: ../include/openssl/x509_vfy.h apps.h progs.h 397gendh.o: ../include/openssl/x509_vfy.h apps.h
371gendsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 398gendsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h
372gendsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 399gendsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
373gendsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h 400gendsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -380,12 +407,11 @@ gendsa.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
380gendsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 407gendsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
381gendsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 408gendsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
382gendsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 409gendsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
383gendsa.o: ../include/openssl/rand.h ../include/openssl/rc2.h 410gendsa.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
384gendsa.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 411gendsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
385gendsa.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 412gendsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
386gendsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h 413gendsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
387gendsa.o: ../include/openssl/stack.h ../include/openssl/x509.h 414gendsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
388gendsa.o: ../include/openssl/x509_vfy.h apps.h progs.h
389genrsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 415genrsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h
390genrsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 416genrsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
391genrsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h 417genrsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -398,12 +424,11 @@ genrsa.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
398genrsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 424genrsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
399genrsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 425genrsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
400genrsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 426genrsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
401genrsa.o: ../include/openssl/rand.h ../include/openssl/rc2.h 427genrsa.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
402genrsa.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 428genrsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
403genrsa.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 429genrsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
404genrsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h 430genrsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
405genrsa.o: ../include/openssl/stack.h ../include/openssl/x509.h 431genrsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
406genrsa.o: ../include/openssl/x509_vfy.h apps.h progs.h
407nseq.o: ../include/openssl/asn1.h ../include/openssl/bio.h 432nseq.o: ../include/openssl/asn1.h ../include/openssl/bio.h
408nseq.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 433nseq.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
409nseq.o: ../include/openssl/buffer.h ../include/openssl/cast.h 434nseq.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -420,7 +445,7 @@ nseq.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
420nseq.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 445nseq.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
421nseq.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 446nseq.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
422nseq.o: ../include/openssl/sha.h ../include/openssl/stack.h 447nseq.o: ../include/openssl/sha.h ../include/openssl/stack.h
423nseq.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 448nseq.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
424openssl.o: ../include/openssl/asn1.h ../include/openssl/bio.h 449openssl.o: ../include/openssl/asn1.h ../include/openssl/bio.h
425openssl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 450openssl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
426openssl.o: ../include/openssl/buffer.h ../include/openssl/cast.h 451openssl.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -442,6 +467,23 @@ openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
442openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 467openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
443openssl.o: ../include/openssl/tls1.h ../include/openssl/x509.h 468openssl.o: ../include/openssl/tls1.h ../include/openssl/x509.h
444openssl.o: ../include/openssl/x509_vfy.h apps.h progs.h s_apps.h 469openssl.o: ../include/openssl/x509_vfy.h apps.h progs.h s_apps.h
470passwd.o: ../include/openssl/asn1.h ../include/openssl/bio.h
471passwd.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
472passwd.o: ../include/openssl/buffer.h ../include/openssl/cast.h
473passwd.o: ../include/openssl/crypto.h ../include/openssl/des.h
474passwd.o: ../include/openssl/dh.h ../include/openssl/dsa.h
475passwd.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
476passwd.o: ../include/openssl/err.h ../include/openssl/evp.h
477passwd.o: ../include/openssl/idea.h ../include/openssl/md2.h
478passwd.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
479passwd.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
480passwd.o: ../include/openssl/opensslv.h ../include/openssl/pkcs7.h
481passwd.o: ../include/openssl/rand.h ../include/openssl/rc2.h
482passwd.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
483passwd.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
484passwd.o: ../include/openssl/safestack.h ../include/openssl/sha.h
485passwd.o: ../include/openssl/stack.h ../include/openssl/x509.h
486passwd.o: ../include/openssl/x509_vfy.h apps.h
445pkcs12.o: ../include/openssl/asn1.h ../include/openssl/bio.h 487pkcs12.o: ../include/openssl/asn1.h ../include/openssl/bio.h
446pkcs12.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 488pkcs12.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
447pkcs12.o: ../include/openssl/buffer.h ../include/openssl/cast.h 489pkcs12.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -459,7 +501,7 @@ pkcs12.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
459pkcs12.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 501pkcs12.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
460pkcs12.o: ../include/openssl/safestack.h ../include/openssl/sha.h 502pkcs12.o: ../include/openssl/safestack.h ../include/openssl/sha.h
461pkcs12.o: ../include/openssl/stack.h ../include/openssl/x509.h 503pkcs12.o: ../include/openssl/stack.h ../include/openssl/x509.h
462pkcs12.o: ../include/openssl/x509_vfy.h apps.h progs.h 504pkcs12.o: ../include/openssl/x509_vfy.h apps.h
463pkcs7.o: ../include/openssl/asn1.h ../include/openssl/bio.h 505pkcs7.o: ../include/openssl/asn1.h ../include/openssl/bio.h
464pkcs7.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 506pkcs7.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
465pkcs7.o: ../include/openssl/buffer.h ../include/openssl/cast.h 507pkcs7.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -476,7 +518,7 @@ pkcs7.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
476pkcs7.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 518pkcs7.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
477pkcs7.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 519pkcs7.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
478pkcs7.o: ../include/openssl/sha.h ../include/openssl/stack.h 520pkcs7.o: ../include/openssl/sha.h ../include/openssl/stack.h
479pkcs7.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 521pkcs7.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
480pkcs8.o: ../include/openssl/asn1.h ../include/openssl/bio.h 522pkcs8.o: ../include/openssl/asn1.h ../include/openssl/bio.h
481pkcs8.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 523pkcs8.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
482pkcs8.o: ../include/openssl/buffer.h ../include/openssl/cast.h 524pkcs8.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -494,7 +536,7 @@ pkcs8.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
494pkcs8.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 536pkcs8.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
495pkcs8.o: ../include/openssl/safestack.h ../include/openssl/sha.h 537pkcs8.o: ../include/openssl/safestack.h ../include/openssl/sha.h
496pkcs8.o: ../include/openssl/stack.h ../include/openssl/x509.h 538pkcs8.o: ../include/openssl/stack.h ../include/openssl/x509.h
497pkcs8.o: ../include/openssl/x509_vfy.h apps.h progs.h 539pkcs8.o: ../include/openssl/x509_vfy.h apps.h
498req.o: ../include/openssl/asn1.h ../include/openssl/bio.h 540req.o: ../include/openssl/asn1.h ../include/openssl/bio.h
499req.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 541req.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
500req.o: ../include/openssl/buffer.h ../include/openssl/cast.h 542req.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -508,12 +550,12 @@ req.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
508req.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 550req.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
509req.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 551req.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
510req.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 552req.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
511req.o: ../include/openssl/rand.h ../include/openssl/rc2.h 553req.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
512req.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 554req.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
513req.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 555req.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
514req.o: ../include/openssl/safestack.h ../include/openssl/sha.h 556req.o: ../include/openssl/sha.h ../include/openssl/stack.h
515req.o: ../include/openssl/stack.h ../include/openssl/x509.h 557req.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
516req.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h progs.h 558req.o: ../include/openssl/x509v3.h apps.h
517rsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 559rsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h
518rsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 560rsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
519rsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h 561rsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -530,7 +572,7 @@ rsa.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
530rsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 572rsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
531rsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 573rsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
532rsa.o: ../include/openssl/sha.h ../include/openssl/stack.h 574rsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
533rsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 575rsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
534s_cb.o: ../include/openssl/asn1.h ../include/openssl/bio.h 576s_cb.o: ../include/openssl/asn1.h ../include/openssl/bio.h
535s_cb.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 577s_cb.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
536s_cb.o: ../include/openssl/buffer.h ../include/openssl/cast.h 578s_cb.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -550,8 +592,7 @@ s_cb.o: ../include/openssl/safestack.h ../include/openssl/sha.h
550s_cb.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 592s_cb.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
551s_cb.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 593s_cb.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
552s_cb.o: ../include/openssl/stack.h ../include/openssl/tls1.h 594s_cb.o: ../include/openssl/stack.h ../include/openssl/tls1.h
553s_cb.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h progs.h 595s_cb.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h s_apps.h
554s_cb.o: s_apps.h
555s_client.o: ../include/openssl/asn1.h ../include/openssl/bio.h 596s_client.o: ../include/openssl/asn1.h ../include/openssl/bio.h
556s_client.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 597s_client.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
557s_client.o: ../include/openssl/buffer.h ../include/openssl/cast.h 598s_client.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -572,7 +613,7 @@ s_client.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
572s_client.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 613s_client.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
573s_client.o: ../include/openssl/stack.h ../include/openssl/tls1.h 614s_client.o: ../include/openssl/stack.h ../include/openssl/tls1.h
574s_client.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 615s_client.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
575s_client.o: progs.h s_apps.h 616s_client.o: s_apps.h
576s_server.o: ../include/openssl/asn1.h ../include/openssl/bio.h 617s_server.o: ../include/openssl/asn1.h ../include/openssl/bio.h
577s_server.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 618s_server.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
578s_server.o: ../include/openssl/buffer.h ../include/openssl/cast.h 619s_server.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -593,7 +634,7 @@ s_server.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
593s_server.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 634s_server.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
594s_server.o: ../include/openssl/stack.h ../include/openssl/tls1.h 635s_server.o: ../include/openssl/stack.h ../include/openssl/tls1.h
595s_server.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 636s_server.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
596s_server.o: progs.h s_apps.h 637s_server.o: s_apps.h
597s_socket.o: ../include/openssl/asn1.h ../include/openssl/bio.h 638s_socket.o: ../include/openssl/asn1.h ../include/openssl/bio.h
598s_socket.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 639s_socket.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
599s_socket.o: ../include/openssl/buffer.h ../include/openssl/cast.h 640s_socket.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -613,7 +654,7 @@ s_socket.o: ../include/openssl/sha.h ../include/openssl/ssl.h
613s_socket.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 654s_socket.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
614s_socket.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 655s_socket.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
615s_socket.o: ../include/openssl/tls1.h ../include/openssl/x509.h 656s_socket.o: ../include/openssl/tls1.h ../include/openssl/x509.h
616s_socket.o: ../include/openssl/x509_vfy.h apps.h progs.h s_apps.h 657s_socket.o: ../include/openssl/x509_vfy.h apps.h s_apps.h
617s_time.o: ../include/openssl/asn1.h ../include/openssl/bio.h 658s_time.o: ../include/openssl/asn1.h ../include/openssl/bio.h
618s_time.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 659s_time.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
619s_time.o: ../include/openssl/buffer.h ../include/openssl/cast.h 660s_time.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -634,7 +675,7 @@ s_time.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
634s_time.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 675s_time.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
635s_time.o: ../include/openssl/stack.h ../include/openssl/tls1.h 676s_time.o: ../include/openssl/stack.h ../include/openssl/tls1.h
636s_time.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 677s_time.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
637s_time.o: progs.h s_apps.h 678s_time.o: s_apps.h
638sess_id.o: ../include/openssl/asn1.h ../include/openssl/bio.h 679sess_id.o: ../include/openssl/asn1.h ../include/openssl/bio.h
639sess_id.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 680sess_id.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
640sess_id.o: ../include/openssl/buffer.h ../include/openssl/cast.h 681sess_id.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -655,7 +696,23 @@ sess_id.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
655sess_id.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 696sess_id.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
656sess_id.o: ../include/openssl/stack.h ../include/openssl/tls1.h 697sess_id.o: ../include/openssl/stack.h ../include/openssl/tls1.h
657sess_id.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 698sess_id.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
658sess_id.o: progs.h 699smime.o: ../include/openssl/asn1.h ../include/openssl/bio.h
700smime.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
701smime.o: ../include/openssl/buffer.h ../include/openssl/cast.h
702smime.o: ../include/openssl/crypto.h ../include/openssl/des.h
703smime.o: ../include/openssl/dh.h ../include/openssl/dsa.h
704smime.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
705smime.o: ../include/openssl/err.h ../include/openssl/evp.h
706smime.o: ../include/openssl/idea.h ../include/openssl/md2.h
707smime.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
708smime.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
709smime.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
710smime.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
711smime.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
712smime.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
713smime.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
714smime.o: ../include/openssl/sha.h ../include/openssl/stack.h
715smime.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
659speed.o: ../include/openssl/asn1.h ../include/openssl/bio.h 716speed.o: ../include/openssl/asn1.h ../include/openssl/bio.h
660speed.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 717speed.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
661speed.o: ../include/openssl/buffer.h ../include/openssl/cast.h 718speed.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -673,15 +730,33 @@ speed.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
673speed.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 730speed.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
674speed.o: ../include/openssl/sha.h ../include/openssl/stack.h 731speed.o: ../include/openssl/sha.h ../include/openssl/stack.h
675speed.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ./testdsa.h 732speed.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ./testdsa.h
676speed.o: ./testrsa.h apps.h progs.h 733speed.o: ./testrsa.h apps.h
734spkac.o: ../include/openssl/asn1.h ../include/openssl/bio.h
735spkac.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
736spkac.o: ../include/openssl/buffer.h ../include/openssl/cast.h
737spkac.o: ../include/openssl/crypto.h ../include/openssl/des.h
738spkac.o: ../include/openssl/dh.h ../include/openssl/dsa.h
739spkac.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
740spkac.o: ../include/openssl/err.h ../include/openssl/evp.h
741spkac.o: ../include/openssl/idea.h ../include/openssl/md2.h
742spkac.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
743spkac.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
744spkac.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
745spkac.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
746spkac.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
747spkac.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
748spkac.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
749spkac.o: ../include/openssl/sha.h ../include/openssl/stack.h
750spkac.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
677verify.o: ../include/openssl/asn1.h ../include/openssl/bio.h 751verify.o: ../include/openssl/asn1.h ../include/openssl/bio.h
678verify.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 752verify.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
679verify.o: ../include/openssl/buffer.h ../include/openssl/cast.h 753verify.o: ../include/openssl/buffer.h ../include/openssl/cast.h
680verify.o: ../include/openssl/crypto.h ../include/openssl/des.h 754verify.o: ../include/openssl/conf.h ../include/openssl/crypto.h
681verify.o: ../include/openssl/dh.h ../include/openssl/dsa.h 755verify.o: ../include/openssl/des.h ../include/openssl/dh.h
682verify.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 756verify.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
683verify.o: ../include/openssl/err.h ../include/openssl/evp.h 757verify.o: ../include/openssl/e_os2.h ../include/openssl/err.h
684verify.o: ../include/openssl/idea.h ../include/openssl/md2.h 758verify.o: ../include/openssl/evp.h ../include/openssl/idea.h
759verify.o: ../include/openssl/lhash.h ../include/openssl/md2.h
685verify.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 760verify.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
686verify.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 761verify.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
687verify.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 762verify.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
@@ -690,8 +765,8 @@ verify.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
690verify.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 765verify.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
691verify.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 766verify.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
692verify.o: ../include/openssl/sha.h ../include/openssl/stack.h 767verify.o: ../include/openssl/sha.h ../include/openssl/stack.h
693verify.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 768verify.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
694verify.o: progs.h 769verify.o: ../include/openssl/x509v3.h apps.h
695version.o: ../include/openssl/asn1.h ../include/openssl/bio.h 770version.o: ../include/openssl/asn1.h ../include/openssl/bio.h
696version.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 771version.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
697version.o: ../include/openssl/buffer.h ../include/openssl/cast.h 772version.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -702,10 +777,12 @@ version.o: ../include/openssl/evp.h ../include/openssl/idea.h
702version.o: ../include/openssl/md2.h ../include/openssl/md5.h 777version.o: ../include/openssl/md2.h ../include/openssl/md5.h
703version.o: ../include/openssl/mdc2.h ../include/openssl/objects.h 778version.o: ../include/openssl/mdc2.h ../include/openssl/objects.h
704version.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 779version.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
705version.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 780version.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h
706version.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 781version.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
707version.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 782version.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
708version.o: ../include/openssl/sha.h ../include/openssl/stack.h apps.h progs.h 783version.o: ../include/openssl/safestack.h ../include/openssl/sha.h
784version.o: ../include/openssl/stack.h ../include/openssl/x509.h
785version.o: ../include/openssl/x509_vfy.h apps.h
709x509.o: ../include/openssl/asn1.h ../include/openssl/bio.h 786x509.o: ../include/openssl/asn1.h ../include/openssl/bio.h
710x509.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 787x509.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
711x509.o: ../include/openssl/buffer.h ../include/openssl/cast.h 788x509.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -724,4 +801,4 @@ x509.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
724x509.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 801x509.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
725x509.o: ../include/openssl/sha.h ../include/openssl/stack.h 802x509.o: ../include/openssl/sha.h ../include/openssl/stack.h
726x509.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 803x509.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
727x509.o: ../include/openssl/x509v3.h apps.h progs.h 804x509.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
new file mode 100644
index 0000000000..f7f133831d
--- /dev/null
+++ b/src/lib/libssl/src/apps/app_rand.c
@@ -0,0 +1,211 @@
1/* apps/app_rand.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright (c) 1998-1999 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 "apps.h"
113#include <openssl/bio.h>
114#include <openssl/rand.h>
115
116
117static int seeded = 0;
118static int egdsocket = 0;
119
120int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
121 {
122 int consider_randfile = (file == NULL);
123 char buffer[200];
124
125#ifdef WINDOWS
126 BIO_printf(bio_e,"Loading 'screen' into random state -");
127 BIO_flush(bio_e);
128 RAND_screen();
129 BIO_printf(bio_e," done\n");
130#endif
131
132 if (file == NULL)
133 file = RAND_file_name(buffer, sizeof buffer);
134 else if (RAND_egd(file) > 0)
135 {
136 /* we try if the given filename is an EGD socket.
137 if it is, we don't write anything back to the file. */
138 egdsocket = 1;
139 return 1;
140 }
141 if (file == NULL || !RAND_load_file(file, -1))
142 {
143 if (RAND_status() == 0 && !dont_warn)
144 {
145 BIO_printf(bio_e,"unable to load 'random state'\n");
146 BIO_printf(bio_e,"This means that the random number generator has not been seeded\n");
147 BIO_printf(bio_e,"with much random data.\n");
148 if (consider_randfile) /* explanation does not apply when a file is explicitly named */
149 {
150 BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n");
151 BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n");
152 }
153 }
154 return 0;
155 }
156 seeded = 1;
157 return 1;
158 }
159
160long app_RAND_load_files(char *name)
161 {
162 char *p,*n;
163 int last;
164 long tot=0;
165 int egd;
166
167 for (;;)
168 {
169 last=0;
170 for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
171 if (*p == '\0') last=1;
172 *p='\0';
173 n=name;
174 name=p+1;
175 if (*n == '\0') break;
176
177 egd=RAND_egd(n);
178 if (egd > 0) tot+=egd;
179 tot+=RAND_load_file(n,1024L*1024L);
180 if (last) break;
181 }
182 if (tot > 512)
183 app_RAND_allow_write_file();
184 return(tot);
185 }
186
187int app_RAND_write_file(const char *file, BIO *bio_e)
188 {
189 char buffer[200];
190
191 if (egdsocket || !seeded)
192 /* If we did not manage to read the seed file,
193 * we should not write a low-entropy seed file back --
194 * it would suppress a crucial warning the next time
195 * we want to use it. */
196 return 0;
197
198 if (file == NULL)
199 file = RAND_file_name(buffer, sizeof buffer);
200 if (file == NULL || !RAND_write_file(file))
201 {
202 BIO_printf(bio_e,"unable to write 'random state'\n");
203 return 0;
204 }
205 return 1;
206 }
207
208void app_RAND_allow_write_file(void)
209 {
210 seeded = 1;
211 }
diff --git a/src/lib/libssl/src/apps/apps.c b/src/lib/libssl/src/apps/apps.c
index 8fb5e8aaa7..a87d23bf33 100644
--- a/src/lib/libssl/src/apps/apps.c
+++ b/src/lib/libssl/src/apps/apps.c
@@ -324,3 +324,93 @@ int app_init(long mesgwin)
324 return(1); 324 return(1);
325 } 325 }
326#endif 326#endif
327
328
329int dump_cert_text (BIO *out, X509 *x)
330{
331 char buf[256];
332 X509_NAME_oneline(X509_get_subject_name(x),buf,256);
333 BIO_puts(out,"subject=");
334 BIO_puts(out,buf);
335
336 X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
337 BIO_puts(out,"\nissuer= ");
338 BIO_puts(out,buf);
339 BIO_puts(out,"\n");
340 return 0;
341}
342
343static char *app_get_pass(BIO *err, char *arg, int keepbio);
344
345int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2)
346{
347 int same;
348 if(!arg2 || !arg1 || strcmp(arg1, arg2)) same = 0;
349 else same = 1;
350 if(arg1) {
351 *pass1 = app_get_pass(err, arg1, same);
352 if(!*pass1) return 0;
353 } else if(pass1) *pass1 = NULL;
354 if(arg2) {
355 *pass2 = app_get_pass(err, arg2, same ? 2 : 0);
356 if(!*pass2) return 0;
357 } else if(pass2) *pass2 = NULL;
358 return 1;
359}
360
361static char *app_get_pass(BIO *err, char *arg, int keepbio)
362{
363 char *tmp, tpass[APP_PASS_LEN];
364 static BIO *pwdbio = NULL;
365 int i;
366 if(!strncmp(arg, "pass:", 5)) return BUF_strdup(arg + 5);
367 if(!strncmp(arg, "env:", 4)) {
368 tmp = getenv(arg + 4);
369 if(!tmp) {
370 BIO_printf(err, "Can't read environment variable %s\n", arg + 4);
371 return NULL;
372 }
373 return BUF_strdup(tmp);
374 }
375 if(!keepbio || !pwdbio) {
376 if(!strncmp(arg, "file:", 5)) {
377 pwdbio = BIO_new_file(arg + 5, "r");
378 if(!pwdbio) {
379 BIO_printf(err, "Can't open file %s\n", arg + 5);
380 return NULL;
381 }
382 } else if(!strncmp(arg, "fd:", 3)) {
383 BIO *btmp;
384 i = atoi(arg + 3);
385 if(i >= 0) pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
386 if((i < 0) || !pwdbio) {
387 BIO_printf(err, "Can't access file descriptor %s\n", arg + 3);
388 return NULL;
389 }
390 /* Can't do BIO_gets on an fd BIO so add a buffering BIO */
391 btmp = BIO_new(BIO_f_buffer());
392 pwdbio = BIO_push(btmp, pwdbio);
393 } else if(!strcmp(arg, "stdin")) {
394 pwdbio = BIO_new_fp(stdin, BIO_NOCLOSE);
395 if(!pwdbio) {
396 BIO_printf(err, "Can't open BIO for stdin\n");
397 return NULL;
398 }
399 } else {
400 BIO_printf(err, "Invalid password argument \"%s\"\n", arg);
401 return NULL;
402 }
403 }
404 i = BIO_gets(pwdbio, tpass, APP_PASS_LEN);
405 if(keepbio != 1) {
406 BIO_free_all(pwdbio);
407 pwdbio = NULL;
408 }
409 if(i <= 0) {
410 BIO_printf(err, "Error reading password from BIO\n");
411 return NULL;
412 }
413 tmp = strchr(tpass, '\n');
414 if(tmp) *tmp = 0;
415 return BUF_strdup(tpass);
416}
diff --git a/src/lib/libssl/src/apps/apps.h b/src/lib/libssl/src/apps/apps.h
index 063f9c65be..2dcdb88c43 100644
--- a/src/lib/libssl/src/apps/apps.h
+++ b/src/lib/libssl/src/apps/apps.h
@@ -64,7 +64,17 @@
64#include <openssl/buffer.h> 64#include <openssl/buffer.h>
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66#include <openssl/crypto.h> 66#include <openssl/crypto.h>
67#include "progs.h" 67#include <openssl/x509.h>
68
69int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
70int app_RAND_write_file(const char *file, BIO *bio_e);
71/* When `file' is NULL, use defaults.
72 * `bio_e' is for error messages. */
73void app_RAND_allow_write_file(void);
74long app_RAND_load_files(char *file); /* `file' is a list of files to read,
75 * separated by LIST_SEPARATOR_CHAR
76 * (see e_os.h). The string is
77 * destroyed! */
68 78
69#ifdef NO_STDIO 79#ifdef NO_STDIO
70BIO_METHOD *BIO_s_file(); 80BIO_METHOD *BIO_s_file();
@@ -103,7 +113,7 @@ extern BIO *bio_err;
103#define do_pipe_sig() 113#define do_pipe_sig()
104#endif 114#endif
105 115
106#if defined(MONOLITH) && !defined(SSLEAY) 116#if defined(MONOLITH) && !defined(OPENSSL_C)
107# define apps_startup() do_pipe_sig() 117# define apps_startup() do_pipe_sig()
108#else 118#else
109# if defined(MSDOS) || defined(WIN16) || defined(WIN32) 119# if defined(MSDOS) || defined(WIN16) || defined(WIN32)
@@ -132,10 +142,16 @@ int args_from_file(char *file, int *argc, char **argv[]);
132int str2fmt(char *s); 142int str2fmt(char *s);
133void program_name(char *in,char *out,int size); 143void program_name(char *in,char *out,int size);
134int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]); 144int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
145#ifdef HEADER_X509_H
146int dump_cert_text(BIO *out, X509 *x);
147#endif
148int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
135#define FORMAT_UNDEF 0 149#define FORMAT_UNDEF 0
136#define FORMAT_ASN1 1 150#define FORMAT_ASN1 1
137#define FORMAT_TEXT 2 151#define FORMAT_TEXT 2
138#define FORMAT_PEM 3 152#define FORMAT_PEM 3
139#define FORMAT_NETSCAPE 4 153#define FORMAT_NETSCAPE 4
140 154
155#define APP_PASS_LEN 1024
156
141#endif 157#endif
diff --git a/src/lib/libssl/src/apps/asn1pars.c b/src/lib/libssl/src/apps/asn1pars.c
index 1b272b2977..f104ebc1f0 100644
--- a/src/lib/libssl/src/apps/asn1pars.c
+++ b/src/lib/libssl/src/apps/asn1pars.c
@@ -74,19 +74,21 @@
74 * -i - indent the details by depth 74 * -i - indent the details by depth
75 * -offset - where in the file to start 75 * -offset - where in the file to start
76 * -length - how many bytes to use 76 * -length - how many bytes to use
77 * -oid file - extra oid decription file 77 * -oid file - extra oid description file
78 */ 78 */
79 79
80#undef PROG 80#undef PROG
81#define PROG asn1parse_main 81#define PROG asn1parse_main
82 82
83int MAIN(int, char **);
84
83int MAIN(int argc, char **argv) 85int MAIN(int argc, char **argv)
84 { 86 {
85 int i,badops=0,offset=0,ret=1,j; 87 int i,badops=0,offset=0,ret=1,j;
86 unsigned int length=0; 88 unsigned int length=0;
87 long num,tmplen; 89 long num,tmplen;
88 BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL; 90 BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL;
89 int informat,indent=0; 91 int informat,indent=0, noout = 0;
90 char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL; 92 char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;
91 unsigned char *tmpbuf; 93 unsigned char *tmpbuf;
92 BUF_MEM *buf=NULL; 94 BUF_MEM *buf=NULL;
@@ -130,6 +132,7 @@ int MAIN(int argc, char **argv)
130 { 132 {
131 indent=1; 133 indent=1;
132 } 134 }
135 else if (strcmp(*argv,"-noout") == 0) noout = 1;
133 else if (strcmp(*argv,"-oid") == 0) 136 else if (strcmp(*argv,"-oid") == 0)
134 { 137 {
135 if (--argc < 1) goto bad; 138 if (--argc < 1) goto bad;
@@ -168,8 +171,10 @@ bad:
168 BIO_printf(bio_err,"where options are\n"); 171 BIO_printf(bio_err,"where options are\n");
169 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n"); 172 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n");
170 BIO_printf(bio_err," -in arg input file\n"); 173 BIO_printf(bio_err," -in arg input file\n");
174 BIO_printf(bio_err," -out arg output file\n");
175 BIO_printf(bio_err," -noout arg don't produce any output\n");
171 BIO_printf(bio_err," -offset arg offset into file\n"); 176 BIO_printf(bio_err," -offset arg offset into file\n");
172 BIO_printf(bio_err," -length arg lenth of section in file\n"); 177 BIO_printf(bio_err," -length arg length of section in file\n");
173 BIO_printf(bio_err," -i indent entries\n"); 178 BIO_printf(bio_err," -i indent entries\n");
174 BIO_printf(bio_err," -oid file file of extra oid definitions\n"); 179 BIO_printf(bio_err," -oid file file of extra oid definitions\n");
175 BIO_printf(bio_err," -strparse offset\n"); 180 BIO_printf(bio_err," -strparse offset\n");
@@ -287,7 +292,8 @@ bad:
287 goto end; 292 goto end;
288 } 293 }
289 } 294 }
290 if (!ASN1_parse(out,(unsigned char *)&(str[offset]),length,indent)) 295 if (!noout &&
296 !ASN1_parse(out,(unsigned char *)&(str[offset]),length,indent))
291 { 297 {
292 ERR_print_errors(bio_err); 298 ERR_print_errors(bio_err);
293 goto end; 299 goto end;
diff --git a/src/lib/libssl/src/apps/ca.c b/src/lib/libssl/src/apps/ca.c
index 9ed100dd3c..e22beda097 100644
--- a/src/lib/libssl/src/apps/ca.c
+++ b/src/lib/libssl/src/apps/ca.c
@@ -147,6 +147,8 @@ static char *ca_usage[]={
147" -gencrl - Generate a new CRL\n", 147" -gencrl - Generate a new CRL\n",
148" -crldays days - Days is when the next CRL is due\n", 148" -crldays days - Days is when the next CRL is due\n",
149" -crlhours hours - Hours is when the next CRL is due\n", 149" -crlhours hours - Hours is when the next CRL is due\n",
150" -startdate YYMMDDHHMMSSZ - certificate validity notBefore\n",
151" -enddate YYMMDDHHMMSSZ - certificate validity notAfter (overrides -days)\n",
150" -days arg - number of days to certify the certificate for\n", 152" -days arg - number of days to certify the certificate for\n",
151" -md arg - md to use, one of md2, md5, sha or sha1\n", 153" -md arg - md to use, one of md2, md5, sha or sha1\n",
152" -policy arg - The CA 'policy' to support\n", 154" -policy arg - The CA 'policy' to support\n",
@@ -163,6 +165,8 @@ static char *ca_usage[]={
163" -batch - Don't ask questions\n", 165" -batch - Don't ask questions\n",
164" -msie_hack - msie modifications to handle all those universal strings\n", 166" -msie_hack - msie modifications to handle all those universal strings\n",
165" -revoke file - Revoke a certificate (given in file)\n", 167" -revoke file - Revoke a certificate (given in file)\n",
168" -extensions .. - Extension section (override value in config file)\n",
169" -crlexts .. - CRL extension section (override value in config file)\n",
166NULL 170NULL
167}; 171};
168 172
@@ -174,7 +178,6 @@ extern int EF_ALIGNMENT;
174 178
175static int add_oid_section(LHASH *conf); 179static int add_oid_section(LHASH *conf);
176static void lookup_fail(char *name,char *tag); 180static void lookup_fail(char *name,char *tag);
177static int MS_CALLBACK key_callback(char *buf,int len,int verify,void *u);
178static unsigned long index_serial_hash(char **a); 181static unsigned long index_serial_hash(char **a);
179static int index_serial_cmp(char **a, char **b); 182static int index_serial_cmp(char **a, char **b);
180static unsigned long index_name_hash(char **a); 183static unsigned long index_name_hash(char **a);
@@ -197,22 +200,24 @@ static int certify_spkac(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
197 char *enddate, int days, char *ext_sect,LHASH *conf, 200 char *enddate, int days, char *ext_sect,LHASH *conf,
198 int verbose); 201 int verbose);
199static int fix_data(int nid, int *type); 202static int fix_data(int nid, int *type);
200static void write_new_certificate(BIO *bp, X509 *x, int output_der); 203static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext);
201static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, 204static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
202 STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial, 205 STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial,
203 char *startdate, char *enddate, int days, int batch, int verbose, 206 char *startdate, char *enddate, int days, int batch, int verbose,
204 X509_REQ *req, char *ext_sect, LHASH *conf); 207 X509_REQ *req, char *ext_sect, LHASH *conf);
205static int do_revoke(X509 *x509, TXT_DB *db); 208static int do_revoke(X509 *x509, TXT_DB *db);
206static int check_time_format(char *str); 209static int check_time_format(char *str);
207static LHASH *conf; 210static LHASH *conf=NULL;
208static char *key=NULL;
209static char *section=NULL; 211static char *section=NULL;
210 212
211static int preserve=0; 213static int preserve=0;
212static int msie_hack=0; 214static int msie_hack=0;
213 215
216int MAIN(int, char **);
217
214int MAIN(int argc, char **argv) 218int MAIN(int argc, char **argv)
215 { 219 {
220 char *key=NULL;
216 int total=0; 221 int total=0;
217 int total_done=0; 222 int total_done=0;
218 int badops=0; 223 int badops=0;
@@ -244,6 +249,7 @@ int MAIN(int argc, char **argv)
244 char *enddate=NULL; 249 char *enddate=NULL;
245 int days=0; 250 int days=0;
246 int batch=0; 251 int batch=0;
252 int notext=0;
247 X509 *x509=NULL; 253 X509 *x509=NULL;
248 X509 *x=NULL; 254 X509 *x=NULL;
249 BIO *in=NULL,*out=NULL,*Sout=NULL,*Cout=NULL; 255 BIO *in=NULL,*out=NULL,*Sout=NULL,*Cout=NULL;
@@ -262,6 +268,7 @@ int MAIN(int argc, char **argv)
262#undef BSIZE 268#undef BSIZE
263#define BSIZE 256 269#define BSIZE 256
264 MS_STATIC char buf[3][BSIZE]; 270 MS_STATIC char buf[3][BSIZE];
271 char *randfile=NULL;
265 272
266#ifdef EFENCE 273#ifdef EFENCE
267EF_PROTECT_FREE=1; 274EF_PROTECT_FREE=1;
@@ -271,9 +278,12 @@ EF_ALIGNMENT=0;
271 278
272 apps_startup(); 279 apps_startup();
273 280
274 X509V3_add_standard_extensions(); 281 conf = NULL;
282 key = NULL;
283 section = NULL;
275 284
276 preserve=0; 285 preserve=0;
286 msie_hack=0;
277 if (bio_err == NULL) 287 if (bio_err == NULL)
278 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 288 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
279 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 289 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
@@ -350,6 +360,8 @@ EF_ALIGNMENT=0;
350 if (--argc < 1) goto bad; 360 if (--argc < 1) goto bad;
351 outdir= *(++argv); 361 outdir= *(++argv);
352 } 362 }
363 else if (strcmp(*argv,"-notext") == 0)
364 notext=1;
353 else if (strcmp(*argv,"-batch") == 0) 365 else if (strcmp(*argv,"-batch") == 0)
354 batch=1; 366 batch=1;
355 else if (strcmp(*argv,"-preserveDN") == 0) 367 else if (strcmp(*argv,"-preserveDN") == 0)
@@ -393,6 +405,16 @@ EF_ALIGNMENT=0;
393 infile= *(++argv); 405 infile= *(++argv);
394 dorevoke=1; 406 dorevoke=1;
395 } 407 }
408 else if (strcmp(*argv,"-extensions") == 0)
409 {
410 if (--argc < 1) goto bad;
411 extensions= *(++argv);
412 }
413 else if (strcmp(*argv,"-crlexts") == 0)
414 {
415 if (--argc < 1) goto bad;
416 crl_ext= *(++argv);
417 }
396 else 418 else
397 { 419 {
398bad: 420bad:
@@ -476,12 +498,16 @@ bad:
476 BIO_free(oid_bio); 498 BIO_free(oid_bio);
477 } 499 }
478 } 500 }
479 } 501 if(!add_oid_section(conf))
480 if(!add_oid_section(conf)) { 502 {
481 ERR_print_errors(bio_err); 503 ERR_print_errors(bio_err);
482 goto err; 504 goto err;
505 }
483 } 506 }
484 507
508 randfile = CONF_get_string(conf, BASE_SECTION, "RANDFILE");
509 app_RAND_load_file(randfile, bio_err, 0);
510
485 in=BIO_new(BIO_s_file()); 511 in=BIO_new(BIO_s_file());
486 out=BIO_new(BIO_s_file()); 512 out=BIO_new(BIO_s_file());
487 Sout=BIO_new(BIO_s_file()); 513 Sout=BIO_new(BIO_s_file());
@@ -493,7 +519,7 @@ bad:
493 } 519 }
494 520
495 /*****************************************************************/ 521 /*****************************************************************/
496 /* we definitly need an public key, so lets get it */ 522 /* we definitely need an public key, so lets get it */
497 523
498 if ((keyfile == NULL) && ((keyfile=CONF_get_string(conf, 524 if ((keyfile == NULL) && ((keyfile=CONF_get_string(conf,
499 section,ENV_PRIVATE_KEY)) == NULL)) 525 section,ENV_PRIVATE_KEY)) == NULL))
@@ -507,13 +533,8 @@ bad:
507 BIO_printf(bio_err,"trying to load CA private key\n"); 533 BIO_printf(bio_err,"trying to load CA private key\n");
508 goto err; 534 goto err;
509 } 535 }
510 if (key == NULL) 536 pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,key);
511 pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL); 537 if(key) memset(key,0,strlen(key));
512 else
513 {
514 pkey=PEM_read_bio_PrivateKey(in,NULL,key_callback,NULL);
515 memset(key,0,strlen(key));
516 }
517 if (pkey == NULL) 538 if (pkey == NULL)
518 { 539 {
519 BIO_printf(bio_err,"unable to load CA private key\n"); 540 BIO_printf(bio_err,"unable to load CA private key\n");
@@ -566,14 +587,19 @@ bad:
566 BIO_printf(bio_err,"there needs to be defined a directory for new certificate to be placed in\n"); 587 BIO_printf(bio_err,"there needs to be defined a directory for new certificate to be placed in\n");
567 goto err; 588 goto err;
568 } 589 }
569#ifdef VMS 590#ifndef VMS /* outdir is a directory spec, but access() for VMS demands a
570 /* For technical reasons, VMS misbehaves with X_OK */ 591 filename. In any case, stat(), below, will catch the problem
571 if (access(outdir,R_OK|W_OK) != 0) 592 if outdir is not a directory spec, and the fopen() or open()
572#else 593 will catch an error if there is no write access.
594
595 Presumably, this problem could also be solved by using the DEC
596 C routines to convert the directory syntax to Unixly, and give
597 that to access(). However, time's too short to do that just
598 now.
599 */
573 if (access(outdir,R_OK|W_OK|X_OK) != 0) 600 if (access(outdir,R_OK|W_OK|X_OK) != 0)
574#endif
575 { 601 {
576 BIO_printf(bio_err,"I am unable to acces the %s directory\n",outdir); 602 BIO_printf(bio_err,"I am unable to access the %s directory\n",outdir);
577 perror(outdir); 603 perror(outdir);
578 goto err; 604 goto err;
579 } 605 }
@@ -584,12 +610,15 @@ bad:
584 perror(outdir); 610 perror(outdir);
585 goto err; 611 goto err;
586 } 612 }
613#ifdef S_IFDIR
587 if (!(sb.st_mode & S_IFDIR)) 614 if (!(sb.st_mode & S_IFDIR))
588 { 615 {
589 BIO_printf(bio_err,"%s need to be a directory\n",outdir); 616 BIO_printf(bio_err,"%s need to be a directory\n",outdir);
590 perror(outdir); 617 perror(outdir);
591 goto err; 618 goto err;
592 } 619 }
620#endif
621#endif
593 } 622 }
594 623
595 /*****************************************************************/ 624 /*****************************************************************/
@@ -655,7 +684,7 @@ bad:
655 TXT_DB_write(out,db); 684 TXT_DB_write(out,db);
656 BIO_printf(bio_err,"%d entries loaded from the database\n", 685 BIO_printf(bio_err,"%d entries loaded from the database\n",
657 db->data->num); 686 db->data->num);
658 BIO_printf(bio_err,"generating indexs\n"); 687 BIO_printf(bio_err,"generating index\n");
659 } 688 }
660 689
661 if (!TXT_DB_create_index(db,DB_serial,NULL,index_serial_hash, 690 if (!TXT_DB_create_index(db,DB_serial,NULL,index_serial_hash,
@@ -720,8 +749,8 @@ bad:
720 lookup_fail(section,ENV_SERIAL); 749 lookup_fail(section,ENV_SERIAL);
721 goto err; 750 goto err;
722 } 751 }
723 752 if(!extensions)
724 extensions=CONF_get_string(conf,section,ENV_EXTENSIONS); 753 extensions=CONF_get_string(conf,section,ENV_EXTENSIONS);
725 if(extensions) { 754 if(extensions) {
726 /* Check syntax of file */ 755 /* Check syntax of file */
727 X509V3_CTX ctx; 756 X509V3_CTX ctx;
@@ -966,8 +995,8 @@ bad:
966 perror(buf[2]); 995 perror(buf[2]);
967 goto err; 996 goto err;
968 } 997 }
969 write_new_certificate(Cout,x, 0); 998 write_new_certificate(Cout,x, 0, notext);
970 write_new_certificate(Sout,x, output_der); 999 write_new_certificate(Sout,x, output_der, notext);
971 } 1000 }
972 1001
973 if (sk_num(cert_sk)) 1002 if (sk_num(cert_sk))
@@ -987,14 +1016,14 @@ bad:
987 out=NULL; 1016 out=NULL;
988 if (rename(serialfile,buf[2]) < 0) 1017 if (rename(serialfile,buf[2]) < 0)
989 { 1018 {
990 BIO_printf(bio_err,"unabel to rename %s to %s\n", 1019 BIO_printf(bio_err,"unable to rename %s to %s\n",
991 serialfile,buf[2]); 1020 serialfile,buf[2]);
992 perror("reason"); 1021 perror("reason");
993 goto err; 1022 goto err;
994 } 1023 }
995 if (rename(buf[0],serialfile) < 0) 1024 if (rename(buf[0],serialfile) < 0)
996 { 1025 {
997 BIO_printf(bio_err,"unabel to rename %s to %s\n", 1026 BIO_printf(bio_err,"unable to rename %s to %s\n",
998 buf[0],serialfile); 1027 buf[0],serialfile);
999 perror("reason"); 1028 perror("reason");
1000 rename(buf[2],serialfile); 1029 rename(buf[2],serialfile);
@@ -1011,14 +1040,14 @@ bad:
1011 1040
1012 if (rename(dbfile,buf[2]) < 0) 1041 if (rename(dbfile,buf[2]) < 0)
1013 { 1042 {
1014 BIO_printf(bio_err,"unabel to rename %s to %s\n", 1043 BIO_printf(bio_err,"unable to rename %s to %s\n",
1015 dbfile,buf[2]); 1044 dbfile,buf[2]);
1016 perror("reason"); 1045 perror("reason");
1017 goto err; 1046 goto err;
1018 } 1047 }
1019 if (rename(buf[1],dbfile) < 0) 1048 if (rename(buf[1],dbfile) < 0)
1020 { 1049 {
1021 BIO_printf(bio_err,"unabel to rename %s to %s\n", 1050 BIO_printf(bio_err,"unable to rename %s to %s\n",
1022 buf[1],dbfile); 1051 buf[1],dbfile);
1023 perror("reason"); 1052 perror("reason");
1024 rename(buf[2],dbfile); 1053 rename(buf[2],dbfile);
@@ -1031,7 +1060,7 @@ bad:
1031 /*****************************************************************/ 1060 /*****************************************************************/
1032 if (gencrl) 1061 if (gencrl)
1033 { 1062 {
1034 crl_ext=CONF_get_string(conf,section,ENV_CRLEXT); 1063 if(!crl_ext) crl_ext=CONF_get_string(conf,section,ENV_CRLEXT);
1035 if(crl_ext) { 1064 if(crl_ext) {
1036 /* Check syntax of file */ 1065 /* Check syntax of file */
1037 X509V3_CTX ctx; 1066 X509V3_CTX ctx;
@@ -1143,13 +1172,6 @@ bad:
1143 /*****************************************************************/ 1172 /*****************************************************************/
1144 if (dorevoke) 1173 if (dorevoke)
1145 { 1174 {
1146 in=BIO_new(BIO_s_file());
1147 out=BIO_new(BIO_s_file());
1148 if ((in == NULL) || (out == NULL))
1149 {
1150 ERR_print_errors(bio_err);
1151 goto err;
1152 }
1153 if (infile == NULL) 1175 if (infile == NULL)
1154 { 1176 {
1155 BIO_printf(bio_err,"no input files\n"); 1177 BIO_printf(bio_err,"no input files\n");
@@ -1157,19 +1179,22 @@ bad:
1157 } 1179 }
1158 else 1180 else
1159 { 1181 {
1182 X509 *revcert;
1160 if (BIO_read_filename(in,infile) <= 0) 1183 if (BIO_read_filename(in,infile) <= 0)
1161 { 1184 {
1162 perror(infile); 1185 perror(infile);
1163 BIO_printf(bio_err,"error trying to load '%s' certificate\n",infile); 1186 BIO_printf(bio_err,"error trying to load '%s' certificate\n",infile);
1164 goto err; 1187 goto err;
1165 } 1188 }
1166 x509=PEM_read_bio_X509(in,NULL,NULL,NULL); 1189 revcert=PEM_read_bio_X509(in,NULL,NULL,NULL);
1167 if (x509 == NULL) 1190 if (revcert == NULL)
1168 { 1191 {
1169 BIO_printf(bio_err,"unable to load '%s' certificate\n",infile); 1192 BIO_printf(bio_err,"unable to load '%s' certificate\n",infile);
1170 goto err; 1193 goto err;
1171 } 1194 }
1172 j=do_revoke(x509,db); 1195 j=do_revoke(revcert,db);
1196 if (j <= 0) goto err;
1197 X509_free(revcert);
1173 1198
1174 strncpy(buf[0],dbfile,BSIZE-4); 1199 strncpy(buf[0],dbfile,BSIZE-4);
1175 strcat(buf[0],".new"); 1200 strcat(buf[0],".new");
@@ -1181,10 +1206,6 @@ bad:
1181 } 1206 }
1182 j=TXT_DB_write(out,db); 1207 j=TXT_DB_write(out,db);
1183 if (j <= 0) goto err; 1208 if (j <= 0) goto err;
1184 BIO_free(in);
1185 BIO_free(out);
1186 in=NULL;
1187 out=NULL;
1188 strncpy(buf[1],dbfile,BSIZE-4); 1209 strncpy(buf[1],dbfile,BSIZE-4);
1189 strcat(buf[1],".old"); 1210 strcat(buf[1],".old");
1190 if (rename(dbfile,buf[1]) < 0) 1211 if (rename(dbfile,buf[1]) < 0)
@@ -1215,13 +1236,13 @@ err:
1215 sk_pop_free(cert_sk,X509_free); 1236 sk_pop_free(cert_sk,X509_free);
1216 1237
1217 if (ret) ERR_print_errors(bio_err); 1238 if (ret) ERR_print_errors(bio_err);
1239 app_RAND_write_file(randfile, bio_err);
1218 BN_free(serial); 1240 BN_free(serial);
1219 TXT_DB_free(db); 1241 TXT_DB_free(db);
1220 EVP_PKEY_free(pkey); 1242 EVP_PKEY_free(pkey);
1221 X509_free(x509); 1243 X509_free(x509);
1222 X509_CRL_free(crl); 1244 X509_CRL_free(crl);
1223 CONF_free(conf); 1245 CONF_free(conf);
1224 X509V3_EXT_cleanup();
1225 OBJ_cleanup(); 1246 OBJ_cleanup();
1226 EXIT(ret); 1247 EXIT(ret);
1227 } 1248 }
@@ -1231,17 +1252,6 @@ static void lookup_fail(char *name, char *tag)
1231 BIO_printf(bio_err,"variable lookup failed for %s::%s\n",name,tag); 1252 BIO_printf(bio_err,"variable lookup failed for %s::%s\n",name,tag);
1232 } 1253 }
1233 1254
1234static int MS_CALLBACK key_callback(char *buf, int len, int verify, void *u)
1235 {
1236 int i;
1237
1238 if (key == NULL) return(0);
1239 i=strlen(key);
1240 i=(i > len)?len:i;
1241 memcpy(buf,key,i);
1242 return(i);
1243 }
1244
1245static unsigned long index_serial_hash(char **a) 1255static unsigned long index_serial_hash(char **a)
1246 { 1256 {
1247 char *n; 1257 char *n;
@@ -1664,8 +1674,7 @@ again2:
1664 1674
1665 if (push != NULL) 1675 if (push != NULL)
1666 { 1676 {
1667 if (!X509_NAME_add_entry(subject,push, 1677 if (!X509_NAME_add_entry(subject,push, -1, 0))
1668 X509_NAME_entry_count(subject),0))
1669 { 1678 {
1670 if (push != NULL) 1679 if (push != NULL)
1671 X509_NAME_ENTRY_free(push); 1680 X509_NAME_ENTRY_free(push);
@@ -1685,7 +1694,7 @@ again2:
1685 } 1694 }
1686 1695
1687 if (verbose) 1696 if (verbose)
1688 BIO_printf(bio_err,"The subject name apears to be ok, checking data base for clashes\n"); 1697 BIO_printf(bio_err,"The subject name appears to be ok, checking data base for clashes\n");
1689 1698
1690 row[DB_name]=X509_NAME_oneline(subject,NULL,0); 1699 row[DB_name]=X509_NAME_oneline(subject,NULL,0);
1691 row[DB_serial]=BN_bn2hex(serial); 1700 row[DB_serial]=BN_bn2hex(serial);
@@ -1742,7 +1751,7 @@ again2:
1742 goto err; 1751 goto err;
1743 } 1752 }
1744 1753
1745 /* We are now totaly happy, lets make and sign the certificate */ 1754 /* We are now totally happy, lets make and sign the certificate */
1746 if (verbose) 1755 if (verbose)
1747 BIO_printf(bio_err,"Everything appears to be ok, creating and signing the certificate\n"); 1756 BIO_printf(bio_err,"Everything appears to be ok, creating and signing the certificate\n");
1748 1757
@@ -1789,7 +1798,7 @@ again2:
1789 ASN1_INTEGER_set(ci->version,2); /* version 3 certificate */ 1798 ASN1_INTEGER_set(ci->version,2); /* version 3 certificate */
1790 1799
1791 /* Free the current entries if any, there should not 1800 /* Free the current entries if any, there should not
1792 * be any I belive */ 1801 * be any I believe */
1793 if (ci->extensions != NULL) 1802 if (ci->extensions != NULL)
1794 sk_X509_EXTENSION_pop_free(ci->extensions, 1803 sk_X509_EXTENSION_pop_free(ci->extensions,
1795 X509_EXTENSION_free); 1804 X509_EXTENSION_free);
@@ -1883,6 +1892,8 @@ err:
1883 X509_NAME_free(CAname); 1892 X509_NAME_free(CAname);
1884 if (subject != NULL) 1893 if (subject != NULL)
1885 X509_NAME_free(subject); 1894 X509_NAME_free(subject);
1895 if (tmptm != NULL)
1896 ASN1_UTCTIME_free(tmptm);
1886 if (ok <= 0) 1897 if (ok <= 0)
1887 { 1898 {
1888 if (ret != NULL) X509_free(ret); 1899 if (ret != NULL) X509_free(ret);
@@ -1893,17 +1904,16 @@ err:
1893 return(ok); 1904 return(ok);
1894 } 1905 }
1895 1906
1896static void write_new_certificate(BIO *bp, X509 *x, int output_der) 1907static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext)
1897 { 1908 {
1898 char *f;
1899 char buf[256];
1900 1909
1901 if (output_der) 1910 if (output_der)
1902 { 1911 {
1903 (void)i2d_X509_bio(bp,x); 1912 (void)i2d_X509_bio(bp,x);
1904 return; 1913 return;
1905 } 1914 }
1906 1915#if 0
1916 /* ??? Not needed since X509_print prints all this stuff anyway */
1907 f=X509_NAME_oneline(X509_get_issuer_name(x),buf,256); 1917 f=X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
1908 BIO_printf(bp,"issuer :%s\n",f); 1918 BIO_printf(bp,"issuer :%s\n",f);
1909 1919
@@ -1913,10 +1923,9 @@ static void write_new_certificate(BIO *bp, X509 *x, int output_der)
1913 BIO_puts(bp,"serial :"); 1923 BIO_puts(bp,"serial :");
1914 i2a_ASN1_INTEGER(bp,x->cert_info->serialNumber); 1924 i2a_ASN1_INTEGER(bp,x->cert_info->serialNumber);
1915 BIO_puts(bp,"\n\n"); 1925 BIO_puts(bp,"\n\n");
1916 X509_print(bp,x); 1926#endif
1917 BIO_puts(bp,"\n"); 1927 if(!notext)X509_print(bp,x);
1918 PEM_write_bio_X509(bp,x); 1928 PEM_write_bio_X509(bp,x);
1919 BIO_puts(bp,"\n");
1920 } 1929 }
1921 1930
1922static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509, 1931static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
@@ -1929,7 +1938,6 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1929 X509_REQ *req=NULL; 1938 X509_REQ *req=NULL;
1930 CONF_VALUE *cv=NULL; 1939 CONF_VALUE *cv=NULL;
1931 NETSCAPE_SPKI *spki = NULL; 1940 NETSCAPE_SPKI *spki = NULL;
1932 unsigned char *spki_der = NULL,*p;
1933 X509_REQ_INFO *ri; 1941 X509_REQ_INFO *ri;
1934 char *type,*buf; 1942 char *type,*buf;
1935 EVP_PKEY *pktmp=NULL; 1943 EVP_PKEY *pktmp=NULL;
@@ -1986,31 +1994,22 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1986 1994
1987 cv=sk_CONF_VALUE_value(sk,i); 1995 cv=sk_CONF_VALUE_value(sk,i);
1988 type=cv->name; 1996 type=cv->name;
1989 buf=cv->value; 1997 /* Skip past any leading X. X: X, etc to allow for
1998 * multiple instances
1999 */
2000 for(buf = cv->name; *buf ; buf++)
2001 if ((*buf == ':') || (*buf == ',') || (*buf == '.')) {
2002 buf++;
2003 if(*buf) type = buf;
2004 break;
2005 }
1990 2006
2007 buf=cv->value;
1991 if ((nid=OBJ_txt2nid(type)) == NID_undef) 2008 if ((nid=OBJ_txt2nid(type)) == NID_undef)
1992 { 2009 {
1993 if (strcmp(type, "SPKAC") == 0) 2010 if (strcmp(type, "SPKAC") == 0)
1994 { 2011 {
1995 spki_der=(unsigned char *)Malloc( 2012 spki = NETSCAPE_SPKI_b64_decode(cv->value, -1);
1996 strlen(cv->value)+1);
1997 if (spki_der == NULL)
1998 {
1999 BIO_printf(bio_err,"Malloc failure\n");
2000 goto err;
2001 }
2002 j = EVP_DecodeBlock(spki_der, (unsigned char *)cv->value,
2003 strlen(cv->value));
2004 if (j <= 0)
2005 {
2006 BIO_printf(bio_err, "Can't b64 decode SPKAC structure\n");
2007 goto err;
2008 }
2009
2010 p=spki_der;
2011 spki = d2i_NETSCAPE_SPKI(&spki, &p, j);
2012 Free(spki_der);
2013 spki_der = NULL;
2014 if (spki == NULL) 2013 if (spki == NULL)
2015 { 2014 {
2016 BIO_printf(bio_err,"unable to load Netscape SPKAC structure\n"); 2015 BIO_printf(bio_err,"unable to load Netscape SPKAC structure\n");
@@ -2034,8 +2033,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
2034 strlen(buf))) == NULL) 2033 strlen(buf))) == NULL)
2035 goto err; 2034 goto err;
2036 2035
2037 if (!X509_NAME_add_entry(n,ne,X509_NAME_entry_count(n),0)) 2036 if (!X509_NAME_add_entry(n,ne,-1, 0)) goto err;
2038 goto err;
2039 } 2037 }
2040 if (spki == NULL) 2038 if (spki == NULL)
2041 { 2039 {
@@ -2050,7 +2048,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
2050 2048
2051 BIO_printf(bio_err,"Check that the SPKAC request matches the signature\n"); 2049 BIO_printf(bio_err,"Check that the SPKAC request matches the signature\n");
2052 2050
2053 if ((pktmp=X509_PUBKEY_get(spki->spkac->pubkey)) == NULL) 2051 if ((pktmp=NETSCAPE_SPKI_get_pubkey(spki)) == NULL)
2054 { 2052 {
2055 BIO_printf(bio_err,"error unpacking SPKAC public key\n"); 2053 BIO_printf(bio_err,"error unpacking SPKAC public key\n");
2056 goto err; 2054 goto err;
@@ -2071,7 +2069,6 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
2071err: 2069err:
2072 if (req != NULL) X509_REQ_free(req); 2070 if (req != NULL) X509_REQ_free(req);
2073 if (parms != NULL) CONF_free(parms); 2071 if (parms != NULL) CONF_free(parms);
2074 if (spki_der != NULL) Free(spki_der);
2075 if (spki != NULL) NETSCAPE_SPKI_free(spki); 2072 if (spki != NULL) NETSCAPE_SPKI_free(spki);
2076 if (ne != NULL) X509_NAME_ENTRY_free(ne); 2073 if (ne != NULL) X509_NAME_ENTRY_free(ne);
2077 2074
@@ -2127,20 +2124,26 @@ static int add_oid_section(LHASH *hconf)
2127 2124
2128static int do_revoke(X509 *x509, TXT_DB *db) 2125static int do_revoke(X509 *x509, TXT_DB *db)
2129{ 2126{
2130 ASN1_UTCTIME *tm=NULL; 2127 ASN1_UTCTIME *tm=NULL, *revtm=NULL;
2131 char *row[DB_NUMBER],**rrow,**irow; 2128 char *row[DB_NUMBER],**rrow,**irow;
2129 BIGNUM *bn = NULL;
2132 int ok=-1,i; 2130 int ok=-1,i;
2133 2131
2134 for (i=0; i<DB_NUMBER; i++) 2132 for (i=0; i<DB_NUMBER; i++)
2135 row[i]=NULL; 2133 row[i]=NULL;
2136 row[DB_name]=X509_NAME_oneline(x509->cert_info->subject,NULL,0); 2134 row[DB_name]=X509_NAME_oneline(X509_get_subject_name(x509),NULL,0);
2137 row[DB_serial]=BN_bn2hex(ASN1_INTEGER_to_BN(x509->cert_info->serialNumber,NULL)); 2135 bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(x509),NULL);
2136 row[DB_serial]=BN_bn2hex(bn);
2137 BN_free(bn);
2138 if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) 2138 if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
2139 { 2139 {
2140 BIO_printf(bio_err,"Malloc failure\n"); 2140 BIO_printf(bio_err,"Malloc failure\n");
2141 goto err; 2141 goto err;
2142 } 2142 }
2143 rrow=TXT_DB_get_by_index(db,DB_name,row); 2143 /* We have to lookup by serial number because name lookup
2144 * skips revoked certs
2145 */
2146 rrow=TXT_DB_get_by_index(db,DB_serial,row);
2144 if (rrow == NULL) 2147 if (rrow == NULL)
2145 { 2148 {
2146 BIO_printf(bio_err,"Adding Entry to DB for %s\n", row[DB_name]); 2149 BIO_printf(bio_err,"Adding Entry to DB for %s\n", row[DB_name]);
@@ -2191,16 +2194,15 @@ static int do_revoke(X509 *x509, TXT_DB *db)
2191 } 2194 }
2192 2195
2193 /* Revoke Certificate */ 2196 /* Revoke Certificate */
2194 do_revoke(x509,db); 2197 ok = do_revoke(x509,db);
2195 2198
2196 ok=1;
2197 goto err; 2199 goto err;
2198 2200
2199 } 2201 }
2200 else if (index_serial_cmp(row,rrow)) 2202 else if (index_name_cmp(row,rrow))
2201 { 2203 {
2202 BIO_printf(bio_err,"ERROR:no same serial number %s\n", 2204 BIO_printf(bio_err,"ERROR:name does not match %s\n",
2203 row[DB_serial]); 2205 row[DB_name]);
2204 goto err; 2206 goto err;
2205 } 2207 }
2206 else if (rrow[DB_type][0]=='R') 2208 else if (rrow[DB_type][0]=='R')
@@ -2212,12 +2214,14 @@ static int do_revoke(X509 *x509, TXT_DB *db)
2212 else 2214 else
2213 { 2215 {
2214 BIO_printf(bio_err,"Revoking Certificate %s.\n", rrow[DB_serial]); 2216 BIO_printf(bio_err,"Revoking Certificate %s.\n", rrow[DB_serial]);
2215 tm=X509_gmtime_adj(tm,0); 2217 revtm = ASN1_UTCTIME_new();
2218 revtm=X509_gmtime_adj(revtm,0);
2216 rrow[DB_type][0]='R'; 2219 rrow[DB_type][0]='R';
2217 rrow[DB_type][1]='\0'; 2220 rrow[DB_type][1]='\0';
2218 rrow[DB_rev_date]=(char *)Malloc(tm->length+1); 2221 rrow[DB_rev_date]=(char *)Malloc(revtm->length+1);
2219 memcpy(rrow[DB_rev_date],tm->data,tm->length); 2222 memcpy(rrow[DB_rev_date],revtm->data,revtm->length);
2220 rrow[DB_rev_date][tm->length]='\0'; 2223 rrow[DB_rev_date][revtm->length]='\0';
2224 ASN1_UTCTIME_free(revtm);
2221 } 2225 }
2222 ok=1; 2226 ok=1;
2223err: 2227err:
@@ -2226,7 +2230,6 @@ err:
2226 if (row[i] != NULL) 2230 if (row[i] != NULL)
2227 Free(row[i]); 2231 Free(row[i]);
2228 } 2232 }
2229 ASN1_UTCTIME_free(tm);
2230 return(ok); 2233 return(ok);
2231} 2234}
2232 2235
diff --git a/src/lib/libssl/src/apps/ciphers.c b/src/lib/libssl/src/apps/ciphers.c
index 08e47be4f7..f8e9e7be2e 100644
--- a/src/lib/libssl/src/apps/ciphers.c
+++ b/src/lib/libssl/src/apps/ciphers.c
@@ -66,10 +66,6 @@
66#include <openssl/err.h> 66#include <openssl/err.h>
67#include <openssl/ssl.h> 67#include <openssl/ssl.h>
68 68
69#if defined(NO_RSA) && !defined(NO_SSL2)
70#define NO_SSL2
71#endif
72
73#undef PROG 69#undef PROG
74#define PROG ciphers_main 70#define PROG ciphers_main
75 71
@@ -81,6 +77,8 @@ static char *ciphers_usage[]={
81NULL 77NULL
82}; 78};
83 79
80int MAIN(int, char **);
81
84int MAIN(int argc, char **argv) 82int MAIN(int argc, char **argv)
85 { 83 {
86 int ret=1,i; 84 int ret=1,i;
@@ -145,12 +143,16 @@ int MAIN(int argc, char **argv)
145 goto end; 143 goto end;
146 } 144 }
147 145
148 SSLeay_add_ssl_algorithms(); 146 OpenSSL_add_ssl_algorithms();
149 147
150 ctx=SSL_CTX_new(meth); 148 ctx=SSL_CTX_new(meth);
151 if (ctx == NULL) goto err; 149 if (ctx == NULL) goto err;
152 if (ciphers != NULL) 150 if (ciphers != NULL) {
153 SSL_CTX_set_cipher_list(ctx,ciphers); 151 if(!SSL_CTX_set_cipher_list(ctx,ciphers)) {
152 BIO_printf(bio_err, "Error in cipher list\n");
153 goto err;
154 }
155 }
154 ssl=SSL_new(ctx); 156 ssl=SSL_new(ctx);
155 if (ssl == NULL) goto err; 157 if (ssl == NULL) goto err;
156 158
diff --git a/src/lib/libssl/src/apps/crl.c b/src/lib/libssl/src/apps/crl.c
index f7bdf76676..338f46d97c 100644
--- a/src/lib/libssl/src/apps/crl.c
+++ b/src/lib/libssl/src/apps/crl.c
@@ -75,7 +75,7 @@
75static char *crl_usage[]={ 75static char *crl_usage[]={
76"usage: crl args\n", 76"usage: crl args\n",
77"\n", 77"\n",
78" -inform arg - input format - default PEM (one of DER, TXT or PEM)\n", 78" -inform arg - input format - default PEM (DER or PEM)\n",
79" -outform arg - output format - default PEM\n", 79" -outform arg - output format - default PEM\n",
80" -text - print out a text format version\n", 80" -text - print out a text format version\n",
81" -in arg - input file - default stdin\n", 81" -in arg - input file - default stdin\n",
@@ -85,21 +85,32 @@ static char *crl_usage[]={
85" -lastupdate - lastUpdate field\n", 85" -lastupdate - lastUpdate field\n",
86" -nextupdate - nextUpdate field\n", 86" -nextupdate - nextUpdate field\n",
87" -noout - no CRL output\n", 87" -noout - no CRL output\n",
88" -CAfile name - verify CRL using certificates in file \"name\"\n",
89" -CApath dir - verify CRL using certificates in \"dir\"\n",
88NULL 90NULL
89}; 91};
90 92
91static X509_CRL *load_crl(char *file, int format); 93static X509_CRL *load_crl(char *file, int format);
92static BIO *bio_out=NULL; 94static BIO *bio_out=NULL;
93 95
96int MAIN(int, char **);
97
94int MAIN(int argc, char **argv) 98int MAIN(int argc, char **argv)
95 { 99 {
96 X509_CRL *x=NULL; 100 X509_CRL *x=NULL;
101 char *CAfile = NULL, *CApath = NULL;
97 int ret=1,i,num,badops=0; 102 int ret=1,i,num,badops=0;
98 BIO *out=NULL; 103 BIO *out=NULL;
99 int informat,outformat; 104 int informat,outformat;
100 char *infile=NULL,*outfile=NULL; 105 char *infile=NULL,*outfile=NULL;
101 int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; 106 int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0;
102 char **pp,buf[256]; 107 char **pp,buf[256];
108 X509_STORE *store = NULL;
109 X509_STORE_CTX ctx;
110 X509_LOOKUP *lookup = NULL;
111 X509_OBJECT xobj;
112 EVP_PKEY *pkey;
113 int do_ver = 0;
103 114
104 apps_startup(); 115 apps_startup();
105 116
@@ -146,6 +157,20 @@ int MAIN(int argc, char **argv)
146 if (--argc < 1) goto bad; 157 if (--argc < 1) goto bad;
147 outfile= *(++argv); 158 outfile= *(++argv);
148 } 159 }
160 else if (strcmp(*argv,"-CApath") == 0)
161 {
162 if (--argc < 1) goto bad;
163 CApath = *(++argv);
164 do_ver = 1;
165 }
166 else if (strcmp(*argv,"-CAfile") == 0)
167 {
168 if (--argc < 1) goto bad;
169 CAfile = *(++argv);
170 do_ver = 1;
171 }
172 else if (strcmp(*argv,"-verify") == 0)
173 do_ver = 1;
149 else if (strcmp(*argv,"-text") == 0) 174 else if (strcmp(*argv,"-text") == 0)
150 text = 1; 175 text = 1;
151 else if (strcmp(*argv,"-hash") == 0) 176 else if (strcmp(*argv,"-hash") == 0)
@@ -177,36 +202,74 @@ bad:
177 } 202 }
178 203
179 ERR_load_crypto_strings(); 204 ERR_load_crypto_strings();
180 X509V3_add_standard_extensions();
181 x=load_crl(infile,informat); 205 x=load_crl(infile,informat);
182 if (x == NULL) { goto end; } 206 if (x == NULL) { goto end; }
183 207
208 if(do_ver) {
209 store = X509_STORE_new();
210 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
211 if (lookup == NULL) goto end;
212 if (!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM))
213 X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
214
215 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
216 if (lookup == NULL) goto end;
217 if (!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM))
218 X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
219 ERR_clear_error();
220
221 X509_STORE_CTX_init(&ctx, store, NULL, NULL);
222
223 i = X509_STORE_get_by_subject(&ctx, X509_LU_X509,
224 X509_CRL_get_issuer(x), &xobj);
225 if(i <= 0) {
226 BIO_printf(bio_err,
227 "Error getting CRL issuer certificate\n");
228 goto end;
229 }
230 pkey = X509_get_pubkey(xobj.data.x509);
231 X509_OBJECT_free_contents(&xobj);
232 if(!pkey) {
233 BIO_printf(bio_err,
234 "Error getting CRL issuer public key\n");
235 goto end;
236 }
237 i = X509_CRL_verify(x, pkey);
238 EVP_PKEY_free(pkey);
239 if(i < 0) goto end;
240 if(i == 0) BIO_printf(bio_err, "verify failure\n");
241 else BIO_printf(bio_err, "verify OK\n");
242 }
243
184 if (num) 244 if (num)
185 { 245 {
186 for (i=1; i<=num; i++) 246 for (i=1; i<=num; i++)
187 { 247 {
188 if (issuer == i) 248 if (issuer == i)
189 { 249 {
190 X509_NAME_oneline(x->crl->issuer,buf,256); 250 X509_NAME_oneline(X509_CRL_get_issuer(x),
251 buf,256);
191 BIO_printf(bio_out,"issuer= %s\n",buf); 252 BIO_printf(bio_out,"issuer= %s\n",buf);
192 } 253 }
193 254
194 if (hash == i) 255 if (hash == i)
195 { 256 {
196 BIO_printf(bio_out,"%08lx\n", 257 BIO_printf(bio_out,"%08lx\n",
197 X509_NAME_hash(x->crl->issuer)); 258 X509_NAME_hash(X509_CRL_get_issuer(x)));
198 } 259 }
199 if (lastupdate == i) 260 if (lastupdate == i)
200 { 261 {
201 BIO_printf(bio_out,"lastUpdate="); 262 BIO_printf(bio_out,"lastUpdate=");
202 ASN1_TIME_print(bio_out,x->crl->lastUpdate); 263 ASN1_TIME_print(bio_out,
264 X509_CRL_get_lastUpdate(x));
203 BIO_printf(bio_out,"\n"); 265 BIO_printf(bio_out,"\n");
204 } 266 }
205 if (nextupdate == i) 267 if (nextupdate == i)
206 { 268 {
207 BIO_printf(bio_out,"nextUpdate="); 269 BIO_printf(bio_out,"nextUpdate=");
208 if (x->crl->nextUpdate != NULL) 270 if (X509_CRL_get_nextUpdate(x))
209 ASN1_TIME_print(bio_out,x->crl->nextUpdate); 271 ASN1_TIME_print(bio_out,
272 X509_CRL_get_nextUpdate(x));
210 else 273 else
211 BIO_printf(bio_out,"NONE"); 274 BIO_printf(bio_out,"NONE");
212 BIO_printf(bio_out,"\n"); 275 BIO_printf(bio_out,"\n");
@@ -250,8 +313,12 @@ bad:
250end: 313end:
251 BIO_free(out); 314 BIO_free(out);
252 BIO_free(bio_out); 315 BIO_free(bio_out);
316 bio_out=NULL;
253 X509_CRL_free(x); 317 X509_CRL_free(x);
254 X509V3_EXT_cleanup(); 318 if(store) {
319 X509_STORE_CTX_cleanup(&ctx);
320 X509_STORE_free(store);
321 }
255 EXIT(ret); 322 EXIT(ret);
256 } 323 }
257 324
diff --git a/src/lib/libssl/src/apps/crl2p7.c b/src/lib/libssl/src/apps/crl2p7.c
index 8634e3a1ec..4056591676 100644
--- a/src/lib/libssl/src/apps/crl2p7.c
+++ b/src/lib/libssl/src/apps/crl2p7.c
@@ -76,12 +76,14 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
76#undef PROG 76#undef PROG
77#define PROG crl2pkcs7_main 77#define PROG crl2pkcs7_main
78 78
79/* -inform arg - input format - default PEM (one of DER, TXT or PEM) 79/* -inform arg - input format - default PEM (DER or PEM)
80 * -outform arg - output format - default PEM 80 * -outform arg - output format - default PEM
81 * -in arg - input file - default stdin 81 * -in arg - input file - default stdin
82 * -out arg - output file - default stdout 82 * -out arg - output file - default stdout
83 */ 83 */
84 84
85int MAIN(int, char **);
86
85int MAIN(int argc, char **argv) 87int MAIN(int argc, char **argv)
86 { 88 {
87 int i,badops=0; 89 int i,badops=0;
@@ -157,8 +159,8 @@ int MAIN(int argc, char **argv)
157bad: 159bad:
158 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog); 160 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
159 BIO_printf(bio_err,"where options are\n"); 161 BIO_printf(bio_err,"where options are\n");
160 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n"); 162 BIO_printf(bio_err," -inform arg input format - DER or PEM\n");
161 BIO_printf(bio_err," -outform arg output format - one of DER TXT PEM\n"); 163 BIO_printf(bio_err," -outform arg output format - DER or PEM\n");
162 BIO_printf(bio_err," -in arg input file\n"); 164 BIO_printf(bio_err," -in arg input file\n");
163 BIO_printf(bio_err," -out arg output file\n"); 165 BIO_printf(bio_err," -out arg output file\n");
164 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");
diff --git a/src/lib/libssl/src/apps/dgst.c b/src/lib/libssl/src/apps/dgst.c
index 5f0506ed8c..1b56d6ef44 100644
--- a/src/lib/libssl/src/apps/dgst.c
+++ b/src/lib/libssl/src/apps/dgst.c
@@ -74,6 +74,9 @@
74#define PROG dgst_main 74#define PROG dgst_main
75 75
76void do_fp(unsigned char *buf,BIO *f,int sep); 76void do_fp(unsigned char *buf,BIO *f,int sep);
77
78int MAIN(int, char **);
79
77int MAIN(int argc, char **argv) 80int MAIN(int argc, char **argv)
78 { 81 {
79 unsigned char *buf=NULL; 82 unsigned char *buf=NULL;
diff --git a/src/lib/libssl/src/apps/dh.c b/src/lib/libssl/src/apps/dh.c
index 9efdcd78a3..b3c20e2b5c 100644
--- a/src/lib/libssl/src/apps/dh.c
+++ b/src/lib/libssl/src/apps/dh.c
@@ -72,7 +72,7 @@
72#undef PROG 72#undef PROG
73#define PROG dh_main 73#define PROG dh_main
74 74
75/* -inform arg - input format - default PEM (one of DER, TXT or PEM) 75/* -inform arg - input format - default PEM (DER or PEM)
76 * -outform arg - output format - default PEM 76 * -outform arg - output format - default PEM
77 * -in arg - input file - default stdin 77 * -in arg - input file - default stdin
78 * -out arg - output file - default stdout 78 * -out arg - output file - default stdout
@@ -82,6 +82,8 @@
82 * -C 82 * -C
83 */ 83 */
84 84
85int MAIN(int, char **);
86
85int MAIN(int argc, char **argv) 87int MAIN(int argc, char **argv)
86 { 88 {
87 DH *dh=NULL; 89 DH *dh=NULL;
@@ -149,8 +151,8 @@ int MAIN(int argc, char **argv)
149bad: 151bad:
150 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog); 152 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
151 BIO_printf(bio_err,"where options are\n"); 153 BIO_printf(bio_err,"where options are\n");
152 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n"); 154 BIO_printf(bio_err," -inform arg input format - one of DER PEM\n");
153 BIO_printf(bio_err," -outform arg output format - one of DER TXT PEM\n"); 155 BIO_printf(bio_err," -outform arg output format - one of DER PEM\n");
154 BIO_printf(bio_err," -in arg input file\n"); 156 BIO_printf(bio_err," -in arg input file\n");
155 BIO_printf(bio_err," -out arg output file\n"); 157 BIO_printf(bio_err," -out arg output file\n");
156 BIO_printf(bio_err," -check check the DH parameters\n"); 158 BIO_printf(bio_err," -check check the DH parameters\n");
@@ -219,7 +221,7 @@ bad:
219 BN_print(stdout,dh->g); 221 BN_print(stdout,dh->g);
220 printf("\n"); 222 printf("\n");
221 if (dh->length != 0) 223 if (dh->length != 0)
222 printf("recomented private length=%ld\n",dh->length); 224 printf("recommended private length=%ld\n",dh->length);
223#endif 225#endif
224 } 226 }
225 227
@@ -282,6 +284,7 @@ bad:
282 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n"); 284 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
283 printf("\t\treturn(NULL);\n"); 285 printf("\t\treturn(NULL);\n");
284 printf("\treturn(dh);\n\t}\n"); 286 printf("\treturn(dh);\n\t}\n");
287 Free(data);
285 } 288 }
286 289
287 290
@@ -297,7 +300,7 @@ bad:
297 } 300 }
298 if (!i) 301 if (!i)
299 { 302 {
300 BIO_printf(bio_err,"unable to write DH paramaters\n"); 303 BIO_printf(bio_err,"unable to write DH parameters\n");
301 ERR_print_errors(bio_err); 304 ERR_print_errors(bio_err);
302 goto end; 305 goto end;
303 } 306 }
diff --git a/src/lib/libssl/src/apps/dhparam.c b/src/lib/libssl/src/apps/dhparam.c
new file mode 100644
index 0000000000..293a400d0c
--- /dev/null
+++ b/src/lib/libssl/src/apps/dhparam.c
@@ -0,0 +1,368 @@
1/* apps/dhparam.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_DH
60#include <stdio.h>
61#include <stdlib.h>
62#include <time.h>
63#include <string.h>
64#include "apps.h"
65#include <openssl/bio.h>
66#include <openssl/err.h>
67#include <openssl/bn.h>
68#include <openssl/dh.h>
69#include <openssl/x509.h>
70#include <openssl/pem.h>
71
72#undef PROG
73#define PROG dhparam_main
74
75#define DEFBITS 512
76
77/* -inform arg - input format - default PEM (DER or PEM)
78 * -outform arg - output format - default PEM
79 * -in arg - input file - default stdin
80 * -out arg - output file - default stdout
81 * -check - check the parameters are ok
82 * -noout
83 * -text
84 * -C
85 */
86
87static void MS_CALLBACK dh_cb(int p, int n, void *arg);
88
89int MAIN(int, char **);
90
91int MAIN(int argc, char **argv)
92 {
93 DH *dh=NULL;
94 int i,badops=0,text=0;
95 BIO *in=NULL,*out=NULL;
96 int informat,outformat,check=0,noout=0,C=0,ret=1;
97 char *infile,*outfile,*prog;
98 char *inrand=NULL;
99 int num = 0, g = 0;
100
101 apps_startup();
102
103 if (bio_err == NULL)
104 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
105 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
106
107 infile=NULL;
108 outfile=NULL;
109 informat=FORMAT_PEM;
110 outformat=FORMAT_PEM;
111
112 prog=argv[0];
113 argc--;
114 argv++;
115 while (argc >= 1)
116 {
117 if (strcmp(*argv,"-inform") == 0)
118 {
119 if (--argc < 1) goto bad;
120 informat=str2fmt(*(++argv));
121 }
122 else if (strcmp(*argv,"-outform") == 0)
123 {
124 if (--argc < 1) goto bad;
125 outformat=str2fmt(*(++argv));
126 }
127 else if (strcmp(*argv,"-in") == 0)
128 {
129 if (--argc < 1) goto bad;
130 infile= *(++argv);
131 }
132 else if (strcmp(*argv,"-out") == 0)
133 {
134 if (--argc < 1) goto bad;
135 outfile= *(++argv);
136 }
137 else if (strcmp(*argv,"-check") == 0)
138 check=1;
139 else if (strcmp(*argv,"-text") == 0)
140 text=1;
141 else if (strcmp(*argv,"-C") == 0)
142 C=1;
143 else if (strcmp(*argv,"-noout") == 0)
144 noout=1;
145 else if (strcmp(*argv,"-2") == 0)
146 g=2;
147 else if (strcmp(*argv,"-5") == 0)
148 g=5;
149 else if (strcmp(*argv,"-rand") == 0)
150 {
151 if (--argc < 1) goto bad;
152 inrand= *(++argv);
153 }
154 else if (((sscanf(*argv,"%d",&num) == 0) || (num <= 0)))
155 goto bad;
156 argv++;
157 argc--;
158 }
159
160 if (badops)
161 {
162bad:
163 BIO_printf(bio_err,"%s [options] [numbits]\n",prog);
164 BIO_printf(bio_err,"where options are\n");
165 BIO_printf(bio_err," -inform arg input format - one of DER PEM\n");
166 BIO_printf(bio_err," -outform arg output format - one of DER PEM\n");
167 BIO_printf(bio_err," -in arg input file\n");
168 BIO_printf(bio_err," -out arg output file\n");
169 BIO_printf(bio_err," -check check the DH parameters\n");
170 BIO_printf(bio_err," -text print a text form of the DH parameters\n");
171 BIO_printf(bio_err," -C Output C code\n");
172 BIO_printf(bio_err," -2 generate parameters using 2 as the generator value\n");
173 BIO_printf(bio_err," -5 generate parameters using 5 as the generator value\n");
174 BIO_printf(bio_err," numbits number of bits in to generate (default 512)\n");
175 BIO_printf(bio_err," -rand file:file:...\n");
176 BIO_printf(bio_err," - load the file (or the files in the directory) into\n");
177 BIO_printf(bio_err," the random number generator\n");
178 BIO_printf(bio_err," -noout no output\n");
179 goto end;
180 }
181
182 ERR_load_crypto_strings();
183
184 if(g && !num) num = DEFBITS;
185 else if(num && !g) g = 2;
186
187 if(num) {
188
189 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
190 {
191 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
192 }
193 if (inrand != NULL)
194 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
195 app_RAND_load_files(inrand));
196
197 BIO_printf(bio_err,"Generating DH parameters, %d bit long strong prime, generator of %d\n",num,g);
198 BIO_printf(bio_err,"This is going to take a long time\n");
199 dh=DH_generate_parameters(num,g,dh_cb,bio_err);
200
201 if (dh == NULL) goto end;
202
203 app_RAND_write_file(NULL, bio_err);
204 } else {
205
206 in=BIO_new(BIO_s_file());
207 if (in == NULL)
208 {
209 ERR_print_errors(bio_err);
210 goto end;
211 }
212 if (infile == NULL)
213 BIO_set_fp(in,stdin,BIO_NOCLOSE);
214 else
215 {
216 if (BIO_read_filename(in,infile) <= 0)
217 {
218 perror(infile);
219 goto end;
220 }
221 }
222
223 if (informat == FORMAT_ASN1)
224 dh=d2i_DHparams_bio(in,NULL);
225 else if (informat == FORMAT_PEM)
226 dh=PEM_read_bio_DHparams(in,NULL,NULL,NULL);
227 else
228 {
229 BIO_printf(bio_err,"bad input format specified\n");
230 goto end;
231 }
232 if (dh == NULL)
233 {
234 BIO_printf(bio_err,"unable to load DH parameters\n");
235 ERR_print_errors(bio_err);
236 goto end;
237 }
238
239 }
240
241 out=BIO_new(BIO_s_file());
242 if (out == NULL)
243 {
244 ERR_print_errors(bio_err);
245 goto end;
246 }
247 if (outfile == NULL)
248 BIO_set_fp(out,stdout,BIO_NOCLOSE);
249 else
250 {
251 if (BIO_write_filename(out,outfile) <= 0)
252 {
253 perror(outfile);
254 goto end;
255 }
256 }
257
258
259
260 if (text)
261 {
262 DHparams_print(out,dh);
263 }
264
265 if (check)
266 {
267 if (!DH_check(dh,&i))
268 {
269 ERR_print_errors(bio_err);
270 goto end;
271 }
272 if (i & DH_CHECK_P_NOT_PRIME)
273 printf("p value is not prime\n");
274 if (i & DH_CHECK_P_NOT_STRONG_PRIME)
275 printf("p value is not a strong prime\n");
276 if (i & DH_UNABLE_TO_CHECK_GENERATOR)
277 printf("unable to check the generator value\n");
278 if (i & DH_NOT_SUITABLE_GENERATOR)
279 printf("the g value is not a generator\n");
280 if (i == 0)
281 printf("DH parameters appear to be ok.\n");
282 }
283 if (C)
284 {
285 unsigned char *data;
286 int len,l,bits;
287
288 len=BN_num_bytes(dh->p);
289 bits=BN_num_bits(dh->p);
290 data=(unsigned char *)Malloc(len);
291 if (data == NULL)
292 {
293 perror("Malloc");
294 goto end;
295 }
296 l=BN_bn2bin(dh->p,data);
297 printf("static unsigned char dh%d_p[]={",bits);
298 for (i=0; i<l; i++)
299 {
300 if ((i%12) == 0) printf("\n\t");
301 printf("0x%02X,",data[i]);
302 }
303 printf("\n\t};\n");
304
305 l=BN_bn2bin(dh->g,data);
306 printf("static unsigned char dh%d_g[]={",bits);
307 for (i=0; i<l; i++)
308 {
309 if ((i%12) == 0) printf("\n\t");
310 printf("0x%02X,",data[i]);
311 }
312 printf("\n\t};\n\n");
313
314 printf("DH *get_dh%d()\n\t{\n",bits);
315 printf("\tDH *dh;\n\n");
316 printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
317 printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
318 bits,bits);
319 printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
320 bits,bits);
321 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
322 printf("\t\treturn(NULL);\n");
323 printf("\treturn(dh);\n\t}\n");
324 Free(data);
325 }
326
327
328 if (!noout)
329 {
330 if (outformat == FORMAT_ASN1)
331 i=i2d_DHparams_bio(out,dh);
332 else if (outformat == FORMAT_PEM)
333 i=PEM_write_bio_DHparams(out,dh);
334 else {
335 BIO_printf(bio_err,"bad output format specified for outfile\n");
336 goto end;
337 }
338 if (!i)
339 {
340 BIO_printf(bio_err,"unable to write DH parameters\n");
341 ERR_print_errors(bio_err);
342 goto end;
343 }
344 }
345 ret=0;
346end:
347 if (in != NULL) BIO_free(in);
348 if (out != NULL) BIO_free(out);
349 if (dh != NULL) DH_free(dh);
350 EXIT(ret);
351 }
352
353static void MS_CALLBACK dh_cb(int p, int n, void *arg)
354 {
355 char c='*';
356
357 if (p == 0) c='.';
358 if (p == 1) c='+';
359 if (p == 2) c='*';
360 if (p == 3) c='\n';
361 BIO_write((BIO *)arg,&c,1);
362 (void)BIO_flush((BIO *)arg);
363#ifdef LINT
364 p=n;
365#endif
366 }
367
368#endif
diff --git a/src/lib/libssl/src/apps/dsa.c b/src/lib/libssl/src/apps/dsa.c
index fedecf2739..4977671b8a 100644
--- a/src/lib/libssl/src/apps/dsa.c
+++ b/src/lib/libssl/src/apps/dsa.c
@@ -83,6 +83,8 @@
83 * -modulus - print the DSA public key 83 * -modulus - print the DSA public key
84 */ 84 */
85 85
86int MAIN(int, char **);
87
86int MAIN(int argc, char **argv) 88int MAIN(int argc, char **argv)
87 { 89 {
88 int ret=1; 90 int ret=1;
@@ -91,7 +93,10 @@ int MAIN(int argc, char **argv)
91 const EVP_CIPHER *enc=NULL; 93 const EVP_CIPHER *enc=NULL;
92 BIO *in=NULL,*out=NULL; 94 BIO *in=NULL,*out=NULL;
93 int informat,outformat,text=0,noout=0; 95 int informat,outformat,text=0,noout=0;
96 int pubin = 0, pubout = 0;
94 char *infile,*outfile,*prog; 97 char *infile,*outfile,*prog;
98 char *passargin = NULL, *passargout = NULL;
99 char *passin = NULL, *passout = NULL;
95 int modulus=0; 100 int modulus=0;
96 101
97 apps_startup(); 102 apps_startup();
@@ -130,12 +135,26 @@ int MAIN(int argc, char **argv)
130 if (--argc < 1) goto bad; 135 if (--argc < 1) goto bad;
131 outfile= *(++argv); 136 outfile= *(++argv);
132 } 137 }
138 else if (strcmp(*argv,"-passin") == 0)
139 {
140 if (--argc < 1) goto bad;
141 passargin= *(++argv);
142 }
143 else if (strcmp(*argv,"-passout") == 0)
144 {
145 if (--argc < 1) goto bad;
146 passargout= *(++argv);
147 }
133 else if (strcmp(*argv,"-noout") == 0) 148 else if (strcmp(*argv,"-noout") == 0)
134 noout=1; 149 noout=1;
135 else if (strcmp(*argv,"-text") == 0) 150 else if (strcmp(*argv,"-text") == 0)
136 text=1; 151 text=1;
137 else if (strcmp(*argv,"-modulus") == 0) 152 else if (strcmp(*argv,"-modulus") == 0)
138 modulus=1; 153 modulus=1;
154 else if (strcmp(*argv,"-pubin") == 0)
155 pubin=1;
156 else if (strcmp(*argv,"-pubout") == 0)
157 pubout=1;
139 else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL) 158 else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)
140 { 159 {
141 BIO_printf(bio_err,"unknown option %s\n",*argv); 160 BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -151,23 +170,30 @@ int MAIN(int argc, char **argv)
151bad: 170bad:
152 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog); 171 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
153 BIO_printf(bio_err,"where options are\n"); 172 BIO_printf(bio_err,"where options are\n");
154 BIO_printf(bio_err," -inform arg input format - one of DER NET PEM\n"); 173 BIO_printf(bio_err," -inform arg input format - DER or PEM\n");
155 BIO_printf(bio_err," -outform arg output format - one of DER NET PEM\n"); 174 BIO_printf(bio_err," -outform arg output format - DER or PEM\n");
156 BIO_printf(bio_err," -in arg input file\n"); 175 BIO_printf(bio_err," -in arg input file\n");
157 BIO_printf(bio_err," -out arg output file\n"); 176 BIO_printf(bio_err," -passin arg input file pass phrase source\n");
158 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 177 BIO_printf(bio_err," -out arg output file\n");
159 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 178 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
179 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n");
180 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
160#ifndef NO_IDEA 181#ifndef NO_IDEA
161 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n"); 182 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n");
162#endif 183#endif
163 BIO_printf(bio_err," -text print the key in text\n"); 184 BIO_printf(bio_err," -text print the key in text\n");
164 BIO_printf(bio_err," -noout don't print key out\n"); 185 BIO_printf(bio_err," -noout don't print key out\n");
165 BIO_printf(bio_err," -modulus print the DSA public value\n"); 186 BIO_printf(bio_err," -modulus print the DSA public value\n");
166 goto end; 187 goto end;
167 } 188 }
168 189
169 ERR_load_crypto_strings(); 190 ERR_load_crypto_strings();
170 191
192 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
193 BIO_printf(bio_err, "Error getting passwords\n");
194 goto end;
195 }
196
171 in=BIO_new(BIO_s_file()); 197 in=BIO_new(BIO_s_file());
172 out=BIO_new(BIO_s_file()); 198 out=BIO_new(BIO_s_file());
173 if ((in == NULL) || (out == NULL)) 199 if ((in == NULL) || (out == NULL))
@@ -187,19 +213,21 @@ bad:
187 } 213 }
188 } 214 }
189 215
190 BIO_printf(bio_err,"read DSA private key\n"); 216 BIO_printf(bio_err,"read DSA key\n");
191 if (informat == FORMAT_ASN1) 217 if (informat == FORMAT_ASN1) {
192 dsa=d2i_DSAPrivateKey_bio(in,NULL); 218 if(pubin) dsa=d2i_DSA_PUBKEY_bio(in,NULL);
193 else if (informat == FORMAT_PEM) 219 else dsa=d2i_DSAPrivateKey_bio(in,NULL);
194 dsa=PEM_read_bio_DSAPrivateKey(in,NULL,NULL,NULL); 220 } else if (informat == FORMAT_PEM) {
195 else 221 if(pubin) dsa=PEM_read_bio_DSA_PUBKEY(in,NULL, NULL, NULL);
222 else dsa=PEM_read_bio_DSAPrivateKey(in,NULL,NULL,passin);
223 } else
196 { 224 {
197 BIO_printf(bio_err,"bad input format specified for key\n"); 225 BIO_printf(bio_err,"bad input format specified for key\n");
198 goto end; 226 goto end;
199 } 227 }
200 if (dsa == NULL) 228 if (dsa == NULL)
201 { 229 {
202 BIO_printf(bio_err,"unable to load Private Key\n"); 230 BIO_printf(bio_err,"unable to load Key\n");
203 ERR_print_errors(bio_err); 231 ERR_print_errors(bio_err);
204 goto end; 232 goto end;
205 } 233 }
@@ -231,12 +259,16 @@ bad:
231 } 259 }
232 260
233 if (noout) goto end; 261 if (noout) goto end;
234 BIO_printf(bio_err,"writing DSA private key\n"); 262 BIO_printf(bio_err,"writing DSA key\n");
235 if (outformat == FORMAT_ASN1) 263 if (outformat == FORMAT_ASN1) {
236 i=i2d_DSAPrivateKey_bio(out,dsa); 264 if(pubin || pubout) i=i2d_DSA_PUBKEY_bio(out,dsa);
237 else if (outformat == FORMAT_PEM) 265 else i=i2d_DSAPrivateKey_bio(out,dsa);
238 i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL,NULL); 266 } else if (outformat == FORMAT_PEM) {
239 else { 267 if(pubin || pubout)
268 i=PEM_write_bio_DSA_PUBKEY(out,dsa);
269 else i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,
270 NULL,0,NULL, passout);
271 } else {
240 BIO_printf(bio_err,"bad output format specified for outfile\n"); 272 BIO_printf(bio_err,"bad output format specified for outfile\n");
241 goto end; 273 goto end;
242 } 274 }
@@ -248,9 +280,11 @@ bad:
248 else 280 else
249 ret=0; 281 ret=0;
250end: 282end:
251 if (in != NULL) BIO_free(in); 283 if(in != NULL) BIO_free(in);
252 if (out != NULL) BIO_free(out); 284 if(out != NULL) BIO_free(out);
253 if (dsa != NULL) DSA_free(dsa); 285 if(dsa != NULL) DSA_free(dsa);
286 if(passin) Free(passin);
287 if(passout) Free(passout);
254 EXIT(ret); 288 EXIT(ret);
255 } 289 }
256#endif 290#endif
diff --git a/src/lib/libssl/src/apps/dsaparam.c b/src/lib/libssl/src/apps/dsaparam.c
index fb8d471108..4d4e1ad2b5 100644
--- a/src/lib/libssl/src/apps/dsaparam.c
+++ b/src/lib/libssl/src/apps/dsaparam.c
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#ifndef NO_DSA 59#ifndef NO_DSA
60#include <assert.h>
60#include <stdio.h> 61#include <stdio.h>
61#include <stdlib.h> 62#include <stdlib.h>
62#include <time.h> 63#include <time.h>
@@ -65,7 +66,6 @@
65#include <openssl/bio.h> 66#include <openssl/bio.h>
66#include <openssl/err.h> 67#include <openssl/err.h>
67#include <openssl/bn.h> 68#include <openssl/bn.h>
68#include <openssl/rand.h>
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>
@@ -73,7 +73,7 @@
73#undef PROG 73#undef PROG
74#define PROG dsaparam_main 74#define PROG dsaparam_main
75 75
76/* -inform arg - input format - default PEM (one of DER, TXT or PEM) 76/* -inform arg - input format - default PEM (DER or PEM)
77 * -outform arg - output format - default PEM 77 * -outform arg - output format - default PEM
78 * -in arg - input file - default stdin 78 * -in arg - input file - default stdin
79 * -out arg - output file - default stdout 79 * -out arg - output file - default stdout
@@ -84,7 +84,10 @@
84 * -genkey 84 * -genkey
85 */ 85 */
86 86
87static void MS_CALLBACK dsa_cb(int p, int n, char *arg); 87static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
88
89int MAIN(int, char **);
90
88int MAIN(int argc, char **argv) 91int MAIN(int argc, char **argv)
89 { 92 {
90 DSA *dsa=NULL; 93 DSA *dsa=NULL;
@@ -93,7 +96,7 @@ int MAIN(int argc, char **argv)
93 int informat,outformat,noout=0,C=0,ret=1; 96 int informat,outformat,noout=0,C=0,ret=1;
94 char *infile,*outfile,*prog,*inrand=NULL; 97 char *infile,*outfile,*prog,*inrand=NULL;
95 int numbits= -1,num,genkey=0; 98 int numbits= -1,num,genkey=0;
96 char buffer[200],*randfile=NULL; 99 int need_rand=0;
97 100
98 apps_startup(); 101 apps_startup();
99 102
@@ -136,11 +139,15 @@ int MAIN(int argc, char **argv)
136 else if (strcmp(*argv,"-C") == 0) 139 else if (strcmp(*argv,"-C") == 0)
137 C=1; 140 C=1;
138 else if (strcmp(*argv,"-genkey") == 0) 141 else if (strcmp(*argv,"-genkey") == 0)
142 {
139 genkey=1; 143 genkey=1;
144 need_rand=1;
145 }
140 else if (strcmp(*argv,"-rand") == 0) 146 else if (strcmp(*argv,"-rand") == 0)
141 { 147 {
142 if (--argc < 1) goto bad; 148 if (--argc < 1) goto bad;
143 inrand= *(++argv); 149 inrand= *(++argv);
150 need_rand=1;
144 } 151 }
145 else if (strcmp(*argv,"-noout") == 0) 152 else if (strcmp(*argv,"-noout") == 0)
146 noout=1; 153 noout=1;
@@ -148,6 +155,7 @@ int MAIN(int argc, char **argv)
148 { 155 {
149 /* generate a key */ 156 /* generate a key */
150 numbits=num; 157 numbits=num;
158 need_rand=1;
151 } 159 }
152 else 160 else
153 { 161 {
@@ -164,11 +172,11 @@ int MAIN(int argc, char **argv)
164bad: 172bad:
165 BIO_printf(bio_err,"%s [options] [bits] <infile >outfile\n",prog); 173 BIO_printf(bio_err,"%s [options] [bits] <infile >outfile\n",prog);
166 BIO_printf(bio_err,"where options are\n"); 174 BIO_printf(bio_err,"where options are\n");
167 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n"); 175 BIO_printf(bio_err," -inform arg input format - DER or PEM\n");
168 BIO_printf(bio_err," -outform arg output format - one of DER TXT PEM\n"); 176 BIO_printf(bio_err," -outform arg output format - DER or PEM\n");
169 BIO_printf(bio_err," -in arg input file\n"); 177 BIO_printf(bio_err," -in arg input file\n");
170 BIO_printf(bio_err," -out arg output file\n"); 178 BIO_printf(bio_err," -out arg output file\n");
171 BIO_printf(bio_err," -text check the DSA parameters\n"); 179 BIO_printf(bio_err," -text print the key in text\n");
172 BIO_printf(bio_err," -C Output C code\n"); 180 BIO_printf(bio_err," -C Output C code\n");
173 BIO_printf(bio_err," -noout no output\n"); 181 BIO_printf(bio_err," -noout no output\n");
174 BIO_printf(bio_err," -rand files to use for random number input\n"); 182 BIO_printf(bio_err," -rand files to use for random number input\n");
@@ -207,15 +215,20 @@ bad:
207 } 215 }
208 } 216 }
209 217
210 if (numbits > 0) 218 if (need_rand)
211 { 219 {
212 randfile=RAND_file_name(buffer,200); 220 app_RAND_load_file(NULL, bio_err, (inrand != NULL));
213 RAND_load_file(randfile,1024L*1024L); 221 if (inrand != NULL)
222 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
223 app_RAND_load_files(inrand));
224 }
214 225
226 if (numbits > 0)
227 {
228 assert(need_rand);
215 BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num); 229 BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
216 BIO_printf(bio_err,"This could take some time\n"); 230 BIO_printf(bio_err,"This could take some time\n");
217 dsa=DSA_generate_parameters(num,NULL,0,NULL,NULL, 231 dsa=DSA_generate_parameters(num,NULL,0,NULL,NULL, dsa_cb,bio_err);
218 dsa_cb,(char *)bio_err);
219 } 232 }
220 else if (informat == FORMAT_ASN1) 233 else if (informat == FORMAT_ASN1)
221 dsa=d2i_DSAparams_bio(in,NULL); 234 dsa=d2i_DSAparams_bio(in,NULL);
@@ -307,7 +320,7 @@ bad:
307 } 320 }
308 if (!i) 321 if (!i)
309 { 322 {
310 BIO_printf(bio_err,"unable to write DSA paramaters\n"); 323 BIO_printf(bio_err,"unable to write DSA parameters\n");
311 ERR_print_errors(bio_err); 324 ERR_print_errors(bio_err);
312 goto end; 325 goto end;
313 } 326 }
@@ -316,6 +329,7 @@ bad:
316 { 329 {
317 DSA *dsakey; 330 DSA *dsakey;
318 331
332 assert(need_rand);
319 if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end; 333 if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end;
320 if (!DSA_generate_key(dsakey)) goto end; 334 if (!DSA_generate_key(dsakey)) goto end;
321 if (outformat == FORMAT_ASN1) 335 if (outformat == FORMAT_ASN1)
@@ -328,6 +342,8 @@ bad:
328 } 342 }
329 DSA_free(dsakey); 343 DSA_free(dsakey);
330 } 344 }
345 if (need_rand)
346 app_RAND_write_file(NULL, bio_err);
331 ret=0; 347 ret=0;
332end: 348end:
333 if (in != NULL) BIO_free(in); 349 if (in != NULL) BIO_free(in);
@@ -336,7 +352,7 @@ end:
336 EXIT(ret); 352 EXIT(ret);
337 } 353 }
338 354
339static void MS_CALLBACK dsa_cb(int p, int n, char *arg) 355static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
340 { 356 {
341 char c='*'; 357 char c='*';
342 358
@@ -344,8 +360,8 @@ static void MS_CALLBACK dsa_cb(int p, int n, char *arg)
344 if (p == 1) c='+'; 360 if (p == 1) c='+';
345 if (p == 2) c='*'; 361 if (p == 2) c='*';
346 if (p == 3) c='\n'; 362 if (p == 3) c='\n';
347 BIO_write((BIO *)arg,&c,1); 363 BIO_write(arg,&c,1);
348 (void)BIO_flush((BIO *)arg); 364 (void)BIO_flush(arg);
349#ifdef LINT 365#ifdef LINT
350 p=n; 366 p=n;
351#endif 367#endif
diff --git a/src/lib/libssl/src/apps/enc.c b/src/lib/libssl/src/apps/enc.c
index bce936a2fc..6531c58c54 100644
--- a/src/lib/libssl/src/apps/enc.c
+++ b/src/lib/libssl/src/apps/enc.c
@@ -65,6 +65,7 @@
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#include <openssl/rand.h>
68#ifndef NO_MD5 69#ifndef NO_MD5
69#include <openssl/md5.h> 70#include <openssl/md5.h>
70#endif 71#endif
@@ -79,17 +80,22 @@ int set_hex(char *in,unsigned char *out,int size);
79#define BSIZE (8*1024) 80#define BSIZE (8*1024)
80#define PROG enc_main 81#define PROG enc_main
81 82
83int MAIN(int, char **);
84
82int MAIN(int argc, char **argv) 85int MAIN(int argc, char **argv)
83 { 86 {
87 static const char magic[]="Salted__";
88 char mbuf[8]; /* should be 1 smaller than magic */
84 char *strbuf=NULL; 89 char *strbuf=NULL;
85 unsigned char *buff=NULL,*bufsize=NULL; 90 unsigned char *buff=NULL,*bufsize=NULL;
86 int bsize=BSIZE,verbose=0; 91 int bsize=BSIZE,verbose=0;
87 int ret=1,inl; 92 int ret=1,inl;
88 unsigned char key[24],iv[MD5_DIGEST_LENGTH]; 93 unsigned char key[24],iv[MD5_DIGEST_LENGTH];
89 char *str=NULL; 94 unsigned char salt[PKCS5_SALT_LEN];
90 char *hkey=NULL,*hiv=NULL; 95 char *str=NULL, *passarg = NULL, *pass = NULL;
96 char *hkey=NULL,*hiv=NULL,*hsalt = NULL;
91 int enc=1,printkey=0,i,base64=0; 97 int enc=1,printkey=0,i,base64=0;
92 int debug=0,olb64=0; 98 int debug=0,olb64=0,nosalt=0;
93 const EVP_CIPHER *cipher=NULL,*c; 99 const EVP_CIPHER *cipher=NULL,*c;
94 char *inf=NULL,*outf=NULL; 100 char *inf=NULL,*outf=NULL;
95 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL; 101 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
@@ -130,14 +136,22 @@ int MAIN(int argc, char **argv)
130 if (--argc < 1) goto bad; 136 if (--argc < 1) goto bad;
131 outf= *(++argv); 137 outf= *(++argv);
132 } 138 }
139 else if (strcmp(*argv,"-pass") == 0)
140 {
141 if (--argc < 1) goto bad;
142 passarg= *(++argv);
143 }
133 else if (strcmp(*argv,"-d") == 0) 144 else if (strcmp(*argv,"-d") == 0)
134 enc=0; 145 enc=0;
135 else if (strcmp(*argv,"-p") == 0) 146 else if (strcmp(*argv,"-p") == 0)
136 printkey=1; 147 printkey=1;
137 else if (strcmp(*argv,"-v") == 0) 148 else if (strcmp(*argv,"-v") == 0)
138 verbose=1; 149 verbose=1;
139 else if ((strcmp(*argv,"-debug") == 0) || 150 else if (strcmp(*argv,"-salt") == 0)
140 (strcmp(*argv,"-d") == 0)) 151 nosalt=0;
152 else if (strcmp(*argv,"-nosalt") == 0)
153 nosalt=1;
154 else if (strcmp(*argv,"-debug") == 0)
141 debug=1; 155 debug=1;
142 else if (strcmp(*argv,"-P") == 0) 156 else if (strcmp(*argv,"-P") == 0)
143 printkey=2; 157 printkey=2;
@@ -194,6 +208,11 @@ int MAIN(int argc, char **argv)
194 if (--argc < 1) goto bad; 208 if (--argc < 1) goto bad;
195 hkey= *(++argv); 209 hkey= *(++argv);
196 } 210 }
211 else if (strcmp(*argv,"-S") == 0)
212 {
213 if (--argc < 1) goto bad;
214 hsalt= *(++argv);
215 }
197 else if (strcmp(*argv,"-iv") == 0) 216 else if (strcmp(*argv,"-iv") == 0)
198 { 217 {
199 if (--argc < 1) goto bad; 218 if (--argc < 1) goto bad;
@@ -212,7 +231,8 @@ int MAIN(int argc, char **argv)
212bad: 231bad:
213 BIO_printf(bio_err,"options are\n"); 232 BIO_printf(bio_err,"options are\n");
214 BIO_printf(bio_err,"%-14s input file\n","-in <file>"); 233 BIO_printf(bio_err,"%-14s input file\n","-in <file>");
215 BIO_printf(bio_err,"%-14s output fileencrypt\n","-out <file>"); 234 BIO_printf(bio_err,"%-14s output file\n","-out <file>");
235 BIO_printf(bio_err,"%-14s pass phrase source\n","-pass <arg>");
216 BIO_printf(bio_err,"%-14s encrypt\n","-e"); 236 BIO_printf(bio_err,"%-14s encrypt\n","-e");
217 BIO_printf(bio_err,"%-14s decrypt\n","-d"); 237 BIO_printf(bio_err,"%-14s decrypt\n","-d");
218 BIO_printf(bio_err,"%-14s base64 encode/decode, depending on encryption flag\n","-a/-base64"); 238 BIO_printf(bio_err,"%-14s base64 encode/decode, depending on encryption flag\n","-a/-base64");
@@ -233,7 +253,7 @@ bad:
233 BIO_printf(bio_err,"rc2 :128 bit key RC2 encryption\n"); 253 BIO_printf(bio_err,"rc2 :128 bit key RC2 encryption\n");
234#endif 254#endif
235#ifndef NO_BF 255#ifndef NO_BF
236 BIO_printf(bio_err,"bf :128 bit key BlowFish encryption\n"); 256 BIO_printf(bio_err,"bf :128 bit key Blowfish encryption\n");
237#endif 257#endif
238#ifndef NO_RC4 258#ifndef NO_RC4
239 BIO_printf(bio_err," -%-5s :128 bit key RC4 encryption\n", 259 BIO_printf(bio_err," -%-5s :128 bit key RC4 encryption\n",
@@ -357,6 +377,14 @@ bad:
357 } 377 }
358 } 378 }
359 379
380 if(!str && passarg) {
381 if(!app_passwd(bio_err, passarg, NULL, &pass, NULL)) {
382 BIO_printf(bio_err, "Error getting password\n");
383 goto end;
384 }
385 str = pass;
386 }
387
360 if ((str == NULL) && (cipher != NULL) && (hkey == NULL)) 388 if ((str == NULL) && (cipher != NULL) && (hkey == NULL))
361 { 389 {
362 for (;;) 390 for (;;)
@@ -386,11 +414,83 @@ bad:
386 } 414 }
387 } 415 }
388 416
417
418 if (outf == NULL)
419 BIO_set_fp(out,stdout,BIO_NOCLOSE);
420 else
421 {
422 if (BIO_write_filename(out,outf) <= 0)
423 {
424 perror(outf);
425 goto end;
426 }
427 }
428
429 rbio=in;
430 wbio=out;
431
432 if (base64)
433 {
434 if ((b64=BIO_new(BIO_f_base64())) == NULL)
435 goto end;
436 if (debug)
437 {
438 BIO_set_callback(b64,BIO_debug_callback);
439 BIO_set_callback_arg(b64,bio_err);
440 }
441 if (olb64)
442 BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);
443 if (enc)
444 wbio=BIO_push(b64,wbio);
445 else
446 rbio=BIO_push(b64,rbio);
447 }
448
389 if (cipher != NULL) 449 if (cipher != NULL)
390 { 450 {
391 if (str != NULL) 451 if (str != NULL)
392 { 452 {
393 EVP_BytesToKey(cipher,EVP_md5(),NULL, 453 /* Salt handling: if encrypting generate a salt and
454 * write to output BIO. If decrypting read salt from
455 * input BIO.
456 */
457 unsigned char *sptr;
458 if(nosalt) sptr = NULL;
459 else {
460 if(enc) {
461 if(hsalt) {
462 if(!set_hex(hsalt,salt,PKCS5_SALT_LEN)) {
463 BIO_printf(bio_err,
464 "invalid hex salt value\n");
465 goto end;
466 }
467 } else if (RAND_pseudo_bytes(salt, PKCS5_SALT_LEN) < 0)
468 goto end;
469 /* If -P option then don't bother writing */
470 if((printkey != 2)
471 && (BIO_write(wbio,magic,
472 sizeof magic-1) != sizeof magic-1
473 || BIO_write(wbio,
474 (char *)salt,
475 PKCS5_SALT_LEN) != PKCS5_SALT_LEN)) {
476 BIO_printf(bio_err,"error writing output file\n");
477 goto end;
478 }
479 } else if(BIO_read(rbio,mbuf,sizeof mbuf) != sizeof mbuf
480 || BIO_read(rbio,
481 (unsigned char *)salt,
482 PKCS5_SALT_LEN) != PKCS5_SALT_LEN) {
483 BIO_printf(bio_err,"error reading input file\n");
484 goto end;
485 } else if(memcmp(mbuf,magic,sizeof magic-1)) {
486 BIO_printf(bio_err,"bad magic number\n");
487 goto end;
488 }
489
490 sptr = salt;
491 }
492
493 EVP_BytesToKey(cipher,EVP_md5(),sptr,
394 (unsigned char *)str, 494 (unsigned char *)str,
395 strlen(str),1,key,iv); 495 strlen(str),1,key,iv);
396 /* zero the complete buffer or the string 496 /* zero the complete buffer or the string
@@ -424,6 +524,13 @@ bad:
424 524
425 if (printkey) 525 if (printkey)
426 { 526 {
527 if (!nosalt)
528 {
529 printf("salt=");
530 for (i=0; i<PKCS5_SALT_LEN; i++)
531 printf("%02X",salt[i]);
532 printf("\n");
533 }
427 if (cipher->key_len > 0) 534 if (cipher->key_len > 0)
428 { 535 {
429 printf("key="); 536 printf("key=");
@@ -446,38 +553,6 @@ bad:
446 } 553 }
447 } 554 }
448 555
449
450 if (outf == NULL)
451 BIO_set_fp(out,stdout,BIO_NOCLOSE);
452 else
453 {
454 if (BIO_write_filename(out,outf) <= 0)
455 {
456 perror(outf);
457 goto end;
458 }
459 }
460
461 rbio=in;
462 wbio=out;
463
464 if (base64)
465 {
466 if ((b64=BIO_new(BIO_f_base64())) == NULL)
467 goto end;
468 if (debug)
469 {
470 BIO_set_callback(b64,BIO_debug_callback);
471 BIO_set_callback_arg(b64,bio_err);
472 }
473 if (olb64)
474 BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);
475 if (enc)
476 wbio=BIO_push(b64,wbio);
477 else
478 rbio=BIO_push(b64,rbio);
479 }
480
481 /* Only encrypt/decrypt as we write the file */ 556 /* Only encrypt/decrypt as we write the file */
482 if (benc != NULL) 557 if (benc != NULL)
483 wbio=BIO_push(benc,wbio); 558 wbio=BIO_push(benc,wbio);
@@ -505,12 +580,14 @@ bad:
505 BIO_printf(bio_err,"bytes written:%8ld\n",BIO_number_written(out)); 580 BIO_printf(bio_err,"bytes written:%8ld\n",BIO_number_written(out));
506 } 581 }
507end: 582end:
583 ERR_print_errors(bio_err);
508 if (strbuf != NULL) Free(strbuf); 584 if (strbuf != NULL) Free(strbuf);
509 if (buff != NULL) Free(buff); 585 if (buff != NULL) Free(buff);
510 if (in != NULL) BIO_free(in); 586 if (in != NULL) BIO_free(in);
511 if (out != NULL) BIO_free(out); 587 if (out != NULL) BIO_free(out);
512 if (benc != NULL) BIO_free(benc); 588 if (benc != NULL) BIO_free(benc);
513 if (b64 != NULL) BIO_free(b64); 589 if (b64 != NULL) BIO_free(b64);
590 if(pass) Free(pass);
514 EXIT(ret); 591 EXIT(ret);
515 } 592 }
516 593
diff --git a/src/lib/libssl/src/apps/errstr.c b/src/lib/libssl/src/apps/errstr.c
index c86b5d940b..4650379589 100644
--- a/src/lib/libssl/src/apps/errstr.c
+++ b/src/lib/libssl/src/apps/errstr.c
@@ -68,6 +68,8 @@
68#undef PROG 68#undef PROG
69#define PROG errstr_main 69#define PROG errstr_main
70 70
71int MAIN(int, char **);
72
71int MAIN(int argc, char **argv) 73int MAIN(int argc, char **argv)
72 { 74 {
73 int i,ret=0; 75 int i,ret=0;
diff --git a/src/lib/libssl/src/apps/gendh.c b/src/lib/libssl/src/apps/gendh.c
index 3d50948580..1f6be96599 100644
--- a/src/lib/libssl/src/apps/gendh.c
+++ b/src/lib/libssl/src/apps/gendh.c
@@ -75,15 +75,16 @@
75#define PROG gendh_main 75#define PROG gendh_main
76 76
77static void MS_CALLBACK dh_cb(int p, int n, void *arg); 77static void MS_CALLBACK dh_cb(int p, int n, void *arg);
78static long dh_load_rand(char *names); 78
79int MAIN(int, char **);
80
79int MAIN(int argc, char **argv) 81int MAIN(int argc, char **argv)
80 { 82 {
81 char buffer[200];
82 DH *dh=NULL; 83 DH *dh=NULL;
83 int ret=1,num=DEFBITS; 84 int ret=1,num=DEFBITS;
84 int g=2; 85 int g=2;
85 char *outfile=NULL; 86 char *outfile=NULL;
86 char *inrand=NULL,*randfile; 87 char *inrand=NULL;
87 BIO *out=NULL; 88 BIO *out=NULL;
88 89
89 apps_startup(); 90 apps_startup();
@@ -150,17 +151,13 @@ bad:
150 } 151 }
151 } 152 }
152 153
153 randfile=RAND_file_name(buffer,200); 154 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
154 if ((randfile == NULL)|| !RAND_load_file(randfile,1024L*1024L))
155 BIO_printf(bio_err,"unable to load 'random state'\n");
156
157 if (inrand == NULL)
158 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
159 else
160 { 155 {
161 BIO_printf(bio_err,"%ld semi-random bytes loaded\n", 156 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
162 dh_load_rand(inrand));
163 } 157 }
158 if (inrand != NULL)
159 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
160 app_RAND_load_files(inrand));
164 161
165 BIO_printf(bio_err,"Generating DH parameters, %d bit long strong prime, generator of %d\n",num,g); 162 BIO_printf(bio_err,"Generating DH parameters, %d bit long strong prime, generator of %d\n",num,g);
166 BIO_printf(bio_err,"This is going to take a long time\n"); 163 BIO_printf(bio_err,"This is going to take a long time\n");
@@ -168,10 +165,7 @@ bad:
168 165
169 if (dh == NULL) goto end; 166 if (dh == NULL) goto end;
170 167
171 if (randfile == NULL) 168 app_RAND_write_file(NULL, bio_err);
172 BIO_printf(bio_err,"unable to write 'random state'\n");
173 else
174 RAND_write_file(randfile);
175 169
176 if (!PEM_write_bio_DHparams(out,dh)) 170 if (!PEM_write_bio_DHparams(out,dh))
177 goto end; 171 goto end;
@@ -198,26 +192,4 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
198 p=n; 192 p=n;
199#endif 193#endif
200 } 194 }
201
202static long dh_load_rand(char *name)
203 {
204 char *p,*n;
205 int last;
206 long tot=0;
207
208 for (;;)
209 {
210 last=0;
211 for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
212 if (*p == '\0') last=1;
213 *p='\0';
214 n=name;
215 name=p+1;
216 if (*n == '\0') break;
217
218 tot+=RAND_load_file(n,1);
219 if (last) break;
220 }
221 return(tot);
222 }
223#endif 195#endif
diff --git a/src/lib/libssl/src/apps/gendsa.c b/src/lib/libssl/src/apps/gendsa.c
index 5f00b89bb0..d69a93da45 100644
--- a/src/lib/libssl/src/apps/gendsa.c
+++ b/src/lib/libssl/src/apps/gendsa.c
@@ -63,7 +63,6 @@
63#include <sys/stat.h> 63#include <sys/stat.h>
64#include "apps.h" 64#include "apps.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66#include <openssl/rand.h>
67#include <openssl/err.h> 66#include <openssl/err.h>
68#include <openssl/bn.h> 67#include <openssl/bn.h>
69#include <openssl/dsa.h> 68#include <openssl/dsa.h>
@@ -74,14 +73,15 @@
74#undef PROG 73#undef PROG
75#define PROG gendsa_main 74#define PROG gendsa_main
76 75
77static long dsa_load_rand(char *names); 76int MAIN(int, char **);
77
78int MAIN(int argc, char **argv) 78int MAIN(int argc, char **argv)
79 { 79 {
80 char buffer[200];
81 DSA *dsa=NULL; 80 DSA *dsa=NULL;
82 int ret=1; 81 int ret=1;
83 char *outfile=NULL; 82 char *outfile=NULL;
84 char *inrand=NULL,*randfile,*dsaparams=NULL; 83 char *inrand=NULL,*dsaparams=NULL;
84 char *passargout = NULL, *passout = NULL;
85 BIO *out=NULL,*in=NULL; 85 BIO *out=NULL,*in=NULL;
86 EVP_CIPHER *enc=NULL; 86 EVP_CIPHER *enc=NULL;
87 87
@@ -101,6 +101,11 @@ int MAIN(int argc, char **argv)
101 if (--argc < 1) goto bad; 101 if (--argc < 1) goto bad;
102 outfile= *(++argv); 102 outfile= *(++argv);
103 } 103 }
104 else if (strcmp(*argv,"-passout") == 0)
105 {
106 if (--argc < 1) goto bad;
107 passargout= *(++argv);
108 }
104 else if (strcmp(*argv,"-rand") == 0) 109 else if (strcmp(*argv,"-rand") == 0)
105 { 110 {
106 if (--argc < 1) goto bad; 111 if (--argc < 1) goto bad;
@@ -148,6 +153,12 @@ bad:
148 goto end; 153 goto end;
149 } 154 }
150 155
156 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
157 BIO_printf(bio_err, "Error getting password\n");
158 goto end;
159 }
160
161
151 in=BIO_new(BIO_s_file()); 162 in=BIO_new(BIO_s_file());
152 if (!(BIO_read_filename(in,dsaparams))) 163 if (!(BIO_read_filename(in,dsaparams)))
153 { 164 {
@@ -161,6 +172,7 @@ bad:
161 goto end; 172 goto end;
162 } 173 }
163 BIO_free(in); 174 BIO_free(in);
175 in = NULL;
164 176
165 out=BIO_new(BIO_s_file()); 177 out=BIO_new(BIO_s_file());
166 if (out == NULL) goto end; 178 if (out == NULL) goto end;
@@ -176,57 +188,30 @@ bad:
176 } 188 }
177 } 189 }
178 190
179 randfile=RAND_file_name(buffer,200); 191 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
180 if ((randfile == NULL)|| !RAND_load_file(randfile,1024L*1024L))
181 BIO_printf(bio_err,"unable to load 'random state'\n");
182
183 if (inrand == NULL)
184 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
185 else
186 { 192 {
187 BIO_printf(bio_err,"%ld semi-random bytes loaded\n", 193 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
188 dsa_load_rand(inrand));
189 } 194 }
195 if (inrand != NULL)
196 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
197 app_RAND_load_files(inrand));
190 198
191 BIO_printf(bio_err,"Generating DSA key, %d bits\n", 199 BIO_printf(bio_err,"Generating DSA key, %d bits\n",
192 BN_num_bits(dsa->p)); 200 BN_num_bits(dsa->p));
193 if (!DSA_generate_key(dsa)) goto end; 201 if (!DSA_generate_key(dsa)) goto end;
194 202
195 if (randfile == NULL) 203 app_RAND_write_file(NULL, bio_err);
196 BIO_printf(bio_err,"unable to write 'random state'\n");
197 else
198 RAND_write_file(randfile);
199 204
200 if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL,NULL)) 205 if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL, passout))
201 goto end; 206 goto end;
202 ret=0; 207 ret=0;
203end: 208end:
204 if (ret != 0) 209 if (ret != 0)
205 ERR_print_errors(bio_err); 210 ERR_print_errors(bio_err);
211 if (in != NULL) BIO_free(in);
206 if (out != NULL) BIO_free(out); 212 if (out != NULL) BIO_free(out);
207 if (dsa != NULL) DSA_free(dsa); 213 if (dsa != NULL) DSA_free(dsa);
214 if(passout) Free(passout);
208 EXIT(ret); 215 EXIT(ret);
209 } 216 }
210
211static long dsa_load_rand(char *name)
212 {
213 char *p,*n;
214 int last;
215 long tot=0;
216
217 for (;;)
218 {
219 last=0;
220 for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
221 if (*p == '\0') last=1;
222 *p='\0';
223 n=name;
224 name=p+1;
225 if (*n == '\0') break;
226
227 tot+=RAND_load_file(n,1);
228 if (last) break;
229 }
230 return(tot);
231 }
232#endif 217#endif
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c
index 67382065fb..dc63ff02bd 100644
--- a/src/lib/libssl/src/apps/genrsa.c
+++ b/src/lib/libssl/src/apps/genrsa.c
@@ -63,7 +63,6 @@
63#include <sys/stat.h> 63#include <sys/stat.h>
64#include "apps.h" 64#include "apps.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66#include <openssl/rand.h>
67#include <openssl/err.h> 66#include <openssl/err.h>
68#include <openssl/bn.h> 67#include <openssl/bn.h>
69#include <openssl/rsa.h> 68#include <openssl/rsa.h>
@@ -76,18 +75,20 @@
76#define PROG genrsa_main 75#define PROG genrsa_main
77 76
78static void MS_CALLBACK genrsa_cb(int p, int n, void *arg); 77static void MS_CALLBACK genrsa_cb(int p, int n, void *arg);
79static long gr_load_rand(char *names); 78
79int MAIN(int, char **);
80
80int MAIN(int argc, char **argv) 81int MAIN(int argc, char **argv)
81 { 82 {
82 int ret=1; 83 int ret=1;
83 char buffer[200];
84 RSA *rsa=NULL; 84 RSA *rsa=NULL;
85 int i,num=DEFBITS; 85 int i,num=DEFBITS;
86 long rnum=0,l; 86 long l;
87 EVP_CIPHER *enc=NULL; 87 EVP_CIPHER *enc=NULL;
88 unsigned long f4=RSA_F4; 88 unsigned long f4=RSA_F4;
89 char *outfile=NULL; 89 char *outfile=NULL;
90 char *inrand=NULL,*randfile; 90 char *passargout = NULL, *passout = NULL;
91 char *inrand=NULL;
91 BIO *out=NULL; 92 BIO *out=NULL;
92 93
93 apps_startup(); 94 apps_startup();
@@ -97,7 +98,7 @@ int MAIN(int argc, char **argv)
97 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 98 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
98 if ((out=BIO_new(BIO_s_file())) == NULL) 99 if ((out=BIO_new(BIO_s_file())) == NULL)
99 { 100 {
100 BIO_printf(bio_err,"unable to creat BIO for output\n"); 101 BIO_printf(bio_err,"unable to create BIO for output\n");
101 goto err; 102 goto err;
102 } 103 }
103 104
@@ -130,6 +131,11 @@ int MAIN(int argc, char **argv)
130 else if (strcmp(*argv,"-idea") == 0) 131 else if (strcmp(*argv,"-idea") == 0)
131 enc=EVP_idea_cbc(); 132 enc=EVP_idea_cbc();
132#endif 133#endif
134 else if (strcmp(*argv,"-passout") == 0)
135 {
136 if (--argc < 1) goto bad;
137 passargout= *(++argv);
138 }
133 else 139 else
134 break; 140 break;
135 argv++; 141 argv++;
@@ -139,21 +145,28 @@ int MAIN(int argc, char **argv)
139 { 145 {
140bad: 146bad:
141 BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n"); 147 BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n");
142 BIO_printf(bio_err," -des - encrypt the generated key with DES in cbc mode\n"); 148 BIO_printf(bio_err," -des encrypt the generated key with DES in cbc mode\n");
143 BIO_printf(bio_err," -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); 149 BIO_printf(bio_err," -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
144#ifndef NO_IDEA 150#ifndef NO_IDEA
145 BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n"); 151 BIO_printf(bio_err," -idea encrypt the generated key with IDEA in cbc mode\n");
146#endif 152#endif
147 BIO_printf(bio_err," -out file - output the key to 'file\n"); 153 BIO_printf(bio_err," -out file output the key to 'file\n");
148 BIO_printf(bio_err," -f4 - use F4 (0x10001) for the E value\n"); 154 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
149 BIO_printf(bio_err," -3 - use 3 for the E value\n"); 155 BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n");
156 BIO_printf(bio_err," -3 use 3 for the E value\n");
150 BIO_printf(bio_err," -rand file:file:...\n"); 157 BIO_printf(bio_err," -rand file:file:...\n");
151 BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); 158 BIO_printf(bio_err," load the file (or the files in the directory) into\n");
152 BIO_printf(bio_err," the random number generator\n"); 159 BIO_printf(bio_err," the random number generator\n");
153 goto err; 160 goto err;
154 } 161 }
155 162
156 ERR_load_crypto_strings(); 163 ERR_load_crypto_strings();
164
165 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
166 BIO_printf(bio_err, "Error getting password\n");
167 goto err;
168 }
169
157 if (outfile == NULL) 170 if (outfile == NULL)
158 BIO_set_fp(out,stdout,BIO_NOCLOSE); 171 BIO_set_fp(out,stdout,BIO_NOCLOSE);
159 else 172 else
@@ -165,45 +178,23 @@ bad:
165 } 178 }
166 } 179 }
167 180
168#ifdef WINDOWS 181 if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
169 BIO_printf(bio_err,"Loading 'screen' into random state -");
170 BIO_flush(bio_err);
171 RAND_screen();
172 BIO_printf(bio_err," done\n");
173#endif
174 randfile=RAND_file_name(buffer,200);
175 if ((randfile == NULL) ||
176 !(rnum=(long)RAND_load_file(randfile,1024L*1024L)))
177 { 182 {
178 BIO_printf(bio_err,"unable to load 'random state'\n"); 183 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
179 } 184 }
180 185 if (inrand != NULL)
181 if (inrand == NULL) 186 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
182 { 187 app_RAND_load_files(inrand));
183 if (rnum == 0)
184 {
185 BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
186 }
187 }
188 else
189 {
190 rnum+=gr_load_rand(inrand);
191 }
192 if (rnum != 0)
193 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",rnum);
194 188
195 BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n", 189 BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
196 num); 190 num);
197 rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err); 191 rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err);
198 192
199 if (randfile == NULL) 193 app_RAND_write_file(NULL, bio_err);
200 BIO_printf(bio_err,"unable to write 'random state'\n");
201 else
202 RAND_write_file(randfile);
203 194
204 if (rsa == NULL) goto err; 195 if (rsa == NULL) goto err;
205 196
206 /* We need to do the folloing for when the base number size is < 197 /* We need to do the following for when the base number size is <
207 * long, esp windows 3.1 :-(. */ 198 * long, esp windows 3.1 :-(. */
208 l=0L; 199 l=0L;
209 for (i=0; i<rsa->e->top; i++) 200 for (i=0; i<rsa->e->top; i++)
@@ -215,13 +206,14 @@ bad:
215 l+=rsa->e->d[i]; 206 l+=rsa->e->d[i];
216 } 207 }
217 BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l); 208 BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l);
218 if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL,NULL)) 209 if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL, passout))
219 goto err; 210 goto err;
220 211
221 ret=0; 212 ret=0;
222err: 213err:
223 if (rsa != NULL) RSA_free(rsa); 214 if (rsa != NULL) RSA_free(rsa);
224 if (out != NULL) BIO_free(out); 215 if (out != NULL) BIO_free(out);
216 if(passout) Free(passout);
225 if (ret != 0) 217 if (ret != 0)
226 ERR_print_errors(bio_err); 218 ERR_print_errors(bio_err);
227 EXIT(ret); 219 EXIT(ret);
@@ -241,26 +233,10 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
241 p=n; 233 p=n;
242#endif 234#endif
243 } 235 }
236#else /* !NO_RSA */
244 237
245static long gr_load_rand(char *name) 238# if PEDANTIC
246 { 239static void *dummy=&dummy;
247 char *p,*n; 240# endif
248 int last;
249 long tot=0;
250
251 for (;;)
252 {
253 last=0;
254 for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
255 if (*p == '\0') last=1;
256 *p='\0';
257 n=name;
258 name=p+1;
259 if (*n == '\0') break;
260 241
261 tot+=RAND_load_file(n,1024L*1024L);
262 if (last) break;
263 }
264 return(tot);
265 }
266#endif 242#endif
diff --git a/src/lib/libssl/src/apps/makeapps.com b/src/lib/libssl/src/apps/makeapps.com
index 8a15a130ed..5ef6a8904e 100644
--- a/src/lib/libssl/src/apps/makeapps.com
+++ b/src/lib/libssl/src/apps/makeapps.com
@@ -79,7 +79,7 @@ $!
79$! Define what programs should be compiled 79$! Define what programs should be compiled
80$! 80$!
81$ PROGRAMS := OPENSSL 81$ PROGRAMS := OPENSSL
82$!$ PROGRAMS := VERIFY,ASN1PARS,REQ,DGST,DH,ENC,GENDH,ERRSTR,CA,CRL,- 82$!$ PROGRAMS := VERIFY,ASN1PARS,REQ,DGST,DH,ENC,PASSWD,GENDH,ERRSTR,CA,CRL,-
83$! RSA,DSA,DSAPARAM,- 83$! RSA,DSA,DSAPARAM,-
84$! X509,GENRSA,GENDSA,S_SERVER,S_CLIENT,SPEED,- 84$! X509,GENRSA,GENDSA,S_SERVER,S_CLIENT,SPEED,-
85$! S_TIME,VERSION,PKCS7,CRL2P7,SESS_ID,CIPHERS,NSEQ, 85$! S_TIME,VERSION,PKCS7,CRL2P7,SESS_ID,CIPHERS,NSEQ,
@@ -152,20 +152,18 @@ $ GOSUB CHECK_OPT_FILE
152$! 152$!
153$! Define The Application Files. 153$! Define The Application Files.
154$! 154$!
155$ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;ENC;GENDH;"+- 155$ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;DHPARAM;ENC;PASSWD;GENDH;ERRSTR;"+-
156 "ERRSTR;CA;"+- 156 "CA;PKCS7;CRL2P7;CRL;"+-
157 "PKCS7;CRL2P7;CRL;"+-
158 "RSA;DSA;DSAPARAM;"+- 157 "R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BJ,PKCS12.OBJ,PKCS8.OBJ,SPKAC.OBJ,SMIME.OBJ
169$ TCPIP_PROGRAMS = ",," 167$ TCPIP_PROGRAMS = ",,"
170$ IF COMPILER .EQS. "VAXC" THEN - 168$ IF COMPILER .EQS. "VAXC" THEN -
171 TCPIP_PROGRAMS = ",OPENSSL," 169 TCPIP_PROGRAMS = ",OPENSSL,"
@@ -808,12 +806,36 @@ $!
808$! Set Up Initial CC Definitions, Possibly With User Ones 806$! Set Up Initial CC Definitions, Possibly With User Ones
809$! 807$!
810$ CCDEFS = "VMS=1,MONOLITH" 808$ CCDEFS = "VMS=1,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"
811$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 833$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
812$ CCEXTRAFLAGS = "" 834$ CCEXTRAFLAGS = ""
813$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 835$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
814$ CCDISABLEWARNINGS = "" 836$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
815$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - 837$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
816 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS 838 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
817$! 839$!
818$! Check To See If The User Entered A Valid Paramter. 840$! Check To See If The User Entered A Valid Paramter.
819$! 841$!
diff --git a/src/lib/libssl/src/apps/nseq.c b/src/lib/libssl/src/apps/nseq.c
index d9d01659e7..cc88d50ceb 100644
--- a/src/lib/libssl/src/apps/nseq.c
+++ b/src/lib/libssl/src/apps/nseq.c
@@ -65,7 +65,7 @@
65#undef PROG 65#undef PROG
66#define PROG nseq_main 66#define PROG nseq_main
67 67
68static int dump_cert_text(BIO *out, X509 *x); 68int MAIN(int, char **);
69 69
70int MAIN(int argc, char **argv) 70int MAIN(int argc, char **argv)
71{ 71{
@@ -158,17 +158,3 @@ end:
158 EXIT(ret); 158 EXIT(ret);
159} 159}
160 160
161static int dump_cert_text(BIO *out, X509 *x)
162{
163 char buf[256];
164 X509_NAME_oneline(X509_get_subject_name(x),buf,256);
165 BIO_puts(out,"subject=");
166 BIO_puts(out,buf);
167
168 X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
169 BIO_puts(out,"\nissuer= ");
170 BIO_puts(out,buf);
171 BIO_puts(out,"\n");
172 return 0;
173}
174
diff --git a/src/lib/libssl/src/apps/openssl-vms.cnf b/src/lib/libssl/src/apps/openssl-vms.cnf
index 13d10f21ed..d4498713fa 100644
--- a/src/lib/libssl/src/apps/openssl-vms.cnf
+++ b/src/lib/libssl/src/apps/openssl-vms.cnf
@@ -86,6 +86,19 @@ distinguished_name = req_distinguished_name
86attributes = req_attributes 86attributes = req_attributes
87x509_extensions = v3_ca # The extentions to add to the self signed cert 87x509_extensions = v3_ca # The extentions to add to the self signed cert
88 88
89# This sets the permitted types in a DirectoryString. There are several
90# options.
91# default: PrintableString, T61String, BMPString.
92# pkix : PrintableString, BMPString.
93# utf8only: only UTF8Strings.
94# nobmp : PrintableString, T61String (no BMPStrings).
95# MASK:XXXX a literal mask value.
96# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
97# so use this option with caution!
98dirstring_type = nobmp
99
100# req_extensions = v3_req # The extensions to add to a certificate request
101
89[ req_distinguished_name ] 102[ req_distinguished_name ]
90countryName = Country Name (2 letter code) 103countryName = Country Name (2 letter code)
91countryName_default = AU 104countryName_default = AU
@@ -170,7 +183,15 @@ authorityKeyIdentifier=keyid,issuer:always
170#nsCaPolicyUrl 183#nsCaPolicyUrl
171#nsSslServerName 184#nsSslServerName
172 185
173[ v3_ca] 186[ v3_req ]
187
188# Extensions to add to a certificate request
189
190basicConstraints = CA:FALSE
191keyUsage = nonRepudiation, digitalSignature, keyEncipherment
192
193[ v3_ca ]
194
174 195
175# Extensions for a typical CA 196# Extensions for a typical CA
176 197
@@ -200,10 +221,11 @@ basicConstraints = CA:true
200# Copy issuer details 221# Copy issuer details
201# issuerAltName=issuer:copy 222# issuerAltName=issuer:copy
202 223
203# RAW DER hex encoding of an extension: beware experts only! 224# DER hex encoding of an extension: beware experts only!
204# 1.2.3.5=RAW:02:03 225# obj=DER:02:03
226# Where 'obj' is a standard or added object
205# You can even override a supported extension: 227# You can even override a supported extension:
206# basicConstraints= critical, RAW:30:03:01:01:FF 228# basicConstraints= critical, DER:30:03:01:01:FF
207 229
208[ crl_ext ] 230[ crl_ext ]
209 231
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 9a337fb316..748c6ce71a 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -70,10 +70,10 @@
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71#include <openssl/pem.h> 71#include <openssl/pem.h>
72#include <openssl/ssl.h> 72#include <openssl/ssl.h>
73#define SSLEAY /* turn off a few special case MONOLITH macros */
74#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ 73#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
75#define SSLEAY_SRC 74#define OPENSSL_C /* tells apps.h to use complete apps_startup() */
76#include "apps.h" 75#include "apps.h"
76#include "progs.h"
77#include "s_apps.h" 77#include "s_apps.h"
78#include <openssl/err.h> 78#include <openssl/err.h>
79 79
@@ -120,9 +120,6 @@ int main(int Argc, char *Argv[])
120 arg.data=NULL; 120 arg.data=NULL;
121 arg.count=0; 121 arg.count=0;
122 122
123 /* SSLeay_add_ssl_algorithms(); is called in apps_startup() */
124 apps_startup();
125
126#if defined(DEBUG) && !defined(WINDOWS) && !defined(MSDOS) 123#if defined(DEBUG) && !defined(WINDOWS) && !defined(MSDOS)
127#ifdef SIGBUS 124#ifdef SIGBUS
128 signal(SIGBUS,sig_stop); 125 signal(SIGBUS,sig_stop);
@@ -132,12 +129,14 @@ int main(int Argc, char *Argv[])
132#endif 129#endif
133#endif 130#endif
134 131
132 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
133
134 apps_startup();
135
135 if (bio_err == NULL) 136 if (bio_err == NULL)
136 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 137 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
137 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 138 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
138 139
139 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
140
141 ERR_load_crypto_strings(); 140 ERR_load_crypto_strings();
142 141
143 /* Lets load up our environment a little */ 142 /* Lets load up our environment a little */
@@ -165,7 +164,7 @@ int main(int Argc, char *Argv[])
165 program_name(Argv[0],pname,PROG_NAME_SIZE); 164 program_name(Argv[0],pname,PROG_NAME_SIZE);
166 165
167 f.name=pname; 166 f.name=pname;
168 fp=(FUNCTION *)lh_retrieve(prog,(char *)&f); 167 fp=(FUNCTION *)lh_retrieve(prog,&f);
169 if (fp != NULL) 168 if (fp != NULL)
170 { 169 {
171 Argv[0]=pname; 170 Argv[0]=pname;
@@ -236,6 +235,12 @@ end:
236 EVP_cleanup(); 235 EVP_cleanup();
237 ERR_free_strings(); 236 ERR_free_strings();
238 237
238#ifdef LEVITTE_DEBUG
239 CRYPTO_push_info("Just to make sure I get a memory leak I can see :-)");
240 (void)Malloc(1024);
241 CRYPTO_pop_info();
242#endif
243
239 CRYPTO_mem_leaks(bio_err); 244 CRYPTO_mem_leaks(bio_err);
240 if (bio_err != NULL) 245 if (bio_err != NULL)
241 { 246 {
@@ -257,7 +262,7 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
257 if ((argc <= 0) || (argv[0] == NULL)) 262 if ((argc <= 0) || (argv[0] == NULL))
258 { ret=0; goto end; } 263 { ret=0; goto end; }
259 f.name=argv[0]; 264 f.name=argv[0];
260 fp=(FUNCTION *)lh_retrieve(prog,(char *)&f); 265 fp=(FUNCTION *)lh_retrieve(prog,&f);
261 if (fp != NULL) 266 if (fp != NULL)
262 { 267 {
263 ret=fp->func(argc,argv); 268 ret=fp->func(argc,argv);
@@ -356,7 +361,7 @@ static LHASH *prog_init(void)
356 if ((ret=lh_new(hash,cmp)) == NULL) return(NULL); 361 if ((ret=lh_new(hash,cmp)) == NULL) return(NULL);
357 362
358 for (f=functions; f->name != NULL; f++) 363 for (f=functions; f->name != NULL; f++)
359 lh_insert(ret,(char *)f); 364 lh_insert(ret,f);
360 return(ret); 365 return(ret);
361 } 366 }
362 367
@@ -369,5 +374,3 @@ static unsigned long MS_CALLBACK hash(FUNCTION *a)
369 { 374 {
370 return(lh_strhash(a->name)); 375 return(lh_strhash(a->name));
371 } 376 }
372
373#undef SSLEAY
diff --git a/src/lib/libssl/src/apps/openssl.cnf b/src/lib/libssl/src/apps/openssl.cnf
index d70dd25622..dbe8cbefe0 100644
--- a/src/lib/libssl/src/apps/openssl.cnf
+++ b/src/lib/libssl/src/apps/openssl.cnf
@@ -3,8 +3,13 @@
3# This is mostly being used for generation of certificate requests. 3# This is mostly being used for generation of certificate requests.
4# 4#
5 5
6# This definition stops the following lines choking if HOME isn't
7# defined.
8HOME = .
6RANDFILE = $ENV::HOME/.rnd 9RANDFILE = $ENV::HOME/.rnd
7oid_file = $ENV::HOME/.oid 10
11# Extra OBJECT IDENTIFIER info:
12#oid_file = $ENV::HOME/.oid
8oid_section = new_oids 13oid_section = new_oids
9 14
10# To use this configuration file with the "-extfile" option of the 15# To use this configuration file with the "-extfile" option of the
@@ -86,6 +91,22 @@ distinguished_name = req_distinguished_name
86attributes = req_attributes 91attributes = req_attributes
87x509_extensions = v3_ca # The extentions to add to the self signed cert 92x509_extensions = v3_ca # The extentions to add to the self signed cert
88 93
94# Passwords for private keys if not present they will be prompted for
95# input_password = secret
96# output_password = secret
97
98# This sets a mask for permitted string types. There are several options.
99# default: PrintableString, T61String, BMPString.
100# pkix : PrintableString, BMPString.
101# utf8only: only UTF8Strings.
102# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
103# MASK:XXXX a literal mask value.
104# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
105# so use this option with caution!
106string_mask = nombstr
107
108# req_extensions = v3_req # The extensions to add to a certificate request
109
89[ req_distinguished_name ] 110[ req_distinguished_name ]
90countryName = Country Name (2 letter code) 111countryName = Country Name (2 letter code)
91countryName_default = AU 112countryName_default = AU
@@ -170,8 +191,16 @@ authorityKeyIdentifier=keyid,issuer:always
170#nsCaPolicyUrl 191#nsCaPolicyUrl
171#nsSslServerName 192#nsSslServerName
172 193
194[ v3_req ]
195
196# Extensions to add to a certificate request
197
198basicConstraints = CA:FALSE
199keyUsage = nonRepudiation, digitalSignature, keyEncipherment
200
173[ v3_ca ] 201[ v3_ca ]
174 202
203
175# Extensions for a typical CA 204# Extensions for a typical CA
176 205
177 206
@@ -200,10 +229,11 @@ basicConstraints = CA:true
200# Copy issuer details 229# Copy issuer details
201# issuerAltName=issuer:copy 230# issuerAltName=issuer:copy
202 231
203# RAW DER hex encoding of an extension: beware experts only! 232# DER hex encoding of an extension: beware experts only!
204# 1.2.3.5=RAW:02:03 233# obj=DER:02:03
234# Where 'obj' is a standard or added object
205# You can even override a supported extension: 235# You can even override a supported extension:
206# basicConstraints= critical, RAW:30:03:01:01:FF 236# basicConstraints= critical, DER:30:03:01:01:FF
207 237
208[ crl_ext ] 238[ crl_ext ]
209 239
diff --git a/src/lib/libssl/src/apps/passwd.c b/src/lib/libssl/src/apps/passwd.c
new file mode 100644
index 0000000000..c7e21d2081
--- /dev/null
+++ b/src/lib/libssl/src/apps/passwd.c
@@ -0,0 +1,475 @@
1/* apps/passwd.c */
2
3#if defined NO_MD5 || defined CHARSET_EBCDIC
4# define NO_APR1
5#endif
6
7#if !defined(NO_DES) || !defined(NO_APR1)
8
9#include <assert.h>
10#include <string.h>
11
12#include "apps.h"
13
14#include <openssl/bio.h>
15#include <openssl/err.h>
16#include <openssl/evp.h>
17#include <openssl/rand.h>
18
19#ifndef NO_DES
20# include <openssl/des.h>
21#endif
22#ifndef NO_APR1
23# include <openssl/md5.h>
24#endif
25
26
27#undef PROG
28#define PROG passwd_main
29
30
31static unsigned const char cov_2char[64]={
32 /* from crypto/des/fcrypt.c */
33 0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
34 0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,
35 0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,
36 0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,
37 0x55,0x56,0x57,0x58,0x59,0x5A,0x61,0x62,
38 0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,
39 0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,
40 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
41};
42
43static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
44 char *passwd, BIO *out, int quiet, int table, int reverse,
45 size_t pw_maxlen, int usecrypt, int useapr1);
46
47/* -crypt - standard Unix password algorithm (default, only choice)
48 * -apr1 - MD5-based password algorithm
49 * -salt string - salt
50 * -in file - read passwords from file
51 * -stdin - read passwords from stdin
52 * -quiet - no warnings
53 * -table - format output as table
54 * -reverse - switch table columns
55 */
56
57int MAIN(int, char **);
58
59int MAIN(int argc, char **argv)
60 {
61 int ret = 1;
62 char *infile = NULL;
63 int in_stdin = 0;
64 char *salt = NULL, *passwd = NULL, **passwds = NULL;
65 char *salt_malloc = NULL, *passwd_malloc = NULL;
66 int pw_source_defined = 0;
67 BIO *in = NULL, *out = NULL;
68 int i, badopt, opt_done;
69 int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
70 int usecrypt = 0, useapr1 = 0;
71 size_t pw_maxlen = 0;
72
73 apps_startup();
74
75 if (bio_err == NULL)
76 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
77 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
78 out = BIO_new(BIO_s_file());
79 if (out == NULL)
80 goto err;
81 BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
82
83 badopt = 0, opt_done = 0;
84 i = 0;
85 while (!badopt && !opt_done && argv[++i] != NULL)
86 {
87 if (strcmp(argv[i], "-crypt") == 0)
88 usecrypt = 1;
89 else if (strcmp(argv[i], "-apr1") == 0)
90 useapr1 = 1;
91 else if (strcmp(argv[i], "-salt") == 0)
92 {
93 if ((argv[i+1] != NULL) && (salt == NULL))
94 {
95 passed_salt = 1;
96 salt = argv[++i];
97 }
98 else
99 badopt = 1;
100 }
101 else if (strcmp(argv[i], "-in") == 0)
102 {
103 if ((argv[i+1] != NULL) && !pw_source_defined)
104 {
105 pw_source_defined = 1;
106 infile = argv[++i];
107 }
108 else
109 badopt = 1;
110 }
111 else if (strcmp(argv[i], "-stdin") == 0)
112 {
113 if (!pw_source_defined)
114 {
115 pw_source_defined = 1;
116 in_stdin = 1;
117 }
118 else
119 badopt = 1;
120 }
121 else if (strcmp(argv[i], "-quiet") == 0)
122 quiet = 1;
123 else if (strcmp(argv[i], "-table") == 0)
124 table = 1;
125 else if (strcmp(argv[i], "-reverse") == 0)
126 reverse = 1;
127 else if (argv[i][0] == '-')
128 badopt = 1;
129 else if (!pw_source_defined)
130 /* non-option arguments, use as passwords */
131 {
132 pw_source_defined = 1;
133 passwds = &argv[i];
134 opt_done = 1;
135 }
136 else
137 badopt = 1;
138 }
139
140 if (!usecrypt && !useapr1) /* use default */
141 usecrypt = 1;
142 if (usecrypt + useapr1 > 1) /* conflict */
143 badopt = 1;
144
145 /* reject unsupported algorithms */
146#ifdef NO_DES
147 if (usecrypt) badopt = 1;
148#endif
149#ifdef NO_APR1
150 if (useapr1) badopt = 1;
151#endif
152
153 if (badopt)
154 {
155 BIO_printf(bio_err, "Usage: passwd [options] [passwords]\n");
156 BIO_printf(bio_err, "where options are\n");
157#ifndef NO_DES
158 BIO_printf(bio_err, "-crypt standard Unix password algorithm (default)\n");
159#endif
160#ifndef NO_APR1
161 BIO_printf(bio_err, "-apr1 MD5-based password algorithm\n");
162#endif
163 BIO_printf(bio_err, "-salt string use provided salt\n");
164 BIO_printf(bio_err, "-in file read passwords from file\n");
165 BIO_printf(bio_err, "-stdin read passwords from stdin\n");
166 BIO_printf(bio_err, "-quiet no warnings\n");
167 BIO_printf(bio_err, "-table format output as table\n");
168 BIO_printf(bio_err, "-reverse switch table columns\n");
169
170 goto err;
171 }
172
173 if ((infile != NULL) || in_stdin)
174 {
175 in = BIO_new(BIO_s_file());
176 if (in == NULL)
177 goto err;
178 if (infile != NULL)
179 {
180 assert(in_stdin == 0);
181 if (BIO_read_filename(in, infile) <= 0)
182 goto err;
183 }
184 else
185 {
186 assert(in_stdin);
187 BIO_set_fp(in, stdin, BIO_NOCLOSE);
188 }
189 }
190
191 if (usecrypt)
192 pw_maxlen = 8;
193 else if (useapr1)
194 pw_maxlen = 256; /* arbitrary limit, should be enough for most passwords */
195
196 if (passwds == NULL)
197 {
198 /* no passwords on the command line */
199 passwd = passwd_malloc = Malloc(pw_maxlen + 1);
200 if (passwd_malloc == NULL)
201 goto err;
202 }
203
204 if ((in == NULL) && (passwds == NULL))
205 {
206 /* build a null-terminated list */
207 static char *passwds_static[2] = {NULL, NULL};
208
209 passwds = passwds_static;
210 if (in == NULL)
211 if (EVP_read_pw_string(passwd_malloc, pw_maxlen + 1, "Password: ", 0) != 0)
212 goto err;
213 passwds[0] = passwd_malloc;
214 }
215
216 if (in == NULL)
217 {
218 assert(passwds != NULL);
219 assert(*passwds != NULL);
220
221 do /* loop over list of passwords */
222 {
223 passwd = *passwds++;
224 if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, out,
225 quiet, table, reverse, pw_maxlen, usecrypt, useapr1))
226 goto err;
227 }
228 while (*passwds != NULL);
229 }
230 else
231 /* in != NULL */
232 {
233 int done;
234
235 assert (passwd != NULL);
236 do
237 {
238 int r = BIO_gets(in, passwd, pw_maxlen + 1);
239 if (r > 0)
240 {
241 char *c = (strchr(passwd, '\n')) ;
242 if (c != NULL)
243 *c = 0; /* truncate at newline */
244 else
245 {
246 /* ignore rest of line */
247 char trash[BUFSIZ];
248 do
249 r = BIO_gets(in, trash, sizeof trash);
250 while ((r > 0) && (!strchr(trash, '\n')));
251 }
252
253 if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, out,
254 quiet, table, reverse, pw_maxlen, usecrypt, useapr1))
255 goto err;
256 }
257 done = (r <= 0);
258 }
259 while (!done);
260 }
261
262err:
263 ERR_print_errors(bio_err);
264 if (salt_malloc)
265 Free(salt_malloc);
266 if (passwd_malloc)
267 Free(passwd_malloc);
268 if (in)
269 BIO_free(in);
270 if (out)
271 BIO_free(out);
272 EXIT(ret);
273 }
274
275
276#ifndef NO_APR1
277/* MD5-based password algorithm compatible to the one found in Apache
278 * (should probably be available as a library function;
279 * then the static buffer would not be acceptable) */
280static char *apr1_crypt(const char *passwd, const char *salt)
281 {
282 static char out_buf[6 + 9 + 24 + 2]; /* "$apr1$..salt..$.......md5hash..........\0" */
283 unsigned char buf[MD5_DIGEST_LENGTH];
284 char *salt_out;
285 int n, i;
286 MD5_CTX md;
287 size_t passwd_len, salt_len;
288
289 passwd_len = strlen(passwd);
290 strcpy(out_buf, "$apr1$");
291 strncat(out_buf, salt, 8);
292 assert(strlen(out_buf) <= 6 + 8); /* "$apr1$..salt.." */
293 salt_out = out_buf + 6;
294 salt_len = strlen(salt_out);
295 assert(salt_len <= 8);
296
297 MD5_Init(&md);
298 MD5_Update(&md, passwd, passwd_len);
299 MD5_Update(&md, "$apr1$", 6);
300 MD5_Update(&md, salt_out, salt_len);
301
302 {
303 MD5_CTX md2;
304
305 MD5_Init(&md2);
306 MD5_Update(&md2, passwd, passwd_len);
307 MD5_Update(&md2, salt_out, salt_len);
308 MD5_Update(&md2, passwd, passwd_len);
309 MD5_Final(buf, &md2);
310 }
311 for (i = passwd_len; i > sizeof buf; i -= sizeof buf)
312 MD5_Update(&md, buf, sizeof buf);
313 MD5_Update(&md, buf, i);
314
315 n = passwd_len;
316 while (n)
317 {
318 MD5_Update(&md, (n & 1) ? "\0" : passwd, 1);
319 n >>= 1;
320 }
321 MD5_Final(buf, &md);
322
323 for (i = 0; i < 1000; i++)
324 {
325 MD5_CTX md2;
326
327 MD5_Init(&md2);
328 MD5_Update(&md2, (i & 1) ? (unsigned char *) passwd : buf,
329 (i & 1) ? passwd_len : sizeof buf);
330 if (i % 3)
331 MD5_Update(&md2, salt_out, salt_len);
332 if (i % 7)
333 MD5_Update(&md2, passwd, passwd_len);
334 MD5_Update(&md2, (i & 1) ? buf : (unsigned char *) passwd,
335 (i & 1) ? sizeof buf : passwd_len);
336 MD5_Final(buf, &md2);
337 }
338
339 {
340 /* transform buf into output string */
341
342 unsigned char buf_perm[sizeof buf];
343 int dest, source;
344 char *output;
345
346 /* silly output permutation */
347 for (dest = 0, source = 0; dest < 14; dest++, source = (source + 6) % 17)
348 buf_perm[dest] = buf[source];
349 buf_perm[14] = buf[5];
350 buf_perm[15] = buf[11];
351#ifndef PEDANTIC /* Unfortunately, this generates a "no effect" warning */
352 assert(16 == sizeof buf_perm);
353#endif
354
355 output = salt_out + salt_len;
356 assert(output == out_buf + strlen(out_buf));
357
358 *output++ = '$';
359
360 for (i = 0; i < 15; i += 3)
361 {
362 *output++ = cov_2char[buf_perm[i+2] & 0x3f];
363 *output++ = cov_2char[((buf_perm[i+1] & 0xf) << 2) |
364 (buf_perm[i+2] >> 6)];
365 *output++ = cov_2char[((buf_perm[i] & 3) << 4) |
366 (buf_perm[i+1] >> 4)];
367 *output++ = cov_2char[buf_perm[i] >> 2];
368 }
369 assert(i == 15);
370 *output++ = cov_2char[buf_perm[i] & 0x3f];
371 *output++ = cov_2char[buf_perm[i] >> 6];
372 *output = 0;
373 assert(strlen(out_buf) < sizeof(out_buf));
374 }
375
376 return out_buf;
377 }
378#endif
379
380
381static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
382 char *passwd, BIO *out, int quiet, int table, int reverse,
383 size_t pw_maxlen, int usecrypt, int useapr1)
384 {
385 char *hash = NULL;
386
387 assert(salt_p != NULL);
388 assert(salt_malloc_p != NULL);
389
390 /* first make sure we have a salt */
391 if (!passed_salt)
392 {
393#ifndef NO_DES
394 if (usecrypt)
395 {
396 if (*salt_malloc_p == NULL)
397 {
398 *salt_p = *salt_malloc_p = Malloc(3);
399 if (*salt_malloc_p == NULL)
400 goto err;
401 }
402 if (RAND_pseudo_bytes((unsigned char *)*salt_p, 2) < 0)
403 goto err;
404 (*salt_p)[0] = cov_2char[(*salt_p)[0] & 0x3f]; /* 6 bits */
405 (*salt_p)[1] = cov_2char[(*salt_p)[1] & 0x3f]; /* 6 bits */
406 (*salt_p)[2] = 0;
407#ifdef CHARSET_EBCDIC
408 ascii2ebcdic(*salt_p, *salt_p, 2); /* des_crypt will convert
409 * back to ASCII */
410#endif
411 }
412#endif /* !NO_DES */
413
414#ifndef NO_APR1
415 if (useapr1)
416 {
417 int i;
418
419 if (*salt_malloc_p == NULL)
420 {
421 *salt_p = *salt_malloc_p = Malloc(9);
422 if (*salt_malloc_p == NULL)
423 goto err;
424 }
425 if (RAND_pseudo_bytes((unsigned char *)*salt_p, 8) < 0)
426 goto err;
427
428 for (i = 0; i < 8; i++)
429 (*salt_p)[i] = cov_2char[(*salt_p)[i] & 0x3f]; /* 6 bits */
430 (*salt_p)[8] = 0;
431 }
432#endif /* !NO_APR1 */
433 }
434
435 assert(*salt_p != NULL);
436
437 /* truncate password if necessary */
438 if ((strlen(passwd) > pw_maxlen))
439 {
440 if (!quiet)
441 BIO_printf(bio_err, "Warning: truncating password to %u characters\n", pw_maxlen);
442 passwd[pw_maxlen] = 0;
443 }
444 assert(strlen(passwd) <= pw_maxlen);
445
446 /* now compute password hash */
447#ifndef NO_DES
448 if (usecrypt)
449 hash = des_crypt(passwd, *salt_p);
450#endif
451#ifndef NO_APR1
452 if (useapr1)
453 hash = apr1_crypt(passwd, *salt_p);
454#endif
455 assert(hash != NULL);
456
457 if (table && !reverse)
458 BIO_printf(out, "%s\t%s\n", passwd, hash);
459 else if (table && reverse)
460 BIO_printf(out, "%s\t%s\n", hash, passwd);
461 else
462 BIO_printf(out, "%s\n", hash);
463 return 1;
464
465err:
466 return 0;
467 }
468#else
469
470int MAIN(int argc, char **argv)
471 {
472 fputs("Program not available.\n", stderr)
473 EXIT(1);
474 }
475#endif
diff --git a/src/lib/libssl/src/apps/pkcs12.c b/src/lib/libssl/src/apps/pkcs12.c
index 5defddeb32..d535a71335 100644
--- a/src/lib/libssl/src/apps/pkcs12.c
+++ b/src/lib/libssl/src/apps/pkcs12.c
@@ -61,12 +61,12 @@
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 <openssl/des.h> 64#include "apps.h"
65#include <openssl/pem.h> 65#include <openssl/crypto.h>
66#include <openssl/err.h> 66#include <openssl/err.h>
67#include <openssl/pem.h>
67#include <openssl/pkcs12.h> 68#include <openssl/pkcs12.h>
68 69
69#include "apps.h"
70#define PROG pkcs12_main 70#define PROG pkcs12_main
71 71
72EVP_CIPHER *enc; 72EVP_CIPHER *enc;
@@ -79,14 +79,16 @@ EVP_CIPHER *enc;
79#define CACERTS 0x10 79#define CACERTS 0x10
80 80
81int get_cert_chain(X509 *cert, STACK_OF(X509) **chain); 81int get_cert_chain(X509 *cert, STACK_OF(X509) **chain);
82int dump_cert_text (BIO *out, X509 *x); 82int dump_certs_keys_p12(BIO *out, PKCS12 *p12, char *pass, int passlen, int options, char *pempass);
83int dump_certs_keys_p12(BIO *out, PKCS12 *p12, char *pass, int passlen, int options); 83int dump_certs_pkeys_bags(BIO *out, STACK *bags, char *pass, int passlen, int options, char *pempass);
84int dump_certs_pkeys_bags(BIO *out, STACK *bags, char *pass, int passlen, int options); 84int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bags, char *pass, int passlen, int options, char *pempass);
85int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bags, char *pass, int passlen, int options);
86int print_attribs(BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst, char *name); 85int print_attribs(BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst, char *name);
87void hex_prin(BIO *out, unsigned char *buf, int len); 86void hex_prin(BIO *out, unsigned char *buf, int len);
88int alg_print(BIO *x, X509_ALGOR *alg); 87int alg_print(BIO *x, X509_ALGOR *alg);
89int cert_load(BIO *in, STACK_OF(X509) *sk); 88int cert_load(BIO *in, STACK_OF(X509) *sk);
89
90int MAIN(int, char **);
91
90int MAIN(int argc, char **argv) 92int MAIN(int argc, char **argv)
91{ 93{
92 char *infile=NULL, *outfile=NULL, *keyname = NULL; 94 char *infile=NULL, *outfile=NULL, *keyname = NULL;
@@ -101,15 +103,19 @@ int MAIN(int argc, char **argv)
101 int chain = 0; 103 int chain = 0;
102 int badarg = 0; 104 int badarg = 0;
103 int iter = PKCS12_DEFAULT_ITER; 105 int iter = PKCS12_DEFAULT_ITER;
104 int maciter = 1; 106 int maciter = PKCS12_DEFAULT_ITER;
105 int twopass = 0; 107 int twopass = 0;
106 int keytype = 0; 108 int keytype = 0;
107 int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; 109 int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
110 int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
108 int ret = 1; 111 int ret = 1;
109 int macver = 1; 112 int macver = 1;
110 int noprompt = 0; 113 int noprompt = 0;
111 STACK *canames = NULL; 114 STACK *canames = NULL;
112 char *cpass = NULL, *mpass = NULL; 115 char *cpass = NULL, *mpass = NULL;
116 char *passargin = NULL, *passargout = NULL, *passarg = NULL;
117 char *passin = NULL, *passout = NULL;
118 char *inrand = NULL;
113 119
114 apps_startup(); 120 apps_startup();
115 121
@@ -143,8 +149,35 @@ int MAIN(int argc, char **argv)
143 else if (!strcmp (*args, "-noiter")) iter = 1; 149 else if (!strcmp (*args, "-noiter")) iter = 1;
144 else if (!strcmp (*args, "-maciter")) 150 else if (!strcmp (*args, "-maciter"))
145 maciter = PKCS12_DEFAULT_ITER; 151 maciter = PKCS12_DEFAULT_ITER;
152 else if (!strcmp (*args, "-nomaciter"))
153 maciter = 1;
146 else if (!strcmp (*args, "-nodes")) enc=NULL; 154 else if (!strcmp (*args, "-nodes")) enc=NULL;
147 else if (!strcmp (*args, "-inkey")) { 155 else if (!strcmp (*args, "-certpbe")) {
156 if (args[1]) {
157 args++;
158 cert_pbe=OBJ_txt2nid(*args);
159 if(cert_pbe == NID_undef) {
160 BIO_printf(bio_err,
161 "Unknown PBE algorithm %s\n", *args);
162 badarg = 1;
163 }
164 } else badarg = 1;
165 } else if (!strcmp (*args, "-keypbe")) {
166 if (args[1]) {
167 args++;
168 key_pbe=OBJ_txt2nid(*args);
169 if(key_pbe == NID_undef) {
170 BIO_printf(bio_err,
171 "Unknown PBE algorithm %s\n", *args);
172 badarg = 1;
173 }
174 } else badarg = 1;
175 } else if (!strcmp (*args, "-rand")) {
176 if (args[1]) {
177 args++;
178 inrand = *args;
179 } else badarg = 1;
180 } else if (!strcmp (*args, "-inkey")) {
148 if (args[1]) { 181 if (args[1]) {
149 args++; 182 args++;
150 keyname = *args; 183 keyname = *args;
@@ -175,20 +208,20 @@ int MAIN(int argc, char **argv)
175 args++; 208 args++;
176 outfile = *args; 209 outfile = *args;
177 } else badarg = 1; 210 } else badarg = 1;
178 } else if (!strcmp (*args, "-envpass")) { 211 } else if (!strcmp(*args,"-passin")) {
179 if (args[1]) { 212 if (args[1]) {
180 args++; 213 args++;
181 if(!(cpass = getenv(*args))) { 214 passargin = *args;
182 BIO_printf(bio_err, 215 } else badarg = 1;
183 "Can't read environment variable %s\n", *args); 216 } else if (!strcmp(*args,"-passout")) {
184 goto end; 217 if (args[1]) {
185 } 218 args++;
186 noprompt = 1; 219 passargout = *args;
187 } else badarg = 1; 220 } else badarg = 1;
188 } else if (!strcmp (*args, "-password")) { 221 } else if (!strcmp (*args, "-password")) {
189 if (args[1]) { 222 if (args[1]) {
190 args++; 223 args++;
191 cpass = *args; 224 passarg = *args;
192 noprompt = 1; 225 noprompt = 1;
193 } else badarg = 1; 226 } else badarg = 1;
194 } else badarg = 1; 227 } else badarg = 1;
@@ -225,21 +258,54 @@ int MAIN(int argc, char **argv)
225 BIO_printf (bio_err, "-maciter use MAC iteration\n"); 258 BIO_printf (bio_err, "-maciter use MAC iteration\n");
226 BIO_printf (bio_err, "-twopass separate MAC, encryption passwords\n"); 259 BIO_printf (bio_err, "-twopass separate MAC, encryption passwords\n");
227 BIO_printf (bio_err, "-descert encrypt PKCS#12 certificates with triple DES (default RC2-40)\n"); 260 BIO_printf (bio_err, "-descert encrypt PKCS#12 certificates with triple DES (default RC2-40)\n");
261 BIO_printf (bio_err, "-certpbe alg specify certificate PBE algorithm (default RC2-40)\n");
262 BIO_printf (bio_err, "-keypbe alg specify private key PBE algorithm (default 3DES)\n");
228 BIO_printf (bio_err, "-keyex set MS key exchange type\n"); 263 BIO_printf (bio_err, "-keyex set MS key exchange type\n");
229 BIO_printf (bio_err, "-keysig set MS key signature type\n"); 264 BIO_printf (bio_err, "-keysig set MS key signature type\n");
230 BIO_printf (bio_err, "-password p set import/export password (NOT RECOMMENDED)\n"); 265 BIO_printf (bio_err, "-password p set import/export password source\n");
231 BIO_printf (bio_err, "-envpass p set import/export password from environment\n"); 266 BIO_printf (bio_err, "-passin p input file pass phrase source\n");
267 BIO_printf (bio_err, "-passout p output file pass phrase source\n");
268 BIO_printf(bio_err, "-rand file:file:...\n");
269 BIO_printf(bio_err, " load the file (or the files in the directory) into\n");
270 BIO_printf(bio_err, " the random number generator\n");
232 goto end; 271 goto end;
233 } 272 }
234 273
235 if(cpass) mpass = cpass; 274 if(passarg) {
236 else { 275 if(export_cert) passargout = passarg;
276 else passargin = passarg;
277 }
278
279 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
280 BIO_printf(bio_err, "Error getting passwords\n");
281 goto end;
282 }
283
284 if(!cpass) {
285 if(export_cert) cpass = passout;
286 else cpass = passin;
287 }
288
289 if(cpass) {
290 mpass = cpass;
291 noprompt = 1;
292 } else {
237 cpass = pass; 293 cpass = pass;
238 mpass = macpass; 294 mpass = macpass;
239 } 295 }
240 296
297 if(export_cert || inrand) {
298 app_RAND_load_file(NULL, bio_err, (inrand != NULL));
299 if (inrand != NULL)
300 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
301 app_RAND_load_files(inrand));
302 }
241 ERR_load_crypto_strings(); 303 ERR_load_crypto_strings();
242 304
305#ifdef CRYPTO_MDEBUG
306 CRYPTO_push_info("read files");
307#endif
308
243 if (!infile) in = BIO_new_fp(stdin, BIO_NOCLOSE); 309 if (!infile) in = BIO_new_fp(stdin, BIO_NOCLOSE);
244 else in = BIO_new_file(infile, "rb"); 310 else in = BIO_new_file(infile, "rb");
245 if (!in) { 311 if (!in) {
@@ -265,6 +331,11 @@ int MAIN(int argc, char **argv)
265 } 331 }
266 } 332 }
267 333
334#ifdef CRYPTO_MDEBUG
335 CRYPTO_pop_info();
336 CRYPTO_push_info("write files");
337#endif
338
268 if (!outfile) out = BIO_new_fp(stdout, BIO_NOCLOSE); 339 if (!outfile) out = BIO_new_fp(stdout, BIO_NOCLOSE);
269 else out = BIO_new_file(outfile, "wb"); 340 else out = BIO_new_file(outfile, "wb");
270 if (!out) { 341 if (!out) {
@@ -274,27 +345,38 @@ int MAIN(int argc, char **argv)
274 goto end; 345 goto end;
275 } 346 }
276 if (twopass) { 347 if (twopass) {
348#ifdef CRYPTO_MDEBUG
349 CRYPTO_push_info("read MAC password");
350#endif
277 if(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert)) 351 if(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert))
278 { 352 {
279 BIO_printf (bio_err, "Can't read Password\n"); 353 BIO_printf (bio_err, "Can't read Password\n");
280 goto end; 354 goto end;
281 } 355 }
356#ifdef CRYPTO_MDEBUG
357 CRYPTO_pop_info();
358#endif
282 } 359 }
283 360
284if (export_cert) { 361 if (export_cert) {
285 EVP_PKEY *key; 362 EVP_PKEY *key;
286 STACK *bags, *safes; 363 STACK *bags, *safes;
287 PKCS12_SAFEBAG *bag; 364 PKCS12_SAFEBAG *bag;
288 PKCS8_PRIV_KEY_INFO *p8; 365 PKCS8_PRIV_KEY_INFO *p8;
289 PKCS7 *authsafe; 366 PKCS7 *authsafe;
290 X509 *cert = NULL, *ucert = NULL; 367 X509 *ucert = NULL;
291 STACK_OF(X509) *certs; 368 STACK_OF(X509) *certs=NULL;
292 char *catmp; 369 char *catmp;
293 int i; 370 int i;
294 unsigned char keyid[EVP_MAX_MD_SIZE]; 371 unsigned char keyid[EVP_MAX_MD_SIZE];
295 unsigned int keyidlen = 0; 372 unsigned int keyidlen = 0;
296 key = PEM_read_bio_PrivateKey(inkey ? inkey : in, NULL, NULL, NULL); 373
374#ifdef CRYPTO_MDEBUG
375 CRYPTO_push_info("process -export_cert");
376#endif
377 key = PEM_read_bio_PrivateKey(inkey ? inkey : in, NULL, NULL, passin);
297 if (!inkey) (void) BIO_reset(in); 378 if (!inkey) (void) BIO_reset(in);
379 else BIO_free(inkey);
298 if (!key) { 380 if (!key) {
299 BIO_printf (bio_err, "Error loading private key\n"); 381 BIO_printf (bio_err, "Error loading private key\n");
300 ERR_print_errors(bio_err); 382 ERR_print_errors(bio_err);
@@ -313,7 +395,7 @@ if (export_cert) {
313 for(i = 0; i < sk_X509_num(certs); i++) { 395 for(i = 0; i < sk_X509_num(certs); i++) {
314 ucert = sk_X509_value(certs, i); 396 ucert = sk_X509_value(certs, i);
315 if(X509_check_private_key(ucert, key)) { 397 if(X509_check_private_key(ucert, key)) {
316 X509_digest(cert, EVP_sha1(), keyid, &keyidlen); 398 X509_digest(ucert, EVP_sha1(), keyid, &keyidlen);
317 break; 399 break;
318 } 400 }
319 } 401 }
@@ -354,6 +436,7 @@ if (export_cert) {
354 436
355 /* We now have loads of certificates: include them all */ 437 /* We now have loads of certificates: include them all */
356 for(i = 0; i < sk_X509_num(certs); i++) { 438 for(i = 0; i < sk_X509_num(certs); i++) {
439 X509 *cert = NULL;
357 cert = sk_X509_value(certs, i); 440 cert = sk_X509_value(certs, i);
358 bag = M_PKCS12_x5092certbag(cert); 441 bag = M_PKCS12_x5092certbag(cert);
359 /* If it matches private key set id */ 442 /* If it matches private key set id */
@@ -364,7 +447,7 @@ if (export_cert) {
364 PKCS12_add_friendlyname(bag, catmp, -1); 447 PKCS12_add_friendlyname(bag, catmp, -1);
365 sk_push(bags, (char *)bag); 448 sk_push(bags, (char *)bag);
366 } 449 }
367 450 sk_X509_pop_free(certs, X509_free);
368 if (canames) sk_free(canames); 451 if (canames) sk_free(canames);
369 452
370 if(!noprompt && 453 if(!noprompt &&
@@ -390,8 +473,7 @@ if (export_cert) {
390 p8 = EVP_PKEY2PKCS8 (key); 473 p8 = EVP_PKEY2PKCS8 (key);
391 EVP_PKEY_free(key); 474 EVP_PKEY_free(key);
392 if(keytype) PKCS8_add_keyusage(p8, keytype); 475 if(keytype) PKCS8_add_keyusage(p8, keytype);
393 bag = PKCS12_MAKE_SHKEYBAG(NID_pbe_WithSHA1And3_Key_TripleDES_CBC, 476 bag = PKCS12_MAKE_SHKEYBAG(key_pbe, cpass, -1, NULL, 0, iter, p8);
394 cpass, -1, NULL, 0, iter, p8);
395 PKCS8_PRIV_KEY_INFO_free(p8); 477 PKCS8_PRIV_KEY_INFO_free(p8);
396 if (name) PKCS12_add_friendlyname (bag, name, -1); 478 if (name) PKCS12_add_friendlyname (bag, name, -1);
397 PKCS12_add_localkeyid (bag, keyid, keyidlen); 479 PKCS12_add_localkeyid (bag, keyid, keyidlen);
@@ -415,6 +497,10 @@ if (export_cert) {
415 PKCS12_free(p12); 497 PKCS12_free(p12);
416 498
417 ret = 0; 499 ret = 0;
500
501#ifdef CRYPTO_MDEBUG
502 CRYPTO_pop_info();
503#endif
418 goto end; 504 goto end;
419 505
420 } 506 }
@@ -424,50 +510,61 @@ if (export_cert) {
424 goto end; 510 goto end;
425 } 511 }
426 512
513#ifdef CRYPTO_MDEBUG
514 CRYPTO_push_info("read import password");
515#endif
427 if(!noprompt && EVP_read_pw_string(pass, 50, "Enter Import Password:", 0)) { 516 if(!noprompt && EVP_read_pw_string(pass, 50, "Enter Import Password:", 0)) {
428 BIO_printf (bio_err, "Can't read Password\n"); 517 BIO_printf (bio_err, "Can't read Password\n");
429 goto end; 518 goto end;
430 } 519 }
520#ifdef CRYPTO_MDEBUG
521 CRYPTO_pop_info();
522#endif
431 523
432 if (!twopass) strcpy(macpass, pass); 524 if (!twopass) strcpy(macpass, pass);
433 525
434 if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1); 526 if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);
435 if(macver) { 527 if(macver) {
528#ifdef CRYPTO_MDEBUG
529 CRYPTO_push_info("verify MAC");
530#endif
436 if (!PKCS12_verify_mac (p12, mpass, -1)) { 531 if (!PKCS12_verify_mac (p12, mpass, -1)) {
437 BIO_printf (bio_err, "Mac verify errror: invalid password?\n"); 532 BIO_printf (bio_err, "Mac verify error: invalid password?\n");
438 ERR_print_errors (bio_err); 533 ERR_print_errors (bio_err);
439 goto end; 534 goto end;
440 } else BIO_printf (bio_err, "MAC verified OK\n"); 535 } else BIO_printf (bio_err, "MAC verified OK\n");
536#ifdef CRYPTO_MDEBUG
537 CRYPTO_pop_info();
538#endif
441 } 539 }
442 540
443 if (!dump_certs_keys_p12 (out, p12, cpass, -1, options)) { 541#ifdef CRYPTO_MDEBUG
542 CRYPTO_push_info("output keys and certificates");
543#endif
544 if (!dump_certs_keys_p12 (out, p12, cpass, -1, options, passout)) {
444 BIO_printf(bio_err, "Error outputting keys and certificates\n"); 545 BIO_printf(bio_err, "Error outputting keys and certificates\n");
445 ERR_print_errors (bio_err); 546 ERR_print_errors (bio_err);
446 goto end; 547 goto end;
447 } 548 }
549#ifdef CRYPTO_MDEBUG
550 CRYPTO_pop_info();
551#endif
448 PKCS12_free(p12); 552 PKCS12_free(p12);
449 ret = 0; 553 ret = 0;
450 end: 554 end:
555 if(export_cert || inrand) app_RAND_write_file(NULL, bio_err);
556#ifdef CRYPTO_MDEBUG
557 CRYPTO_remove_all_info();
558#endif
559 BIO_free(in);
451 BIO_free(out); 560 BIO_free(out);
561 if(passin) Free(passin);
562 if(passout) Free(passout);
452 EXIT(ret); 563 EXIT(ret);
453} 564}
454 565
455int dump_cert_text (BIO *out, X509 *x)
456{
457 char buf[256];
458 X509_NAME_oneline(X509_get_subject_name(x),buf,256);
459 BIO_puts(out,"subject=");
460 BIO_puts(out,buf);
461
462 X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
463 BIO_puts(out,"\nissuer= ");
464 BIO_puts(out,buf);
465 BIO_puts(out,"\n");
466 return 0;
467}
468
469int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, 566int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
470 int passlen, int options) 567 int passlen, int options, char *pempass)
471{ 568{
472 STACK *asafes, *bags; 569 STACK *asafes, *bags;
473 int i, bagnid; 570 int i, bagnid;
@@ -489,7 +586,7 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
489 } else continue; 586 } else continue;
490 if (!bags) return 0; 587 if (!bags) return 0;
491 if (!dump_certs_pkeys_bags (out, bags, pass, passlen, 588 if (!dump_certs_pkeys_bags (out, bags, pass, passlen,
492 options)) { 589 options, pempass)) {
493 sk_pop_free (bags, PKCS12_SAFEBAG_free); 590 sk_pop_free (bags, PKCS12_SAFEBAG_free);
494 return 0; 591 return 0;
495 } 592 }
@@ -500,19 +597,19 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
500} 597}
501 598
502int dump_certs_pkeys_bags (BIO *out, STACK *bags, char *pass, 599int dump_certs_pkeys_bags (BIO *out, STACK *bags, char *pass,
503 int passlen, int options) 600 int passlen, int options, char *pempass)
504{ 601{
505 int i; 602 int i;
506 for (i = 0; i < sk_num (bags); i++) { 603 for (i = 0; i < sk_num (bags); i++) {
507 if (!dump_certs_pkeys_bag (out, 604 if (!dump_certs_pkeys_bag (out,
508 (PKCS12_SAFEBAG *)sk_value (bags, i), pass, passlen, 605 (PKCS12_SAFEBAG *)sk_value (bags, i), pass, passlen,
509 options)) return 0; 606 options, pempass)) return 0;
510 } 607 }
511 return 1; 608 return 1;
512} 609}
513 610
514int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass, 611int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
515 int passlen, int options) 612 int passlen, int options, char *pempass)
516{ 613{
517 EVP_PKEY *pkey; 614 EVP_PKEY *pkey;
518 PKCS8_PRIV_KEY_INFO *p8; 615 PKCS8_PRIV_KEY_INFO *p8;
@@ -527,7 +624,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
527 p8 = bag->value.keybag; 624 p8 = bag->value.keybag;
528 if (!(pkey = EVP_PKCS82PKEY (p8))) return 0; 625 if (!(pkey = EVP_PKCS82PKEY (p8))) return 0;
529 print_attribs (out, p8->attributes, "Key Attributes"); 626 print_attribs (out, p8->attributes, "Key Attributes");
530 PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, NULL); 627 PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, pempass);
531 EVP_PKEY_free(pkey); 628 EVP_PKEY_free(pkey);
532 break; 629 break;
533 630
@@ -543,7 +640,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
543 if (!(pkey = EVP_PKCS82PKEY (p8))) return 0; 640 if (!(pkey = EVP_PKCS82PKEY (p8))) return 0;
544 print_attribs (out, p8->attributes, "Key Attributes"); 641 print_attribs (out, p8->attributes, "Key Attributes");
545 PKCS8_PRIV_KEY_INFO_free(p8); 642 PKCS8_PRIV_KEY_INFO_free(p8);
546 PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, NULL); 643 PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, pempass);
547 EVP_PKEY_free(pkey); 644 EVP_PKEY_free(pkey);
548 break; 645 break;
549 646
@@ -566,7 +663,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
566 if (options & INFO) BIO_printf (bio_err, "Safe Contents bag\n"); 663 if (options & INFO) BIO_printf (bio_err, "Safe Contents bag\n");
567 print_attribs (out, bag->attrib, "Bag Attributes"); 664 print_attribs (out, bag->attrib, "Bag Attributes");
568 return dump_certs_pkeys_bags (out, bag->value.safes, pass, 665 return dump_certs_pkeys_bags (out, bag->value.safes, pass,
569 passlen, options); 666 passlen, options, pempass);
570 667
571 default: 668 default:
572 BIO_printf (bio_err, "Warning unsupported bag type: "); 669 BIO_printf (bio_err, "Warning unsupported bag type: ");
@@ -588,7 +685,7 @@ int get_cert_chain (X509 *cert, STACK_OF(X509) **chain)
588 X509_STORE_CTX store_ctx; 685 X509_STORE_CTX store_ctx;
589 STACK_OF(X509) *chn; 686 STACK_OF(X509) *chn;
590 int i; 687 int i;
591 X509 *x; 688
592 store = X509_STORE_new (); 689 store = X509_STORE_new ();
593 X509_STORE_set_default_paths (store); 690 X509_STORE_set_default_paths (store);
594 X509_STORE_CTX_init(&store_ctx, store, cert, NULL); 691 X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
@@ -596,11 +693,7 @@ int get_cert_chain (X509 *cert, STACK_OF(X509) **chain)
596 i = X509_STORE_CTX_get_error (&store_ctx); 693 i = X509_STORE_CTX_get_error (&store_ctx);
597 goto err; 694 goto err;
598 } 695 }
599 chn = sk_X509_dup(X509_STORE_CTX_get_chain (&store_ctx)); 696 chn = X509_STORE_CTX_get1_chain(&store_ctx);
600 for (i = 0; i < sk_X509_num(chn); i++) {
601 x = sk_X509_value(chn, i);
602 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);
603 }
604 i = 0; 697 i = 0;
605 *chain = chn; 698 *chain = chn;
606err: 699err:
diff --git a/src/lib/libssl/src/apps/pkcs7.c b/src/lib/libssl/src/apps/pkcs7.c
index 0e1427cc31..f471cc77fd 100644
--- a/src/lib/libssl/src/apps/pkcs7.c
+++ b/src/lib/libssl/src/apps/pkcs7.c
@@ -71,27 +71,23 @@
71#undef PROG 71#undef PROG
72#define PROG pkcs7_main 72#define PROG pkcs7_main
73 73
74/* -inform arg - input format - default PEM (one of DER, TXT or PEM) 74/* -inform arg - input format - default PEM (DER or PEM)
75 * -outform arg - output format - default PEM 75 * -outform arg - output format - default PEM
76 * -in arg - input file - default stdin 76 * -in arg - input file - default stdin
77 * -out arg - output file - default stdout 77 * -out arg - output file - default stdout
78 * -des - encrypt output if PEM format with DES in cbc mode
79 * -des3 - encrypt output if PEM format
80 * -idea - encrypt output if PEM format
81 * -print_certs 78 * -print_certs
82 */ 79 */
83 80
81int MAIN(int, char **);
82
84int MAIN(int argc, char **argv) 83int MAIN(int argc, char **argv)
85 { 84 {
86 PKCS7 *p7=NULL; 85 PKCS7 *p7=NULL;
87 int i,badops=0; 86 int i,badops=0;
88#if !defined(NO_DES) || !defined(NO_IDEA)
89 EVP_CIPHER *enc=NULL;
90#endif
91 BIO *in=NULL,*out=NULL; 87 BIO *in=NULL,*out=NULL;
92 int informat,outformat; 88 int informat,outformat;
93 char *infile,*outfile,*prog,buf[256]; 89 char *infile,*outfile,*prog;
94 int print_certs=0; 90 int print_certs=0,text=0,noout=0;
95 int ret=0; 91 int ret=0;
96 92
97 apps_startup(); 93 apps_startup();
@@ -130,18 +126,12 @@ int MAIN(int argc, char **argv)
130 if (--argc < 1) goto bad; 126 if (--argc < 1) goto bad;
131 outfile= *(++argv); 127 outfile= *(++argv);
132 } 128 }
129 else if (strcmp(*argv,"-noout") == 0)
130 noout=1;
131 else if (strcmp(*argv,"-text") == 0)
132 text=1;
133 else if (strcmp(*argv,"-print_certs") == 0) 133 else if (strcmp(*argv,"-print_certs") == 0)
134 print_certs=1; 134 print_certs=1;
135#ifndef NO_DES
136 else if (strcmp(*argv,"-des") == 0)
137 enc=EVP_des_cbc();
138 else if (strcmp(*argv,"-des3") == 0)
139 enc=EVP_des_ede3_cbc();
140#endif
141#ifndef NO_IDEA
142 else if (strcmp(*argv,"-idea") == 0)
143 enc=EVP_idea_cbc();
144#endif
145 else 135 else
146 { 136 {
147 BIO_printf(bio_err,"unknown option %s\n",*argv); 137 BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -157,16 +147,13 @@ int MAIN(int argc, char **argv)
157bad: 147bad:
158 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog); 148 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
159 BIO_printf(bio_err,"where options are\n"); 149 BIO_printf(bio_err,"where options are\n");
160 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n"); 150 BIO_printf(bio_err," -inform arg input format - DER or PEM\n");
161 BIO_printf(bio_err," -outform arg output format - one of DER TXT PEM\n"); 151 BIO_printf(bio_err," -outform arg output format - DER or PEM\n");
162 BIO_printf(bio_err," -in arg input file\n"); 152 BIO_printf(bio_err," -in arg input file\n");
163 BIO_printf(bio_err," -out arg output file\n"); 153 BIO_printf(bio_err," -out arg output file\n");
164 BIO_printf(bio_err," -print_certs print any certs or crl in the input\n"); 154 BIO_printf(bio_err," -print_certs print any certs or crl in the input\n");
165 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 155 BIO_printf(bio_err," -text print full details of certificates\n");
166 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 156 BIO_printf(bio_err," -noout don't output encoded data\n");
167#ifndef NO_IDEA
168 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n");
169#endif
170 EXIT(1); 157 EXIT(1);
171 } 158 }
172 159
@@ -246,19 +233,10 @@ bad:
246 for (i=0; i<sk_X509_num(certs); i++) 233 for (i=0; i<sk_X509_num(certs); i++)
247 { 234 {
248 x=sk_X509_value(certs,i); 235 x=sk_X509_value(certs,i);
236 if(text) X509_print(out, x);
237 else dump_cert_text(out, x);
249 238
250 X509_NAME_oneline(X509_get_subject_name(x), 239 if(!noout) PEM_write_bio_X509(out,x);
251 buf,256);
252 BIO_puts(out,"subject=");
253 BIO_puts(out,buf);
254
255 X509_NAME_oneline(X509_get_issuer_name(x),
256 buf,256);
257 BIO_puts(out,"\nissuer= ");
258 BIO_puts(out,buf);
259 BIO_puts(out,"\n");
260
261 PEM_write_bio_X509(out,x);
262 BIO_puts(out,"\n"); 240 BIO_puts(out,"\n");
263 } 241 }
264 } 242 }
@@ -270,17 +248,9 @@ bad:
270 { 248 {
271 crl=sk_X509_CRL_value(crls,i); 249 crl=sk_X509_CRL_value(crls,i);
272 250
273 X509_NAME_oneline(crl->crl->issuer,buf,256); 251 X509_CRL_print(out, crl);
274 BIO_puts(out,"issuer= ");
275 BIO_puts(out,buf);
276 252
277 BIO_puts(out,"\nlast update="); 253 if(!noout)PEM_write_bio_X509_CRL(out,crl);
278 ASN1_TIME_print(out,crl->crl->lastUpdate);
279 BIO_puts(out,"\nnext update=");
280 ASN1_TIME_print(out,crl->crl->nextUpdate);
281 BIO_puts(out,"\n");
282
283 PEM_write_bio_X509_CRL(out,crl);
284 BIO_puts(out,"\n"); 254 BIO_puts(out,"\n");
285 } 255 }
286 } 256 }
@@ -289,21 +259,23 @@ bad:
289 goto end; 259 goto end;
290 } 260 }
291 261
292 if (outformat == FORMAT_ASN1) 262 if(!noout) {
293 i=i2d_PKCS7_bio(out,p7); 263 if (outformat == FORMAT_ASN1)
294 else if (outformat == FORMAT_PEM) 264 i=i2d_PKCS7_bio(out,p7);
295 i=PEM_write_bio_PKCS7(out,p7); 265 else if (outformat == FORMAT_PEM)
296 else { 266 i=PEM_write_bio_PKCS7(out,p7);
297 BIO_printf(bio_err,"bad output format specified for outfile\n"); 267 else {
298 goto end; 268 BIO_printf(bio_err,"bad output format specified for outfile\n");
299 } 269 goto end;
270 }
300 271
301 if (!i) 272 if (!i)
302 { 273 {
303 BIO_printf(bio_err,"unable to write pkcs7 object\n"); 274 BIO_printf(bio_err,"unable to write pkcs7 object\n");
304 ERR_print_errors(bio_err); 275 ERR_print_errors(bio_err);
305 goto end; 276 goto end;
306 } 277 }
278 }
307 ret=0; 279 ret=0;
308end: 280end:
309 if (p7 != NULL) PKCS7_free(p7); 281 if (p7 != NULL) PKCS7_free(p7);
diff --git a/src/lib/libssl/src/apps/pkcs8.c b/src/lib/libssl/src/apps/pkcs8.c
index a05388300a..3e59b74124 100644
--- a/src/lib/libssl/src/apps/pkcs8.c
+++ b/src/lib/libssl/src/apps/pkcs8.c
@@ -57,6 +57,7 @@
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h> 59#include <string.h>
60#include "apps.h"
60#include <openssl/pem.h> 61#include <openssl/pem.h>
61#include <openssl/err.h> 62#include <openssl/err.h>
62#include <openssl/evp.h> 63#include <openssl/evp.h>
@@ -65,10 +66,12 @@
65#include "apps.h" 66#include "apps.h"
66#define PROG pkcs8_main 67#define PROG pkcs8_main
67 68
69int MAIN(int, char **);
68 70
69int MAIN(int argc, char **argv) 71int MAIN(int argc, char **argv)
70{ 72{
71 char **args, *infile = NULL, *outfile = NULL; 73 char **args, *infile = NULL, *outfile = NULL;
74 char *passargin = NULL, *passargout = NULL;
72 BIO *in = NULL, *out = NULL; 75 BIO *in = NULL, *out = NULL;
73 int topk8 = 0; 76 int topk8 = 0;
74 int pbe_nid = -1; 77 int pbe_nid = -1;
@@ -80,13 +83,13 @@ int MAIN(int argc, char **argv)
80 X509_SIG *p8; 83 X509_SIG *p8;
81 PKCS8_PRIV_KEY_INFO *p8inf; 84 PKCS8_PRIV_KEY_INFO *p8inf;
82 EVP_PKEY *pkey; 85 EVP_PKEY *pkey;
83 char pass[50]; 86 char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
84 int badarg = 0; 87 int badarg = 0;
85 if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE); 88 if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
86 informat=FORMAT_PEM; 89 informat=FORMAT_PEM;
87 outformat=FORMAT_PEM; 90 outformat=FORMAT_PEM;
88 ERR_load_crypto_strings(); 91 ERR_load_crypto_strings();
89 SSLeay_add_all_algorithms(); 92 OpenSSL_add_all_algorithms();
90 args = argv + 1; 93 args = argv + 1;
91 while (!badarg && *args && *args[0] == '-') { 94 while (!badarg && *args && *args[0] == '-') {
92 if (!strcmp(*args,"-v2")) { 95 if (!strcmp(*args,"-v2")) {
@@ -99,6 +102,16 @@ int MAIN(int argc, char **argv)
99 badarg = 1; 102 badarg = 1;
100 } 103 }
101 } else badarg = 1; 104 } else badarg = 1;
105 } else if (!strcmp(*args,"-v1")) {
106 if (args[1]) {
107 args++;
108 pbe_nid=OBJ_txt2nid(*args);
109 if(pbe_nid == NID_undef) {
110 BIO_printf(bio_err,
111 "Unknown PBE algorithm %s\n", *args);
112 badarg = 1;
113 }
114 } else badarg = 1;
102 } else if (!strcmp(*args,"-inform")) { 115 } else if (!strcmp(*args,"-inform")) {
103 if (args[1]) { 116 if (args[1]) {
104 args++; 117 args++;
@@ -113,6 +126,18 @@ int MAIN(int argc, char **argv)
113 else if (!strcmp (*args, "-noiter")) iter = 1; 126 else if (!strcmp (*args, "-noiter")) iter = 1;
114 else if (!strcmp (*args, "-nocrypt")) nocrypt = 1; 127 else if (!strcmp (*args, "-nocrypt")) nocrypt = 1;
115 else if (!strcmp (*args, "-nooct")) p8_broken = PKCS8_NO_OCTET; 128 else if (!strcmp (*args, "-nooct")) p8_broken = PKCS8_NO_OCTET;
129 else if (!strcmp (*args, "-nsdb")) p8_broken = PKCS8_NS_DB;
130 else if (!strcmp (*args, "-embed")) p8_broken = PKCS8_EMBEDDED_PARAM;
131 else if (!strcmp(*args,"-passin"))
132 {
133 if (!args[1]) goto bad;
134 passargin= *(++args);
135 }
136 else if (!strcmp(*args,"-passout"))
137 {
138 if (!args[1]) goto bad;
139 passargout= *(++args);
140 }
116 else if (!strcmp (*args, "-in")) { 141 else if (!strcmp (*args, "-in")) {
117 if (args[1]) { 142 if (args[1]) {
118 args++; 143 args++;
@@ -128,25 +153,36 @@ int MAIN(int argc, char **argv)
128 } 153 }
129 154
130 if (badarg) { 155 if (badarg) {
131 BIO_printf (bio_err, "Usage pkcs8 [options]\n"); 156 bad:
132 BIO_printf (bio_err, "where options are\n"); 157 BIO_printf(bio_err, "Usage pkcs8 [options]\n");
133 BIO_printf (bio_err, "-in file input file\n"); 158 BIO_printf(bio_err, "where options are\n");
134 BIO_printf (bio_err, "-inform X input format (DER or PEM)\n"); 159 BIO_printf(bio_err, "-in file input file\n");
135 BIO_printf (bio_err, "-outform X output format (DER or PEM)\n"); 160 BIO_printf(bio_err, "-inform X input format (DER or PEM)\n");
136 BIO_printf (bio_err, "-out file output file\n"); 161 BIO_printf(bio_err, "-passin arg input file pass phrase source\n");
137 BIO_printf (bio_err, "-topk8 output PKCS8 file\n"); 162 BIO_printf(bio_err, "-outform X output format (DER or PEM)\n");
138 BIO_printf (bio_err, "-nooct use (broken) no octet form\n"); 163 BIO_printf(bio_err, "-out file output file\n");
139 BIO_printf (bio_err, "-noiter use 1 as iteration count\n"); 164 BIO_printf(bio_err, "-passout arg output file pass phrase source\n");
140 BIO_printf (bio_err, "-nocrypt use or expect unencrypted private key\n"); 165 BIO_printf(bio_err, "-topk8 output PKCS8 file\n");
141 BIO_printf (bio_err, "-v2 alg use PKCS#5 v2.0 and cipher \"alg\"\n"); 166 BIO_printf(bio_err, "-nooct use (nonstandard) no octet format\n");
167 BIO_printf(bio_err, "-embed use (nonstandard) embedded DSA parameters format\n");
168 BIO_printf(bio_err, "-nsdb use (nonstandard) DSA Netscape DB format\n");
169 BIO_printf(bio_err, "-noiter use 1 as iteration count\n");
170 BIO_printf(bio_err, "-nocrypt use or expect unencrypted private key\n");
171 BIO_printf(bio_err, "-v2 alg use PKCS#5 v2.0 and cipher \"alg\"\n");
172 BIO_printf(bio_err, "-v1 obj use PKCS#5 v1.5 and cipher \"alg\"\n");
173 return (1);
174 }
175
176 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
177 BIO_printf(bio_err, "Error getting passwords\n");
142 return (1); 178 return (1);
143 } 179 }
144 180
145 if ((pbe_nid == -1) && !cipher) pbe_nid = NID_pbeWithMD5AndDES_CBC; 181 if ((pbe_nid == -1) && !cipher) pbe_nid = NID_pbeWithMD5AndDES_CBC;
146 182
147 if (infile) { 183 if (infile) {
148 if (!(in = BIO_new_file (infile, "rb"))) { 184 if (!(in = BIO_new_file(infile, "rb"))) {
149 BIO_printf (bio_err, 185 BIO_printf(bio_err,
150 "Can't open input file %s\n", infile); 186 "Can't open input file %s\n", infile);
151 return (1); 187 return (1);
152 } 188 }
@@ -154,25 +190,32 @@ int MAIN(int argc, char **argv)
154 190
155 if (outfile) { 191 if (outfile) {
156 if (!(out = BIO_new_file (outfile, "wb"))) { 192 if (!(out = BIO_new_file (outfile, "wb"))) {
157 BIO_printf (bio_err, 193 BIO_printf(bio_err,
158 "Can't open output file %s\n", outfile); 194 "Can't open output file %s\n", outfile);
159 return (1); 195 return (1);
160 } 196 }
161 } else out = BIO_new_fp (stdout, BIO_NOCLOSE); 197 } else out = BIO_new_fp (stdout, BIO_NOCLOSE);
162 198
163 if (topk8) { 199 if (topk8) {
164 if (!(pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL))) { 200 if(informat == FORMAT_PEM)
165 BIO_printf (bio_err, "Error reading key\n", outfile); 201 pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, passin);
202 else if(informat == FORMAT_ASN1)
203 pkey = d2i_PrivateKey_bio(in, NULL);
204 else {
205 BIO_printf(bio_err, "Bad format specified for key\n");
206 return (1);
207 }
208 if (!pkey) {
209 BIO_printf(bio_err, "Error reading key\n", outfile);
166 ERR_print_errors(bio_err); 210 ERR_print_errors(bio_err);
167 return (1); 211 return (1);
168 } 212 }
169 BIO_free(in); 213 BIO_free(in);
170 if (!(p8inf = EVP_PKEY2PKCS8(pkey))) { 214 if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
171 BIO_printf (bio_err, "Error converting key\n", outfile); 215 BIO_printf(bio_err, "Error converting key\n", outfile);
172 ERR_print_errors(bio_err); 216 ERR_print_errors(bio_err);
173 return (1); 217 return (1);
174 } 218 }
175 PKCS8_set_broken(p8inf, p8_broken);
176 if(nocrypt) { 219 if(nocrypt) {
177 if(outformat == FORMAT_PEM) 220 if(outformat == FORMAT_PEM)
178 PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8inf); 221 PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8inf);
@@ -183,17 +226,23 @@ int MAIN(int argc, char **argv)
183 return (1); 226 return (1);
184 } 227 }
185 } else { 228 } else {
186 EVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1); 229 if(passout) p8pass = passout;
230 else {
231 p8pass = pass;
232 EVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1);
233 }
234 app_RAND_load_file(NULL, bio_err, 0);
187 if (!(p8 = PKCS8_encrypt(pbe_nid, cipher, 235 if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
188 pass, strlen(pass), 236 p8pass, strlen(p8pass),
189 NULL, 0, iter, p8inf))) { 237 NULL, 0, iter, p8inf))) {
190 BIO_printf (bio_err, "Error encrypting key\n", 238 BIO_printf(bio_err, "Error encrypting key\n",
191 outfile); 239 outfile);
192 ERR_print_errors(bio_err); 240 ERR_print_errors(bio_err);
193 return (1); 241 return (1);
194 } 242 }
243 app_RAND_write_file(NULL, bio_err);
195 if(outformat == FORMAT_PEM) 244 if(outformat == FORMAT_PEM)
196 PEM_write_bio_PKCS8 (out, p8); 245 PEM_write_bio_PKCS8(out, p8);
197 else if(outformat == FORMAT_ASN1) 246 else if(outformat == FORMAT_ASN1)
198 i2d_PKCS8_bio(out, p8); 247 i2d_PKCS8_bio(out, p8);
199 else { 248 else {
@@ -205,6 +254,8 @@ int MAIN(int argc, char **argv)
205 PKCS8_PRIV_KEY_INFO_free (p8inf); 254 PKCS8_PRIV_KEY_INFO_free (p8inf);
206 EVP_PKEY_free(pkey); 255 EVP_PKEY_free(pkey);
207 BIO_free(out); 256 BIO_free(out);
257 if(passin) Free(passin);
258 if(passout) Free(passout);
208 return (0); 259 return (0);
209 } 260 }
210 261
@@ -232,8 +283,12 @@ int MAIN(int argc, char **argv)
232 ERR_print_errors(bio_err); 283 ERR_print_errors(bio_err);
233 return (1); 284 return (1);
234 } 285 }
235 EVP_read_pw_string(pass, 50, "Enter Password:", 0); 286 if(passin) p8pass = passin;
236 p8inf = M_PKCS8_decrypt(p8, pass, strlen(pass)); 287 else {
288 p8pass = pass;
289 EVP_read_pw_string(pass, 50, "Enter Password:", 0);
290 }
291 p8inf = M_PKCS8_decrypt(p8, p8pass, strlen(p8pass));
237 X509_SIG_free(p8); 292 X509_SIG_free(p8);
238 } 293 }
239 294
@@ -253,7 +308,15 @@ int MAIN(int argc, char **argv)
253 BIO_printf(bio_err, "Warning: broken key encoding: "); 308 BIO_printf(bio_err, "Warning: broken key encoding: ");
254 switch (p8inf->broken) { 309 switch (p8inf->broken) {
255 case PKCS8_NO_OCTET: 310 case PKCS8_NO_OCTET:
256 BIO_printf(bio_err, "No Octet String\n"); 311 BIO_printf(bio_err, "No Octet String in PrivateKey\n");
312 break;
313
314 case PKCS8_EMBEDDED_PARAM:
315 BIO_printf(bio_err, "DSA parameters included in PrivateKey\n");
316 break;
317
318 case PKCS8_NS_DB:
319 BIO_printf(bio_err, "DSA public key include in PrivateKey\n");
257 break; 320 break;
258 321
259 default: 322 default:
@@ -263,12 +326,20 @@ int MAIN(int argc, char **argv)
263 } 326 }
264 327
265 PKCS8_PRIV_KEY_INFO_free(p8inf); 328 PKCS8_PRIV_KEY_INFO_free(p8inf);
266 329 if(outformat == FORMAT_PEM)
267 PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, NULL); 330 PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, passout);
331 else if(outformat == FORMAT_ASN1)
332 i2d_PrivateKey_bio(out, pkey);
333 else {
334 BIO_printf(bio_err, "Bad format specified for key\n");
335 return (1);
336 }
268 337
269 EVP_PKEY_free(pkey); 338 EVP_PKEY_free(pkey);
270 BIO_free(out); 339 BIO_free(out);
271 BIO_free(in); 340 BIO_free(in);
341 if(passin) Free(passin);
342 if(passout) Free(passout);
272 343
273 return (0); 344 return (0);
274} 345}
diff --git a/src/lib/libssl/src/apps/progs.h b/src/lib/libssl/src/apps/progs.h
index df067182bc..ffb21bd64f 100644
--- a/src/lib/libssl/src/apps/progs.h
+++ b/src/lib/libssl/src/apps/progs.h
@@ -1,11 +1,14 @@
1/* This file was generated by progs.pl. */ 1/* apps/progs.h */
2/* automatically generated by progs.pl for openssl.c */
2 3
3extern int verify_main(int argc,char *argv[]); 4extern int verify_main(int argc,char *argv[]);
4extern int asn1parse_main(int argc,char *argv[]); 5extern int asn1parse_main(int argc,char *argv[]);
5extern int req_main(int argc,char *argv[]); 6extern int req_main(int argc,char *argv[]);
6extern int dgst_main(int argc,char *argv[]); 7extern int dgst_main(int argc,char *argv[]);
7extern int dh_main(int argc,char *argv[]); 8extern int dh_main(int argc,char *argv[]);
9extern int dhparam_main(int argc,char *argv[]);
8extern int enc_main(int argc,char *argv[]); 10extern int enc_main(int argc,char *argv[]);
11extern int passwd_main(int argc,char *argv[]);
9extern int gendh_main(int argc,char *argv[]); 12extern int gendh_main(int argc,char *argv[]);
10extern int errstr_main(int argc,char *argv[]); 13extern int errstr_main(int argc,char *argv[]);
11extern int ca_main(int argc,char *argv[]); 14extern int ca_main(int argc,char *argv[]);
@@ -28,8 +31,8 @@ extern int ciphers_main(int argc,char *argv[]);
28extern int nseq_main(int argc,char *argv[]); 31extern int nseq_main(int argc,char *argv[]);
29extern int pkcs12_main(int argc,char *argv[]); 32extern int pkcs12_main(int argc,char *argv[]);
30extern int pkcs8_main(int argc,char *argv[]); 33extern int pkcs8_main(int argc,char *argv[]);
31 34extern int spkac_main(int argc,char *argv[]);
32#ifdef SSLEAY_SRC /* Defined only in openssl.c. */ 35extern int smime_main(int argc,char *argv[]);
33 36
34#define FUNC_TYPE_GENERAL 1 37#define FUNC_TYPE_GENERAL 1
35#define FUNC_TYPE_MD 2 38#define FUNC_TYPE_MD 2
@@ -49,7 +52,11 @@ FUNCTION functions[] = {
49#ifndef NO_DH 52#ifndef NO_DH
50 {FUNC_TYPE_GENERAL,"dh",dh_main}, 53 {FUNC_TYPE_GENERAL,"dh",dh_main},
51#endif 54#endif
55#ifndef NO_DH
56 {FUNC_TYPE_GENERAL,"dhparam",dhparam_main},
57#endif
52 {FUNC_TYPE_GENERAL,"enc",enc_main}, 58 {FUNC_TYPE_GENERAL,"enc",enc_main},
59 {FUNC_TYPE_GENERAL,"passwd",passwd_main},
53#ifndef NO_DH 60#ifndef NO_DH
54 {FUNC_TYPE_GENERAL,"gendh",gendh_main}, 61 {FUNC_TYPE_GENERAL,"gendh",gendh_main},
55#endif 62#endif
@@ -72,14 +79,14 @@ FUNCTION functions[] = {
72#ifndef NO_DSA 79#ifndef NO_DSA
73 {FUNC_TYPE_GENERAL,"gendsa",gendsa_main}, 80 {FUNC_TYPE_GENERAL,"gendsa",gendsa_main},
74#endif 81#endif
75#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3)) 82#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
76 {FUNC_TYPE_GENERAL,"s_server",s_server_main}, 83 {FUNC_TYPE_GENERAL,"s_server",s_server_main},
77#endif 84#endif
78#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3)) 85#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
79 {FUNC_TYPE_GENERAL,"s_client",s_client_main}, 86 {FUNC_TYPE_GENERAL,"s_client",s_client_main},
80#endif 87#endif
81 {FUNC_TYPE_GENERAL,"speed",speed_main}, 88 {FUNC_TYPE_GENERAL,"speed",speed_main},
82#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3)) 89#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
83 {FUNC_TYPE_GENERAL,"s_time",s_time_main}, 90 {FUNC_TYPE_GENERAL,"s_time",s_time_main},
84#endif 91#endif
85 {FUNC_TYPE_GENERAL,"version",version_main}, 92 {FUNC_TYPE_GENERAL,"version",version_main},
@@ -94,6 +101,8 @@ FUNCTION functions[] = {
94 {FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main}, 101 {FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main},
95#endif 102#endif
96 {FUNC_TYPE_GENERAL,"pkcs8",pkcs8_main}, 103 {FUNC_TYPE_GENERAL,"pkcs8",pkcs8_main},
104 {FUNC_TYPE_GENERAL,"spkac",spkac_main},
105 {FUNC_TYPE_GENERAL,"smime",smime_main},
97 {FUNC_TYPE_MD,"md2",dgst_main}, 106 {FUNC_TYPE_MD,"md2",dgst_main},
98 {FUNC_TYPE_MD,"md5",dgst_main}, 107 {FUNC_TYPE_MD,"md5",dgst_main},
99 {FUNC_TYPE_MD,"sha",dgst_main}, 108 {FUNC_TYPE_MD,"sha",dgst_main},
@@ -116,6 +125,9 @@ FUNCTION functions[] = {
116#ifndef NO_RC4 125#ifndef NO_RC4
117 {FUNC_TYPE_CIPHER,"rc4",enc_main}, 126 {FUNC_TYPE_CIPHER,"rc4",enc_main},
118#endif 127#endif
128#ifndef NO_RC4
129 {FUNC_TYPE_CIPHER,"rc4-40",enc_main},
130#endif
119#ifndef NO_RC2 131#ifndef NO_RC2
120 {FUNC_TYPE_CIPHER,"rc2",enc_main}, 132 {FUNC_TYPE_CIPHER,"rc2",enc_main},
121#endif 133#endif
@@ -188,6 +200,12 @@ FUNCTION functions[] = {
188#ifndef NO_RC2 200#ifndef NO_RC2
189 {FUNC_TYPE_CIPHER,"rc2-ofb",enc_main}, 201 {FUNC_TYPE_CIPHER,"rc2-ofb",enc_main},
190#endif 202#endif
203#ifndef NO_RC2
204 {FUNC_TYPE_CIPHER,"rc2-64-cbc",enc_main},
205#endif
206#ifndef NO_RC2
207 {FUNC_TYPE_CIPHER,"rc2-40-cbc",enc_main},
208#endif
191#ifndef NO_BF 209#ifndef NO_BF
192 {FUNC_TYPE_CIPHER,"bf-cbc",enc_main}, 210 {FUNC_TYPE_CIPHER,"bf-cbc",enc_main},
193#endif 211#endif
@@ -229,5 +247,3 @@ FUNCTION functions[] = {
229#endif 247#endif
230 {0,NULL,NULL} 248 {0,NULL,NULL}
231 }; 249 };
232#endif
233
diff --git a/src/lib/libssl/src/apps/progs.pl b/src/lib/libssl/src/apps/progs.pl
index 7a69fc7b18..9842d2ace7 100644
--- a/src/lib/libssl/src/apps/progs.pl
+++ b/src/lib/libssl/src/apps/progs.pl
@@ -1,6 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3print "/* This file was generated by progs.pl. */\n\n"; 3print "/* apps/progs.h */\n";
4print "/* automatically generated by progs.pl for openssl.c */\n\n";
4 5
5grep(s/^asn1pars$/asn1parse/,@ARGV); 6grep(s/^asn1pars$/asn1parse/,@ARGV);
6 7
@@ -9,8 +10,6 @@ foreach (@ARGV)
9 10
10print <<'EOF'; 11print <<'EOF';
11 12
12#ifdef SSLEAY_SRC /* Defined only in openssl.c. */
13
14#define FUNC_TYPE_GENERAL 1 13#define FUNC_TYPE_GENERAL 1
15#define FUNC_TYPE_MD 2 14#define FUNC_TYPE_MD 2
16#define FUNC_TYPE_CIPHER 3 15#define FUNC_TYPE_CIPHER 3
@@ -29,13 +28,15 @@ foreach (@ARGV)
29 push(@files,$_); 28 push(@files,$_);
30 $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n"; 29 $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
31 if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/)) 30 if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
32 { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))\n${str}#endif\n"; } 31 { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))\n${str}#endif\n"; }
33 elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) ) 32 elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) )
34 { print "#ifndef NO_RSA\n${str}#endif\n"; } 33 { print "#ifndef NO_RSA\n${str}#endif\n"; }
35 elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/)) 34 elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
36 { print "#ifndef NO_DSA\n${str}#endif\n"; } 35 { print "#ifndef NO_DSA\n${str}#endif\n"; }
37 elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/)) 36 elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/))
38 { print "#ifndef NO_DH\n${str}#endif\n"; } 37 { print "#ifndef NO_DH\n${str}#endif\n"; }
38 elsif ( ($_ =~ /^pkcs12$/))
39 { print "#if !defined(NO_DES) && !defined(NO_SHA1)\n${str}#endif\n"; }
39 else 40 else
40 { print $str; } 41 { print $str; }
41 } 42 }
@@ -48,13 +49,14 @@ foreach ("md2","md5","sha","sha1","mdc2","rmd160")
48 49
49foreach ( 50foreach (
50 "base64", 51 "base64",
51 "des", "des3", "desx", "idea", "rc4", "rc2","bf","cast","rc5", 52 "des", "des3", "desx", "idea", "rc4", "rc4-40",
53 "rc2", "bf", "cast", "rc5",
52 "des-ecb", "des-ede", "des-ede3", 54 "des-ecb", "des-ede", "des-ede3",
53 "des-cbc", "des-ede-cbc","des-ede3-cbc", 55 "des-cbc", "des-ede-cbc","des-ede3-cbc",
54 "des-cfb", "des-ede-cfb","des-ede3-cfb", 56 "des-cfb", "des-ede-cfb","des-ede3-cfb",
55 "des-ofb", "des-ede-ofb","des-ede3-ofb", 57 "des-ofb", "des-ede-ofb","des-ede3-ofb",
56 "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb", 58 "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
57 "rc2-cbc", "rc2-ecb", "rc2-cfb", "rc2-ofb", 59 "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
58 "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb", 60 "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
59 "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb", 61 "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
60 "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb") 62 "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb")
@@ -73,5 +75,3 @@ foreach (
73 } 75 }
74 76
75print "\t{0,NULL,NULL}\n\t};\n"; 77print "\t{0,NULL,NULL}\n\t};\n";
76print "#endif\n\n";
77
diff --git a/src/lib/libssl/src/apps/req.c b/src/lib/libssl/src/apps/req.c
index 463ac156ea..97bb0d0ed8 100644
--- a/src/lib/libssl/src/apps/req.c
+++ b/src/lib/libssl/src/apps/req.c
@@ -66,7 +66,6 @@
66#include "apps.h" 66#include "apps.h"
67#include <openssl/bio.h> 67#include <openssl/bio.h>
68#include <openssl/evp.h> 68#include <openssl/evp.h>
69#include <openssl/rand.h>
70#include <openssl/conf.h> 69#include <openssl/conf.h>
71#include <openssl/err.h> 70#include <openssl/err.h>
72#include <openssl/asn1.h> 71#include <openssl/asn1.h>
@@ -79,9 +78,12 @@
79 78
80#define BITS "default_bits" 79#define BITS "default_bits"
81#define KEYFILE "default_keyfile" 80#define KEYFILE "default_keyfile"
81#define PROMPT "prompt"
82#define DISTINGUISHED_NAME "distinguished_name" 82#define DISTINGUISHED_NAME "distinguished_name"
83#define ATTRIBUTES "attributes" 83#define ATTRIBUTES "attributes"
84#define V3_EXTENSIONS "x509_extensions" 84#define V3_EXTENSIONS "x509_extensions"
85#define REQ_EXTENSIONS "req_extensions"
86#define STRING_MASK "string_mask"
85 87
86#define DEFAULT_KEY_LENGTH 512 88#define DEFAULT_KEY_LENGTH 512
87#define MIN_KEY_LENGTH 384 89#define MIN_KEY_LENGTH 384
@@ -89,7 +91,7 @@
89#undef PROG 91#undef PROG
90#define PROG req_main 92#define PROG req_main
91 93
92/* -inform arg - input format - default PEM (one of DER, TXT or PEM) 94/* -inform arg - input format - default PEM (DER or PEM)
93 * -outform arg - output format - default PEM 95 * -outform arg - output format - default PEM
94 * -in arg - input file - default stdin 96 * -in arg - input file - default stdin
95 * -out arg - output file - default stdout 97 * -out arg - output file - default stdout
@@ -108,13 +110,20 @@
108 */ 110 */
109 111
110static int make_REQ(X509_REQ *req,EVP_PKEY *pkey,int attribs); 112static int make_REQ(X509_REQ *req,EVP_PKEY *pkey,int attribs);
111static int add_attribute_object(STACK_OF(X509_ATTRIBUTE) *n, char *text, 113static int prompt_info(X509_REQ *req,
114 STACK_OF(CONF_VALUE) *dn_sk, char *dn_sect,
115 STACK_OF(CONF_VALUE) *attr_sk, char *attr_sect, int attribs);
116static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *sk,
117 STACK_OF(CONF_VALUE) *attr, int attribs);
118static int add_attribute_object(X509_REQ *req, char *text,
112 char *def, char *value, int nid, int min, 119 char *def, char *value, int nid, int min,
113 int max); 120 int max);
114static int add_DN_object(X509_NAME *n, char *text, char *def, char *value, 121static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
115 int nid,int min,int max); 122 int nid,int min,int max);
123#ifndef NO_RSA
116static void MS_CALLBACK req_cb(int p,int n,void *arg); 124static void MS_CALLBACK req_cb(int p,int n,void *arg);
117static int req_fix_data(int nid,int *type,int len,int min,int max); 125#endif
126static int req_check_len(int len,int min,int max);
118static int check_end(char *str, char *end); 127static int check_end(char *str, char *end);
119static int add_oid_section(LHASH *conf); 128static int add_oid_section(LHASH *conf);
120#ifndef MONOLITH 129#ifndef MONOLITH
@@ -127,6 +136,8 @@ static LHASH *req_conf=NULL;
127#define TYPE_DSA 2 136#define TYPE_DSA 2
128#define TYPE_DH 3 137#define TYPE_DH 3
129 138
139int MAIN(int, char **);
140
130int MAIN(int argc, char **argv) 141int MAIN(int argc, char **argv)
131 { 142 {
132#ifndef NO_DSA 143#ifndef NO_DSA
@@ -139,17 +150,21 @@ int MAIN(int argc, char **argv)
139 int i,badops=0,newreq=0,newkey= -1,pkey_type=0; 150 int i,badops=0,newreq=0,newkey= -1,pkey_type=0;
140 BIO *in=NULL,*out=NULL; 151 BIO *in=NULL,*out=NULL;
141 int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM; 152 int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM;
142 int nodes=0,kludge=0; 153 int nodes=0,kludge=0,newhdr=0;
143 char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL; 154 char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL;
144 char *extensions = NULL; 155 char *extensions = NULL;
156 char *req_exts = NULL;
145 EVP_CIPHER *cipher=NULL; 157 EVP_CIPHER *cipher=NULL;
146 int modulus=0; 158 int modulus=0;
159 char *passargin = NULL, *passargout = NULL;
160 char *passin = NULL, *passout = NULL;
147 char *p; 161 char *p;
148 const EVP_MD *md_alg=NULL,*digest=EVP_md5(); 162 const EVP_MD *md_alg=NULL,*digest=EVP_md5();
149#ifndef MONOLITH 163#ifndef MONOLITH
150 MS_STATIC char config_name[256]; 164 MS_STATIC char config_name[256];
151#endif 165#endif
152 166
167 req_conf = NULL;
153#ifndef NO_DES 168#ifndef NO_DES
154 cipher=EVP_des_ede3_cbc(); 169 cipher=EVP_des_ede3_cbc();
155#endif 170#endif
@@ -214,6 +229,16 @@ int MAIN(int argc, char **argv)
214 if (--argc < 1) goto bad; 229 if (--argc < 1) goto bad;
215 keyout= *(++argv); 230 keyout= *(++argv);
216 } 231 }
232 else if (strcmp(*argv,"-passin") == 0)
233 {
234 if (--argc < 1) goto bad;
235 passargin= *(++argv);
236 }
237 else if (strcmp(*argv,"-passout") == 0)
238 {
239 if (--argc < 1) goto bad;
240 passargout= *(++argv);
241 }
217 else if (strcmp(*argv,"-newkey") == 0) 242 else if (strcmp(*argv,"-newkey") == 0)
218 { 243 {
219 int is_numeric; 244 int is_numeric;
@@ -281,6 +306,8 @@ int MAIN(int argc, char **argv)
281 306
282 newreq=1; 307 newreq=1;
283 } 308 }
309 else if (strcmp(*argv,"-newhdr") == 0)
310 newhdr=1;
284 else if (strcmp(*argv,"-modulus") == 0) 311 else if (strcmp(*argv,"-modulus") == 0)
285 modulus=1; 312 modulus=1;
286 else if (strcmp(*argv,"-verify") == 0) 313 else if (strcmp(*argv,"-verify") == 0)
@@ -308,8 +335,17 @@ int MAIN(int argc, char **argv)
308 /* ok */ 335 /* ok */
309 digest=md_alg; 336 digest=md_alg;
310 } 337 }
338 else if (strcmp(*argv,"-extensions") == 0)
339 {
340 if (--argc < 1) goto bad;
341 extensions = *(++argv);
342 }
343 else if (strcmp(*argv,"-reqexts") == 0)
344 {
345 if (--argc < 1) goto bad;
346 req_exts = *(++argv);
347 }
311 else 348 else
312
313 { 349 {
314 BIO_printf(bio_err,"unknown option %s\n",*argv); 350 BIO_printf(bio_err,"unknown option %s\n",*argv);
315 badops=1; 351 badops=1;
@@ -324,8 +360,8 @@ int MAIN(int argc, char **argv)
324bad: 360bad:
325 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog); 361 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
326 BIO_printf(bio_err,"where options are\n"); 362 BIO_printf(bio_err,"where options are\n");
327 BIO_printf(bio_err," -inform arg input format - one of DER TXT PEM\n"); 363 BIO_printf(bio_err," -inform arg input format - DER or PEM\n");
328 BIO_printf(bio_err," -outform arg output format - one of DER TXT PEM\n"); 364 BIO_printf(bio_err," -outform arg output format - DER or PEM\n");
329 BIO_printf(bio_err," -in arg input file\n"); 365 BIO_printf(bio_err," -in arg input file\n");
330 BIO_printf(bio_err," -out arg output file\n"); 366 BIO_printf(bio_err," -out arg output file\n");
331 BIO_printf(bio_err," -text text form of request\n"); 367 BIO_printf(bio_err," -text text form of request\n");
@@ -344,16 +380,21 @@ bad:
344 BIO_printf(bio_err," -new new request.\n"); 380 BIO_printf(bio_err," -new new request.\n");
345 BIO_printf(bio_err," -x509 output a x509 structure instead of a cert. req.\n"); 381 BIO_printf(bio_err," -x509 output a x509 structure instead of a cert. req.\n");
346 BIO_printf(bio_err," -days number of days a x509 generated by -x509 is valid for.\n"); 382 BIO_printf(bio_err," -days number of days a x509 generated by -x509 is valid for.\n");
383 BIO_printf(bio_err," -newhdr output \"NEW\" in the header lines\n");
347 BIO_printf(bio_err," -asn1-kludge Output the 'request' in a format that is wrong but some CA's\n"); 384 BIO_printf(bio_err," -asn1-kludge Output the 'request' in a format that is wrong but some CA's\n");
348 BIO_printf(bio_err," have been reported as requiring\n"); 385 BIO_printf(bio_err," have been reported as requiring\n");
349 BIO_printf(bio_err," [ It is now always turned on but can be turned off with -no-asn1-kludge ]\n"); 386 BIO_printf(bio_err," -extensions .. specify certificate extension section (override value in config file)\n");
387 BIO_printf(bio_err," -reqexts .. specify request extension section (override value in config file)\n");
350 goto end; 388 goto end;
351 } 389 }
352 390
353 ERR_load_crypto_strings(); 391 ERR_load_crypto_strings();
354 X509V3_add_standard_extensions(); 392 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
393 BIO_printf(bio_err, "Error getting passwords\n");
394 goto end;
395 }
355 396
356#ifndef MONOLITH 397#ifndef MONOLITH /* else this has happened in openssl.c (global `config') */
357 /* Lets load up our environment a little */ 398 /* Lets load up our environment a little */
358 p=getenv("OPENSSL_CONF"); 399 p=getenv("OPENSSL_CONF");
359 if (p == NULL) 400 if (p == NULL)
@@ -367,7 +408,7 @@ bad:
367 strcat(config_name,OPENSSL_CONF); 408 strcat(config_name,OPENSSL_CONF);
368 p=config_name; 409 p=config_name;
369 } 410 }
370 default_config_file=p; 411 default_config_file=p;
371 config=CONF_load(config,p,NULL); 412 config=CONF_load(config,p,NULL);
372#endif 413#endif
373 414
@@ -425,7 +466,8 @@ bad:
425 digest=md_alg; 466 digest=md_alg;
426 } 467 }
427 468
428 extensions = CONF_get_string(req_conf, SECTION, V3_EXTENSIONS); 469 if(!extensions)
470 extensions = CONF_get_string(req_conf, SECTION, V3_EXTENSIONS);
429 if(extensions) { 471 if(extensions) {
430 /* Check syntax of file */ 472 /* Check syntax of file */
431 X509V3_CTX ctx; 473 X509V3_CTX ctx;
@@ -438,6 +480,34 @@ bad:
438 } 480 }
439 } 481 }
440 482
483 if(!passin)
484 passin = CONF_get_string(req_conf, SECTION, "input_password");
485
486 if(!passout)
487 passout = CONF_get_string(req_conf, SECTION, "output_password");
488
489 p = CONF_get_string(req_conf, SECTION, STRING_MASK);
490
491 if(p && !ASN1_STRING_set_default_mask_asc(p)) {
492 BIO_printf(bio_err, "Invalid global string mask setting %s\n", p);
493 goto end;
494 }
495
496 if(!req_exts)
497 req_exts = CONF_get_string(req_conf, SECTION, REQ_EXTENSIONS);
498 if(req_exts) {
499 /* Check syntax of file */
500 X509V3_CTX ctx;
501 X509V3_set_ctx_test(&ctx);
502 X509V3_set_conf_lhash(&ctx, req_conf);
503 if(!X509V3_EXT_add_conf(req_conf, &ctx, req_exts, NULL)) {
504 BIO_printf(bio_err,
505 "Error Loading request extension section %s\n",
506 req_exts);
507 goto end;
508 }
509 }
510
441 in=BIO_new(BIO_s_file()); 511 in=BIO_new(BIO_s_file());
442 out=BIO_new(BIO_s_file()); 512 out=BIO_new(BIO_s_file());
443 if ((in == NULL) || (out == NULL)) 513 if ((in == NULL) || (out == NULL))
@@ -451,11 +521,12 @@ bad:
451 goto end; 521 goto end;
452 } 522 }
453 523
454/* if (keyform == FORMAT_ASN1) 524 if (keyform == FORMAT_ASN1)
455 rsa=d2i_RSAPrivateKey_bio(in,NULL); 525 pkey=d2i_PrivateKey_bio(in,NULL);
456 else */ 526 else if (keyform == FORMAT_PEM)
457 if (keyform == FORMAT_PEM) 527 {
458 pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL); 528 pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,passin);
529 }
459 else 530 else
460 { 531 {
461 BIO_printf(bio_err,"bad input format specified for X509 request\n"); 532 BIO_printf(bio_err,"bad input format specified for X509 request\n");
@@ -471,25 +542,9 @@ bad:
471 542
472 if (newreq && (pkey == NULL)) 543 if (newreq && (pkey == NULL))
473 { 544 {
474 char *randfile; 545 char *randfile = CONF_get_string(req_conf,SECTION,"RANDFILE");
475 char buffer[200]; 546 app_RAND_load_file(randfile, bio_err, 0);
476 547
477 if ((randfile=CONF_get_string(req_conf,SECTION,"RANDFILE")) == NULL)
478 randfile=RAND_file_name(buffer,200);
479#ifdef WINDOWS
480 BIO_printf(bio_err,"Loading 'screen' into random state -");
481 BIO_flush(bio_err);
482 RAND_screen();
483 BIO_printf(bio_err," done\n");
484#endif
485 if ((randfile == NULL) || !RAND_load_file(randfile,1024L*1024L))
486 {
487 BIO_printf(bio_err,"unable to load 'random state'\n");
488 BIO_printf(bio_err,"What this means is that the random number generator has not been seeded\n");
489 BIO_printf(bio_err,"with much random data.\n");
490 BIO_printf(bio_err,"Consider setting the RANDFILE environment variable to point at a file that\n");
491 BIO_printf(bio_err,"'random' data can be kept in.\n");
492 }
493 if (newkey <= 0) 548 if (newkey <= 0)
494 { 549 {
495 newkey=(int)CONF_get_number(req_conf,SECTION,BITS); 550 newkey=(int)CONF_get_number(req_conf,SECTION,BITS);
@@ -527,8 +582,7 @@ bad:
527 } 582 }
528#endif 583#endif
529 584
530 if ((randfile == NULL) || (RAND_write_file(randfile) == 0)) 585 app_RAND_write_file(randfile, bio_err);
531 BIO_printf(bio_err,"unable to write 'random state'\n");
532 586
533 if (pkey == NULL) goto end; 587 if (pkey == NULL) goto end;
534 588
@@ -560,7 +614,7 @@ bad:
560 i=0; 614 i=0;
561loop: 615loop:
562 if (!PEM_write_bio_PrivateKey(out,pkey,cipher, 616 if (!PEM_write_bio_PrivateKey(out,pkey,cipher,
563 NULL,0,NULL,NULL)) 617 NULL,0,NULL,passout))
564 { 618 {
565 if ((ERR_GET_REASON(ERR_peek_error()) == 619 if ((ERR_GET_REASON(ERR_peek_error()) ==
566 PEM_R_PROBLEMS_GETTING_PASSWORD) && (i < 3)) 620 PEM_R_PROBLEMS_GETTING_PASSWORD) && (i < 3))
@@ -677,6 +731,22 @@ loop:
677 } 731 }
678 else 732 else
679 { 733 {
734 X509V3_CTX ext_ctx;
735
736 /* Set up V3 context struct */
737
738 X509V3_set_ctx(&ext_ctx, NULL, NULL, req, NULL, 0);
739 X509V3_set_conf_lhash(&ext_ctx, req_conf);
740
741 /* Add extensions */
742 if(req_exts && !X509V3_EXT_REQ_add_conf(req_conf,
743 &ext_ctx, req_exts, req))
744 {
745 BIO_printf(bio_err,
746 "Error Loading extension section %s\n",
747 req_exts);
748 goto end;
749 }
680 if (!(i=X509_REQ_sign(req,pkey,digest))) 750 if (!(i=X509_REQ_sign(req,pkey,digest)))
681 goto end; 751 goto end;
682 } 752 }
@@ -767,9 +837,10 @@ loop:
767 { 837 {
768 if (outformat == FORMAT_ASN1) 838 if (outformat == FORMAT_ASN1)
769 i=i2d_X509_REQ_bio(out,req); 839 i=i2d_X509_REQ_bio(out,req);
770 else if (outformat == FORMAT_PEM) 840 else if (outformat == FORMAT_PEM) {
771 i=PEM_write_bio_X509_REQ(out,req); 841 if(newhdr) i=PEM_write_bio_X509_REQ_NEW(out,req);
772 else { 842 else i=PEM_write_bio_X509_REQ(out,req);
843 } else {
773 BIO_printf(bio_err,"bad output format specified for outfile\n"); 844 BIO_printf(bio_err,"bad output format specified for outfile\n");
774 goto end; 845 goto end;
775 } 846 }
@@ -807,7 +878,8 @@ end:
807 EVP_PKEY_free(pkey); 878 EVP_PKEY_free(pkey);
808 X509_REQ_free(req); 879 X509_REQ_free(req);
809 X509_free(x509ss); 880 X509_free(x509ss);
810 X509V3_EXT_cleanup(); 881 if(passin) Free(passin);
882 if(passout) Free(passout);
811 OBJ_cleanup(); 883 OBJ_cleanup();
812#ifndef NO_DSA 884#ifndef NO_DSA
813 if (dsa_params != NULL) DSA_free(dsa_params); 885 if (dsa_params != NULL) DSA_free(dsa_params);
@@ -818,43 +890,67 @@ end:
818static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, int attribs) 890static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, int attribs)
819 { 891 {
820 int ret=0,i; 892 int ret=0,i;
821 char *p,*q; 893 char no_prompt = 0;
822 X509_REQ_INFO *ri; 894 STACK_OF(CONF_VALUE) *dn_sk, *attr_sk = NULL;
823 char buf[100]; 895 char *tmp, *dn_sect,*attr_sect;
824 int nid,min,max; 896
825 char *type,*def,*tmp,*value,*tmp_attr; 897 tmp=CONF_get_string(req_conf,SECTION,PROMPT);
826 STACK_OF(CONF_VALUE) *sk, *attr=NULL; 898 if((tmp != NULL) && !strcmp(tmp, "no")) no_prompt = 1;
827 CONF_VALUE *v; 899
828 900 dn_sect=CONF_get_string(req_conf,SECTION,DISTINGUISHED_NAME);
829 tmp=CONF_get_string(req_conf,SECTION,DISTINGUISHED_NAME); 901 if (dn_sect == NULL)
830 if (tmp == NULL)
831 { 902 {
832 BIO_printf(bio_err,"unable to find '%s' in config\n", 903 BIO_printf(bio_err,"unable to find '%s' in config\n",
833 DISTINGUISHED_NAME); 904 DISTINGUISHED_NAME);
834 goto err; 905 goto err;
835 } 906 }
836 sk=CONF_get_section(req_conf,tmp); 907 dn_sk=CONF_get_section(req_conf,dn_sect);
837 if (sk == NULL) 908 if (dn_sk == NULL)
838 { 909 {
839 BIO_printf(bio_err,"unable to get '%s' section\n",tmp); 910 BIO_printf(bio_err,"unable to get '%s' section\n",dn_sect);
840 goto err; 911 goto err;
841 } 912 }
842 913
843 tmp_attr=CONF_get_string(req_conf,SECTION,ATTRIBUTES); 914 attr_sect=CONF_get_string(req_conf,SECTION,ATTRIBUTES);
844 if (tmp_attr == NULL) 915 if (attr_sect == NULL)
845 attr=NULL; 916 attr_sk=NULL;
846 else 917 else
847 { 918 {
848 attr=CONF_get_section(req_conf,tmp_attr); 919 attr_sk=CONF_get_section(req_conf,attr_sect);
849 if (attr == NULL) 920 if (attr_sk == NULL)
850 { 921 {
851 BIO_printf(bio_err,"unable to get '%s' section\n",tmp_attr); 922 BIO_printf(bio_err,"unable to get '%s' section\n",attr_sect);
852 goto err; 923 goto err;
853 } 924 }
854 } 925 }
855 926
856 ri=req->req_info; 927 /* setup version number */
928 if (!X509_REQ_set_version(req,0L)) goto err; /* version 1 */
929
930 if(no_prompt) i = auto_info(req, dn_sk, attr_sk, attribs);
931 else i = prompt_info(req, dn_sk, dn_sect, attr_sk, attr_sect, attribs);
932 if(!i) goto err;
933
934 X509_REQ_set_pubkey(req,pkey);
857 935
936 ret=1;
937err:
938 return(ret);
939 }
940
941
942static int prompt_info(X509_REQ *req,
943 STACK_OF(CONF_VALUE) *dn_sk, char *dn_sect,
944 STACK_OF(CONF_VALUE) *attr_sk, char *attr_sect, int attribs)
945 {
946 int i;
947 char *p,*q;
948 char buf[100];
949 int nid,min,max;
950 char *type,*def,*value;
951 CONF_VALUE *v;
952 X509_NAME *subj;
953 subj = X509_REQ_get_subject_name(req);
858 BIO_printf(bio_err,"You are about to be asked to enter information that will be incorporated\n"); 954 BIO_printf(bio_err,"You are about to be asked to enter information that will be incorporated\n");
859 BIO_printf(bio_err,"into your certificate request.\n"); 955 BIO_printf(bio_err,"into your certificate request.\n");
860 BIO_printf(bio_err,"What you are about to enter is what is called a Distinguished Name or a DN.\n"); 956 BIO_printf(bio_err,"What you are about to enter is what is called a Distinguished Name or a DN.\n");
@@ -863,18 +959,16 @@ static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, int attribs)
863 BIO_printf(bio_err,"If you enter '.', the field will be left blank.\n"); 959 BIO_printf(bio_err,"If you enter '.', the field will be left blank.\n");
864 BIO_printf(bio_err,"-----\n"); 960 BIO_printf(bio_err,"-----\n");
865 961
866 /* setup version number */
867 if (!ASN1_INTEGER_set(ri->version,0L)) goto err; /* version 1 */
868 962
869 if (sk_CONF_VALUE_num(sk)) 963 if (sk_CONF_VALUE_num(dn_sk))
870 { 964 {
871 i= -1; 965 i= -1;
872start: for (;;) 966start: for (;;)
873 { 967 {
874 i++; 968 i++;
875 if (sk_CONF_VALUE_num(sk) <= i) break; 969 if (sk_CONF_VALUE_num(dn_sk) <= i) break;
876 970
877 v=sk_CONF_VALUE_value(sk,i); 971 v=sk_CONF_VALUE_value(dn_sk,i);
878 p=q=NULL; 972 p=q=NULL;
879 type=v->name; 973 type=v->name;
880 if(!check_end(type,"_min") || !check_end(type,"_max") || 974 if(!check_end(type,"_min") || !check_end(type,"_max") ||
@@ -893,32 +987,32 @@ start: for (;;)
893 /* If OBJ not recognised ignore it */ 987 /* If OBJ not recognised ignore it */
894 if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start; 988 if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;
895 sprintf(buf,"%s_default",v->name); 989 sprintf(buf,"%s_default",v->name);
896 if ((def=CONF_get_string(req_conf,tmp,buf)) == NULL) 990 if ((def=CONF_get_string(req_conf,dn_sect,buf)) == NULL)
897 def=""; 991 def="";
898 992
899 sprintf(buf,"%s_value",v->name); 993 sprintf(buf,"%s_value",v->name);
900 if ((value=CONF_get_string(req_conf,tmp,buf)) == NULL) 994 if ((value=CONF_get_string(req_conf,dn_sect,buf)) == NULL)
901 value=NULL; 995 value=NULL;
902 996
903 sprintf(buf,"%s_min",v->name); 997 sprintf(buf,"%s_min",v->name);
904 min=(int)CONF_get_number(req_conf,tmp,buf); 998 min=(int)CONF_get_number(req_conf,dn_sect,buf);
905 999
906 sprintf(buf,"%s_max",v->name); 1000 sprintf(buf,"%s_max",v->name);
907 max=(int)CONF_get_number(req_conf,tmp,buf); 1001 max=(int)CONF_get_number(req_conf,dn_sect,buf);
908 1002
909 if (!add_DN_object(ri->subject,v->value,def,value,nid, 1003 if (!add_DN_object(subj,v->value,def,value,nid,
910 min,max)) 1004 min,max))
911 goto err; 1005 return 0;
912 } 1006 }
913 if (sk_X509_NAME_ENTRY_num(ri->subject->entries) == 0) 1007 if (X509_NAME_entry_count(subj) == 0)
914 { 1008 {
915 BIO_printf(bio_err,"error, no objects specified in config file\n"); 1009 BIO_printf(bio_err,"error, no objects specified in config file\n");
916 goto err; 1010 return 0;
917 } 1011 }
918 1012
919 if (attribs) 1013 if (attribs)
920 { 1014 {
921 if ((attr != NULL) && (sk_CONF_VALUE_num(attr) > 0)) 1015 if ((attr_sk != NULL) && (sk_CONF_VALUE_num(attr_sk) > 0))
922 { 1016 {
923 BIO_printf(bio_err,"\nPlease enter the following 'extra' attributes\n"); 1017 BIO_printf(bio_err,"\nPlease enter the following 'extra' attributes\n");
924 BIO_printf(bio_err,"to be sent with your certificate request\n"); 1018 BIO_printf(bio_err,"to be sent with your certificate request\n");
@@ -928,57 +1022,101 @@ start: for (;;)
928start2: for (;;) 1022start2: for (;;)
929 { 1023 {
930 i++; 1024 i++;
931 if ((attr == NULL) || 1025 if ((attr_sk == NULL) ||
932 (sk_CONF_VALUE_num(attr) <= i)) 1026 (sk_CONF_VALUE_num(attr_sk) <= i))
933 break; 1027 break;
934 1028
935 v=sk_CONF_VALUE_value(attr,i); 1029 v=sk_CONF_VALUE_value(attr_sk,i);
936 type=v->name; 1030 type=v->name;
937 if ((nid=OBJ_txt2nid(type)) == NID_undef) 1031 if ((nid=OBJ_txt2nid(type)) == NID_undef)
938 goto start2; 1032 goto start2;
939 1033
940 sprintf(buf,"%s_default",type); 1034 sprintf(buf,"%s_default",type);
941 if ((def=CONF_get_string(req_conf,tmp_attr,buf)) 1035 if ((def=CONF_get_string(req_conf,attr_sect,buf))
942 == NULL) 1036 == NULL)
943 def=""; 1037 def="";
944 1038
945 sprintf(buf,"%s_value",type); 1039 sprintf(buf,"%s_value",type);
946 if ((value=CONF_get_string(req_conf,tmp_attr,buf)) 1040 if ((value=CONF_get_string(req_conf,attr_sect,buf))
947 == NULL) 1041 == NULL)
948 value=NULL; 1042 value=NULL;
949 1043
950 sprintf(buf,"%s_min",type); 1044 sprintf(buf,"%s_min",type);
951 min=(int)CONF_get_number(req_conf,tmp_attr,buf); 1045 min=(int)CONF_get_number(req_conf,attr_sect,buf);
952 1046
953 sprintf(buf,"%s_max",type); 1047 sprintf(buf,"%s_max",type);
954 max=(int)CONF_get_number(req_conf,tmp_attr,buf); 1048 max=(int)CONF_get_number(req_conf,attr_sect,buf);
955 1049
956 if (!add_attribute_object(ri->attributes, 1050 if (!add_attribute_object(req,
957 v->value,def,value,nid,min,max)) 1051 v->value,def,value,nid,min,max))
958 goto err; 1052 return 0;
959 } 1053 }
960 } 1054 }
961 } 1055 }
962 else 1056 else
963 { 1057 {
964 BIO_printf(bio_err,"No template, please set one up.\n"); 1058 BIO_printf(bio_err,"No template, please set one up.\n");
965 goto err; 1059 return 0;
966 } 1060 }
967 1061
968 X509_REQ_set_pubkey(req,pkey); 1062 return 1;
969 1063
970 ret=1;
971err:
972 return(ret);
973 } 1064 }
974 1065
1066static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
1067 STACK_OF(CONF_VALUE) *attr_sk, int attribs)
1068 {
1069 int i;
1070 char *p,*q;
1071 char *type;
1072 CONF_VALUE *v;
1073 X509_NAME *subj;
1074
1075 subj = X509_REQ_get_subject_name(req);
1076
1077 for (i = 0; i < sk_CONF_VALUE_num(dn_sk); i++)
1078 {
1079 v=sk_CONF_VALUE_value(dn_sk,i);
1080 p=q=NULL;
1081 type=v->name;
1082 /* Skip past any leading X. X: X, etc to allow for
1083 * multiple instances
1084 */
1085 for(p = v->name; *p ; p++)
1086 if ((*p == ':') || (*p == ',') || (*p == '.')) {
1087 p++;
1088 if(*p) type = p;
1089 break;
1090 }
1091 if (!X509_NAME_add_entry_by_txt(subj,type, MBSTRING_ASC,
1092 (unsigned char *) v->value,-1,-1,0)) return 0;
1093
1094 }
1095
1096 if (!X509_NAME_entry_count(subj))
1097 {
1098 BIO_printf(bio_err,"error, no objects specified in config file\n");
1099 return 0;
1100 }
1101 if (attribs)
1102 {
1103 for (i = 0; i < sk_CONF_VALUE_num(attr_sk); i++)
1104 {
1105 v=sk_CONF_VALUE_value(attr_sk,i);
1106 if(!X509_REQ_add1_attr_by_txt(req, v->name, MBSTRING_ASC,
1107 (unsigned char *)v->value, -1)) return 0;
1108 }
1109 }
1110 return 1;
1111 }
1112
1113
975static int add_DN_object(X509_NAME *n, char *text, char *def, char *value, 1114static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
976 int nid, int min, int max) 1115 int nid, int min, int max)
977 { 1116 {
978 int i,j,ret=0; 1117 int i,ret=0;
979 X509_NAME_ENTRY *ne=NULL;
980 MS_STATIC char buf[1024]; 1118 MS_STATIC char buf[1024];
981 1119start:
982 BIO_printf(bio_err,"%s [%s]:",text,def); 1120 BIO_printf(bio_err,"%s [%s]:",text,def);
983 (void)BIO_flush(bio_err); 1121 (void)BIO_flush(bio_err);
984 if (value != NULL) 1122 if (value != NULL)
@@ -1011,33 +1149,23 @@ static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
1011 } 1149 }
1012 buf[--i]='\0'; 1150 buf[--i]='\0';
1013 1151
1014 j=ASN1_PRINTABLE_type((unsigned char *)buf,-1);
1015 if (req_fix_data(nid,&j,i,min,max) == 0)
1016 goto err;
1017#ifdef CHARSET_EBCDIC 1152#ifdef CHARSET_EBCDIC
1018 ebcdic2ascii(buf, buf, i); 1153 ebcdic2ascii(buf, buf, i);
1019#endif 1154#endif
1020 if ((ne=X509_NAME_ENTRY_create_by_NID(NULL,nid,j,(unsigned char *)buf, 1155 if(!req_check_len(i, min, max)) goto start;
1021 strlen(buf))) 1156 if (!X509_NAME_add_entry_by_NID(n,nid, MBSTRING_ASC,
1022 == NULL) goto err; 1157 (unsigned char *) buf, -1,-1,0)) goto err;
1023 if (!X509_NAME_add_entry(n,ne,X509_NAME_entry_count(n),0))
1024 goto err;
1025
1026 ret=1; 1158 ret=1;
1027err: 1159err:
1028 if (ne != NULL) X509_NAME_ENTRY_free(ne);
1029 return(ret); 1160 return(ret);
1030 } 1161 }
1031 1162
1032static int add_attribute_object(STACK_OF(X509_ATTRIBUTE) *n, char *text, 1163static int add_attribute_object(X509_REQ *req, char *text,
1033 char *def, char *value, int nid, int min, 1164 char *def, char *value, int nid, int min,
1034 int max) 1165 int max)
1035 { 1166 {
1036 int i,z; 1167 int i;
1037 X509_ATTRIBUTE *xa=NULL;
1038 static char buf[1024]; 1168 static char buf[1024];
1039 ASN1_BIT_STRING *bs=NULL;
1040 ASN1_TYPE *at=NULL;
1041 1169
1042start: 1170start:
1043 BIO_printf(bio_err,"%s [%s]:",text,def); 1171 BIO_printf(bio_err,"%s [%s]:",text,def);
@@ -1071,50 +1199,21 @@ start:
1071 return(0); 1199 return(0);
1072 } 1200 }
1073 buf[--i]='\0'; 1201 buf[--i]='\0';
1202 if(!req_check_len(i, min, max)) goto start;
1074 1203
1075 /* add object plus value */ 1204 if(!X509_REQ_add1_attr_by_NID(req, nid, MBSTRING_ASC,
1076 if ((xa=X509_ATTRIBUTE_new()) == NULL) 1205 (unsigned char *)buf, -1)) {
1077 goto err; 1206 BIO_printf(bio_err, "Error adding attribute\n");
1078 if ((xa->value.set=sk_ASN1_TYPE_new_null()) == NULL) 1207 ERR_print_errors(bio_err);
1079 goto err; 1208 goto err;
1080 xa->set=1; 1209 }
1081
1082 if (xa->object != NULL) ASN1_OBJECT_free(xa->object);
1083 xa->object=OBJ_nid2obj(nid);
1084
1085 if ((bs=ASN1_BIT_STRING_new()) == NULL) goto err;
1086
1087 bs->type=ASN1_PRINTABLE_type((unsigned char *)buf,-1);
1088
1089 z=req_fix_data(nid,&bs->type,i,min,max);
1090 if (z == 0)
1091 {
1092 if (value == NULL)
1093 goto start;
1094 else goto err;
1095 }
1096
1097 if (!ASN1_STRING_set(bs,(unsigned char *)buf,i+1))
1098 { BIO_printf(bio_err,"Malloc failure\n"); goto err; }
1099
1100 if ((at=ASN1_TYPE_new()) == NULL)
1101 { BIO_printf(bio_err,"Malloc failure\n"); goto err; }
1102
1103 ASN1_TYPE_set(at,bs->type,(char *)bs);
1104 sk_ASN1_TYPE_push(xa->value.set,at);
1105 bs=NULL;
1106 at=NULL;
1107 /* only one item per attribute */
1108 1210
1109 if (!sk_X509_ATTRIBUTE_push(n,xa)) goto err;
1110 return(1); 1211 return(1);
1111err: 1212err:
1112 if (xa != NULL) X509_ATTRIBUTE_free(xa);
1113 if (at != NULL) ASN1_TYPE_free(at);
1114 if (bs != NULL) ASN1_BIT_STRING_free(bs);
1115 return(0); 1213 return(0);
1116 } 1214 }
1117 1215
1216#ifndef NO_RSA
1118static void MS_CALLBACK req_cb(int p, int n, void *arg) 1217static void MS_CALLBACK req_cb(int p, int n, void *arg)
1119 { 1218 {
1120 char c='*'; 1219 char c='*';
@@ -1129,26 +1228,10 @@ static void MS_CALLBACK req_cb(int p, int n, void *arg)
1129 p=n; 1228 p=n;
1130#endif 1229#endif
1131 } 1230 }
1231#endif
1132 1232
1133static int req_fix_data(int nid, int *type, int len, int min, int max) 1233static int req_check_len(int len, int min, int max)
1134 { 1234 {
1135 if (nid == NID_pkcs9_emailAddress)
1136 *type=V_ASN1_IA5STRING;
1137 if ((nid == NID_commonName) && (*type == V_ASN1_IA5STRING))
1138 *type=V_ASN1_T61STRING;
1139 if ((nid == NID_pkcs9_challengePassword) &&
1140 (*type == V_ASN1_IA5STRING))
1141 *type=V_ASN1_T61STRING;
1142
1143 if ((nid == NID_pkcs9_unstructuredName) &&
1144 (*type == V_ASN1_T61STRING))
1145 {
1146 BIO_printf(bio_err,"invalid characters in string, please re-enter the string\n");
1147 return(0);
1148 }
1149 if (nid == NID_pkcs9_unstructuredName)
1150 *type=V_ASN1_IA5STRING;
1151
1152 if (len < min) 1235 if (len < min)
1153 { 1236 {
1154 BIO_printf(bio_err,"string is too short, it needs to be at least %d bytes long\n",min); 1237 BIO_printf(bio_err,"string is too short, it needs to be at least %d bytes long\n",min);
diff --git a/src/lib/libssl/src/apps/rsa.c b/src/lib/libssl/src/apps/rsa.c
index 9b723ee406..53d234ca35 100644
--- a/src/lib/libssl/src/apps/rsa.c
+++ b/src/lib/libssl/src/apps/rsa.c
@@ -82,8 +82,12 @@
82 * -text - print a text version 82 * -text - print a text version
83 * -modulus - print the RSA key modulus 83 * -modulus - print the RSA key modulus
84 * -check - verify key consistency 84 * -check - verify key consistency
85 * -pubin - Expect a public key in input file.
86 * -pubout - Output a public key.
85 */ 87 */
86 88
89int MAIN(int, char **);
90
87int MAIN(int argc, char **argv) 91int MAIN(int argc, char **argv)
88 { 92 {
89 int ret=1; 93 int ret=1;
@@ -92,7 +96,10 @@ int MAIN(int argc, char **argv)
92 const EVP_CIPHER *enc=NULL; 96 const EVP_CIPHER *enc=NULL;
93 BIO *in=NULL,*out=NULL; 97 BIO *in=NULL,*out=NULL;
94 int informat,outformat,text=0,check=0,noout=0; 98 int informat,outformat,text=0,check=0,noout=0;
99 int pubin = 0, pubout = 0;
95 char *infile,*outfile,*prog; 100 char *infile,*outfile,*prog;
101 char *passargin = NULL, *passargout = NULL;
102 char *passin = NULL, *passout = NULL;
96 int modulus=0; 103 int modulus=0;
97 104
98 apps_startup(); 105 apps_startup();
@@ -131,6 +138,20 @@ int MAIN(int argc, char **argv)
131 if (--argc < 1) goto bad; 138 if (--argc < 1) goto bad;
132 outfile= *(++argv); 139 outfile= *(++argv);
133 } 140 }
141 else if (strcmp(*argv,"-passin") == 0)
142 {
143 if (--argc < 1) goto bad;
144 passargin= *(++argv);
145 }
146 else if (strcmp(*argv,"-passout") == 0)
147 {
148 if (--argc < 1) goto bad;
149 passargout= *(++argv);
150 }
151 else if (strcmp(*argv,"-pubin") == 0)
152 pubin=1;
153 else if (strcmp(*argv,"-pubout") == 0)
154 pubout=1;
134 else if (strcmp(*argv,"-noout") == 0) 155 else if (strcmp(*argv,"-noout") == 0)
135 noout=1; 156 noout=1;
136 else if (strcmp(*argv,"-text") == 0) 157 else if (strcmp(*argv,"-text") == 0)
@@ -154,24 +175,39 @@ int MAIN(int argc, char **argv)
154bad: 175bad:
155 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog); 176 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
156 BIO_printf(bio_err,"where options are\n"); 177 BIO_printf(bio_err,"where options are\n");
157 BIO_printf(bio_err," -inform arg input format - one of DER NET PEM\n"); 178 BIO_printf(bio_err," -inform arg input format - one of DER NET PEM\n");
158 BIO_printf(bio_err," -outform arg output format - one of DER NET PEM\n"); 179 BIO_printf(bio_err," -outform arg output format - one of DER NET PEM\n");
159 BIO_printf(bio_err," -in arg input file\n"); 180 BIO_printf(bio_err," -in arg input file\n");
160 BIO_printf(bio_err," -out arg output file\n"); 181 BIO_printf(bio_err," -passin arg input file pass phrase source\n");
161 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 182 BIO_printf(bio_err," -in arg input file\n");
162 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 183 BIO_printf(bio_err," -out arg output file\n");
184 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
185 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n");
186 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
163#ifndef NO_IDEA 187#ifndef NO_IDEA
164 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n"); 188 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n");
165#endif 189#endif
166 BIO_printf(bio_err," -text print the key in text\n"); 190 BIO_printf(bio_err," -text print the key in text\n");
167 BIO_printf(bio_err," -noout don't print key out\n"); 191 BIO_printf(bio_err," -noout don't print key out\n");
168 BIO_printf(bio_err," -modulus print the RSA key modulus\n"); 192 BIO_printf(bio_err," -modulus print the RSA key modulus\n");
169 BIO_printf(bio_err," -check verify key consistency\n"); 193 BIO_printf(bio_err," -check verify key consistency\n");
194 BIO_printf(bio_err," -pubin expect a public key in input file\n");
195 BIO_printf(bio_err," -pubout output a public key\n");
170 goto end; 196 goto end;
171 } 197 }
172 198
173 ERR_load_crypto_strings(); 199 ERR_load_crypto_strings();
174 200
201 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
202 BIO_printf(bio_err, "Error getting passwords\n");
203 goto end;
204 }
205
206 if(check && pubin) {
207 BIO_printf(bio_err, "Only private keys can be checked\n");
208 goto end;
209 }
210
175 in=BIO_new(BIO_s_file()); 211 in=BIO_new(BIO_s_file());
176 out=BIO_new(BIO_s_file()); 212 out=BIO_new(BIO_s_file());
177 if ((in == NULL) || (out == NULL)) 213 if ((in == NULL) || (out == NULL))
@@ -191,9 +227,11 @@ bad:
191 } 227 }
192 } 228 }
193 229
194 BIO_printf(bio_err,"read RSA private key\n"); 230 BIO_printf(bio_err,"read RSA key\n");
195 if (informat == FORMAT_ASN1) 231 if (informat == FORMAT_ASN1) {
196 rsa=d2i_RSAPrivateKey_bio(in,NULL); 232 if (pubin) rsa=d2i_RSA_PUBKEY_bio(in,NULL);
233 else rsa=d2i_RSAPrivateKey_bio(in,NULL);
234 }
197#ifndef NO_RC4 235#ifndef NO_RC4
198 else if (informat == FORMAT_NETSCAPE) 236 else if (informat == FORMAT_NETSCAPE)
199 { 237 {
@@ -217,12 +255,14 @@ bad:
217 } 255 }
218 } 256 }
219 p=(unsigned char *)buf->data; 257 p=(unsigned char *)buf->data;
220 rsa=(RSA *)d2i_Netscape_RSA(NULL,&p,(long)size,NULL); 258 rsa=d2i_Netscape_RSA(NULL,&p,(long)size,NULL);
221 BUF_MEM_free(buf); 259 BUF_MEM_free(buf);
222 } 260 }
223#endif 261#endif
224 else if (informat == FORMAT_PEM) 262 else if (informat == FORMAT_PEM) {
225 rsa=PEM_read_bio_RSAPrivateKey(in,NULL,NULL,NULL); 263 if(pubin) rsa=PEM_read_bio_RSA_PUBKEY(in,NULL,NULL,NULL);
264 else rsa=PEM_read_bio_RSAPrivateKey(in,NULL, NULL,passin);
265 }
226 else 266 else
227 { 267 {
228 BIO_printf(bio_err,"bad input format specified for key\n"); 268 BIO_printf(bio_err,"bad input format specified for key\n");
@@ -230,7 +270,7 @@ bad:
230 } 270 }
231 if (rsa == NULL) 271 if (rsa == NULL)
232 { 272 {
233 BIO_printf(bio_err,"unable to load Private Key\n"); 273 BIO_printf(bio_err,"unable to load key\n");
234 ERR_print_errors(bio_err); 274 ERR_print_errors(bio_err);
235 goto end; 275 goto end;
236 } 276 }
@@ -256,9 +296,9 @@ bad:
256 296
257 if (modulus) 297 if (modulus)
258 { 298 {
259 fprintf(stdout,"Modulus="); 299 BIO_printf(out,"Modulus=");
260 BN_print(out,rsa->n); 300 BN_print(out,rsa->n);
261 fprintf(stdout,"\n"); 301 BIO_printf(out,"\n");
262 } 302 }
263 303
264 if (check) 304 if (check)
@@ -288,10 +328,16 @@ bad:
288 } 328 }
289 } 329 }
290 330
291 if (noout) goto end; 331 if (noout)
292 BIO_printf(bio_err,"writing RSA private key\n"); 332 {
293 if (outformat == FORMAT_ASN1) 333 ret = 0;
294 i=i2d_RSAPrivateKey_bio(out,rsa); 334 goto end;
335 }
336 BIO_printf(bio_err,"writing RSA key\n");
337 if (outformat == FORMAT_ASN1) {
338 if(pubout || pubin) i=i2d_RSA_PUBKEY_bio(out,rsa);
339 else i=i2d_RSAPrivateKey_bio(out,rsa);
340 }
295#ifndef NO_RC4 341#ifndef NO_RC4
296 else if (outformat == FORMAT_NETSCAPE) 342 else if (outformat == FORMAT_NETSCAPE)
297 { 343 {
@@ -311,23 +357,34 @@ bad:
311 Free(pp); 357 Free(pp);
312 } 358 }
313#endif 359#endif
314 else if (outformat == FORMAT_PEM) 360 else if (outformat == FORMAT_PEM) {
315 i=PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL,NULL); 361 if(pubout || pubin)
316 else { 362 i=PEM_write_bio_RSA_PUBKEY(out,rsa);
363 else i=PEM_write_bio_RSAPrivateKey(out,rsa,
364 enc,NULL,0,NULL,passout);
365 } else {
317 BIO_printf(bio_err,"bad output format specified for outfile\n"); 366 BIO_printf(bio_err,"bad output format specified for outfile\n");
318 goto end; 367 goto end;
319 } 368 }
320 if (!i) 369 if (!i)
321 { 370 {
322 BIO_printf(bio_err,"unable to write private key\n"); 371 BIO_printf(bio_err,"unable to write key\n");
323 ERR_print_errors(bio_err); 372 ERR_print_errors(bio_err);
324 } 373 }
325 else 374 else
326 ret=0; 375 ret=0;
327end: 376end:
328 if (in != NULL) BIO_free(in); 377 if(in != NULL) BIO_free(in);
329 if (out != NULL) BIO_free(out); 378 if(out != NULL) BIO_free(out);
330 if (rsa != NULL) RSA_free(rsa); 379 if(rsa != NULL) RSA_free(rsa);
380 if(passin) Free(passin);
381 if(passout) Free(passout);
331 EXIT(ret); 382 EXIT(ret);
332 } 383 }
384#else /* !NO_RSA */
385
386# if PEDANTIC
387static void *dummy=&dummy;
388# endif
389
333#endif 390#endif
diff --git a/src/lib/libssl/src/apps/s_client.c b/src/lib/libssl/src/apps/s_client.c
index b06104130e..c4c3b0e94a 100644
--- a/src/lib/libssl/src/apps/s_client.c
+++ b/src/lib/libssl/src/apps/s_client.c
@@ -56,9 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifdef APPS_CRLF 59#include <assert.h>
60# include <assert.h>
61#endif
62#include <stdio.h> 60#include <stdio.h>
63#include <stdlib.h> 61#include <stdlib.h>
64#include <string.h> 62#include <string.h>
@@ -83,15 +81,16 @@ typedef unsigned int u_int;
83#include <openssl/pem.h> 81#include <openssl/pem.h>
84#include "s_apps.h" 82#include "s_apps.h"
85 83
84#ifdef WINDOWS
85#include <conio.h>
86#endif
87
88
86#if (defined(VMS) && __VMS_VER < 70000000) 89#if (defined(VMS) && __VMS_VER < 70000000)
87/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 90/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
88#undef FIONBIO 91#undef FIONBIO
89#endif 92#endif
90 93
91#if defined(NO_RSA) && !defined(NO_SSL2)
92#define NO_SSL2
93#endif
94
95#undef PROG 94#undef PROG
96#define PROG s_client_main 95#define PROG s_client_main
97 96
@@ -142,20 +141,20 @@ static void sc_usage(void)
142#ifdef FIONBIO 141#ifdef FIONBIO
143 BIO_printf(bio_err," -nbio - Run with non-blocking IO\n"); 142 BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
144#endif 143#endif
145#ifdef APPS_CRLF /* won't be #ifdef'd in next release */
146 BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n"); 144 BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
147#endif
148 BIO_printf(bio_err," -quiet - no s_client output\n"); 145 BIO_printf(bio_err," -quiet - no s_client output\n");
149 BIO_printf(bio_err," -ssl2 - just use SSLv2\n"); 146 BIO_printf(bio_err," -ssl2 - just use SSLv2\n");
150 BIO_printf(bio_err," -ssl3 - just use SSLv3\n"); 147 BIO_printf(bio_err," -ssl3 - just use SSLv3\n");
151 BIO_printf(bio_err," -tls1 - just use TLSv1\n"); 148 BIO_printf(bio_err," -tls1 - just use TLSv1\n");
152 BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n"); 149 BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
153 BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n"); 150 BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n");
154 BIO_printf(bio_err," -cipher - prefered cipher to use, use the 'openssl ciphers'\n"); 151 BIO_printf(bio_err," -cipher - preferred cipher to use, use the 'openssl ciphers'\n");
155 BIO_printf(bio_err," command to see what is available\n"); 152 BIO_printf(bio_err," command to see what is available\n");
156 153
157 } 154 }
158 155
156int MAIN(int, char **);
157
159int MAIN(int argc, char **argv) 158int MAIN(int argc, char **argv)
160 { 159 {
161 int off=0; 160 int off=0;
@@ -171,15 +170,16 @@ int MAIN(int argc, char **argv)
171 char *cert_file=NULL,*key_file=NULL; 170 char *cert_file=NULL,*key_file=NULL;
172 char *CApath=NULL,*CAfile=NULL,*cipher=NULL; 171 char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
173 int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0; 172 int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
174#ifdef APPS_CRLF
175 int crlf=0; 173 int crlf=0;
176#endif
177 int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending; 174 int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
178 SSL_CTX *ctx=NULL; 175 SSL_CTX *ctx=NULL;
179 int ret=1,in_init=1,i,nbio_test=0; 176 int ret=1,in_init=1,i,nbio_test=0;
177 int prexit = 0;
180 SSL_METHOD *meth=NULL; 178 SSL_METHOD *meth=NULL;
181 BIO *sbio; 179 BIO *sbio;
182 /*static struct timeval timeout={10,0};*/ 180#ifdef WINDOWS
181 struct timeval tv;
182#endif
183 183
184#if !defined(NO_SSL2) && !defined(NO_SSL3) 184#if !defined(NO_SSL2) && !defined(NO_SSL3)
185 meth=SSLv23_client_method(); 185 meth=SSLv23_client_method();
@@ -244,10 +244,10 @@ int MAIN(int argc, char **argv)
244 if (--argc < 1) goto bad; 244 if (--argc < 1) goto bad;
245 cert_file= *(++argv); 245 cert_file= *(++argv);
246 } 246 }
247#ifdef APPS_CRLF 247 else if (strcmp(*argv,"-prexit") == 0)
248 prexit=1;
248 else if (strcmp(*argv,"-crlf") == 0) 249 else if (strcmp(*argv,"-crlf") == 0)
249 crlf=1; 250 crlf=1;
250#endif
251 else if (strcmp(*argv,"-quiet") == 0) 251 else if (strcmp(*argv,"-quiet") == 0)
252 c_quiet=1; 252 c_quiet=1;
253 else if (strcmp(*argv,"-pause") == 0) 253 else if (strcmp(*argv,"-pause") == 0)
@@ -324,6 +324,8 @@ bad:
324 goto end; 324 goto end;
325 } 325 }
326 326
327 app_RAND_load_file(NULL, bio_err, 0);
328
327 if (bio_c_out == NULL) 329 if (bio_c_out == NULL)
328 { 330 {
329 if (c_quiet) 331 if (c_quiet)
@@ -337,7 +339,8 @@ bad:
337 } 339 }
338 } 340 }
339 341
340 SSLeay_add_ssl_algorithms(); 342 OpenSSL_add_ssl_algorithms();
343 SSL_load_error_strings();
341 ctx=SSL_CTX_new(meth); 344 ctx=SSL_CTX_new(meth);
342 if (ctx == NULL) 345 if (ctx == NULL)
343 { 346 {
@@ -352,7 +355,11 @@ bad:
352 355
353 if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback); 356 if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
354 if (cipher != NULL) 357 if (cipher != NULL)
355 SSL_CTX_set_cipher_list(ctx,cipher); 358 if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
359 BIO_printf(bio_err,"error setting cipher list\n");
360 ERR_print_errors(bio_err);
361 goto end;
362 }
356#if 0 363#if 0
357 else 364 else
358 SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER")); 365 SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
@@ -365,14 +372,13 @@ bad:
365 if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) || 372 if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||
366 (!SSL_CTX_set_default_verify_paths(ctx))) 373 (!SSL_CTX_set_default_verify_paths(ctx)))
367 { 374 {
368 /* BIO_printf(bio_err,"error seting default verify locations\n"); */ 375 /* BIO_printf(bio_err,"error setting default verify locations\n"); */
369 ERR_print_errors(bio_err); 376 ERR_print_errors(bio_err);
370 /* goto end; */ 377 /* goto end; */
371 } 378 }
372 379
373 SSL_load_error_strings();
374 380
375 con=(SSL *)SSL_new(ctx); 381 con=SSL_new(ctx);
376/* SSL_set_cipher_list(con,"RC4-MD5"); */ 382/* SSL_set_cipher_list(con,"RC4-MD5"); */
377 383
378re_start: 384re_start:
@@ -473,12 +479,18 @@ re_start:
473 if (read_tty) FD_SET(fileno(stdin),&readfds); 479 if (read_tty) FD_SET(fileno(stdin),&readfds);
474 if (write_tty) FD_SET(fileno(stdout),&writefds); 480 if (write_tty) FD_SET(fileno(stdout),&writefds);
475 } 481 }
476#endif
477 if (read_ssl) 482 if (read_ssl)
478 FD_SET(SSL_get_fd(con),&readfds); 483 FD_SET(SSL_get_fd(con),&readfds);
479 if (write_ssl) 484 if (write_ssl)
480 FD_SET(SSL_get_fd(con),&writefds); 485 FD_SET(SSL_get_fd(con),&writefds);
481 486#else
487 if(!tty_on || !write_tty) {
488 if (read_ssl)
489 FD_SET(SSL_get_fd(con),&readfds);
490 if (write_ssl)
491 FD_SET(SSL_get_fd(con),&writefds);
492 }
493#endif
482/* printf("mode tty(%d %d%d) ssl(%d%d)\n", 494/* printf("mode tty(%d %d%d) ssl(%d%d)\n",
483 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/ 495 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
484 496
@@ -488,8 +500,29 @@ re_start:
488 * will choke the compiler: if you do have a cast then 500 * will choke the compiler: if you do have a cast then
489 * you can either go for (int *) or (void *). 501 * you can either go for (int *) or (void *).
490 */ 502 */
503#ifdef WINDOWS
504 /* Under Windows we make the assumption that we can
505 * always write to the tty: therefore if we need to
506 * write to the tty we just fall through. Otherwise
507 * we timeout the select every second and see if there
508 * are any keypresses. Note: this is a hack, in a proper
509 * Windows application we wouldn't do this.
510 */
511 i=0;
512 if(!write_tty) {
513 if(read_tty) {
514 tv.tv_sec = 1;
515 tv.tv_usec = 0;
516 i=select(width,(void *)&readfds,(void *)&writefds,
517 NULL,&tv);
518 if(!i && (!_kbhit() || !read_tty) ) continue;
519 } else i=select(width,(void *)&readfds,(void *)&writefds,
520 NULL,NULL);
521 }
522#else
491 i=select(width,(void *)&readfds,(void *)&writefds, 523 i=select(width,(void *)&readfds,(void *)&writefds,
492 NULL,NULL); 524 NULL,NULL);
525#endif
493 if ( i < 0) 526 if ( i < 0)
494 { 527 {
495 BIO_printf(bio_err,"bad select %d\n", 528 BIO_printf(bio_err,"bad select %d\n",
@@ -566,8 +599,12 @@ re_start:
566 goto shut; 599 goto shut;
567 } 600 }
568 } 601 }
569#ifndef WINDOWS 602#ifdef WINDOWS
603 /* Assume Windows can always write */
604 else if (!ssl_pending && write_tty)
605#else
570 else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds)) 606 else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds))
607#endif
571 { 608 {
572#ifdef CHARSET_EBCDIC 609#ifdef CHARSET_EBCDIC
573 ascii2ebcdic(&(sbuf[sbuf_off]),&(sbuf[sbuf_off]),sbuf_len); 610 ascii2ebcdic(&(sbuf[sbuf_off]),&(sbuf[sbuf_off]),sbuf_len);
@@ -589,7 +626,6 @@ re_start:
589 write_tty=0; 626 write_tty=0;
590 } 627 }
591 } 628 }
592#endif
593 else if (ssl_pending || FD_ISSET(SSL_get_fd(con),&readfds)) 629 else if (ssl_pending || FD_ISSET(SSL_get_fd(con),&readfds))
594 { 630 {
595#ifdef RENEG 631#ifdef RENEG
@@ -644,10 +680,12 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
644 } 680 }
645 } 681 }
646 682
647#ifndef WINDOWS 683#ifdef WINDOWS
684 else if (_kbhit())
685#else
648 else if (FD_ISSET(fileno(stdin),&readfds)) 686 else if (FD_ISSET(fileno(stdin),&readfds))
687#endif
649 { 688 {
650#ifdef APPS_CRLF
651 if (crlf) 689 if (crlf)
652 { 690 {
653 int j, lf_num; 691 int j, lf_num;
@@ -671,7 +709,6 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
671 assert(lf_num == 0); 709 assert(lf_num == 0);
672 } 710 }
673 else 711 else
674#endif
675 i=read(fileno(stdin),cbuf,BUFSIZZ); 712 i=read(fileno(stdin),cbuf,BUFSIZZ);
676 713
677 if ((!c_quiet) && ((i <= 0) || (cbuf[0] == 'Q'))) 714 if ((!c_quiet) && ((i <= 0) || (cbuf[0] == 'Q')))
@@ -698,13 +735,13 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
698 write_ssl=1; 735 write_ssl=1;
699 read_tty=0; 736 read_tty=0;
700 } 737 }
701#endif
702 } 738 }
703shut: 739shut:
704 SSL_shutdown(con); 740 SSL_shutdown(con);
705 SHUTDOWN(SSL_get_fd(con)); 741 SHUTDOWN(SSL_get_fd(con));
706 ret=0; 742 ret=0;
707end: 743end:
744 if(prexit) print_stuff(bio_c_out,con,1);
708 if (con != NULL) SSL_free(con); 745 if (con != NULL) SSL_free(con);
709 if (con2 != NULL) SSL_free(con2); 746 if (con2 != NULL) SSL_free(con2);
710 if (ctx != NULL) SSL_CTX_free(ctx); 747 if (ctx != NULL) SSL_CTX_free(ctx);
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c
index 9a81418cda..af19b89227 100644
--- a/src/lib/libssl/src/apps/s_server.c
+++ b/src/lib/libssl/src/apps/s_server.c
@@ -56,9 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifdef APPS_CRLF 59#include <assert.h>
60# include <assert.h>
61#endif
62#include <stdio.h> 60#include <stdio.h>
63#include <stdlib.h> 61#include <stdlib.h>
64#include <string.h> 62#include <string.h>
@@ -87,15 +85,15 @@ typedef unsigned int u_int;
87#include <openssl/ssl.h> 85#include <openssl/ssl.h>
88#include "s_apps.h" 86#include "s_apps.h"
89 87
88#ifdef WINDOWS
89#include <conio.h>
90#endif
91
90#if (defined(VMS) && __VMS_VER < 70000000) 92#if (defined(VMS) && __VMS_VER < 70000000)
91/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 93/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
92#undef FIONBIO 94#undef FIONBIO
93#endif 95#endif
94 96
95#if defined(NO_RSA) && !defined(NO_SSL2)
96#define NO_SSL2
97#endif
98
99#ifndef NO_RSA 97#ifndef NO_RSA
100static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength); 98static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength);
101#endif 99#endif
@@ -106,10 +104,12 @@ static void sv_usage(void);
106static int init_ssl_connection(SSL *s); 104static int init_ssl_connection(SSL *s);
107static void print_stats(BIO *bp,SSL_CTX *ctx); 105static void print_stats(BIO *bp,SSL_CTX *ctx);
108#ifndef NO_DH 106#ifndef NO_DH
109static DH *load_dh_param(void ); 107static DH *load_dh_param(char *dhfile);
110static DH *get_dh512(void); 108static DH *get_dh512(void);
111#endif 109#endif
112/* static void s_server_init(void);*/ 110#ifdef MONOLITH
111static void s_server_init(void);
112#endif
113 113
114#ifndef S_ISDIR 114#ifndef S_ISDIR
115# if defined(_S_IFMT) && defined(_S_IFDIR) 115# if defined(_S_IFMT) && defined(_S_IFDIR)
@@ -149,15 +149,13 @@ static DH *get_dh512(void)
149 149
150#undef BUFSIZZ 150#undef BUFSIZZ
151#define BUFSIZZ 16*1024 151#define BUFSIZZ 16*1024
152static int bufsize=32; 152static int bufsize=BUFSIZZ;
153static int accept_socket= -1; 153static int accept_socket= -1;
154 154
155#define TEST_CERT "server.pem" 155#define TEST_CERT "server.pem"
156#undef PROG 156#undef PROG
157#define PROG s_server_main 157#define PROG s_server_main
158 158
159#define DH_PARAM "server.pem"
160
161extern int verify_depth; 159extern int verify_depth;
162 160
163static char *cipher=NULL; 161static char *cipher=NULL;
@@ -169,9 +167,7 @@ static char *s_dcert_file=NULL,*s_dkey_file=NULL;
169static int s_nbio=0; 167static int s_nbio=0;
170#endif 168#endif
171static int s_nbio_test=0; 169static int s_nbio_test=0;
172#ifdef APPS_CRLF /* won't be #ifdef'd in next release */
173int s_crlf=0; 170int s_crlf=0;
174#endif
175static SSL_CTX *ctx=NULL; 171static SSL_CTX *ctx=NULL;
176static int www=0; 172static int www=0;
177 173
@@ -179,9 +175,12 @@ static BIO *bio_s_out=NULL;
179static int s_debug=0; 175static int s_debug=0;
180static int s_quiet=0; 176static int s_quiet=0;
181 177
182#if 0 178static int hack=0;
179
180#ifdef MONOLITH
183static void s_server_init(void) 181static void s_server_init(void)
184 { 182 {
183 accept_socket=-1;
185 cipher=NULL; 184 cipher=NULL;
186 s_server_verify=SSL_VERIFY_NONE; 185 s_server_verify=SSL_VERIFY_NONE;
187 s_dcert_file=NULL; 186 s_dcert_file=NULL;
@@ -198,6 +197,7 @@ static void s_server_init(void)
198 bio_s_out=NULL; 197 bio_s_out=NULL;
199 s_debug=0; 198 s_debug=0;
200 s_quiet=0; 199 s_quiet=0;
200 hack=0;
201 } 201 }
202#endif 202#endif
203 203
@@ -211,17 +211,17 @@ static void sv_usage(void)
211 BIO_printf(bio_err," -Verify arg - turn on peer certificate verification, must have a cert.\n"); 211 BIO_printf(bio_err," -Verify arg - turn on peer certificate verification, must have a cert.\n");
212 BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n"); 212 BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n");
213 BIO_printf(bio_err," (default is %s)\n",TEST_CERT); 213 BIO_printf(bio_err," (default is %s)\n",TEST_CERT);
214 BIO_printf(bio_err," -key arg - RSA file to use, PEM format assumed, in cert file if\n"); 214 BIO_printf(bio_err," -key arg - Private Key file to use, PEM format assumed, in cert file if\n");
215 BIO_printf(bio_err," not specified (default is %s)\n",TEST_CERT); 215 BIO_printf(bio_err," not specified (default is %s)\n",TEST_CERT);
216 BIO_printf(bio_err," -dcert arg - second certificate file to use (usually for DSA)\n"); 216 BIO_printf(bio_err," -dcert arg - second certificate file to use (usually for DSA)\n");
217 BIO_printf(bio_err," -dkey arg - second private key file to use (usually for DSA)\n"); 217 BIO_printf(bio_err," -dkey arg - second private key file to use (usually for DSA)\n");
218 BIO_printf(bio_err," -dhparam arg - DH parameter file to use, in cert file if not specified\n");
219 BIO_printf(bio_err," or a default set of parameters is used\n");
218#ifdef FIONBIO 220#ifdef FIONBIO
219 BIO_printf(bio_err," -nbio - Run with non-blocking IO\n"); 221 BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
220#endif 222#endif
221 BIO_printf(bio_err," -nbio_test - test with the non-blocking test bio\n"); 223 BIO_printf(bio_err," -nbio_test - test with the non-blocking test bio\n");
222#ifdef APPS_CRLF
223 BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n"); 224 BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
224#endif
225 BIO_printf(bio_err," -debug - Print more output\n"); 225 BIO_printf(bio_err," -debug - Print more output\n");
226 BIO_printf(bio_err," -state - Print the SSL states\n"); 226 BIO_printf(bio_err," -state - Print the SSL states\n");
227 BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n"); 227 BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n");
@@ -239,14 +239,13 @@ static void sv_usage(void)
239#ifndef NO_DH 239#ifndef NO_DH
240 BIO_printf(bio_err," -no_dhe - Disable ephemeral DH\n"); 240 BIO_printf(bio_err," -no_dhe - Disable ephemeral DH\n");
241#endif 241#endif
242 BIO_printf(bio_err," -bugs - Turn on SSL bug compatability\n"); 242 BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n");
243 BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n"); 243 BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n");
244 BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); 244 BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
245 } 245 }
246 246
247static int local_argc=0; 247static int local_argc=0;
248static char **local_argv; 248static char **local_argv;
249static int hack=0;
250 249
251#ifdef CHARSET_EBCDIC 250#ifdef CHARSET_EBCDIC
252static int ebcdic_new(BIO *bi); 251static int ebcdic_new(BIO *bi);
@@ -337,7 +336,7 @@ static int ebcdic_write(BIO *b, char *in, int inl)
337 num = num + num; /* double the size */ 336 num = num + num; /* double the size */
338 if (num < inl) 337 if (num < inl)
339 num = inl; 338 num = inl;
340 Free((char*)wbuf); 339 Free(wbuf);
341 wbuf=(EBCDIC_OUTBUFF *)Malloc(sizeof(EBCDIC_OUTBUFF) + num); 340 wbuf=(EBCDIC_OUTBUFF *)Malloc(sizeof(EBCDIC_OUTBUFF) + num);
342 341
343 wbuf->alloced = num; 342 wbuf->alloced = num;
@@ -398,11 +397,14 @@ static int ebcdic_puts(BIO *bp, char *str)
398} 397}
399#endif 398#endif
400 399
400int MAIN(int, char **);
401
401int MAIN(int argc, char *argv[]) 402int MAIN(int argc, char *argv[])
402 { 403 {
403 short port=PORT; 404 short port=PORT;
404 char *CApath=NULL,*CAfile=NULL; 405 char *CApath=NULL,*CAfile=NULL;
405 char *context = NULL; 406 char *context = NULL;
407 char *dhfile = NULL;
406 int badop=0,bugs=0; 408 int badop=0,bugs=0;
407 int ret=1; 409 int ret=1;
408 int off=0; 410 int off=0;
@@ -425,8 +427,9 @@ int MAIN(int argc, char *argv[])
425 local_argv=argv; 427 local_argv=argv;
426 428
427 apps_startup(); 429 apps_startup();
428 s_quiet=0; 430#ifdef MONOLITH
429 s_debug=0; 431 s_server_init();
432#endif
430 433
431 if (bio_err == NULL) 434 if (bio_err == NULL)
432 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 435 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
@@ -479,6 +482,11 @@ int MAIN(int argc, char *argv[])
479 if (--argc < 1) goto bad; 482 if (--argc < 1) goto bad;
480 s_key_file= *(++argv); 483 s_key_file= *(++argv);
481 } 484 }
485 else if (strcmp(*argv,"-dhparam") == 0)
486 {
487 if (--argc < 1) goto bad;
488 dhfile = *(++argv);
489 }
482 else if (strcmp(*argv,"-dcert") == 0) 490 else if (strcmp(*argv,"-dcert") == 0)
483 { 491 {
484 if (--argc < 1) goto bad; 492 if (--argc < 1) goto bad;
@@ -525,10 +533,8 @@ int MAIN(int argc, char *argv[])
525 { hack=1; } 533 { hack=1; }
526 else if (strcmp(*argv,"-state") == 0) 534 else if (strcmp(*argv,"-state") == 0)
527 { state=1; } 535 { state=1; }
528#ifdef APPS_CRLF
529 else if (strcmp(*argv,"-crlf") == 0) 536 else if (strcmp(*argv,"-crlf") == 0)
530 { s_crlf=1; } 537 { s_crlf=1; }
531#endif
532 else if (strcmp(*argv,"-quiet") == 0) 538 else if (strcmp(*argv,"-quiet") == 0)
533 { s_quiet=1; } 539 { s_quiet=1; }
534 else if (strcmp(*argv,"-bugs") == 0) 540 else if (strcmp(*argv,"-bugs") == 0)
@@ -575,6 +581,8 @@ bad:
575 goto end; 581 goto end;
576 } 582 }
577 583
584 app_RAND_load_file(NULL, bio_err, 0);
585
578 if (bio_s_out == NULL) 586 if (bio_s_out == NULL)
579 { 587 {
580 if (s_quiet && !s_debug) 588 if (s_quiet && !s_debug)
@@ -599,7 +607,7 @@ bad:
599 } 607 }
600 608
601 SSL_load_error_strings(); 609 SSL_load_error_strings();
602 SSLeay_add_ssl_algorithms(); 610 OpenSSL_add_ssl_algorithms();
603 611
604 ctx=SSL_CTX_new(meth); 612 ctx=SSL_CTX_new(meth);
605 if (ctx == NULL) 613 if (ctx == NULL)
@@ -641,8 +649,7 @@ bad:
641#ifndef NO_DH 649#ifndef NO_DH
642 if (!no_dhe) 650 if (!no_dhe)
643 { 651 {
644 /* EAY EAY EAY evil hack */ 652 dh=load_dh_param(dhfile ? dhfile : s_cert_file);
645 dh=load_dh_param();
646 if (dh != NULL) 653 if (dh != NULL)
647 { 654 {
648 BIO_printf(bio_s_out,"Setting temp DH parameters\n"); 655 BIO_printf(bio_s_out,"Setting temp DH parameters\n");
@@ -692,12 +699,17 @@ bad:
692#endif 699#endif
693 700
694 if (cipher != NULL) 701 if (cipher != NULL)
695 SSL_CTX_set_cipher_list(ctx,cipher); 702 if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
703 BIO_printf(bio_err,"error setting cipher list\n");
704 ERR_print_errors(bio_err);
705 goto end;
706 }
696 SSL_CTX_set_verify(ctx,s_server_verify,verify_callback); 707 SSL_CTX_set_verify(ctx,s_server_verify,verify_callback);
697 SSL_CTX_set_session_id_context(ctx,(void*)&s_server_session_id_context, 708 SSL_CTX_set_session_id_context(ctx,(void*)&s_server_session_id_context,
698 sizeof s_server_session_id_context); 709 sizeof s_server_session_id_context);
699 710
700 SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile)); 711 if (CAfile != NULL)
712 SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
701 713
702 BIO_printf(bio_s_out,"ACCEPT\n"); 714 BIO_printf(bio_s_out,"ACCEPT\n");
703 if (www) 715 if (www)
@@ -750,6 +762,9 @@ static int sv_body(char *hostname, int s, unsigned char *context)
750 unsigned long l; 762 unsigned long l;
751 SSL *con=NULL; 763 SSL *con=NULL;
752 BIO *sbio; 764 BIO *sbio;
765#ifdef WINDOWS
766 struct timeval tv;
767#endif
753 768
754 if ((buf=Malloc(bufsize)) == NULL) 769 if ((buf=Malloc(bufsize)) == NULL)
755 { 770 {
@@ -769,7 +784,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
769#endif 784#endif
770 785
771 if (con == NULL) { 786 if (con == NULL) {
772 con=(SSL *)SSL_new(ctx); 787 con=SSL_new(ctx);
773 if(context) 788 if(context)
774 SSL_set_session_id_context(con, context, 789 SSL_set_session_id_context(con, context,
775 strlen((char *)context)); 790 strlen((char *)context));
@@ -798,22 +813,48 @@ static int sv_body(char *hostname, int s, unsigned char *context)
798 width=s+1; 813 width=s+1;
799 for (;;) 814 for (;;)
800 { 815 {
801 FD_ZERO(&readfds); 816 int read_from_terminal;
817 int read_from_sslcon;
818
819 read_from_terminal = 0;
820 read_from_sslcon = SSL_pending(con);
821
822 if (!read_from_sslcon)
823 {
824 FD_ZERO(&readfds);
802#ifndef WINDOWS 825#ifndef WINDOWS
803 FD_SET(fileno(stdin),&readfds); 826 FD_SET(fileno(stdin),&readfds);
804#endif 827#endif
805 FD_SET(s,&readfds); 828 FD_SET(s,&readfds);
806 /* Note: under VMS with SOCKETSHR the second parameter is 829 /* Note: under VMS with SOCKETSHR the second parameter is
807 * currently of type (int *) whereas under other systems 830 * currently of type (int *) whereas under other systems
808 * it is (void *) if you don't have a cast it will choke 831 * it is (void *) if you don't have a cast it will choke
809 * the compiler: if you do have a cast then you can either 832 * the compiler: if you do have a cast then you can either
810 * go for (int *) or (void *). 833 * go for (int *) or (void *).
811 */ 834 */
812 i=select(width,(void *)&readfds,NULL,NULL,NULL); 835#ifdef WINDOWS
813 if (i <= 0) continue; 836 /* Under Windows we can't select on stdin: only
814 if (FD_ISSET(fileno(stdin),&readfds)) 837 * on sockets. As a workaround we timeout the select every
838 * second and check for any keypress. In a proper Windows
839 * application we wouldn't do this because it is inefficient.
840 */
841 tv.tv_sec = 1;
842 tv.tv_usec = 0;
843 i=select(width,(void *)&readfds,NULL,NULL,&tv);
844 if((i < 0) || (!i && !_kbhit() ) )continue;
845 if(_kbhit())
846 read_from_terminal = 1;
847#else
848 i=select(width,(void *)&readfds,NULL,NULL,NULL);
849 if (i <= 0) continue;
850 if (FD_ISSET(fileno(stdin),&readfds))
851 read_from_terminal = 1;
852#endif
853 if (FD_ISSET(s,&readfds))
854 read_from_sslcon = 1;
855 }
856 if (read_from_terminal)
815 { 857 {
816#ifdef APPS_CRLF
817 if (s_crlf) 858 if (s_crlf)
818 { 859 {
819 int j, lf_num; 860 int j, lf_num;
@@ -837,7 +878,6 @@ static int sv_body(char *hostname, int s, unsigned char *context)
837 assert(lf_num == 0); 878 assert(lf_num == 0);
838 } 879 }
839 else 880 else
840#endif
841 i=read(fileno(stdin),buf,bufsize); 881 i=read(fileno(stdin),buf,bufsize);
842 if (!s_quiet) 882 if (!s_quiet)
843 { 883 {
@@ -926,7 +966,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
926 if (i <= 0) break; 966 if (i <= 0) break;
927 } 967 }
928 } 968 }
929 if (FD_ISSET(s,&readfds)) 969 if (read_from_sslcon)
930 { 970 {
931 if (!SSL_is_init_finished(con)) 971 if (!SSL_is_init_finished(con))
932 { 972 {
@@ -1059,12 +1099,12 @@ static int init_ssl_connection(SSL *con)
1059 } 1099 }
1060 1100
1061#ifndef NO_DH 1101#ifndef NO_DH
1062static DH *load_dh_param(void) 1102static DH *load_dh_param(char *dhfile)
1063 { 1103 {
1064 DH *ret=NULL; 1104 DH *ret=NULL;
1065 BIO *bio; 1105 BIO *bio;
1066 1106
1067 if ((bio=BIO_new_file(DH_PARAM,"r")) == NULL) 1107 if ((bio=BIO_new_file(dhfile,"r")) == NULL)
1068 goto err; 1108 goto err;
1069 ret=PEM_read_bio_DHparams(bio,NULL,NULL,NULL); 1109 ret=PEM_read_bio_DHparams(bio,NULL,NULL,NULL);
1070err: 1110err:
@@ -1126,7 +1166,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
1126 /* lets make the output buffer a reasonable size */ 1166 /* lets make the output buffer a reasonable size */
1127 if (!BIO_set_write_buffer_size(io,bufsize)) goto err; 1167 if (!BIO_set_write_buffer_size(io,bufsize)) goto err;
1128 1168
1129 if ((con=(SSL *)SSL_new(ctx)) == NULL) goto err; 1169 if ((con=SSL_new(ctx)) == NULL) goto err;
1130 if(context) SSL_set_session_id_context(con, context, 1170 if(context) SSL_set_session_id_context(con, context,
1131 strlen((char *)context)); 1171 strlen((char *)context));
1132 1172
@@ -1424,7 +1464,7 @@ end:
1424 /* make sure we re-use sessions */ 1464 /* make sure we re-use sessions */
1425 SSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); 1465 SSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
1426#else 1466#else
1427 /* This kills performace */ 1467 /* This kills performance */
1428/* SSL_shutdown(con); A shutdown gets sent in the 1468/* SSL_shutdown(con); A shutdown gets sent in the
1429 * BIO_free_all(io) procession */ 1469 * BIO_free_all(io) procession */
1430#endif 1470#endif
diff --git a/src/lib/libssl/src/apps/s_time.c b/src/lib/libssl/src/apps/s_time.c
index a529e2a119..39fd3b8b4d 100644
--- a/src/lib/libssl/src/apps/s_time.c
+++ b/src/lib/libssl/src/apps/s_time.c
@@ -67,10 +67,6 @@
67#include <stdlib.h> 67#include <stdlib.h>
68#include <string.h> 68#include <string.h>
69 69
70#if defined(NO_RSA) && !defined(NO_SSL2)
71#define NO_SSL2
72#endif
73
74#ifdef NO_STDIO 70#ifdef NO_STDIO
75#define APPS_WIN16 71#define APPS_WIN16
76#endif 72#endif
@@ -220,7 +216,7 @@ static void s_time_usage(void)
220 file if not specified by this option\n\ 216 file if not specified by this option\n\
221-CApath arg - PEM format directory of CA's\n\ 217-CApath arg - PEM format directory of CA's\n\
222-CAfile arg - PEM format file of CA's\n\ 218-CAfile arg - PEM format file of CA's\n\
223-cipher - prefered cipher to use, play with 'openssl ciphers'\n\n"; 219-cipher - preferred cipher to use, play with 'openssl ciphers'\n\n";
224 220
225 printf( "usage: s_time <args>\n\n" ); 221 printf( "usage: s_time <args>\n\n" );
226 222
@@ -229,7 +225,7 @@ static void s_time_usage(void)
229 printf("-nbio - Run with non-blocking IO\n"); 225 printf("-nbio - Run with non-blocking IO\n");
230 printf("-ssl2 - Just use SSLv2\n"); 226 printf("-ssl2 - Just use SSLv2\n");
231 printf("-ssl3 - Just use SSLv3\n"); 227 printf("-ssl3 - Just use SSLv3\n");
232 printf("-bugs - Turn on SSL bug compatability\n"); 228 printf("-bugs - Turn on SSL bug compatibility\n");
233 printf("-new - Just time new connections\n"); 229 printf("-new - Just time new connections\n");
234 printf("-reuse - Just time connection reuse\n"); 230 printf("-reuse - Just time connection reuse\n");
235 printf("-www page - Retrieve 'page' from the site\n"); 231 printf("-www page - Retrieve 'page' from the site\n");
@@ -248,15 +244,6 @@ static int parseArgs(int argc, char **argv)
248 244
249 verify_depth=0; 245 verify_depth=0;
250 verify_error=X509_V_OK; 246 verify_error=X509_V_OK;
251#ifdef FIONBIO
252 t_nbio=0;
253#endif
254
255 apps_startup();
256 s_time_init();
257
258 if (bio_err == NULL)
259 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
260 247
261 argc--; 248 argc--;
262 argv++; 249 argv++;
@@ -401,6 +388,8 @@ static double tm_Time_F(int s)
401 * MAIN - main processing area for client 388 * MAIN - main processing area for client
402 * real name depends on MONOLITH 389 * real name depends on MONOLITH
403 */ 390 */
391int MAIN(int, char **);
392
404int MAIN(int argc, char **argv) 393int MAIN(int argc, char **argv)
405 { 394 {
406 double totalTime = 0.0; 395 double totalTime = 0.0;
@@ -411,6 +400,12 @@ int MAIN(int argc, char **argv)
411 MS_STATIC char buf[1024*8]; 400 MS_STATIC char buf[1024*8];
412 int ver; 401 int ver;
413 402
403 apps_startup();
404 s_time_init();
405
406 if (bio_err == NULL)
407 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
408
414#if !defined(NO_SSL2) && !defined(NO_SSL3) 409#if !defined(NO_SSL2) && !defined(NO_SSL3)
415 s_time_meth=SSLv23_client_method(); 410 s_time_meth=SSLv23_client_method();
416#elif !defined(NO_SSL3) 411#elif !defined(NO_SSL3)
@@ -423,7 +418,7 @@ int MAIN(int argc, char **argv)
423 if( parseArgs( argc, argv ) < 0 ) 418 if( parseArgs( argc, argv ) < 0 )
424 goto end; 419 goto end;
425 420
426 SSLeay_add_ssl_algorithms(); 421 OpenSSL_add_ssl_algorithms();
427 if ((tm_ctx=SSL_CTX_new(s_time_meth)) == NULL) return(1); 422 if ((tm_ctx=SSL_CTX_new(s_time_meth)) == NULL) return(1);
428 423
429 SSL_CTX_set_quiet_shutdown(tm_ctx,1); 424 SSL_CTX_set_quiet_shutdown(tm_ctx,1);
@@ -438,7 +433,7 @@ int MAIN(int argc, char **argv)
438 if ((!SSL_CTX_load_verify_locations(tm_ctx,CAfile,CApath)) || 433 if ((!SSL_CTX_load_verify_locations(tm_ctx,CAfile,CApath)) ||
439 (!SSL_CTX_set_default_verify_paths(tm_ctx))) 434 (!SSL_CTX_set_default_verify_paths(tm_ctx)))
440 { 435 {
441 /* BIO_printf(bio_err,"error seting default verify locations\n"); */ 436 /* BIO_printf(bio_err,"error setting default verify locations\n"); */
442 ERR_print_errors(bio_err); 437 ERR_print_errors(bio_err);
443 /* goto end; */ 438 /* goto end; */
444 } 439 }
@@ -639,7 +634,7 @@ static SSL *doConnection(SSL *scon)
639 BIO_set_conn_hostname(conn,host); 634 BIO_set_conn_hostname(conn,host);
640 635
641 if (scon == NULL) 636 if (scon == NULL)
642 serverCon=(SSL *)SSL_new(tm_ctx); 637 serverCon=SSL_new(tm_ctx);
643 else 638 else
644 { 639 {
645 serverCon=scon; 640 serverCon=scon;
diff --git a/src/lib/libssl/src/apps/sess_id.c b/src/lib/libssl/src/apps/sess_id.c
index 8ac118d4a1..71d5aa0b7c 100644
--- a/src/lib/libssl/src/apps/sess_id.c
+++ b/src/lib/libssl/src/apps/sess_id.c
@@ -72,7 +72,7 @@
72static char *sess_id_usage[]={ 72static char *sess_id_usage[]={
73"usage: sess_id args\n", 73"usage: sess_id args\n",
74"\n", 74"\n",
75" -inform arg - input format - default PEM (one of DER, TXT or PEM)\n", 75" -inform arg - input format - default PEM (DER or PEM)\n",
76" -outform arg - output format - default PEM\n", 76" -outform arg - output format - default PEM\n",
77" -in arg - input file - default stdin\n", 77" -in arg - input file - default stdin\n",
78" -out arg - output file - default stdout\n", 78" -out arg - output file - default stdout\n",
@@ -84,6 +84,9 @@ NULL
84}; 84};
85 85
86static SSL_SESSION *load_sess_id(char *file, int format); 86static SSL_SESSION *load_sess_id(char *file, int format);
87
88int MAIN(int, char **);
89
87int MAIN(int argc, char **argv) 90int MAIN(int argc, char **argv)
88 { 91 {
89 SSL_SESSION *x=NULL; 92 SSL_SESSION *x=NULL;
diff --git a/src/lib/libssl/src/apps/smime.c b/src/lib/libssl/src/apps/smime.c
new file mode 100644
index 0000000000..77633cfb60
--- /dev/null
+++ b/src/lib/libssl/src/apps/smime.c
@@ -0,0 +1,646 @@
1/* smime.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/* S/MIME utility function */
60
61#include <stdio.h>
62#include <string.h>
63#include "apps.h"
64#include <openssl/crypto.h>
65#include <openssl/pem.h>
66#include <openssl/err.h>
67
68#undef PROG
69#define PROG smime_main
70static X509 *load_cert(char *file);
71static EVP_PKEY *load_key(char *file, char *pass);
72static STACK_OF(X509) *load_certs(char *file);
73static X509_STORE *setup_verify(char *CAfile, char *CApath);
74static int save_certs(char *signerfile, STACK_OF(X509) *signers);
75
76#define SMIME_OP 0x10
77#define SMIME_ENCRYPT (1 | SMIME_OP)
78#define SMIME_DECRYPT 2
79#define SMIME_SIGN (3 | SMIME_OP)
80#define SMIME_VERIFY 4
81#define SMIME_PK7OUT 5
82
83int MAIN(int, char **);
84
85int MAIN(int argc, char **argv)
86{
87 int operation = 0;
88 int ret = 0;
89 char **args;
90 char *inmode = "r", *outmode = "w";
91 char *infile = NULL, *outfile = NULL;
92 char *signerfile = NULL, *recipfile = NULL;
93 char *certfile = NULL, *keyfile = NULL;
94 EVP_CIPHER *cipher = NULL;
95 PKCS7 *p7 = NULL;
96 X509_STORE *store = NULL;
97 X509 *cert = NULL, *recip = NULL, *signer = NULL;
98 EVP_PKEY *key = NULL;
99 STACK_OF(X509) *encerts = NULL, *other = NULL;
100 BIO *in = NULL, *out = NULL, *indata = NULL;
101 int badarg = 0;
102 int flags = PKCS7_DETACHED;
103 char *to = NULL, *from = NULL, *subject = NULL;
104 char *CAfile = NULL, *CApath = NULL;
105 char *passargin = NULL, *passin = NULL;
106 char *inrand = NULL;
107 int need_rand = 0;
108 args = argv + 1;
109
110 ret = 1;
111
112 while (!badarg && *args && *args[0] == '-') {
113 if (!strcmp (*args, "-encrypt")) operation = SMIME_ENCRYPT;
114 else if (!strcmp (*args, "-decrypt")) operation = SMIME_DECRYPT;
115 else if (!strcmp (*args, "-sign")) operation = SMIME_SIGN;
116 else if (!strcmp (*args, "-verify")) operation = SMIME_VERIFY;
117 else if (!strcmp (*args, "-pk7out")) operation = SMIME_PK7OUT;
118#ifndef NO_DES
119 else if (!strcmp (*args, "-des3"))
120 cipher = EVP_des_ede3_cbc();
121 else if (!strcmp (*args, "-des"))
122 cipher = EVP_des_cbc();
123#endif
124#ifndef NO_RC2
125 else if (!strcmp (*args, "-rc2-40"))
126 cipher = EVP_rc2_40_cbc();
127 else if (!strcmp (*args, "-rc2-128"))
128 cipher = EVP_rc2_cbc();
129 else if (!strcmp (*args, "-rc2-64"))
130 cipher = EVP_rc2_64_cbc();
131#endif
132 else if (!strcmp (*args, "-text"))
133 flags |= PKCS7_TEXT;
134 else if (!strcmp (*args, "-nointern"))
135 flags |= PKCS7_NOINTERN;
136 else if (!strcmp (*args, "-noverify"))
137 flags |= PKCS7_NOVERIFY;
138 else if (!strcmp (*args, "-nochain"))
139 flags |= PKCS7_NOCHAIN;
140 else if (!strcmp (*args, "-nocerts"))
141 flags |= PKCS7_NOCERTS;
142 else if (!strcmp (*args, "-noattr"))
143 flags |= PKCS7_NOATTR;
144 else if (!strcmp (*args, "-nodetach"))
145 flags &= ~PKCS7_DETACHED;
146 else if (!strcmp (*args, "-binary"))
147 flags |= PKCS7_BINARY;
148 else if (!strcmp (*args, "-nosigs"))
149 flags |= PKCS7_NOSIGS;
150 else if (!strcmp(*args,"-rand")) {
151 if (args[1]) {
152 args++;
153 inrand = *args;
154 } else badarg = 1;
155 need_rand = 1;
156 } else if (!strcmp(*args,"-passin")) {
157 if (args[1]) {
158 args++;
159 passargin = *args;
160 } else badarg = 1;
161 } else if (!strcmp (*args, "-to")) {
162 if (args[1]) {
163 args++;
164 to = *args;
165 } else badarg = 1;
166 } else if (!strcmp (*args, "-from")) {
167 if (args[1]) {
168 args++;
169 from = *args;
170 } else badarg = 1;
171 } else if (!strcmp (*args, "-subject")) {
172 if (args[1]) {
173 args++;
174 subject = *args;
175 } else badarg = 1;
176 } else if (!strcmp (*args, "-signer")) {
177 if (args[1]) {
178 args++;
179 signerfile = *args;
180 } else badarg = 1;
181 } else if (!strcmp (*args, "-recip")) {
182 if (args[1]) {
183 args++;
184 recipfile = *args;
185 } else badarg = 1;
186 } else if (!strcmp (*args, "-inkey")) {
187 if (args[1]) {
188 args++;
189 keyfile = *args;
190 } else badarg = 1;
191 } else if (!strcmp (*args, "-certfile")) {
192 if (args[1]) {
193 args++;
194 certfile = *args;
195 } else badarg = 1;
196 } else if (!strcmp (*args, "-CAfile")) {
197 if (args[1]) {
198 args++;
199 CAfile = *args;
200 } else badarg = 1;
201 } else if (!strcmp (*args, "-CApath")) {
202 if (args[1]) {
203 args++;
204 CApath = *args;
205 } else badarg = 1;
206 } else if (!strcmp (*args, "-in")) {
207 if (args[1]) {
208 args++;
209 infile = *args;
210 } else badarg = 1;
211 } else if (!strcmp (*args, "-out")) {
212 if (args[1]) {
213 args++;
214 outfile = *args;
215 } else badarg = 1;
216 } else badarg = 1;
217 args++;
218 }
219
220 if(operation == SMIME_SIGN) {
221 if(!signerfile) {
222 BIO_printf(bio_err, "No signer certificate specified\n");
223 badarg = 1;
224 }
225 need_rand = 1;
226 } else if(operation == SMIME_DECRYPT) {
227 if(!recipfile) {
228 BIO_printf(bio_err, "No recipient certificate and key specified\n");
229 badarg = 1;
230 }
231 } else if(operation == SMIME_ENCRYPT) {
232 if(!*args) {
233 BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
234 badarg = 1;
235 }
236 need_rand = 1;
237 } else if(!operation) badarg = 1;
238
239 if (badarg) {
240 BIO_printf (bio_err, "Usage smime [options] cert.pem ...\n");
241 BIO_printf (bio_err, "where options are\n");
242 BIO_printf (bio_err, "-encrypt encrypt message\n");
243 BIO_printf (bio_err, "-decrypt decrypt encrypted message\n");
244 BIO_printf (bio_err, "-sign sign message\n");
245 BIO_printf (bio_err, "-verify verify signed message\n");
246 BIO_printf (bio_err, "-pk7out output PKCS#7 structure\n");
247#ifndef NO_DES
248 BIO_printf (bio_err, "-des3 encrypt with triple DES\n");
249 BIO_printf (bio_err, "-des encrypt with DES\n");
250#endif
251#ifndef NO_RC2
252 BIO_printf (bio_err, "-rc2-40 encrypt with RC2-40 (default)\n");
253 BIO_printf (bio_err, "-rc2-64 encrypt with RC2-64\n");
254 BIO_printf (bio_err, "-rc2-128 encrypt with RC2-128\n");
255#endif
256 BIO_printf (bio_err, "-nointern don't search certificates in message for signer\n");
257 BIO_printf (bio_err, "-nosigs don't verify message signature\n");
258 BIO_printf (bio_err, "-noverify don't verify signers certificate\n");
259 BIO_printf (bio_err, "-nocerts don't include signers certificate when signing\n");
260 BIO_printf (bio_err, "-nodetach use opaque signing\n");
261 BIO_printf (bio_err, "-noattr don't include any signed attributes\n");
262 BIO_printf (bio_err, "-binary don't translate message to text\n");
263 BIO_printf (bio_err, "-certfile file other certificates file\n");
264 BIO_printf (bio_err, "-signer file signer certificate file\n");
265 BIO_printf (bio_err, "-recip file recipient certificate file for decryption\n");
266 BIO_printf (bio_err, "-in file input file\n");
267 BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n");
268 BIO_printf (bio_err, "-out file output file\n");
269 BIO_printf (bio_err, "-to addr to address\n");
270 BIO_printf (bio_err, "-from ad from address\n");
271 BIO_printf (bio_err, "-subject s subject\n");
272 BIO_printf (bio_err, "-text include or delete text MIME headers\n");
273 BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
274 BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
275 BIO_printf(bio_err, "-rand file:file:...\n");
276 BIO_printf(bio_err, " load the file (or the files in the directory) into\n");
277 BIO_printf(bio_err, " the random number generator\n");
278 BIO_printf (bio_err, "cert.pem recipient certificate(s) for encryption\n");
279 goto end;
280 }
281
282 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
283 BIO_printf(bio_err, "Error getting password\n");
284 goto end;
285 }
286
287 if (need_rand) {
288 app_RAND_load_file(NULL, bio_err, (inrand != NULL));
289 if (inrand != NULL)
290 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
291 app_RAND_load_files(inrand));
292 }
293
294 ret = 2;
295
296 if(operation != SMIME_SIGN) flags &= ~PKCS7_DETACHED;
297
298 if(flags & PKCS7_BINARY) {
299 if(operation & SMIME_OP) inmode = "rb";
300 else outmode = "rb";
301 }
302
303 if(operation == SMIME_ENCRYPT) {
304 if (!cipher) {
305#ifndef NO_RC2
306 cipher = EVP_rc2_40_cbc();
307#else
308 BIO_printf(bio_err, "No cipher selected\n");
309 goto end;
310#endif
311 }
312#ifdef CRYPTO_MDEBUG
313 CRYPTO_push_info("load encryption certificates");
314#endif
315 encerts = sk_X509_new_null();
316 while (*args) {
317 if(!(cert = load_cert(*args))) {
318 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", *args);
319 goto end;
320 }
321 sk_X509_push(encerts, cert);
322 cert = NULL;
323 args++;
324 }
325#ifdef CRYPTO_MDEBUG
326 CRYPTO_pop_info();
327#endif
328 }
329
330 if(signerfile && (operation == SMIME_SIGN)) {
331#ifdef CRYPTO_MDEBUG
332 CRYPTO_push_info("load signer certificate");
333#endif
334 if(!(signer = load_cert(signerfile))) {
335 BIO_printf(bio_err, "Can't read signer certificate file %s\n", signerfile);
336 goto end;
337 }
338#ifdef CRYPTO_MDEBUG
339 CRYPTO_pop_info();
340#endif
341 }
342
343 if(certfile) {
344#ifdef CRYPTO_MDEBUG
345 CRYPTO_push_info("load other certfiles");
346#endif
347 if(!(other = load_certs(certfile))) {
348 BIO_printf(bio_err, "Can't read certificate file %s\n", certfile);
349 ERR_print_errors(bio_err);
350 goto end;
351 }
352#ifdef CRYPTO_MDEBUG
353 CRYPTO_pop_info();
354#endif
355 }
356
357 if(recipfile && (operation == SMIME_DECRYPT)) {
358#ifdef CRYPTO_MDEBUG
359 CRYPTO_push_info("load recipient certificate");
360#endif
361 if(!(recip = load_cert(recipfile))) {
362 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", recipfile);
363 ERR_print_errors(bio_err);
364 goto end;
365 }
366#ifdef CRYPTO_MDEBUG
367 CRYPTO_pop_info();
368#endif
369 }
370
371 if(operation == SMIME_DECRYPT) {
372 if(!keyfile) keyfile = recipfile;
373 } else if(operation == SMIME_SIGN) {
374 if(!keyfile) keyfile = signerfile;
375 } else keyfile = NULL;
376
377 if(keyfile) {
378#ifdef CRYPTO_MDEBUG
379 CRYPTO_push_info("load keyfile");
380#endif
381 if(!(key = load_key(keyfile, passin))) {
382 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", keyfile);
383 ERR_print_errors(bio_err);
384 goto end;
385 }
386#ifdef CRYPTO_MDEBUG
387 CRYPTO_pop_info();
388#endif
389 }
390
391#ifdef CRYPTO_MDEBUG
392 CRYPTO_push_info("open input files");
393#endif
394 if (infile) {
395 if (!(in = BIO_new_file(infile, inmode))) {
396 BIO_printf (bio_err,
397 "Can't open input file %s\n", infile);
398 goto end;
399 }
400 } else in = BIO_new_fp(stdin, BIO_NOCLOSE);
401#ifdef CRYPTO_MDEBUG
402 CRYPTO_pop_info();
403#endif
404
405#ifdef CRYPTO_MDEBUG
406 CRYPTO_push_info("open output files");
407#endif
408 if (outfile) {
409 if (!(out = BIO_new_file(outfile, outmode))) {
410 BIO_printf (bio_err,
411 "Can't open output file %s\n", outfile);
412 goto end;
413 }
414 } else out = BIO_new_fp(stdout, BIO_NOCLOSE);
415#ifdef CRYPTO_MDEBUG
416 CRYPTO_pop_info();
417#endif
418
419 if(operation == SMIME_VERIFY) {
420#ifdef CRYPTO_MDEBUG
421 CRYPTO_push_info("setup_verify");
422#endif
423 if(!(store = setup_verify(CAfile, CApath))) goto end;
424#ifdef CRYPTO_MDEBUG
425 CRYPTO_pop_info();
426#endif
427 }
428
429 ret = 3;
430
431 if(operation == SMIME_ENCRYPT) {
432#ifdef CRYPTO_MDEBUG
433 CRYPTO_push_info("PKCS7_encrypt");
434#endif
435 p7 = PKCS7_encrypt(encerts, in, cipher, flags);
436#ifdef CRYPTO_MDEBUG
437 CRYPTO_pop_info();
438#endif
439 } else if(operation == SMIME_SIGN) {
440#ifdef CRYPTO_MDEBUG
441 CRYPTO_push_info("PKCS7_sign");
442#endif
443 p7 = PKCS7_sign(signer, key, other, in, flags);
444 BIO_reset(in);
445#ifdef CRYPTO_MDEBUG
446 CRYPTO_pop_info();
447#endif
448 } else {
449#ifdef CRYPTO_MDEBUG
450 CRYPTO_push_info("SMIME_read_PKCS7");
451#endif
452 if(!(p7 = SMIME_read_PKCS7(in, &indata))) {
453 BIO_printf(bio_err, "Error reading S/MIME message\n");
454 goto end;
455 }
456#ifdef CRYPTO_MDEBUG
457 CRYPTO_pop_info();
458#endif
459 }
460
461 if(!p7) {
462 BIO_printf(bio_err, "Error creating PKCS#7 structure\n");
463 goto end;
464 }
465
466 ret = 4;
467 if(operation == SMIME_DECRYPT) {
468#ifdef CRYPTO_MDEBUG
469 CRYPTO_push_info("PKCS7_decrypt");
470#endif
471 if(!PKCS7_decrypt(p7, key, recip, out, flags)) {
472 BIO_printf(bio_err, "Error decrypting PKCS#7 structure\n");
473 goto end;
474 }
475#ifdef CRYPTO_MDEBUG
476 CRYPTO_pop_info();
477#endif
478 } else if(operation == SMIME_VERIFY) {
479 STACK_OF(X509) *signers;
480#ifdef CRYPTO_MDEBUG
481 CRYPTO_push_info("PKCS7_verify");
482#endif
483 if(PKCS7_verify(p7, other, store, indata, out, flags)) {
484 BIO_printf(bio_err, "Verification Successful\n");
485 } else {
486 BIO_printf(bio_err, "Verification Failure\n");
487 goto end;
488 }
489#ifdef CRYPTO_MDEBUG
490 CRYPTO_pop_info();
491 CRYPTO_push_info("PKCS7_get0_signers");
492#endif
493 signers = PKCS7_get0_signers(p7, other, flags);
494#ifdef CRYPTO_MDEBUG
495 CRYPTO_pop_info();
496 CRYPTO_push_info("save_certs");
497#endif
498 if(!save_certs(signerfile, signers)) {
499 BIO_printf(bio_err, "Error writing signers to %s\n",
500 signerfile);
501 ret = 5;
502 goto end;
503 }
504#ifdef CRYPTO_MDEBUG
505 CRYPTO_pop_info();
506#endif
507 sk_X509_free(signers);
508 } else if(operation == SMIME_PK7OUT) {
509 PEM_write_bio_PKCS7(out, p7);
510 } else {
511 if(to) BIO_printf(out, "To: %s\n", to);
512 if(from) BIO_printf(out, "From: %s\n", from);
513 if(subject) BIO_printf(out, "Subject: %s\n", subject);
514 SMIME_write_PKCS7(out, p7, in, flags);
515 }
516 ret = 0;
517end:
518#ifdef CRYPTO_MDEBUG
519 CRYPTO_remove_all_info();
520#endif
521 if (need_rand)
522 app_RAND_write_file(NULL, bio_err);
523 if(ret) ERR_print_errors(bio_err);
524 sk_X509_pop_free(encerts, X509_free);
525 sk_X509_pop_free(other, X509_free);
526 X509_STORE_free(store);
527 X509_free(cert);
528 X509_free(recip);
529 X509_free(signer);
530 EVP_PKEY_free(key);
531 PKCS7_free(p7);
532 BIO_free(in);
533 BIO_free(indata);
534 BIO_free(out);
535 if(passin) Free(passin);
536 return (ret);
537}
538
539static X509 *load_cert(char *file)
540{
541 BIO *in;
542 X509 *cert;
543 if(!(in = BIO_new_file(file, "r"))) return NULL;
544 cert = PEM_read_bio_X509(in, NULL, NULL,NULL);
545 BIO_free(in);
546 return cert;
547}
548
549static EVP_PKEY *load_key(char *file, char *pass)
550{
551 BIO *in;
552 EVP_PKEY *key;
553 if(!(in = BIO_new_file(file, "r"))) return NULL;
554 key = PEM_read_bio_PrivateKey(in, NULL,NULL,pass);
555 BIO_free(in);
556 return key;
557}
558
559static STACK_OF(X509) *load_certs(char *file)
560{
561 BIO *in;
562 int i;
563 STACK_OF(X509) *othercerts;
564 STACK_OF(X509_INFO) *allcerts;
565 X509_INFO *xi;
566 if(!(in = BIO_new_file(file, "r"))) return NULL;
567 othercerts = sk_X509_new(NULL);
568 if(!othercerts) return NULL;
569 allcerts = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
570 for(i = 0; i < sk_X509_INFO_num(allcerts); i++) {
571 xi = sk_X509_INFO_value (allcerts, i);
572 if (xi->x509) {
573 sk_X509_push(othercerts, xi->x509);
574 xi->x509 = NULL;
575 }
576 }
577 sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
578 BIO_free(in);
579 return othercerts;
580}
581
582static X509_STORE *setup_verify(char *CAfile, char *CApath)
583{
584 X509_STORE *store;
585 X509_LOOKUP *lookup;
586#ifdef CRYPTO_MDEBUG
587 CRYPTO_push_info("X509_STORE_new");
588#endif
589 if(!(store = X509_STORE_new())) goto end;
590#ifdef CRYPTO_MDEBUG
591 CRYPTO_pop_info();
592 CRYPTO_push_info("X509_STORE_add_lookup(...file)");
593#endif
594 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
595 if (lookup == NULL) goto end;
596#ifdef CRYPTO_MDEBUG
597 CRYPTO_pop_info();
598 CRYPTO_push_info("X509_LOOKUP_load_file");
599#endif
600 if (CAfile) {
601 if(!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) {
602 BIO_printf(bio_err, "Error loading file %s\n", CAfile);
603 goto end;
604 }
605 } else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
606
607#ifdef CRYPTO_MDEBUG
608 CRYPTO_pop_info();
609 CRYPTO_push_info("X509_STORE_add_lookup(...hash_dir)");
610#endif
611 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
612 if (lookup == NULL) goto end;
613#ifdef CRYPTO_MDEBUG
614 CRYPTO_pop_info();
615 CRYPTO_push_info("X509_LOOKUP_add_dir");
616#endif
617 if (CApath) {
618 if(!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) {
619 BIO_printf(bio_err, "Error loading directory %s\n", CApath);
620 goto end;
621 }
622 } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
623#ifdef CRYPTO_MDEBUG
624 CRYPTO_pop_info();
625#endif
626
627 ERR_clear_error();
628 return store;
629 end:
630 X509_STORE_free(store);
631 return NULL;
632}
633
634static int save_certs(char *signerfile, STACK_OF(X509) *signers)
635{
636 int i;
637 BIO *tmp;
638 if(!signerfile) return 1;
639 tmp = BIO_new_file(signerfile, "w");
640 if(!tmp) return 0;
641 for(i = 0; i < sk_X509_num(signers); i++)
642 PEM_write_bio_X509(tmp, sk_X509_value(signers, i));
643 BIO_free(tmp);
644 return 1;
645}
646
diff --git a/src/lib/libssl/src/apps/speed.c b/src/lib/libssl/src/apps/speed.c
index 3cfb4dbea2..b3130def8b 100644
--- a/src/lib/libssl/src/apps/speed.c
+++ b/src/lib/libssl/src/apps/speed.c
@@ -238,16 +238,19 @@ static double Time_F(int s)
238#endif 238#endif
239 } 239 }
240 240
241int MAIN(int, char **);
242
241int MAIN(int argc, char **argv) 243int MAIN(int argc, char **argv)
242 { 244 {
243 unsigned char *buf=NULL,*buf2=NULL; 245 unsigned char *buf=NULL,*buf2=NULL;
244 int ret=1; 246 int mret=1;
245#define ALGOR_NUM 14 247#define ALGOR_NUM 14
246#define SIZE_NUM 5 248#define SIZE_NUM 5
247#define RSA_NUM 4 249#define RSA_NUM 4
248#define DSA_NUM 3 250#define DSA_NUM 3
249 long count,rsa_count; 251 long count,rsa_count;
250 int i,j,k,rsa_num,rsa_num2; 252 int i,j,k;
253 unsigned rsa_num,rsa_num2;
251#ifndef NO_MD2 254#ifndef NO_MD2
252 unsigned char md2[MD2_DIGEST_LENGTH]; 255 unsigned char md2[MD2_DIGEST_LENGTH];
253#endif 256#endif
@@ -344,6 +347,7 @@ int MAIN(int argc, char **argv)
344 int pr_header=0; 347 int pr_header=0;
345 348
346 apps_startup(); 349 apps_startup();
350 memset(results, 0, sizeof(results));
347#ifndef NO_DSA 351#ifndef NO_DSA
348 memset(dsa_key,0,sizeof(dsa_key)); 352 memset(dsa_key,0,sizeof(dsa_key));
349#endif 353#endif
@@ -421,7 +425,7 @@ int MAIN(int argc, char **argv)
421 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1; 425 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
422 else 426 else
423#endif 427#endif
424#ifndef NO_DEF 428#ifndef NO_DES
425 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1; 429 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
426 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1; 430 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
427 else 431 else
@@ -435,12 +439,14 @@ int MAIN(int argc, char **argv)
435 } 439 }
436 else 440 else
437#endif 441#endif
442#ifndef RSA_NULL
438 if (strcmp(*argv,"openssl") == 0) 443 if (strcmp(*argv,"openssl") == 0)
439 { 444 {
440 RSA_set_default_method(RSA_PKCS1_SSLeay()); 445 RSA_set_default_method(RSA_PKCS1_SSLeay());
441 j--; 446 j--;
442 } 447 }
443 else 448 else
449#endif
444#endif /* !NO_RSA */ 450#endif /* !NO_RSA */
445 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2; 451 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
446 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2; 452 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
@@ -586,9 +592,9 @@ int MAIN(int argc, char **argv)
586#endif 592#endif
587 593
588#ifndef NO_DES 594#ifndef NO_DES
589 des_set_key(&key,sch); 595 des_set_key_unchecked(&key,sch);
590 des_set_key(&key2,sch2); 596 des_set_key_unchecked(&key2,sch2);
591 des_set_key(&key3,sch3); 597 des_set_key_unchecked(&key3,sch3);
592#endif 598#endif
593#ifndef NO_IDEA 599#ifndef NO_IDEA
594 idea_set_encrypt_key(key16,&idea_ks); 600 idea_set_encrypt_key(key16,&idea_ks);
@@ -612,6 +618,7 @@ int MAIN(int argc, char **argv)
612 memset(rsa_c,0,sizeof(rsa_c)); 618 memset(rsa_c,0,sizeof(rsa_c));
613#endif 619#endif
614#ifndef SIGALRM 620#ifndef SIGALRM
621#ifndef NO_DES
615 BIO_printf(bio_err,"First we calculate the approximate speed ...\n"); 622 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
616 count=10; 623 count=10;
617 do { 624 do {
@@ -703,10 +710,14 @@ int MAIN(int argc, char **argv)
703#define COND(d) (count < (d)) 710#define COND(d) (count < (d))
704#define COUNT(d) (d) 711#define COUNT(d) (d)
705#else 712#else
713/* not worth fixing */
714# error "You cannot disable DES on systems without SIGALRM."
715#endif /* NO_DES */
716#else
706#define COND(c) (run) 717#define COND(c) (run)
707#define COUNT(d) (count) 718#define COUNT(d) (count)
708 signal(SIGALRM,sig_done); 719 signal(SIGALRM,sig_done);
709#endif 720#endif /* SIGALRM */
710 721
711#ifndef NO_MD2 722#ifndef NO_MD2
712 if (doit[D_MD2]) 723 if (doit[D_MD2])
@@ -956,22 +967,22 @@ int MAIN(int argc, char **argv)
956 } 967 }
957#endif 968#endif
958 969
959 RAND_bytes(buf,30); 970 RAND_pseudo_bytes(buf,36);
960#ifndef NO_RSA 971#ifndef NO_RSA
961 for (j=0; j<RSA_NUM; j++) 972 for (j=0; j<RSA_NUM; j++)
962 { 973 {
974 int ret;
963 if (!rsa_doit[j]) continue; 975 if (!rsa_doit[j]) continue;
964 rsa_num=RSA_private_encrypt(30,buf,buf2,rsa_key[j], 976 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
965 RSA_PKCS1_PADDING);
966 pkey_print_message("private","rsa",rsa_c[j][0],rsa_bits[j], 977 pkey_print_message("private","rsa",rsa_c[j][0],rsa_bits[j],
967 RSA_SECONDS); 978 RSA_SECONDS);
968/* RSA_blinding_on(rsa_key[j],NULL); */ 979/* RSA_blinding_on(rsa_key[j],NULL); */
969 Time_F(START); 980 Time_F(START);
970 for (count=0,run=1; COND(rsa_c[j][0]); count++) 981 for (count=0,run=1; COND(rsa_c[j][0]); count++)
971 { 982 {
972 rsa_num=RSA_private_encrypt(30,buf,buf2,rsa_key[j], 983 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num,
973 RSA_PKCS1_PADDING); 984 rsa_key[j]);
974 if (rsa_num <= 0) 985 if (ret <= 0)
975 { 986 {
976 BIO_printf(bio_err,"RSA private encrypt failure\n"); 987 BIO_printf(bio_err,"RSA private encrypt failure\n");
977 ERR_print_errors(bio_err); 988 ERR_print_errors(bio_err);
@@ -986,18 +997,17 @@ int MAIN(int argc, char **argv)
986 rsa_count=count; 997 rsa_count=count;
987 998
988#if 1 999#if 1
989 rsa_num2=RSA_public_decrypt(rsa_num,buf2,buf,rsa_key[j], 1000 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
990 RSA_PKCS1_PADDING);
991 pkey_print_message("public","rsa",rsa_c[j][1],rsa_bits[j], 1001 pkey_print_message("public","rsa",rsa_c[j][1],rsa_bits[j],
992 RSA_SECONDS); 1002 RSA_SECONDS);
993 Time_F(START); 1003 Time_F(START);
994 for (count=0,run=1; COND(rsa_c[j][1]); count++) 1004 for (count=0,run=1; COND(rsa_c[j][1]); count++)
995 { 1005 {
996 rsa_num2=RSA_public_decrypt(rsa_num,buf2,buf,rsa_key[j], 1006 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num,
997 RSA_PKCS1_PADDING); 1007 rsa_key[j]);
998 if (rsa_num2 <= 0) 1008 if (ret <= 0)
999 { 1009 {
1000 BIO_printf(bio_err,"RSA public encrypt failure\n"); 1010 BIO_printf(bio_err,"RSA verify failure\n");
1001 ERR_print_errors(bio_err); 1011 ERR_print_errors(bio_err);
1002 count=1; 1012 count=1;
1003 break; 1013 break;
@@ -1018,7 +1028,7 @@ int MAIN(int argc, char **argv)
1018 } 1028 }
1019#endif 1029#endif
1020 1030
1021 RAND_bytes(buf,20); 1031 RAND_pseudo_bytes(buf,20);
1022#ifndef NO_DSA 1032#ifndef NO_DSA
1023 for (j=0; j<DSA_NUM; j++) 1033 for (j=0; j<DSA_NUM; j++)
1024 { 1034 {
@@ -1036,7 +1046,7 @@ int MAIN(int argc, char **argv)
1036 { 1046 {
1037 rsa_num=DSA_sign(EVP_PKEY_DSA,buf,20,buf2, 1047 rsa_num=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1038 &kk,dsa_key[j]); 1048 &kk,dsa_key[j]);
1039 if (rsa_num <= 0) 1049 if (rsa_num == 0)
1040 { 1050 {
1041 BIO_printf(bio_err,"DSA sign failure\n"); 1051 BIO_printf(bio_err,"DSA sign failure\n");
1042 ERR_print_errors(bio_err); 1052 ERR_print_errors(bio_err);
@@ -1059,7 +1069,7 @@ int MAIN(int argc, char **argv)
1059 { 1069 {
1060 rsa_num2=DSA_verify(EVP_PKEY_DSA,buf,20,buf2, 1070 rsa_num2=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1061 kk,dsa_key[j]); 1071 kk,dsa_key[j]);
1062 if (rsa_num2 <= 0) 1072 if (rsa_num2 == 0)
1063 { 1073 {
1064 BIO_printf(bio_err,"DSA verify failure\n"); 1074 BIO_printf(bio_err,"DSA verify failure\n");
1065 ERR_print_errors(bio_err); 1075 ERR_print_errors(bio_err);
@@ -1155,7 +1165,7 @@ int MAIN(int argc, char **argv)
1155 fprintf(stdout,"\n"); 1165 fprintf(stdout,"\n");
1156 } 1166 }
1157#endif 1167#endif
1158 ret=0; 1168 mret=0;
1159end: 1169end:
1160 if (buf != NULL) Free(buf); 1170 if (buf != NULL) Free(buf);
1161 if (buf2 != NULL) Free(buf2); 1171 if (buf2 != NULL) Free(buf2);
@@ -1169,7 +1179,7 @@ end:
1169 if (dsa_key[i] != NULL) 1179 if (dsa_key[i] != NULL)
1170 DSA_free(dsa_key[i]); 1180 DSA_free(dsa_key[i]);
1171#endif 1181#endif
1172 EXIT(ret); 1182 EXIT(mret);
1173 } 1183 }
1174 1184
1175static void print_message(char *s, long num, int length) 1185static void print_message(char *s, long num, int length)
diff --git a/src/lib/libssl/src/apps/spkac.c b/src/lib/libssl/src/apps/spkac.c
new file mode 100644
index 0000000000..b35354a8d7
--- /dev/null
+++ b/src/lib/libssl/src/apps/spkac.c
@@ -0,0 +1,274 @@
1/* apps/spkac.c */
2
3/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
4 * project 1999. Based on an original idea by Massimiliano Pala
5 * (madwolf@openca.org).
6 */
7/* ====================================================================
8 * Copyright (c) 1999 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#include <stdio.h>
61#include <stdlib.h>
62#include <string.h>
63#include <time.h>
64#include "apps.h"
65#include <openssl/bio.h>
66#include <openssl/err.h>
67#include <openssl/evp.h>
68#include <openssl/x509.h>
69#include <openssl/pem.h>
70
71#undef PROG
72#define PROG spkac_main
73
74/* -in arg - input file - default stdin
75 * -out arg - output file - default stdout
76 */
77
78int MAIN(int, char **);
79
80int MAIN(int argc, char **argv)
81 {
82 int i,badops=0, ret = 1;
83 BIO *in = NULL,*out = NULL, *key = NULL;
84 int verify=0,noout=0,pubkey=0;
85 char *infile = NULL,*outfile = NULL,*prog;
86 char *passargin = NULL, *passin = NULL;
87 char *spkac = "SPKAC", *spksect = "default", *spkstr = NULL;
88 char *challenge = NULL, *keyfile = NULL;
89 LHASH *conf = NULL;
90 NETSCAPE_SPKI *spki = NULL;
91 EVP_PKEY *pkey = NULL;
92
93 apps_startup();
94
95 if (!bio_err) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
96
97 prog=argv[0];
98 argc--;
99 argv++;
100 while (argc >= 1)
101 {
102 if (strcmp(*argv,"-in") == 0)
103 {
104 if (--argc < 1) goto bad;
105 infile= *(++argv);
106 }
107 else if (strcmp(*argv,"-out") == 0)
108 {
109 if (--argc < 1) goto bad;
110 outfile= *(++argv);
111 }
112 else if (strcmp(*argv,"-passin") == 0)
113 {
114 if (--argc < 1) goto bad;
115 passargin= *(++argv);
116 }
117 else if (strcmp(*argv,"-key") == 0)
118 {
119 if (--argc < 1) goto bad;
120 keyfile= *(++argv);
121 }
122 else if (strcmp(*argv,"-challenge") == 0)
123 {
124 if (--argc < 1) goto bad;
125 challenge= *(++argv);
126 }
127 else if (strcmp(*argv,"-spkac") == 0)
128 {
129 if (--argc < 1) goto bad;
130 spkac= *(++argv);
131 }
132 else if (strcmp(*argv,"-spksect") == 0)
133 {
134 if (--argc < 1) goto bad;
135 spksect= *(++argv);
136 }
137 else if (strcmp(*argv,"-noout") == 0)
138 noout=1;
139 else if (strcmp(*argv,"-pubkey") == 0)
140 pubkey=1;
141 else if (strcmp(*argv,"-verify") == 0)
142 verify=1;
143 else badops = 1;
144 argc--;
145 argv++;
146 }
147
148 if (badops)
149 {
150bad:
151 BIO_printf(bio_err,"%s [options]\n",prog);
152 BIO_printf(bio_err,"where options are\n");
153 BIO_printf(bio_err," -in arg input file\n");
154 BIO_printf(bio_err," -out arg output file\n");
155 BIO_printf(bio_err," -key arg create SPKAC using private key\n");
156 BIO_printf(bio_err," -passin arg input file pass phrase source\n");
157 BIO_printf(bio_err," -challenge arg challenge string\n");
158 BIO_printf(bio_err," -spkac arg alternative SPKAC name\n");
159 BIO_printf(bio_err," -noout don't print SPKAC\n");
160 BIO_printf(bio_err," -pubkey output public key\n");
161 BIO_printf(bio_err," -verify verify SPKAC signature\n");
162 goto end;
163 }
164
165 ERR_load_crypto_strings();
166 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
167 BIO_printf(bio_err, "Error getting password\n");
168 goto end;
169 }
170
171 if(keyfile) {
172 if(strcmp(keyfile, "-")) key = BIO_new_file(keyfile, "r");
173 else key = BIO_new_fp(stdin, BIO_NOCLOSE);
174 if(!key) {
175 BIO_printf(bio_err, "Error opening key file\n");
176 ERR_print_errors(bio_err);
177 goto end;
178 }
179 pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, passin);
180 if(!pkey) {
181 BIO_printf(bio_err, "Error reading private key\n");
182 ERR_print_errors(bio_err);
183 goto end;
184 }
185 spki = NETSCAPE_SPKI_new();
186 if(challenge) ASN1_STRING_set(spki->spkac->challenge,
187 challenge, strlen(challenge));
188 NETSCAPE_SPKI_set_pubkey(spki, pkey);
189 NETSCAPE_SPKI_sign(spki, pkey, EVP_md5());
190 spkstr = NETSCAPE_SPKI_b64_encode(spki);
191
192 if (outfile) out = BIO_new_file(outfile, "w");
193 else out = BIO_new_fp(stdout, BIO_NOCLOSE);
194
195 if(!out) {
196 BIO_printf(bio_err, "Error opening output file\n");
197 ERR_print_errors(bio_err);
198 goto end;
199 }
200 BIO_printf(out, "SPKAC=%s\n", spkstr);
201 Free(spkstr);
202 ret = 0;
203 goto end;
204 }
205
206
207
208 if (infile) in = BIO_new_file(infile, "r");
209 else in = BIO_new_fp(stdin, BIO_NOCLOSE);
210
211 if(!in) {
212 BIO_printf(bio_err, "Error opening input file\n");
213 ERR_print_errors(bio_err);
214 goto end;
215 }
216
217 conf = CONF_load_bio(NULL, in, NULL);
218
219 if(!conf) {
220 BIO_printf(bio_err, "Error parsing config file\n");
221 ERR_print_errors(bio_err);
222 goto end;
223 }
224
225 spkstr = CONF_get_string(conf, spksect, spkac);
226
227 if(!spkstr) {
228 BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", spkac);
229 ERR_print_errors(bio_err);
230 goto end;
231 }
232
233 spki = NETSCAPE_SPKI_b64_decode(spkstr, -1);
234
235 if(!spki) {
236 BIO_printf(bio_err, "Error loading SPKAC\n");
237 ERR_print_errors(bio_err);
238 goto end;
239 }
240
241 if (outfile) out = BIO_new_file(outfile, "w");
242 else out = BIO_new_fp(stdout, BIO_NOCLOSE);
243
244 if(!out) {
245 BIO_printf(bio_err, "Error opening output file\n");
246 ERR_print_errors(bio_err);
247 goto end;
248 }
249
250 if(!noout) NETSCAPE_SPKI_print(out, spki);
251 pkey = NETSCAPE_SPKI_get_pubkey(spki);
252 if(verify) {
253 i = NETSCAPE_SPKI_verify(spki, pkey);
254 if(i) BIO_printf(bio_err, "Signature OK\n");
255 else {
256 BIO_printf(bio_err, "Signature Failure\n");
257 ERR_print_errors(bio_err);
258 goto end;
259 }
260 }
261 if(pubkey) PEM_write_bio_PUBKEY(out, pkey);
262
263 ret = 0;
264
265end:
266 CONF_free(conf);
267 NETSCAPE_SPKI_free(spki);
268 BIO_free(in);
269 BIO_free(out);
270 BIO_free(key);
271 EVP_PKEY_free(pkey);
272 if(passin) Free(passin);
273 EXIT(ret);
274 }
diff --git a/src/lib/libssl/src/apps/verify.c b/src/lib/libssl/src/apps/verify.c
index 093fe09f2c..267ee4ecd7 100644
--- a/src/lib/libssl/src/apps/verify.c
+++ b/src/lib/libssl/src/apps/verify.c
@@ -63,19 +63,26 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
66#include <openssl/pem.h> 67#include <openssl/pem.h>
67 68
68#undef PROG 69#undef PROG
69#define PROG verify_main 70#define PROG verify_main
70 71
71static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx); 72static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx);
72static int check(X509_STORE *ctx,char *file); 73static int check(X509_STORE *ctx,char *file, STACK_OF(X509)*other, int purpose);
74static STACK_OF(X509) *load_untrusted(char *file);
73static int v_verbose=0; 75static int v_verbose=0;
74 76
77int MAIN(int, char **);
78
75int MAIN(int argc, char **argv) 79int MAIN(int argc, char **argv)
76 { 80 {
77 int i,ret=1; 81 int i,ret=1;
82 int purpose = -1;
78 char *CApath=NULL,*CAfile=NULL; 83 char *CApath=NULL,*CAfile=NULL;
84 char *untfile = NULL;
85 STACK_OF(X509) *untrusted = NULL;
79 X509_STORE *cert_ctx=NULL; 86 X509_STORE *cert_ctx=NULL;
80 X509_LOOKUP *lookup=NULL; 87 X509_LOOKUP *lookup=NULL;
81 88
@@ -107,6 +114,24 @@ int MAIN(int argc, char **argv)
107 if (argc-- < 1) goto end; 114 if (argc-- < 1) goto end;
108 CAfile= *(++argv); 115 CAfile= *(++argv);
109 } 116 }
117 else if (strcmp(*argv,"-purpose") == 0)
118 {
119 X509_PURPOSE *xptmp;
120 if (argc-- < 1) goto end;
121 i = X509_PURPOSE_get_by_sname(*(++argv));
122 if(i < 0)
123 {
124 BIO_printf(bio_err, "unrecognized purpose\n");
125 goto end;
126 }
127 xptmp = X509_PURPOSE_get0(i);
128 purpose = X509_PURPOSE_get_id(xptmp);
129 }
130 else if (strcmp(*argv,"-untrusted") == 0)
131 {
132 if (argc-- < 1) goto end;
133 untfile= *(++argv);
134 }
110 else if (strcmp(*argv,"-help") == 0) 135 else if (strcmp(*argv,"-help") == 0)
111 goto end; 136 goto end;
112 else if (strcmp(*argv,"-verbose") == 0) 137 else if (strcmp(*argv,"-verbose") == 0)
@@ -124,34 +149,63 @@ int MAIN(int argc, char **argv)
124 149
125 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file()); 150 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file());
126 if (lookup == NULL) abort(); 151 if (lookup == NULL) abort();
127 if (!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) 152 if (CAfile) {
128 X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT); 153 i=X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM);
154 if(!i) {
155 BIO_printf(bio_err, "Error loading file %s\n", CAfile);
156 ERR_print_errors(bio_err);
157 goto end;
158 }
159 } else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
129 160
130 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_hash_dir()); 161 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_hash_dir());
131 if (lookup == NULL) abort(); 162 if (lookup == NULL) abort();
132 if (!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) 163 if (CApath) {
133 X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT); 164 i=X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM);
134 165 if(!i) {
166 BIO_printf(bio_err, "Error loading directory %s\n", CApath);
167 ERR_print_errors(bio_err);
168 goto end;
169 }
170 } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
135 171
136 ERR_clear_error(); 172 ERR_clear_error();
137 if (argc < 1) check(cert_ctx,NULL); 173
174 if(untfile) {
175 if(!(untrusted = load_untrusted(untfile))) {
176 BIO_printf(bio_err, "Error loading untrusted file %s\n", untfile);
177 ERR_print_errors(bio_err);
178 goto end;
179 }
180 }
181
182 if (argc < 1) check(cert_ctx, NULL, untrusted, purpose);
138 else 183 else
139 for (i=0; i<argc; i++) 184 for (i=0; i<argc; i++)
140 check(cert_ctx,argv[i]); 185 check(cert_ctx,argv[i], untrusted, purpose);
141 ret=0; 186 ret=0;
142end: 187end:
143 if (ret == 1) 188 if (ret == 1) {
144 BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] cert1 cert2 ...\n"); 189 BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] cert1 cert2 ...\n");
190 BIO_printf(bio_err,"recognized usages:\n");
191 for(i = 0; i < X509_PURPOSE_get_count(); i++) {
192 X509_PURPOSE *ptmp;
193 ptmp = X509_PURPOSE_get0(i);
194 BIO_printf(bio_err, "\t%-10s\t%s\n", X509_PURPOSE_get0_sname(ptmp),
195 X509_PURPOSE_get0_name(ptmp));
196 }
197 }
145 if (cert_ctx != NULL) X509_STORE_free(cert_ctx); 198 if (cert_ctx != NULL) X509_STORE_free(cert_ctx);
199 sk_X509_pop_free(untrusted, X509_free);
146 EXIT(ret); 200 EXIT(ret);
147 } 201 }
148 202
149static int check(X509_STORE *ctx, char *file) 203static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, int purpose)
150 { 204 {
151 X509 *x=NULL; 205 X509 *x=NULL;
152 BIO *in=NULL; 206 BIO *in=NULL;
153 int i=0,ret=0; 207 int i=0,ret=0;
154 X509_STORE_CTX csc; 208 X509_STORE_CTX *csc;
155 209
156 in=BIO_new(BIO_s_file()); 210 in=BIO_new(BIO_s_file());
157 if (in == NULL) 211 if (in == NULL)
@@ -181,9 +235,16 @@ static int check(X509_STORE *ctx, char *file)
181 } 235 }
182 fprintf(stdout,"%s: ",(file == NULL)?"stdin":file); 236 fprintf(stdout,"%s: ",(file == NULL)?"stdin":file);
183 237
184 X509_STORE_CTX_init(&csc,ctx,x,NULL); 238 csc = X509_STORE_CTX_new();
185 i=X509_verify_cert(&csc); 239 if (csc == NULL)
186 X509_STORE_CTX_cleanup(&csc); 240 {
241 ERR_print_errors(bio_err);
242 goto end;
243 }
244 X509_STORE_CTX_init(csc,ctx,x,uchain);
245 if(purpose >= 0) X509_STORE_CTX_set_purpose(csc, purpose);
246 i=X509_verify_cert(csc);
247 X509_STORE_CTX_free(csc);
187 248
188 ret=0; 249 ret=0;
189end: 250end:
@@ -200,27 +261,75 @@ end:
200 return(ret); 261 return(ret);
201 } 262 }
202 263
264static STACK_OF(X509) *load_untrusted(char *certfile)
265{
266 STACK_OF(X509_INFO) *sk=NULL;
267 STACK_OF(X509) *stack=NULL, *ret=NULL;
268 BIO *in=NULL;
269 X509_INFO *xi;
270
271 if(!(stack = sk_X509_new_null())) {
272 BIO_printf(bio_err,"memory allocation failure\n");
273 goto end;
274 }
275
276 if(!(in=BIO_new_file(certfile, "r"))) {
277 BIO_printf(bio_err,"error opening the file, %s\n",certfile);
278 goto end;
279 }
280
281 /* This loads from a file, a stack of x509/crl/pkey sets */
282 if(!(sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL))) {
283 BIO_printf(bio_err,"error reading the file, %s\n",certfile);
284 goto end;
285 }
286
287 /* scan over it and pull out the certs */
288 while (sk_X509_INFO_num(sk))
289 {
290 xi=sk_X509_INFO_shift(sk);
291 if (xi->x509 != NULL)
292 {
293 sk_X509_push(stack,xi->x509);
294 xi->x509=NULL;
295 }
296 X509_INFO_free(xi);
297 }
298 if(!sk_X509_num(stack)) {
299 BIO_printf(bio_err,"no certificates in file, %s\n",certfile);
300 sk_X509_free(stack);
301 goto end;
302 }
303 ret=stack;
304end:
305 BIO_free(in);
306 sk_X509_INFO_free(sk);
307 return(ret);
308 }
309
203static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx) 310static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx)
204 { 311 {
205 char buf[256]; 312 char buf[256];
206 313
207 if (!ok) 314 if (!ok)
208 { 315 {
209 /* since we are just checking the certificates, it is 316 X509_NAME_oneline(
210 * ok if they are self signed. */
211 if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)
212 ok=1;
213 else
214 {
215 X509_NAME_oneline(
216 X509_get_subject_name(ctx->current_cert),buf,256); 317 X509_get_subject_name(ctx->current_cert),buf,256);
217 printf("%s\n",buf); 318 printf("%s\n",buf);
218 printf("error %d at %d depth lookup:%s\n",ctx->error, 319 printf("error %d at %d depth lookup:%s\n",ctx->error,
219 ctx->error_depth, 320 ctx->error_depth,
220 X509_verify_cert_error_string(ctx->error)); 321 X509_verify_cert_error_string(ctx->error));
221 if (ctx->error == X509_V_ERR_CERT_HAS_EXPIRED) 322 if (ctx->error == X509_V_ERR_CERT_HAS_EXPIRED) ok=1;
222 ok=1; 323 /* since we are just checking the certificates, it is
223 } 324 * ok if they are self signed. But we should still warn
325 * the user.
326 */
327 if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ok=1;
328 /* Continue after extension errors too */
329 if (ctx->error == X509_V_ERR_INVALID_CA) ok=1;
330 if (ctx->error == X509_V_ERR_PATH_LENGTH_EXCEEDED) ok=1;
331 if (ctx->error == X509_V_ERR_INVALID_PURPOSE) ok=1;
332 if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ok=1;
224 } 333 }
225 if (!v_verbose) 334 if (!v_verbose)
226 ERR_clear_error(); 335 ERR_clear_error();
diff --git a/src/lib/libssl/src/apps/version.c b/src/lib/libssl/src/apps/version.c
index a567f34094..f5c9adc254 100644
--- a/src/lib/libssl/src/apps/version.c
+++ b/src/lib/libssl/src/apps/version.c
@@ -66,6 +66,8 @@
66#undef PROG 66#undef PROG
67#define PROG version_main 67#define PROG version_main
68 68
69int MAIN(int, char **);
70
69int MAIN(int argc, char **argv) 71int MAIN(int argc, char **argv)
70 { 72 {
71 int i,ret=0; 73 int i,ret=0;
diff --git a/src/lib/libssl/src/apps/x509.c b/src/lib/libssl/src/apps/x509.c
index 2e2d18bea4..d5c0d0404e 100644
--- a/src/lib/libssl/src/apps/x509.c
+++ b/src/lib/libssl/src/apps/x509.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <assert.h>
59#include <stdio.h> 60#include <stdio.h>
60#include <stdlib.h> 61#include <stdlib.h>
61#include <string.h> 62#include <string.h>
@@ -91,59 +92,78 @@ static char *x509_usage[]={
91" -CAkeyform arg - CA key format - default PEM\n", 92" -CAkeyform arg - CA key format - default PEM\n",
92" -in arg - input file - default stdin\n", 93" -in arg - input file - default stdin\n",
93" -out arg - output file - default stdout\n", 94" -out arg - output file - default stdout\n",
95" -passin arg - private key password source\n",
94" -serial - print serial number value\n", 96" -serial - print serial number value\n",
95" -hash - print hash value\n", 97" -hash - print hash value\n",
96" -subject - print subject DN\n", 98" -subject - print subject DN\n",
97" -issuer - print issuer DN\n", 99" -issuer - print issuer DN\n",
98" -startdate - notBefore field\n", 100" -startdate - notBefore field\n",
99" -enddate - notAfter field\n", 101" -enddate - notAfter field\n",
102" -purpose - print out certificate purposes\n",
100" -dates - both Before and After dates\n", 103" -dates - both Before and After dates\n",
101" -modulus - print the RSA key modulus\n", 104" -modulus - print the RSA key modulus\n",
105" -pubkey - output the public key\n",
102" -fingerprint - print the certificate fingerprint\n", 106" -fingerprint - print the certificate fingerprint\n",
107" -alias - output certificate alias\n",
103" -noout - no certificate output\n", 108" -noout - no certificate output\n",
104 109" -trustout - output a \"trusted\" certificate\n",
110" -clrtrust - clear all trusted purposes\n",
111" -clrreject - clear all rejected purposes\n",
112" -addtrust arg - trust certificate for a given purpose\n",
113" -addreject arg - reject certificate for a given purpose\n",
114" -setalias arg - set certificate alias\n",
105" -days arg - How long till expiry of a signed certificate - def 30 days\n", 115" -days arg - How long till expiry of a signed certificate - def 30 days\n",
106" -signkey arg - self sign cert with arg\n", 116" -signkey arg - self sign cert with arg\n",
107" -x509toreq - output a certification request object\n", 117" -x509toreq - output a certification request object\n",
108" -req - input is a certificate request, sign and output.\n", 118" -req - input is a certificate request, sign and output.\n",
109" -CA arg - set the CA certificate, must be PEM format.\n", 119" -CA arg - set the CA certificate, must be PEM format.\n",
110" -CAkey arg - set the CA key, must be PEM format\n", 120" -CAkey arg - set the CA key, must be PEM format\n",
111" missing, it is asssumed to be in the CA file.\n", 121" missing, it is assumed to be in the CA file.\n",
112" -CAcreateserial - create serial number file if it does not exist\n", 122" -CAcreateserial - create serial number file if it does not exist\n",
113" -CAserial - serial file\n", 123" -CAserial - serial file\n",
114" -text - print the certificate in text form\n", 124" -text - print the certificate in text form\n",
115" -C - print out C code forms\n", 125" -C - print out C code forms\n",
116" -md2/-md5/-sha1/-mdc2 - digest to do an RSA sign with\n", 126" -md2/-md5/-sha1/-mdc2 - digest to use\n",
117" -extfile - configuration file with X509V3 extensions to add\n", 127" -extfile - configuration file with X509V3 extensions to add\n",
128" -extensions - section from config file with X509V3 extensions to add\n",
129" -crlext - delete extensions before signing and input certificate\n",
118NULL 130NULL
119}; 131};
120 132
121static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx); 133static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx);
122static EVP_PKEY *load_key(char *file, int format); 134static EVP_PKEY *load_key(char *file, int format, char *passin);
123static X509 *load_cert(char *file, int format); 135static X509 *load_cert(char *file, int format);
124static int sign (X509 *x, EVP_PKEY *pkey,int days,const EVP_MD *digest, 136static int sign (X509 *x, EVP_PKEY *pkey,int days,int clrext, const EVP_MD *digest,
125 LHASH *conf, char *section); 137 LHASH *conf, char *section);
126static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest, 138static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest,
127 X509 *x,X509 *xca,EVP_PKEY *pkey,char *serial, 139 X509 *x,X509 *xca,EVP_PKEY *pkey,char *serial,
128 int create,int days, LHASH *conf, char *section); 140 int create,int days, int clrext, LHASH *conf, char *section);
141static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
129static int reqfile=0; 142static int reqfile=0;
130 143
144int MAIN(int, char **);
145
131int MAIN(int argc, char **argv) 146int MAIN(int argc, char **argv)
132 { 147 {
133 int ret=1; 148 int ret=1;
134 X509_REQ *req=NULL; 149 X509_REQ *req=NULL;
135 X509 *x=NULL,*xca=NULL; 150 X509 *x=NULL,*xca=NULL;
151 ASN1_OBJECT *objtmp;
136 EVP_PKEY *Upkey=NULL,*CApkey=NULL; 152 EVP_PKEY *Upkey=NULL,*CApkey=NULL;
137 int i,num,badops=0; 153 int i,num,badops=0;
138 BIO *out=NULL; 154 BIO *out=NULL;
139 BIO *STDout=NULL; 155 BIO *STDout=NULL;
156 STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL;
140 int informat,outformat,keyformat,CAformat,CAkeyformat; 157 int informat,outformat,keyformat,CAformat,CAkeyformat;
141 char *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL; 158 char *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL;
142 char *CAkeyfile=NULL,*CAserial=NULL; 159 char *CAkeyfile=NULL,*CAserial=NULL;
160 char *alias=NULL;
143 int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0; 161 int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0;
144 int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0; 162 int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0;
163 int trustout=0,clrtrust=0,clrreject=0,aliasout=0,clrext=0;
145 int C=0; 164 int C=0;
146 int x509req=0,days=DEF_DAYS,modulus=0; 165 int x509req=0,days=DEF_DAYS,modulus=0,pubkey=0;
166 int pprint = 0;
147 char **pp; 167 char **pp;
148 X509_STORE *ctx=NULL; 168 X509_STORE *ctx=NULL;
149 X509_REQ *rq=NULL; 169 X509_REQ *rq=NULL;
@@ -151,7 +171,8 @@ int MAIN(int argc, char **argv)
151 char buf[256]; 171 char buf[256];
152 const EVP_MD *md_alg,*digest=EVP_md5(); 172 const EVP_MD *md_alg,*digest=EVP_md5();
153 LHASH *extconf = NULL; 173 LHASH *extconf = NULL;
154 char *extsect = NULL, *extfile = NULL; 174 char *extsect = NULL, *extfile = NULL, *passin = NULL, *passargin = NULL;
175 int need_rand = 0;
155 176
156 reqfile=0; 177 reqfile=0;
157 178
@@ -192,7 +213,10 @@ int MAIN(int argc, char **argv)
192 keyformat=str2fmt(*(++argv)); 213 keyformat=str2fmt(*(++argv));
193 } 214 }
194 else if (strcmp(*argv,"-req") == 0) 215 else if (strcmp(*argv,"-req") == 0)
216 {
195 reqfile=1; 217 reqfile=1;
218 need_rand = 1;
219 }
196 else if (strcmp(*argv,"-CAform") == 0) 220 else if (strcmp(*argv,"-CAform") == 0)
197 { 221 {
198 if (--argc < 1) goto bad; 222 if (--argc < 1) goto bad;
@@ -213,11 +237,21 @@ int MAIN(int argc, char **argv)
213 goto bad; 237 goto bad;
214 } 238 }
215 } 239 }
240 else if (strcmp(*argv,"-passin") == 0)
241 {
242 if (--argc < 1) goto bad;
243 passargin= *(++argv);
244 }
216 else if (strcmp(*argv,"-extfile") == 0) 245 else if (strcmp(*argv,"-extfile") == 0)
217 { 246 {
218 if (--argc < 1) goto bad; 247 if (--argc < 1) goto bad;
219 extfile= *(++argv); 248 extfile= *(++argv);
220 } 249 }
250 else if (strcmp(*argv,"-extensions") == 0)
251 {
252 if (--argc < 1) goto bad;
253 extsect= *(++argv);
254 }
221 else if (strcmp(*argv,"-in") == 0) 255 else if (strcmp(*argv,"-in") == 0)
222 { 256 {
223 if (--argc < 1) goto bad; 257 if (--argc < 1) goto bad;
@@ -233,12 +267,14 @@ int MAIN(int argc, char **argv)
233 if (--argc < 1) goto bad; 267 if (--argc < 1) goto bad;
234 keyfile= *(++argv); 268 keyfile= *(++argv);
235 sign_flag= ++num; 269 sign_flag= ++num;
270 need_rand = 1;
236 } 271 }
237 else if (strcmp(*argv,"-CA") == 0) 272 else if (strcmp(*argv,"-CA") == 0)
238 { 273 {
239 if (--argc < 1) goto bad; 274 if (--argc < 1) goto bad;
240 CAfile= *(++argv); 275 CAfile= *(++argv);
241 CA_flag= ++num; 276 CA_flag= ++num;
277 need_rand = 1;
242 } 278 }
243 else if (strcmp(*argv,"-CAkey") == 0) 279 else if (strcmp(*argv,"-CAkey") == 0)
244 { 280 {
@@ -250,12 +286,50 @@ int MAIN(int argc, char **argv)
250 if (--argc < 1) goto bad; 286 if (--argc < 1) goto bad;
251 CAserial= *(++argv); 287 CAserial= *(++argv);
252 } 288 }
289 else if (strcmp(*argv,"-addtrust") == 0)
290 {
291 if (--argc < 1) goto bad;
292 if(!(objtmp = OBJ_txt2obj(*(++argv), 0))) {
293 BIO_printf(bio_err,
294 "Invalid trust object value %s\n", *argv);
295 goto bad;
296 }
297 if(!trust) trust = sk_ASN1_OBJECT_new_null();
298 sk_ASN1_OBJECT_push(trust, objtmp);
299 trustout = 1;
300 }
301 else if (strcmp(*argv,"-addreject") == 0)
302 {
303 if (--argc < 1) goto bad;
304 if(!(objtmp = OBJ_txt2obj(*(++argv), 0))) {
305 BIO_printf(bio_err,
306 "Invalid reject object value %s\n", *argv);
307 goto bad;
308 }
309 if(!reject) reject = sk_ASN1_OBJECT_new_null();
310 sk_ASN1_OBJECT_push(reject, objtmp);
311 trustout = 1;
312 }
313 else if (strcmp(*argv,"-setalias") == 0)
314 {
315 if (--argc < 1) goto bad;
316 alias= *(++argv);
317 trustout = 1;
318 }
319 else if (strcmp(*argv,"-setalias") == 0)
320 {
321 if (--argc < 1) goto bad;
322 alias= *(++argv);
323 trustout = 1;
324 }
253 else if (strcmp(*argv,"-C") == 0) 325 else if (strcmp(*argv,"-C") == 0)
254 C= ++num; 326 C= ++num;
255 else if (strcmp(*argv,"-serial") == 0) 327 else if (strcmp(*argv,"-serial") == 0)
256 serial= ++num; 328 serial= ++num;
257 else if (strcmp(*argv,"-modulus") == 0) 329 else if (strcmp(*argv,"-modulus") == 0)
258 modulus= ++num; 330 modulus= ++num;
331 else if (strcmp(*argv,"-pubkey") == 0)
332 pubkey= ++num;
259 else if (strcmp(*argv,"-x509toreq") == 0) 333 else if (strcmp(*argv,"-x509toreq") == 0)
260 x509req= ++num; 334 x509req= ++num;
261 else if (strcmp(*argv,"-text") == 0) 335 else if (strcmp(*argv,"-text") == 0)
@@ -273,15 +347,27 @@ int MAIN(int argc, char **argv)
273 startdate= ++num; 347 startdate= ++num;
274 enddate= ++num; 348 enddate= ++num;
275 } 349 }
350 else if (strcmp(*argv,"-purpose") == 0)
351 pprint= ++num;
276 else if (strcmp(*argv,"-startdate") == 0) 352 else if (strcmp(*argv,"-startdate") == 0)
277 startdate= ++num; 353 startdate= ++num;
278 else if (strcmp(*argv,"-enddate") == 0) 354 else if (strcmp(*argv,"-enddate") == 0)
279 enddate= ++num; 355 enddate= ++num;
280 else if (strcmp(*argv,"-noout") == 0) 356 else if (strcmp(*argv,"-noout") == 0)
281 noout= ++num; 357 noout= ++num;
358 else if (strcmp(*argv,"-trustout") == 0)
359 trustout= 1;
360 else if (strcmp(*argv,"-clrtrust") == 0)
361 clrtrust= ++num;
362 else if (strcmp(*argv,"-clrreject") == 0)
363 clrreject= ++num;
364 else if (strcmp(*argv,"-alias") == 0)
365 aliasout= ++num;
282 else if (strcmp(*argv,"-CAcreateserial") == 0) 366 else if (strcmp(*argv,"-CAcreateserial") == 0)
283 CA_createserial= ++num; 367 CA_createserial= ++num;
284 else if ((md_alg=EVP_get_digestbyname(&((*argv)[1]))) != NULL) 368 else if (strcmp(*argv,"-crlext") == 0)
369 clrext = 1;
370 else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
285 { 371 {
286 /* ok */ 372 /* ok */
287 digest=md_alg; 373 digest=md_alg;
@@ -304,8 +390,15 @@ bad:
304 goto end; 390 goto end;
305 } 391 }
306 392
393 if (need_rand)
394 app_RAND_load_file(NULL, bio_err, 0);
395
307 ERR_load_crypto_strings(); 396 ERR_load_crypto_strings();
308 X509V3_add_standard_extensions(); 397
398 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
399 BIO_printf(bio_err, "Error getting password\n");
400 goto end;
401 }
309 402
310 if (!X509_STORE_set_default_paths(ctx)) 403 if (!X509_STORE_set_default_paths(ctx))
311 { 404 {
@@ -335,7 +428,7 @@ bad:
335 ,errorline,extfile); 428 ,errorline,extfile);
336 goto end; 429 goto end;
337 } 430 }
338 if(!(extsect = CONF_get_string(extconf, "default", 431 if(!extsect && !(extsect = CONF_get_string(extconf, "default",
339 "extensions"))) extsect = "default"; 432 "extensions"))) extsect = "default";
340 X509V3_set_ctx_test(&ctx2); 433 X509V3_set_ctx_test(&ctx2);
341 X509V3_set_conf_lhash(&ctx2, extconf); 434 X509V3_set_conf_lhash(&ctx2, extconf);
@@ -425,15 +518,9 @@ bad:
425 X509_gmtime_adj(X509_get_notBefore(x),0); 518 X509_gmtime_adj(X509_get_notBefore(x),0);
426 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days); 519 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days);
427 520
428#if 0
429 X509_PUBKEY_free(ci->key);
430 ci->key=req->req_info->pubkey;
431 req->req_info->pubkey=NULL;
432#else
433 pkey = X509_REQ_get_pubkey(req); 521 pkey = X509_REQ_get_pubkey(req);
434 X509_set_pubkey(x,pkey); 522 X509_set_pubkey(x,pkey);
435 EVP_PKEY_free(pkey); 523 EVP_PKEY_free(pkey);
436#endif
437 } 524 }
438 else 525 else
439 x=load_cert(infile,informat); 526 x=load_cert(infile,informat);
@@ -468,6 +555,25 @@ bad:
468 } 555 }
469 } 556 }
470 557
558 if(alias) X509_alias_set1(x, (unsigned char *)alias, -1);
559
560 if(clrtrust) X509_trust_clear(x);
561 if(clrreject) X509_reject_clear(x);
562
563 if(trust) {
564 for(i = 0; i < sk_ASN1_OBJECT_num(trust); i++) {
565 objtmp = sk_ASN1_OBJECT_value(trust, i);
566 X509_add1_trust_object(x, objtmp);
567 }
568 }
569
570 if(reject) {
571 for(i = 0; i < sk_ASN1_OBJECT_num(reject); i++) {
572 objtmp = sk_ASN1_OBJECT_value(reject, i);
573 X509_add1_reject_object(x, objtmp);
574 }
575 }
576
471 if (num) 577 if (num)
472 { 578 {
473 for (i=1; i<=num; i++) 579 for (i=1; i<=num; i++)
@@ -490,10 +596,28 @@ bad:
490 i2a_ASN1_INTEGER(STDout,x->cert_info->serialNumber); 596 i2a_ASN1_INTEGER(STDout,x->cert_info->serialNumber);
491 BIO_printf(STDout,"\n"); 597 BIO_printf(STDout,"\n");
492 } 598 }
599 else if (aliasout == i)
600 {
601 unsigned char *alstr;
602 alstr = X509_alias_get0(x, NULL);
603 if(alstr) BIO_printf(STDout,"%s\n", alstr);
604 else BIO_puts(STDout,"<No Alias>\n");
605 }
493 else if (hash == i) 606 else if (hash == i)
494 { 607 {
495 BIO_printf(STDout,"%08lx\n",X509_subject_name_hash(x)); 608 BIO_printf(STDout,"%08lx\n",X509_subject_name_hash(x));
496 } 609 }
610 else if (pprint == i)
611 {
612 X509_PURPOSE *ptmp;
613 int j;
614 BIO_printf(STDout, "Certificate purposes:\n");
615 for(j = 0; j < X509_PURPOSE_get_count(); j++)
616 {
617 ptmp = X509_PURPOSE_get0(j);
618 purpose_print(STDout, x, ptmp);
619 }
620 }
497 else 621 else
498 if (modulus == i) 622 if (modulus == i)
499 { 623 {
@@ -522,6 +646,21 @@ bad:
522 EVP_PKEY_free(pkey); 646 EVP_PKEY_free(pkey);
523 } 647 }
524 else 648 else
649 if (pubkey == i)
650 {
651 EVP_PKEY *pkey;
652
653 pkey=X509_get_pubkey(x);
654 if (pkey == NULL)
655 {
656 BIO_printf(bio_err,"Error getting public key\n");
657 ERR_print_errors(bio_err);
658 goto end;
659 }
660 PEM_write_bio_PUBKEY(STDout, pkey);
661 EVP_PKEY_free(pkey);
662 }
663 else
525 if (C == i) 664 if (C == i)
526 { 665 {
527 unsigned char *d; 666 unsigned char *d;
@@ -598,12 +737,13 @@ bad:
598 unsigned int n; 737 unsigned int n;
599 unsigned char md[EVP_MAX_MD_SIZE]; 738 unsigned char md[EVP_MAX_MD_SIZE];
600 739
601 if (!X509_digest(x,EVP_md5(),md,&n)) 740 if (!X509_digest(x,digest,md,&n))
602 { 741 {
603 BIO_printf(bio_err,"out of memory\n"); 742 BIO_printf(bio_err,"out of memory\n");
604 goto end; 743 goto end;
605 } 744 }
606 BIO_printf(STDout,"MD5 Fingerprint="); 745 BIO_printf(STDout,"%s Fingerprint=",
746 OBJ_nid2sn(EVP_MD_type(digest)));
607 for (j=0; j<(int)n; j++) 747 for (j=0; j<(int)n; j++)
608 { 748 {
609 BIO_printf(STDout,"%02X%c",md[j], 749 BIO_printf(STDout,"%02X%c",md[j],
@@ -618,7 +758,7 @@ bad:
618 BIO_printf(bio_err,"Getting Private key\n"); 758 BIO_printf(bio_err,"Getting Private key\n");
619 if (Upkey == NULL) 759 if (Upkey == NULL)
620 { 760 {
621 Upkey=load_key(keyfile,keyformat); 761 Upkey=load_key(keyfile,keyformat, passin);
622 if (Upkey == NULL) goto end; 762 if (Upkey == NULL) goto end;
623 } 763 }
624#ifndef NO_DSA 764#ifndef NO_DSA
@@ -626,7 +766,8 @@ bad:
626 digest=EVP_dss1(); 766 digest=EVP_dss1();
627#endif 767#endif
628 768
629 if (!sign(x,Upkey,days,digest, 769 assert(need_rand);
770 if (!sign(x,Upkey,days,clrext,digest,
630 extconf, extsect)) goto end; 771 extconf, extsect)) goto end;
631 } 772 }
632 else if (CA_flag == i) 773 else if (CA_flag == i)
@@ -634,7 +775,7 @@ bad:
634 BIO_printf(bio_err,"Getting CA Private Key\n"); 775 BIO_printf(bio_err,"Getting CA Private Key\n");
635 if (CAkeyfile != NULL) 776 if (CAkeyfile != NULL)
636 { 777 {
637 CApkey=load_key(CAkeyfile,CAkeyformat); 778 CApkey=load_key(CAkeyfile,CAkeyformat, passin);
638 if (CApkey == NULL) goto end; 779 if (CApkey == NULL) goto end;
639 } 780 }
640#ifndef NO_DSA 781#ifndef NO_DSA
@@ -642,8 +783,9 @@ bad:
642 digest=EVP_dss1(); 783 digest=EVP_dss1();
643#endif 784#endif
644 785
786 assert(need_rand);
645 if (!x509_certify(ctx,CAfile,digest,x,xca, 787 if (!x509_certify(ctx,CAfile,digest,x,xca,
646 CApkey, CAserial,CA_createserial,days, 788 CApkey, CAserial,CA_createserial,days, clrext,
647 extconf, extsect)) 789 extconf, extsect))
648 goto end; 790 goto end;
649 } 791 }
@@ -659,13 +801,16 @@ bad:
659 } 801 }
660 else 802 else
661 { 803 {
662 pk=load_key(keyfile,FORMAT_PEM); 804 pk=load_key(keyfile,FORMAT_PEM, passin);
663 if (pk == NULL) goto end; 805 if (pk == NULL) goto end;
664 } 806 }
665 807
666 BIO_printf(bio_err,"Generating certificate request\n"); 808 BIO_printf(bio_err,"Generating certificate request\n");
667 809
668 rq=X509_to_X509_REQ(x,pk,EVP_md5()); 810 if (pk->type == EVP_PKEY_DSA)
811 digest=EVP_dss1();
812
813 rq=X509_to_X509_REQ(x,pk,digest);
669 EVP_PKEY_free(pk); 814 EVP_PKEY_free(pk);
670 if (rq == NULL) 815 if (rq == NULL)
671 { 816 {
@@ -690,9 +835,10 @@ bad:
690 835
691 if (outformat == FORMAT_ASN1) 836 if (outformat == FORMAT_ASN1)
692 i=i2d_X509_bio(out,x); 837 i=i2d_X509_bio(out,x);
693 else if (outformat == FORMAT_PEM) 838 else if (outformat == FORMAT_PEM) {
694 i=PEM_write_bio_X509(out,x); 839 if(trustout) i=PEM_write_bio_X509_AUX(out,x);
695 else if (outformat == FORMAT_NETSCAPE) 840 else i=PEM_write_bio_X509(out,x);
841 } else if (outformat == FORMAT_NETSCAPE)
696 { 842 {
697 ASN1_HEADER ah; 843 ASN1_HEADER ah;
698 ASN1_OCTET_STRING os; 844 ASN1_OCTET_STRING os;
@@ -717,6 +863,8 @@ bad:
717 } 863 }
718 ret=0; 864 ret=0;
719end: 865end:
866 if (need_rand)
867 app_RAND_write_file(NULL, bio_err);
720 OBJ_cleanup(); 868 OBJ_cleanup();
721 CONF_free(extconf); 869 CONF_free(extconf);
722 BIO_free(out); 870 BIO_free(out);
@@ -728,13 +876,15 @@ end:
728 EVP_PKEY_free(Upkey); 876 EVP_PKEY_free(Upkey);
729 EVP_PKEY_free(CApkey); 877 EVP_PKEY_free(CApkey);
730 X509_REQ_free(rq); 878 X509_REQ_free(rq);
731 X509V3_EXT_cleanup(); 879 sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
880 sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
881 if(passin) Free(passin);
732 EXIT(ret); 882 EXIT(ret);
733 } 883 }
734 884
735static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, 885static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
736 X509 *x, X509 *xca, EVP_PKEY *pkey, char *serialfile, int create, 886 X509 *x, X509 *xca, EVP_PKEY *pkey, char *serialfile, int create,
737 int days, LHASH *conf, char *section) 887 int days, int clrext, LHASH *conf, char *section)
738 { 888 {
739 int ret=0; 889 int ret=0;
740 BIO *io=NULL; 890 BIO *io=NULL;
@@ -750,7 +900,7 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
750 EVP_PKEY_free(upkey); 900 EVP_PKEY_free(upkey);
751 901
752 X509_STORE_CTX_init(&xsc,ctx,x,NULL); 902 X509_STORE_CTX_init(&xsc,ctx,x,NULL);
753 buf=(char *)Malloc(EVP_PKEY_size(pkey)*2+ 903 buf=Malloc(EVP_PKEY_size(pkey)*2+
754 ((serialfile == NULL) 904 ((serialfile == NULL)
755 ?(strlen(CAfile)+strlen(POSTFIX)+1) 905 ?(strlen(CAfile)+strlen(POSTFIX)+1)
756 :(strlen(serialfile)))+1); 906 :(strlen(serialfile)))+1);
@@ -792,8 +942,8 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
792 } 942 }
793 else 943 else
794 { 944 {
795 ASN1_INTEGER_set(bs,0); 945 ASN1_INTEGER_set(bs,1);
796 BN_zero(serial); 946 BN_one(serial);
797 } 947 }
798 } 948 }
799 else 949 else
@@ -855,6 +1005,10 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
855 if (X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days) == NULL) 1005 if (X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days) == NULL)
856 goto end; 1006 goto end;
857 1007
1008 if(clrext) {
1009 while(X509_get_ext_count(x) > 0) X509_delete_ext(x, 0);
1010 }
1011
858 if(conf) { 1012 if(conf) {
859 X509V3_CTX ctx2; 1013 X509V3_CTX ctx2;
860 X509_set_version(x,2); /* version 3 certificate */ 1014 X509_set_version(x,2); /* version 3 certificate */
@@ -909,7 +1063,7 @@ static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx)
909 } 1063 }
910 } 1064 }
911 1065
912static EVP_PKEY *load_key(char *file, int format) 1066static EVP_PKEY *load_key(char *file, int format, char *passin)
913 { 1067 {
914 BIO *key=NULL; 1068 BIO *key=NULL;
915 EVP_PKEY *pkey=NULL; 1069 EVP_PKEY *pkey=NULL;
@@ -930,25 +1084,13 @@ static EVP_PKEY *load_key(char *file, int format)
930 perror(file); 1084 perror(file);
931 goto end; 1085 goto end;
932 } 1086 }
933#ifndef NO_RSA 1087 if (format == FORMAT_ASN1)
934 if (format == FORMAT_ASN1)
935 { 1088 {
936 RSA *rsa; 1089 pkey=d2i_PrivateKey_bio(key, NULL);
937
938 rsa=d2i_RSAPrivateKey_bio(key,NULL);
939 if (rsa != NULL)
940 {
941 if ((pkey=EVP_PKEY_new()) != NULL)
942 EVP_PKEY_assign_RSA(pkey,rsa);
943 else
944 RSA_free(rsa);
945 }
946 } 1090 }
947 else 1091 else if (format == FORMAT_PEM)
948#endif
949 if (format == FORMAT_PEM)
950 { 1092 {
951 pkey=PEM_read_bio_PrivateKey(key,NULL,NULL,NULL); 1093 pkey=PEM_read_bio_PrivateKey(key,NULL,NULL,passin);
952 } 1094 }
953 else 1095 else
954 { 1096 {
@@ -1031,7 +1173,7 @@ static X509 *load_cert(char *file, int format)
1031 ah->data=NULL; 1173 ah->data=NULL;
1032 } 1174 }
1033 else if (format == FORMAT_PEM) 1175 else if (format == FORMAT_PEM)
1034 x=PEM_read_bio_X509(cert,NULL,NULL,NULL); 1176 x=PEM_read_bio_X509_AUX(cert,NULL,NULL,NULL);
1035 else { 1177 else {
1036 BIO_printf(bio_err,"bad input format specified for input cert\n"); 1178 BIO_printf(bio_err,"bad input format specified for input cert\n");
1037 goto end; 1179 goto end;
@@ -1049,7 +1191,7 @@ end:
1049 } 1191 }
1050 1192
1051/* self sign */ 1193/* self sign */
1052static int sign(X509 *x, EVP_PKEY *pkey, int days, const EVP_MD *digest, 1194static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest,
1053 LHASH *conf, char *section) 1195 LHASH *conf, char *section)
1054 { 1196 {
1055 1197
@@ -1071,6 +1213,9 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, const EVP_MD *digest,
1071 goto err; 1213 goto err;
1072 1214
1073 if (!X509_set_pubkey(x,pkey)) goto err; 1215 if (!X509_set_pubkey(x,pkey)) goto err;
1216 if(clrext) {
1217 while(X509_get_ext_count(x) > 0) X509_delete_ext(x, 0);
1218 }
1074 if(conf) { 1219 if(conf) {
1075 X509V3_CTX ctx; 1220 X509V3_CTX ctx;
1076 X509_set_version(x,2); /* version 3 certificate */ 1221 X509_set_version(x,2); /* version 3 certificate */
@@ -1084,3 +1229,22 @@ err:
1084 ERR_print_errors(bio_err); 1229 ERR_print_errors(bio_err);
1085 return(0); 1230 return(0);
1086 } 1231 }
1232
1233static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt)
1234{
1235 int id, i, idret;
1236 char *pname;
1237 id = X509_PURPOSE_get_id(pt);
1238 pname = X509_PURPOSE_get0_name(pt);
1239 for(i = 0; i < 2; i++) {
1240 idret = X509_check_purpose(cert, id, i);
1241 BIO_printf(bio, "%s%s : ", pname, i ? " CA" : "");
1242 if(idret == 1) BIO_printf(bio, "Yes\n");
1243 else if (idret == 0) BIO_printf(bio, "No\n");
1244 else BIO_printf(bio, "Yes (WARNING code=%d)\n", idret);
1245 }
1246 return 1;
1247}
1248
1249
1250
diff --git a/src/lib/libssl/src/bugs/SSLv3 b/src/lib/libssl/src/bugs/SSLv3
index 2e22a65cdd..db53e1343a 100644
--- a/src/lib/libssl/src/bugs/SSLv3
+++ b/src/lib/libssl/src/bugs/SSLv3
@@ -39,3 +39,11 @@ SSL_shutdown() and still sharing the socket with its parent).
39 39
40Netscape, when using export ciphers, will accept a 1024 bit temporary 40Netscape, when using export ciphers, will accept a 1024 bit temporary
41RSA key. It is supposed to only accept 512. 41RSA key. It is supposed to only accept 512.
42
43If Netscape connects to a server which requests a client certificate
44it will frequently hang after the user has selected one and never
45complete the connection. Hitting "Stop" and reload fixes this and
46all subsequent connections work fine. This appears to be because
47Netscape wont read any new records in when it is awaiting a server
48done message at this point. The fix is to send the certificate request
49and server done messages in one record.
diff --git a/src/lib/libssl/src/certs/ca-cert.pem b/src/lib/libssl/src/certs/ca-cert.pem
index 6dd974d70d..bcba68aefa 100644
--- a/src/lib/libssl/src/certs/ca-cert.pem
+++ b/src/lib/libssl/src/certs/ca-cert.pem
@@ -1,18 +1,20 @@
1issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
2subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
3-----BEGIN CERTIFICATE----- 1-----BEGIN CERTIFICATE-----
4MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV 2MIIC5TCCAk6gAwIBAgIBATANBgkqhkiG9w0BAQQFADBcMQswCQYDVQQGEwJBVTET
5BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD 3MBEGA1UECBMKUXVlZW5zbGFuZDEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQx
6VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw 4HDAaBgNVBAM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BEGA1UECBMKUXVlZW5zbGFuZDEaMBgG
15q30KIqGM/uoM60INq97qjDmCJapagcNBGQs= 13A1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxHDAaBgNVBAMTE1Rlc3QgUENBICgxMDI0
14IGJpdCmCAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBb39BRphHL
156aRAQyymsvBvPSCiG9+kR0R1L23aTpNbhXp2BebyFjbEQYZc2kWGiKKcHkNECA35
163d4LoqUlVey8DFyafOIJd9hxdZfg+rxlHMxnL7uCJRmx9+xB411Jtsol9/wg1uCK
17sleGpgB4j8cG2SVCz7V2MNZNK+d5QCnR7A==
16-----END CERTIFICATE----- 18-----END CERTIFICATE-----
17-----BEGIN RSA PRIVATE KEY----- 19-----BEGIN RSA PRIVATE KEY-----
18MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425 20MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425
diff --git a/src/lib/libssl/src/certs/pca-cert.pem b/src/lib/libssl/src/certs/pca-cert.pem
index 140e9a6b43..9d754d460d 100644
--- a/src/lib/libssl/src/certs/pca-cert.pem
+++ b/src/lib/libssl/src/certs/pca-cert.pem
@@ -1,18 +1,20 @@
1issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
2subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
3-----BEGIN CERTIFICATE----- 1-----BEGIN CERTIFICATE-----
4MIICJzCCAZACAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV 2MIIC5jCCAk+gAwIBAgIBADANBgkqhkiG9w0BAQQFADBcMQswCQYDVQQGEwJBVTET
5BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD 3MBEGA1UECBMK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aEogQe1LLcuOJV6rKfUSAsPgwgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp 15+Mvxeq9HsEzJxHIFQla05S5J/e/V+DQTYoKiRFchKPrDAdrzYSEvP3h4QJEtsNqQ
1122Jp85PmemiDzyUIStwk72qhp1imbANZvlmlCFKiQrjUyuDfu4TABmn+kkt3vR1Y 16JfOxg5M42uLFq7aPGWkF6ZZqZsYS+zA9IVT14g7gNA6Ne+5QtJqQtH9HA24st0T0
12BEOGt+IFye1UBVSATVdRJ2UVhwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABNA1u/S 17Tga/lZ9M2ovImovaxSL/kRHbpCWcqWVxpOw=
13Cg/LJZWb7GliiKJsvuhxlE4E5JxQF2zMub/CSNbF97//tYSyj96sxeFQxZXbcjm9
14xt6mr/xNLA4szNQMJ4P+L7b5e/jC5DSqlwS+CUYJgaFs/SP+qJoCSu1bR3IM9XWO
15cRBpDmcBbYLkSyB92WURvsZ1LtjEcn+cdQVI
16-----END CERTIFICATE----- 18-----END CERTIFICATE-----
17-----BEGIN RSA PRIVATE KEY----- 19-----BEGIN RSA PRIVATE KEY-----
18MIICXAIBAAKBgQCdoWk/3+WcMlfjIrkg40ketmnQaEogQe1LLcuOJV6rKfUSAsPg 20MIICXAIBAAKBgQCdoWk/3+WcMlfjIrkg40ketmnQaEogQe1LLcuOJV6rKfUSAsPg
diff --git a/src/lib/libssl/src/config b/src/lib/libssl/src/config
index 93e2317c3f..f57969bb44 100644
--- a/src/lib/libssl/src/config
+++ b/src/lib/libssl/src/config
@@ -27,6 +27,7 @@ RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
27SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown" 27SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
28VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown" 28VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
29 29
30
30# Now test for ISC and SCO, since it is has a braindamaged uname. 31# Now test for ISC and SCO, since it is has a braindamaged uname.
31# 32#
32# We need to work around FreeBSD 1.1.5.1 33# We need to work around FreeBSD 1.1.5.1
@@ -50,6 +51,8 @@ if [ "x$XREL" != "x" ]; then
50 4.2MP) 51 4.2MP)
51 if [ "x$VERSION" = "x2.1.1" ]; then 52 if [ "x$VERSION" = "x2.1.1" ]; then
52 echo "${MACHINE}-whatever-unixware211"; exit 0 53 echo "${MACHINE}-whatever-unixware211"; exit 0
54 elif [ "x$VERSION" = "x2.1.2" ]; then
55 echo "${MACHINE}-whatever-unixware212"; exit 0
53 else 56 else
54 echo "${MACHINE}-whatever-unixware2"; exit 0 57 echo "${MACHINE}-whatever-unixware2"; exit 0
55 fi 58 fi
@@ -57,6 +60,11 @@ if [ "x$XREL" != "x" ]; then
57 4.2) 60 4.2)
58 echo "whatever-whatever-unixware1"; exit 0 61 echo "whatever-whatever-unixware1"; exit 0
59 ;; 62 ;;
63 5)
64 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
65 echo "${MACHINE}-sco-unixware7"; exit 0
66 fi
67 ;;
60 esac 68 esac
61 fi 69 fi
62fi 70fi
@@ -187,6 +195,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
187 echo "i860-intel-osf1"; exit 0 195 echo "i860-intel-osf1"; exit 0
188 ;; 196 ;;
189 197
198 Rhapsody:*)
199 echo "ppc-apple-rhapsody"; exit 0
200 ;;
201
190 SunOS:5.*) 202 SunOS:5.*)
191 echo "${MACHINE}-sun-solaris2"; exit 0 203 echo "${MACHINE}-sun-solaris2"; exit 0
192 ;; 204 ;;
@@ -311,7 +323,7 @@ else
311fi 323fi
312 324
313if [ "$SYSTEM" = "SunOS" ]; then 325if [ "$SYSTEM" = "SunOS" ]; then
314 # assume output is "blah-blah C x.x" 326 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
315 CCVER=`(cc -V 2>&1) 2>/dev/null | \ 327 CCVER=`(cc -V 2>&1) 2>/dev/null | \
316 egrep -e '^cc: .* C [0-9]\.[0-9]' | \ 328 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
317 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'` 329 sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
@@ -328,6 +340,19 @@ if [ "$SYSTEM" = "SunOS" ]; then
328 fi 340 fi
329fi 341fi
330 342
343if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
344 # check for Compaq C, expected output is "blah-blah C Vx.x"
345 CCCVER=`(ccc -V 2>&1) 2>/dev/null | \
346 egrep -e '.* C V[0-9]\.[0-9]' | \
347 sed 's/.* C V\([0-9]\)\.\([0-9]\).*/\1\2/'`
348 CCCVER=${CCCVER:-0}
349 if [ $CCCVER -gt 60 ]; then
350 CC=ccc # overrides gcc!!! well, ccc outperforms inoticeably
351 # only on hash routines and des, otherwise gcc (2.95)
352 # keeps along rather tight...
353 fi
354fi
355
331GCCVER=${GCCVER:-0} 356GCCVER=${GCCVER:-0}
332CCVER=${CCVER:-0} 357CCVER=${CCVER:-0}
333 358
@@ -340,9 +365,6 @@ echo Operating system: $GUESSOS
340# script above so we end up with values in vars but that would take 365# script above so we end up with values in vars but that would take
341# more time that I want to waste at the moment 366# more time that I want to waste at the moment
342case "$GUESSOS" in 367case "$GUESSOS" in
343 alpha-*-linux2) OUT="alpha-gcc" ;;
344 ppc-*-linux2) OUT="linux-ppc" ;;
345 mips-*-linux?) OUT="linux-mips" ;;
346 mips2-sgi-irix) 368 mips2-sgi-irix)
347 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'` 369 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
348 CPU=${CPU:-0} 370 CPU=${CPU:-0}
@@ -369,6 +391,23 @@ case "$GUESSOS" in
369 options="$options -mips4" 391 options="$options -mips4"
370 OUT="irix-mips3-$CC" 392 OUT="irix-mips3-$CC"
371 ;; 393 ;;
394 alpha-*-linux2)
395 ISA=`awk '/cpu model/{print$4}' /proc/cpuinfo`
396 case ${ISA:-generic} in
397 *[67]) OUT="linux-alpha+bwx-$CC" ;;
398 *) OUT="linux-alpha-$CC" ;;
399 esac
400 if [ "$CC" = "gcc" ]; then
401 case ${ISA:-generic} in
402 EV5|EV45) options="$options -mcpu=ev5";;
403 EV56|PCA56) options="$options -mcpu=ev56";;
404 EV6|EV67|PCA57) options="$options -mcpu=ev6";;
405 esac
406 fi
407 ;;
408 mips-*-linux?) OUT="linux-mips" ;;
409 ppc-*-linux2) OUT="linux-ppc" ;;
410 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
372 sparc64-*-linux2) 411 sparc64-*-linux2)
373 #Before we can uncomment following lines we have to wait at least 412 #Before we can uncomment following lines we have to wait at least
374 #till 64-bit glibc for SPARC is operational:-( 413 #till 64-bit glibc for SPARC is operational:-(
@@ -413,17 +452,30 @@ case "$GUESSOS" in
413 *-*-openbsd) OUT="OpenBSD" ;; 452 *-*-openbsd) OUT="OpenBSD" ;;
414 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;; 453 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
415 *-*-osf) OUT="alpha-cc" ;; 454 *-*-osf) OUT="alpha-cc" ;;
416 *-*-unixware*) OUT="unixware-2.0" ;; 455 *-*-unixware7) OUT="unixware-7" ;;
456 *-*-UnixWare7) OUT="unixware-7" ;;
457 *-*-Unixware7) OUT="unixware-7" ;;
458 *-*-unixware[1-2]*) OUT="unixware-2.0" ;;
459 *-*-UnixWare[1-2]*) OUT="unixware-2.0" ;;
460 *-*-Unixware[1-2]*) OUT="unixware-2.0" ;;
417 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;; 461 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
418 RM*-siemens-sysv4) OUT="ReliantUNIX" ;; 462 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
419 *-siemens-sysv4) OUT="SINIX" ;; 463 *-siemens-sysv4) OUT="SINIX" ;;
464 *-hpux1*) OUT="hpux-parisc-$CC"
465 options="$options -D_REENTRANT" ;;
466 *-hpux) OUT="hpux-parisc-$CC" ;;
420 # these are all covered by the catchall below 467 # these are all covered by the catchall below
421 # *-hpux*) OUT="hpux-$CC" ;;
422 # *-aix) OUT="aix-$CC" ;; 468 # *-aix) OUT="aix-$CC" ;;
423 # *-dgux) OUT="dgux" ;; 469 # *-dgux) OUT="dgux" ;;
424 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;; 470 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
425esac 471esac
426 472
473# See whether we can compile Atalla support
474if [ -f /usr/include/atasi.h ]
475then
476 options="$options -DATALLA"
477fi
478
427# gcc < 2.8 does not support -mcpu=ultrasparc 479# gcc < 2.8 does not support -mcpu=ultrasparc
428if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ] 480if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
429then 481then
@@ -438,6 +490,17 @@ then
438 sleep 5 490 sleep 5
439 OUT=linux-sparcv8 491 OUT=linux-sparcv8
440fi 492fi
493# To start with $OUT is never i86pc-sun-solaris2. Secondly why
494# ban *all* assembler implementation if it can't stand only one,
495# SHA-0 implementation.
496#if [ "$OUT" = "i86pc-sun-solaris2" ]
497#then
498# ASM=`as -V /dev/null 2>&1`
499# case "$ASM" in
500# GNU*) ;;
501# *) options="$options no-asm" ; echo "WARNING: You need the GNU assembler to use OpenSSL assembler code." ; echo "Sun as is not supported on Solaris x86." ;;
502# esac
503#fi
441 504
442case "$GUESSOS" in 505case "$GUESSOS" in
443 i386-*) options="$options 386" ;; 506 i386-*) options="$options 386" ;;
@@ -484,14 +547,14 @@ fi
484# compiler for the platform ... in which case we add it on 547# compiler for the platform ... in which case we add it on
485# the end ... otherwise we leave it off 548# the end ... otherwise we leave it off
486 549
487$PERL ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null 550$PERL ./Configure LIST | grep "$OUT-$CC" > /dev/null
488if [ $? = "0" ]; then 551if [ $? = "0" ]; then
489 OUT="$OUT-$CC" 552 OUT="$OUT-$CC"
490fi 553fi
491 554
492OUT="$PREFIX$OUT" 555OUT="$PREFIX$OUT"
493 556
494$PERL ./Configure 2>&1 | grep "$OUT" > /dev/null 557$PERL ./Configure LIST | grep "$OUT" > /dev/null
495if [ $? = "0" ]; then 558if [ $? = "0" ]; then
496 echo Configuring for $OUT 559 echo Configuring for $OUT
497 560
diff --git a/src/lib/libssl/src/crypto/Makefile b/src/lib/libssl/src/crypto/Makefile
index f4813d3aaa..c0b6e906a8 100644
--- a/src/lib/libssl/src/crypto/Makefile
+++ b/src/lib/libssl/src/crypto/Makefile
@@ -34,8 +34,8 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
34GENERAL=Makefile README crypto-lib.com install.com 34GENERAL=Makefile README crypto-lib.com install.com
35 35
36LIB= $(TOP)/libcrypto.a 36LIB= $(TOP)/libcrypto.a
37LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c cpt_err.c 37LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c
38LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o cpt_err.o 38LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o
39 39
40SRC= $(LIBSRC) 40SRC= $(LIBSRC)
41 41
@@ -57,6 +57,11 @@ buildinf.h: ../Makefile.ssl
57 echo " #define DATE \"`date`\""; \ 57 echo " #define DATE \"`date`\""; \
58 echo "#endif" ) >buildinf.h 58 echo "#endif" ) >buildinf.h
59 59
60testapps:
61 if echo ${SDIRS} | fgrep ' des '; \
62 then cd des && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' des; fi
63 cd pkcs7 && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' testapps
64
60subdirs: 65subdirs:
61 @for i in $(SDIRS) ;\ 66 @for i in $(SDIRS) ;\
62 do \ 67 do \
@@ -122,7 +127,7 @@ lint:
122 done; 127 done;
123 128
124depend: 129depend:
125 if [ ! -e buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist 130 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist
126 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC) 131 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC)
127 if [ ! -s buildinf.h ]; then rm buildinf.h; fi 132 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
128 @for i in $(SDIRS) ;\ 133 @for i in $(SDIRS) ;\
@@ -151,29 +156,40 @@ dclean:
151# DO NOT DELETE THIS LINE -- make depend depends on it. 156# DO NOT DELETE THIS LINE -- make depend depends on it.
152 157
153cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h 158cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h
154cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/stack.h 159cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
160cpt_err.o: ../include/openssl/stack.h
155cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h 161cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h
156cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 162cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
157cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 163cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
158cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 164cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
159cryptlib.o: ../include/openssl/stack.h cryptlib.h 165cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
166cryptlib.o: cryptlib.h
160cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h 167cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h
161cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 168cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
162cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h 169cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h
163cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 170cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
164cversion.o: ../include/openssl/stack.h buildinf.h cryptlib.h 171cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
172cversion.o: buildinf.h cryptlib.h
165ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h 173ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h
166ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 174ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
167ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h 175ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h
168ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 176ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
169ex_data.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 177ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
178ex_data.o: ../include/openssl/stack.h cryptlib.h
170mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h 179mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h
171mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 180mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
172mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h 181mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h
173mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 182mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
174mem.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 183mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h cryptlib.h
184mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h
185mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
186mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h
187mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
188mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
189mem_dbg.o: ../include/openssl/stack.h cryptlib.h
175tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h 190tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h
176tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 191tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
177tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h 192tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h
178tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 193tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
179tmdiff.o: ../include/openssl/stack.h ../include/openssl/tmdiff.h cryptlib.h 194tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
195tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
diff --git a/src/lib/libssl/src/crypto/Makefile.ssl b/src/lib/libssl/src/crypto/Makefile.ssl
index 2fcbf18545..cab75d9f80 100644
--- a/src/lib/libssl/src/crypto/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/Makefile.ssl
@@ -34,8 +34,8 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
34GENERAL=Makefile README crypto-lib.com install.com 34GENERAL=Makefile README crypto-lib.com install.com
35 35
36LIB= $(TOP)/libcrypto.a 36LIB= $(TOP)/libcrypto.a
37LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c cpt_err.c 37LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c
38LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o cpt_err.o 38LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o
39 39
40SRC= $(LIBSRC) 40SRC= $(LIBSRC)
41 41
@@ -57,6 +57,11 @@ buildinf.h: ../Makefile.ssl
57 echo " #define DATE \"`date`\""; \ 57 echo " #define DATE \"`date`\""; \
58 echo "#endif" ) >buildinf.h 58 echo "#endif" ) >buildinf.h
59 59
60testapps:
61 if echo ${SDIRS} | fgrep ' des '; \
62 then cd des && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' des; fi
63 cd pkcs7 && $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' testapps
64
60subdirs: 65subdirs:
61 @for i in $(SDIRS) ;\ 66 @for i in $(SDIRS) ;\
62 do \ 67 do \
@@ -122,7 +127,7 @@ lint:
122 done; 127 done;
123 128
124depend: 129depend:
125 if [ ! -e buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist 130 if [ ! -f buildinf.h ]; then touch buildinf.h; fi # fake buildinf.h if it does not exist
126 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC) 131 $(MAKEDEPEND) $(INCLUDE) $(DEPFLAG) $(PROGS) $(LIBSRC)
127 if [ ! -s buildinf.h ]; then rm buildinf.h; fi 132 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
128 @for i in $(SDIRS) ;\ 133 @for i in $(SDIRS) ;\
@@ -151,29 +156,40 @@ dclean:
151# DO NOT DELETE THIS LINE -- make depend depends on it. 156# DO NOT DELETE THIS LINE -- make depend depends on it.
152 157
153cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h 158cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h
154cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/stack.h 159cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
160cpt_err.o: ../include/openssl/stack.h
155cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h 161cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h
156cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 162cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
157cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 163cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
158cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 164cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
159cryptlib.o: ../include/openssl/stack.h cryptlib.h 165cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
166cryptlib.o: cryptlib.h
160cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h 167cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h
161cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 168cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
162cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h 169cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h
163cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 170cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
164cversion.o: ../include/openssl/stack.h buildinf.h cryptlib.h 171cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
172cversion.o: buildinf.h cryptlib.h
165ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h 173ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h
166ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 174ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
167ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h 175ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h
168ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 176ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
169ex_data.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 177ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
178ex_data.o: ../include/openssl/stack.h cryptlib.h
170mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h 179mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h
171mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 180mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
172mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h 181mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h
173mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 182mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
174mem.o: ../include/openssl/opensslv.h ../include/openssl/stack.h cryptlib.h 183mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h cryptlib.h
184mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h
185mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
186mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h
187mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
188mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
189mem_dbg.o: ../include/openssl/stack.h cryptlib.h
175tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h 190tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h
176tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 191tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
177tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h 192tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h
178tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 193tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
179tmdiff.o: ../include/openssl/stack.h ../include/openssl/tmdiff.h cryptlib.h 194tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
195tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
diff --git a/src/lib/libssl/src/crypto/asn1/Makefile.ssl b/src/lib/libssl/src/crypto/asn1/Makefile.ssl
index 5d668411f6..a17a713a75 100644
--- a/src/lib/libssl/src/crypto/asn1/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/asn1/Makefile.ssl
@@ -23,34 +23,34 @@ APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(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 \ 25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \
26 a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_bmp.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_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c \ 27 a_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c \
28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \ 28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \
29 x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c nsseq.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 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.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 \ 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\ 32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
33 t_req.c t_x509.c t_crl.c t_pkey.c \ 33 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 \ 34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \
35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ 35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \
36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.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 \ 37 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 \ 38 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 39 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c
40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \ 40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \
41 a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_bmp.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 \
42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o \ 42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o \
43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \ 43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \
44 x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o nsseq.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 \
45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.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 \ 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 \ 47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
48 t_req.o t_x509.o t_crl.o t_pkey.o \ 48 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 \ 49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \
50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ 50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \
51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.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 \ 52 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 \ 53 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 54 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o
55 55
56SRC= $(LIBSRC) 56SRC= $(LIBSRC)
@@ -160,11 +160,13 @@ a_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
160a_digest.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 160a_digest.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
161a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 161a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
162a_digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 162a_digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
163a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h 163a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
164a_digest.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 164a_digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
165a_digest.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 165a_digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
166a_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 166a_digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
167a_digest.o: ../../include/openssl/stack.h ../cryptlib.h 167a_digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
168a_digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
169a_digest.o: ../cryptlib.h
168a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 170a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
169a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 171a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
170a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 172a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -207,6 +209,13 @@ a_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
207a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 209a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
208a_int.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 210a_int.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209a_int.o: ../cryptlib.h 211a_int.o: ../cryptlib.h
212a_mbstr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
213a_mbstr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
214a_mbstr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
215a_mbstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
216a_mbstr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
217a_mbstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
218a_mbstr.o: ../cryptlib.h
210a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 219a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
211a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 220a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
212a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 221a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -214,6 +223,13 @@ a_meth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 223a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
215a_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 224a_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
216a_meth.o: ../cryptlib.h 225a_meth.o: ../cryptlib.h
226a_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
227a_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
228a_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
229a_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
230a_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
231a_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
232a_null.o: ../cryptlib.h
217a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 233a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
218a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 234a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
219a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 235a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -259,6 +275,13 @@ a_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
259a_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 275a_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
260a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 276a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
261a_sign.o: ../cryptlib.h 277a_sign.o: ../cryptlib.h
278a_strnid.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
279a_strnid.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
280a_strnid.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
281a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
282a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
283a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
284a_strnid.o: ../../include/openssl/stack.h ../cryptlib.h
262a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 285a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
263a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 286a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
264a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 287a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -788,6 +811,24 @@ p8_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
788p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 811p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
789p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 812p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
790p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 813p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
814t_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
815t_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
816t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
817t_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
818t_bitst.o: ../../include/openssl/des.h ../../include/openssl/dh.h
819t_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
820t_bitst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
821t_bitst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
822t_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
823t_bitst.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
824t_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
825t_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
826t_bitst.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
827t_bitst.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
828t_bitst.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
829t_bitst.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
830t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
831t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h
791t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 832t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
792t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 833t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
793t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 834t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -812,15 +853,17 @@ t_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
812t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 853t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
813t_pkey.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 854t_pkey.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
814t_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 855t_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
815t_pkey.o: ../../include/openssl/stack.h ../cryptlib.h 856t_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
857t_pkey.o: ../cryptlib.h
816t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 858t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
817t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 859t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
818t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 860t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
819t_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 861t_req.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
820t_req.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 862t_req.o: ../../include/openssl/des.h ../../include/openssl/dh.h
821t_req.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 863t_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
822t_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h 864t_req.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
823t_req.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 865t_req.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
866t_req.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
824t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 867t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
825t_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 868t_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
826t_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 869t_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -829,7 +872,24 @@ t_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
829t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 872t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
830t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 873t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
831t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 874t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
832t_req.o: ../cryptlib.h 875t_req.o: ../../include/openssl/x509v3.h ../cryptlib.h
876t_spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
877t_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
878t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
879t_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
880t_spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h
881t_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
882t_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
883t_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
884t_spki.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
885t_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
886t_spki.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
887t_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
888t_spki.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
889t_spki.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
890t_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
891t_spki.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
892t_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
833t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 893t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
834t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 894t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
835t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 895t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -848,6 +908,23 @@ t_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
848t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 908t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
849t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 909t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
850t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h 910t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h
911t_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
912t_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
913t_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
914t_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
915t_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
916t_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
917t_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
918t_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
919t_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
920t_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
921t_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
922t_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
923t_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
924t_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
925t_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
926t_x509a.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
927t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
851x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 928x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
852x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 929x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
853x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 930x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -1088,3 +1165,20 @@ x_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1088x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 1165x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1089x_x509.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 1166x_x509.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
1090x_x509.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 1167x_x509.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
1168x_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
1169x_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1170x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1171x_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1172x_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
1173x_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
1174x_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1175x_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1176x_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
1177x_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
1178x_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1179x_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1180x_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1181x_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1182x_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1183x_x509a.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
1184x_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 38ea802be8..c77456b315 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bitstr.c
+++ b/src/lib/libssl/src/crypto/asn1/a_bitstr.c
@@ -60,6 +60,15 @@
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)
70{ return M_ASN1_BIT_STRING_set(x, d, len); }
71
63int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) 72int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
64 { 73 {
65 int ret,j,r,bits,len; 74 int ret,j,r,bits,len;
@@ -121,7 +130,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
121 130
122 if ((a == NULL) || ((*a) == NULL)) 131 if ((a == NULL) || ((*a) == NULL))
123 { 132 {
124 if ((ret=ASN1_BIT_STRING_new()) == NULL) return(NULL); 133 if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL);
125 } 134 }
126 else 135 else
127 ret=(*a); 136 ret=(*a);
@@ -164,7 +173,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
164 s=NULL; 173 s=NULL;
165 174
166 ret->length=(int)len; 175 ret->length=(int)len;
167 if (ret->data != NULL) Free((char *)ret->data); 176 if (ret->data != NULL) Free(ret->data);
168 ret->data=s; 177 ret->data=s;
169 ret->type=V_ASN1_BIT_STRING; 178 ret->type=V_ASN1_BIT_STRING;
170 if (a != NULL) (*a)=ret; 179 if (a != NULL) (*a)=ret;
@@ -173,7 +182,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
173err: 182err:
174 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i); 183 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i);
175 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 184 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
176 ASN1_BIT_STRING_free(ret); 185 M_ASN1_BIT_STRING_free(ret);
177 return(NULL); 186 return(NULL);
178 } 187 }
179 188
diff --git a/src/lib/libssl/src/crypto/asn1/a_bmp.c b/src/lib/libssl/src/crypto/asn1/a_bmp.c
index 6075871984..d9ac5a0475 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bmp.c
+++ b/src/lib/libssl/src/crypto/asn1/a_bmp.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_BMPSTRING *ASN1_BMPSTRING_new(void)
64{ return M_ASN1_BMPSTRING_new(); }
65
66void ASN1_BMPSTRING_free(ASN1_BMPSTRING *x)
67{ M_ASN1_BMPSTRING_free(x); }
68
63int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp) 69int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
diff --git a/src/lib/libssl/src/crypto/asn1/a_bytes.c b/src/lib/libssl/src/crypto/asn1/a_bytes.c
index e452e03b88..8cde695804 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bytes.c
+++ b/src/lib/libssl/src/crypto/asn1/a_bytes.c
@@ -71,7 +71,7 @@ B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN, 71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
72 }; 72 };
73 73
74static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c); 74static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
75/* type is a 'bitmap' of acceptable string types. 75/* type is a 'bitmap' of acceptable string types.
76 */ 76 */
77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp, 77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
@@ -124,7 +124,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
124 else 124 else
125 s=NULL; 125 s=NULL;
126 126
127 if (ret->data != NULL) Free((char *)ret->data); 127 if (ret->data != NULL) Free(ret->data);
128 ret->length=(int)len; 128 ret->length=(int)len;
129 ret->data=s; 129 ret->data=s;
130 ret->type=tag; 130 ret->type=tag;
@@ -205,7 +205,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
205 c.tag=Ptag; 205 c.tag=Ptag;
206 c.xclass=Pclass; 206 c.xclass=Pclass;
207 c.max=(length == 0)?0:(p+length); 207 c.max=(length == 0)?0:(p+length);
208 if (!asn1_collate_primative(ret,&c)) 208 if (!asn1_collate_primitive(ret,&c))
209 goto err; 209 goto err;
210 else 210 else
211 { 211 {
@@ -218,8 +218,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
218 { 218 {
219 if ((ret->length < len) || (ret->data == NULL)) 219 if ((ret->length < len) || (ret->data == NULL))
220 { 220 {
221 if (ret->data != NULL) Free((char *)ret->data); 221 if (ret->data != NULL) Free(ret->data);
222 s=(unsigned char *)Malloc((int)len); 222 s=(unsigned char *)Malloc((int)len + 1);
223 if (s == NULL) 223 if (s == NULL)
224 { 224 {
225 i=ERR_R_MALLOC_FAILURE; 225 i=ERR_R_MALLOC_FAILURE;
@@ -229,12 +229,13 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
229 else 229 else
230 s=ret->data; 230 s=ret->data;
231 memcpy(s,p,(int)len); 231 memcpy(s,p,(int)len);
232 s[len] = '\0';
232 p+=len; 233 p+=len;
233 } 234 }
234 else 235 else
235 { 236 {
236 s=NULL; 237 s=NULL;
237 if (ret->data != NULL) Free((char *)ret->data); 238 if (ret->data != NULL) Free(ret->data);
238 } 239 }
239 240
240 ret->length=(int)len; 241 ret->length=(int)len;
@@ -253,11 +254,11 @@ err:
253 } 254 }
254 255
255 256
256/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapes 257/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapse
257 * them into the one struture that is then returned */ 258 * them into the one structure that is then returned */
258/* There have been a few bug fixes for this function from 259/* There have been a few bug fixes for this function from
259 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */ 260 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
260static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c) 261static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
261 { 262 {
262 ASN1_STRING *os=NULL; 263 ASN1_STRING *os=NULL;
263 BUF_MEM b; 264 BUF_MEM b;
diff --git a/src/lib/libssl/src/crypto/asn1/a_digest.c b/src/lib/libssl/src/crypto/asn1/a_digest.c
index 8c45add557..3370aae998 100644
--- a/src/lib/libssl/src/crypto/asn1/a_digest.c
+++ b/src/lib/libssl/src/crypto/asn1/a_digest.c
@@ -58,16 +58,19 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/evp.h> 68#include <openssl/evp.h>
66#include <openssl/buffer.h> 69#include <openssl/buffer.h>
67#include <openssl/x509.h> 70#include <openssl/x509.h>
68 71
69int ASN1_digest(int (*i2d)(), EVP_MD *type, char *data, unsigned char *md, 72int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
70 unsigned int *len) 73 unsigned char *md, unsigned int *len)
71 { 74 {
72 EVP_MD_CTX ctx; 75 EVP_MD_CTX ctx;
73 int i; 76 int i;
diff --git a/src/lib/libssl/src/crypto/asn1/a_dup.c b/src/lib/libssl/src/crypto/asn1/a_dup.c
index c0a8709f3b..3202a816d0 100644
--- a/src/lib/libssl/src/crypto/asn1/a_dup.c
+++ b/src/lib/libssl/src/crypto/asn1/a_dup.c
@@ -78,6 +78,6 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
78 i=i2d(x,&p); 78 i=i2d(x,&p);
79 p= b; 79 p= b;
80 ret=d2i(NULL,&p,i); 80 ret=d2i(NULL,&p,i);
81 Free((char *)b); 81 Free(b);
82 return(ret); 82 return(ret);
83 } 83 }
diff --git a/src/lib/libssl/src/crypto/asn1/a_enum.c b/src/lib/libssl/src/crypto/asn1/a_enum.c
index 9239ecc439..ccf62e5a04 100644
--- a/src/lib/libssl/src/crypto/asn1/a_enum.c
+++ b/src/lib/libssl/src/crypto/asn1/a_enum.c
@@ -65,6 +65,12 @@
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
68int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp) 74int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp)
69 { 75 {
70 int pad=0,ret,r,i,t; 76 int pad=0,ret,r,i,t;
@@ -142,7 +148,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
142 148
143 if ((a == NULL) || ((*a) == NULL)) 149 if ((a == NULL) || ((*a) == NULL))
144 { 150 {
145 if ((ret=ASN1_ENUMERATED_new()) == NULL) return(NULL); 151 if ((ret=M_ASN1_ENUMERATED_new()) == NULL) return(NULL);
146 ret->type=V_ASN1_ENUMERATED; 152 ret->type=V_ASN1_ENUMERATED;
147 } 153 }
148 else 154 else
@@ -171,7 +177,12 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
171 goto err; 177 goto err;
172 } 178 }
173 to=s; 179 to=s;
174 if (*p & 0x80) /* a negative number */ 180 if(!len) {
181 /* Strictly speaking this is an illegal ENUMERATED but we
182 * tolerate it.
183 */
184 ret->type=V_ASN1_ENUMERATED;
185 } else if (*p & 0x80) /* a negative number */
175 { 186 {
176 ret->type=V_ASN1_NEG_ENUMERATED; 187 ret->type=V_ASN1_NEG_ENUMERATED;
177 if ((*p == 0xff) && (len != 1)) { 188 if ((*p == 0xff) && (len != 1)) {
@@ -208,7 +219,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
208 p+=len; 219 p+=len;
209 } 220 }
210 221
211 if (ret->data != NULL) Free((char *)ret->data); 222 if (ret->data != NULL) Free(ret->data);
212 ret->data=s; 223 ret->data=s;
213 ret->length=(int)len; 224 ret->length=(int)len;
214 if (a != NULL) (*a)=ret; 225 if (a != NULL) (*a)=ret;
@@ -217,7 +228,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
217err: 228err:
218 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i); 229 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i);
219 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 230 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
220 ASN1_ENUMERATED_free(ret); 231 M_ASN1_ENUMERATED_free(ret);
221 return(NULL); 232 return(NULL);
222 } 233 }
223 234
@@ -231,7 +242,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
231 if (a->length < (sizeof(long)+1)) 242 if (a->length < (sizeof(long)+1))
232 { 243 {
233 if (a->data != NULL) 244 if (a->data != NULL)
234 Free((char *)a->data); 245 Free(a->data);
235 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL) 246 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
236 memset((char *)a->data,0,sizeof(long)+1); 247 memset((char *)a->data,0,sizeof(long)+1);
237 } 248 }
@@ -295,7 +306,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
295 int len,j; 306 int len,j;
296 307
297 if (ai == NULL) 308 if (ai == NULL)
298 ret=ASN1_ENUMERATED_new(); 309 ret=M_ASN1_ENUMERATED_new();
299 else 310 else
300 ret=ai; 311 ret=ai;
301 if (ret == NULL) 312 if (ret == NULL)
@@ -311,7 +322,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
311 ret->length=BN_bn2bin(bn,ret->data); 322 ret->length=BN_bn2bin(bn,ret->data);
312 return(ret); 323 return(ret);
313err: 324err:
314 if (ret != ai) ASN1_ENUMERATED_free(ret); 325 if (ret != ai) M_ASN1_ENUMERATED_free(ret);
315 return(NULL); 326 return(NULL);
316 } 327 }
317 328
diff --git a/src/lib/libssl/src/crypto/asn1/a_gentm.c b/src/lib/libssl/src/crypto/asn1/a_gentm.c
index 226474f057..84062170e8 100644
--- a/src/lib/libssl/src/crypto/asn1/a_gentm.c
+++ b/src/lib/libssl/src/crypto/asn1/a_gentm.c
@@ -63,6 +63,12 @@
63#include "cryptlib.h" 63#include "cryptlib.h"
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65 65
66ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void)
67{ return M_ASN1_GENERALIZEDTIME_new(); }
68
69void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *x)
70{ M_ASN1_GENERALIZEDTIME_free(x); }
71
66int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) 72int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
67 { 73 {
68#ifdef CHARSET_EBCDIC 74#ifdef CHARSET_EBCDIC
@@ -106,7 +112,7 @@ ASN1_GENERALIZEDTIME *d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,
106 return(ret); 112 return(ret);
107err: 113err:
108 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 114 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
109 ASN1_GENERALIZEDTIME_free(ret); 115 M_ASN1_GENERALIZEDTIME_free(ret);
110 return(NULL); 116 return(NULL);
111 } 117 }
112 118
@@ -193,7 +199,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
193#endif 199#endif
194 200
195 if (s == NULL) 201 if (s == NULL)
196 s=ASN1_GENERALIZEDTIME_new(); 202 s=M_ASN1_GENERALIZEDTIME_new();
197 if (s == NULL) 203 if (s == NULL)
198 return(NULL); 204 return(NULL);
199 205
diff --git a/src/lib/libssl/src/crypto/asn1/a_hdr.c b/src/lib/libssl/src/crypto/asn1/a_hdr.c
index 1171d36443..434610e8e1 100644
--- a/src/lib/libssl/src/crypto/asn1/a_hdr.c
+++ b/src/lib/libssl/src/crypto/asn1/a_hdr.c
@@ -102,7 +102,7 @@ ASN1_HEADER *ASN1_HEADER_new(void)
102 ASN1_CTX c; 102 ASN1_CTX c;
103 103
104 M_ASN1_New_Malloc(ret,ASN1_HEADER); 104 M_ASN1_New_Malloc(ret,ASN1_HEADER);
105 M_ASN1_New(ret->header,ASN1_OCTET_STRING_new); 105 M_ASN1_New(ret->header,M_ASN1_OCTET_STRING_new);
106 ret->meth=NULL; 106 ret->meth=NULL;
107 ret->data=NULL; 107 ret->data=NULL;
108 return(ret); 108 return(ret);
@@ -112,8 +112,8 @@ ASN1_HEADER *ASN1_HEADER_new(void)
112void ASN1_HEADER_free(ASN1_HEADER *a) 112void ASN1_HEADER_free(ASN1_HEADER *a)
113 { 113 {
114 if (a == NULL) return; 114 if (a == NULL) return;
115 ASN1_OCTET_STRING_free(a->header); 115 M_ASN1_OCTET_STRING_free(a->header);
116 if (a->meth != NULL) 116 if (a->meth != NULL)
117 a->meth->destroy(a->data); 117 a->meth->destroy(a->data);
118 Free((char *)a); 118 Free(a);
119 } 119 }
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 6bd845443c..d9b8035e17 100644
--- a/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c
+++ b/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c
@@ -108,6 +108,6 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x)
108 j+=i; 108 j+=i;
109 n-=i; 109 n-=i;
110 } 110 }
111 Free((char *)b); 111 Free(b);
112 return(ret); 112 return(ret);
113 } 113 }
diff --git a/src/lib/libssl/src/crypto/asn1/a_int.c b/src/lib/libssl/src/crypto/asn1/a_int.c
index d05436378b..8b6794e8c1 100644
--- a/src/lib/libssl/src/crypto/asn1/a_int.c
+++ b/src/lib/libssl/src/crypto/asn1/a_int.c
@@ -60,6 +60,18 @@
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)
70{ return M_ASN1_INTEGER_dup(x);}
71
72int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
73{ return M_ASN1_INTEGER_cmp(x,y);}
74
63/* 75/*
64 * This converts an ASN1 INTEGER into its DER encoding. 76 * This converts an ASN1 INTEGER into its DER encoding.
65 * The internal representation is an ASN1_STRING whose data is a big endian 77 * The internal representation is an ASN1_STRING whose data is a big endian
@@ -160,7 +172,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
160 172
161 if ((a == NULL) || ((*a) == NULL)) 173 if ((a == NULL) || ((*a) == NULL))
162 { 174 {
163 if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL); 175 if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
164 ret->type=V_ASN1_INTEGER; 176 ret->type=V_ASN1_INTEGER;
165 } 177 }
166 else 178 else
@@ -190,7 +202,12 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
190 goto err; 202 goto err;
191 } 203 }
192 to=s; 204 to=s;
193 if (*p & 0x80) /* a negative number */ 205 if(!len) {
206 /* Strictly speaking this is an illegal INTEGER but we
207 * tolerate it.
208 */
209 ret->type=V_ASN1_INTEGER;
210 } else if (*p & 0x80) /* a negative number */
194 { 211 {
195 ret->type=V_ASN1_NEG_INTEGER; 212 ret->type=V_ASN1_NEG_INTEGER;
196 if ((*p == 0xff) && (len != 1)) { 213 if ((*p == 0xff) && (len != 1)) {
@@ -231,7 +248,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
231 memcpy(s,p,(int)len); 248 memcpy(s,p,(int)len);
232 } 249 }
233 250
234 if (ret->data != NULL) Free((char *)ret->data); 251 if (ret->data != NULL) Free(ret->data);
235 ret->data=s; 252 ret->data=s;
236 ret->length=(int)len; 253 ret->length=(int)len;
237 if (a != NULL) (*a)=ret; 254 if (a != NULL) (*a)=ret;
@@ -240,7 +257,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
240err: 257err:
241 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i); 258 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
242 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 259 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
243 ASN1_INTEGER_free(ret); 260 M_ASN1_INTEGER_free(ret);
244 return(NULL); 261 return(NULL);
245 } 262 }
246 263
@@ -260,7 +277,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
260 277
261 if ((a == NULL) || ((*a) == NULL)) 278 if ((a == NULL) || ((*a) == NULL))
262 { 279 {
263 if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL); 280 if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
264 ret->type=V_ASN1_INTEGER; 281 ret->type=V_ASN1_INTEGER;
265 } 282 }
266 else 283 else
@@ -289,7 +306,8 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
289 goto err; 306 goto err;
290 } 307 }
291 to=s; 308 to=s;
292 ret->type=V_ASN1_INTEGER; 309 ret->type=V_ASN1_INTEGER;
310 if(len) {
293 if ((*p == 0) && (len != 1)) 311 if ((*p == 0) && (len != 1))
294 { 312 {
295 p++; 313 p++;
@@ -297,8 +315,9 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
297 } 315 }
298 memcpy(s,p,(int)len); 316 memcpy(s,p,(int)len);
299 p+=len; 317 p+=len;
318 }
300 319
301 if (ret->data != NULL) Free((char *)ret->data); 320 if (ret->data != NULL) Free(ret->data);
302 ret->data=s; 321 ret->data=s;
303 ret->length=(int)len; 322 ret->length=(int)len;
304 if (a != NULL) (*a)=ret; 323 if (a != NULL) (*a)=ret;
@@ -307,7 +326,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
307err: 326err:
308 ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i); 327 ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i);
309 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 328 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
310 ASN1_INTEGER_free(ret); 329 M_ASN1_INTEGER_free(ret);
311 return(NULL); 330 return(NULL);
312 } 331 }
313 332
@@ -321,7 +340,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
321 if (a->length < (sizeof(long)+1)) 340 if (a->length < (sizeof(long)+1))
322 { 341 {
323 if (a->data != NULL) 342 if (a->data != NULL)
324 Free((char *)a->data); 343 Free(a->data);
325 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL) 344 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
326 memset((char *)a->data,0,sizeof(long)+1); 345 memset((char *)a->data,0,sizeof(long)+1);
327 } 346 }
@@ -385,7 +404,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
385 int len,j; 404 int len,j;
386 405
387 if (ai == NULL) 406 if (ai == NULL)
388 ret=ASN1_INTEGER_new(); 407 ret=M_ASN1_INTEGER_new();
389 else 408 else
390 ret=ai; 409 ret=ai;
391 if (ret == NULL) 410 if (ret == NULL)
@@ -401,7 +420,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
401 ret->length=BN_bn2bin(bn,ret->data); 420 ret->length=BN_bn2bin(bn,ret->data);
402 return(ret); 421 return(ret);
403err: 422err:
404 if (ret != ai) ASN1_INTEGER_free(ret); 423 if (ret != ai) M_ASN1_INTEGER_free(ret);
405 return(NULL); 424 return(NULL);
406 } 425 }
407 426
diff --git a/src/lib/libssl/src/crypto/asn1/a_mbstr.c b/src/lib/libssl/src/crypto/asn1/a_mbstr.c
new file mode 100644
index 0000000000..7a710d5459
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/a_mbstr.c
@@ -0,0 +1,390 @@
1/* a_mbstr.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 <ctype.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63
64static int traverse_string(const unsigned char *p, int len, int inform,
65 int (*rfunc)(unsigned long value, void *in), void *arg);
66static int in_utf8(unsigned long value, void *arg);
67static int out_utf8(unsigned long value, void *arg);
68static int type_str(unsigned long value, void *arg);
69static int cpy_asc(unsigned long value, void *arg);
70static int cpy_bmp(unsigned long value, void *arg);
71static int cpy_univ(unsigned long value, void *arg);
72static int cpy_utf8(unsigned long value, void *arg);
73static int is_printable(unsigned long value);
74
75/* These functions take a string in UTF8, ASCII or multibyte form and
76 * a mask of permissible ASN1 string types. It then works out the minimal
77 * type (using the order Printable < IA5 < T61 < BMP < Universal < UTF8)
78 * and creates a string of the correct type with the supplied data.
79 * Yes this is horrible: it has to be :-(
80 * The 'ncopy' form checks minimum and maximum size limits too.
81 */
82
83int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
84 int inform, unsigned long mask)
85{
86 return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
87}
88
89int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
90 int inform, unsigned long mask,
91 long minsize, long maxsize)
92{
93 int str_type;
94 int ret;
95 int outform, outlen;
96 ASN1_STRING *dest;
97 unsigned char *p;
98 int nchar;
99 char strbuf[32];
100 int (*cpyfunc)(unsigned long,void *) = NULL;
101 if(len == -1) len = strlen((const char *)in);
102 if(!mask) mask = DIRSTRING_TYPE;
103
104 /* First do a string check and work out the number of characters */
105 switch(inform) {
106
107 case MBSTRING_BMP:
108 if(len & 1) {
109 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
110 ASN1_R_INVALID_BMPSTRING_LENGTH);
111 return -1;
112 }
113 nchar = len >> 1;
114 break;
115
116 case MBSTRING_UNIV:
117 if(len & 3) {
118 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
119 ASN1_R_INVALID_UNIVERSALSTRING_LENGTH);
120 return -1;
121 }
122 nchar = len >> 2;
123 break;
124
125 case MBSTRING_UTF8:
126 nchar = 0;
127 /* This counts the characters and does utf8 syntax checking */
128 ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar);
129 if(ret < 0) {
130 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
131 ASN1_R_INVALID_UTF8STRING);
132 return -1;
133 }
134 break;
135
136 case MBSTRING_ASC:
137 nchar = len;
138 break;
139
140 default:
141 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_UNKNOWN_FORMAT);
142 return -1;
143 }
144
145 if((minsize > 0) && (nchar < minsize)) {
146 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT);
147 sprintf(strbuf, "%ld", minsize);
148 ERR_add_error_data(2, "minsize=", strbuf);
149 return -1;
150 }
151
152 if((maxsize > 0) && (nchar > maxsize)) {
153 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG);
154 sprintf(strbuf, "%ld", maxsize);
155 ERR_add_error_data(2, "maxsize=", strbuf);
156 return -1;
157 }
158
159 /* Now work out minimal type (if any) */
160 if(traverse_string(in, len, inform, type_str, &mask) < 0) {
161 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_ILLEGAL_CHARACTERS);
162 return -1;
163 }
164
165
166 /* Now work out output format and string type */
167 outform = MBSTRING_ASC;
168 if(mask & B_ASN1_PRINTABLESTRING) str_type = V_ASN1_PRINTABLESTRING;
169 else if(mask & B_ASN1_IA5STRING) str_type = V_ASN1_IA5STRING;
170 else if(mask & B_ASN1_T61STRING) str_type = V_ASN1_T61STRING;
171 else if(mask & B_ASN1_BMPSTRING) {
172 str_type = V_ASN1_BMPSTRING;
173 outform = MBSTRING_BMP;
174 } else if(mask & B_ASN1_UNIVERSALSTRING) {
175 str_type = V_ASN1_UNIVERSALSTRING;
176 outform = MBSTRING_UNIV;
177 } else {
178 str_type = V_ASN1_UTF8STRING;
179 outform = MBSTRING_UTF8;
180 }
181 if(!out) return str_type;
182 if(*out) {
183 dest = *out;
184 if(dest->data) {
185 dest->length = 0;
186 Free(dest->data);
187 dest->data = NULL;
188 }
189 dest->type = str_type;
190 } else {
191 dest = ASN1_STRING_type_new(str_type);
192 if(!dest) {
193 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
194 ERR_R_MALLOC_FAILURE);
195 return -1;
196 }
197 *out = dest;
198 }
199 /* If both the same type just copy across */
200 if(inform == outform) {
201 if(!ASN1_STRING_set(dest, in, len)) {
202 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
203 return -1;
204 }
205 return str_type;
206 }
207
208 /* Work out how much space the destination will need */
209 switch(outform) {
210 case MBSTRING_ASC:
211 outlen = nchar;
212 cpyfunc = cpy_asc;
213 break;
214
215 case MBSTRING_BMP:
216 outlen = nchar << 1;
217 cpyfunc = cpy_bmp;
218 break;
219
220 case MBSTRING_UNIV:
221 outlen = nchar << 2;
222 cpyfunc = cpy_univ;
223 break;
224
225 case MBSTRING_UTF8:
226 outlen = 0;
227 traverse_string(in, len, inform, out_utf8, &outlen);
228 cpyfunc = cpy_utf8;
229 break;
230 }
231 if(!(p = Malloc(outlen + 1))) {
232 ASN1_STRING_free(dest);
233 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
234 return -1;
235 }
236 dest->length = outlen;
237 dest->data = p;
238 p[outlen] = 0;
239 traverse_string(in, len, inform, cpyfunc, &p);
240 return str_type;
241}
242
243/* This function traverses a string and passes the value of each character
244 * to an optional function along with a void * argument.
245 */
246
247static int traverse_string(const unsigned char *p, int len, int inform,
248 int (*rfunc)(unsigned long value, void *in), void *arg)
249{
250 unsigned long value;
251 int ret;
252 while(len) {
253 if(inform == MBSTRING_ASC) {
254 value = *p++;
255 len--;
256 } else if(inform == MBSTRING_BMP) {
257 value = *p++ << 8;
258 value |= *p++;
259 len -= 2;
260 } else if(inform == MBSTRING_UNIV) {
261 value = *p++ << 24;
262 value |= *p++ << 16;
263 value |= *p++ << 8;
264 value |= *p++;
265 len -= 4;
266 } else {
267 ret = UTF8_getc(p, len, &value);
268 if(ret < 0) return -1;
269 len -= ret;
270 p += ret;
271 }
272 if(rfunc) {
273 ret = rfunc(value, arg);
274 if(ret <= 0) return ret;
275 }
276 }
277 return 1;
278}
279
280/* Various utility functions for traverse_string */
281
282/* Just count number of characters */
283
284static int in_utf8(unsigned long value, void *arg)
285{
286 int *nchar;
287 nchar = arg;
288 (*nchar)++;
289 return 1;
290}
291
292/* Determine size of output as a UTF8 String */
293
294static int out_utf8(unsigned long value, void *arg)
295{
296 long *outlen;
297 outlen = arg;
298 *outlen += UTF8_putc(NULL, -1, value);
299 return 1;
300}
301
302/* Determine the "type" of a string: check each character against a
303 * supplied "mask".
304 */
305
306static int type_str(unsigned long value, void *arg)
307{
308 unsigned long types;
309 types = *((unsigned long *)arg);
310 if((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
311 types &= ~B_ASN1_PRINTABLESTRING;
312 if((types & B_ASN1_IA5STRING) && (value > 127))
313 types &= ~B_ASN1_IA5STRING;
314 if((types & B_ASN1_T61STRING) && (value > 0xff))
315 types &= ~B_ASN1_T61STRING;
316 if((types & B_ASN1_BMPSTRING) && (value > 0xffff))
317 types &= ~B_ASN1_BMPSTRING;
318 if(!types) return -1;
319 *((unsigned long *)arg) = types;
320 return 1;
321}
322
323/* Copy one byte per character ASCII like strings */
324
325static int cpy_asc(unsigned long value, void *arg)
326{
327 unsigned char **p, *q;
328 p = arg;
329 q = *p;
330 *q = (unsigned char) value;
331 (*p)++;
332 return 1;
333}
334
335/* Copy two byte per character BMPStrings */
336
337static int cpy_bmp(unsigned long value, void *arg)
338{
339 unsigned char **p, *q;
340 p = arg;
341 q = *p;
342 *q++ = (unsigned char) ((value >> 8) & 0xff);
343 *q = (unsigned char) (value & 0xff);
344 *p += 2;
345 return 1;
346}
347
348/* Copy four byte per character UniversalStrings */
349
350static int cpy_univ(unsigned long value, void *arg)
351{
352 unsigned char **p, *q;
353 p = arg;
354 q = *p;
355 *q++ = (unsigned char) ((value >> 24) & 0xff);
356 *q++ = (unsigned char) ((value >> 16) & 0xff);
357 *q++ = (unsigned char) ((value >> 8) & 0xff);
358 *q = (unsigned char) (value & 0xff);
359 *p += 4;
360 return 1;
361}
362
363/* Copy to a UTF8String */
364
365static int cpy_utf8(unsigned long value, void *arg)
366{
367 unsigned char **p;
368 int ret;
369 p = arg;
370 /* We already know there is enough room so pass 0xff as the length */
371 ret = UTF8_putc(*p, 0xff, value);
372 *p += ret;
373 return 1;
374}
375
376/* Return 1 if the character is permitted in a PrintableString */
377static int is_printable(unsigned long value)
378{
379 int ch;
380 if(value > 0x7f) return 0;
381 ch = (int) value;
382 /* Note: we can't use 'isalnum' because certain accented
383 * characters may count as alphanumeric in some environments.
384 */
385 if((ch >= 'a') && (ch <= 'z')) return 1;
386 if((ch >= 'A') && (ch <= 'Z')) return 1;
387 if((ch >= '0') && (ch <= '9')) return 1;
388 if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1;
389 return 0;
390}
diff --git a/src/lib/libssl/src/crypto/asn1/a_null.c b/src/lib/libssl/src/crypto/asn1/a_null.c
new file mode 100644
index 0000000000..119fd784be
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/a_null.c
@@ -0,0 +1,119 @@
1/* a_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1.h>
62
63/* ASN1 functions for NULL type. For compatibility with other ASN1 code
64 * it returns a pointer to an "ASN1_NULL" structure. The new/free functions
65 * don't need to do any allocating because nothing is stored in a NULL.
66 */
67
68int i2d_ASN1_NULL(ASN1_NULL *a, unsigned char **pp)
69 {
70 if(!a) return 0;
71 if (pp) ASN1_put_object(pp,0,0,V_ASN1_NULL,V_ASN1_UNIVERSAL);
72 return 2;
73 }
74
75ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp, long length)
76 {
77 ASN1_NULL *ret = NULL;
78 unsigned char *p;
79 long len;
80 int inf,tag,xclass;
81 int i=0;
82
83 p= *pp;
84 inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
85 if (inf & 0x80)
86 {
87 i=ASN1_R_BAD_OBJECT_HEADER;
88 goto err;
89 }
90
91 if (tag != V_ASN1_NULL)
92 {
93 i=ASN1_R_EXPECTING_A_NULL;
94 goto err;
95 }
96
97 if (len != 0)
98 {
99 i=ASN1_R_NULL_IS_WRONG_LENGTH;
100 goto err;
101 }
102 ret=(ASN1_NULL *)1;
103 if (a != NULL) (*a)=ret;
104 *pp=p;
105 return(ret);
106err:
107 ASN1err(ASN1_F_D2I_ASN1_NULL,i);
108 return(ret);
109 }
110
111ASN1_NULL *ASN1_NULL_new(void)
112{
113 return (ASN1_NULL *)1;
114}
115
116void ASN1_NULL_free(ASN1_NULL *a)
117{
118 return;
119}
diff --git a/src/lib/libssl/src/crypto/asn1/a_object.c b/src/lib/libssl/src/crypto/asn1/a_object.c
index b94b418ee8..09d56fb669 100644
--- a/src/lib/libssl/src/crypto/asn1/a_object.c
+++ b/src/lib/libssl/src/crypto/asn1/a_object.c
@@ -222,8 +222,8 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
222 } 222 }
223 if ((ret->data == NULL) || (ret->length < len)) 223 if ((ret->data == NULL) || (ret->length < len))
224 { 224 {
225 if (ret->data != NULL) Free((char *)ret->data); 225 if (ret->data != NULL) Free(ret->data);
226 ret->data=(unsigned char *)Malloc((int)len); 226 ret->data=(unsigned char *)Malloc(len ? (int)len : 1);
227 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; 227 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
228 if (ret->data == NULL) 228 if (ret->data == NULL)
229 { i=ERR_R_MALLOC_FAILURE; goto err; } 229 { i=ERR_R_MALLOC_FAILURE; goto err; }
@@ -269,7 +269,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
269 if (a == NULL) return; 269 if (a == NULL) return;
270 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) 270 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS)
271 { 271 {
272#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause mempory leaks */ 272#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause memory leaks */
273 if (a->sn != NULL) Free((void *)a->sn); 273 if (a->sn != NULL) Free((void *)a->sn);
274 if (a->ln != NULL) Free((void *)a->ln); 274 if (a->ln != NULL) Free((void *)a->ln);
275#endif 275#endif
diff --git a/src/lib/libssl/src/crypto/asn1/a_octet.c b/src/lib/libssl/src/crypto/asn1/a_octet.c
index 7659a13bd3..2586f4327d 100644
--- a/src/lib/libssl/src/crypto/asn1/a_octet.c
+++ b/src/lib/libssl/src/crypto/asn1/a_octet.c
@@ -60,11 +60,23 @@
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)
70{ return M_ASN1_OCTET_STRING_dup(x); }
71
72int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b)
73{ return M_ASN1_OCTET_STRING_cmp(a, b); }
74
75int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, unsigned char *d, int len)
76{ return M_ASN1_OCTET_STRING_set(x, d, len); }
77
63int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp) 78int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp)
64 { 79{ return M_i2d_ASN1_OCTET_STRING(a, pp); }
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
66 V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL));
67 }
68 80
69ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, 81ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
70 unsigned char **pp, long length) 82 unsigned char **pp, long length)
diff --git a/src/lib/libssl/src/crypto/asn1/a_print.c b/src/lib/libssl/src/crypto/asn1/a_print.c
index cdec7a1561..b7bd2bd18a 100644
--- a/src/lib/libssl/src/crypto/asn1/a_print.c
+++ b/src/lib/libssl/src/crypto/asn1/a_print.c
@@ -60,6 +60,12 @@
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
63int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp) 69int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp)
64 { return(M_i2d_ASN1_IA5STRING(a,pp)); } 70 { return(M_i2d_ASN1_IA5STRING(a,pp)); }
65 71
@@ -67,15 +73,30 @@ ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, unsigned char **pp,
67 long l) 73 long l)
68 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); } 74 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); }
69 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
70ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp, 82ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp,
71 long l) 83 long l)
72 { return(M_d2i_ASN1_T61STRING(a,pp,l)); } 84 { return(M_d2i_ASN1_T61STRING(a,pp,l)); }
73 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
74ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, 92ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
75 unsigned char **pp, long l) 93 unsigned char **pp, long l)
76 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp, 94 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp,
77 l)); } 95 l)); }
78 96
97int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp)
98 { return(M_i2d_ASN1_PRINTABLESTRING(a,pp)); }
99
79int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp) 100int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp)
80 { return(M_i2d_ASN1_PRINTABLE(a,pp)); } 101 { return(M_i2d_ASN1_PRINTABLE(a,pp)); }
81 102
@@ -149,6 +170,11 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
149 return(1); 170 return(1);
150 } 171 }
151 172
173ASN1_STRING *DIRECTORYSTRING_new(void)
174{ return M_DIRECTORYSTRING_new();}
175
176void DIRECTORYSTRING_free(ASN1_STRING *x)
177{ M_DIRECTORYSTRING_free(x);}
152 178
153int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp) 179int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp)
154 { return(M_i2d_DIRECTORYSTRING(a,pp)); } 180 { return(M_i2d_DIRECTORYSTRING(a,pp)); }
@@ -157,6 +183,12 @@ ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
157 long l) 183 long l)
158 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); } 184 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); }
159 185
186ASN1_STRING *DISPLAYTEXT_new(void)
187{ return M_DISPLAYTEXT_new();}
188
189void DISPLAYTEXT_free(ASN1_STRING *x)
190{ M_DISPLAYTEXT_free(x);}
191
160int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp) 192int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp)
161 { return(M_i2d_DISPLAYTEXT(a,pp)); } 193 { return(M_i2d_DISPLAYTEXT(a,pp)); }
162 194
diff --git a/src/lib/libssl/src/crypto/asn1/a_sign.c b/src/lib/libssl/src/crypto/asn1/a_sign.c
index 57595692e5..cfb4bca4f1 100644
--- a/src/lib/libssl/src/crypto/asn1/a_sign.c
+++ b/src/lib/libssl/src/crypto/asn1/a_sign.c
@@ -58,10 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/bn.h> 68#include <openssl/bn.h>
66#include <openssl/evp.h> 69#include <openssl/evp.h>
67#include <openssl/x509.h> 70#include <openssl/x509.h>
@@ -126,11 +129,11 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
126 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB); 129 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB);
127 goto err; 130 goto err;
128 } 131 }
129 if (signature->data != NULL) Free((char *)signature->data); 132 if (signature->data != NULL) Free(signature->data);
130 signature->data=buf_out; 133 signature->data=buf_out;
131 buf_out=NULL; 134 buf_out=NULL;
132 signature->length=outl; 135 signature->length=outl;
133 /* In the interests of compatability, I'll make sure that 136 /* In the interests of compatibility, I'll make sure that
134 * the bit string has a 'not-used bits' value of 0 137 * the bit string has a 'not-used bits' value of 0
135 */ 138 */
136 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 139 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
@@ -138,8 +141,8 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
138err: 141err:
139 memset(&ctx,0,sizeof(ctx)); 142 memset(&ctx,0,sizeof(ctx));
140 if (buf_in != NULL) 143 if (buf_in != NULL)
141 { memset((char *)buf_in,0,(unsigned int)inl); Free((char *)buf_in); } 144 { memset((char *)buf_in,0,(unsigned int)inl); Free(buf_in); }
142 if (buf_out != NULL) 145 if (buf_out != NULL)
143 { memset((char *)buf_out,0,outll); Free((char *)buf_out); } 146 { memset((char *)buf_out,0,outll); Free(buf_out); }
144 return(outl); 147 return(outl);
145 } 148 }
diff --git a/src/lib/libssl/src/crypto/asn1/a_strnid.c b/src/lib/libssl/src/crypto/asn1/a_strnid.c
new file mode 100644
index 0000000000..ab8417ffab
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/a_strnid.c
@@ -0,0 +1,247 @@
1/* a_strnid.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 <ctype.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63#include <openssl/objects.h>
64
65
66static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
67static void st_free(ASN1_STRING_TABLE *tbl);
68static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b);
69static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b);
70
71
72/* This is the global mask for the mbstring functions: this is use to
73 * mask out certain types (such as BMPString and UTF8String) because
74 * certain software (e.g. Netscape) has problems with them.
75 */
76
77static unsigned long global_mask = 0xFFFFFFFFL;
78
79void ASN1_STRING_set_default_mask(unsigned long mask)
80{
81 global_mask = mask;
82}
83
84unsigned long ASN1_STRING_get_default_mask(void)
85{
86 return global_mask;
87}
88
89/* This function sets the default to various "flavours" of configuration.
90 * based on an ASCII string. Currently this is:
91 * MASK:XXXX : a numerical mask value.
92 * nobmp : Don't use BMPStrings (just Printable, T61).
93 * pkix : PKIX recommendation in RFC2459.
94 * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004).
95 * default: the default value, Printable, T61, BMP.
96 */
97
98int ASN1_STRING_set_default_mask_asc(char *p)
99{
100 unsigned long mask;
101 char *end;
102 if(!strncmp(p, "MASK:", 5)) {
103 if(!p[5]) return 0;
104 mask = strtoul(p + 5, &end, 0);
105 if(*end) return 0;
106 } else if(!strcmp(p, "nombstr"))
107 mask = ~(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING);
108 else if(!strcmp(p, "pkix"))
109 mask = ~B_ASN1_T61STRING;
110 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING;
111 else if(!strcmp(p, "default"))
112 mask = 0xFFFFFFFFL;
113 else return 0;
114 ASN1_STRING_set_default_mask(mask);
115 return 1;
116}
117
118/* The following function generates an ASN1_STRING based on limits in a table.
119 * Frequently the types and length of an ASN1_STRING are restricted by a
120 * corresponding OID. For example certificates and certificate requests.
121 */
122
123ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
124 int inlen, int inform, int nid)
125{
126 ASN1_STRING_TABLE *tbl;
127 ASN1_STRING *str = NULL;
128 unsigned long mask;
129 int ret;
130 if(!out) out = &str;
131 tbl = ASN1_STRING_TABLE_get(nid);
132 if(tbl) {
133 mask = tbl->mask;
134 if(!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask;
135 ret = ASN1_mbstring_ncopy(out, in, inlen, inform, tbl->mask,
136 tbl->minsize, tbl->maxsize);
137 } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask);
138 if(ret <= 0) return NULL;
139 return *out;
140}
141
142/* Now the tables and helper functions for the string table:
143 */
144
145/* size limits: this stuff is taken straight from RFC2459 */
146
147#define ub_name 32768
148#define ub_common_name 64
149#define ub_locality_name 128
150#define ub_state_name 128
151#define ub_organization_name 64
152#define ub_organization_unit_name 64
153#define ub_title 64
154#define ub_email_address 128
155
156/* This table must be kept in NID order */
157
158static ASN1_STRING_TABLE tbl_standard[] = {
159{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
160{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
161{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
162{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
163{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
164{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE, 0},
165{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING, STABLE_NO_MASK},
166{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
167{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
168{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
169{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
170{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
171{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
172{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
173{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}
174};
175
176static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b)
177{
178 return (*a)->nid - (*b)->nid;
179}
180
181static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b)
182{
183 return a->nid - b->nid;
184}
185
186ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
187{
188 int idx;
189 ASN1_STRING_TABLE *ttmp;
190 ASN1_STRING_TABLE fnd;
191 fnd.nid = nid;
192 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd,
193 (char *)tbl_standard,
194 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
195 sizeof(ASN1_STRING_TABLE), (int(*)())table_cmp);
196 if(ttmp) return ttmp;
197 if(!stable) return NULL;
198 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
199 if(idx < 0) return NULL;
200 return sk_ASN1_STRING_TABLE_value(stable, idx);
201}
202
203int ASN1_STRING_TABLE_add(int nid,
204 long minsize, long maxsize, unsigned long mask,
205 unsigned long flags)
206{
207 ASN1_STRING_TABLE *tmp;
208 char new_nid = 0;
209 flags &= ~STABLE_FLAGS_MALLOC;
210 if(!stable) stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
211 if(!stable) {
212 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE);
213 return 0;
214 }
215 if(!(tmp = ASN1_STRING_TABLE_get(nid))) {
216 tmp = Malloc(sizeof(ASN1_STRING_TABLE));
217 if(!tmp) {
218 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD,
219 ERR_R_MALLOC_FAILURE);
220 return 0;
221 }
222 tmp->flags = flags | STABLE_FLAGS_MALLOC;
223 tmp->nid = nid;
224 new_nid = 1;
225 } else tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags;
226 if(minsize != -1) tmp->minsize = minsize;
227 if(maxsize != -1) tmp->maxsize = maxsize;
228 tmp->mask = mask;
229 if(new_nid) sk_ASN1_STRING_TABLE_push(stable, tmp);
230 return 1;
231}
232
233void ASN1_STRING_TABLE_cleanup(void)
234{
235 STACK_OF(ASN1_STRING_TABLE) *tmp;
236 tmp = stable;
237 if(!tmp) return;
238 stable = NULL;
239 sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);
240}
241
242static void st_free(ASN1_STRING_TABLE *tbl)
243{
244 if(tbl->flags & STABLE_FLAGS_MALLOC) Free(tbl);
245}
246
247IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)
diff --git a/src/lib/libssl/src/crypto/asn1/a_time.c b/src/lib/libssl/src/crypto/asn1/a_time.c
index c1690a5694..b193f1c71f 100644
--- a/src/lib/libssl/src/crypto/asn1/a_time.c
+++ b/src/lib/libssl/src/crypto/asn1/a_time.c
@@ -66,6 +66,12 @@
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68 68
69ASN1_TIME *ASN1_TIME_new(void)
70{ return M_ASN1_TIME_new(); }
71
72void ASN1_TIME_free(ASN1_TIME *x)
73{ M_ASN1_TIME_free(x); }
74
69int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp) 75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
70 { 76 {
71#ifdef CHARSET_EBCDIC 77#ifdef CHARSET_EBCDIC
diff --git a/src/lib/libssl/src/crypto/asn1/a_type.c b/src/lib/libssl/src/crypto/asn1/a_type.c
index 3f2ecee5c2..161ef81197 100644
--- a/src/lib/libssl/src/crypto/asn1/a_type.c
+++ b/src/lib/libssl/src/crypto/asn1/a_type.c
@@ -282,7 +282,7 @@ void ASN1_TYPE_free(ASN1_TYPE *a)
282 { 282 {
283 if (a == NULL) return; 283 if (a == NULL) return;
284 ASN1_TYPE_component_free(a); 284 ASN1_TYPE_component_free(a);
285 Free((char *)(char *)a); 285 Free(a);
286 } 286 }
287 287
288int ASN1_TYPE_get(ASN1_TYPE *a) 288int ASN1_TYPE_get(ASN1_TYPE *a)
diff --git a/src/lib/libssl/src/crypto/asn1/a_utctm.c b/src/lib/libssl/src/crypto/asn1/a_utctm.c
index 688199fdd2..07565974e3 100644
--- a/src/lib/libssl/src/crypto/asn1/a_utctm.c
+++ b/src/lib/libssl/src/crypto/asn1/a_utctm.c
@@ -66,6 +66,12 @@
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68 68
69ASN1_UTCTIME *ASN1_UTCTIME_new(void)
70{ return M_ASN1_UTCTIME_new(); }
71
72void ASN1_UTCTIME_free(ASN1_UTCTIME *x)
73{ M_ASN1_UTCTIME_free(x); }
74
69int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) 75int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
70 { 76 {
71#ifndef CHARSET_EBCDIC 77#ifndef CHARSET_EBCDIC
@@ -109,7 +115,7 @@ ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, unsigned char **pp,
109 return(ret); 115 return(ret);
110err: 116err:
111 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 117 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
112 ASN1_UTCTIME_free(ret); 118 M_ASN1_UTCTIME_free(ret);
113 return(NULL); 119 return(NULL);
114 } 120 }
115 121
@@ -192,7 +198,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
192#endif 198#endif
193 199
194 if (s == NULL) 200 if (s == NULL)
195 s=ASN1_UTCTIME_new(); 201 s=M_ASN1_UTCTIME_new();
196 if (s == NULL) 202 if (s == NULL)
197 return(NULL); 203 return(NULL);
198 204
diff --git a/src/lib/libssl/src/crypto/asn1/a_utf8.c b/src/lib/libssl/src/crypto/asn1/a_utf8.c
index 4a8a92e9e4..b5125af224 100644
--- a/src/lib/libssl/src/crypto/asn1/a_utf8.c
+++ b/src/lib/libssl/src/crypto/asn1/a_utf8.c
@@ -60,6 +60,12 @@
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
63int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp) 69int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
@@ -81,3 +87,152 @@ ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, unsigned char **pp,
81 return(ret); 87 return(ret);
82 } 88 }
83 89
90
91/* UTF8 utilities */
92
93/* This parses a UTF8 string one character at a time. It is passed a pointer
94 * to the string and the length of the string. It sets 'value' to the value of
95 * the current character. It returns the number of characters read or a
96 * negative error code:
97 * -1 = string too short
98 * -2 = illegal character
99 * -3 = subsequent characters not of the form 10xxxxxx
100 * -4 = character encoded incorrectly (not minimal length).
101 */
102
103int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
104{
105 const unsigned char *p;
106 unsigned long value;
107 int ret;
108 if(len <= 0) return 0;
109 p = str;
110
111 /* Check syntax and work out the encoded value (if correct) */
112 if((*p & 0x80) == 0) {
113 value = *p++ & 0x7f;
114 ret = 1;
115 } else if((*p & 0xe0) == 0xc0) {
116 if(len < 2) return -1;
117 if((p[1] & 0xc0) != 0x80) return -3;
118 value = (*p++ & 0x1f) << 6;
119 value |= *p++ & 0x3f;
120 if(value < 0x80) return -4;
121 ret = 2;
122 } else if((*p & 0xf0) == 0xe0) {
123 if(len < 3) return -1;
124 if( ((p[1] & 0xc0) != 0x80)
125 || ((p[2] & 0xc0) != 0x80) ) return -3;
126 value = (*p++ & 0xf) << 12;
127 value |= (*p++ & 0x3f) << 6;
128 value |= *p++ & 0x3f;
129 if(value < 0x800) return -4;
130 ret = 3;
131 } else if((*p & 0xf8) == 0xf0) {
132 if(len < 4) return -1;
133 if( ((p[1] & 0xc0) != 0x80)
134 || ((p[2] & 0xc0) != 0x80)
135 || ((p[3] & 0xc0) != 0x80) ) return -3;
136 value = (*p++ & 0x7) << 18;
137 value |= (*p++ & 0x3f) << 12;
138 value |= (*p++ & 0x3f) << 6;
139 value |= *p++ & 0x3f;
140 if(value < 0x10000) return -4;
141 ret = 4;
142 } else if((*p & 0xfc) == 0xf8) {
143 if(len < 5) return -1;
144 if( ((p[1] & 0xc0) != 0x80)
145 || ((p[2] & 0xc0) != 0x80)
146 || ((p[3] & 0xc0) != 0x80)
147 || ((p[4] & 0xc0) != 0x80) ) return -3;
148 value = (*p++ & 0x3) << 24;
149 value |= (*p++ & 0x3f) << 18;
150 value |= (*p++ & 0x3f) << 12;
151 value |= (*p++ & 0x3f) << 6;
152 value |= *p++ & 0x3f;
153 if(value < 0x200000) return -4;
154 ret = 5;
155 } else if((*p & 0xfe) == 0xfc) {
156 if(len < 6) return -1;
157 if( ((p[1] & 0xc0) != 0x80)
158 || ((p[2] & 0xc0) != 0x80)
159 || ((p[3] & 0xc0) != 0x80)
160 || ((p[4] & 0xc0) != 0x80)
161 || ((p[5] & 0xc0) != 0x80) ) return -3;
162 value = (*p++ & 0x1) << 30;
163 value |= (*p++ & 0x3f) << 24;
164 value |= (*p++ & 0x3f) << 18;
165 value |= (*p++ & 0x3f) << 12;
166 value |= (*p++ & 0x3f) << 6;
167 value |= *p++ & 0x3f;
168 if(value < 0x4000000) return -4;
169 ret = 6;
170 } else return -2;
171 *val = value;
172 return ret;
173}
174
175/* This takes a character 'value' and writes the UTF8 encoded value in
176 * 'str' where 'str' is a buffer containing 'len' characters. Returns
177 * the number of characters written or -1 if 'len' is too small. 'str' can
178 * be set to NULL in which case it just returns the number of characters.
179 * It will need at most 6 characters.
180 */
181
182int UTF8_putc(unsigned char *str, int len, unsigned long value)
183{
184 if(!str) len = 6; /* Maximum we will need */
185 else if(len <= 0) return -1;
186 if(value < 0x80) {
187 if(str) *str = (unsigned char)value;
188 return 1;
189 }
190 if(value < 0x800) {
191 if(len < 2) return -1;
192 if(str) {
193 *str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
194 *str = (unsigned char)((value & 0x3f) | 0x80);
195 }
196 return 2;
197 }
198 if(value < 0x10000) {
199 if(len < 3) return -1;
200 if(str) {
201 *str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
202 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
203 *str = (unsigned char)((value & 0x3f) | 0x80);
204 }
205 return 3;
206 }
207 if(value < 0x200000) {
208 if(len < 4) return -1;
209 if(str) {
210 *str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
211 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
212 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
213 *str = (unsigned char)((value & 0x3f) | 0x80);
214 }
215 return 4;
216 }
217 if(value < 0x4000000) {
218 if(len < 5) return -1;
219 if(str) {
220 *str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
221 *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
222 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
223 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
224 *str = (unsigned char)((value & 0x3f) | 0x80);
225 }
226 return 5;
227 }
228 if(len < 6) return -1;
229 if(str) {
230 *str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
231 *str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
232 *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
233 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
234 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
235 *str = (unsigned char)((value & 0x3f) | 0x80);
236 }
237 return 6;
238}
diff --git a/src/lib/libssl/src/crypto/asn1/a_verify.c b/src/lib/libssl/src/crypto/asn1/a_verify.c
index 6383d2c698..d4aede85c3 100644
--- a/src/lib/libssl/src/crypto/asn1/a_verify.c
+++ b/src/lib/libssl/src/crypto/asn1/a_verify.c
@@ -58,10 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/bn.h> 68#include <openssl/bn.h>
66#include <openssl/x509.h> 69#include <openssl/x509.h>
67#include <openssl/objects.h> 70#include <openssl/objects.h>
@@ -98,7 +101,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
98 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 101 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
99 102
100 memset(buf_in,0,(unsigned int)inl); 103 memset(buf_in,0,(unsigned int)inl);
101 Free((char *)buf_in); 104 Free(buf_in);
102 105
103 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 106 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
104 (unsigned int)signature->length,pkey) <= 0) 107 (unsigned int)signature->length,pkey) <= 0)
diff --git a/src/lib/libssl/src/crypto/asn1/a_vis.c b/src/lib/libssl/src/crypto/asn1/a_vis.c
index 2072be780d..5cfc080bec 100644
--- a/src/lib/libssl/src/crypto/asn1/a_vis.c
+++ b/src/lib/libssl/src/crypto/asn1/a_vis.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_VISIBLESTRING *ASN1_VISIBLESTRING_new(void)
64{ return M_ASN1_VISIBLESTRING_new(); }
65
66void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *x)
67{ M_ASN1_VISIBLESTRING_free(x); }
68
63int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **pp) 69int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
diff --git a/src/lib/libssl/src/crypto/asn1/asn1.h b/src/lib/libssl/src/crypto/asn1/asn1.h
index 5c2d8999bc..99bd64a11e 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1.h
+++ b/src/lib/libssl/src/crypto/asn1/asn1.h
@@ -68,6 +68,10 @@ extern "C" {
68#include <openssl/stack.h> 68#include <openssl/stack.h>
69#include <openssl/safestack.h> 69#include <openssl/safestack.h>
70 70
71#ifdef VMS
72#include <openssl/vms_idhacks.h>
73#endif
74
71#define V_ASN1_UNIVERSAL 0x00 75#define V_ASN1_UNIVERSAL 0x00
72#define V_ASN1_APPLICATION 0x40 76#define V_ASN1_APPLICATION 0x40
73#define V_ASN1_CONTEXT_SPECIFIC 0x80 77#define V_ASN1_CONTEXT_SPECIFIC 0x80
@@ -77,7 +81,7 @@ extern "C" {
77#define V_ASN1_PRIMITIVE_TAG 0x1f 81#define V_ASN1_PRIMITIVE_TAG 0x1f
78#define V_ASN1_PRIMATIVE_TAG 0x1f 82#define V_ASN1_PRIMATIVE_TAG 0x1f
79 83
80#define V_ASN1_APP_CHOOSE -2 /* let the recipent choose */ 84#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
81 85
82#define V_ASN1_UNDEF -1 86#define V_ASN1_UNDEF -1
83#define V_ASN1_EOC 0 87#define V_ASN1_EOC 0
@@ -129,6 +133,13 @@ extern "C" {
129#define B_ASN1_UNKNOWN 0x1000 133#define B_ASN1_UNKNOWN 0x1000
130#define B_ASN1_UTF8STRING 0x2000 134#define B_ASN1_UTF8STRING 0x2000
131 135
136/* For use with ASN1_mbstring_copy() */
137#define MBSTRING_FLAG 0x1000
138#define MBSTRING_ASC (MBSTRING_FLAG|1)
139#define MBSTRING_BMP (MBSTRING_FLAG|2)
140#define MBSTRING_UNIV (MBSTRING_FLAG|3)
141#define MBSTRING_UTF8 (MBSTRING_FLAG|4)
142
132#define DECLARE_ASN1_SET_OF(type) \ 143#define DECLARE_ASN1_SET_OF(type) \
133int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \ 144int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
134 int (*func)(type *,unsigned char **), int ex_tag, \ 145 int (*func)(type *,unsigned char **), int ex_tag, \
@@ -165,7 +176,7 @@ typedef struct asn1_ctx_st
165 int tag; /* tag from last 'get object' */ 176 int tag; /* tag from last 'get object' */
166 int xclass; /* class from last 'get object' */ 177 int xclass; /* class from last 'get object' */
167 long slen; /* length of last 'get object' */ 178 long slen; /* length of last 'get object' */
168 unsigned char *max; /* largest value of p alowed */ 179 unsigned char *max; /* largest value of p allowed */
169 unsigned char *q;/* temporary variable */ 180 unsigned char *q;/* temporary variable */
170 unsigned char **pp;/* variable */ 181 unsigned char **pp;/* variable */
171 int line; /* used in error processing */ 182 int line; /* used in error processing */
@@ -200,7 +211,34 @@ typedef struct asn1_string_st
200 long flags; 211 long flags;
201 } ASN1_STRING; 212 } ASN1_STRING;
202 213
203#ifndef DEBUG 214#define STABLE_FLAGS_MALLOC 0x01
215#define STABLE_NO_MASK 0x02
216#define DIRSTRING_TYPE \
217 (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
218#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
219
220typedef struct asn1_string_table_st {
221 int nid;
222 long minsize;
223 long maxsize;
224 unsigned long mask;
225 unsigned long flags;
226} ASN1_STRING_TABLE;
227
228DECLARE_STACK_OF(ASN1_STRING_TABLE)
229
230/* size limits: this stuff is taken straight from RFC2459 */
231
232#define ub_name 32768
233#define ub_common_name 64
234#define ub_locality_name 128
235#define ub_state_name 128
236#define ub_organization_name 64
237#define ub_organization_unit_name 64
238#define ub_title 64
239#define ub_email_address 128
240
241#ifdef NO_ASN1_TYPEDEFS
204#define ASN1_INTEGER ASN1_STRING 242#define ASN1_INTEGER ASN1_STRING
205#define ASN1_ENUMERATED ASN1_STRING 243#define ASN1_ENUMERATED ASN1_STRING
206#define ASN1_BIT_STRING ASN1_STRING 244#define ASN1_BIT_STRING ASN1_STRING
@@ -234,6 +272,8 @@ typedef struct asn1_string_st ASN1_VISIBLESTRING;
234typedef struct asn1_string_st ASN1_UTF8STRING; 272typedef struct asn1_string_st ASN1_UTF8STRING;
235#endif 273#endif
236 274
275typedef int ASN1_NULL;
276
237typedef struct asn1_type_st 277typedef struct asn1_type_st
238 { 278 {
239 int type; 279 int type;
@@ -281,60 +321,58 @@ typedef struct asn1_header_st
281 ASN1_METHOD *meth; 321 ASN1_METHOD *meth;
282 } ASN1_HEADER; 322 } ASN1_HEADER;
283 323
284#define ASN1_STRING_length(x) ((x)->length) 324/* This is used to contain a list of bit names */
285#define ASN1_STRING_type(x) ((x)->type) 325typedef struct BIT_STRING_BITNAME_st {
286#define ASN1_STRING_data(x) ((x)->data) 326 int bitnum;
327 const char *lname;
328 const char *sname;
329} BIT_STRING_BITNAME;
330
331
332#define M_ASN1_STRING_length(x) ((x)->length)
333#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n))
334#define M_ASN1_STRING_type(x) ((x)->type)
335#define M_ASN1_STRING_data(x) ((x)->data)
287 336
288/* Macros for string operations */ 337/* Macros for string operations */
289#define ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ 338#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\
290 ASN1_STRING_type_new(V_ASN1_BIT_STRING) 339 ASN1_STRING_type_new(V_ASN1_BIT_STRING)
291#define ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 340#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
292#define ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ 341#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
293 ASN1_STRING_dup((ASN1_STRING *)a) 342 ASN1_STRING_dup((ASN1_STRING *)a)
294#define ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ 343#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
295 (ASN1_STRING *)a,(ASN1_STRING *)b) 344 (ASN1_STRING *)a,(ASN1_STRING *)b)
296#define ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 345#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
297/* i2d_ASN1_BIT_STRING() is a function */
298/* d2i_ASN1_BIT_STRING() is a function */
299 346
300#define ASN1_INTEGER_new() (ASN1_INTEGER *)\ 347#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\
301 ASN1_STRING_type_new(V_ASN1_INTEGER) 348 ASN1_STRING_type_new(V_ASN1_INTEGER)
302#define ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) 349#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a)
303#define ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) 350#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)
304#define ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ 351#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\
305 (ASN1_STRING *)a,(ASN1_STRING *)b) 352 (ASN1_STRING *)a,(ASN1_STRING *)b)
306/* ASN1_INTEGER_set() is a function, also see BN_to_ASN1_INTEGER() */
307/* ASN1_INTEGER_get() is a function, also see ASN1_INTEGER_to_BN() */
308/* i2d_ASN1_INTEGER() is a function */
309/* d2i_ASN1_INTEGER() is a function */
310 353
311#define ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ 354#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\
312 ASN1_STRING_type_new(V_ASN1_ENUMERATED) 355 ASN1_STRING_type_new(V_ASN1_ENUMERATED)
313#define ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) 356#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a)
314#define ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) 357#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a)
315#define ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ 358#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\
316 (ASN1_STRING *)a,(ASN1_STRING *)b) 359 (ASN1_STRING *)a,(ASN1_STRING *)b)
317/* ASN1_ENUMERATED_set() is a function, also see BN_to_ASN1_ENUMERATED() */
318/* ASN1_ENUMERATED_get() is a function, also see ASN1_ENUMERATED_to_BN() */
319/* i2d_ASN1_ENUMERATED() is a function */
320/* d2i_ASN1_ENUMERATED() is a function */
321 360
322#define ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ 361#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\
323 ASN1_STRING_type_new(V_ASN1_OCTET_STRING) 362 ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
324#define ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 363#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
325#define ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ 364#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
326 ASN1_STRING_dup((ASN1_STRING *)a) 365 ASN1_STRING_dup((ASN1_STRING *)a)
327#define ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ 366#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
328 (ASN1_STRING *)a,(ASN1_STRING *)b) 367 (ASN1_STRING *)a,(ASN1_STRING *)b)
329#define ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 368#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
330#define ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) 369#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b)
331#define M_i2d_ASN1_OCTET_STRING(a,pp) \ 370#define M_i2d_ASN1_OCTET_STRING(a,pp) \
332 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ 371 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
333 V_ASN1_OCTET_STRING) 372 V_ASN1_UNIVERSAL)
334/* d2i_ASN1_OCTET_STRING() is a function */
335 373
336#define ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) 374#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING)
337#define ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) 375#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)
338#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 376#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
339 pp,a->type,V_ASN1_UNIVERSAL) 377 pp,a->type,V_ASN1_UNIVERSAL)
340#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 378#define M_d2i_ASN1_PRINTABLE(a,pp,l) \
@@ -345,10 +383,11 @@ typedef struct asn1_header_st
345 B_ASN1_BIT_STRING| \ 383 B_ASN1_BIT_STRING| \
346 B_ASN1_UNIVERSALSTRING|\ 384 B_ASN1_UNIVERSALSTRING|\
347 B_ASN1_BMPSTRING|\ 385 B_ASN1_BMPSTRING|\
386 B_ASN1_UTF8STRING|\
348 B_ASN1_UNKNOWN) 387 B_ASN1_UNKNOWN)
349 388
350#define DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 389#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
351#define DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 390#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
352#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 391#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
353 pp,a->type,V_ASN1_UNIVERSAL) 392 pp,a->type,V_ASN1_UNIVERSAL)
354#define M_d2i_DIRECTORYSTRING(a,pp,l) \ 393#define M_d2i_DIRECTORYSTRING(a,pp,l) \
@@ -359,8 +398,8 @@ typedef struct asn1_header_st
359 B_ASN1_UNIVERSALSTRING|\ 398 B_ASN1_UNIVERSALSTRING|\
360 B_ASN1_UTF8STRING) 399 B_ASN1_UTF8STRING)
361 400
362#define DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 401#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
363#define DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) 402#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
364#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 403#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
365 pp,a->type,V_ASN1_UNIVERSAL) 404 pp,a->type,V_ASN1_UNIVERSAL)
366#define M_d2i_DISPLAYTEXT(a,pp,l) \ 405#define M_d2i_DISPLAYTEXT(a,pp,l) \
@@ -369,9 +408,9 @@ typedef struct asn1_header_st
369 B_ASN1_BMPSTRING|\ 408 B_ASN1_BMPSTRING|\
370 B_ASN1_UTF8STRING) 409 B_ASN1_UTF8STRING)
371 410
372#define ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ 411#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
373 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 412 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
374#define ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 413#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
375#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ 414#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
376 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ 415 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
377 V_ASN1_UNIVERSAL) 416 V_ASN1_UNIVERSAL)
@@ -379,9 +418,9 @@ typedef struct asn1_header_st
379 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ 418 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
380 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) 419 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)
381 420
382#define ASN1_T61STRING_new() (ASN1_T61STRING_STRING *)\ 421#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\
383 ASN1_STRING_type_new(V_ASN1_T61STRING) 422 ASN1_STRING_type_new(V_ASN1_T61STRING)
384#define ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 423#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
385#define M_i2d_ASN1_T61STRING(a,pp) \ 424#define M_i2d_ASN1_T61STRING(a,pp) \
386 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ 425 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
387 V_ASN1_UNIVERSAL) 426 V_ASN1_UNIVERSAL)
@@ -389,10 +428,10 @@ typedef struct asn1_header_st
389 (ASN1_T61STRING *)d2i_ASN1_type_bytes\ 428 (ASN1_T61STRING *)d2i_ASN1_type_bytes\
390 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) 429 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)
391 430
392#define ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ 431#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\
393 ASN1_STRING_type_new(V_ASN1_IA5STRING) 432 ASN1_STRING_type_new(V_ASN1_IA5STRING)
394#define ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 433#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
395#define ASN1_IA5STRING_dup(a) \ 434#define M_ASN1_IA5STRING_dup(a) \
396 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) 435 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a)
397#define M_i2d_ASN1_IA5STRING(a,pp) \ 436#define M_i2d_ASN1_IA5STRING(a,pp) \
398 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ 437 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
@@ -401,38 +440,25 @@ typedef struct asn1_header_st
401 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ 440 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
402 B_ASN1_IA5STRING) 441 B_ASN1_IA5STRING)
403 442
404#define ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ 443#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\
405 ASN1_STRING_type_new(V_ASN1_UTCTIME) 444 ASN1_STRING_type_new(V_ASN1_UTCTIME)
406#define ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 445#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
407#define ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) 446#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)
408/* i2d_ASN1_UTCTIME() is a function */ 447
409/* d2i_ASN1_UTCTIME() is a function */ 448#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
410/* ASN1_UTCTIME_set() is a function */
411/* ASN1_UTCTIME_check() is a function */
412
413#define ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
414 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) 449 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
415#define ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 450#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
416#define ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ 451#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
417 (ASN1_STRING *)a) 452 (ASN1_STRING *)a)
418/* i2d_ASN1_GENERALIZEDTIME() is a function */
419/* d2i_ASN1_GENERALIZEDTIME() is a function */
420/* ASN1_GENERALIZEDTIME_set() is a function */
421/* ASN1_GENERALIZEDTIME_check() is a function */
422 453
423#define ASN1_TIME_new() (ASN1_TIME *)\ 454#define M_ASN1_TIME_new() (ASN1_TIME *)\
424 ASN1_STRING_type_new(V_ASN1_UTCTIME) 455 ASN1_STRING_type_new(V_ASN1_UTCTIME)
425#define ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 456#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
426#define ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) 457#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a)
427 458
428/* i2d_ASN1_TIME() is a function */ 459#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
429/* d2i_ASN1_TIME() is a function */
430/* ASN1_TIME_set() is a function */
431/* ASN1_TIME_check() is a function */
432
433#define ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
434 ASN1_STRING_type_new(V_ASN1_GENERALSTRING) 460 ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
435#define ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 461#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
436#define M_i2d_ASN1_GENERALSTRING(a,pp) \ 462#define M_i2d_ASN1_GENERALSTRING(a,pp) \
437 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ 463 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
438 V_ASN1_UNIVERSAL) 464 V_ASN1_UNIVERSAL)
@@ -440,9 +466,9 @@ typedef struct asn1_header_st
440 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ 466 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
441 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) 467 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)
442 468
443#define ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ 469#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\
444 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) 470 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
445#define ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 471#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
446#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ 472#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
447 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ 473 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
448 V_ASN1_UNIVERSAL) 474 V_ASN1_UNIVERSAL)
@@ -450,9 +476,9 @@ typedef struct asn1_header_st
450 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ 476 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
451 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) 477 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)
452 478
453#define ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ 479#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\
454 ASN1_STRING_type_new(V_ASN1_BMPSTRING) 480 ASN1_STRING_type_new(V_ASN1_BMPSTRING)
455#define ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 481#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
456#define M_i2d_ASN1_BMPSTRING(a,pp) \ 482#define M_i2d_ASN1_BMPSTRING(a,pp) \
457 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ 483 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
458 V_ASN1_UNIVERSAL) 484 V_ASN1_UNIVERSAL)
@@ -460,9 +486,9 @@ typedef struct asn1_header_st
460 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ 486 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
461 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) 487 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)
462 488
463#define ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ 489#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\
464 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 490 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
465#define ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 491#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
466#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ 492#define M_i2d_ASN1_VISIBLESTRING(a,pp) \
467 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ 493 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
468 V_ASN1_UNIVERSAL) 494 V_ASN1_UNIVERSAL)
@@ -470,9 +496,9 @@ typedef struct asn1_header_st
470 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ 496 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
471 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) 497 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)
472 498
473#define ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ 499#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\
474 ASN1_STRING_type_new(V_ASN1_UTF8STRING) 500 ASN1_STRING_type_new(V_ASN1_UTF8STRING)
475#define ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 501#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
476#define M_i2d_ASN1_UTF8STRING(a,pp) \ 502#define M_i2d_ASN1_UTF8STRING(a,pp) \
477 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ 503 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
478 V_ASN1_UNIVERSAL) 504 V_ASN1_UNIVERSAL)
@@ -500,7 +526,7 @@ ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
500DECLARE_STACK_OF(ASN1_OBJECT) 526DECLARE_STACK_OF(ASN1_OBJECT)
501DECLARE_ASN1_SET_OF(ASN1_OBJECT) 527DECLARE_ASN1_SET_OF(ASN1_OBJECT)
502 528
503ASN1_STRING * ASN1_STRING_new(void ); 529ASN1_STRING * ASN1_STRING_new(void);
504void ASN1_STRING_free(ASN1_STRING *a); 530void ASN1_STRING_free(ASN1_STRING *a);
505ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); 531ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a);
506ASN1_STRING * ASN1_STRING_type_new(int type ); 532ASN1_STRING * ASN1_STRING_type_new(int type );
@@ -508,23 +534,44 @@ int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
508 /* Since this is used to store all sorts of things, via macros, for now, make 534 /* Since this is used to store all sorts of things, via macros, for now, make
509 its data void * */ 535 its data void * */
510int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); 536int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
537int ASN1_STRING_length(ASN1_STRING *x);
538void ASN1_STRING_length_set(ASN1_STRING *x, int n);
539int ASN1_STRING_type(ASN1_STRING *x);
540unsigned char * ASN1_STRING_data(ASN1_STRING *x);
511 541
542ASN1_BIT_STRING * ASN1_BIT_STRING_new(void);
543void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
512int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); 544int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
513ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp, 545ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
514 long length); 546 long length);
547int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
548 int length );
515int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 549int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
516int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 550int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
517 551
552#ifdef HEADER_BIO_H
553int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
554 BIT_STRING_BITNAME *tbl, int indent);
555#endif
556int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
557int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
558 BIT_STRING_BITNAME *tbl);
518 559
519int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); 560int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
520int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length); 561int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
521 562
563ASN1_INTEGER * ASN1_INTEGER_new(void);
564void ASN1_INTEGER_free(ASN1_INTEGER *a);
522int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); 565int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
523ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp, 566ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
524 long length); 567 long length);
525ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp, 568ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
526 long length); 569 long length);
570ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
571int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
527 572
573ASN1_ENUMERATED * ASN1_ENUMERATED_new(void);
574void ASN1_ENUMERATED_free(ASN1_ENUMERATED *a);
528int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp); 575int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp);
529ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp, 576ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
530 long length); 577 long length);
@@ -537,49 +584,88 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
537ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); 584ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
538int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str); 585int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str);
539 586
587ASN1_OCTET_STRING * ASN1_OCTET_STRING_new(void);
588void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);
540int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp); 589int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp);
541ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, 590ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
542 unsigned char **pp,long length); 591 unsigned char **pp,long length);
592ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
593int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
594int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, unsigned char *data, int len);
543 595
596ASN1_VISIBLESTRING * ASN1_VISIBLESTRING_new(void);
597void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *a);
544int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp); 598int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp);
545ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a, 599ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a,
546 unsigned char **pp,long length); 600 unsigned char **pp,long length);
547 601
602ASN1_UTF8STRING * ASN1_UTF8STRING_new(void);
603void ASN1_UTF8STRING_free(ASN1_UTF8STRING *a);
548int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp); 604int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp);
549ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, 605ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a,
550 unsigned char **pp,long length); 606 unsigned char **pp,long length);
551 607
608ASN1_NULL * ASN1_NULL_new(void);
609void ASN1_NULL_free(ASN1_NULL *a);
610int i2d_ASN1_NULL(ASN1_NULL *a,unsigned char **pp);
611ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp,long length);
612
613ASN1_BMPSTRING * ASN1_BMPSTRING_new(void);
614void ASN1_BMPSTRING_free(ASN1_BMPSTRING *a);
552int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp); 615int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp);
553ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp, 616ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp,
554 long length); 617 long length);
555 618
619
620int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
621int UTF8_putc(unsigned char *str, int len, unsigned long value);
622
556int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp); 623int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp);
557ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a, 624ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a,
558 unsigned char **pp, long l); 625 unsigned char **pp, long l);
626
627ASN1_PRINTABLESTRING * ASN1_PRINTABLESTRING_new(void);
628void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a);
559ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, 629ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
560 unsigned char **pp, long l); 630 unsigned char **pp, long l);
631int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp);
561 632
633ASN1_STRING * DIRECTORYSTRING_new(void);
634void DIRECTORYSTRING_free(ASN1_STRING *a);
562int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp); 635int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp);
563ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp, 636ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
564 long length); 637 long length);
565 638
639ASN1_STRING * DISPLAYTEXT_new(void);
640void DISPLAYTEXT_free(ASN1_STRING *a);
566int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp); 641int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp);
567ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length); 642ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length);
568 643
644ASN1_T61STRING * ASN1_T61STRING_new(void);
645void ASN1_T61STRING_free(ASN1_IA5STRING *a);
569ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, 646ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a,
570 unsigned char **pp, long l); 647 unsigned char **pp, long l);
648
649ASN1_IA5STRING * ASN1_IA5STRING_new(void);
650void ASN1_IA5STRING_free(ASN1_IA5STRING *a);
571int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp); 651int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp);
572ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, 652ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a,
573 unsigned char **pp, long l); 653 unsigned char **pp, long l);
574 654
655ASN1_UTCTIME * ASN1_UTCTIME_new(void);
656void ASN1_UTCTIME_free(ASN1_UTCTIME *a);
575int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp); 657int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp);
576ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp, 658ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp,
577 long length); 659 long length);
578 660
661ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_new(void);
662void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *a);
579int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp); 663int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp);
580ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp, 664ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp,
581 long length); 665 long length);
582 666
667ASN1_TIME * ASN1_TIME_new(void);
668void ASN1_TIME_free(ASN1_TIME *a);
583int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp); 669int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp);
584ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length); 670ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length);
585ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); 671ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
@@ -654,6 +740,7 @@ int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
654int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); 740int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
655int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent); 741int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent);
656#endif 742#endif
743const char *ASN1_tag2str(int tag);
657 744
658/* Used to load and write netscape format cert/key */ 745/* Used to load and write netscape format cert/key */
659int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); 746int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
@@ -687,6 +774,21 @@ unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
687void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)()); 774void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
688ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct); 775ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
689 776
777void ASN1_STRING_set_default_mask(unsigned long mask);
778int ASN1_STRING_set_default_mask_asc(char *p);
779unsigned long ASN1_STRING_get_default_mask(void);
780int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
781 int inform, unsigned long mask);
782int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
783 int inform, unsigned long mask,
784 long minsize, long maxsize);
785
786ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
787 const unsigned char *in, int inlen, int inform, int nid);
788ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
789int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
790void ASN1_STRING_TABLE_cleanup(void);
791
690/* BEGIN ERROR CODES */ 792/* BEGIN ERROR CODES */
691/* The following lines are auto generated by the script mkerr.pl. Any changes 793/* The following lines are auto generated by the script mkerr.pl. Any changes
692 * made after this point may be overwritten when the script is next run. 794 * made after this point may be overwritten when the script is next run.
@@ -699,6 +801,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
699#define ASN1_F_A2I_ASN1_ENUMERATED 236 801#define ASN1_F_A2I_ASN1_ENUMERATED 236
700#define ASN1_F_A2I_ASN1_INTEGER 101 802#define ASN1_F_A2I_ASN1_INTEGER 101
701#define ASN1_F_A2I_ASN1_STRING 102 803#define ASN1_F_A2I_ASN1_STRING 102
804#define ASN1_F_ACCESS_DESCRIPTION_NEW 291
702#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103 805#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103
703#define ASN1_F_ASN1_D2I_BIO 104 806#define ASN1_F_ASN1_D2I_BIO 104
704#define ASN1_F_ASN1_D2I_FP 105 807#define ASN1_F_ASN1_D2I_FP 105
@@ -712,6 +815,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
712#define ASN1_F_ASN1_I2D_FP 110 815#define ASN1_F_ASN1_I2D_FP 110
713#define ASN1_F_ASN1_INTEGER_SET 111 816#define ASN1_F_ASN1_INTEGER_SET 111
714#define ASN1_F_ASN1_INTEGER_TO_BN 112 817#define ASN1_F_ASN1_INTEGER_TO_BN 112
818#define ASN1_F_ASN1_MBSTRING_COPY 282
715#define ASN1_F_ASN1_OBJECT_NEW 113 819#define ASN1_F_ASN1_OBJECT_NEW 113
716#define ASN1_F_ASN1_PACK_STRING 245 820#define ASN1_F_ASN1_PACK_STRING 245
717#define ASN1_F_ASN1_PBE_SET 253 821#define ASN1_F_ASN1_PBE_SET 253
@@ -719,6 +823,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
719#define ASN1_F_ASN1_SEQ_UNPACK 247 823#define ASN1_F_ASN1_SEQ_UNPACK 247
720#define ASN1_F_ASN1_SIGN 114 824#define ASN1_F_ASN1_SIGN 114
721#define ASN1_F_ASN1_STRING_NEW 115 825#define ASN1_F_ASN1_STRING_NEW 115
826#define ASN1_F_ASN1_STRING_TABLE_ADD 283
722#define ASN1_F_ASN1_STRING_TYPE_NEW 116 827#define ASN1_F_ASN1_STRING_TYPE_NEW 116
723#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117 828#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117
724#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118 829#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118
@@ -730,6 +835,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
730#define ASN1_F_BASIC_CONSTRAINTS_NEW 226 835#define ASN1_F_BASIC_CONSTRAINTS_NEW 226
731#define ASN1_F_BN_TO_ASN1_ENUMERATED 234 836#define ASN1_F_BN_TO_ASN1_ENUMERATED 234
732#define ASN1_F_BN_TO_ASN1_INTEGER 122 837#define ASN1_F_BN_TO_ASN1_INTEGER 122
838#define ASN1_F_D2I_ACCESS_DESCRIPTION 284
733#define ASN1_F_D2I_ASN1_BIT_STRING 123 839#define ASN1_F_D2I_ASN1_BIT_STRING 123
734#define ASN1_F_D2I_ASN1_BMPSTRING 124 840#define ASN1_F_D2I_ASN1_BMPSTRING 124
735#define ASN1_F_D2I_ASN1_BOOLEAN 125 841#define ASN1_F_D2I_ASN1_BOOLEAN 125
@@ -738,6 +844,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
738#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223 844#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223
739#define ASN1_F_D2I_ASN1_HEADER 127 845#define ASN1_F_D2I_ASN1_HEADER 127
740#define ASN1_F_D2I_ASN1_INTEGER 128 846#define ASN1_F_D2I_ASN1_INTEGER 128
847#define ASN1_F_D2I_ASN1_NULL 292
741#define ASN1_F_D2I_ASN1_OBJECT 129 848#define ASN1_F_D2I_ASN1_OBJECT 129
742#define ASN1_F_D2I_ASN1_OCTET_STRING 130 849#define ASN1_F_D2I_ASN1_OCTET_STRING 130
743#define ASN1_F_D2I_ASN1_PRINT_TYPE 131 850#define ASN1_F_D2I_ASN1_PRINT_TYPE 131
@@ -765,6 +872,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
765#define ASN1_F_D2I_NETSCAPE_SPKAC 143 872#define ASN1_F_D2I_NETSCAPE_SPKAC 143
766#define ASN1_F_D2I_NETSCAPE_SPKI 144 873#define ASN1_F_D2I_NETSCAPE_SPKI 144
767#define ASN1_F_D2I_NOTICEREF 268 874#define ASN1_F_D2I_NOTICEREF 268
875#define ASN1_F_D2I_OTHERNAME 287
768#define ASN1_F_D2I_PBE2PARAM 262 876#define ASN1_F_D2I_PBE2PARAM 262
769#define ASN1_F_D2I_PBEPARAM 249 877#define ASN1_F_D2I_PBEPARAM 249
770#define ASN1_F_D2I_PBKDF2PARAM 263 878#define ASN1_F_D2I_PBKDF2PARAM 263
@@ -796,6 +904,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
796#define ASN1_F_D2I_X509 159 904#define ASN1_F_D2I_X509 159
797#define ASN1_F_D2I_X509_ALGOR 160 905#define ASN1_F_D2I_X509_ALGOR 160
798#define ASN1_F_D2I_X509_ATTRIBUTE 161 906#define ASN1_F_D2I_X509_ATTRIBUTE 161
907#define ASN1_F_D2I_X509_CERT_AUX 285
799#define ASN1_F_D2I_X509_CINF 162 908#define ASN1_F_D2I_X509_CINF 162
800#define ASN1_F_D2I_X509_CRL 163 909#define ASN1_F_D2I_X509_CRL 163
801#define ASN1_F_D2I_X509_CRL_INFO 164 910#define ASN1_F_D2I_X509_CRL_INFO 164
@@ -819,12 +928,14 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
819#define ASN1_F_I2D_DSAPARAMS 178 928#define ASN1_F_I2D_DSAPARAMS 178
820#define ASN1_F_I2D_DSAPRIVATEKEY 179 929#define ASN1_F_I2D_DSAPRIVATEKEY 179
821#define ASN1_F_I2D_DSAPUBLICKEY 180 930#define ASN1_F_I2D_DSAPUBLICKEY 180
931#define ASN1_F_I2D_DSA_PUBKEY 290
822#define ASN1_F_I2D_NETSCAPE_RSA 181 932#define ASN1_F_I2D_NETSCAPE_RSA 181
823#define ASN1_F_I2D_PKCS7 182 933#define ASN1_F_I2D_PKCS7 182
824#define ASN1_F_I2D_PRIVATEKEY 183 934#define ASN1_F_I2D_PRIVATEKEY 183
825#define ASN1_F_I2D_PUBLICKEY 184 935#define ASN1_F_I2D_PUBLICKEY 184
826#define ASN1_F_I2D_RSAPRIVATEKEY 185 936#define ASN1_F_I2D_RSAPRIVATEKEY 185
827#define ASN1_F_I2D_RSAPUBLICKEY 186 937#define ASN1_F_I2D_RSAPUBLICKEY 186
938#define ASN1_F_I2D_RSA_PUBKEY 289
828#define ASN1_F_I2D_X509_ATTRIBUTE 187 939#define ASN1_F_I2D_X509_ATTRIBUTE 187
829#define ASN1_F_I2T_ASN1_OBJECT 188 940#define ASN1_F_I2T_ASN1_OBJECT 188
830#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229 941#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229
@@ -832,6 +943,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
832#define ASN1_F_NETSCAPE_SPKAC_NEW 190 943#define ASN1_F_NETSCAPE_SPKAC_NEW 190
833#define ASN1_F_NETSCAPE_SPKI_NEW 191 944#define ASN1_F_NETSCAPE_SPKI_NEW 191
834#define ASN1_F_NOTICEREF_NEW 272 945#define ASN1_F_NOTICEREF_NEW 272
946#define ASN1_F_OTHERNAME_NEW 288
835#define ASN1_F_PBE2PARAM_NEW 264 947#define ASN1_F_PBE2PARAM_NEW 264
836#define ASN1_F_PBEPARAM_NEW 251 948#define ASN1_F_PBEPARAM_NEW 251
837#define ASN1_F_PBKDF2PARAM_NEW 265 949#define ASN1_F_PBKDF2PARAM_NEW 265
@@ -859,6 +971,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
859#define ASN1_F_USERNOTICE_NEW 275 971#define ASN1_F_USERNOTICE_NEW 275
860#define ASN1_F_X509_ALGOR_NEW 202 972#define ASN1_F_X509_ALGOR_NEW 202
861#define ASN1_F_X509_ATTRIBUTE_NEW 203 973#define ASN1_F_X509_ATTRIBUTE_NEW 203
974#define ASN1_F_X509_CERT_AUX_NEW 286
862#define ASN1_F_X509_CINF_NEW 204 975#define ASN1_F_X509_CINF_NEW 204
863#define ASN1_F_X509_CRL_INFO_NEW 205 976#define ASN1_F_X509_CRL_INFO_NEW 205
864#define ASN1_F_X509_CRL_NEW 206 977#define ASN1_F_X509_CRL_NEW 206
@@ -889,6 +1002,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
889#define ASN1_R_BN_LIB 107 1002#define ASN1_R_BN_LIB 107
890#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108 1003#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108
891#define ASN1_R_BUFFER_TOO_SMALL 109 1004#define ASN1_R_BUFFER_TOO_SMALL 109
1005#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 166
892#define ASN1_R_DATA_IS_WRONG 110 1006#define ASN1_R_DATA_IS_WRONG 110
893#define ASN1_R_DECODE_ERROR 155 1007#define ASN1_R_DECODE_ERROR 155
894#define ASN1_R_DECODING_ERROR 111 1008#define ASN1_R_DECODING_ERROR 111
@@ -902,24 +1016,31 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
902#define ASN1_R_EXPECTING_A_BIT_STRING 116 1016#define ASN1_R_EXPECTING_A_BIT_STRING 116
903#define ASN1_R_EXPECTING_A_BOOLEAN 117 1017#define ASN1_R_EXPECTING_A_BOOLEAN 117
904#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151 1018#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151
1019#define ASN1_R_EXPECTING_A_NULL 164
905#define ASN1_R_EXPECTING_A_TIME 152 1020#define ASN1_R_EXPECTING_A_TIME 152
906#define ASN1_R_EXPECTING_A_UTCTIME 118 1021#define ASN1_R_EXPECTING_A_UTCTIME 118
907#define ASN1_R_FIRST_NUM_TOO_LARGE 119 1022#define ASN1_R_FIRST_NUM_TOO_LARGE 119
908#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153 1023#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153
909#define ASN1_R_HEADER_TOO_LONG 120 1024#define ASN1_R_HEADER_TOO_LONG 120
1025#define ASN1_R_ILLEGAL_CHARACTERS 158
1026#define ASN1_R_INVALID_BMPSTRING_LENGTH 159
910#define ASN1_R_INVALID_DIGIT 121 1027#define ASN1_R_INVALID_DIGIT 121
911#define ASN1_R_INVALID_SEPARATOR 122 1028#define ASN1_R_INVALID_SEPARATOR 122
912#define ASN1_R_INVALID_TIME_FORMAT 123 1029#define ASN1_R_INVALID_TIME_FORMAT 123
1030#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 160
1031#define ASN1_R_INVALID_UTF8STRING 161
913#define ASN1_R_IV_TOO_LARGE 124 1032#define ASN1_R_IV_TOO_LARGE 124
914#define ASN1_R_LENGTH_ERROR 125 1033#define ASN1_R_LENGTH_ERROR 125
915#define ASN1_R_MISSING_SECOND_NUMBER 126 1034#define ASN1_R_MISSING_SECOND_NUMBER 126
916#define ASN1_R_NON_HEX_CHARACTERS 127 1035#define ASN1_R_NON_HEX_CHARACTERS 127
917#define ASN1_R_NOT_ENOUGH_DATA 128 1036#define ASN1_R_NOT_ENOUGH_DATA 128
1037#define ASN1_R_NULL_IS_WRONG_LENGTH 165
918#define ASN1_R_ODD_NUMBER_OF_CHARS 129 1038#define ASN1_R_ODD_NUMBER_OF_CHARS 129
919#define ASN1_R_PARSING 130 1039#define ASN1_R_PARSING 130
920#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131 1040#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131
921#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132 1041#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132
922#define ASN1_R_SHORT_LINE 133 1042#define ASN1_R_SHORT_LINE 133
1043#define ASN1_R_STRING_TOO_LONG 163
923#define ASN1_R_STRING_TOO_SHORT 134 1044#define ASN1_R_STRING_TOO_SHORT 134
924#define ASN1_R_TAG_VALUE_TOO_HIGH 135 1045#define ASN1_R_TAG_VALUE_TOO_HIGH 135
925#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136 1046#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136
@@ -927,6 +1048,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
927#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138 1048#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138
928#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139 1049#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139
929#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140 1050#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140
1051#define ASN1_R_UNKNOWN_FORMAT 162
930#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141 1052#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141
931#define ASN1_R_UNKNOWN_OBJECT_TYPE 142 1053#define ASN1_R_UNKNOWN_OBJECT_TYPE 142
932#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143 1054#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_err.c b/src/lib/libssl/src/crypto/asn1/asn1_err.c
index 16755a0b05..b183814242 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_err.c
+++ b/src/lib/libssl/src/crypto/asn1/asn1_err.c
@@ -69,19 +69,21 @@ static ERR_STRING_DATA ASN1_str_functs[]=
69{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"}, 69{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"},
70{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"}, 70{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"},
71{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"}, 71{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"},
72{ERR_PACK(0,ASN1_F_ACCESS_DESCRIPTION_NEW,0), "ACCESS_DESCRIPTION_new"},
72{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"}, 73{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"},
73{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"}, 74{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"},
74{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"}, 75{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"},
75{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"}, 76{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"},
76{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"}, 77{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"},
77{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"}, 78{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"},
78{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_NEW"}, 79{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_new"},
79{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"}, 80{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"},
80{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"}, 81{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"},
81{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"}, 82{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"},
82{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"}, 83{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"},
83{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"}, 84{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"},
84{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"}, 85{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"},
86{ERR_PACK(0,ASN1_F_ASN1_MBSTRING_COPY,0), "ASN1_mbstring_copy"},
85{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"}, 87{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"},
86{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"}, 88{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"},
87{ERR_PACK(0,ASN1_F_ASN1_PBE_SET,0), "ASN1_PBE_SET"}, 89{ERR_PACK(0,ASN1_F_ASN1_PBE_SET,0), "ASN1_PBE_SET"},
@@ -89,17 +91,19 @@ static ERR_STRING_DATA ASN1_str_functs[]=
89{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"}, 91{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"},
90{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"}, 92{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"},
91{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"}, 93{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"},
94{ERR_PACK(0,ASN1_F_ASN1_STRING_TABLE_ADD,0), "ASN1_STRING_TABLE_add"},
92{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"}, 95{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"},
93{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"}, 96{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"},
94{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"}, 97{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"},
95{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"}, 98{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"},
96{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"}, 99{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"},
97{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_NEW"}, 100{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_new"},
98{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"}, 101{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"},
99{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"}, 102{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"},
100{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"}, 103{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"},
101{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"}, 104{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"},
102{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"}, 105{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"},
106{ERR_PACK(0,ASN1_F_D2I_ACCESS_DESCRIPTION,0), "d2i_ACCESS_DESCRIPTION"},
103{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"}, 107{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"},
104{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"}, 108{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"},
105{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"}, 109{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"},
@@ -108,6 +112,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
108{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"}, 112{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"},
109{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"}, 113{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"},
110{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"}, 114{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"},
115{ERR_PACK(0,ASN1_F_D2I_ASN1_NULL,0), "d2i_ASN1_NULL"},
111{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"},
112{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"}, 117{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"},
113{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"}, 118{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"},
@@ -135,6 +140,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
135{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"}, 140{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"},
136{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"}, 141{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"},
137{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"}, 142{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"},
143{ERR_PACK(0,ASN1_F_D2I_OTHERNAME,0), "d2i_OTHERNAME"},
138{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"}, 144{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"},
139{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"}, 145{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"},
140{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"}, 146{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"},
@@ -166,6 +172,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
166{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"}, 172{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"},
167{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"}, 173{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"},
168{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"}, 174{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"},
175{ERR_PACK(0,ASN1_F_D2I_X509_CERT_AUX,0), "d2i_X509_CERT_AUX"},
169{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"}, 176{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"},
170{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"}, 177{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"},
171{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"}, 178{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"},
@@ -189,12 +196,14 @@ static ERR_STRING_DATA ASN1_str_functs[]=
189{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"}, 196{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"},
190{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"}, 197{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"},
191{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"}, 198{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"},
199{ERR_PACK(0,ASN1_F_I2D_DSA_PUBKEY,0), "i2d_DSA_PUBKEY"},
192{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"}, 200{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"},
193{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"}, 201{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"},
194{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"}, 202{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"},
195{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"}, 203{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"},
196{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"}, 204{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"},
197{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"}, 205{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"},
206{ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0), "i2d_RSA_PUBKEY"},
198{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"}, 207{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"},
199{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"}, 208{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"},
200{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"}, 209{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"},
@@ -202,6 +211,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
202{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"}, 211{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"},
203{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"}, 212{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"},
204{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"}, 213{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"},
214{ERR_PACK(0,ASN1_F_OTHERNAME_NEW,0), "OTHERNAME_new"},
205{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"}, 215{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"},
206{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"}, 216{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"},
207{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"}, 217{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"},
@@ -229,6 +239,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
229{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"}, 239{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"},
230{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"}, 240{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"},
231{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"}, 241{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"},
242{ERR_PACK(0,ASN1_F_X509_CERT_AUX_NEW,0), "X509_CERT_AUX_new"},
232{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"}, 243{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"},
233{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"}, 244{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"},
234{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"}, 245{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"},
@@ -262,6 +273,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
262{ASN1_R_BN_LIB ,"bn lib"}, 273{ASN1_R_BN_LIB ,"bn lib"},
263{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"}, 274{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"},
264{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"}, 275{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"},
276{ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER ,"cipher has no object identifier"},
265{ASN1_R_DATA_IS_WRONG ,"data is wrong"}, 277{ASN1_R_DATA_IS_WRONG ,"data is wrong"},
266{ASN1_R_DECODE_ERROR ,"decode error"}, 278{ASN1_R_DECODE_ERROR ,"decode error"},
267{ASN1_R_DECODING_ERROR ,"decoding error"}, 279{ASN1_R_DECODING_ERROR ,"decoding error"},
@@ -275,24 +287,31 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
275{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"}, 287{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"},
276{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"}, 288{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"},
277{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"}, 289{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"},
290{ASN1_R_EXPECTING_A_NULL ,"expecting a null"},
278{ASN1_R_EXPECTING_A_TIME ,"expecting a time"}, 291{ASN1_R_EXPECTING_A_TIME ,"expecting a time"},
279{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"}, 292{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"},
280{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"}, 293{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"},
281{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"}, 294{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"},
282{ASN1_R_HEADER_TOO_LONG ,"header too long"}, 295{ASN1_R_HEADER_TOO_LONG ,"header too long"},
296{ASN1_R_ILLEGAL_CHARACTERS ,"illegal characters"},
297{ASN1_R_INVALID_BMPSTRING_LENGTH ,"invalid bmpstring length"},
283{ASN1_R_INVALID_DIGIT ,"invalid digit"}, 298{ASN1_R_INVALID_DIGIT ,"invalid digit"},
284{ASN1_R_INVALID_SEPARATOR ,"invalid separator"}, 299{ASN1_R_INVALID_SEPARATOR ,"invalid separator"},
285{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"}, 300{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"},
301{ASN1_R_INVALID_UNIVERSALSTRING_LENGTH ,"invalid universalstring length"},
302{ASN1_R_INVALID_UTF8STRING ,"invalid utf8string"},
286{ASN1_R_IV_TOO_LARGE ,"iv too large"}, 303{ASN1_R_IV_TOO_LARGE ,"iv too large"},
287{ASN1_R_LENGTH_ERROR ,"length error"}, 304{ASN1_R_LENGTH_ERROR ,"length error"},
288{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"}, 305{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"},
289{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"}, 306{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"},
290{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"}, 307{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"},
308{ASN1_R_NULL_IS_WRONG_LENGTH ,"null is wrong length"},
291{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"}, 309{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"},
292{ASN1_R_PARSING ,"parsing"}, 310{ASN1_R_PARSING ,"parsing"},
293{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"}, 311{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"},
294{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"}, 312{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"},
295{ASN1_R_SHORT_LINE ,"short line"}, 313{ASN1_R_SHORT_LINE ,"short line"},
314{ASN1_R_STRING_TOO_LONG ,"string too long"},
296{ASN1_R_STRING_TOO_SHORT ,"string too short"}, 315{ASN1_R_STRING_TOO_SHORT ,"string too short"},
297{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"}, 316{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"},
298{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"}, 317{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
@@ -300,6 +319,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
300{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"}, 319{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"},
301{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"}, 320{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"},
302{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"}, 321{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"},
322{ASN1_R_UNKNOWN_FORMAT ,"unknown format"},
303{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"}, 323{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"},
304{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"}, 324{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"},
305{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"}, 325{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"},
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_lib.c b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
index 95e54ed626..be8daa8688 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_lib.c
+++ b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
@@ -176,7 +176,7 @@ static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max)
176 } 176 }
177 177
178/* class 0 is constructed 178/* class 0 is constructed
179 * constructed == 2 for indefinitle length constructed */ 179 * constructed == 2 for indefinite length constructed */
180void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, 180void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
181 int xclass) 181 int xclass)
182 { 182 {
@@ -349,7 +349,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
349 if (data != NULL) 349 if (data != NULL)
350 { 350 {
351 memcpy(str->data,data,len); 351 memcpy(str->data,data,len);
352 /* an alowance for strings :-) */ 352 /* an allowance for strings :-) */
353 str->data[len]='\0'; 353 str->data[len]='\0';
354 } 354 }
355 return(1); 355 return(1);
@@ -381,8 +381,8 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
381void ASN1_STRING_free(ASN1_STRING *a) 381void ASN1_STRING_free(ASN1_STRING *a)
382 { 382 {
383 if (a == NULL) return; 383 if (a == NULL) return;
384 if (a->data != NULL) Free((char *)a->data); 384 if (a->data != NULL) Free(a->data);
385 Free((char *)a); 385 Free(a);
386 } 386 }
387 387
388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b) 388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b)
@@ -411,3 +411,14 @@ void asn1_add_error(unsigned char *address, int offset)
411 ERR_add_error_data(4,"address=",buf1," offset=",buf2); 411 ERR_add_error_data(4,"address=",buf1," offset=",buf2);
412 } 412 }
413 413
414int ASN1_STRING_length(ASN1_STRING *x)
415{ return M_ASN1_STRING_length(x); }
416
417void ASN1_STRING_length_set(ASN1_STRING *x, int len)
418{ M_ASN1_STRING_length_set(x, len); return; }
419
420int ASN1_STRING_type(ASN1_STRING *x)
421{ return M_ASN1_STRING_type(x); }
422
423unsigned char * ASN1_STRING_data(ASN1_STRING *x)
424{ return M_ASN1_STRING_data(x); }
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_mac.h b/src/lib/libssl/src/crypto/asn1/asn1_mac.h
index 93f9c5193c..4f2a82d340 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_mac.h
+++ b/src/lib/libssl/src/crypto/asn1/asn1_mac.h
@@ -106,6 +106,20 @@ err:\
106#define M_ASN1_D2I_start_sequence() \ 106#define M_ASN1_D2I_start_sequence() \
107 if (!asn1_GetSequence(&c,&length)) \ 107 if (!asn1_GetSequence(&c,&length)) \
108 { c.line=__LINE__; goto err; } 108 { c.line=__LINE__; goto err; }
109/* Begin reading ASN1 without a surrounding sequence */
110#define M_ASN1_D2I_begin() \
111 c.slen = length;
112
113/* End reading ASN1 with no check on length */
114#define M_ASN1_D2I_Finish_nolen(a, func, e) \
115 *pp=c.p; \
116 if (a != NULL) (*a)=ret; \
117 return(ret); \
118err:\
119 ASN1_MAC_H_err((e),c.error,c.line); \
120 asn1_add_error(*pp,(int)(c.q- *pp)); \
121 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
122 return(NULL)
109 123
110#define M_ASN1_D2I_end_sequence() \ 124#define M_ASN1_D2I_end_sequence() \
111 (((c.inf&1) == 0)?(c.slen <= 0): \ 125 (((c.inf&1) == 0)?(c.slen <= 0): \
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_par.c b/src/lib/libssl/src/crypto/asn1/asn1_par.c
index 86886606ef..d1e9816bad 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_par.c
+++ b/src/lib/libssl/src/crypto/asn1/asn1_par.c
@@ -93,55 +93,8 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
93 sprintf(str,"cont [ %d ]",tag); 93 sprintf(str,"cont [ %d ]",tag);
94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) 94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
95 sprintf(str,"appl [ %d ]",tag); 95 sprintf(str,"appl [ %d ]",tag);
96 else if ((tag == V_ASN1_EOC) /* && (xclass == V_ASN1_UNIVERSAL) */) 96 else p = ASN1_tag2str(tag);
97 p="EOC";
98 else if (tag == V_ASN1_BOOLEAN)
99 p="BOOLEAN";
100 else if (tag == V_ASN1_INTEGER)
101 p="INTEGER";
102 else if (tag == V_ASN1_ENUMERATED)
103 p="ENUMERATED";
104 else if (tag == V_ASN1_BIT_STRING)
105 p="BIT STRING";
106 else if (tag == V_ASN1_OCTET_STRING)
107 p="OCTET STRING";
108 else if (tag == V_ASN1_NULL)
109 p="NULL";
110 else if (tag == V_ASN1_OBJECT)
111 p="OBJECT";
112 else if (tag == V_ASN1_SEQUENCE)
113 p="SEQUENCE";
114 else if (tag == V_ASN1_SET)
115 p="SET";
116 else if (tag == V_ASN1_PRINTABLESTRING)
117 p="PRINTABLESTRING";
118 else if (tag == V_ASN1_T61STRING)
119 p="T61STRING";
120 else if (tag == V_ASN1_IA5STRING)
121 p="IA5STRING";
122 else if (tag == V_ASN1_UTCTIME)
123 p="UTCTIME";
124 97
125 /* extras */
126 else if (tag == V_ASN1_NUMERICSTRING)
127 p="NUMERICSTRING";
128 else if (tag == V_ASN1_VIDEOTEXSTRING)
129 p="VIDEOTEXSTRING";
130 else if (tag == V_ASN1_GENERALIZEDTIME)
131 p="GENERALIZEDTIME";
132 else if (tag == V_ASN1_GRAPHICSTRING)
133 p="GRAPHICSTRING";
134 else if (tag == V_ASN1_VISIBLESTRING)
135 p="VISIBLESTRING";
136 else if (tag == V_ASN1_GENERALSTRING)
137 p="GENERALSTRING";
138 else if (tag == V_ASN1_UNIVERSALSTRING)
139 p="UNIVERSALSTRING";
140 else if (tag == V_ASN1_BMPSTRING)
141 p="BMPSTRING";
142 else
143 p2="(unknown)";
144
145 if (p2 != NULL) 98 if (p2 != NULL)
146 { 99 {
147 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err; 100 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err;
@@ -320,7 +273,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
320 os->length) <= 0) 273 os->length) <= 0)
321 goto end; 274 goto end;
322 } 275 }
323 ASN1_OCTET_STRING_free(os); 276 M_ASN1_OCTET_STRING_free(os);
324 os=NULL; 277 os=NULL;
325 } 278 }
326 } 279 }
@@ -354,7 +307,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
354 if (BIO_write(bp,"BAD INTEGER",11) <= 0) 307 if (BIO_write(bp,"BAD INTEGER",11) <= 0)
355 goto end; 308 goto end;
356 } 309 }
357 ASN1_INTEGER_free(bs); 310 M_ASN1_INTEGER_free(bs);
358 } 311 }
359 else if (tag == V_ASN1_ENUMERATED) 312 else if (tag == V_ASN1_ENUMERATED)
360 { 313 {
@@ -386,7 +339,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
386 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0) 339 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0)
387 goto end; 340 goto end;
388 } 341 }
389 ASN1_ENUMERATED_free(bs); 342 M_ASN1_ENUMERATED_free(bs);
390 } 343 }
391 344
392 if (!nl) 345 if (!nl)
@@ -405,7 +358,28 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
405 ret=1; 358 ret=1;
406end: 359end:
407 if (o != NULL) ASN1_OBJECT_free(o); 360 if (o != NULL) ASN1_OBJECT_free(o);
408 if (os != NULL) ASN1_OCTET_STRING_free(os); 361 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
409 *pp=p; 362 *pp=p;
410 return(ret); 363 return(ret);
411 } 364 }
365
366const char *ASN1_tag2str(int tag)
367{
368 const static char *tag2str[] = {
369 "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */
370 "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */
371 "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */
372 "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */
373 "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */
374 "VIDEOTEXSTRING", "IA5STRING", "UTCTIME","GENERALIZEDTIME", /* 21-24 */
375 "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */
376 "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */
377 };
378
379 if((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
380 tag &= ~0x100;
381
382 if(tag < 0 || tag > 30) return "(unknown)";
383 return tag2str[tag];
384}
385
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_dhp.c b/src/lib/libssl/src/crypto/asn1/d2i_dhp.c
index a077211a4c..635ae829db 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_dhp.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_dhp.c
@@ -86,7 +86,7 @@ DH *d2i_DHparams(DH **a, unsigned char **pp, long length)
86 ret->length=(int)v; 86 ret->length=(int)v;
87 } 87 }
88 88
89 ASN1_BIT_STRING_free(bs); 89 M_ASN1_BIT_STRING_free(bs);
90 90
91 M_ASN1_D2I_Finish_2(a); 91 M_ASN1_D2I_Finish_2(a);
92 92
@@ -95,7 +95,7 @@ err_bn:
95err: 95err:
96 ASN1err(ASN1_F_D2I_DHPARAMS,i); 96 ASN1err(ASN1_F_D2I_DHPARAMS,i);
97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret); 97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret);
98 if (bs != NULL) ASN1_BIT_STRING_free(bs); 98 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
99 return(NULL); 99 return(NULL);
100 } 100 }
101#endif 101#endif
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_dsap.c b/src/lib/libssl/src/crypto/asn1/d2i_dsap.c
index cdd7136f51..6d1c297133 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_dsap.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_dsap.c
@@ -83,7 +83,7 @@ DSA *d2i_DSAparams(DSA **a, unsigned char **pp, long length)
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; 84 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
85 85
86 ASN1_BIT_STRING_free(bs); 86 M_ASN1_BIT_STRING_free(bs);
87 87
88 M_ASN1_D2I_Finish_2(a); 88 M_ASN1_D2I_Finish_2(a);
89 89
@@ -92,7 +92,7 @@ err_bn:
92err: 92err:
93 ASN1err(ASN1_F_D2I_DSAPARAMS,i); 93 ASN1err(ASN1_F_D2I_DSAPARAMS,i);
94 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 94 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
95 if (bs != NULL) ASN1_BIT_STRING_free(bs); 95 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
96 return(NULL); 96 return(NULL);
97 } 97 }
98#endif 98#endif
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_pr.c
index f3d1aa6240..c92b8325d8 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_pr.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_pr.c
@@ -112,3 +112,26 @@ err:
112 return(NULL); 112 return(NULL);
113 } 113 }
114 114
115/* This works like d2i_PrivateKey() except it automatically works out the type */
116
117EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
118 long length)
119{
120 STACK_OF(ASN1_TYPE) *inkey;
121 unsigned char *p;
122 int keytype;
123 p = *pp;
124 /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE):
125 * by analyzing it we can determine the passed structure: this
126 * assumes the input is surrounded by an ASN1 SEQUENCE.
127 */
128 inkey = d2i_ASN1_SET_OF_ASN1_TYPE(NULL, &p, length, d2i_ASN1_TYPE,
129 ASN1_TYPE_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
130 /* Since we only need to discern "traditional format" RSA and DSA
131 * keys we can just count the elements.
132 */
133 if(sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA;
134 else keytype = EVP_PKEY_RSA;
135 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
136 return d2i_PrivateKey(keytype, a, pp, length);
137}
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c
index 18f11b6f5e..6c8a45f821 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c
@@ -107,7 +107,7 @@ RSA *d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length)
107 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL) 107 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL)
108 goto err_bn; 108 goto err_bn;
109 109
110 ASN1_INTEGER_free(bs); 110 M_ASN1_INTEGER_free(bs);
111 111
112 M_ASN1_D2I_Finish_2(a); 112 M_ASN1_D2I_Finish_2(a);
113err_bn: 113err_bn:
@@ -115,7 +115,14 @@ err_bn:
115err: 115err:
116 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i); 116 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i);
117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); 117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
118 if (bs != NULL) ASN1_INTEGER_free(bs); 118 if (bs != NULL) M_ASN1_INTEGER_free(bs);
119
119 return(NULL); 120 return(NULL);
120 } 121 }
122#else /* !NO_RSA */
123
124# if PEDANTIC
125static void *dummy=&dummy;
126# endif
127
121#endif 128#endif
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c
index c4ae58b594..d1289f160e 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c
@@ -81,7 +81,7 @@ RSA *d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length)
81 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 81 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
82 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; 82 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
83 83
84 ASN1_INTEGER_free(bs); 84 M_ASN1_INTEGER_free(bs);
85 bs=NULL; 85 bs=NULL;
86 86
87 M_ASN1_D2I_Finish_2(a); 87 M_ASN1_D2I_Finish_2(a);
@@ -91,7 +91,13 @@ err_bn:
91err: 91err:
92 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i); 92 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i);
93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); 93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
94 if (bs != NULL) ASN1_INTEGER_free(bs); 94 if (bs != NULL) M_ASN1_INTEGER_free(bs);
95 return(NULL); 95 return(NULL);
96 } 96 }
97#else /* !NO_RSA */
98
99# if PEDANTIC
100static void *dummy=&dummy;
101# endif
102
97#endif 103#endif
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c
index 050e1cc5fb..dec2a2ebd3 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c
@@ -91,7 +91,7 @@ DSA *d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length)
91 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key)) 91 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key))
92 == NULL) goto err_bn; 92 == NULL) goto err_bn;
93 93
94 ASN1_INTEGER_free(bs); 94 M_ASN1_INTEGER_free(bs);
95 95
96 M_ASN1_D2I_Finish_2(a); 96 M_ASN1_D2I_Finish_2(a);
97err_bn: 97err_bn:
@@ -99,7 +99,7 @@ err_bn:
99err: 99err:
100 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i); 100 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i);
101 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 101 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
102 if (bs != NULL) ASN1_INTEGER_free(bs); 102 if (bs != NULL) M_ASN1_INTEGER_free(bs);
103 return(NULL); 103 return(NULL);
104 } 104 }
105#endif 105#endif
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c
index 94ea1c313b..e0adaa0393 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c
@@ -107,7 +107,7 @@ DSA *d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length)
107 ret->write_params=1; 107 ret->write_params=1;
108 } 108 }
109 109
110 ASN1_INTEGER_free(bs); 110 M_ASN1_INTEGER_free(bs);
111 bs=NULL; 111 bs=NULL;
112 M_ASN1_D2I_Finish_2(a); 112 M_ASN1_D2I_Finish_2(a);
113err_bn: 113err_bn:
@@ -115,7 +115,7 @@ err_bn:
115err: 115err:
116 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i); 116 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i);
117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
118 if (bs != NULL) ASN1_INTEGER_free(bs); 118 if (bs != NULL) M_ASN1_INTEGER_free(bs);
119 return(NULL); 119 return(NULL);
120 } 120 }
121#endif 121#endif
diff --git a/src/lib/libssl/src/crypto/asn1/evp_asn1.c b/src/lib/libssl/src/crypto/asn1/evp_asn1.c
index 41ced49c19..3506005a71 100644
--- a/src/lib/libssl/src/crypto/asn1/evp_asn1.c
+++ b/src/lib/libssl/src/crypto/asn1/evp_asn1.c
@@ -65,8 +65,8 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
65 { 65 {
66 ASN1_STRING *os; 66 ASN1_STRING *os;
67 67
68 if ((os=ASN1_OCTET_STRING_new()) == NULL) return(0); 68 if ((os=M_ASN1_OCTET_STRING_new()) == NULL) return(0);
69 if (!ASN1_OCTET_STRING_set(os,data,len)) return(0); 69 if (!M_ASN1_OCTET_STRING_set(os,data,len)) return(0);
70 ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os); 70 ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os);
71 return(1); 71 return(1);
72 } 72 }
@@ -83,8 +83,8 @@ int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
83 ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG); 83 ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG);
84 return(-1); 84 return(-1);
85 } 85 }
86 p=ASN1_STRING_data(a->value.octet_string); 86 p=M_ASN1_STRING_data(a->value.octet_string);
87 ret=ASN1_STRING_length(a->value.octet_string); 87 ret=M_ASN1_STRING_length(a->value.octet_string);
88 if (ret < max_len) 88 if (ret < max_len)
89 num=ret; 89 num=ret;
90 else 90 else
@@ -117,8 +117,8 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
117 /* Grow the 'string' */ 117 /* Grow the 'string' */
118 ASN1_STRING_set(osp,NULL,size); 118 ASN1_STRING_set(osp,NULL,size);
119 119
120 ASN1_STRING_length(osp)=size; 120 M_ASN1_STRING_length_set(osp, size);
121 p=ASN1_STRING_data(osp); 121 p=M_ASN1_STRING_data(osp);
122 122
123 ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); 123 ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
124 i2d_ASN1_INTEGER(&in,&p); 124 i2d_ASN1_INTEGER(&in,&p);
@@ -145,8 +145,8 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
145 { 145 {
146 goto err; 146 goto err;
147 } 147 }
148 p=ASN1_STRING_data(a->value.sequence); 148 p=M_ASN1_STRING_data(a->value.sequence);
149 length=ASN1_STRING_length(a->value.sequence); 149 length=M_ASN1_STRING_length(a->value.sequence);
150 150
151 c.pp= &p; 151 c.pp= &p;
152 c.p=p; 152 c.p=p;
@@ -165,21 +165,21 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
165 if (num != NULL) 165 if (num != NULL)
166 *num=ASN1_INTEGER_get(ai); 166 *num=ASN1_INTEGER_get(ai);
167 167
168 ret=ASN1_STRING_length(os); 168 ret=M_ASN1_STRING_length(os);
169 if (max_len > ret) 169 if (max_len > ret)
170 n=ret; 170 n=ret;
171 else 171 else
172 n=max_len; 172 n=max_len;
173 173
174 if (data != NULL) 174 if (data != NULL)
175 memcpy(data,ASN1_STRING_data(os),n); 175 memcpy(data,M_ASN1_STRING_data(os),n);
176 if (0) 176 if (0)
177 { 177 {
178err: 178err:
179 ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG); 179 ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG);
180 } 180 }
181 if (os != NULL) ASN1_OCTET_STRING_free(os); 181 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
182 if (ai != NULL) ASN1_INTEGER_free(ai); 182 if (ai != NULL) M_ASN1_INTEGER_free(ai);
183 return(ret); 183 return(ret);
184 } 184 }
185 185
diff --git a/src/lib/libssl/src/crypto/asn1/f_enum.c b/src/lib/libssl/src/crypto/asn1/f_enum.c
index 3bcceecdb8..3d0b1107cb 100644
--- a/src/lib/libssl/src/crypto/asn1/f_enum.c
+++ b/src/lib/libssl/src/crypto/asn1/f_enum.c
@@ -161,7 +161,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
161 if (sp == NULL) 161 if (sp == NULL)
162 { 162 {
163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE); 163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE);
164 if (s != NULL) Free((char *)s); 164 if (s != NULL) Free(s);
165 goto err; 165 goto err;
166 } 166 }
167 s=sp; 167 s=sp;
diff --git a/src/lib/libssl/src/crypto/asn1/f_int.c b/src/lib/libssl/src/crypto/asn1/f_int.c
index 55560dd814..cd57331c3f 100644
--- a/src/lib/libssl/src/crypto/asn1/f_int.c
+++ b/src/lib/libssl/src/crypto/asn1/f_int.c
@@ -168,7 +168,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
168 if (sp == NULL) 168 if (sp == NULL)
169 { 169 {
170 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 170 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
171 if (s != NULL) Free((char *)s); 171 if (s != NULL) Free(s);
172 goto err; 172 goto err;
173 } 173 }
174 s=sp; 174 s=sp;
diff --git a/src/lib/libssl/src/crypto/asn1/f_string.c b/src/lib/libssl/src/crypto/asn1/f_string.c
index 5d0cf5a46d..088313689a 100644
--- a/src/lib/libssl/src/crypto/asn1/f_string.c
+++ b/src/lib/libssl/src/crypto/asn1/f_string.c
@@ -166,7 +166,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
166 if (sp == NULL) 166 if (sp == NULL)
167 { 167 {
168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE); 168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
169 if (s != NULL) Free((char *)s); 169 if (s != NULL) Free(s);
170 goto err; 170 goto err;
171 } 171 }
172 s=sp; 172 s=sp;
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_dhp.c b/src/lib/libssl/src/crypto/asn1/i2d_dhp.c
index fdda4ec41b..61eeb646f9 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_dhp.c
+++ b/src/lib/libssl/src/crypto/asn1/i2d_dhp.c
@@ -118,7 +118,7 @@ int i2d_DHparams(DH *a, unsigned char **pp)
118 bs.length=BN_bn2bin(num[i],bs.data); 118 bs.length=BN_bn2bin(num[i],bs.data);
119 i2d_ASN1_INTEGER(&bs,&p); 119 i2d_ASN1_INTEGER(&bs,&p);
120 } 120 }
121 Free((char *)bs.data); 121 Free(bs.data);
122 ret=t; 122 ret=t;
123err: 123err:
124 if (num[2] != NULL) BN_free(num[2]); 124 if (num[2] != NULL) BN_free(num[2]);
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_dsap.c b/src/lib/libssl/src/crypto/asn1/i2d_dsap.c
index f36f0da4e2..4021123ba3 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_dsap.c
+++ b/src/lib/libssl/src/crypto/asn1/i2d_dsap.c
@@ -107,7 +107,7 @@ int i2d_DSAparams(DSA *a, unsigned char **pp)
107 bs.length=BN_bn2bin(num[i],bs.data); 107 bs.length=BN_bn2bin(num[i],bs.data);
108 i2d_ASN1_INTEGER(&bs,&p); 108 i2d_ASN1_INTEGER(&bs,&p);
109 } 109 }
110 Free((char *)bs.data); 110 Free(bs.data);
111 ret=t; 111 ret=t;
112err: 112err:
113 *pp=p; 113 *pp=p;
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c
index 27e6844a7f..1250fa4b2d 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c
+++ b/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c
@@ -119,9 +119,15 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
119 bs.length=BN_bn2bin(num[i],bs.data); 119 bs.length=BN_bn2bin(num[i],bs.data);
120 i2d_ASN1_INTEGER(&bs,&p); 120 i2d_ASN1_INTEGER(&bs,&p);
121 } 121 }
122 Free((char *)bs.data); 122 Free(bs.data);
123 *pp=p; 123 *pp=p;
124 return(t); 124 return(t);
125 } 125 }
126#else /* !NO_RSA */
127
128# if PEDANTIC
129static void *dummy=&dummy;
130# endif
131
126#endif 132#endif
127 133
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c
index 6d01bfa8b5..582b92ee4c 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c
+++ b/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c
@@ -105,8 +105,14 @@ int i2d_RSAPublicKey(RSA *a, unsigned char **pp)
105 bs.length=BN_bn2bin(num[i],bs.data); 105 bs.length=BN_bn2bin(num[i],bs.data);
106 i2d_ASN1_INTEGER(&bs,&p); 106 i2d_ASN1_INTEGER(&bs,&p);
107 } 107 }
108 Free((char *)bs.data); 108 Free(bs.data);
109 *pp=p; 109 *pp=p;
110 return(t); 110 return(t);
111 } 111 }
112#else /* !NO_RSA */
113
114# if PEDANTIC
115static void *dummy=&dummy;
116# endif
117
112#endif 118#endif
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c
index 5d3dcdf197..e399ceaeb9 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c
+++ b/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c
@@ -116,7 +116,7 @@ int i2d_DSAPrivateKey(DSA *a, unsigned char **pp)
116 bs.length=BN_bn2bin(num[i],bs.data); 116 bs.length=BN_bn2bin(num[i],bs.data);
117 i2d_ASN1_INTEGER(&bs,&p); 117 i2d_ASN1_INTEGER(&bs,&p);
118 } 118 }
119 Free((char *)bs.data); 119 Free(bs.data);
120 *pp=p; 120 *pp=p;
121 return(t); 121 return(t);
122 } 122 }
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c
index 18f790f746..ca7f251b71 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c
+++ b/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c
@@ -121,7 +121,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp)
121 bs.length=BN_bn2bin(num[i],bs.data); 121 bs.length=BN_bn2bin(num[i],bs.data);
122 i2d_ASN1_INTEGER(&bs,&p); 122 i2d_ASN1_INTEGER(&bs,&p);
123 } 123 }
124 Free((char *)bs.data); 124 Free(bs.data);
125 *pp=p; 125 *pp=p;
126 if(all) return(t); 126 if(all) return(t);
127 else return(tot); 127 else return(tot);
diff --git a/src/lib/libssl/src/crypto/asn1/n_pkey.c b/src/lib/libssl/src/crypto/asn1/n_pkey.c
index cdc0d8b7c4..d804986b73 100644
--- a/src/lib/libssl/src/crypto/asn1/n_pkey.c
+++ b/src/lib/libssl/src/crypto/asn1/n_pkey.c
@@ -139,7 +139,7 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
139 } 139 }
140 140
141 if (pkey->private_key->data != NULL) 141 if (pkey->private_key->data != NULL)
142 Free((char *)pkey->private_key->data); 142 Free(pkey->private_key->data);
143 if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL) 143 if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL)
144 { 144 {
145 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); 145 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
@@ -205,10 +205,10 @@ RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)())
205 (char *)os->data,os->length) != 0)) 205 (char *)os->data,os->length) != 0))
206 { 206 {
207 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING); 207 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING);
208 ASN1_BIT_STRING_free(os); 208 M_ASN1_BIT_STRING_free(os);
209 goto err; 209 goto err;
210 } 210 }
211 ASN1_BIT_STRING_free(os); 211 M_ASN1_BIT_STRING_free(os);
212 c.q=c.p; 212 c.q=c.p;
213 if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err; 213 if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err;
214 c.slen-=(c.p-c.q); 214 c.slen-=(c.p-c.q);
@@ -279,7 +279,7 @@ RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length,
279 *pp=c.p; 279 *pp=c.p;
280err: 280err:
281 if (pkey != NULL) NETSCAPE_PKEY_free(pkey); 281 if (pkey != NULL) NETSCAPE_PKEY_free(pkey);
282 if (os != NULL) ASN1_BIT_STRING_free(os); 282 if (os != NULL) M_ASN1_BIT_STRING_free(os);
283 if (alg != NULL) X509_ALGOR_free(alg); 283 if (alg != NULL) X509_ALGOR_free(alg);
284 return(ret); 284 return(ret);
285 } 285 }
@@ -321,9 +321,9 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
321 ASN1_CTX c; 321 ASN1_CTX c;
322 322
323 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY); 323 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY);
324 M_ASN1_New(ret->version,ASN1_INTEGER_new); 324 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
325 M_ASN1_New(ret->algor,X509_ALGOR_new); 325 M_ASN1_New(ret->algor,X509_ALGOR_new);
326 M_ASN1_New(ret->private_key,ASN1_OCTET_STRING_new); 326 M_ASN1_New(ret->private_key,M_ASN1_OCTET_STRING_new);
327 return(ret); 327 return(ret);
328 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW); 328 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW);
329 } 329 }
@@ -331,11 +331,18 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
331static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a) 331static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a)
332 { 332 {
333 if (a == NULL) return; 333 if (a == NULL) return;
334 ASN1_INTEGER_free(a->version); 334 M_ASN1_INTEGER_free(a->version);
335 X509_ALGOR_free(a->algor); 335 X509_ALGOR_free(a->algor);
336 ASN1_OCTET_STRING_free(a->private_key); 336 M_ASN1_OCTET_STRING_free(a->private_key);
337 Free((char *)a); 337 Free(a);
338 } 338 }
339 339
340#endif /* NO_RC4 */ 340#endif /* NO_RC4 */
341
342#else /* !NO_RSA */
343
344# if PEDANTIC
345static void *dummy=&dummy;
346# endif
347
341#endif 348#endif
diff --git a/src/lib/libssl/src/crypto/asn1/p5_pbe.c b/src/lib/libssl/src/crypto/asn1/p5_pbe.c
index b831836e7b..64e90237cc 100644
--- a/src/lib/libssl/src/crypto/asn1/p5_pbe.c
+++ b/src/lib/libssl/src/crypto/asn1/p5_pbe.c
@@ -82,8 +82,8 @@ PBEPARAM *PBEPARAM_new(void)
82 PBEPARAM *ret=NULL; 82 PBEPARAM *ret=NULL;
83 ASN1_CTX c; 83 ASN1_CTX c;
84 M_ASN1_New_Malloc(ret, PBEPARAM); 84 M_ASN1_New_Malloc(ret, PBEPARAM);
85 M_ASN1_New(ret->iter,ASN1_INTEGER_new); 85 M_ASN1_New(ret->iter,M_ASN1_INTEGER_new);
86 M_ASN1_New(ret->salt,ASN1_OCTET_STRING_new); 86 M_ASN1_New(ret->salt,M_ASN1_OCTET_STRING_new);
87 return (ret); 87 return (ret);
88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW); 88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW);
89} 89}
@@ -101,9 +101,9 @@ PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length)
101void PBEPARAM_free (PBEPARAM *a) 101void PBEPARAM_free (PBEPARAM *a)
102{ 102{
103 if(a==NULL) return; 103 if(a==NULL) return;
104 ASN1_OCTET_STRING_free(a->salt); 104 M_ASN1_OCTET_STRING_free(a->salt);
105 ASN1_INTEGER_free (a->iter); 105 M_ASN1_INTEGER_free (a->iter);
106 Free ((char *)a); 106 Free (a);
107} 107}
108 108
109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */ 109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
@@ -129,7 +129,8 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt,
129 } 129 }
130 pbe->salt->length = saltlen; 130 pbe->salt->length = saltlen;
131 if (salt) memcpy (pbe->salt->data, salt, saltlen); 131 if (salt) memcpy (pbe->salt->data, salt, saltlen);
132 else RAND_bytes (pbe->salt->data, saltlen); 132 else if (RAND_bytes (pbe->salt->data, saltlen) <= 0)
133 return NULL;
133 134
134 if (!(astype = ASN1_TYPE_new())) { 135 if (!(astype = ASN1_TYPE_new())) {
135 ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE); 136 ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libssl/src/crypto/asn1/p5_pbev2.c b/src/lib/libssl/src/crypto/asn1/p5_pbev2.c
index 09f4bf6112..4ce06a94ab 100644
--- a/src/lib/libssl/src/crypto/asn1/p5_pbev2.c
+++ b/src/lib/libssl/src/crypto/asn1/p5_pbev2.c
@@ -104,7 +104,7 @@ void PBE2PARAM_free (PBE2PARAM *a)
104 if(a==NULL) return; 104 if(a==NULL) return;
105 X509_ALGOR_free(a->keyfunc); 105 X509_ALGOR_free(a->keyfunc);
106 X509_ALGOR_free(a->encryption); 106 X509_ALGOR_free(a->encryption);
107 Free ((char *)a); 107 Free (a);
108} 108}
109 109
110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp) 110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
@@ -131,7 +131,7 @@ PBKDF2PARAM *PBKDF2PARAM_new(void)
131 ASN1_CTX c; 131 ASN1_CTX c;
132 M_ASN1_New_Malloc(ret, PBKDF2PARAM); 132 M_ASN1_New_Malloc(ret, PBKDF2PARAM);
133 M_ASN1_New(ret->salt, ASN1_TYPE_new); 133 M_ASN1_New(ret->salt, ASN1_TYPE_new);
134 M_ASN1_New(ret->iter, ASN1_INTEGER_new); 134 M_ASN1_New(ret->iter, M_ASN1_INTEGER_new);
135 ret->keylength = NULL; 135 ret->keylength = NULL;
136 ret->prf = NULL; 136 ret->prf = NULL;
137 return (ret); 137 return (ret);
@@ -155,10 +155,10 @@ void PBKDF2PARAM_free (PBKDF2PARAM *a)
155{ 155{
156 if(a==NULL) return; 156 if(a==NULL) return;
157 ASN1_TYPE_free(a->salt); 157 ASN1_TYPE_free(a->salt);
158 ASN1_INTEGER_free(a->iter); 158 M_ASN1_INTEGER_free(a->iter);
159 ASN1_INTEGER_free(a->keylength); 159 M_ASN1_INTEGER_free(a->keylength);
160 X509_ALGOR_free(a->prf); 160 X509_ALGOR_free(a->prf);
161 Free ((char *)a); 161 Free (a);
162} 162}
163 163
164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm: 164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
@@ -175,19 +175,26 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
175 PBKDF2PARAM *kdf = NULL; 175 PBKDF2PARAM *kdf = NULL;
176 PBE2PARAM *pbe2 = NULL; 176 PBE2PARAM *pbe2 = NULL;
177 ASN1_OCTET_STRING *osalt = NULL; 177 ASN1_OCTET_STRING *osalt = NULL;
178 ASN1_OBJECT *obj;
179
180 alg_nid = EVP_CIPHER_type(cipher);
181 if(alg_nid == NID_undef) {
182 ASN1err(ASN1_F_PKCS5_PBE2_SET,
183 ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
184 goto err;
185 }
186 obj = OBJ_nid2obj(alg_nid);
178 187
179 if(!(pbe2 = PBE2PARAM_new())) goto merr; 188 if(!(pbe2 = PBE2PARAM_new())) goto merr;
180 189
181 /* Setup the AlgorithmIdentifier for the encryption scheme */ 190 /* Setup the AlgorithmIdentifier for the encryption scheme */
182 scheme = pbe2->encryption; 191 scheme = pbe2->encryption;
183 192
184 alg_nid = EVP_CIPHER_type(cipher); 193 scheme->algorithm = obj;
185
186 scheme->algorithm = OBJ_nid2obj(alg_nid);
187 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr; 194 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr;
188 195
189 /* Create random IV */ 196 /* Create random IV */
190 RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)); 197 RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher));
191 198
192 /* Dummy cipherinit to just setup the IV */ 199 /* Dummy cipherinit to just setup the IV */
193 EVP_CipherInit(&ctx, cipher, NULL, iv, 0); 200 EVP_CipherInit(&ctx, cipher, NULL, iv, 0);
@@ -199,13 +206,13 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
199 EVP_CIPHER_CTX_cleanup(&ctx); 206 EVP_CIPHER_CTX_cleanup(&ctx);
200 207
201 if(!(kdf = PBKDF2PARAM_new())) goto merr; 208 if(!(kdf = PBKDF2PARAM_new())) goto merr;
202 if(!(osalt = ASN1_OCTET_STRING_new())) goto merr; 209 if(!(osalt = M_ASN1_OCTET_STRING_new())) goto merr;
203 210
204 if (!saltlen) saltlen = PKCS5_SALT_LEN; 211 if (!saltlen) saltlen = PKCS5_SALT_LEN;
205 if (!(osalt->data = Malloc (saltlen))) goto merr; 212 if (!(osalt->data = Malloc (saltlen))) goto merr;
206 osalt->length = saltlen; 213 osalt->length = saltlen;
207 if (salt) memcpy (osalt->data, salt, saltlen); 214 if (salt) memcpy (osalt->data, salt, saltlen);
208 else RAND_bytes (osalt->data, saltlen); 215 else if (RAND_bytes (osalt->data, saltlen) <= 0) goto merr;
209 216
210 if(iter <= 0) iter = PKCS5_DEFAULT_ITER; 217 if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
211 if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr; 218 if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr;
@@ -218,7 +225,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
218 /* If its RC2 then we'd better setup the key length */ 225 /* If its RC2 then we'd better setup the key length */
219 226
220 if(alg_nid == NID_rc2_cbc) { 227 if(alg_nid == NID_rc2_cbc) {
221 if(!(kdf->keylength = ASN1_INTEGER_new())) goto merr; 228 if(!(kdf->keylength = M_ASN1_INTEGER_new())) goto merr;
222 if(!ASN1_INTEGER_set (kdf->keylength, 229 if(!ASN1_INTEGER_set (kdf->keylength,
223 EVP_CIPHER_key_length(cipher))) goto merr; 230 EVP_CIPHER_key_length(cipher))) goto merr;
224 } 231 }
@@ -264,7 +271,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
264 err: 271 err:
265 PBE2PARAM_free(pbe2); 272 PBE2PARAM_free(pbe2);
266 /* Note 'scheme' is freed as part of pbe2 */ 273 /* Note 'scheme' is freed as part of pbe2 */
267 ASN1_OCTET_STRING_free(osalt); 274 M_ASN1_OCTET_STRING_free(osalt);
268 PBKDF2PARAM_free(kdf); 275 PBKDF2PARAM_free(kdf);
269 X509_ALGOR_free(kalg); 276 X509_ALGOR_free(kalg);
270 X509_ALGOR_free(ret); 277 X509_ALGOR_free(ret);
diff --git a/src/lib/libssl/src/crypto/asn1/p7_dgst.c b/src/lib/libssl/src/crypto/asn1/p7_dgst.c
index 62783a2b8d..cba90e94a1 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_dgst.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_dgst.c
@@ -101,10 +101,10 @@ PKCS7_DIGEST *PKCS7_DIGEST_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_DIGEST); 103 M_ASN1_New_Malloc(ret,PKCS7_DIGEST);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->md,X509_ALGOR_new); 105 M_ASN1_New(ret->md,X509_ALGOR_new);
106 M_ASN1_New(ret->contents,PKCS7_new); 106 M_ASN1_New(ret->contents,PKCS7_new);
107 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); 107 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
108 return(ret); 108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW); 109 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW);
110 } 110 }
@@ -112,10 +112,10 @@ PKCS7_DIGEST *PKCS7_DIGEST_new(void)
112void PKCS7_DIGEST_free(PKCS7_DIGEST *a) 112void PKCS7_DIGEST_free(PKCS7_DIGEST *a)
113 { 113 {
114 if (a == NULL) return; 114 if (a == NULL) return;
115 ASN1_INTEGER_free(a->version); 115 M_ASN1_INTEGER_free(a->version);
116 X509_ALGOR_free(a->md); 116 X509_ALGOR_free(a->md);
117 PKCS7_free(a->contents); 117 PKCS7_free(a->contents);
118 ASN1_OCTET_STRING_free(a->digest); 118 M_ASN1_OCTET_STRING_free(a->digest);
119 Free((char *)a); 119 Free(a);
120 } 120 }
121 121
diff --git a/src/lib/libssl/src/crypto/asn1/p7_enc.c b/src/lib/libssl/src/crypto/asn1/p7_enc.c
index 4741126587..83b0e15faa 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_enc.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_enc.c
@@ -95,7 +95,7 @@ PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void)
95 ASN1_CTX c; 95 ASN1_CTX c;
96 96
97 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT); 97 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT);
98 M_ASN1_New(ret->version,ASN1_INTEGER_new); 98 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
99 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 99 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
100 return(ret); 100 return(ret);
101 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW); 101 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW);
@@ -104,8 +104,8 @@ PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void)
104void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a) 104void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a)
105 { 105 {
106 if (a == NULL) return; 106 if (a == NULL) return;
107 ASN1_INTEGER_free(a->version); 107 M_ASN1_INTEGER_free(a->version);
108 PKCS7_ENC_CONTENT_free(a->enc_data); 108 PKCS7_ENC_CONTENT_free(a->enc_data);
109 Free((char *)a); 109 Free(a);
110 } 110 }
111 111
diff --git a/src/lib/libssl/src/crypto/asn1/p7_enc_c.c b/src/lib/libssl/src/crypto/asn1/p7_enc_c.c
index a832737a38..582cc78b06 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_enc_c.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_enc_c.c
@@ -101,7 +101,8 @@ PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new(void)
101 101
102 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT); 102 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT);
103 /* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */ 103 /* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */
104 ret->content_type=OBJ_nid2obj(NID_pkcs7_encrypted); 104 /* We will almost always want this: so make it the default */
105 ret->content_type=OBJ_nid2obj(NID_pkcs7_data);
105 M_ASN1_New(ret->algorithm,X509_ALGOR_new); 106 M_ASN1_New(ret->algorithm,X509_ALGOR_new);
106 ret->enc_data=NULL; 107 ret->enc_data=NULL;
107 return(ret); 108 return(ret);
@@ -113,7 +114,7 @@ void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a)
113 if (a == NULL) return; 114 if (a == NULL) return;
114 ASN1_OBJECT_free(a->content_type); 115 ASN1_OBJECT_free(a->content_type);
115 X509_ALGOR_free(a->algorithm); 116 X509_ALGOR_free(a->algorithm);
116 ASN1_OCTET_STRING_free(a->enc_data); 117 M_ASN1_OCTET_STRING_free(a->enc_data);
117 Free((char *)a); 118 Free(a);
118 } 119 }
119 120
diff --git a/src/lib/libssl/src/crypto/asn1/p7_evp.c b/src/lib/libssl/src/crypto/asn1/p7_evp.c
index b2b3d50dcd..4e734fdd28 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_evp.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_evp.c
@@ -101,7 +101,7 @@ PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE); 103 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null); 105 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null);
106 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 106 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
107 return(ret); 107 return(ret);
@@ -111,9 +111,9 @@ PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void)
111void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a) 111void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a)
112 { 112 {
113 if (a == NULL) return; 113 if (a == NULL) return;
114 ASN1_INTEGER_free(a->version); 114 M_ASN1_INTEGER_free(a->version);
115 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); 115 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
116 PKCS7_ENC_CONTENT_free(a->enc_data); 116 PKCS7_ENC_CONTENT_free(a->enc_data);
117 Free((char *)a); 117 Free(a);
118 } 118 }
119 119
diff --git a/src/lib/libssl/src/crypto/asn1/p7_i_s.c b/src/lib/libssl/src/crypto/asn1/p7_i_s.c
index 7d4b457e01..d21f7ddb84 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_i_s.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_i_s.c
@@ -96,7 +96,7 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void)
96 96
97 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL); 97 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL);
98 M_ASN1_New(ret->issuer,X509_NAME_new); 98 M_ASN1_New(ret->issuer,X509_NAME_new);
99 M_ASN1_New(ret->serial,ASN1_INTEGER_new); 99 M_ASN1_New(ret->serial,M_ASN1_INTEGER_new);
100 return(ret); 100 return(ret);
101 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW); 101 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW);
102 } 102 }
@@ -105,7 +105,7 @@ void PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a)
105 { 105 {
106 if (a == NULL) return; 106 if (a == NULL) return;
107 X509_NAME_free(a->issuer); 107 X509_NAME_free(a->issuer);
108 ASN1_INTEGER_free(a->serial); 108 M_ASN1_INTEGER_free(a->serial);
109 Free((char *)a); 109 Free(a);
110 } 110 }
111 111
diff --git a/src/lib/libssl/src/crypto/asn1/p7_lib.c b/src/lib/libssl/src/crypto/asn1/p7_lib.c
index 846be17158..86db82cfa1 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_lib.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_lib.c
@@ -152,7 +152,7 @@ PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
152 { 152 {
153 if ((*a)->asn1 != NULL) 153 if ((*a)->asn1 != NULL)
154 { 154 {
155 Free((char *)(*a)->asn1); 155 Free((*a)->asn1);
156 (*a)->asn1=NULL; 156 (*a)->asn1=NULL;
157 } 157 }
158 (*a)->length=0; 158 (*a)->length=0;
@@ -251,7 +251,7 @@ void PKCS7_free(PKCS7 *a)
251 { 251 {
252 ASN1_OBJECT_free(a->type); 252 ASN1_OBJECT_free(a->type);
253 } 253 }
254 Free((char *)(char *)a); 254 Free(a);
255 } 255 }
256 256
257void PKCS7_content_free(PKCS7 *a) 257void PKCS7_content_free(PKCS7 *a)
@@ -259,7 +259,7 @@ void PKCS7_content_free(PKCS7 *a)
259 if(a == NULL) 259 if(a == NULL)
260 return; 260 return;
261 261
262 if (a->asn1 != NULL) Free((char *)a->asn1); 262 if (a->asn1 != NULL) Free(a->asn1);
263 263
264 if (a->d.ptr != NULL) 264 if (a->d.ptr != NULL)
265 { 265 {
@@ -268,7 +268,7 @@ void PKCS7_content_free(PKCS7 *a)
268 switch (OBJ_obj2nid(a->type)) 268 switch (OBJ_obj2nid(a->type))
269 { 269 {
270 case NID_pkcs7_data: 270 case NID_pkcs7_data:
271 ASN1_OCTET_STRING_free(a->d.data); 271 M_ASN1_OCTET_STRING_free(a->d.data);
272 break; 272 break;
273 case NID_pkcs7_signed: 273 case NID_pkcs7_signed:
274 PKCS7_SIGNED_free(a->d.sign); 274 PKCS7_SIGNED_free(a->d.sign);
diff --git a/src/lib/libssl/src/crypto/asn1/p7_recip.c b/src/lib/libssl/src/crypto/asn1/p7_recip.c
index 9fda4f20d4..b1abfa3b8f 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_recip.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_recip.c
@@ -101,10 +101,10 @@ PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO); 103 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); 105 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
106 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new); 106 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new);
107 M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new); 107 M_ASN1_New(ret->enc_key,M_ASN1_OCTET_STRING_new);
108 ret->cert=NULL; 108 ret->cert=NULL;
109 return(ret); 109 return(ret);
110 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW); 110 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW);
@@ -113,10 +113,10 @@ PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void)
113void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a) 113void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a)
114 { 114 {
115 if (a == NULL) return; 115 if (a == NULL) return;
116 ASN1_INTEGER_free(a->version); 116 M_ASN1_INTEGER_free(a->version);
117 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); 117 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
118 X509_ALGOR_free(a->key_enc_algor); 118 X509_ALGOR_free(a->key_enc_algor);
119 ASN1_OCTET_STRING_free(a->enc_key); 119 M_ASN1_OCTET_STRING_free(a->enc_key);
120 if (a->cert != NULL) X509_free(a->cert); 120 if (a->cert != NULL) X509_free(a->cert);
121 Free(a); 121 Free(a);
122 } 122 }
diff --git a/src/lib/libssl/src/crypto/asn1/p7_s_e.c b/src/lib/libssl/src/crypto/asn1/p7_s_e.c
index 90946695c9..3d18fedf8e 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_s_e.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_s_e.c
@@ -119,7 +119,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
119 ASN1_CTX c; 119 ASN1_CTX c;
120 120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE); 121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new); 122 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
123 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null); 123 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null);
124 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null); 124 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null);
125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
@@ -133,7 +133,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
133void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a) 133void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a)
134 { 134 {
135 if (a == NULL) return; 135 if (a == NULL) return;
136 ASN1_INTEGER_free(a->version); 136 M_ASN1_INTEGER_free(a->version);
137 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); 137 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
138 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free); 138 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free);
139 PKCS7_ENC_CONTENT_free(a->enc_data); 139 PKCS7_ENC_CONTENT_free(a->enc_data);
diff --git a/src/lib/libssl/src/crypto/asn1/p7_signd.c b/src/lib/libssl/src/crypto/asn1/p7_signd.c
index 74f0f522e1..f6f16a8715 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_signd.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_signd.c
@@ -112,7 +112,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
112 ASN1_CTX c; 112 ASN1_CTX c;
113 113
114 M_ASN1_New_Malloc(ret,PKCS7_SIGNED); 114 M_ASN1_New_Malloc(ret,PKCS7_SIGNED);
115 M_ASN1_New(ret->version,ASN1_INTEGER_new); 115 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
116 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null); 116 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null);
117 M_ASN1_New(ret->contents,PKCS7_new); 117 M_ASN1_New(ret->contents,PKCS7_new);
118 ret->cert=NULL; 118 ret->cert=NULL;
@@ -125,7 +125,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
125void PKCS7_SIGNED_free(PKCS7_SIGNED *a) 125void PKCS7_SIGNED_free(PKCS7_SIGNED *a)
126 { 126 {
127 if (a == NULL) return; 127 if (a == NULL) return;
128 ASN1_INTEGER_free(a->version); 128 M_ASN1_INTEGER_free(a->version);
129 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free); 129 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free);
130 PKCS7_free(a->contents); 130 PKCS7_free(a->contents);
131 sk_X509_pop_free(a->cert,X509_free); 131 sk_X509_pop_free(a->cert,X509_free);
diff --git a/src/lib/libssl/src/crypto/asn1/p7_signi.c b/src/lib/libssl/src/crypto/asn1/p7_signi.c
index 21132ef4dd..f74658ffe6 100644
--- a/src/lib/libssl/src/crypto/asn1/p7_signi.c
+++ b/src/lib/libssl/src/crypto/asn1/p7_signi.c
@@ -119,12 +119,12 @@ PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void)
119 ASN1_CTX c; 119 ASN1_CTX c;
120 120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO); 121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new); 122 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); 123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new); 124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new);
125 ret->auth_attr=NULL; 125 ret->auth_attr=NULL;
126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new); 126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new);
127 M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new); 127 M_ASN1_New(ret->enc_digest,M_ASN1_OCTET_STRING_new);
128 ret->unauth_attr=NULL; 128 ret->unauth_attr=NULL;
129 ret->pkey=NULL; 129 ret->pkey=NULL;
130 return(ret); 130 return(ret);
@@ -134,16 +134,16 @@ PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void)
134void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a) 134void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a)
135 { 135 {
136 if (a == NULL) return; 136 if (a == NULL) return;
137 ASN1_INTEGER_free(a->version); 137 M_ASN1_INTEGER_free(a->version);
138 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); 138 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
139 X509_ALGOR_free(a->digest_alg); 139 X509_ALGOR_free(a->digest_alg);
140 sk_X509_ATTRIBUTE_pop_free(a->auth_attr,X509_ATTRIBUTE_free); 140 sk_X509_ATTRIBUTE_pop_free(a->auth_attr,X509_ATTRIBUTE_free);
141 X509_ALGOR_free(a->digest_enc_alg); 141 X509_ALGOR_free(a->digest_enc_alg);
142 ASN1_OCTET_STRING_free(a->enc_digest); 142 M_ASN1_OCTET_STRING_free(a->enc_digest);
143 sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free); 143 sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free);
144 if (a->pkey != NULL) 144 if (a->pkey != NULL)
145 EVP_PKEY_free(a->pkey); 145 EVP_PKEY_free(a->pkey);
146 Free((char *)a); 146 Free(a);
147 } 147 }
148 148
149IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO) 149IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO)
diff --git a/src/lib/libssl/src/crypto/asn1/p8_key.c b/src/lib/libssl/src/crypto/asn1/p8_key.c
new file mode 100644
index 0000000000..0b24374627
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p8_key.c
@@ -0,0 +1,131 @@
1/* crypto/asn1/p8_key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_Malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 Free(a);
130 }
131
diff --git a/src/lib/libssl/src/crypto/asn1/p8_pkey.c b/src/lib/libssl/src/crypto/asn1/p8_pkey.c
index aa9a4f6c96..59cfbe7f28 100644
--- a/src/lib/libssl/src/crypto/asn1/p8_pkey.c
+++ b/src/lib/libssl/src/crypto/asn1/p8_pkey.c
@@ -88,7 +88,7 @@ PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void)
88 PKCS8_PRIV_KEY_INFO *ret=NULL; 88 PKCS8_PRIV_KEY_INFO *ret=NULL;
89 ASN1_CTX c; 89 ASN1_CTX c;
90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO); 90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO);
91 M_ASN1_New (ret->version, ASN1_INTEGER_new); 91 M_ASN1_New (ret->version, M_ASN1_INTEGER_new);
92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new); 92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new);
93 M_ASN1_New (ret->pkey, ASN1_TYPE_new); 93 M_ASN1_New (ret->pkey, ASN1_TYPE_new);
94 ret->attributes = NULL; 94 ret->attributes = NULL;
@@ -109,15 +109,13 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes, 109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,
110 d2i_X509_ATTRIBUTE, 110 d2i_X509_ATTRIBUTE,
111 X509_ATTRIBUTE_free, 0); 111 X509_ATTRIBUTE_free, 0);
112 if (ASN1_TYPE_get(ret->pkey) == V_ASN1_SEQUENCE)
113 ret->broken = PKCS8_NO_OCTET;
114 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO); 112 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);
115} 113}
116 114
117void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a) 115void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a)
118{ 116{
119 if (a == NULL) return; 117 if (a == NULL) return;
120 ASN1_INTEGER_free (a->version); 118 M_ASN1_INTEGER_free (a->version);
121 X509_ALGOR_free(a->pkeyalg); 119 X509_ALGOR_free(a->pkeyalg);
122 /* Clear sensitive data */ 120 /* Clear sensitive data */
123 if (a->pkey->value.octet_string) 121 if (a->pkey->value.octet_string)
diff --git a/src/lib/libssl/src/crypto/asn1/pkcs8.c b/src/lib/libssl/src/crypto/asn1/pkcs8.c
index 29c4ea6a29..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/asn1/pkcs8.c
+++ b/src/lib/libssl/src/crypto/asn1/pkcs8.c
@@ -1,131 +0,0 @@
1/* crypto/asn1/pkcs8.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_Malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 Free((char *)a);
130 }
131
diff --git a/src/lib/libssl/src/crypto/asn1/t_bitst.c b/src/lib/libssl/src/crypto/asn1/t_bitst.c
new file mode 100644
index 0000000000..8ee789f082
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/t_bitst.c
@@ -0,0 +1,99 @@
1/* t_bitst.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/x509v3.h>
63
64int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
65 BIT_STRING_BITNAME *tbl, int indent)
66{
67 BIT_STRING_BITNAME *bnam;
68 char first = 1;
69 BIO_printf(out, "%*s", indent, "");
70 for(bnam = tbl; bnam->lname; bnam++) {
71 if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
72 if(!first) BIO_puts(out, ", ");
73 BIO_puts(out, bnam->lname);
74 first = 0;
75 }
76 }
77 BIO_puts(out, "\n");
78 return 1;
79}
80
81int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
82 BIT_STRING_BITNAME *tbl)
83{
84 int bitnum;
85 bitnum = ASN1_BIT_STRING_num_asc(name, tbl);
86 if(bitnum < 0) return 0;
87 if(bs) ASN1_BIT_STRING_set_bit(bs, bitnum, value);
88 return 1;
89}
90
91int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl)
92{
93 BIT_STRING_BITNAME *bnam;
94 for(bnam = tbl; bnam->lname; bnam++) {
95 if(!strcmp(bnam->sname, name) ||
96 !strcmp(bnam->lname, name) ) return bnam->bitnum;
97 }
98 return -1;
99}
diff --git a/src/lib/libssl/src/crypto/asn1/t_crl.c b/src/lib/libssl/src/crypto/asn1/t_crl.c
index c2e447ce6f..d78e4a8f88 100644
--- a/src/lib/libssl/src/crypto/asn1/t_crl.c
+++ b/src/lib/libssl/src/crypto/asn1/t_crl.c
@@ -160,7 +160,7 @@ static void ext_print(BIO *out, X509_EXTENSION *ex)
160 BIO_printf(out, ": %s\n", j ? "critical":"",""); 160 BIO_printf(out, ": %s\n", j ? "critical":"","");
161 if(!X509V3_EXT_print(out, ex, 0, 16)) { 161 if(!X509V3_EXT_print(out, ex, 0, 16)) {
162 BIO_printf(out, "%16s", ""); 162 BIO_printf(out, "%16s", "");
163 ASN1_OCTET_STRING_print(out,ex->value); 163 M_ASN1_OCTET_STRING_print(out,ex->value);
164 } 164 }
165 BIO_write(out,"\n",1); 165 BIO_write(out,"\n",1);
166} 166}
diff --git a/src/lib/libssl/src/crypto/asn1/t_pkey.c b/src/lib/libssl/src/crypto/asn1/t_pkey.c
index 0dc6e30c3d..e570ed1c47 100644
--- a/src/lib/libssl/src/crypto/asn1/t_pkey.c
+++ b/src/lib/libssl/src/crypto/asn1/t_pkey.c
@@ -133,7 +133,7 @@ int RSA_print(BIO *bp, RSA *x, int off)
133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err; 133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err;
134 ret=1; 134 ret=1;
135err: 135err:
136 if (m != NULL) Free((char *)m); 136 if (m != NULL) Free(m);
137 return(ret); 137 return(ret);
138 } 138 }
139#endif /* NO_RSA */ 139#endif /* NO_RSA */
@@ -204,7 +204,7 @@ int DSA_print(BIO *bp, DSA *x, int off)
204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err; 204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err;
205 ret=1; 205 ret=1;
206err: 206err:
207 if (m != NULL) Free((char *)m); 207 if (m != NULL) Free(m);
208 return(ret); 208 return(ret);
209 } 209 }
210#endif /* !NO_DSA */ 210#endif /* !NO_DSA */
@@ -298,7 +298,7 @@ int DHparams_print(BIO *bp, DH *x)
298 if (!print(bp,"generator:",x->g,m,4)) goto err; 298 if (!print(bp,"generator:",x->g,m,4)) goto err;
299 if (x->length != 0) 299 if (x->length != 0)
300 { 300 {
301 if (BIO_printf(bp," recomented-private-length: %d bits\n", 301 if (BIO_printf(bp," recommended-private-length: %d bits\n",
302 (int)x->length) <= 0) goto err; 302 (int)x->length) <= 0) goto err;
303 } 303 }
304 ret=1; 304 ret=1;
@@ -307,7 +307,7 @@ int DHparams_print(BIO *bp, DH *x)
307err: 307err:
308 DHerr(DH_F_DHPARAMS_PRINT,reason); 308 DHerr(DH_F_DHPARAMS_PRINT,reason);
309 } 309 }
310 if (m != NULL) Free((char *)m); 310 if (m != NULL) Free(m);
311 return(ret); 311 return(ret);
312 } 312 }
313#endif 313#endif
@@ -352,7 +352,7 @@ int DSAparams_print(BIO *bp, DSA *x)
352 if (!print(bp,"g:",x->g,m,4)) goto err; 352 if (!print(bp,"g:",x->g,m,4)) goto err;
353 ret=1; 353 ret=1;
354err: 354err:
355 if (m != NULL) Free((char *)m); 355 if (m != NULL) Free(m);
356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason); 356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason);
357 return(ret); 357 return(ret);
358 } 358 }
diff --git a/src/lib/libssl/src/crypto/asn1/t_req.c b/src/lib/libssl/src/crypto/asn1/t_req.c
index bdd749436a..81dd6355a8 100644
--- a/src/lib/libssl/src/crypto/asn1/t_req.c
+++ b/src/lib/libssl/src/crypto/asn1/t_req.c
@@ -62,6 +62,7 @@
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/x509v3.h>
65 66
66#ifndef NO_FP_API 67#ifndef NO_FP_API
67int X509_REQ_print_fp(FILE *fp, X509_REQ *x) 68int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
@@ -90,6 +91,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
90 X509_REQ_INFO *ri; 91 X509_REQ_INFO *ri;
91 EVP_PKEY *pkey; 92 EVP_PKEY *pkey;
92 STACK_OF(X509_ATTRIBUTE) *sk; 93 STACK_OF(X509_ATTRIBUTE) *sk;
94 STACK_OF(X509_EXTENSION) *exts;
93 char str[128]; 95 char str[128];
94 96
95 ri=x->req_info; 97 ri=x->req_info;
@@ -161,6 +163,8 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
161 int j,type=0,count=1,ii=0; 163 int j,type=0,count=1,ii=0;
162 164
163 a=sk_X509_ATTRIBUTE_value(sk,i); 165 a=sk_X509_ATTRIBUTE_value(sk,i);
166 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
167 continue;
164 sprintf(str,"%12s",""); 168 sprintf(str,"%12s","");
165 if (BIO_puts(bp,str) <= 0) goto err; 169 if (BIO_puts(bp,str) <= 0) goto err;
166 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 170 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
@@ -201,6 +205,29 @@ get_next:
201 } 205 }
202 } 206 }
203 207
208 exts = X509_REQ_get_extensions(x);
209 if(exts) {
210 BIO_printf(bp,"%8sRequested Extensions:\n","");
211 for (i=0; i<sk_X509_EXTENSION_num(exts); i++) {
212 ASN1_OBJECT *obj;
213 X509_EXTENSION *ex;
214 int j;
215 ex=sk_X509_EXTENSION_value(exts, i);
216 if (BIO_printf(bp,"%12s","") <= 0) goto err;
217 obj=X509_EXTENSION_get_object(ex);
218 i2a_ASN1_OBJECT(bp,obj);
219 j=X509_EXTENSION_get_critical(ex);
220 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
221 goto err;
222 if(!X509V3_EXT_print(bp, ex, 0, 16)) {
223 BIO_printf(bp, "%16s", "");
224 M_ASN1_OCTET_STRING_print(bp,ex->value);
225 }
226 if (BIO_write(bp,"\n",1) <= 0) goto err;
227 }
228 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
229 }
230
204 i=OBJ_obj2nid(x->sig_alg->algorithm); 231 i=OBJ_obj2nid(x->sig_alg->algorithm);
205 sprintf(str,"%4sSignature Algorithm: %s","", 232 sprintf(str,"%4sSignature Algorithm: %s","",
206 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); 233 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
diff --git a/src/lib/libssl/src/crypto/asn1/t_spki.c b/src/lib/libssl/src/crypto/asn1/t_spki.c
new file mode 100644
index 0000000000..d708434fca
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/t_spki.c
@@ -0,0 +1,116 @@
1/* t_spki.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/x509.h>
62#include <openssl/asn1_mac.h>
63
64/* Print out an SPKI */
65
66int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
67{
68 EVP_PKEY *pkey;
69 ASN1_IA5STRING *chal;
70 int i, n;
71 char *s;
72 BIO_printf(out, "Netscape SPKI:\n");
73 i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm);
74 BIO_printf(out," Public Key Algorithm: %s\n",
75 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
76 pkey = X509_PUBKEY_get(spki->spkac->pubkey);
77 if(!pkey) BIO_printf(out, " Unable to load public key\n");
78 else {
79#ifndef NO_RSA
80 if (pkey->type == EVP_PKEY_RSA)
81 {
82 BIO_printf(out," RSA Public Key: (%d bit)\n",
83 BN_num_bits(pkey->pkey.rsa->n));
84 RSA_print(out,pkey->pkey.rsa,2);
85 }
86 else
87#endif
88#ifndef NO_DSA
89 if (pkey->type == EVP_PKEY_DSA)
90 {
91 BIO_printf(out," DSA Public Key:\n");
92 DSA_print(out,pkey->pkey.dsa,2);
93 }
94 else
95#endif
96 BIO_printf(out," Unknown Public Key:\n");
97 EVP_PKEY_free(pkey);
98 }
99 chal = spki->spkac->challenge;
100 if(chal->length)
101 BIO_printf(out, " Challenge String: %s\n", chal->data);
102 i=OBJ_obj2nid(spki->sig_algor->algorithm);
103 BIO_printf(out," Signature Algorithm: %s",
104 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
105
106 n=spki->signature->length;
107 s=(char *)spki->signature->data;
108 for (i=0; i<n; i++)
109 {
110 if ((i%18) == 0) BIO_write(out,"\n ",7);
111 BIO_printf(out,"%02x%s",(unsigned char)s[i],
112 ((i+1) == n)?"":":");
113 }
114 BIO_write(out,"\n",1);
115 return 1;
116}
diff --git a/src/lib/libssl/src/crypto/asn1/t_x509.c b/src/lib/libssl/src/crypto/asn1/t_x509.c
index 42f4d498cf..6ee1065ce9 100644
--- a/src/lib/libssl/src/crypto/asn1/t_x509.c
+++ b/src/lib/libssl/src/crypto/asn1/t_x509.c
@@ -188,11 +188,7 @@ int X509_print(BIO *bp, X509 *x)
188 BIO_printf(bp,"%8sX509v3 extensions:\n",""); 188 BIO_printf(bp,"%8sX509v3 extensions:\n","");
189 for (i=0; i<n; i++) 189 for (i=0; i<n; i++)
190 { 190 {
191#if 0
192 int data_type,pack_type;
193#endif
194 ASN1_OBJECT *obj; 191 ASN1_OBJECT *obj;
195
196 ex=X509_get_ext(x,i); 192 ex=X509_get_ext(x,i);
197 if (BIO_printf(bp,"%12s","") <= 0) goto err; 193 if (BIO_printf(bp,"%12s","") <= 0) goto err;
198 obj=X509_EXTENSION_get_object(ex); 194 obj=X509_EXTENSION_get_object(ex);
@@ -203,7 +199,7 @@ int X509_print(BIO *bp, X509 *x)
203 if(!X509V3_EXT_print(bp, ex, 0, 16)) 199 if(!X509V3_EXT_print(bp, ex, 0, 16))
204 { 200 {
205 BIO_printf(bp, "%16s", ""); 201 BIO_printf(bp, "%16s", "");
206 ASN1_OCTET_STRING_print(bp,ex->value); 202 M_ASN1_OCTET_STRING_print(bp,ex->value);
207 } 203 }
208 if (BIO_write(bp,"\n",1) <= 0) goto err; 204 if (BIO_write(bp,"\n",1) <= 0) goto err;
209 } 205 }
@@ -223,10 +219,11 @@ int X509_print(BIO *bp, X509 *x)
223 ((i+1) == n)?"":":") <= 0) goto err; 219 ((i+1) == n)?"":":") <= 0) goto err;
224 } 220 }
225 if (BIO_write(bp,"\n",1) != 1) goto err; 221 if (BIO_write(bp,"\n",1) != 1) goto err;
222 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
226 ret=1; 223 ret=1;
227err: 224err:
228 if (str != NULL) ASN1_STRING_free(str); 225 if (str != NULL) ASN1_STRING_free(str);
229 if (m != NULL) Free((char *)m); 226 if (m != NULL) Free(m);
230 return(ret); 227 return(ret);
231 } 228 }
232 229
diff --git a/src/lib/libssl/src/crypto/asn1/t_x509a.c b/src/lib/libssl/src/crypto/asn1/t_x509a.c
new file mode 100644
index 0000000000..a18ebb586c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/t_x509a.c
@@ -0,0 +1,102 @@
1/* t_x509a.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/evp.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h>
64
65/* X509_CERT_AUX and string set routines
66 */
67
68int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
69{
70 char oidstr[80], first;
71 int i;
72 if(!aux) return 1;
73 if(aux->trust) {
74 first = 1;
75 BIO_printf(out, "%*sTrusted Uses:\n%*s",
76 indent, "", indent + 2, "");
77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
78 if(!first) BIO_puts(out, ", ");
79 else first = 0;
80 OBJ_obj2txt(oidstr, 80,
81 sk_ASN1_OBJECT_value(aux->trust, i), 0);
82 BIO_puts(out, oidstr);
83 }
84 BIO_puts(out, "\n");
85 } else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, "");
86 if(aux->reject) {
87 first = 1;
88 BIO_printf(out, "%*sRejected Uses:\n%*s",
89 indent, "", indent + 2, "");
90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
91 if(!first) BIO_puts(out, ", ");
92 else first = 0;
93 OBJ_obj2txt(oidstr, 80,
94 sk_ASN1_OBJECT_value(aux->reject, i), 0);
95 BIO_puts(out, oidstr);
96 }
97 BIO_puts(out, "\n");
98 } else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
99 if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "",
100 aux->alias->data);
101 return 1;
102}
diff --git a/src/lib/libssl/src/crypto/asn1/x_algor.c b/src/lib/libssl/src/crypto/asn1/x_algor.c
index b2c20d139f..fe023842f8 100644
--- a/src/lib/libssl/src/crypto/asn1/x_algor.c
+++ b/src/lib/libssl/src/crypto/asn1/x_algor.c
@@ -111,7 +111,7 @@ void X509_ALGOR_free(X509_ALGOR *a)
111 if (a == NULL) return; 111 if (a == NULL) return;
112 ASN1_OBJECT_free(a->algorithm); 112 ASN1_OBJECT_free(a->algorithm);
113 ASN1_TYPE_free(a->parameter); 113 ASN1_TYPE_free(a->parameter);
114 Free((char *)a); 114 Free(a);
115 } 115 }
116 116
117IMPLEMENT_STACK_OF(X509_ALGOR) 117IMPLEMENT_STACK_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 a1cbebf5a5..a874df79db 100644
--- a/src/lib/libssl/src/crypto/asn1/x_attrib.c
+++ b/src/lib/libssl/src/crypto/asn1/x_attrib.c
@@ -160,6 +160,6 @@ void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a)
160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free); 160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free);
161 else 161 else
162 ASN1_TYPE_free(a->value.single); 162 ASN1_TYPE_free(a->value.single);
163 Free((char *)a); 163 Free(a);
164 } 164 }
165 165
diff --git a/src/lib/libssl/src/crypto/asn1/x_cinf.c b/src/lib/libssl/src/crypto/asn1/x_cinf.c
index fe1b18a90f..b87c8fff17 100644
--- a/src/lib/libssl/src/crypto/asn1/x_cinf.c
+++ b/src/lib/libssl/src/crypto/asn1/x_cinf.c
@@ -115,7 +115,7 @@ X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
115 { 115 {
116 if (ret->version != NULL) 116 if (ret->version != NULL)
117 { 117 {
118 ASN1_INTEGER_free(ret->version); 118 M_ASN1_INTEGER_free(ret->version);
119 ret->version=NULL; 119 ret->version=NULL;
120 } 120 }
121 } 121 }
@@ -129,12 +129,12 @@ X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
129 { 129 {
130 if (ret->issuerUID != NULL) 130 if (ret->issuerUID != NULL)
131 { 131 {
132 ASN1_BIT_STRING_free(ret->issuerUID); 132 M_ASN1_BIT_STRING_free(ret->issuerUID);
133 ret->issuerUID=NULL; 133 ret->issuerUID=NULL;
134 } 134 }
135 if (ret->subjectUID != NULL) 135 if (ret->subjectUID != NULL)
136 { 136 {
137 ASN1_BIT_STRING_free(ret->subjectUID); 137 M_ASN1_BIT_STRING_free(ret->subjectUID);
138 ret->subjectUID=NULL; 138 ret->subjectUID=NULL;
139 } 139 }
140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1, 140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
@@ -170,7 +170,7 @@ X509_CINF *X509_CINF_new(void)
170 170
171 M_ASN1_New_Malloc(ret,X509_CINF); 171 M_ASN1_New_Malloc(ret,X509_CINF);
172 ret->version=NULL; 172 ret->version=NULL;
173 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); 173 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
174 M_ASN1_New(ret->signature,X509_ALGOR_new); 174 M_ASN1_New(ret->signature,X509_ALGOR_new);
175 M_ASN1_New(ret->issuer,X509_NAME_new); 175 M_ASN1_New(ret->issuer,X509_NAME_new);
176 M_ASN1_New(ret->validity,X509_VAL_new); 176 M_ASN1_New(ret->validity,X509_VAL_new);
@@ -186,15 +186,15 @@ X509_CINF *X509_CINF_new(void)
186void X509_CINF_free(X509_CINF *a) 186void X509_CINF_free(X509_CINF *a)
187 { 187 {
188 if (a == NULL) return; 188 if (a == NULL) return;
189 ASN1_INTEGER_free(a->version); 189 M_ASN1_INTEGER_free(a->version);
190 ASN1_INTEGER_free(a->serialNumber); 190 M_ASN1_INTEGER_free(a->serialNumber);
191 X509_ALGOR_free(a->signature); 191 X509_ALGOR_free(a->signature);
192 X509_NAME_free(a->issuer); 192 X509_NAME_free(a->issuer);
193 X509_VAL_free(a->validity); 193 X509_VAL_free(a->validity);
194 X509_NAME_free(a->subject); 194 X509_NAME_free(a->subject);
195 X509_PUBKEY_free(a->key); 195 X509_PUBKEY_free(a->key);
196 ASN1_BIT_STRING_free(a->issuerUID); 196 M_ASN1_BIT_STRING_free(a->issuerUID);
197 ASN1_BIT_STRING_free(a->subjectUID); 197 M_ASN1_BIT_STRING_free(a->subjectUID);
198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
199 Free(a); 199 Free(a);
200 } 200 }
diff --git a/src/lib/libssl/src/crypto/asn1/x_crl.c b/src/lib/libssl/src/crypto/asn1/x_crl.c
index cd46bbebc2..12a42d04c7 100644
--- a/src/lib/libssl/src/crypto/asn1/x_crl.c
+++ b/src/lib/libssl/src/crypto/asn1/x_crl.c
@@ -130,9 +130,9 @@ int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **pp)
130 } 130 }
131 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR); 131 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
132 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME); 132 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
133 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_UTCTIME); 133 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_TIME);
134 if (a->nextUpdate != NULL) 134 if (a->nextUpdate != NULL)
135 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_UTCTIME); } 135 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_TIME); }
136 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked, 136 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
137 i2d_X509_REVOKED); 137 i2d_X509_REVOKED);
138 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions, 138 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
@@ -157,20 +157,16 @@ X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp,
157 157
158 if ((ver == 0) && (ret->version != NULL)) 158 if ((ver == 0) && (ret->version != NULL))
159 { 159 {
160 ASN1_INTEGER_free(ret->version); 160 M_ASN1_INTEGER_free(ret->version);
161 ret->version=NULL; 161 ret->version=NULL;
162 } 162 }
163 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR); 163 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
164 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); 164 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
165 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME); 165 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME);
166 /* Manually handle the OPTIONAL ASN1_TIME stuff */ 166 /* Manually handle the OPTIONAL ASN1_TIME stuff */
167 if(c.slen != 0 167 /* First try UTCTime */
168 && ( (M_ASN1_next & ~V_ASN1_CONSTRUCTED) == 168 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_UTCTIME, V_ASN1_UTCTIME);
169 (V_ASN1_UNIVERSAL|V_ASN1_UTCTIME) 169 /* If that doesn't work try GeneralizedTime */
170 || (M_ASN1_next & ~V_ASN1_CONSTRUCTED) ==
171 (V_ASN1_UNIVERSAL|V_ASN1_GENERALIZEDTIME) ) ) {
172 M_ASN1_D2I_get(ret->nextUpdate,d2i_ASN1_TIME);
173 }
174 if(!ret->nextUpdate) 170 if(!ret->nextUpdate)
175 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME, 171 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME,
176 V_ASN1_GENERALIZEDTIME); 172 V_ASN1_GENERALIZEDTIME);
@@ -190,20 +186,17 @@ X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp,
190 } 186 }
191 } 187 }
192 188
193 if (ver >= 1) 189 if (ret->extensions != NULL)
194 { 190 {
195 if (ret->extensions != NULL) 191 while (sk_X509_EXTENSION_num(ret->extensions))
196 { 192 X509_EXTENSION_free(
197 while (sk_X509_EXTENSION_num(ret->extensions)) 193 sk_X509_EXTENSION_pop(ret->extensions));
198 X509_EXTENSION_free(
199 sk_X509_EXTENSION_pop(ret->extensions));
200 }
201
202 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
203 d2i_X509_EXTENSION,
204 X509_EXTENSION_free,0,
205 V_ASN1_SEQUENCE);
206 } 194 }
195
196 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
197 d2i_X509_EXTENSION,
198 X509_EXTENSION_free,0,
199 V_ASN1_SEQUENCE);
207 200
208 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO); 201 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO);
209 } 202 }
@@ -245,8 +238,8 @@ X509_REVOKED *X509_REVOKED_new(void)
245 ASN1_CTX c; 238 ASN1_CTX c;
246 239
247 M_ASN1_New_Malloc(ret,X509_REVOKED); 240 M_ASN1_New_Malloc(ret,X509_REVOKED);
248 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); 241 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
249 M_ASN1_New(ret->revocationDate,ASN1_UTCTIME_new); 242 M_ASN1_New(ret->revocationDate,M_ASN1_UTCTIME_new);
250 ret->extensions=NULL; 243 ret->extensions=NULL;
251 return(ret); 244 return(ret);
252 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW); 245 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW);
@@ -261,7 +254,7 @@ X509_CRL_INFO *X509_CRL_INFO_new(void)
261 ret->version=NULL; 254 ret->version=NULL;
262 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 255 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
263 M_ASN1_New(ret->issuer,X509_NAME_new); 256 M_ASN1_New(ret->issuer,X509_NAME_new);
264 M_ASN1_New(ret->lastUpdate,ASN1_UTCTIME_new); 257 M_ASN1_New(ret->lastUpdate,M_ASN1_UTCTIME_new);
265 ret->nextUpdate=NULL; 258 ret->nextUpdate=NULL;
266 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null); 259 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null);
267 M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null); 260 M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null);
@@ -279,7 +272,7 @@ X509_CRL *X509_CRL_new(void)
279 ret->references=1; 272 ret->references=1;
280 M_ASN1_New(ret->crl,X509_CRL_INFO_new); 273 M_ASN1_New(ret->crl,X509_CRL_INFO_new);
281 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 274 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
282 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 275 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
283 return(ret); 276 return(ret);
284 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW); 277 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW);
285 } 278 }
@@ -287,8 +280,8 @@ X509_CRL *X509_CRL_new(void)
287void X509_REVOKED_free(X509_REVOKED *a) 280void X509_REVOKED_free(X509_REVOKED *a)
288 { 281 {
289 if (a == NULL) return; 282 if (a == NULL) return;
290 ASN1_INTEGER_free(a->serialNumber); 283 M_ASN1_INTEGER_free(a->serialNumber);
291 ASN1_UTCTIME_free(a->revocationDate); 284 M_ASN1_UTCTIME_free(a->revocationDate);
292 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 285 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
293 Free(a); 286 Free(a);
294 } 287 }
@@ -296,12 +289,12 @@ void X509_REVOKED_free(X509_REVOKED *a)
296void X509_CRL_INFO_free(X509_CRL_INFO *a) 289void X509_CRL_INFO_free(X509_CRL_INFO *a)
297 { 290 {
298 if (a == NULL) return; 291 if (a == NULL) return;
299 ASN1_INTEGER_free(a->version); 292 M_ASN1_INTEGER_free(a->version);
300 X509_ALGOR_free(a->sig_alg); 293 X509_ALGOR_free(a->sig_alg);
301 X509_NAME_free(a->issuer); 294 X509_NAME_free(a->issuer);
302 ASN1_UTCTIME_free(a->lastUpdate); 295 M_ASN1_UTCTIME_free(a->lastUpdate);
303 if (a->nextUpdate) 296 if (a->nextUpdate)
304 ASN1_UTCTIME_free(a->nextUpdate); 297 M_ASN1_UTCTIME_free(a->nextUpdate);
305 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free); 298 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free);
306 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 299 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
307 Free(a); 300 Free(a);
@@ -328,7 +321,7 @@ void X509_CRL_free(X509_CRL *a)
328 321
329 X509_CRL_INFO_free(a->crl); 322 X509_CRL_INFO_free(a->crl);
330 X509_ALGOR_free(a->sig_alg); 323 X509_ALGOR_free(a->sig_alg);
331 ASN1_BIT_STRING_free(a->signature); 324 M_ASN1_BIT_STRING_free(a->signature);
332 Free(a); 325 Free(a);
333 } 326 }
334 327
diff --git a/src/lib/libssl/src/crypto/asn1/x_exten.c b/src/lib/libssl/src/crypto/asn1/x_exten.c
index d5f9e1df9e..185cbd78a0 100644
--- a/src/lib/libssl/src/crypto/asn1/x_exten.c
+++ b/src/lib/libssl/src/crypto/asn1/x_exten.c
@@ -100,10 +100,6 @@ X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, unsigned char **pp,
100 M_ASN1_D2I_start_sequence(); 100 M_ASN1_D2I_start_sequence();
101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT); 101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT);
102 102
103 if ((ret->argp != NULL) && (ret->ex_free != NULL))
104 ret->ex_free(ret);
105 ret->argl=0;
106 ret->argp=NULL;
107 ret->netscape_hack=0; 103 ret->netscape_hack=0;
108 if ((c.slen != 0) && 104 if ((c.slen != 0) &&
109 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN))) 105 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN)))
@@ -126,12 +122,9 @@ X509_EXTENSION *X509_EXTENSION_new(void)
126 122
127 M_ASN1_New_Malloc(ret,X509_EXTENSION); 123 M_ASN1_New_Malloc(ret,X509_EXTENSION);
128 ret->object=OBJ_nid2obj(NID_undef); 124 ret->object=OBJ_nid2obj(NID_undef);
129 M_ASN1_New(ret->value,ASN1_OCTET_STRING_new); 125 M_ASN1_New(ret->value,M_ASN1_OCTET_STRING_new);
130 ret->critical=0; 126 ret->critical=0;
131 ret->netscape_hack=0; 127 ret->netscape_hack=0;
132 ret->argl=0L;
133 ret->argp=NULL;
134 ret->ex_free=NULL;
135 return(ret); 128 return(ret);
136 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW); 129 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW);
137 } 130 }
@@ -139,10 +132,8 @@ X509_EXTENSION *X509_EXTENSION_new(void)
139void X509_EXTENSION_free(X509_EXTENSION *a) 132void X509_EXTENSION_free(X509_EXTENSION *a)
140 { 133 {
141 if (a == NULL) return; 134 if (a == NULL) return;
142 if ((a->argp != NULL) && (a->ex_free != NULL))
143 a->ex_free(a);
144 ASN1_OBJECT_free(a->object); 135 ASN1_OBJECT_free(a->object);
145 ASN1_OCTET_STRING_free(a->value); 136 M_ASN1_OCTET_STRING_free(a->value);
146 Free((char *)a); 137 Free(a);
147 } 138 }
148 139
diff --git a/src/lib/libssl/src/crypto/asn1/x_info.c b/src/lib/libssl/src/crypto/asn1/x_info.c
index 99ce011f07..7fdc6f9dc8 100644
--- a/src/lib/libssl/src/crypto/asn1/x_info.c
+++ b/src/lib/libssl/src/crypto/asn1/x_info.c
@@ -106,7 +106,8 @@ void X509_INFO_free(X509_INFO *x)
106 if (x->x509 != NULL) X509_free(x->x509); 106 if (x->x509 != NULL) X509_free(x->x509);
107 if (x->crl != NULL) X509_CRL_free(x->crl); 107 if (x->crl != NULL) X509_CRL_free(x->crl);
108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey); 108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey);
109 Free((char *)x); 109 if (x->enc_data != NULL) Free(x->enc_data);
110 Free(x);
110 } 111 }
111 112
112IMPLEMENT_STACK_OF(X509_INFO) 113IMPLEMENT_STACK_OF(X509_INFO)
diff --git a/src/lib/libssl/src/crypto/asn1/x_name.c b/src/lib/libssl/src/crypto/asn1/x_name.c
index b09fba33fb..64baf5719d 100644
--- a/src/lib/libssl/src/crypto/asn1/x_name.c
+++ b/src/lib/libssl/src/crypto/asn1/x_name.c
@@ -253,7 +253,7 @@ void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
253 { 253 {
254 if (a == NULL) return; 254 if (a == NULL) return;
255 ASN1_OBJECT_free(a->object); 255 ASN1_OBJECT_free(a->object);
256 ASN1_BIT_STRING_free(a->value); 256 M_ASN1_BIT_STRING_free(a->value);
257 Free(a); 257 Free(a);
258 } 258 }
259 259
diff --git a/src/lib/libssl/src/crypto/asn1/x_pkey.c b/src/lib/libssl/src/crypto/asn1/x_pkey.c
index b0057eb212..fe58919dbb 100644
--- a/src/lib/libssl/src/crypto/asn1/x_pkey.c
+++ b/src/lib/libssl/src/crypto/asn1/x_pkey.c
@@ -112,7 +112,7 @@ X509_PKEY *X509_PKEY_new(void)
112 M_ASN1_New_Malloc(ret,X509_PKEY); 112 M_ASN1_New_Malloc(ret,X509_PKEY);
113 ret->version=0; 113 ret->version=0;
114 M_ASN1_New(ret->enc_algor,X509_ALGOR_new); 114 M_ASN1_New(ret->enc_algor,X509_ALGOR_new);
115 M_ASN1_New(ret->enc_pkey,ASN1_OCTET_STRING_new); 115 M_ASN1_New(ret->enc_pkey,M_ASN1_OCTET_STRING_new);
116 ret->dec_pkey=NULL; 116 ret->dec_pkey=NULL;
117 ret->key_length=0; 117 ret->key_length=0;
118 ret->key_data=NULL; 118 ret->key_data=NULL;
@@ -144,8 +144,8 @@ void X509_PKEY_free(X509_PKEY *x)
144#endif 144#endif
145 145
146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor); 146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor);
147 if (x->enc_pkey != NULL) ASN1_OCTET_STRING_free(x->enc_pkey); 147 if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey);
148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey); 148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey);
149 if ((x->key_data != NULL) && (x->key_free)) Free((char *)x->key_data); 149 if ((x->key_data != NULL) && (x->key_free)) Free(x->key_data);
150 Free((char *)(char *)x); 150 Free(x);
151 } 151 }
diff --git a/src/lib/libssl/src/crypto/asn1/x_pubkey.c b/src/lib/libssl/src/crypto/asn1/x_pubkey.c
index 4ac32c59dd..81e9815222 100644
--- a/src/lib/libssl/src/crypto/asn1/x_pubkey.c
+++ b/src/lib/libssl/src/crypto/asn1/x_pubkey.c
@@ -100,7 +100,7 @@ X509_PUBKEY *X509_PUBKEY_new(void)
100 100
101 M_ASN1_New_Malloc(ret,X509_PUBKEY); 101 M_ASN1_New_Malloc(ret,X509_PUBKEY);
102 M_ASN1_New(ret->algor,X509_ALGOR_new); 102 M_ASN1_New(ret->algor,X509_ALGOR_new);
103 M_ASN1_New(ret->public_key,ASN1_BIT_STRING_new); 103 M_ASN1_New(ret->public_key,M_ASN1_BIT_STRING_new);
104 ret->pkey=NULL; 104 ret->pkey=NULL;
105 return(ret); 105 return(ret);
106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW); 106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW);
@@ -110,9 +110,9 @@ void X509_PUBKEY_free(X509_PUBKEY *a)
110 { 110 {
111 if (a == NULL) return; 111 if (a == NULL) return;
112 X509_ALGOR_free(a->algor); 112 X509_ALGOR_free(a->algor);
113 ASN1_BIT_STRING_free(a->public_key); 113 M_ASN1_BIT_STRING_free(a->public_key);
114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey); 114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey);
115 Free((char *)a); 115 Free(a);
116 } 116 }
117 117
118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) 118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
@@ -176,7 +176,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
176 if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err; 176 if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err;
177 p=s; 177 p=s;
178 i2d_PublicKey(pkey,&p); 178 i2d_PublicKey(pkey,&p);
179 if (!ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err; 179 if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err;
180 /* Set number of unused bits to zero */ 180 /* Set number of unused bits to zero */
181 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 181 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
182 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT; 182 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT;
@@ -252,3 +252,113 @@ err:
252 return(NULL); 252 return(NULL);
253 } 253 }
254 254
255/* Now two pseudo ASN1 routines that take an EVP_PKEY structure
256 * and encode or decode as X509_PUBKEY
257 */
258
259EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, unsigned char **pp,
260 long length)
261{
262 X509_PUBKEY *xpk;
263 EVP_PKEY *pktmp;
264 xpk = d2i_X509_PUBKEY(NULL, pp, length);
265 if(!xpk) return NULL;
266 pktmp = X509_PUBKEY_get(xpk);
267 X509_PUBKEY_free(xpk);
268 if(!pktmp) return NULL;
269 if(a) {
270 EVP_PKEY_free(*a);
271 *a = pktmp;
272 }
273 return pktmp;
274}
275
276int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
277{
278 X509_PUBKEY *xpk=NULL;
279 int ret;
280 if(!a) return 0;
281 if(!X509_PUBKEY_set(&xpk, a)) return 0;
282 ret = i2d_X509_PUBKEY(xpk, pp);
283 X509_PUBKEY_free(xpk);
284 return ret;
285}
286
287/* The following are equivalents but which return RSA and DSA
288 * keys
289 */
290#ifndef NO_RSA
291RSA *d2i_RSA_PUBKEY(RSA **a, unsigned char **pp,
292 long length)
293{
294 EVP_PKEY *pkey;
295 RSA *key;
296 unsigned char *q;
297 q = *pp;
298 pkey = d2i_PUBKEY(NULL, &q, length);
299 if(!pkey) return NULL;
300 key = EVP_PKEY_get1_RSA(pkey);
301 EVP_PKEY_free(pkey);
302 if(!key) return NULL;
303 *pp = q;
304 if(a) {
305 RSA_free(*a);
306 *a = key;
307 }
308 return key;
309}
310
311int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
312{
313 EVP_PKEY *pktmp;
314 int ret;
315 if(!a) return 0;
316 pktmp = EVP_PKEY_new();
317 if(!pktmp) {
318 ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE);
319 return 0;
320 }
321 EVP_PKEY_set1_RSA(pktmp, a);
322 ret = i2d_PUBKEY(pktmp, pp);
323 EVP_PKEY_free(pktmp);
324 return ret;
325}
326#endif
327
328#ifndef NO_DSA
329DSA *d2i_DSA_PUBKEY(DSA **a, unsigned char **pp,
330 long length)
331{
332 EVP_PKEY *pkey;
333 DSA *key;
334 unsigned char *q;
335 q = *pp;
336 pkey = d2i_PUBKEY(NULL, &q, length);
337 if(!pkey) return NULL;
338 key = EVP_PKEY_get1_DSA(pkey);
339 EVP_PKEY_free(pkey);
340 if(!key) return NULL;
341 *pp = q;
342 if(a) {
343 DSA_free(*a);
344 *a = key;
345 }
346 return key;
347}
348
349int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp)
350{
351 EVP_PKEY *pktmp;
352 int ret;
353 if(!a) return 0;
354 pktmp = EVP_PKEY_new();
355 if(!pktmp) {
356 ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE);
357 return 0;
358 }
359 EVP_PKEY_set1_DSA(pktmp, a);
360 ret = i2d_PUBKEY(pktmp, pp);
361 EVP_PKEY_free(pktmp);
362 return ret;
363}
364#endif
diff --git a/src/lib/libssl/src/crypto/asn1/x_req.c b/src/lib/libssl/src/crypto/asn1/x_req.c
index 9b1d6abe64..0cd572ee73 100644
--- a/src/lib/libssl/src/crypto/asn1/x_req.c
+++ b/src/lib/libssl/src/crypto/asn1/x_req.c
@@ -73,7 +73,7 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
73 * allow some CA Software to accept the cert request. 73 * allow some CA Software to accept the cert request.
74 * It is not following the PKCS standards ... 74 * It is not following the PKCS standards ...
75 * PKCS#10 pg 5 75 * PKCS#10 pg 5
76 * attributes [0] IMPLICIT Attibutes 76 * attributes [0] IMPLICIT Attributes
77 * NOTE: no OPTIONAL ... so it *must* be there 77 * NOTE: no OPTIONAL ... so it *must* be there
78 */ 78 */
79 if (a->req_kludge) 79 if (a->req_kludge)
@@ -94,7 +94,7 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
94 /* this is a *nasty* hack reported to be required by some CA's. 94 /* this is a *nasty* hack reported to be required by some CA's.
95 * It is not following the PKCS standards ... 95 * It is not following the PKCS standards ...
96 * PKCS#10 pg 5 96 * PKCS#10 pg 5
97 * attributes [0] IMPLICIT Attibutes 97 * attributes [0] IMPLICIT Attributes
98 * NOTE: no OPTIONAL ... so it *must* be there 98 * NOTE: no OPTIONAL ... so it *must* be there
99 */ 99 */
100 if (a->req_kludge) 100 if (a->req_kludge)
@@ -126,7 +126,7 @@ X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, unsigned char **pp,
126 * have been reported as requiring it. 126 * have been reported as requiring it.
127 * It is not following the PKCS standards ... 127 * It is not following the PKCS standards ...
128 * PKCS#10 pg 5 128 * PKCS#10 pg 5
129 * attributes [0] IMPLICIT Attibutes 129 * attributes [0] IMPLICIT Attributes
130 * NOTE: no OPTIONAL ... so it *must* be there 130 * NOTE: no OPTIONAL ... so it *must* be there
131 */ 131 */
132 if (asn1_Finish(&c)) 132 if (asn1_Finish(&c))
@@ -147,7 +147,7 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
147 ASN1_CTX c; 147 ASN1_CTX c;
148 148
149 M_ASN1_New_Malloc(ret,X509_REQ_INFO); 149 M_ASN1_New_Malloc(ret,X509_REQ_INFO);
150 M_ASN1_New(ret->version,ASN1_INTEGER_new); 150 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
151 M_ASN1_New(ret->subject,X509_NAME_new); 151 M_ASN1_New(ret->subject,X509_NAME_new);
152 M_ASN1_New(ret->pubkey,X509_PUBKEY_new); 152 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
153 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null); 153 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null);
@@ -159,11 +159,11 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
159void X509_REQ_INFO_free(X509_REQ_INFO *a) 159void X509_REQ_INFO_free(X509_REQ_INFO *a)
160 { 160 {
161 if (a == NULL) return; 161 if (a == NULL) return;
162 ASN1_INTEGER_free(a->version); 162 M_ASN1_INTEGER_free(a->version);
163 X509_NAME_free(a->subject); 163 X509_NAME_free(a->subject);
164 X509_PUBKEY_free(a->pubkey); 164 X509_PUBKEY_free(a->pubkey);
165 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free); 165 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free);
166 Free((char *)a); 166 Free(a);
167 } 167 }
168 168
169int i2d_X509_REQ(X509_REQ *a, unsigned char **pp) 169int i2d_X509_REQ(X509_REQ *a, unsigned char **pp)
@@ -203,7 +203,7 @@ X509_REQ *X509_REQ_new(void)
203 ret->references=1; 203 ret->references=1;
204 M_ASN1_New(ret->req_info,X509_REQ_INFO_new); 204 M_ASN1_New(ret->req_info,X509_REQ_INFO_new);
205 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 205 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
206 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 206 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
207 return(ret); 207 return(ret);
208 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW); 208 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW);
209 } 209 }
@@ -229,8 +229,8 @@ void X509_REQ_free(X509_REQ *a)
229 229
230 X509_REQ_INFO_free(a->req_info); 230 X509_REQ_INFO_free(a->req_info);
231 X509_ALGOR_free(a->sig_alg); 231 X509_ALGOR_free(a->sig_alg);
232 ASN1_BIT_STRING_free(a->signature); 232 M_ASN1_BIT_STRING_free(a->signature);
233 Free((char *)a); 233 Free(a);
234 } 234 }
235 235
236 236
diff --git a/src/lib/libssl/src/crypto/asn1/x_sig.c b/src/lib/libssl/src/crypto/asn1/x_sig.c
index c2782d1b9c..3559bd5368 100644
--- a/src/lib/libssl/src/crypto/asn1/x_sig.c
+++ b/src/lib/libssl/src/crypto/asn1/x_sig.c
@@ -94,7 +94,7 @@ X509_SIG *X509_SIG_new(void)
94 94
95 M_ASN1_New_Malloc(ret,X509_SIG); 95 M_ASN1_New_Malloc(ret,X509_SIG);
96 M_ASN1_New(ret->algor,X509_ALGOR_new); 96 M_ASN1_New(ret->algor,X509_ALGOR_new);
97 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); 97 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
98 return(ret); 98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW); 99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW);
100 } 100 }
@@ -103,8 +103,8 @@ void X509_SIG_free(X509_SIG *a)
103 { 103 {
104 if (a == NULL) return; 104 if (a == NULL) return;
105 X509_ALGOR_free(a->algor); 105 X509_ALGOR_free(a->algor);
106 ASN1_OCTET_STRING_free(a->digest); 106 M_ASN1_OCTET_STRING_free(a->digest);
107 Free((char *)a); 107 Free(a);
108 } 108 }
109 109
110 110
diff --git a/src/lib/libssl/src/crypto/asn1/x_spki.c b/src/lib/libssl/src/crypto/asn1/x_spki.c
index 43e0023839..8f5e7e6380 100644
--- a/src/lib/libssl/src/crypto/asn1/x_spki.c
+++ b/src/lib/libssl/src/crypto/asn1/x_spki.c
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59 /* This module was send to me my Pat Richards <patr@x509.com> who 59 /* This module was send to me my Pat Richards <patr@x509.com> who
60 * wrote it. It is under my Copyright with his permision 60 * wrote it. It is under my Copyright with his permission
61 */ 61 */
62 62
63#include <stdio.h> 63#include <stdio.h>
@@ -99,7 +99,7 @@ NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void)
99 99
100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC); 100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC);
101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new); 101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
102 M_ASN1_New(ret->challenge,ASN1_IA5STRING_new); 102 M_ASN1_New(ret->challenge,M_ASN1_IA5STRING_new);
103 return(ret); 103 return(ret);
104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW); 104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW);
105 } 105 }
@@ -108,8 +108,8 @@ void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a)
108 { 108 {
109 if (a == NULL) return; 109 if (a == NULL) return;
110 X509_PUBKEY_free(a->pubkey); 110 X509_PUBKEY_free(a->pubkey);
111 ASN1_IA5STRING_free(a->challenge); 111 M_ASN1_IA5STRING_free(a->challenge);
112 Free((char *)a); 112 Free(a);
113 } 113 }
114 114
115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp) 115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp)
@@ -150,7 +150,7 @@ NETSCAPE_SPKI *NETSCAPE_SPKI_new(void)
150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI); 150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI);
151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new); 151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new);
152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new); 152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new);
153 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 153 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
154 return(ret); 154 return(ret);
155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW); 155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW);
156 } 156 }
@@ -160,7 +160,7 @@ void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a)
160 if (a == NULL) return; 160 if (a == NULL) return;
161 NETSCAPE_SPKAC_free(a->spkac); 161 NETSCAPE_SPKAC_free(a->spkac);
162 X509_ALGOR_free(a->sig_algor); 162 X509_ALGOR_free(a->sig_algor);
163 ASN1_BIT_STRING_free(a->signature); 163 M_ASN1_BIT_STRING_free(a->signature);
164 Free((char *)a); 164 Free(a);
165 } 165 }
166 166
diff --git a/src/lib/libssl/src/crypto/asn1/x_val.c b/src/lib/libssl/src/crypto/asn1/x_val.c
index 84d6f7ca4d..1a2f49ffdf 100644
--- a/src/lib/libssl/src/crypto/asn1/x_val.c
+++ b/src/lib/libssl/src/crypto/asn1/x_val.c
@@ -93,8 +93,8 @@ X509_VAL *X509_VAL_new(void)
93 ASN1_CTX c; 93 ASN1_CTX c;
94 94
95 M_ASN1_New_Malloc(ret,X509_VAL); 95 M_ASN1_New_Malloc(ret,X509_VAL);
96 M_ASN1_New(ret->notBefore,ASN1_TIME_new); 96 M_ASN1_New(ret->notBefore,M_ASN1_TIME_new);
97 M_ASN1_New(ret->notAfter,ASN1_TIME_new); 97 M_ASN1_New(ret->notAfter,M_ASN1_TIME_new);
98 return(ret); 98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW); 99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW);
100 } 100 }
@@ -102,8 +102,8 @@ X509_VAL *X509_VAL_new(void)
102void X509_VAL_free(X509_VAL *a) 102void X509_VAL_free(X509_VAL *a)
103 { 103 {
104 if (a == NULL) return; 104 if (a == NULL) return;
105 ASN1_TIME_free(a->notBefore); 105 M_ASN1_TIME_free(a->notBefore);
106 ASN1_TIME_free(a->notAfter); 106 M_ASN1_TIME_free(a->notAfter);
107 Free((char *)a); 107 Free(a);
108 } 108 }
109 109
diff --git a/src/lib/libssl/src/crypto/asn1/x_x509.c b/src/lib/libssl/src/crypto/asn1/x_x509.c
index 7abf6b2a6b..11e564ea30 100644
--- a/src/lib/libssl/src/crypto/asn1/x_x509.c
+++ b/src/lib/libssl/src/crypto/asn1/x_x509.c
@@ -62,6 +62,9 @@
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65static int x509_meth_num = 0;
66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_meth = NULL;
67
65static ASN1_METHOD meth={ 68static ASN1_METHOD meth={
66 (int (*)()) i2d_X509, 69 (int (*)()) i2d_X509,
67 (char *(*)())d2i_X509, 70 (char *(*)())d2i_X509,
@@ -113,10 +116,13 @@ X509 *X509_new(void)
113 M_ASN1_New_Malloc(ret,X509); 116 M_ASN1_New_Malloc(ret,X509);
114 ret->references=1; 117 ret->references=1;
115 ret->valid=0; 118 ret->valid=0;
119 ret->ex_flags = 0;
116 ret->name=NULL; 120 ret->name=NULL;
121 ret->aux=NULL;
117 M_ASN1_New(ret->cert_info,X509_CINF_new); 122 M_ASN1_New(ret->cert_info,X509_CINF_new);
118 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 123 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
119 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 124 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
125 CRYPTO_new_ex_data(x509_meth, ret, &ret->ex_data);
120 return(ret); 126 return(ret);
121 M_ASN1_New_Error(ASN1_F_X509_NEW); 127 M_ASN1_New_Error(ASN1_F_X509_NEW);
122 } 128 }
@@ -140,12 +146,65 @@ void X509_free(X509 *a)
140 } 146 }
141#endif 147#endif
142 148
143 /* CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); */ 149 CRYPTO_free_ex_data(x509_meth,a,&a->ex_data);
144 X509_CINF_free(a->cert_info); 150 X509_CINF_free(a->cert_info);
145 X509_ALGOR_free(a->sig_alg); 151 X509_ALGOR_free(a->sig_alg);
146 ASN1_BIT_STRING_free(a->signature); 152 M_ASN1_BIT_STRING_free(a->signature);
153 X509_CERT_AUX_free(a->aux);
147 154
148 if (a->name != NULL) Free(a->name); 155 if (a->name != NULL) Free(a->name);
149 Free((char *)a); 156 Free(a);
157 }
158
159int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
160 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
161 {
162 x509_meth_num++;
163 return(CRYPTO_get_ex_new_index(x509_meth_num-1,
164 &x509_meth,argl,argp,new_func,dup_func,free_func));
165 }
166
167int X509_set_ex_data(X509 *r, int idx, void *arg)
168 {
169 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
150 } 170 }
151 171
172void *X509_get_ex_data(X509 *r, int idx)
173 {
174 return(CRYPTO_get_ex_data(&r->ex_data,idx));
175 }
176
177/* X509_AUX ASN1 routines. X509_AUX is the name given to
178 * a certificate with extra info tagged on the end. Since these
179 * functions set how a certificate is trusted they should only
180 * be used when the certificate comes from a reliable source
181 * such as local storage.
182 *
183 */
184
185X509 *d2i_X509_AUX(X509 **a, unsigned char **pp, long length)
186{
187 unsigned char *q;
188 X509 *ret;
189 /* Save start position */
190 q = *pp;
191 ret = d2i_X509(a, pp, length);
192 /* If certificate unreadable then forget it */
193 if(!ret) return NULL;
194 /* update length */
195 length -= *pp - q;
196 if(!length) return ret;
197 if(!d2i_X509_CERT_AUX(&ret->aux, pp, length)) goto err;
198 return ret;
199 err:
200 X509_free(ret);
201 return NULL;
202}
203
204int i2d_X509_AUX(X509 *a, unsigned char **pp)
205{
206 int length;
207 length = i2d_X509(a, pp);
208 if(a) length += i2d_X509_CERT_AUX(a->aux, pp);
209 return length;
210}
diff --git a/src/lib/libssl/src/crypto/asn1/x_x509a.c b/src/lib/libssl/src/crypto/asn1/x_x509a.c
new file mode 100644
index 0000000000..b9987ea968
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/x_x509a.c
@@ -0,0 +1,200 @@
1/* a_x509a.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/evp.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h>
64
65/* X509_CERT_AUX routines. These are used to encode additional
66 * user modifiable data about a certificate. This data is
67 * appended to the X509 encoding when the *_X509_AUX routines
68 * are used. This means that the "traditional" X509 routines
69 * will simply ignore the extra data.
70 */
71
72static X509_CERT_AUX *aux_get(X509 *x);
73
74X509_CERT_AUX *d2i_X509_CERT_AUX(X509_CERT_AUX **a, unsigned char **pp, long length)
75{
76 M_ASN1_D2I_vars(a, X509_CERT_AUX *, X509_CERT_AUX_new);
77
78 M_ASN1_D2I_Init();
79 M_ASN1_D2I_start_sequence();
80
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 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
129 M_ASN1_I2D_seq_total();
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
141static X509_CERT_AUX *aux_get(X509 *x)
142{
143 if(!x) return NULL;
144 if(!x->aux && !(x->aux = X509_CERT_AUX_new())) return NULL;
145 return x->aux;
146}
147
148int X509_alias_set1(X509 *x, unsigned char *name, int len)
149{
150 X509_CERT_AUX *aux;
151 if(!(aux = aux_get(x))) return 0;
152 if(!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) return 0;
153 return ASN1_STRING_set(aux->alias, name, len);
154}
155
156unsigned char *X509_alias_get0(X509 *x, int *len)
157{
158 if(!x->aux || !x->aux->alias) return NULL;
159 if(len) *len = x->aux->alias->length;
160 return x->aux->alias->data;
161}
162
163int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
164{
165 X509_CERT_AUX *aux;
166 ASN1_OBJECT *objtmp;
167 if(!(objtmp = OBJ_dup(obj))) return 0;
168 if(!(aux = aux_get(x))) return 0;
169 if(!aux->trust
170 && !(aux->trust = sk_ASN1_OBJECT_new_null())) return 0;
171 return sk_ASN1_OBJECT_push(aux->trust, objtmp);
172}
173
174int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
175{
176 X509_CERT_AUX *aux;
177 ASN1_OBJECT *objtmp;
178 if(!(objtmp = OBJ_dup(obj))) return 0;
179 if(!(aux = aux_get(x))) return 0;
180 if(!aux->reject
181 && !(aux->reject = sk_ASN1_OBJECT_new_null())) return 0;
182 return sk_ASN1_OBJECT_push(aux->reject, objtmp);
183}
184
185void X509_trust_clear(X509 *x)
186{
187 if(x->aux && x->aux->trust) {
188 sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free);
189 x->aux->trust = NULL;
190 }
191}
192
193void X509_reject_clear(X509 *x)
194{
195 if(x->aux && x->aux->reject) {
196 sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free);
197 x->aux->reject = NULL;
198 }
199}
200
diff --git a/src/lib/libssl/src/crypto/bf/bf_cbc.c b/src/lib/libssl/src/crypto/bf/bf_cbc.c
index 95d1cdcdf9..f949629dc6 100644
--- a/src/lib/libssl/src/crypto/bf/bf_cbc.c
+++ b/src/lib/libssl/src/crypto/bf/bf_cbc.c
@@ -59,8 +59,8 @@
59#include <openssl/blowfish.h> 59#include <openssl/blowfish.h>
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 62void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
63 BF_KEY *ks, unsigned char *iv, int encrypt) 63 const BF_KEY *schedule, unsigned char *ivec, int encrypt)
64 { 64 {
65 register BF_LONG tin0,tin1; 65 register BF_LONG tin0,tin1;
66 register BF_LONG tout0,tout1,xor0,xor1; 66 register BF_LONG tout0,tout1,xor0,xor1;
@@ -69,9 +69,9 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
69 69
70 if (encrypt) 70 if (encrypt)
71 { 71 {
72 n2l(iv,tout0); 72 n2l(ivec,tout0);
73 n2l(iv,tout1); 73 n2l(ivec,tout1);
74 iv-=8; 74 ivec-=8;
75 for (l-=8; l>=0; l-=8) 75 for (l-=8; l>=0; l-=8)
76 { 76 {
77 n2l(in,tin0); 77 n2l(in,tin0);
@@ -80,7 +80,7 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
80 tin1^=tout1; 80 tin1^=tout1;
81 tin[0]=tin0; 81 tin[0]=tin0;
82 tin[1]=tin1; 82 tin[1]=tin1;
83 BF_encrypt(tin,ks); 83 BF_encrypt(tin,schedule);
84 tout0=tin[0]; 84 tout0=tin[0];
85 tout1=tin[1]; 85 tout1=tin[1];
86 l2n(tout0,out); 86 l2n(tout0,out);
@@ -93,27 +93,27 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
93 tin1^=tout1; 93 tin1^=tout1;
94 tin[0]=tin0; 94 tin[0]=tin0;
95 tin[1]=tin1; 95 tin[1]=tin1;
96 BF_encrypt(tin,ks); 96 BF_encrypt(tin,schedule);
97 tout0=tin[0]; 97 tout0=tin[0];
98 tout1=tin[1]; 98 tout1=tin[1];
99 l2n(tout0,out); 99 l2n(tout0,out);
100 l2n(tout1,out); 100 l2n(tout1,out);
101 } 101 }
102 l2n(tout0,iv); 102 l2n(tout0,ivec);
103 l2n(tout1,iv); 103 l2n(tout1,ivec);
104 } 104 }
105 else 105 else
106 { 106 {
107 n2l(iv,xor0); 107 n2l(ivec,xor0);
108 n2l(iv,xor1); 108 n2l(ivec,xor1);
109 iv-=8; 109 ivec-=8;
110 for (l-=8; l>=0; l-=8) 110 for (l-=8; l>=0; l-=8)
111 { 111 {
112 n2l(in,tin0); 112 n2l(in,tin0);
113 n2l(in,tin1); 113 n2l(in,tin1);
114 tin[0]=tin0; 114 tin[0]=tin0;
115 tin[1]=tin1; 115 tin[1]=tin1;
116 BF_decrypt(tin,ks); 116 BF_decrypt(tin,schedule);
117 tout0=tin[0]^xor0; 117 tout0=tin[0]^xor0;
118 tout1=tin[1]^xor1; 118 tout1=tin[1]^xor1;
119 l2n(tout0,out); 119 l2n(tout0,out);
@@ -127,15 +127,15 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
127 n2l(in,tin1); 127 n2l(in,tin1);
128 tin[0]=tin0; 128 tin[0]=tin0;
129 tin[1]=tin1; 129 tin[1]=tin1;
130 BF_decrypt(tin,ks); 130 BF_decrypt(tin,schedule);
131 tout0=tin[0]^xor0; 131 tout0=tin[0]^xor0;
132 tout1=tin[1]^xor1; 132 tout1=tin[1]^xor1;
133 l2nn(tout0,tout1,out,l+8); 133 l2nn(tout0,tout1,out,l+8);
134 xor0=tin0; 134 xor0=tin0;
135 xor1=tin1; 135 xor1=tin1;
136 } 136 }
137 l2n(xor0,iv); 137 l2n(xor0,ivec);
138 l2n(xor1,iv); 138 l2n(xor1,ivec);
139 } 139 }
140 tin0=tin1=tout0=tout1=xor0=xor1=0; 140 tin0=tin1=tout0=tout1=xor0=xor1=0;
141 tin[0]=tin[1]=0; 141 tin[0]=tin[1]=0;
diff --git a/src/lib/libssl/src/crypto/bf/bf_cfb64.c b/src/lib/libssl/src/crypto/bf/bf_cfb64.c
index 1fb8905f49..6451c8d407 100644
--- a/src/lib/libssl/src/crypto/bf/bf_cfb64.c
+++ b/src/lib/libssl/src/crypto/bf/bf_cfb64.c
@@ -64,8 +64,8 @@
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66 66
67void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, 67void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
68 BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) 68 const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt)
69 { 69 {
70 register BF_LONG v0,v1,t; 70 register BF_LONG v0,v1,t;
71 register int n= *num; 71 register int n= *num;
diff --git a/src/lib/libssl/src/crypto/bf/bf_ecb.c b/src/lib/libssl/src/crypto/bf/bf_ecb.c
index 9f8a24cdff..341991636f 100644
--- a/src/lib/libssl/src/crypto/bf/bf_ecb.c
+++ b/src/lib/libssl/src/crypto/bf/bf_ecb.c
@@ -61,11 +61,11 @@
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' 63/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
64 * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, 64 * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
65 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) 65 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
66 */ 66 */
67 67
68const char *BF_version="BlowFish" OPENSSL_VERSION_PTEXT; 68const char *BF_version="Blowfish" OPENSSL_VERSION_PTEXT;
69 69
70const char *BF_options(void) 70const char *BF_options(void)
71 { 71 {
@@ -78,17 +78,17 @@ const char *BF_options(void)
78#endif 78#endif
79 } 79 }
80 80
81void BF_ecb_encrypt(unsigned char *in, unsigned char *out, BF_KEY *ks, 81void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
82 int encrypt) 82 const BF_KEY *key, int encrypt)
83 { 83 {
84 BF_LONG l,d[2]; 84 BF_LONG l,d[2];
85 85
86 n2l(in,l); d[0]=l; 86 n2l(in,l); d[0]=l;
87 n2l(in,l); d[1]=l; 87 n2l(in,l); d[1]=l;
88 if (encrypt) 88 if (encrypt)
89 BF_encrypt(d,ks); 89 BF_encrypt(d,key);
90 else 90 else
91 BF_decrypt(d,ks); 91 BF_decrypt(d,key);
92 l=d[0]; l2n(l,out); 92 l=d[0]; l2n(l,out);
93 l=d[1]; l2n(l,out); 93 l=d[1]; l2n(l,out);
94 l=d[0]=d[1]=0; 94 l=d[0]=d[1]=0;
diff --git a/src/lib/libssl/src/crypto/bf/bf_enc.c b/src/lib/libssl/src/crypto/bf/bf_enc.c
index ee01834561..b380acf959 100644
--- a/src/lib/libssl/src/crypto/bf/bf_enc.c
+++ b/src/lib/libssl/src/crypto/bf/bf_enc.c
@@ -60,7 +60,7 @@
60#include "bf_locl.h" 60#include "bf_locl.h"
61 61
62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' 62/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
63 * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, 63 * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
64 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) 64 * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
65 */ 65 */
66 66
@@ -69,10 +69,11 @@
69to modify the code. 69to modify the code.
70#endif 70#endif
71 71
72void BF_encrypt(BF_LONG *data, BF_KEY *key) 72void BF_encrypt(BF_LONG *data, const BF_KEY *key)
73 { 73 {
74#ifndef BF_PTR2 74#ifndef BF_PTR2
75 register BF_LONG l,r,*p,*s; 75 register BF_LONG l,r;
76 const register BF_LONG *p,*s;
76 77
77 p=key->P; 78 p=key->P;
78 s= &(key->S[0]); 79 s= &(key->S[0]);
@@ -145,10 +146,11 @@ void BF_encrypt(BF_LONG *data, BF_KEY *key)
145 146
146#ifndef BF_DEFAULT_OPTIONS 147#ifndef BF_DEFAULT_OPTIONS
147 148
148void BF_decrypt(BF_LONG *data, BF_KEY *key) 149void BF_decrypt(BF_LONG *data, const BF_KEY *key)
149 { 150 {
150#ifndef BF_PTR2 151#ifndef BF_PTR2
151 register BF_LONG l,r,*p,*s; 152 register BF_LONG l,r;
153 const register BF_LONG *p,*s;
152 154
153 p=key->P; 155 p=key->P;
154 s= &(key->S[0]); 156 s= &(key->S[0]);
@@ -219,8 +221,8 @@ void BF_decrypt(BF_LONG *data, BF_KEY *key)
219#endif 221#endif
220 } 222 }
221 223
222void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 224void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
223 BF_KEY *ks, unsigned char *iv, int encrypt) 225 const BF_KEY *schedule, unsigned char *ivec, int encrypt)
224 { 226 {
225 register BF_LONG tin0,tin1; 227 register BF_LONG tin0,tin1;
226 register BF_LONG tout0,tout1,xor0,xor1; 228 register BF_LONG tout0,tout1,xor0,xor1;
@@ -229,9 +231,9 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
229 231
230 if (encrypt) 232 if (encrypt)
231 { 233 {
232 n2l(iv,tout0); 234 n2l(ivec,tout0);
233 n2l(iv,tout1); 235 n2l(ivec,tout1);
234 iv-=8; 236 ivec-=8;
235 for (l-=8; l>=0; l-=8) 237 for (l-=8; l>=0; l-=8)
236 { 238 {
237 n2l(in,tin0); 239 n2l(in,tin0);
@@ -240,7 +242,7 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
240 tin1^=tout1; 242 tin1^=tout1;
241 tin[0]=tin0; 243 tin[0]=tin0;
242 tin[1]=tin1; 244 tin[1]=tin1;
243 BF_encrypt(tin,ks); 245 BF_encrypt(tin,schedule);
244 tout0=tin[0]; 246 tout0=tin[0];
245 tout1=tin[1]; 247 tout1=tin[1];
246 l2n(tout0,out); 248 l2n(tout0,out);
@@ -253,27 +255,27 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
253 tin1^=tout1; 255 tin1^=tout1;
254 tin[0]=tin0; 256 tin[0]=tin0;
255 tin[1]=tin1; 257 tin[1]=tin1;
256 BF_encrypt(tin,ks); 258 BF_encrypt(tin,schedule);
257 tout0=tin[0]; 259 tout0=tin[0];
258 tout1=tin[1]; 260 tout1=tin[1];
259 l2n(tout0,out); 261 l2n(tout0,out);
260 l2n(tout1,out); 262 l2n(tout1,out);
261 } 263 }
262 l2n(tout0,iv); 264 l2n(tout0,ivec);
263 l2n(tout1,iv); 265 l2n(tout1,ivec);
264 } 266 }
265 else 267 else
266 { 268 {
267 n2l(iv,xor0); 269 n2l(ivec,xor0);
268 n2l(iv,xor1); 270 n2l(ivec,xor1);
269 iv-=8; 271 ivec-=8;
270 for (l-=8; l>=0; l-=8) 272 for (l-=8; l>=0; l-=8)
271 { 273 {
272 n2l(in,tin0); 274 n2l(in,tin0);
273 n2l(in,tin1); 275 n2l(in,tin1);
274 tin[0]=tin0; 276 tin[0]=tin0;
275 tin[1]=tin1; 277 tin[1]=tin1;
276 BF_decrypt(tin,ks); 278 BF_decrypt(tin,schedule);
277 tout0=tin[0]^xor0; 279 tout0=tin[0]^xor0;
278 tout1=tin[1]^xor1; 280 tout1=tin[1]^xor1;
279 l2n(tout0,out); 281 l2n(tout0,out);
@@ -287,15 +289,15 @@ void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
287 n2l(in,tin1); 289 n2l(in,tin1);
288 tin[0]=tin0; 290 tin[0]=tin0;
289 tin[1]=tin1; 291 tin[1]=tin1;
290 BF_decrypt(tin,ks); 292 BF_decrypt(tin,schedule);
291 tout0=tin[0]^xor0; 293 tout0=tin[0]^xor0;
292 tout1=tin[1]^xor1; 294 tout1=tin[1]^xor1;
293 l2nn(tout0,tout1,out,l+8); 295 l2nn(tout0,tout1,out,l+8);
294 xor0=tin0; 296 xor0=tin0;
295 xor1=tin1; 297 xor1=tin1;
296 } 298 }
297 l2n(xor0,iv); 299 l2n(xor0,ivec);
298 l2n(xor1,iv); 300 l2n(xor1,ivec);
299 } 301 }
300 tin0=tin1=tout0=tout1=xor0=xor1=0; 302 tin0=tin1=tout0=tout1=xor0=xor1=0;
301 tin[0]=tin[1]=0; 303 tin[0]=tin[1]=0;
diff --git a/src/lib/libssl/src/crypto/bf/bf_locl.h b/src/lib/libssl/src/crypto/bf/bf_locl.h
index 05756b5d3b..cc7c3ec992 100644
--- a/src/lib/libssl/src/crypto/bf/bf_locl.h
+++ b/src/lib/libssl/src/crypto/bf/bf_locl.h
@@ -148,7 +148,7 @@
148 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ 148 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
149 *((c)++)=(unsigned char)(((l) )&0xff)) 149 *((c)++)=(unsigned char)(((l) )&0xff))
150 150
151/* This is actually a big endian algorithm, the most significate byte 151/* This is actually a big endian algorithm, the most significant byte
152 * is used to lookup array 0 */ 152 * is used to lookup array 0 */
153 153
154#if defined(BF_PTR2) 154#if defined(BF_PTR2)
@@ -183,8 +183,8 @@
183 183
184/* 184/*
185 * This is normally very good on RISC platforms where normally you 185 * This is normally very good on RISC platforms where normally you
186 * have to explicitely "multiplicate" array index by sizeof(BF_LONG) 186 * have to explicitly "multiply" array index by sizeof(BF_LONG)
187 * in order to caclulate the effective address. This implementation 187 * in order to calculate the effective address. This implementation
188 * excuses CPU from this extra work. Power[PC] uses should have most 188 * excuses CPU from this extra work. Power[PC] uses should have most
189 * fun as (R>>BF_i)&BF_M gets folded into a single instruction, namely 189 * fun as (R>>BF_i)&BF_M gets folded into a single instruction, namely
190 * rlwinm. So let'em double-check if their compiler does it. 190 * rlwinm. So let'em double-check if their compiler does it.
diff --git a/src/lib/libssl/src/crypto/bf/bf_ofb64.c b/src/lib/libssl/src/crypto/bf/bf_ofb64.c
index 8ceb8d9bda..f2a9ff6e41 100644
--- a/src/lib/libssl/src/crypto/bf/bf_ofb64.c
+++ b/src/lib/libssl/src/crypto/bf/bf_ofb64.c
@@ -63,8 +63,8 @@
63 * used. The extra state information to record how much of the 63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, 66void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
67 BF_KEY *schedule, unsigned char *ivec, int *num) 67 const BF_KEY *schedule, unsigned char *ivec, int *num)
68 { 68 {
69 register BF_LONG v0,v1,t; 69 register BF_LONG v0,v1,t;
70 register int n= *num; 70 register int n= *num;
diff --git a/src/lib/libssl/src/crypto/bf/bf_opts.c b/src/lib/libssl/src/crypto/bf/bf_opts.c
index 5f330cc53c..bbe32b28c9 100644
--- a/src/lib/libssl/src/crypto/bf/bf_opts.c
+++ b/src/lib/libssl/src/crypto/bf/bf_opts.c
@@ -242,7 +242,7 @@ int main(int argc, char **argv)
242 } 242 }
243 243
244#ifndef TIMES 244#ifndef TIMES
245 fprintf(stderr,"To get the most acurate results, try to run this\n"); 245 fprintf(stderr,"To get the most accurate results, try to run this\n");
246 fprintf(stderr,"program when this computer is idle.\n"); 246 fprintf(stderr,"program when this computer is idle.\n");
247#endif 247#endif
248 248
diff --git a/src/lib/libssl/src/crypto/bf/bf_pi.h b/src/lib/libssl/src/crypto/bf/bf_pi.h
index 417b935538..9949513c68 100644
--- a/src/lib/libssl/src/crypto/bf/bf_pi.h
+++ b/src/lib/libssl/src/crypto/bf/bf_pi.h
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59static BF_KEY bf_init= { 59static const BF_KEY bf_init= {
60 { 60 {
61 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L, 61 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L,
62 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L, 62 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L,
diff --git a/src/lib/libssl/src/crypto/bf/bf_skey.c b/src/lib/libssl/src/crypto/bf/bf_skey.c
index eefa8e6f51..4d6a232fe0 100644
--- a/src/lib/libssl/src/crypto/bf/bf_skey.c
+++ b/src/lib/libssl/src/crypto/bf/bf_skey.c
@@ -62,11 +62,11 @@
62#include "bf_locl.h" 62#include "bf_locl.h"
63#include "bf_pi.h" 63#include "bf_pi.h"
64 64
65void BF_set_key(BF_KEY *key, int len, unsigned char *data) 65void BF_set_key(BF_KEY *key, int len, const unsigned char *data)
66 { 66 {
67 int i; 67 int i;
68 BF_LONG *p,ri,in[2]; 68 BF_LONG *p,ri,in[2];
69 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((char *)key,(char *)&bf_init,sizeof(BF_KEY));
diff --git a/src/lib/libssl/src/crypto/bf/bfspeed.c b/src/lib/libssl/src/crypto/bf/bfspeed.c
index 9b893e92cc..ecc9dff4e4 100644
--- a/src/lib/libssl/src/crypto/bf/bfspeed.c
+++ b/src/lib/libssl/src/crypto/bf/bfspeed.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libssl/src/crypto/bf/bftest.c b/src/lib/libssl/src/crypto/bf/bftest.c
index 6ecd2609a9..5695250195 100644
--- a/src/lib/libssl/src/crypto/bf/bftest.c
+++ b/src/lib/libssl/src/crypto/bf/bftest.c
@@ -76,18 +76,18 @@ int main(int argc, char *argv[])
76#include <openssl/ebcdic.h> 76#include <openssl/ebcdic.h>
77#endif 77#endif
78 78
79char *bf_key[2]={ 79static char *bf_key[2]={
80 "abcdefghijklmnopqrstuvwxyz", 80 "abcdefghijklmnopqrstuvwxyz",
81 "Who is John Galt?" 81 "Who is John Galt?"
82 }; 82 };
83 83
84/* big endian */ 84/* big endian */
85BF_LONG bf_plain[2][2]={ 85static BF_LONG bf_plain[2][2]={
86 {0x424c4f57L,0x46495348L}, 86 {0x424c4f57L,0x46495348L},
87 {0xfedcba98L,0x76543210L} 87 {0xfedcba98L,0x76543210L}
88 }; 88 };
89 89
90BF_LONG bf_cipher[2][2]={ 90static BF_LONG bf_cipher[2][2]={
91 {0x324ed0feL,0xf413a203L}, 91 {0x324ed0feL,0xf413a203L},
92 {0xcc91732bL,0x8022f684L} 92 {0xcc91732bL,0x8022f684L}
93 }; 93 };
@@ -228,16 +228,16 @@ static unsigned char ofb64_ok[]={
228 0x63,0xC2,0xCF,0x80,0xDA}; 228 0x63,0xC2,0xCF,0x80,0xDA};
229 229
230#define KEY_TEST_NUM 25 230#define KEY_TEST_NUM 25
231unsigned char key_test[KEY_TEST_NUM]={ 231static unsigned char key_test[KEY_TEST_NUM]={
232 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87, 232 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
233 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f, 233 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
234 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, 234 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
235 0x88}; 235 0x88};
236 236
237unsigned char key_data[8]= 237static unsigned char key_data[8]=
238 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}; 238 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
239 239
240unsigned char key_out[KEY_TEST_NUM][8]={ 240static unsigned char key_out[KEY_TEST_NUM][8]={
241 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E}, 241 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E},
242 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6}, 242 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6},
243 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3}, 243 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3},
diff --git a/src/lib/libssl/src/crypto/bf/blowfish.h b/src/lib/libssl/src/crypto/bf/blowfish.h
index 02f73b2f30..78acfd63b4 100644
--- a/src/lib/libssl/src/crypto/bf/blowfish.h
+++ b/src/lib/libssl/src/crypto/bf/blowfish.h
@@ -103,17 +103,19 @@ typedef struct bf_key_st
103 } BF_KEY; 103 } BF_KEY;
104 104
105 105
106void BF_set_key(BF_KEY *key, int len, unsigned char *data); 106void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
107void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key, 107
108 int enc); 108void BF_encrypt(BF_LONG *data,const BF_KEY *key);
109void BF_encrypt(BF_LONG *data,BF_KEY *key); 109void BF_decrypt(BF_LONG *data,const BF_KEY *key);
110void BF_decrypt(BF_LONG *data,BF_KEY *key); 110
111void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 111void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
112 BF_KEY *ks, unsigned char *iv, int enc); 112 const BF_KEY *key, int enc);
113void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, 113void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
114 BF_KEY *schedule, unsigned char *ivec, int *num, int enc); 114 const BF_KEY *schedule, unsigned char *ivec, int enc);
115void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, 115void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
116 BF_KEY *schedule, unsigned char *ivec, int *num); 116 const BF_KEY *schedule, unsigned char *ivec, int *num, int enc);
117void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
118 const BF_KEY *schedule, unsigned char *ivec, int *num);
117const char *BF_options(void); 119const char *BF_options(void);
118 120
119#ifdef __cplusplus 121#ifdef __cplusplus
diff --git a/src/lib/libssl/src/crypto/bio/Makefile.ssl b/src/lib/libssl/src/crypto/bio/Makefile.ssl
index d9c381d263..2e7480ead9 100644
--- a/src/lib/libssl/src/crypto/bio/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/bio/Makefile.ssl
@@ -90,17 +90,20 @@ b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
90b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 90b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
91b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 91b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
92b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 92b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
93b_dump.o: ../../include/openssl/stack.h ../cryptlib.h 93b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
94b_dump.o: ../cryptlib.h
94b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 95b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
95b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 96b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
96b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 97b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
97b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 98b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
98b_print.o: ../../include/openssl/stack.h ../cryptlib.h 99b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
100b_print.o: ../cryptlib.h
99b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 101b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
100b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 102b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
101b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 103b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 104b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
103b_sock.o: ../../include/openssl/stack.h ../cryptlib.h 105b_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
106b_sock.o: ../cryptlib.h
104bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 107bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
105bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 108bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
106bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 109bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -151,60 +154,65 @@ bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
151bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 154bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
152bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 155bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
153bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 156bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
154bio_cb.o: ../../include/openssl/stack.h ../cryptlib.h 157bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
158bio_cb.o: ../cryptlib.h
155bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 159bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
156bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h 160bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h
157bio_err.o: ../../include/openssl/stack.h 161bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
158bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 162bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
159bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 163bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
160bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 164bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
161bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 165bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
162bio_lib.o: ../../include/openssl/stack.h ../cryptlib.h 166bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
167bio_lib.o: ../cryptlib.h
163bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
164bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 169bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
165bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 170bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
166bss_acpt.o: ../../include/openssl/opensslconf.h 171bss_acpt.o: ../../include/openssl/opensslconf.h
167bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 172bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
168bss_acpt.o: ../cryptlib.h 173bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h
169bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 174bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
170bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h 175bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h
171bss_bio.o: ../../include/openssl/stack.h 176bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
172bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 177bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
173bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 178bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
174bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 179bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
175bss_conn.o: ../../include/openssl/opensslconf.h 180bss_conn.o: ../../include/openssl/opensslconf.h
176bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 181bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
177bss_conn.o: ../cryptlib.h 182bss_conn.o: ../../include/openssl/stack.h ../cryptlib.h
178bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 183bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
179bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 184bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
180bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 185bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
181bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 186bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
182bss_fd.o: ../../include/openssl/stack.h ../cryptlib.h bss_sock.c 187bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
188bss_fd.o: ../cryptlib.h bss_sock.c
183bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 189bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
184bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 190bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
185bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 191bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186bss_file.o: ../../include/openssl/opensslconf.h 192bss_file.o: ../../include/openssl/opensslconf.h
187bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 193bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
188bss_file.o: ../cryptlib.h 194bss_file.o: ../../include/openssl/stack.h ../cryptlib.h
189bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 195bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
190bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 196bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
191bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 197bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
192bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 198bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
193bss_log.o: ../../include/openssl/stack.h ../cryptlib.h 199bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
200bss_log.o: ../cryptlib.h
194bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 201bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
195bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 202bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
196bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 203bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
197bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 204bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
198bss_mem.o: ../../include/openssl/stack.h ../cryptlib.h 205bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
206bss_mem.o: ../cryptlib.h
199bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 207bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
200bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 208bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
201bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 209bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
202bss_null.o: ../../include/openssl/opensslconf.h 210bss_null.o: ../../include/openssl/opensslconf.h
203bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 211bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
204bss_null.o: ../cryptlib.h 212bss_null.o: ../../include/openssl/stack.h ../cryptlib.h
205bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 213bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
206bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 214bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
207bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 215bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
208bss_sock.o: ../../include/openssl/opensslconf.h 216bss_sock.o: ../../include/openssl/opensslconf.h
209bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 217bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
210bss_sock.o: ../cryptlib.h 218bss_sock.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/bio/b_dump.c b/src/lib/libssl/src/crypto/bio/b_dump.c
index a7cd828978..f5aeb237f5 100644
--- a/src/lib/libssl/src/crypto/bio/b_dump.c
+++ b/src/lib/libssl/src/crypto/bio/b_dump.c
@@ -92,7 +92,7 @@ int BIO_dump(BIO *bio, const char *s, int len)
92 if (((i*DUMP_WIDTH)+j)>=len) { 92 if (((i*DUMP_WIDTH)+j)>=len) {
93 strcat(buf," "); 93 strcat(buf," ");
94 } else { 94 } else {
95 ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; 95 ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff;
96 sprintf(tmp,"%02x%c",ch,j==7?'-':' '); 96 sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
97 strcat(buf,tmp); 97 strcat(buf,tmp);
98 } 98 }
@@ -101,7 +101,7 @@ int BIO_dump(BIO *bio, const char *s, int len)
101 for(j=0;j<DUMP_WIDTH;j++) { 101 for(j=0;j<DUMP_WIDTH;j++) {
102 if (((i*DUMP_WIDTH)+j)>=len) 102 if (((i*DUMP_WIDTH)+j)>=len)
103 break; 103 break;
104 ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; 104 ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff;
105#ifndef CHARSET_EBCDIC 105#ifndef CHARSET_EBCDIC
106 sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); 106 sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
107#else 107#else
diff --git a/src/lib/libssl/src/crypto/bio/b_print.c b/src/lib/libssl/src/crypto/bio/b_print.c
index f448004298..2a5e8b58c9 100644
--- a/src/lib/libssl/src/crypto/bio/b_print.c
+++ b/src/lib/libssl/src/crypto/bio/b_print.c
@@ -62,26 +62,649 @@
62 62
63#include <stdio.h> 63#include <stdio.h>
64#include <stdarg.h> 64#include <stdarg.h>
65#include <string.h>
66#include <ctype.h>
65#include "cryptlib.h" 67#include "cryptlib.h"
68#ifndef NO_SYS_TYPES_H
69#include <sys/types.h>
70#endif
66#include <openssl/bio.h> 71#include <openssl/bio.h>
67 72
73#ifdef BN_LLONG
74# ifndef HAVE_LONG_LONG
75# define HAVE_LONG_LONG
76# endif
77#endif
78
79static void dopr (char *buffer, size_t maxlen, size_t *retlen,
80 const char *format, va_list args);
81
68int BIO_printf (BIO *bio, ...) 82int BIO_printf (BIO *bio, ...)
69 { 83 {
70 va_list args; 84 va_list args;
71 char *format; 85 char *format;
72 int ret; 86 int ret;
87 size_t retlen;
73 MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ 88 MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */
74 89
75 va_start(args, bio); 90 va_start(args, bio);
76 format=va_arg(args, char *); 91 format=va_arg(args, char *);
77 92
78 hugebuf[0]='\0'; 93 hugebuf[0]='\0';
79 94 dopr(hugebuf, sizeof(hugebuf), &retlen, format, args);
80 vsprintf(hugebuf,format,args); 95 ret=BIO_write(bio, hugebuf, (int)retlen);
81
82 ret=BIO_write(bio,hugebuf,strlen(hugebuf));
83 96
84 va_end(args); 97 va_end(args);
85 return(ret); 98 return(ret);
86 } 99 }
87 100
101/*
102 * Copyright Patrick Powell 1995
103 * This code is based on code written by Patrick Powell <papowell@astart.com>
104 * It may be used for any purpose as long as this notice remains intact
105 * on all source code distributions.
106 */
107
108/*
109 * This code contains numerious changes and enhancements which were
110 * made by lots of contributors over the last years to Patrick Powell's
111 * original code:
112 *
113 * o Patrick Powell <papowell@astart.com> (1995)
114 * o Brandon Long <blong@fiction.net> (1996, for Mutt)
115 * o Thomas Roessler <roessler@guug.de> (1998, for Mutt)
116 * o Michael Elkins <me@cs.hmc.edu> (1998, for Mutt)
117 * o Andrew Tridgell <tridge@samba.org> (1998, for Samba)
118 * o Luke Mewburn <lukem@netbsd.org> (1999, for LukemFTP)
119 * o Ralf S. Engelschall <rse@engelschall.com> (1999, for Pth)
120 */
121
122#if HAVE_LONG_DOUBLE
123#define LDOUBLE long double
124#else
125#define LDOUBLE double
126#endif
127
128#if HAVE_LONG_LONG
129#define LLONG long long
130#else
131#define LLONG long
132#endif
133
134static void fmtstr (char *, size_t *, size_t, char *, int, int, int);
135static void fmtint (char *, size_t *, size_t, LLONG, int, int, int, int);
136static void fmtfp (char *, size_t *, size_t, LDOUBLE, int, int, int);
137static void dopr_outch (char *, size_t *, size_t, int);
138
139/* format read states */
140#define DP_S_DEFAULT 0
141#define DP_S_FLAGS 1
142#define DP_S_MIN 2
143#define DP_S_DOT 3
144#define DP_S_MAX 4
145#define DP_S_MOD 5
146#define DP_S_CONV 6
147#define DP_S_DONE 7
148
149/* format flags - Bits */
150#define DP_F_MINUS (1 << 0)
151#define DP_F_PLUS (1 << 1)
152#define DP_F_SPACE (1 << 2)
153#define DP_F_NUM (1 << 3)
154#define DP_F_ZERO (1 << 4)
155#define DP_F_UP (1 << 5)
156#define DP_F_UNSIGNED (1 << 6)
157
158/* conversion flags */
159#define DP_C_SHORT 1
160#define DP_C_LONG 2
161#define DP_C_LDOUBLE 3
162#define DP_C_LLONG 4
163
164/* some handy macros */
165#define char_to_int(p) (p - '0')
166#define MAX(p,q) ((p >= q) ? p : q)
167
168static void
169dopr(
170 char *buffer,
171 size_t maxlen,
172 size_t *retlen,
173 const char *format,
174 va_list args)
175{
176 char ch;
177 LLONG value;
178 LDOUBLE fvalue;
179 char *strvalue;
180 int min;
181 int max;
182 int state;
183 int flags;
184 int cflags;
185 size_t currlen;
186
187 state = DP_S_DEFAULT;
188 flags = currlen = cflags = min = 0;
189 max = -1;
190 ch = *format++;
191
192 while (state != DP_S_DONE) {
193 if ((ch == '\0') || (currlen >= maxlen))
194 state = DP_S_DONE;
195
196 switch (state) {
197 case DP_S_DEFAULT:
198 if (ch == '%')
199 state = DP_S_FLAGS;
200 else
201 dopr_outch(buffer, &currlen, maxlen, ch);
202 ch = *format++;
203 break;
204 case DP_S_FLAGS:
205 switch (ch) {
206 case '-':
207 flags |= DP_F_MINUS;
208 ch = *format++;
209 break;
210 case '+':
211 flags |= DP_F_PLUS;
212 ch = *format++;
213 break;
214 case ' ':
215 flags |= DP_F_SPACE;
216 ch = *format++;
217 break;
218 case '#':
219 flags |= DP_F_NUM;
220 ch = *format++;
221 break;
222 case '0':
223 flags |= DP_F_ZERO;
224 ch = *format++;
225 break;
226 default:
227 state = DP_S_MIN;
228 break;
229 }
230 break;
231 case DP_S_MIN:
232 if (isdigit((unsigned char)ch)) {
233 min = 10 * min + char_to_int(ch);
234 ch = *format++;
235 } else if (ch == '*') {
236 min = va_arg(args, int);
237 ch = *format++;
238 state = DP_S_DOT;
239 } else
240 state = DP_S_DOT;
241 break;
242 case DP_S_DOT:
243 if (ch == '.') {
244 state = DP_S_MAX;
245 ch = *format++;
246 } else
247 state = DP_S_MOD;
248 break;
249 case DP_S_MAX:
250 if (isdigit((unsigned char)ch)) {
251 if (max < 0)
252 max = 0;
253 max = 10 * max + char_to_int(ch);
254 ch = *format++;
255 } else if (ch == '*') {
256 max = va_arg(args, int);
257 ch = *format++;
258 state = DP_S_MOD;
259 } else
260 state = DP_S_MOD;
261 break;
262 case DP_S_MOD:
263 switch (ch) {
264 case 'h':
265 cflags = DP_C_SHORT;
266 ch = *format++;
267 break;
268 case 'l':
269 if (*format == 'l') {
270 cflags = DP_C_LLONG;
271 format++;
272 } else
273 cflags = DP_C_LONG;
274 ch = *format++;
275 break;
276 case 'q':
277 cflags = DP_C_LLONG;
278 ch = *format++;
279 break;
280 case 'L':
281 cflags = DP_C_LDOUBLE;
282 ch = *format++;
283 break;
284 default:
285 break;
286 }
287 state = DP_S_CONV;
288 break;
289 case DP_S_CONV:
290 switch (ch) {
291 case 'd':
292 case 'i':
293 switch (cflags) {
294 case DP_C_SHORT:
295 value = (short int)va_arg(args, int);
296 break;
297 case DP_C_LONG:
298 value = va_arg(args, long int);
299 break;
300 case DP_C_LLONG:
301 value = va_arg(args, LLONG);
302 break;
303 default:
304 value = va_arg(args, int);
305 break;
306 }
307 fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags);
308 break;
309 case 'X':
310 flags |= DP_F_UP;
311 /* FALLTHROUGH */
312 case 'x':
313 case 'o':
314 case 'u':
315 flags |= DP_F_UNSIGNED;
316 switch (cflags) {
317 case DP_C_SHORT:
318 value = (unsigned short int)va_arg(args, unsigned int);
319 break;
320 case DP_C_LONG:
321 value = (LLONG) va_arg(args,
322 unsigned long int);
323 break;
324 case DP_C_LLONG:
325 value = va_arg(args, unsigned LLONG);
326 break;
327 default:
328 value = (LLONG) va_arg(args,
329 unsigned int);
330 break;
331 }
332 fmtint(buffer, &currlen, maxlen, value,
333 ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
334 min, max, flags);
335 break;
336 case 'f':
337 if (cflags == DP_C_LDOUBLE)
338 fvalue = va_arg(args, LDOUBLE);
339 else
340 fvalue = va_arg(args, double);
341 fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags);
342 break;
343 case 'E':
344 flags |= DP_F_UP;
345 case 'e':
346 if (cflags == DP_C_LDOUBLE)
347 fvalue = va_arg(args, LDOUBLE);
348 else
349 fvalue = va_arg(args, double);
350 break;
351 case 'G':
352 flags |= DP_F_UP;
353 case 'g':
354 if (cflags == DP_C_LDOUBLE)
355 fvalue = va_arg(args, LDOUBLE);
356 else
357 fvalue = va_arg(args, double);
358 break;
359 case 'c':
360 dopr_outch(buffer, &currlen, maxlen,
361 va_arg(args, int));
362 break;
363 case 's':
364 strvalue = va_arg(args, char *);
365 if (max < 0)
366 max = maxlen;
367 fmtstr(buffer, &currlen, maxlen, strvalue,
368 flags, min, max);
369 break;
370 case 'p':
371 value = (long)va_arg(args, void *);
372 fmtint(buffer, &currlen, maxlen,
373 value, 16, min, max, flags);
374 break;
375 case 'n': /* XXX */
376 if (cflags == DP_C_SHORT) {
377 short int *num;
378 num = va_arg(args, short int *);
379 *num = currlen;
380 } else if (cflags == DP_C_LONG) { /* XXX */
381 long int *num;
382 num = va_arg(args, long int *);
383 *num = (long int) currlen;
384 } else if (cflags == DP_C_LLONG) { /* XXX */
385 LLONG *num;
386 num = va_arg(args, LLONG *);
387 *num = (LLONG) currlen;
388 } else {
389 int *num;
390 num = va_arg(args, int *);
391 *num = currlen;
392 }
393 break;
394 case '%':
395 dopr_outch(buffer, &currlen, maxlen, ch);
396 break;
397 case 'w':
398 /* not supported yet, treat as next char */
399 ch = *format++;
400 break;
401 default:
402 /* unknown, skip */
403 break;
404 }
405 ch = *format++;
406 state = DP_S_DEFAULT;
407 flags = cflags = min = 0;
408 max = -1;
409 break;
410 case DP_S_DONE:
411 break;
412 default:
413 break;
414 }
415 }
416 if (currlen >= maxlen - 1)
417 currlen = maxlen - 1;
418 buffer[currlen] = '\0';
419 *retlen = currlen;
420 return;
421}
422
423static void
424fmtstr(
425 char *buffer,
426 size_t *currlen,
427 size_t maxlen,
428 char *value,
429 int flags,
430 int min,
431 int max)
432{
433 int padlen, strln;
434 int cnt = 0;
435
436 if (value == 0)
437 value = "<NULL>";
438 for (strln = 0; value[strln]; ++strln)
439 ;
440 padlen = min - strln;
441 if (padlen < 0)
442 padlen = 0;
443 if (flags & DP_F_MINUS)
444 padlen = -padlen;
445
446 while ((padlen > 0) && (cnt < max)) {
447 dopr_outch(buffer, currlen, maxlen, ' ');
448 --padlen;
449 ++cnt;
450 }
451 while (*value && (cnt < max)) {
452 dopr_outch(buffer, currlen, maxlen, *value++);
453 ++cnt;
454 }
455 while ((padlen < 0) && (cnt < max)) {
456 dopr_outch(buffer, currlen, maxlen, ' ');
457 ++padlen;
458 ++cnt;
459 }
460}
461
462static void
463fmtint(
464 char *buffer,
465 size_t *currlen,
466 size_t maxlen,
467 LLONG value,
468 int base,
469 int min,
470 int max,
471 int flags)
472{
473 int signvalue = 0;
474 unsigned LLONG uvalue;
475 char convert[20];
476 int place = 0;
477 int spadlen = 0;
478 int zpadlen = 0;
479 int caps = 0;
480
481 if (max < 0)
482 max = 0;
483 uvalue = value;
484 if (!(flags & DP_F_UNSIGNED)) {
485 if (value < 0) {
486 signvalue = '-';
487 uvalue = -value;
488 } else if (flags & DP_F_PLUS)
489 signvalue = '+';
490 else if (flags & DP_F_SPACE)
491 signvalue = ' ';
492 }
493 if (flags & DP_F_UP)
494 caps = 1;
495 do {
496 convert[place++] =
497 (caps ? "0123456789ABCDEF" : "0123456789abcdef")
498 [uvalue % (unsigned) base];
499 uvalue = (uvalue / (unsigned) base);
500 } while (uvalue && (place < 20));
501 if (place == 20)
502 place--;
503 convert[place] = 0;
504
505 zpadlen = max - place;
506 spadlen = min - MAX(max, place) - (signvalue ? 1 : 0);
507 if (zpadlen < 0)
508 zpadlen = 0;
509 if (spadlen < 0)
510 spadlen = 0;
511 if (flags & DP_F_ZERO) {
512 zpadlen = MAX(zpadlen, spadlen);
513 spadlen = 0;
514 }
515 if (flags & DP_F_MINUS)
516 spadlen = -spadlen;
517
518 /* spaces */
519 while (spadlen > 0) {
520 dopr_outch(buffer, currlen, maxlen, ' ');
521 --spadlen;
522 }
523
524 /* sign */
525 if (signvalue)
526 dopr_outch(buffer, currlen, maxlen, signvalue);
527
528 /* zeros */
529 if (zpadlen > 0) {
530 while (zpadlen > 0) {
531 dopr_outch(buffer, currlen, maxlen, '0');
532 --zpadlen;
533 }
534 }
535 /* digits */
536 while (place > 0)
537 dopr_outch(buffer, currlen, maxlen, convert[--place]);
538
539 /* left justified spaces */
540 while (spadlen < 0) {
541 dopr_outch(buffer, currlen, maxlen, ' ');
542 ++spadlen;
543 }
544 return;
545}
546
547static LDOUBLE
548abs_val(LDOUBLE value)
549{
550 LDOUBLE result = value;
551 if (value < 0)
552 result = -value;
553 return result;
554}
555
556static LDOUBLE
557pow10(int exp)
558{
559 LDOUBLE result = 1;
560 while (exp) {
561 result *= 10;
562 exp--;
563 }
564 return result;
565}
566
567static long
568round(LDOUBLE value)
569{
570 long intpart;
571 intpart = (long) value;
572 value = value - intpart;
573 if (value >= 0.5)
574 intpart++;
575 return intpart;
576}
577
578static void
579fmtfp(
580 char *buffer,
581 size_t *currlen,
582 size_t maxlen,
583 LDOUBLE fvalue,
584 int min,
585 int max,
586 int flags)
587{
588 int signvalue = 0;
589 LDOUBLE ufvalue;
590 char iconvert[20];
591 char fconvert[20];
592 int iplace = 0;
593 int fplace = 0;
594 int padlen = 0;
595 int zpadlen = 0;
596 int caps = 0;
597 long intpart;
598 long fracpart;
599
600 if (max < 0)
601 max = 6;
602 ufvalue = abs_val(fvalue);
603 if (fvalue < 0)
604 signvalue = '-';
605 else if (flags & DP_F_PLUS)
606 signvalue = '+';
607 else if (flags & DP_F_SPACE)
608 signvalue = ' ';
609
610 intpart = (long)ufvalue;
611
612 /* sorry, we only support 9 digits past the decimal because of our
613 conversion method */
614 if (max > 9)
615 max = 9;
616
617 /* we "cheat" by converting the fractional part to integer by
618 multiplying by a factor of 10 */
619 fracpart = round((pow10(max)) * (ufvalue - intpart));
620
621 if (fracpart >= pow10(max)) {
622 intpart++;
623 fracpart -= (long)pow10(max);
624 }
625
626 /* convert integer part */
627 do {
628 iconvert[iplace++] =
629 (caps ? "0123456789ABCDEF"
630 : "0123456789abcdef")[intpart % 10];
631 intpart = (intpart / 10);
632 } while (intpart && (iplace < 20));
633 if (iplace == 20)
634 iplace--;
635 iconvert[iplace] = 0;
636
637 /* convert fractional part */
638 do {
639 fconvert[fplace++] =
640 (caps ? "0123456789ABCDEF"
641 : "0123456789abcdef")[fracpart % 10];
642 fracpart = (fracpart / 10);
643 } while (fracpart && (fplace < 20));
644 if (fplace == 20)
645 fplace--;
646 fconvert[fplace] = 0;
647
648 /* -1 for decimal point, another -1 if we are printing a sign */
649 padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
650 zpadlen = max - fplace;
651 if (zpadlen < 0)
652 zpadlen = 0;
653 if (padlen < 0)
654 padlen = 0;
655 if (flags & DP_F_MINUS)
656 padlen = -padlen;
657
658 if ((flags & DP_F_ZERO) && (padlen > 0)) {
659 if (signvalue) {
660 dopr_outch(buffer, currlen, maxlen, signvalue);
661 --padlen;
662 signvalue = 0;
663 }
664 while (padlen > 0) {
665 dopr_outch(buffer, currlen, maxlen, '0');
666 --padlen;
667 }
668 }
669 while (padlen > 0) {
670 dopr_outch(buffer, currlen, maxlen, ' ');
671 --padlen;
672 }
673 if (signvalue)
674 dopr_outch(buffer, currlen, maxlen, signvalue);
675
676 while (iplace > 0)
677 dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
678
679 /*
680 * Decimal point. This should probably use locale to find the correct
681 * char to print out.
682 */
683 if (max > 0) {
684 dopr_outch(buffer, currlen, maxlen, '.');
685
686 while (fplace > 0)
687 dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
688 }
689 while (zpadlen > 0) {
690 dopr_outch(buffer, currlen, maxlen, '0');
691 --zpadlen;
692 }
693
694 while (padlen < 0) {
695 dopr_outch(buffer, currlen, maxlen, ' ');
696 ++padlen;
697 }
698}
699
700static void
701dopr_outch(
702 char *buffer,
703 size_t *currlen,
704 size_t maxlen,
705 int c)
706{
707 if (*currlen < maxlen)
708 buffer[(*currlen)++] = (char)c;
709 return;
710}
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c
index d29b29ff8b..6409f98f57 100644
--- a/src/lib/libssl/src/crypto/bio/b_sock.c
+++ b/src/lib/libssl/src/crypto/bio/b_sock.c
@@ -163,7 +163,14 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
163 else 163 else
164 { 164 {
165 CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME); 165 CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME);
166 s=getservbyname(str,"tcp"); 166 /* Note: under VMS with SOCKETSHR, it seems like the first
167 * parameter is 'char *', instead of 'const char *'
168 */
169 s=getservbyname(
170#ifndef CONST_STRICT
171 (char *)
172#endif
173 str,"tcp");
167 if(s != NULL) 174 if(s != NULL)
168 *port_ptr=ntohs((unsigned short)s->s_port); 175 *port_ptr=ntohs((unsigned short)s->s_port);
169 CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); 176 CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME);
@@ -282,12 +289,12 @@ static struct hostent *ghbn_dup(struct hostent *a)
282 289
283 j=strlen(a->h_name)+1; 290 j=strlen(a->h_name)+1;
284 if ((ret->h_name=Malloc(j)) == NULL) goto err; 291 if ((ret->h_name=Malloc(j)) == NULL) goto err;
285 memcpy((char *)ret->h_name,a->h_name,j+1); 292 memcpy((char *)ret->h_name,a->h_name,j);
286 for (i=0; a->h_aliases[i] != NULL; i++) 293 for (i=0; a->h_aliases[i] != NULL; i++)
287 { 294 {
288 j=strlen(a->h_aliases[i])+1; 295 j=strlen(a->h_aliases[i])+1;
289 if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err; 296 if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err;
290 memcpy(ret->h_aliases[i],a->h_aliases[i],j+1); 297 memcpy(ret->h_aliases[i],a->h_aliases[i],j);
291 } 298 }
292 ret->h_length=a->h_length; 299 ret->h_length=a->h_length;
293 ret->h_addrtype=a->h_addrtype; 300 ret->h_addrtype=a->h_addrtype;
@@ -327,7 +334,7 @@ static void ghbn_free(struct hostent *a)
327 Free(a->h_addr_list[i]); 334 Free(a->h_addr_list[i]);
328 Free(a->h_addr_list); 335 Free(a->h_addr_list);
329 } 336 }
330 if (a->h_name != NULL) Free((char *)a->h_name); 337 if (a->h_name != NULL) Free(a->h_name);
331 Free(a); 338 Free(a);
332 } 339 }
333 340
@@ -368,7 +375,14 @@ struct hostent *BIO_gethostbyname(const char *name)
368 if (i == GHBN_NUM) /* no hit*/ 375 if (i == GHBN_NUM) /* no hit*/
369 { 376 {
370 BIO_ghbn_miss++; 377 BIO_ghbn_miss++;
371 ret=gethostbyname(name); 378 /* Note: under VMS with SOCKETSHR, it seems like the first
379 * parameter is 'char *', instead of 'const char *'
380 */
381 ret=gethostbyname(
382#ifndef CONST_STRICT
383 (char *)
384#endif
385 name);
372 386
373 if (ret == NULL) 387 if (ret == NULL)
374 goto end; 388 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 acd8148138..ff0c9070ae 100644
--- a/src/lib/libssl/src/crypto/bio/bf_buff.c
+++ b/src/lib/libssl/src/crypto/bio/bf_buff.c
@@ -69,6 +69,7 @@ static int buffer_gets(BIO *h,char *str,int size);
69static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int buffer_new(BIO *h); 70static int buffer_new(BIO *h);
71static int buffer_free(BIO *data); 71static int buffer_free(BIO *data);
72static long buffer_callback_ctrl(BIO *h,int cmd, void (*fp)());
72#define DEFAULT_BUFFER_SIZE 1024 73#define DEFAULT_BUFFER_SIZE 1024
73 74
74static BIO_METHOD methods_buffer= 75static BIO_METHOD methods_buffer=
@@ -82,6 +83,7 @@ static BIO_METHOD methods_buffer=
82 buffer_ctrl, 83 buffer_ctrl,
83 buffer_new, 84 buffer_new,
84 buffer_free, 85 buffer_free,
86 buffer_callback_ctrl,
85 }; 87 };
86 88
87BIO_METHOD *BIO_f_buffer(void) 89BIO_METHOD *BIO_f_buffer(void)
@@ -284,6 +286,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
284 ctx->ibuf_len=0; 286 ctx->ibuf_len=0;
285 ctx->obuf_off=0; 287 ctx->obuf_off=0;
286 ctx->obuf_len=0; 288 ctx->obuf_len=0;
289 if (b->next_bio == NULL) return(0);
287 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 290 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
288 break; 291 break;
289 case BIO_CTRL_INFO: 292 case BIO_CTRL_INFO:
@@ -300,12 +303,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
300 case BIO_CTRL_WPENDING: 303 case BIO_CTRL_WPENDING:
301 ret=(long)ctx->obuf_len; 304 ret=(long)ctx->obuf_len;
302 if (ret == 0) 305 if (ret == 0)
306 {
307 if (b->next_bio == NULL) return(0);
303 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 308 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
309 }
304 break; 310 break;
305 case BIO_CTRL_PENDING: 311 case BIO_CTRL_PENDING:
306 ret=(long)ctx->ibuf_len; 312 ret=(long)ctx->ibuf_len;
307 if (ret == 0) 313 if (ret == 0)
314 {
315 if (b->next_bio == NULL) return(0);
308 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 316 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
317 }
309 break; 318 break;
310 case BIO_C_SET_BUFF_READ_DATA: 319 case BIO_C_SET_BUFF_READ_DATA:
311 if (num > ctx->ibuf_size) 320 if (num > ctx->ibuf_size)
@@ -374,12 +383,14 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
374 } 383 }
375 break; 384 break;
376 case BIO_C_DO_STATE_MACHINE: 385 case BIO_C_DO_STATE_MACHINE:
386 if (b->next_bio == NULL) return(0);
377 BIO_clear_retry_flags(b); 387 BIO_clear_retry_flags(b);
378 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 388 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
379 BIO_copy_next_retry(b); 389 BIO_copy_next_retry(b);
380 break; 390 break;
381 391
382 case BIO_CTRL_FLUSH: 392 case BIO_CTRL_FLUSH:
393 if (b->next_bio == NULL) return(0);
383 if (ctx->obuf_len <= 0) 394 if (ctx->obuf_len <= 0)
384 { 395 {
385 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 396 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
@@ -418,6 +429,7 @@ fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_
418 ret=0; 429 ret=0;
419 break; 430 break;
420 default: 431 default:
432 if (b->next_bio == NULL) return(0);
421 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 433 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
422 break; 434 break;
423 } 435 }
@@ -427,6 +439,20 @@ malloc_error:
427 return(0); 439 return(0);
428 } 440 }
429 441
442static long buffer_callback_ctrl(BIO *b, int cmd, void (*fp)())
443 {
444 long ret=1;
445
446 if (b->next_bio == NULL) return(0);
447 switch (cmd)
448 {
449 default:
450 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
451 break;
452 }
453 return(ret);
454 }
455
430static int buffer_gets(BIO *b, char *buf, int size) 456static int buffer_gets(BIO *b, char *buf, int size)
431 { 457 {
432 BIO_F_BUFFER_CTX *ctx; 458 BIO_F_BUFFER_CTX *ctx;
diff --git a/src/lib/libssl/src/crypto/bio/bf_nbio.c b/src/lib/libssl/src/crypto/bio/bf_nbio.c
index cbec2bae29..5e574b7231 100644
--- a/src/lib/libssl/src/crypto/bio/bf_nbio.c
+++ b/src/lib/libssl/src/crypto/bio/bf_nbio.c
@@ -73,6 +73,7 @@ static int nbiof_gets(BIO *h,char *str,int size);
73static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2); 73static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2);
74static int nbiof_new(BIO *h); 74static int nbiof_new(BIO *h);
75static int nbiof_free(BIO *data); 75static int nbiof_free(BIO *data);
76static long nbiof_callback_ctrl(BIO *h,int cmd,void (*fp)());
76typedef struct nbio_test_st 77typedef struct nbio_test_st
77 { 78 {
78 /* only set if we sent a 'should retry' error */ 79 /* only set if we sent a 'should retry' error */
@@ -91,6 +92,7 @@ static BIO_METHOD methods_nbiof=
91 nbiof_ctrl, 92 nbiof_ctrl,
92 nbiof_new, 93 nbiof_new,
93 nbiof_free, 94 nbiof_free,
95 nbiof_callback_ctrl,
94 }; 96 };
95 97
96BIO_METHOD *BIO_f_nbio_test(void) 98BIO_METHOD *BIO_f_nbio_test(void)
@@ -137,7 +139,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
137 139
138 BIO_clear_retry_flags(b); 140 BIO_clear_retry_flags(b);
139#if 0 141#if 0
140 RAND_bytes(&n,1); 142 RAND_pseudo_bytes(&n,1);
141 num=(n&0x07); 143 num=(n&0x07);
142 144
143 if (outl > num) outl=num; 145 if (outl > num) outl=num;
@@ -178,7 +180,7 @@ static int nbiof_write(BIO *b, char *in, int inl)
178 } 180 }
179 else 181 else
180 { 182 {
181 RAND_bytes(&n,1); 183 RAND_pseudo_bytes(&n,1);
182 num=(n&7); 184 num=(n&7);
183 } 185 }
184 186
@@ -224,6 +226,20 @@ static long nbiof_ctrl(BIO *b, int cmd, long num, char *ptr)
224 return(ret); 226 return(ret);
225 } 227 }
226 228
229static long nbiof_callback_ctrl(BIO *b, int cmd, void (*fp)())
230 {
231 long ret=1;
232
233 if (b->next_bio == NULL) return(0);
234 switch (cmd)
235 {
236 default:
237 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
238 break;
239 }
240 return(ret);
241 }
242
227static int nbiof_gets(BIO *bp, char *buf, int size) 243static int nbiof_gets(BIO *bp, char *buf, int size)
228 { 244 {
229 if (bp->next_bio == NULL) return(0); 245 if (bp->next_bio == NULL) return(0);
diff --git a/src/lib/libssl/src/crypto/bio/bf_null.c b/src/lib/libssl/src/crypto/bio/bf_null.c
index 3254a55dce..0d183a6d9a 100644
--- a/src/lib/libssl/src/crypto/bio/bf_null.c
+++ b/src/lib/libssl/src/crypto/bio/bf_null.c
@@ -72,6 +72,7 @@ static int nullf_gets(BIO *h,char *str,int size);
72static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2); 72static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2);
73static int nullf_new(BIO *h); 73static int nullf_new(BIO *h);
74static int nullf_free(BIO *data); 74static int nullf_free(BIO *data);
75static long nullf_callback_ctrl(BIO *h,int cmd,void (*fp)());
75static BIO_METHOD methods_nullf= 76static BIO_METHOD methods_nullf=
76 { 77 {
77 BIO_TYPE_NULL_FILTER, 78 BIO_TYPE_NULL_FILTER,
@@ -83,6 +84,7 @@ static BIO_METHOD methods_nullf=
83 nullf_ctrl, 84 nullf_ctrl,
84 nullf_new, 85 nullf_new,
85 nullf_free, 86 nullf_free,
87 nullf_callback_ctrl,
86 }; 88 };
87 89
88BIO_METHOD *BIO_f_null(void) 90BIO_METHOD *BIO_f_null(void)
@@ -152,6 +154,20 @@ static long nullf_ctrl(BIO *b, int cmd, long num, char *ptr)
152 return(ret); 154 return(ret);
153 } 155 }
154 156
157static long nullf_callback_ctrl(BIO *b, int cmd, void (*fp)())
158 {
159 long ret=1;
160
161 if (b->next_bio == NULL) return(0);
162 switch (cmd)
163 {
164 default:
165 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
166 break;
167 }
168 return(ret);
169 }
170
155static int nullf_gets(BIO *bp, char *buf, int size) 171static int nullf_gets(BIO *bp, char *buf, int size)
156 { 172 {
157 if (bp->next_bio == NULL) return(0); 173 if (bp->next_bio == NULL) return(0);
diff --git a/src/lib/libssl/src/crypto/bio/bio.h b/src/lib/libssl/src/crypto/bio/bio.h
index 54bf622a3b..bc08401eeb 100644
--- a/src/lib/libssl/src/crypto/bio/bio.h
+++ b/src/lib/libssl/src/crypto/bio/bio.h
@@ -76,7 +76,7 @@ extern "C" {
76#define BIO_TYPE_SOCKET (5|0x0400|0x0100) 76#define BIO_TYPE_SOCKET (5|0x0400|0x0100)
77#define BIO_TYPE_NULL (6|0x0400) 77#define BIO_TYPE_NULL (6|0x0400)
78#define BIO_TYPE_SSL (7|0x0200) 78#define BIO_TYPE_SSL (7|0x0200)
79#define BIO_TYPE_MD (8|0x0200) /* pasive filter */ 79#define BIO_TYPE_MD (8|0x0200) /* passive filter */
80#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ 80#define BIO_TYPE_BUFFER (9|0x0200) /* filter */
81#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ 81#define BIO_TYPE_CIPHER (10|0x0200) /* filter */
82#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ 82#define BIO_TYPE_BASE64 (11|0x0200) /* filter */
@@ -147,6 +147,11 @@ extern "C" {
147 147
148#define BIO_FLAGS_BASE64_NO_NL 0x100 148#define BIO_FLAGS_BASE64_NO_NL 0x100
149 149
150/* This is used with memory BIOs: it means we shouldn't free up or change the
151 * data in any way.
152 */
153#define BIO_FLAGS_MEM_RDONLY 0x200
154
150#define BIO_set_flags(b,f) ((b)->flags|=(f)) 155#define BIO_set_flags(b,f) ((b)->flags|=(f))
151#define BIO_get_flags(b) ((b)->flags) 156#define BIO_get_flags(b) ((b)->flags)
152#define BIO_set_retry_special(b) \ 157#define BIO_set_retry_special(b) \
@@ -163,7 +168,7 @@ extern "C" {
163#define BIO_get_retry_flags(b) \ 168#define BIO_get_retry_flags(b) \
164 ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) 169 ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
165 170
166/* These shouldbe used by the application to tell why we should retry */ 171/* These should be used by the application to tell why we should retry */
167#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ) 172#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
168#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE) 173#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
169#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL) 174#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
@@ -214,6 +219,7 @@ typedef struct bio_method_st
214 long (*ctrl)(); 219 long (*ctrl)();
215 int (*create)(); 220 int (*create)();
216 int (*destroy)(); 221 int (*destroy)();
222 long (*callback_ctrl)();
217 } BIO_METHOD; 223 } BIO_METHOD;
218#else 224#else
219typedef struct bio_method_st 225typedef struct bio_method_st
@@ -227,6 +233,7 @@ typedef struct bio_method_st
227 long (_far *ctrl)(); 233 long (_far *ctrl)();
228 int (_far *create)(); 234 int (_far *create)();
229 int (_far *destroy)(); 235 int (_far *destroy)();
236 long (_fat *callback_ctrl)();
230 } BIO_METHOD; 237 } BIO_METHOD;
231#endif 238#endif
232 239
@@ -278,9 +285,6 @@ typedef struct bio_f_buffer_ctx_struct
278#define BIO_CONN_S_NBIO 8 285#define BIO_CONN_S_NBIO 8
279/*#define BIO_CONN_get_param_hostname BIO_ctrl */ 286/*#define BIO_CONN_get_param_hostname BIO_ctrl */
280 287
281#define BIO_number_read(b) ((b)->num_read)
282#define BIO_number_written(b) ((b)->num_write)
283
284#define BIO_C_SET_CONNECT 100 288#define BIO_C_SET_CONNECT 100
285#define BIO_C_DO_STATE_MACHINE 101 289#define BIO_C_DO_STATE_MACHINE 101
286#define BIO_C_SET_NBIO 102 290#define BIO_C_SET_NBIO 102
@@ -325,9 +329,14 @@ typedef struct bio_f_buffer_ctx_struct
325#define BIO_C_GET_WRITE_GUARANTEE 140 329#define BIO_C_GET_WRITE_GUARANTEE 140
326#define BIO_C_GET_READ_REQUEST 141 330#define BIO_C_GET_READ_REQUEST 141
327#define BIO_C_SHUTDOWN_WR 142 331#define BIO_C_SHUTDOWN_WR 142
332#define BIO_C_NREAD0 143
333#define BIO_C_NREAD 144
334#define BIO_C_NWRITE0 145
335#define BIO_C_NWRITE 146
336#define BIO_C_RESET_READ_REQUEST 147
328 337
329 338
330#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,(char *)arg) 339#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
331#define BIO_get_app_data(s) BIO_get_ex_data(s,0) 340#define BIO_get_app_data(s) BIO_get_ex_data(s,0)
332 341
333/* BIO_s_connect() and BIO_s_socks4a_connect() */ 342/* BIO_s_connect() and BIO_s_socks4a_connect() */
@@ -366,7 +375,7 @@ typedef struct bio_f_buffer_ctx_struct
366/* BIO_set_nbio(b,n) */ 375/* BIO_set_nbio(b,n) */
367#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) 376#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
368/* BIO *BIO_get_filter_bio(BIO *bio); */ 377/* BIO *BIO_get_filter_bio(BIO *bio); */
369#define BIO_set_proxy_cb(b,cb) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(char *)(cb)) 378#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
370#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) 379#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
371#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) 380#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
372 381
@@ -445,8 +454,8 @@ int BIO_read_filename(BIO *b,const char *name);
445size_t BIO_ctrl_pending(BIO *b); 454size_t BIO_ctrl_pending(BIO *b);
446size_t BIO_ctrl_wpending(BIO *b); 455size_t BIO_ctrl_wpending(BIO *b);
447#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) 456#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
448#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(char *)cbp) 457#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(void (**)())(cbp))
449#define BIO_set_info_callback(b,cb) (int)BIO_ctrl(b,BIO_CTRL_SET_CALLBACK,0,(char *)cb) 458#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(void (*)())(cb))
450 459
451/* For the BIO_f_buffer() type */ 460/* For the BIO_f_buffer() type */
452#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) 461#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
@@ -461,8 +470,7 @@ size_t BIO_ctrl_wpending(BIO *b);
461#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) 470#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
462size_t BIO_ctrl_get_write_guarantee(BIO *b); 471size_t BIO_ctrl_get_write_guarantee(BIO *b);
463size_t BIO_ctrl_get_read_request(BIO *b); 472size_t BIO_ctrl_get_read_request(BIO *b);
464 473int BIO_ctrl_reset_read_request(BIO *b);
465
466 474
467#ifdef NO_STDIO 475#ifdef NO_STDIO
468#define NO_FP_API 476#define NO_FP_API
@@ -472,10 +480,12 @@ size_t BIO_ctrl_get_read_request(BIO *b);
472/* These two aren't currently implemented */ 480/* These two aren't currently implemented */
473/* int BIO_get_ex_num(BIO *bio); */ 481/* int BIO_get_ex_num(BIO *bio); */
474/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ 482/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
475int BIO_set_ex_data(BIO *bio,int idx,char *data); 483int BIO_set_ex_data(BIO *bio,int idx,void *data);
476char *BIO_get_ex_data(BIO *bio,int idx); 484void *BIO_get_ex_data(BIO *bio,int idx);
477int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), 485int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
478 int (*dup_func)(), void (*free_func)()); 486 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
487unsigned long BIO_number_read(BIO *bio);
488unsigned long BIO_number_written(BIO *bio);
479 489
480# if defined(WIN16) && defined(_WINDLL) 490# if defined(WIN16) && defined(_WINDLL)
481BIO_METHOD *BIO_s_file_internal(void); 491BIO_METHOD *BIO_s_file_internal(void);
@@ -500,6 +510,7 @@ int BIO_gets(BIO *bp,char *buf, int size);
500int BIO_write(BIO *b, const char *data, int len); 510int BIO_write(BIO *b, const char *data, int len);
501int BIO_puts(BIO *bp,const char *buf); 511int BIO_puts(BIO *bp,const char *buf);
502long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); 512long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
513long BIO_callback_ctrl(BIO *bp,int cmd,void (*fp)());
503char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); 514char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
504long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); 515long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
505BIO * BIO_push(BIO *b,BIO *append); 516BIO * BIO_push(BIO *b,BIO *append);
@@ -510,6 +521,11 @@ BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
510int BIO_get_retry_reason(BIO *bio); 521int BIO_get_retry_reason(BIO *bio);
511BIO * BIO_dup_chain(BIO *in); 522BIO * BIO_dup_chain(BIO *in);
512 523
524int BIO_nread0(BIO *bio, char **buf);
525int BIO_nread(BIO *bio, char **buf, int num);
526int BIO_nwrite0(BIO *bio, char **buf);
527int BIO_nwrite(BIO *bio, char **buf, int num);
528
513#ifndef WIN16 529#ifndef WIN16
514long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, 530long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
515 long argl,long ret); 531 long argl,long ret);
@@ -519,6 +535,7 @@ long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
519#endif 535#endif
520 536
521BIO_METHOD *BIO_s_mem(void); 537BIO_METHOD *BIO_s_mem(void);
538BIO *BIO_new_mem_buf(void *buf, int len);
522BIO_METHOD *BIO_s_socket(void); 539BIO_METHOD *BIO_s_socket(void);
523BIO_METHOD *BIO_s_connect(void); 540BIO_METHOD *BIO_s_connect(void);
524BIO_METHOD *BIO_s_accept(void); 541BIO_METHOD *BIO_s_accept(void);
@@ -597,11 +614,17 @@ int BIO_printf(BIO *bio, ...);
597#define BIO_F_BIO_MAKE_PAIR 121 614#define BIO_F_BIO_MAKE_PAIR 121
598#define BIO_F_BIO_NEW 108 615#define BIO_F_BIO_NEW 108
599#define BIO_F_BIO_NEW_FILE 109 616#define BIO_F_BIO_NEW_FILE 109
617#define BIO_F_BIO_NEW_MEM_BUF 126
618#define BIO_F_BIO_NREAD 123
619#define BIO_F_BIO_NREAD0 124
620#define BIO_F_BIO_NWRITE 125
621#define BIO_F_BIO_NWRITE0 122
600#define BIO_F_BIO_PUTS 110 622#define BIO_F_BIO_PUTS 110
601#define BIO_F_BIO_READ 111 623#define BIO_F_BIO_READ 111
602#define BIO_F_BIO_SOCK_INIT 112 624#define BIO_F_BIO_SOCK_INIT 112
603#define BIO_F_BIO_WRITE 113 625#define BIO_F_BIO_WRITE 113
604#define BIO_F_BUFFER_CTRL 114 626#define BIO_F_BUFFER_CTRL 114
627#define BIO_F_CONN_CTRL 127
605#define BIO_F_CONN_STATE 115 628#define BIO_F_CONN_STATE 115
606#define BIO_F_FILE_CTRL 116 629#define BIO_F_FILE_CTRL 116
607#define BIO_F_MEM_WRITE 117 630#define BIO_F_MEM_WRITE 117
@@ -634,6 +657,7 @@ int BIO_printf(BIO *bio, ...);
634#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 657#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
635#define BIO_R_UNINITIALIZED 120 658#define BIO_R_UNINITIALIZED 120
636#define BIO_R_UNSUPPORTED_METHOD 121 659#define BIO_R_UNSUPPORTED_METHOD 121
660#define BIO_R_WRITE_TO_READ_ONLY_BIO 126
637#define BIO_R_WSASTARTUP 122 661#define BIO_R_WSASTARTUP 122
638 662
639#ifdef __cplusplus 663#ifdef __cplusplus
diff --git a/src/lib/libssl/src/crypto/bio/bio_err.c b/src/lib/libssl/src/crypto/bio/bio_err.c
index 712d98a3a1..b5f07de5a0 100644
--- a/src/lib/libssl/src/crypto/bio/bio_err.c
+++ b/src/lib/libssl/src/crypto/bio/bio_err.c
@@ -77,11 +77,17 @@ static ERR_STRING_DATA BIO_str_functs[]=
77{ERR_PACK(0,BIO_F_BIO_MAKE_PAIR,0), "BIO_MAKE_PAIR"}, 77{ERR_PACK(0,BIO_F_BIO_MAKE_PAIR,0), "BIO_MAKE_PAIR"},
78{ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"}, 78{ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"},
79{ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"}, 79{ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"},
80{ERR_PACK(0,BIO_F_BIO_NEW_MEM_BUF,0), "BIO_new_mem_buf"},
81{ERR_PACK(0,BIO_F_BIO_NREAD,0), "BIO_nread"},
82{ERR_PACK(0,BIO_F_BIO_NREAD0,0), "BIO_nread0"},
83{ERR_PACK(0,BIO_F_BIO_NWRITE,0), "BIO_nwrite"},
84{ERR_PACK(0,BIO_F_BIO_NWRITE0,0), "BIO_nwrite0"},
80{ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"}, 85{ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"},
81{ERR_PACK(0,BIO_F_BIO_READ,0), "BIO_read"}, 86{ERR_PACK(0,BIO_F_BIO_READ,0), "BIO_read"},
82{ERR_PACK(0,BIO_F_BIO_SOCK_INIT,0), "BIO_sock_init"}, 87{ERR_PACK(0,BIO_F_BIO_SOCK_INIT,0), "BIO_sock_init"},
83{ERR_PACK(0,BIO_F_BIO_WRITE,0), "BIO_write"}, 88{ERR_PACK(0,BIO_F_BIO_WRITE,0), "BIO_write"},
84{ERR_PACK(0,BIO_F_BUFFER_CTRL,0), "BUFFER_CTRL"}, 89{ERR_PACK(0,BIO_F_BUFFER_CTRL,0), "BUFFER_CTRL"},
90{ERR_PACK(0,BIO_F_CONN_CTRL,0), "CONN_CTRL"},
85{ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"}, 91{ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"},
86{ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"}, 92{ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"},
87{ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"}, 93{ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"},
@@ -117,6 +123,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
117{BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"}, 123{BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"},
118{BIO_R_UNINITIALIZED ,"uninitialized"}, 124{BIO_R_UNINITIALIZED ,"uninitialized"},
119{BIO_R_UNSUPPORTED_METHOD ,"unsupported method"}, 125{BIO_R_UNSUPPORTED_METHOD ,"unsupported method"},
126{BIO_R_WRITE_TO_READ_ONLY_BIO ,"write to read only bio"},
120{BIO_R_WSASTARTUP ,"wsastartup"}, 127{BIO_R_WSASTARTUP ,"wsastartup"},
121{0,NULL} 128{0,NULL}
122 }; 129 };
diff --git a/src/lib/libssl/src/crypto/bio/bio_lib.c b/src/lib/libssl/src/crypto/bio/bio_lib.c
index b72688ea90..cf8e6150fd 100644
--- a/src/lib/libssl/src/crypto/bio/bio_lib.c
+++ b/src/lib/libssl/src/crypto/bio/bio_lib.c
@@ -63,7 +63,7 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/stack.h> 64#include <openssl/stack.h>
65 65
66static STACK *bio_meth=NULL; 66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *bio_meth=NULL;
67static int bio_meth_num=0; 67static int bio_meth_num=0;
68 68
69BIO *BIO_new(BIO_METHOD *method) 69BIO *BIO_new(BIO_METHOD *method)
@@ -100,7 +100,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method)
100 bio->references=1; 100 bio->references=1;
101 bio->num_read=0L; 101 bio->num_read=0L;
102 bio->num_write=0L; 102 bio->num_write=0L;
103 CRYPTO_new_ex_data(bio_meth,(char *)bio,&bio->ex_data); 103 CRYPTO_new_ex_data(bio_meth,bio,&bio->ex_data);
104 if (method->create != NULL) 104 if (method->create != NULL)
105 if (!method->create(bio)) 105 if (!method->create(bio))
106 return(0); 106 return(0);
@@ -129,7 +129,7 @@ int BIO_free(BIO *a)
129 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) 129 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0))
130 return(i); 130 return(i);
131 131
132 CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); 132 CRYPTO_free_ex_data(bio_meth,a,&a->ex_data);
133 133
134 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); 134 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
135 ret=a->method->destroy(a); 135 ret=a->method->destroy(a);
@@ -317,16 +317,43 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
317 return(ret); 317 return(ret);
318 } 318 }
319 319
320long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)())
321 {
322 long ret;
323 long (*cb)();
324
325 if (b == NULL) return(0);
326
327 if ((b->method == NULL) || (b->method->callback_ctrl == NULL))
328 {
329 BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD);
330 return(-2);
331 }
332
333 cb=b->callback;
334
335 if ((cb != NULL) &&
336 ((ret=cb(b,BIO_CB_CTRL,(void *)&fp,cmd,0,1L)) <= 0))
337 return(ret);
338
339 ret=b->method->callback_ctrl(b,cmd,fp);
340
341 if (cb != NULL)
342 ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,(void *)&fp,cmd,
343 0,ret);
344 return(ret);
345 }
346
320/* It is unfortunate to duplicate in functions what the BIO_(w)pending macros 347/* It is unfortunate to duplicate in functions what the BIO_(w)pending macros
321 * do; but those macros have inappropriate return type, and for interfacing 348 * do; but those macros have inappropriate return type, and for interfacing
322 * from other programming languages, C macros aren't much of a help anyway. */ 349 * from other programming languages, C macros aren't much of a help anyway. */
323size_t BIO_ctrl_pending(BIO *bio) 350size_t BIO_ctrl_pending(BIO *bio)
324 { 351 {
325 return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); 352 return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL);
326 } 353 }
327 354
328size_t BIO_ctrl_wpending(BIO *bio) 355size_t BIO_ctrl_wpending(BIO *bio)
329 { 356 {
330 return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); 357 return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL);
331 } 358 }
332 359
@@ -476,21 +503,32 @@ void BIO_copy_next_retry(BIO *b)
476 b->retry_reason=b->next_bio->retry_reason; 503 b->retry_reason=b->next_bio->retry_reason;
477 } 504 }
478 505
479int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), 506int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
480 int (*dup_func)(), void (*free_func)()) 507 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
481 { 508 {
482 bio_meth_num++; 509 bio_meth_num++;
483 return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, 510 return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth,
484 argl,argp,new_func,dup_func,free_func)); 511 argl,argp,new_func,dup_func,free_func));
485 } 512 }
486 513
487int BIO_set_ex_data(BIO *bio, int idx, char *data) 514int BIO_set_ex_data(BIO *bio, int idx, void *data)
488 { 515 {
489 return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); 516 return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data));
490 } 517 }
491 518
492char *BIO_get_ex_data(BIO *bio, int idx) 519void *BIO_get_ex_data(BIO *bio, int idx)
493 { 520 {
494 return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); 521 return(CRYPTO_get_ex_data(&(bio->ex_data),idx));
495 } 522 }
496 523
524unsigned long BIO_number_read(BIO *bio)
525{
526 if(bio) return bio->num_read;
527 return 0;
528}
529
530unsigned long BIO_number_written(BIO *bio)
531{
532 if(bio) return bio->num_write;
533 return 0;
534}
diff --git a/src/lib/libssl/src/crypto/bio/bss_acpt.c b/src/lib/libssl/src/crypto/bio/bss_acpt.c
index 47af80f76d..9afa636406 100644
--- a/src/lib/libssl/src/crypto/bio/bss_acpt.c
+++ b/src/lib/libssl/src/crypto/bio/bss_acpt.c
@@ -118,6 +118,7 @@ static BIO_METHOD methods_acceptp=
118 acpt_ctrl, 118 acpt_ctrl,
119 acpt_new, 119 acpt_new,
120 acpt_free, 120 acpt_free,
121 NULL,
121 }; 122 };
122 123
123BIO_METHOD *BIO_s_accept(void) 124BIO_METHOD *BIO_s_accept(void)
diff --git a/src/lib/libssl/src/crypto/bio/bss_bio.c b/src/lib/libssl/src/crypto/bio/bss_bio.c
index 562e9d8de2..0d0f9356f7 100644
--- a/src/lib/libssl/src/crypto/bio/bss_bio.c
+++ b/src/lib/libssl/src/crypto/bio/bss_bio.c
@@ -13,6 +13,7 @@
13#endif 13#endif
14 14
15#include <assert.h> 15#include <assert.h>
16#include <limits.h>
16#include <stdlib.h> 17#include <stdlib.h>
17#include <string.h> 18#include <string.h>
18 19
@@ -40,7 +41,8 @@ static BIO_METHOD methods_biop =
40 NULL /* no bio_gets */, 41 NULL /* no bio_gets */,
41 bio_ctrl, 42 bio_ctrl,
42 bio_new, 43 bio_new,
43 bio_free 44 bio_free,
45 NULL /* no bio_callback_ctrl */
44}; 46};
45 47
46BIO_METHOD *BIO_s_bio(void) 48BIO_METHOD *BIO_s_bio(void)
@@ -64,7 +66,7 @@ struct bio_bio_st
64 66
65 size_t request; /* valid iff peer != NULL; 0 if len != 0, 67 size_t request; /* valid iff peer != NULL; 0 if len != 0,
66 * otherwise set by peer to number of bytes 68 * otherwise set by peer to number of bytes
67 * it (unsuccesfully) tried to read, 69 * it (unsuccessfully) tried to read,
68 * never more than buffer space (size-len) warrants. */ 70 * never more than buffer space (size-len) warrants. */
69}; 71};
70 72
@@ -195,6 +197,81 @@ static int bio_read(BIO *bio, char *buf, int size_)
195 return size; 197 return size;
196 } 198 }
197 199
200/* non-copying interface: provide pointer to available data in buffer
201 * bio_nread0: return number of available bytes
202 * bio_nread: also advance index
203 * (example usage: bio_nread0(), read from buffer, bio_nread()
204 * or just bio_nread(), read from buffer)
205 */
206/* WARNING: The non-copying interface is largely untested as of yet
207 * and may contain bugs. */
208static size_t bio_nread0(BIO *bio, char **buf)
209 {
210 struct bio_bio_st *b, *peer_b;
211 size_t num;
212
213 BIO_clear_retry_flags(bio);
214
215 if (!bio->init)
216 return 0;
217
218 b = bio->ptr;
219 assert(b != NULL);
220 assert(b->peer != NULL);
221 peer_b = b->peer->ptr;
222 assert(peer_b != NULL);
223 assert(peer_b->buf != NULL);
224
225 peer_b->request = 0;
226
227 if (peer_b->len == 0)
228 {
229 char dummy;
230
231 /* avoid code duplication -- nothing available for reading */
232 return bio_read(bio, &dummy, 1); /* returns 0 or -1 */
233 }
234
235 num = peer_b->len;
236 if (peer_b->size < peer_b->offset + num)
237 /* no ring buffer wrap-around for non-copying interface */
238 num = peer_b->size - peer_b->offset;
239 assert(num > 0);
240
241 if (buf != NULL)
242 *buf = peer_b->buf + peer_b->offset;
243 return num;
244 }
245
246static size_t bio_nread(BIO *bio, char **buf, size_t num)
247 {
248 struct bio_bio_st *b, *peer_b;
249 size_t available;
250
251 available = bio_nread0(bio, buf);
252 if (num > available)
253 num = available;
254 if (num == 0)
255 return num;
256
257 b = bio->ptr;
258 peer_b = b->peer->ptr;
259
260 peer_b->len -= num;
261 if (peer_b->len)
262 {
263 peer_b->offset += num;
264 assert(peer_b->offset <= peer_b->size);
265 if (peer_b->offset == peer_b->size)
266 peer_b->offset = 0;
267 }
268 else
269 peer_b->offset = 0;
270
271 return num;
272 }
273
274
198static int bio_write(BIO *bio, char *buf, int num_) 275static int bio_write(BIO *bio, char *buf, int num_)
199 { 276 {
200 size_t num = num_; 277 size_t num = num_;
@@ -268,6 +345,78 @@ static int bio_write(BIO *bio, char *buf, int num_)
268 return num; 345 return num;
269 } 346 }
270 347
348/* non-copying interface: provide pointer to region to write to
349 * bio_nwrite0: check how much space is available
350 * bio_nwrite: also increase length
351 * (example usage: bio_nwrite0(), write to buffer, bio_nwrite()
352 * or just bio_nwrite(), write to buffer)
353 */
354static size_t bio_nwrite0(BIO *bio, char **buf)
355 {
356 struct bio_bio_st *b;
357 size_t num;
358 size_t write_offset;
359
360 BIO_clear_retry_flags(bio);
361
362 if (!bio->init)
363 return 0;
364
365 b = bio->ptr;
366 assert(b != NULL);
367 assert(b->peer != NULL);
368 assert(b->buf != NULL);
369
370 b->request = 0;
371 if (b->closed)
372 {
373 BIOerr(BIO_F_BIO_NWRITE0, BIO_R_BROKEN_PIPE);
374 return -1;
375 }
376
377 assert(b->len <= b->size);
378
379 if (b->len == b->size)
380 {
381 BIO_set_retry_write(bio);
382 return -1;
383 }
384
385 num = b->size - b->len;
386 write_offset = b->offset + b->len;
387 if (write_offset >= b->size)
388 write_offset -= b->size;
389 if (write_offset + num > b->size)
390 /* no ring buffer wrap-around for non-copying interface
391 * (to fulfil the promise by BIO_ctrl_get_write_guarantee,
392 * BIO_nwrite may have to be called twice) */
393 num = b->size - write_offset;
394
395 if (buf != NULL)
396 *buf = b->buf + write_offset;
397 assert(write_offset + num <= b->size);
398
399 return num;
400 }
401
402static size_t bio_nwrite(BIO *bio, char **buf, size_t num)
403 {
404 struct bio_bio_st *b;
405 size_t space;
406
407 space = bio_nwrite0(bio, buf);
408 if (num > space)
409 num = space;
410 if (num == 0)
411 return num;
412 b = bio->ptr;
413 assert(b != NULL);
414 b->len += num;
415 assert(b->len <= b->size);
416
417 return num;
418 }
419
271 420
272static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) 421static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
273 { 422 {
@@ -331,7 +480,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
331 480
332 case BIO_C_GET_WRITE_GUARANTEE: 481 case BIO_C_GET_WRITE_GUARANTEE:
333 /* How many bytes can the caller feed to the next write 482 /* How many bytes can the caller feed to the next write
334 * withouth having to keep any? */ 483 * without having to keep any? */
335 if (b->peer == NULL || b->closed) 484 if (b->peer == NULL || b->closed)
336 ret = 0; 485 ret = 0;
337 else 486 else
@@ -339,18 +488,42 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
339 break; 488 break;
340 489
341 case BIO_C_GET_READ_REQUEST: 490 case BIO_C_GET_READ_REQUEST:
342 /* If the peer unsuccesfully tried to read, how many bytes 491 /* If the peer unsuccessfully tried to read, how many bytes
343 * were requested? (As with BIO_CTRL_PENDING, that number 492 * were requested? (As with BIO_CTRL_PENDING, that number
344 * can usually be treated as boolean.) */ 493 * can usually be treated as boolean.) */
345 ret = (long) b->request; 494 ret = (long) b->request;
346 break; 495 break;
347 496
497 case BIO_C_RESET_READ_REQUEST:
498 /* Reset request. (Can be useful after read attempts
499 * at the other side that are meant to be non-blocking,
500 * e.g. when probing SSL_read to see if any data is
501 * available.) */
502 b->request = 0;
503 ret = 1;
504 break;
505
348 case BIO_C_SHUTDOWN_WR: 506 case BIO_C_SHUTDOWN_WR:
349 /* similar to shutdown(..., SHUT_WR) */ 507 /* similar to shutdown(..., SHUT_WR) */
350 b->closed = 1; 508 b->closed = 1;
351 ret = 1; 509 ret = 1;
352 break; 510 break;
353 511
512 case BIO_C_NREAD:
513 /* non-copying read */
514 ret = (long) bio_nread(bio, ptr, (size_t) num);
515 break;
516
517 case BIO_C_NWRITE0:
518 /* prepare for non-copying write */
519 ret = (long) bio_nwrite0(bio, ptr);
520 break;
521
522 case BIO_C_NWRITE:
523 /* non-copying write */
524 ret = (long) bio_nwrite(bio, ptr, (size_t) num);
525 break;
526
354 527
355 /* standard CTRL codes follow */ 528 /* standard CTRL codes follow */
356 529
@@ -586,3 +759,78 @@ size_t BIO_ctrl_get_read_request(BIO *bio)
586 { 759 {
587 return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL); 760 return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL);
588 } 761 }
762
763int BIO_ctrl_reset_read_request(BIO *bio)
764 {
765 return (BIO_ctrl(bio, BIO_C_RESET_READ_REQUEST, 0, NULL) != 0);
766 }
767
768
769/* BIO_nread0/nread/nwrite0/nwrite are available only for BIO pairs for now
770 * (conceivably some other BIOs could allow non-copying reads and writes too.)
771 */
772int BIO_nread0(BIO *bio, char **buf)
773 {
774 long ret;
775
776 if (!bio->init)
777 {
778 BIOerr(BIO_F_BIO_NREAD0, BIO_R_UNINITIALIZED);
779 return -2;
780 }
781
782 ret = BIO_ctrl(bio, BIO_C_NREAD0, 0, buf);
783 if (ret > INT_MAX)
784 return INT_MAX;
785 else
786 return (int) ret;
787 }
788
789int BIO_nread(BIO *bio, char **buf, int num)
790 {
791 int ret;
792
793 if (!bio->init)
794 {
795 BIOerr(BIO_F_BIO_NREAD, BIO_R_UNINITIALIZED);
796 return -2;
797 }
798
799 ret = (int) BIO_ctrl(bio, BIO_C_NREAD, num, buf);
800 if (ret > 0)
801 bio->num_read += ret;
802 return ret;
803 }
804
805int BIO_nwrite0(BIO *bio, char **buf)
806 {
807 long ret;
808
809 if (!bio->init)
810 {
811 BIOerr(BIO_F_BIO_NWRITE0, BIO_R_UNINITIALIZED);
812 return -2;
813 }
814
815 ret = BIO_ctrl(bio, BIO_C_NWRITE0, 0, buf);
816 if (ret > INT_MAX)
817 return INT_MAX;
818 else
819 return (int) ret;
820 }
821
822int BIO_nwrite(BIO *bio, char **buf, int num)
823 {
824 int ret;
825
826 if (!bio->init)
827 {
828 BIOerr(BIO_F_BIO_NWRITE, BIO_R_UNINITIALIZED);
829 return -2;
830 }
831
832 ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf);
833 if (ret > 0)
834 bio->num_read += ret;
835 return ret;
836 }
diff --git a/src/lib/libssl/src/crypto/bio/bss_conn.c b/src/lib/libssl/src/crypto/bio/bss_conn.c
index 68c46e3d69..22d00b369e 100644
--- a/src/lib/libssl/src/crypto/bio/bss_conn.c
+++ b/src/lib/libssl/src/crypto/bio/bss_conn.c
@@ -90,11 +90,11 @@ typedef struct bio_connect_st
90 struct sockaddr_in them; 90 struct sockaddr_in them;
91 91
92 /* int socket; this will be kept in bio->num so that it is 92 /* int socket; this will be kept in bio->num so that it is
93 * compatable with the bss_sock bio */ 93 * compatible with the bss_sock bio */
94 94
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 compatablity with the ssl info_callback */ 97 * 'ret'. state is for compatibility with the ssl info_callback */
98 int (*info_callback)(); 98 int (*info_callback)();
99 } BIO_CONNECT; 99 } BIO_CONNECT;
100 100
@@ -104,6 +104,7 @@ static int conn_puts(BIO *h,char *str);
104static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); 104static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2);
105static int conn_new(BIO *h); 105static int conn_new(BIO *h);
106static int conn_free(BIO *data); 106static int conn_free(BIO *data);
107static long conn_callback_ctrl(BIO *h,int cmd,void *(*fp)());
107 108
108static int conn_state(BIO *b, BIO_CONNECT *c); 109static int conn_state(BIO *b, BIO_CONNECT *c);
109static void conn_close_socket(BIO *data); 110static void conn_close_socket(BIO *data);
@@ -121,6 +122,7 @@ static BIO_METHOD methods_connectp=
121 conn_ctrl, 122 conn_ctrl,
122 conn_new, 123 conn_new,
123 conn_free, 124 conn_free,
125 conn_callback_ctrl,
124 }; 126 };
125 127
126static int conn_state(BIO *b, BIO_CONNECT *c) 128static int conn_state(BIO *b, BIO_CONNECT *c)
@@ -494,7 +496,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
494 *((int *)ptr)=data->port; 496 *((int *)ptr)=data->port;
495 } 497 }
496 if ((!b->init) || (ptr == NULL)) 498 if ((!b->init) || (ptr == NULL))
497 *pptr="not initalised"; 499 *pptr="not initialized";
498 ret=1; 500 ret=1;
499 } 501 }
500 break; 502 break;
@@ -564,16 +566,25 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
564 case BIO_CTRL_FLUSH: 566 case BIO_CTRL_FLUSH:
565 break; 567 break;
566 case BIO_CTRL_DUP: 568 case BIO_CTRL_DUP:
569 {
567 dbio=(BIO *)ptr; 570 dbio=(BIO *)ptr;
568 if (data->param_port) 571 if (data->param_port)
569 BIO_set_conn_port(dbio,data->param_port); 572 BIO_set_conn_port(dbio,data->param_port);
570 if (data->param_hostname) 573 if (data->param_hostname)
571 BIO_set_conn_hostname(dbio,data->param_hostname); 574 BIO_set_conn_hostname(dbio,data->param_hostname);
572 BIO_set_nbio(dbio,data->nbio); 575 BIO_set_nbio(dbio,data->nbio);
573 (void)BIO_set_info_callback(dbio,data->info_callback); 576 (void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback));
577 }
574 break; 578 break;
575 case BIO_CTRL_SET_CALLBACK: 579 case BIO_CTRL_SET_CALLBACK:
576 data->info_callback=(int (*)())ptr; 580 {
581#if 0 /* FIXME: Should this be used? -- Richard Levitte */
582 BIOerr(BIO_F_CONN_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
583 ret = -1;
584#else
585 ret=0;
586#endif
587 }
577 break; 588 break;
578 case BIO_CTRL_GET_CALLBACK: 589 case BIO_CTRL_GET_CALLBACK:
579 { 590 {
@@ -590,6 +601,27 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
590 return(ret); 601 return(ret);
591 } 602 }
592 603
604static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)())
605 {
606 long ret=1;
607 BIO_CONNECT *data;
608
609 data=(BIO_CONNECT *)b->ptr;
610
611 switch (cmd)
612 {
613 case BIO_CTRL_SET_CALLBACK:
614 {
615 data->info_callback=(int (*)())fp;
616 }
617 break;
618 default:
619 ret=0;
620 break;
621 }
622 return(ret);
623 }
624
593static int conn_puts(BIO *bp, char *str) 625static int conn_puts(BIO *bp, char *str)
594 { 626 {
595 int n,ret; 627 int n,ret;
diff --git a/src/lib/libssl/src/crypto/bio/bss_file.c b/src/lib/libssl/src/crypto/bio/bss_file.c
index 52c0c39df0..0d44dc3889 100644
--- a/src/lib/libssl/src/crypto/bio/bss_file.c
+++ b/src/lib/libssl/src/crypto/bio/bss_file.c
@@ -91,6 +91,7 @@ static BIO_METHOD methods_filep=
91 file_ctrl, 91 file_ctrl,
92 file_new, 92 file_new,
93 file_free, 93 file_free,
94 NULL,
94 }; 95 };
95 96
96BIO *BIO_new_file(const char *filename, const char *mode) 97BIO *BIO_new_file(const char *filename, const char *mode)
@@ -171,7 +172,7 @@ static int MS_CALLBACK file_write(BIO *b, char *in, int inl)
171 if (fwrite(in,(int)inl,1,(FILE *)b->ptr)) 172 if (fwrite(in,(int)inl,1,(FILE *)b->ptr))
172 ret=inl; 173 ret=inl;
173 /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ 174 /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
174 /* acording to Tim Hudson <tjh@cryptsoft.com>, the commented 175 /* according to Tim Hudson <tjh@cryptsoft.com>, the commented
175 * out version above can cause 'inl' write calls under 176 * out version above can cause 'inl' write calls under
176 * some stupid stdio implementations (VMS) */ 177 * some stupid stdio implementations (VMS) */
177 } 178 }
diff --git a/src/lib/libssl/src/crypto/bio/bss_log.c b/src/lib/libssl/src/crypto/bio/bss_log.c
index db82e757e7..4308b19663 100644
--- a/src/lib/libssl/src/crypto/bio/bss_log.c
+++ b/src/lib/libssl/src/crypto/bio/bss_log.c
@@ -72,6 +72,8 @@
72#else 72#else
73#include <syslog.h> 73#include <syslog.h>
74#endif 74#endif
75#else
76#include <process.h>
75#endif 77#endif
76 78
77#include "cryptlib.h" 79#include "cryptlib.h"
@@ -98,6 +100,7 @@ static BIO_METHOD methods_slg=
98 slg_ctrl, 100 slg_ctrl,
99 slg_new, 101 slg_new,
100 slg_free, 102 slg_free,
103 NULL,
101 }; 104 };
102 105
103BIO_METHOD *BIO_s_log(void) 106BIO_METHOD *BIO_s_log(void)
@@ -131,8 +134,10 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl)
131 char* buf= in; 134 char* buf= in;
132 char* pp; 135 char* pp;
133#if defined(WIN32) 136#if defined(WIN32)
134 LPTSTR lpszStrings[1]; 137 LPCSTR lpszStrings[2];
135 WORD evtype= EVENTLOG_ERROR_TYPE; 138 WORD evtype= EVENTLOG_ERROR_TYPE;
139 int pid = _getpid();
140 char pidbuf[20];
136#else 141#else
137 int priority; 142 int priority;
138#endif 143#endif
@@ -156,10 +161,13 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl)
156 evtype= EVENTLOG_ERROR_TYPE; 161 evtype= EVENTLOG_ERROR_TYPE;
157 pp= buf; 162 pp= buf;
158 } 163 }
159 lpszStrings[0]= pp; 164
165 sprintf(pidbuf, "[%d] ", pid);
166 lpszStrings[0] = pidbuf;
167 lpszStrings[1] = pp;
160 168
161 if(b->ptr) 169 if(b->ptr)
162 ReportEvent(b->ptr, evtype, 0, 1024, NULL, 1, 0, 170 ReportEvent(b->ptr, evtype, 0, 1024, NULL, 2, 0,
163 lpszStrings, NULL); 171 lpszStrings, NULL);
164#else 172#else
165 if(strncmp(buf, "ERR ", 4) == 0){ 173 if(strncmp(buf, "ERR ", 4) == 0){
diff --git a/src/lib/libssl/src/crypto/bio/bss_mem.c b/src/lib/libssl/src/crypto/bio/bss_mem.c
index 7e749a503e..41eab92415 100644
--- a/src/lib/libssl/src/crypto/bio/bss_mem.c
+++ b/src/lib/libssl/src/crypto/bio/bss_mem.c
@@ -79,6 +79,7 @@ static BIO_METHOD mem_method=
79 mem_ctrl, 79 mem_ctrl,
80 mem_new, 80 mem_new,
81 mem_free, 81 mem_free,
82 NULL,
82 }; 83 };
83 84
84/* bio->num is used to hold the value to return on 'empty', if it is 85/* bio->num is used to hold the value to return on 'empty', if it is
@@ -89,6 +90,26 @@ BIO_METHOD *BIO_s_mem(void)
89 return(&mem_method); 90 return(&mem_method);
90 } 91 }
91 92
93BIO *BIO_new_mem_buf(void *buf, int len)
94{
95 BIO *ret;
96 BUF_MEM *b;
97 if (!buf) {
98 BIOerr(BIO_F_BIO_NEW_MEM_BUF,BIO_R_NULL_PARAMETER);
99 return NULL;
100 }
101 if(len == -1) len = strlen(buf);
102 if(!(ret = BIO_new(BIO_s_mem())) ) return NULL;
103 b = (BUF_MEM *)ret->ptr;
104 b->data = buf;
105 b->length = len;
106 b->max = len;
107 ret->flags |= BIO_FLAGS_MEM_RDONLY;
108 /* Since this is static data retrying wont help */
109 ret->num = 0;
110 return ret;
111}
112
92static int mem_new(BIO *bi) 113static int mem_new(BIO *bi)
93 { 114 {
94 BUF_MEM *b; 115 BUF_MEM *b;
@@ -109,7 +130,10 @@ static int mem_free(BIO *a)
109 { 130 {
110 if ((a->init) && (a->ptr != NULL)) 131 if ((a->init) && (a->ptr != NULL))
111 { 132 {
112 BUF_MEM_free((BUF_MEM *)a->ptr); 133 BUF_MEM *b;
134 b = (BUF_MEM *)a->ptr;
135 if(a->flags & BIO_FLAGS_MEM_RDONLY) b->data = NULL;
136 BUF_MEM_free(b);
113 a->ptr=NULL; 137 a->ptr=NULL;
114 } 138 }
115 } 139 }
@@ -126,17 +150,18 @@ static int mem_read(BIO *b, char *out, int outl)
126 bm=(BUF_MEM *)b->ptr; 150 bm=(BUF_MEM *)b->ptr;
127 BIO_clear_retry_flags(b); 151 BIO_clear_retry_flags(b);
128 ret=(outl > bm->length)?bm->length:outl; 152 ret=(outl > bm->length)?bm->length:outl;
129 if ((out != NULL) && (ret > 0)) 153 if ((out != NULL) && (ret > 0)) {
130 {
131 memcpy(out,bm->data,ret); 154 memcpy(out,bm->data,ret);
132 bm->length-=ret; 155 bm->length-=ret;
133 /* memmove(&(bm->data[0]),&(bm->data[ret]), bm->length); */ 156 /* memmove(&(bm->data[0]),&(bm->data[ret]), bm->length); */
134 from=(char *)&(bm->data[ret]); 157 if(b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret;
135 to=(char *)&(bm->data[0]); 158 else {
136 for (i=0; i<bm->length; i++) 159 from=(char *)&(bm->data[ret]);
137 to[i]=from[i]; 160 to=(char *)&(bm->data[0]);
161 for (i=0; i<bm->length; i++)
162 to[i]=from[i];
138 } 163 }
139 else if (bm->length == 0) 164 } else if (bm->length == 0)
140 { 165 {
141 if (b->num != 0) 166 if (b->num != 0)
142 BIO_set_retry_read(b); 167 BIO_set_retry_read(b);
@@ -158,6 +183,11 @@ static int mem_write(BIO *b, char *in, int inl)
158 goto end; 183 goto end;
159 } 184 }
160 185
186 if(b->flags & BIO_FLAGS_MEM_RDONLY) {
187 BIOerr(BIO_F_MEM_WRITE,BIO_R_WRITE_TO_READ_ONLY_BIO);
188 goto end;
189 }
190
161 BIO_clear_retry_flags(b); 191 BIO_clear_retry_flags(b);
162 blen=bm->length; 192 blen=bm->length;
163 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl)) 193 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl))
@@ -178,9 +208,15 @@ static long mem_ctrl(BIO *b, int cmd, long num, char *ptr)
178 switch (cmd) 208 switch (cmd)
179 { 209 {
180 case BIO_CTRL_RESET: 210 case BIO_CTRL_RESET:
181 if (bm->data != NULL) 211 if (bm->data != NULL) {
182 memset(bm->data,0,bm->max); 212 /* For read only case reset to the start again */
183 bm->length=0; 213 if(b->flags & BIO_FLAGS_MEM_RDONLY)
214 bm->data -= bm->max - bm->length;
215 else {
216 memset(bm->data,0,bm->max);
217 bm->length=0;
218 }
219 }
184 break; 220 break;
185 case BIO_CTRL_EOF: 221 case BIO_CTRL_EOF:
186 ret=(long)(bm->length == 0); 222 ret=(long)(bm->length == 0);
diff --git a/src/lib/libssl/src/crypto/bio/bss_null.c b/src/lib/libssl/src/crypto/bio/bss_null.c
index d04be888e5..aee18e3ada 100644
--- a/src/lib/libssl/src/crypto/bio/bss_null.c
+++ b/src/lib/libssl/src/crypto/bio/bss_null.c
@@ -79,6 +79,7 @@ static BIO_METHOD null_method=
79 null_ctrl, 79 null_ctrl,
80 null_new, 80 null_new,
81 null_free, 81 null_free,
82 NULL,
82 }; 83 };
83 84
84BIO_METHOD *BIO_s_null(void) 85BIO_METHOD *BIO_s_null(void)
diff --git a/src/lib/libssl/src/crypto/bio/bss_rtcp.c b/src/lib/libssl/src/crypto/bio/bss_rtcp.c
index 2ef040057e..4ad0739464 100644
--- a/src/lib/libssl/src/crypto/bio/bss_rtcp.c
+++ b/src/lib/libssl/src/crypto/bio/bss_rtcp.c
@@ -107,6 +107,7 @@ static BIO_METHOD rtcp_method=
107 rtcp_ctrl, 107 rtcp_ctrl,
108 rtcp_new, 108 rtcp_new,
109 rtcp_free, 109 rtcp_free,
110 NULL,
110 }; 111 };
111 112
112BIO_METHOD *BIO_s_rtcp(void) 113BIO_METHOD *BIO_s_rtcp(void)
diff --git a/src/lib/libssl/src/crypto/bio/bss_sock.c b/src/lib/libssl/src/crypto/bio/bss_sock.c
index d336b99fe8..8ce80ef68d 100644
--- a/src/lib/libssl/src/crypto/bio/bss_sock.c
+++ b/src/lib/libssl/src/crypto/bio/bss_sock.c
@@ -95,6 +95,7 @@ static BIO_METHOD methods_sockp=
95 sock_ctrl, 95 sock_ctrl,
96 sock_new, 96 sock_new,
97 sock_free, 97 sock_free,
98 NULL,
98 }; 99 };
99 100
100BIO_METHOD *BIO_s_socket(void) 101BIO_METHOD *BIO_s_socket(void)
@@ -112,6 +113,7 @@ static BIO_METHOD methods_fdp=
112 fd_ctrl, 113 fd_ctrl,
113 fd_new, 114 fd_new,
114 fd_free, 115 fd_free,
116 NULL,
115 }; 117 };
116 118
117BIO_METHOD *BIO_s_fd(void) 119BIO_METHOD *BIO_s_fd(void)
@@ -163,8 +165,7 @@ static int fd_free(BIO *a)
163 if (a->init) 165 if (a->init)
164 { 166 {
165#ifndef BIO_FD 167#ifndef BIO_FD
166 shutdown(a->num,2); 168 SHUTDOWN2(a->num);
167 closesocket(a->num);
168#else /* BIO_FD */ 169#else /* BIO_FD */
169 close(a->num); 170 close(a->num);
170#endif 171#endif
diff --git a/src/lib/libssl/src/crypto/bn/Makefile.ssl b/src/lib/libssl/src/crypto/bn/Makefile.ssl
index cf77869fab..fa23a43fa0 100644
--- a/src/lib/libssl/src/crypto/bn/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/bn/Makefile.ssl
@@ -20,6 +20,13 @@ BN_ASM= bn_asm.o
20#BN_ASM= bn86-elf.o 20#BN_ASM= bn86-elf.o
21 21
22CFLAGS= $(INCLUDES) $(CFLAG) 22CFLAGS= $(INCLUDES) $(CFLAG)
23
24# We let the C compiler driver to take care of .s files. This is done in
25# order to be excused from maintaining a separate set of architecture
26# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
27# gcc, then the driver will automatically translate it to -xarch=v8plus
28# and pass it down to assembler.
29AS=$(CC) -c
23ASFLAGS=$(CFLAGS) 30ASFLAGS=$(CFLAGS)
24 31
25GENERAL=Makefile 32GENERAL=Makefile
@@ -27,12 +34,12 @@ TEST=bntest.c exptest.c
27APPS= 34APPS=
28 35
29LIB=$(TOP)/libcrypto.a 36LIB=$(TOP)/libcrypto.a
30LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mul.c \ 37LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \
31 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ 38 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
32 bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c \ 39 bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c \
33 bn_mpi.c bn_exp2.c 40 bn_mpi.c bn_exp2.c
34 41
35LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mul.o \ 42LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o \
36 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ 43 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
37 bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) bn_recp.o bn_mont.o \ 44 bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) bn_recp.o bn_mont.o \
38 bn_mpi.o bn_exp2.o 45 bn_mpi.o bn_exp2.o
@@ -49,12 +56,14 @@ top:
49 56
50all: lib 57all: lib
51 58
52knuth: bn_knuth.c 59bn_prime.h: bn_prime.pl
53 cc -pg -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a 60 $(PERL) bn_prime.pl >bn_prime.h
54 61
55knuth.fast: bn_knuth.c 62divtest: divtest.c ../../libcrypto.a
56 cc -pg -fast -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a 63 cc -I../../include divtest.c -o divtest ../../libcrypto.a
57 64
65bnbug: bnbug.c ../../libcrypto.a top
66 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a
58 67
59lib: $(LIBOBJ) 68lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ) 69 $(AR) $(LIB) $(LIBOBJ)
@@ -113,13 +122,6 @@ asm/sparcv8plus-gcc27.o: asm/sparcv8plus.S
113 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \ 122 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \
114 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o 123 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o
115 124
116# MIPS 64 bit assember
117asm/mips3.o: asm/mips3.s
118
119# MIPS 32 bit assember
120asm/mips1.o: asm/mips1.s
121 /usr/bin/as -O2 -o asm/mips1.o asm/mips1.s
122
123files: 125files:
124 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 126 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
125 127
@@ -168,109 +170,117 @@ bn_add.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
168bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 170bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
169bn_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 171bn_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
170bn_add.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 172bn_add.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
171bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 173bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
172bn_add.o: ../cryptlib.h bn_lcl.h 174bn_add.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
173bn_asm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 175bn_asm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
174bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 176bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
175bn_asm.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 177bn_asm.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
176bn_asm.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 178bn_asm.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
177bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 179bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
178bn_asm.o: ../cryptlib.h bn_lcl.h 180bn_asm.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
179bn_blind.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 181bn_blind.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
180bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 182bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
181bn_blind.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 183bn_blind.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
182bn_blind.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 184bn_blind.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
183bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 185bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
184bn_blind.o: ../cryptlib.h bn_lcl.h 186bn_blind.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
187bn_ctx.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
188bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
189bn_ctx.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
190bn_ctx.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
191bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
192bn_ctx.o: ../../include/openssl/stack.h ../cryptlib.h
185bn_div.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 193bn_div.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
186bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 194bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
187bn_div.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 195bn_div.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
188bn_div.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 196bn_div.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
189bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 197bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
190bn_div.o: ../cryptlib.h bn_lcl.h 198bn_div.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
191bn_err.o: ../../include/openssl/bn.h ../../include/openssl/err.h 199bn_err.o: ../../include/openssl/bn.h ../../include/openssl/err.h
192bn_err.o: ../../include/openssl/opensslconf.h 200bn_err.o: ../../include/openssl/opensslconf.h
193bn_exp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 201bn_exp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
194bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 202bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
195bn_exp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 203bn_exp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
196bn_exp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 204bn_exp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
197bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 205bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
198bn_exp.o: ../cryptlib.h bn_lcl.h 206bn_exp.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
199bn_exp2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 207bn_exp2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
200bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 208bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
201bn_exp2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 209bn_exp2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
202bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 210bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
203bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 211bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
204bn_exp2.o: ../cryptlib.h bn_lcl.h 212bn_exp2.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
205bn_gcd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 213bn_gcd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
206bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 214bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
207bn_gcd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 215bn_gcd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
208bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 216bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
209bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 217bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
210bn_gcd.o: ../cryptlib.h bn_lcl.h 218bn_gcd.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
211bn_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 219bn_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
212bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 220bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
213bn_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 221bn_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
214bn_lib.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 222bn_lib.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
215bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 223bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
216bn_lib.o: ../cryptlib.h bn_lcl.h 224bn_lib.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
217bn_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 225bn_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
218bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 226bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
219bn_mont.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 227bn_mont.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
220bn_mont.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 228bn_mont.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
221bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 229bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
222bn_mont.o: ../cryptlib.h bn_lcl.h 230bn_mont.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
223bn_mpi.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 231bn_mpi.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
224bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 232bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
225bn_mpi.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 233bn_mpi.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
226bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 234bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
227bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 235bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
228bn_mpi.o: ../cryptlib.h bn_lcl.h 236bn_mpi.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
229bn_mul.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 237bn_mul.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
230bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 238bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
231bn_mul.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 239bn_mul.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
232bn_mul.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 240bn_mul.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
233bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 241bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
234bn_mul.o: ../cryptlib.h bn_lcl.h 242bn_mul.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
235bn_prime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 243bn_prime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
236bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 244bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
237bn_prime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 245bn_prime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
238bn_prime.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 246bn_prime.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
239bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 247bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
240bn_prime.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h bn_prime.h 248bn_prime.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
249bn_prime.o: ../cryptlib.h bn_lcl.h bn_prime.h
241bn_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 250bn_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
242bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 251bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
243bn_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 252bn_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
244bn_print.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 253bn_print.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
245bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 254bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
246bn_print.o: ../cryptlib.h bn_lcl.h 255bn_print.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
247bn_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 256bn_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
248bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 257bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
249bn_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 258bn_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
250bn_rand.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 259bn_rand.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
251bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 260bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
252bn_rand.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h 261bn_rand.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
262bn_rand.o: ../cryptlib.h bn_lcl.h
253bn_recp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 263bn_recp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
254bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 264bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
255bn_recp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 265bn_recp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
256bn_recp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 266bn_recp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
257bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 267bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
258bn_recp.o: ../cryptlib.h bn_lcl.h 268bn_recp.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
259bn_shift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 269bn_shift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
260bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 270bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
261bn_shift.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 271bn_shift.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
262bn_shift.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 272bn_shift.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
263bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 273bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
264bn_shift.o: ../cryptlib.h bn_lcl.h 274bn_shift.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
265bn_sqr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 275bn_sqr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
266bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 276bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
267bn_sqr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 277bn_sqr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
268bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 278bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
269bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 279bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
270bn_sqr.o: ../cryptlib.h bn_lcl.h 280bn_sqr.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
271bn_word.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 281bn_word.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
272bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 282bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
273bn_word.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 283bn_word.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
274bn_word.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 284bn_word.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
275bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 285bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
276bn_word.o: ../cryptlib.h bn_lcl.h 286bn_word.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
diff --git a/src/lib/libssl/src/crypto/bn/asm/README b/src/lib/libssl/src/crypto/bn/asm/README
index d93fbff77f..86bf64cfc2 100644
--- a/src/lib/libssl/src/crypto/bn/asm/README
+++ b/src/lib/libssl/src/crypto/bn/asm/README
@@ -1,5 +1,5 @@
1All assember in this directory are just version of the file 1All assember in this directory are just version of the file
2crypto/bn/bn_mulw.c. 2crypto/bn/bn_asm.c.
3 3
4Quite a few of these files are just the assember output from gcc since on 4Quite a few of these files are just the assember output from gcc since on
5quite a few machines they are 2 times faster than the system compiler. 5quite a few machines they are 2 times faster than the system compiler.
@@ -15,13 +15,6 @@ On the 2 alpha C compilers I had access to, it was not possible to do
15were 64 bits). So the hand assember gives access to the 128 bit result and 15were 64 bits). So the hand assember gives access to the 128 bit result and
16a 2 times speedup :-). 16a 2 times speedup :-).
17 17
18The x86xxxx.obj files are the assembled version of x86xxxx.asm files.
19I had such a hard time finding a macro assember for Microsoft, I decided to
20include the object file to save others the hassle :-).
21
22I have also included uu encoded versions of the .obj incase they get
23trashed.
24
25There are 2 versions of assember for the HP PA-RISC. 18There are 2 versions of assember for the HP PA-RISC.
26pa-risc.s is the origional one which works fine. 19pa-risc.s is the origional one which works fine.
27pa-risc2.s is a new version that often generates warnings but if the 20pa-risc2.s is a new version that often generates warnings but if the
diff --git a/src/lib/libssl/src/crypto/bn/asm/alpha.s b/src/lib/libssl/src/crypto/bn/asm/alpha.s
index a351694ca2..555ff0b92d 100644
--- a/src/lib/libssl/src/crypto/bn/asm/alpha.s
+++ b/src/lib/libssl/src/crypto/bn/asm/alpha.s
@@ -694,567 +694,1868 @@ bn_mul_comba8:
694bn_mul_comba8..ng: 694bn_mul_comba8..ng:
695 .frame $30,0,$26,0 695 .frame $30,0,$26,0
696 .prologue 0 696 .prologue 0
697 697 ldq $1, 0($17)
698 subq $30, 16, $30 698 ldq $2, 0($18)
699 ldq $0, 0($17) 699 zapnot $1, 15, $7
700 srl $2, 32, $8
701 mulq $8, $7, $22
702 srl $1, 32, $6
703 zapnot $2, 15, $5
704 mulq $5, $6, $4
705 mulq $7, $5, $24
706 addq $22, $4, $22
707 cmpult $22, $4, $1
708 mulq $6, $8, $3
709 beq $1, $173
710 bis $31, 1, $1
711 sll $1, 32, $1
712 addq $3, $1, $3
713$173:
714 sll $22, 32, $4
715 addq $24, $4, $24
716 stq $24, 0($16)
717 ldq $2, 0($17)
718 ldq $1, 8($18)
719 zapnot $2, 15, $7
720 srl $1, 32, $8
721 mulq $8, $7, $25
722 zapnot $1, 15, $5
723 mulq $7, $5, $0
724 srl $2, 32, $6
725 mulq $5, $6, $23
726 mulq $6, $8, $6
727 srl $22, 32, $1
728 cmpult $24, $4, $2
729 addq $3, $1, $3
730 addq $2, $3, $22
731 addq $25, $23, $25
732 cmpult $25, $23, $1
733 bis $31, 1, $2
734 beq $1, $177
735 sll $2, 32, $1
736 addq $6, $1, $6
737$177:
738 sll $25, 32, $23
700 ldq $1, 0($18) 739 ldq $1, 0($18)
701 stq $9, 0($30) 740 addq $0, $23, $0
702 stq $10, 8($30) 741 bis $0, $0, $7
703 ldq $2, 8($17) 742 ldq $3, 8($17)
704 ldq $3, 8($18) 743 addq $22, $7, $22
705 ldq $4, 16($17) 744 srl $1, 32, $8
706 ldq $5, 16($18) 745 cmpult $22, $7, $4
707 ldq $6, 24($17) 746 zapnot $3, 15, $7
708 ldq $7, 24($18) 747 mulq $8, $7, $28
709 ldq $8, 8($17) 748 zapnot $1, 15, $5
710 ldq $22, 8($18) 749 mulq $7, $5, $21
711 ldq $23, 8($17) 750 srl $25, 32, $1
712 ldq $24, 8($18) 751 cmpult $0, $23, $2
713 ldq $25, 8($17) 752 addq $6, $1, $6
714 ldq $27, 8($18) 753 addq $2, $6, $6
715 ldq $28, 8($17) 754 addq $4, $6, $24
716 ldq $21, 8($18) 755 srl $3, 32, $6
717 bis $31, $31, $9 756 mulq $5, $6, $2
718 mulq $0, $1, $20 757 mulq $6, $8, $6
719 umulh $0, $1, $19 758 addq $28, $2, $28
720 stq $20, 0($16) 759 cmpult $28, $2, $1
721 bis $31, $31, $20 760 bis $31, 1, $2
722 mulq $0, $3, $10 761 beq $1, $181
723 umulh $0, $3, $17 762 sll $2, 32, $1
724 addq $19, $10, $19 763 addq $6, $1, $6
725 cmpult $19, $10, $18 764$181:
726 addq $18, $17, $17 765 sll $28, 32, $2
727 addq $9, $17, $9 766 addq $21, $2, $21
728 cmpult $9, $17, $10 767 bis $21, $21, $7
729 addq $20, $10, $20 768 addq $22, $7, $22
730 mulq $2, $1, $18 769 stq $22, 8($16)
731 umulh $2, $1, $17 770 ldq $3, 16($17)
732 addq $19, $18, $19 771 ldq $1, 0($18)
733 cmpult $19, $18, $10 772 cmpult $22, $7, $4
734 addq $10, $17, $17 773 zapnot $3, 15, $7
735 addq $9, $17, $9 774 srl $1, 32, $8
736 cmpult $9, $17, $18 775 mulq $8, $7, $22
737 addq $20, $18, $20 776 zapnot $1, 15, $5
738 stq $19, 8($16) 777 mulq $7, $5, $20
739 bis $31, $31, $19 778 srl $28, 32, $1
740 mulq $0, $5, $10 779 cmpult $21, $2, $2
741 umulh $0, $5, $17 780 addq $6, $1, $6
742 addq $9, $10, $9 781 addq $2, $6, $6
743 cmpult $9, $10, $18 782 addq $4, $6, $6
744 addq $18, $17, $17 783 addq $24, $6, $24
745 addq $20, $17, $20 784 cmpult $24, $6, $23
746 cmpult $20, $17, $10 785 srl $3, 32, $6
747 addq $19, $10, $19 786 mulq $5, $6, $2
748 mulq $2, $3, $18 787 mulq $6, $8, $6
749 umulh $2, $3, $17 788 addq $22, $2, $22
750 addq $9, $18, $9 789 cmpult $22, $2, $1
751 cmpult $9, $18, $10 790 bis $31, 1, $2
752 addq $10, $17, $17 791 beq $1, $185
753 addq $20, $17, $20 792 sll $2, 32, $1
754 cmpult $20, $17, $18 793 addq $6, $1, $6
755 addq $19, $18, $19 794$185:
756 mulq $4, $1, $10 795 sll $22, 32, $2
757 umulh $4, $1, $17 796 ldq $1, 8($18)
758 addq $9, $10, $9
759 cmpult $9, $10, $18
760 addq $18, $17, $17
761 addq $20, $17, $20
762 cmpult $20, $17, $10
763 addq $19, $10, $19
764 stq $9, 16($16)
765 bis $31, $31, $9
766 mulq $0, $7, $18
767 umulh $0, $7, $17
768 addq $20, $18, $20
769 cmpult $20, $18, $10
770 addq $10, $17, $17
771 addq $19, $17, $19
772 cmpult $19, $17, $18
773 addq $9, $18, $9
774 mulq $2, $5, $10
775 umulh $2, $5, $17
776 addq $20, $10, $20
777 cmpult $20, $10, $18
778 addq $18, $17, $17
779 addq $19, $17, $19
780 cmpult $19, $17, $10
781 addq $9, $10, $9
782 mulq $4, $3, $18
783 umulh $4, $3, $17
784 addq $20, $18, $20
785 cmpult $20, $18, $10
786 addq $10, $17, $17
787 addq $19, $17, $19
788 cmpult $19, $17, $18
789 addq $9, $18, $9
790 mulq $6, $1, $10
791 umulh $6, $1, $17
792 addq $20, $10, $20
793 cmpult $20, $10, $18
794 addq $18, $17, $17
795 addq $19, $17, $19
796 cmpult $19, $17, $10
797 addq $9, $10, $9
798 stq $20, 24($16)
799 bis $31, $31, $20
800 mulq $0, $22, $18
801 umulh $0, $22, $17
802 addq $19, $18, $19
803 cmpult $19, $18, $10
804 addq $10, $17, $17
805 addq $9, $17, $9
806 cmpult $9, $17, $18
807 addq $20, $18, $20
808 mulq $2, $7, $10
809 umulh $2, $7, $17
810 addq $19, $10, $19
811 cmpult $19, $10, $18
812 addq $18, $17, $17
813 addq $9, $17, $9
814 cmpult $9, $17, $10
815 addq $20, $10, $20
816 mulq $4, $5, $18
817 umulh $4, $5, $17
818 addq $19, $18, $19
819 cmpult $19, $18, $10
820 addq $10, $17, $17
821 addq $9, $17, $9
822 cmpult $9, $17, $18
823 addq $20, $18, $20
824 mulq $6, $3, $10
825 umulh $6, $3, $17
826 addq $19, $10, $19
827 cmpult $19, $10, $18
828 addq $18, $17, $17
829 addq $9, $17, $9
830 cmpult $9, $17, $10
831 addq $20, $10, $20
832 mulq $8, $1, $18
833 umulh $8, $1, $17
834 addq $19, $18, $19
835 cmpult $19, $18, $10
836 addq $10, $17, $17
837 addq $9, $17, $9
838 cmpult $9, $17, $18
839 addq $20, $18, $20
840 stq $19, 32($16)
841 bis $31, $31, $19
842 mulq $0, $24, $10
843 umulh $0, $24, $17
844 addq $9, $10, $9
845 cmpult $9, $10, $18
846 addq $18, $17, $17
847 addq $20, $17, $20
848 cmpult $20, $17, $10
849 addq $19, $10, $19
850 mulq $2, $22, $18
851 umulh $2, $22, $17
852 addq $9, $18, $9
853 cmpult $9, $18, $10
854 addq $10, $17, $17
855 addq $20, $17, $20
856 cmpult $20, $17, $18
857 addq $19, $18, $19
858 mulq $4, $7, $10
859 umulh $4, $7, $17
860 addq $9, $10, $9
861 cmpult $9, $10, $18
862 addq $18, $17, $17
863 addq $20, $17, $20
864 cmpult $20, $17, $10
865 addq $19, $10, $19
866 mulq $6, $5, $18
867 umulh $6, $5, $17
868 addq $9, $18, $9
869 cmpult $9, $18, $10
870 addq $10, $17, $17
871 addq $20, $17, $20
872 cmpult $20, $17, $18
873 addq $19, $18, $19
874 mulq $8, $3, $10
875 umulh $8, $3, $17
876 addq $9, $10, $9
877 cmpult $9, $10, $18
878 addq $18, $17, $17
879 addq $20, $17, $20
880 cmpult $20, $17, $10
881 addq $19, $10, $19
882 mulq $23, $1, $18
883 umulh $23, $1, $17
884 addq $9, $18, $9
885 cmpult $9, $18, $10
886 addq $10, $17, $17
887 addq $20, $17, $20
888 cmpult $20, $17, $18
889 addq $19, $18, $19
890 stq $9, 40($16)
891 bis $31, $31, $9
892 mulq $0, $27, $10
893 umulh $0, $27, $17
894 addq $20, $10, $20
895 cmpult $20, $10, $18
896 addq $18, $17, $17
897 addq $19, $17, $19
898 cmpult $19, $17, $10
899 addq $9, $10, $9
900 mulq $2, $24, $18
901 umulh $2, $24, $17
902 addq $20, $18, $20
903 cmpult $20, $18, $10
904 addq $10, $17, $17
905 addq $19, $17, $19
906 cmpult $19, $17, $18
907 addq $9, $18, $9
908 mulq $4, $22, $10
909 umulh $4, $22, $17
910 addq $20, $10, $20
911 cmpult $20, $10, $18
912 addq $18, $17, $17
913 addq $19, $17, $19
914 cmpult $19, $17, $10
915 addq $9, $10, $9
916 mulq $6, $7, $18
917 umulh $6, $7, $17
918 addq $20, $18, $20
919 cmpult $20, $18, $10
920 addq $10, $17, $17
921 addq $19, $17, $19
922 cmpult $19, $17, $18
923 addq $9, $18, $9
924 mulq $8, $5, $10
925 umulh $8, $5, $17
926 addq $20, $10, $20
927 cmpult $20, $10, $18
928 addq $18, $17, $17
929 addq $19, $17, $19
930 cmpult $19, $17, $10
931 addq $9, $10, $9
932 mulq $23, $3, $18
933 umulh $23, $3, $17
934 addq $20, $18, $20
935 cmpult $20, $18, $10
936 addq $10, $17, $17
937 addq $19, $17, $19
938 cmpult $19, $17, $18
939 addq $9, $18, $9
940 mulq $25, $1, $10
941 umulh $25, $1, $17
942 addq $20, $10, $20
943 cmpult $20, $10, $18
944 addq $18, $17, $17
945 addq $19, $17, $19
946 cmpult $19, $17, $10
947 addq $9, $10, $9
948 stq $20, 48($16)
949 bis $31, $31, $20
950 mulq $0, $21, $18
951 umulh $0, $21, $17
952 addq $19, $18, $19
953 cmpult $19, $18, $10
954 addq $10, $17, $17
955 addq $9, $17, $9
956 cmpult $9, $17, $18
957 addq $20, $18, $20
958 mulq $2, $27, $10
959 umulh $2, $27, $17
960 addq $19, $10, $19
961 cmpult $19, $10, $18
962 addq $18, $17, $17
963 addq $9, $17, $9
964 cmpult $9, $17, $0
965 addq $20, $0, $20
966 mulq $4, $24, $10
967 umulh $4, $24, $18
968 addq $19, $10, $19
969 cmpult $19, $10, $17
970 addq $17, $18, $18
971 addq $9, $18, $9
972 cmpult $9, $18, $0
973 addq $20, $0, $20
974 mulq $6, $22, $10
975 umulh $6, $22, $17
976 addq $19, $10, $19
977 cmpult $19, $10, $18
978 addq $18, $17, $17
979 addq $9, $17, $9
980 cmpult $9, $17, $0
981 addq $20, $0, $20
982 mulq $8, $7, $10
983 umulh $8, $7, $18
984 addq $19, $10, $19
985 cmpult $19, $10, $17
986 addq $17, $18, $18
987 addq $9, $18, $9
988 cmpult $9, $18, $0
989 addq $20, $0, $20
990 mulq $23, $5, $10
991 umulh $23, $5, $17
992 addq $19, $10, $19
993 cmpult $19, $10, $18
994 addq $18, $17, $17
995 addq $9, $17, $9
996 cmpult $9, $17, $0
997 addq $20, $0, $20
998 mulq $25, $3, $10
999 umulh $25, $3, $18
1000 addq $19, $10, $19
1001 cmpult $19, $10, $17
1002 addq $17, $18, $18
1003 addq $9, $18, $9
1004 cmpult $9, $18, $0
1005 addq $20, $0, $20
1006 mulq $28, $1, $10
1007 umulh $28, $1, $17
1008 addq $19, $10, $19
1009 cmpult $19, $10, $18
1010 addq $18, $17, $17
1011 addq $9, $17, $9
1012 cmpult $9, $17, $0
1013 addq $20, $0, $20
1014 stq $19, 56($16)
1015 bis $31, $31, $19
1016 mulq $2, $21, $10
1017 umulh $2, $21, $18
1018 addq $9, $10, $9
1019 cmpult $9, $10, $17
1020 addq $17, $18, $18
1021 addq $20, $18, $20
1022 cmpult $20, $18, $0
1023 addq $19, $0, $19
1024 mulq $4, $27, $1
1025 umulh $4, $27, $10
1026 addq $9, $1, $9
1027 cmpult $9, $1, $17
1028 addq $17, $10, $10
1029 addq $20, $10, $20
1030 cmpult $20, $10, $18
1031 addq $19, $18, $19
1032 mulq $6, $24, $0
1033 umulh $6, $24, $2
1034 addq $9, $0, $9
1035 cmpult $9, $0, $1
1036 addq $1, $2, $2
1037 addq $20, $2, $20
1038 cmpult $20, $2, $17
1039 addq $19, $17, $19
1040 mulq $8, $22, $10
1041 umulh $8, $22, $18
1042 addq $9, $10, $9
1043 cmpult $9, $10, $0
1044 addq $0, $18, $18
1045 addq $20, $18, $20
1046 cmpult $20, $18, $1
1047 addq $19, $1, $19
1048 mulq $23, $7, $2
1049 umulh $23, $7, $17
1050 addq $9, $2, $9
1051 cmpult $9, $2, $10
1052 addq $10, $17, $17
1053 addq $20, $17, $20
1054 cmpult $20, $17, $0
1055 addq $19, $0, $19
1056 mulq $25, $5, $18
1057 umulh $25, $5, $1
1058 addq $9, $18, $9
1059 cmpult $9, $18, $2
1060 addq $2, $1, $1
1061 addq $20, $1, $20
1062 cmpult $20, $1, $10
1063 addq $19, $10, $19
1064 mulq $28, $3, $17
1065 umulh $28, $3, $0
1066 addq $9, $17, $9
1067 cmpult $9, $17, $18
1068 addq $18, $0, $0
1069 addq $20, $0, $20
1070 cmpult $20, $0, $2
1071 addq $19, $2, $19
1072 stq $9, 64($16)
1073 bis $31, $31, $9
1074 mulq $4, $21, $1
1075 umulh $4, $21, $10
1076 addq $20, $1, $20
1077 cmpult $20, $1, $17
1078 addq $17, $10, $10
1079 addq $19, $10, $19
1080 cmpult $19, $10, $18
1081 addq $9, $18, $9
1082 mulq $6, $27, $0
1083 umulh $6, $27, $2
1084 addq $20, $0, $20
1085 cmpult $20, $0, $3
1086 addq $3, $2, $2
1087 addq $19, $2, $19
1088 cmpult $19, $2, $1
1089 addq $9, $1, $9
1090 mulq $8, $24, $17
1091 umulh $8, $24, $10
1092 addq $20, $17, $20
1093 cmpult $20, $17, $18
1094 addq $18, $10, $10
1095 addq $19, $10, $19
1096 cmpult $19, $10, $4
1097 addq $9, $4, $9
1098 mulq $23, $22, $0
1099 umulh $23, $22, $3
1100 addq $20, $0, $20
1101 cmpult $20, $0, $2
1102 addq $2, $3, $3
1103 addq $19, $3, $19
1104 cmpult $19, $3, $1
1105 addq $9, $1, $9
1106 mulq $25, $7, $17
1107 umulh $25, $7, $18
1108 addq $20, $17, $20
1109 cmpult $20, $17, $10
1110 addq $10, $18, $18
1111 addq $19, $18, $19
1112 cmpult $19, $18, $4
1113 addq $9, $4, $9
1114 mulq $28, $5, $0
1115 umulh $28, $5, $2
1116 addq $20, $0, $20
1117 cmpult $20, $0, $3
1118 addq $3, $2, $2
1119 addq $19, $2, $19
1120 cmpult $19, $2, $1
1121 addq $9, $1, $9
1122 stq $20, 72($16)
1123 bis $31, $31, $20
1124 mulq $6, $21, $17
1125 umulh $6, $21, $10
1126 addq $19, $17, $19
1127 cmpult $19, $17, $18
1128 addq $18, $10, $10
1129 addq $9, $10, $9
1130 cmpult $9, $10, $4
1131 addq $20, $4, $20
1132 mulq $8, $27, $0
1133 umulh $8, $27, $3
1134 addq $19, $0, $19
1135 cmpult $19, $0, $2
1136 addq $2, $3, $3
1137 addq $9, $3, $9
1138 cmpult $9, $3, $1
1139 addq $20, $1, $20
1140 mulq $23, $24, $5
1141 umulh $23, $24, $17
1142 addq $19, $5, $19
1143 cmpult $19, $5, $18
1144 addq $18, $17, $17
1145 addq $9, $17, $9
1146 cmpult $9, $17, $10
1147 addq $20, $10, $20
1148 mulq $25, $22, $4
1149 umulh $25, $22, $6
1150 addq $19, $4, $19
1151 cmpult $19, $4, $0
1152 addq $0, $6, $6
1153 addq $9, $6, $9
1154 cmpult $9, $6, $2
1155 addq $20, $2, $20
1156 mulq $28, $7, $3
1157 umulh $28, $7, $1
1158 addq $19, $3, $19
1159 cmpult $19, $3, $5
1160 addq $5, $1, $1
1161 addq $9, $1, $9
1162 cmpult $9, $1, $18
1163 addq $20, $18, $20
1164 stq $19, 80($16)
1165 bis $31, $31, $19
1166 mulq $8, $21, $17
1167 umulh $8, $21, $10
1168 addq $9, $17, $9
1169 cmpult $9, $17, $4
1170 addq $4, $10, $10
1171 addq $20, $10, $20
1172 cmpult $20, $10, $0
1173 addq $19, $0, $19
1174 mulq $23, $27, $6
1175 umulh $23, $27, $2
1176 addq $9, $6, $9
1177 cmpult $9, $6, $3
1178 addq $3, $2, $2
1179 addq $20, $2, $20 797 addq $20, $2, $20
1180 cmpult $20, $2, $5 798 bis $20, $20, $7
1181 addq $19, $5, $19 799 ldq $4, 8($17)
1182 mulq $25, $24, $1 800 addq $24, $7, $24
1183 umulh $25, $24, $18 801 srl $1, 32, $8
1184 addq $9, $1, $9 802 cmpult $24, $7, $3
1185 cmpult $9, $1, $7 803 zapnot $4, 15, $7
1186 addq $7, $18, $18 804 mulq $8, $7, $25
1187 addq $20, $18, $20 805 zapnot $1, 15, $5
1188 cmpult $20, $18, $17 806 mulq $7, $5, $0
1189 addq $19, $17, $19 807 srl $22, 32, $1
1190 mulq $28, $22, $4 808 cmpult $20, $2, $2
1191 umulh $28, $22, $10 809 addq $6, $1, $6
1192 addq $9, $4, $9 810 addq $2, $6, $6
1193 cmpult $9, $4, $0 811 addq $3, $6, $6
1194 addq $0, $10, $10 812 addq $23, $6, $23
1195 addq $20, $10, $20 813 cmpult $23, $6, $22
1196 cmpult $20, $10, $8 814 srl $4, 32, $6
1197 addq $19, $8, $19 815 mulq $5, $6, $5
1198 stq $9, 88($16) 816 bis $31, 1, $21
1199 bis $31, $31, $9 817 addq $25, $5, $25
1200 mulq $23, $21, $6 818 cmpult $25, $5, $1
1201 umulh $23, $21, $3 819 mulq $6, $8, $6
1202 addq $20, $6, $20 820 beq $1, $189
1203 cmpult $20, $6, $2 821 sll $21, 32, $1
1204 addq $2, $3, $3 822 addq $6, $1, $6
1205 addq $19, $3, $19 823$189:
1206 cmpult $19, $3, $5 824 sll $25, 32, $5
1207 addq $9, $5, $9 825 ldq $2, 16($18)
1208 mulq $25, $27, $1 826 addq $0, $5, $0
1209 umulh $25, $27, $7 827 bis $0, $0, $7
1210 addq $20, $1, $20 828 ldq $4, 0($17)
1211 cmpult $20, $1, $18 829 addq $24, $7, $24
1212 addq $18, $7, $7 830 srl $2, 32, $8
1213 addq $19, $7, $19 831 cmpult $24, $7, $3
1214 cmpult $19, $7, $17 832 zapnot $4, 15, $7
1215 addq $9, $17, $9 833 mulq $8, $7, $28
1216 mulq $28, $24, $4 834 srl $25, 32, $1
1217 umulh $28, $24, $0 835 addq $6, $1, $6
1218 addq $20, $4, $20 836 cmpult $0, $5, $1
1219 cmpult $20, $4, $10 837 zapnot $2, 15, $5
1220 addq $10, $0, $0 838 addq $1, $6, $6
1221 addq $19, $0, $19 839 addq $3, $6, $6
1222 cmpult $19, $0, $8 840 addq $23, $6, $23
1223 addq $9, $8, $9 841 cmpult $23, $6, $1
1224 stq $20, 96($16) 842 srl $4, 32, $6
1225 bis $31, $31, $20 843 mulq $5, $6, $25
1226 mulq $25, $21, $22 844 mulq $7, $5, $2
1227 umulh $25, $21, $6 845 addq $1, $22, $22
1228 addq $19, $22, $19 846 addq $28, $25, $28
1229 cmpult $19, $22, $2 847 cmpult $28, $25, $1
848 mulq $6, $8, $6
849 beq $1, $193
850 sll $21, 32, $1
851 addq $6, $1, $6
852$193:
853 sll $28, 32, $25
854 addq $2, $25, $2
855 bis $2, $2, $7
856 addq $24, $7, $24
857 stq $24, 16($16)
858 ldq $4, 0($17)
859 ldq $5, 24($18)
860 cmpult $24, $7, $3
861 zapnot $4, 15, $7
862 srl $5, 32, $8
863 mulq $8, $7, $0
864 srl $28, 32, $1
865 cmpult $2, $25, $2
866 addq $6, $1, $6
867 addq $2, $6, $6
868 addq $3, $6, $6
869 addq $23, $6, $23
870 cmpult $23, $6, $1
871 srl $4, 32, $6
872 zapnot $5, 15, $5
873 mulq $5, $6, $24
874 mulq $7, $5, $2
875 addq $1, $22, $22
876 addq $0, $24, $0
877 cmpult $0, $24, $1
878 mulq $6, $8, $6
879 beq $1, $197
880 sll $21, 32, $1
881 addq $6, $1, $6
882$197:
883 sll $0, 32, $24
884 ldq $1, 16($18)
885 addq $2, $24, $2
886 bis $2, $2, $7
887 ldq $4, 8($17)
888 addq $23, $7, $23
889 srl $1, 32, $8
890 cmpult $23, $7, $3
891 zapnot $4, 15, $7
892 mulq $8, $7, $25
893 zapnot $1, 15, $5
894 mulq $7, $5, $21
895 srl $0, 32, $1
896 cmpult $2, $24, $2
897 addq $6, $1, $6
898 addq $2, $6, $6
899 addq $3, $6, $6
900 addq $22, $6, $22
901 cmpult $22, $6, $24
902 srl $4, 32, $6
903 mulq $5, $6, $5
904 bis $31, 1, $20
905 addq $25, $5, $25
906 cmpult $25, $5, $1
907 mulq $6, $8, $6
908 beq $1, $201
909 sll $20, 32, $1
910 addq $6, $1, $6
911$201:
912 sll $25, 32, $5
913 ldq $2, 8($18)
914 addq $21, $5, $21
915 bis $21, $21, $7
916 ldq $4, 16($17)
917 addq $23, $7, $23
918 srl $2, 32, $8
919 cmpult $23, $7, $3
920 zapnot $4, 15, $7
921 mulq $8, $7, $28
922 srl $25, 32, $1
923 addq $6, $1, $6
924 cmpult $21, $5, $1
925 zapnot $2, 15, $5
926 addq $1, $6, $6
927 addq $3, $6, $6
928 addq $22, $6, $22
929 cmpult $22, $6, $1
930 srl $4, 32, $6
931 mulq $5, $6, $25
932 mulq $7, $5, $5
933 addq $1, $24, $24
934 addq $28, $25, $28
935 cmpult $28, $25, $1
936 mulq $6, $8, $6
937 beq $1, $205
938 sll $20, 32, $1
939 addq $6, $1, $6
940$205:
941 sll $28, 32, $25
942 ldq $2, 0($18)
943 addq $5, $25, $5
944 bis $5, $5, $7
945 ldq $4, 24($17)
946 addq $23, $7, $23
947 srl $2, 32, $8
948 cmpult $23, $7, $3
949 zapnot $4, 15, $7
950 mulq $8, $7, $0
951 srl $28, 32, $1
952 addq $6, $1, $6
953 cmpult $5, $25, $1
954 zapnot $2, 15, $5
955 addq $1, $6, $6
956 addq $3, $6, $6
957 addq $22, $6, $22
958 cmpult $22, $6, $1
959 srl $4, 32, $6
960 mulq $5, $6, $25
961 mulq $7, $5, $2
962 addq $1, $24, $24
963 addq $0, $25, $0
964 cmpult $0, $25, $1
965 mulq $6, $8, $6
966 beq $1, $209
967 sll $20, 32, $1
968 addq $6, $1, $6
969$209:
970 sll $0, 32, $25
971 addq $2, $25, $2
972 bis $2, $2, $7
973 addq $23, $7, $23
974 stq $23, 24($16)
975 ldq $4, 32($17)
976 ldq $5, 0($18)
977 cmpult $23, $7, $3
978 zapnot $4, 15, $7
979 srl $5, 32, $8
980 mulq $8, $7, $28
981 srl $0, 32, $1
982 cmpult $2, $25, $2
983 addq $6, $1, $6
984 addq $2, $6, $6
985 addq $3, $6, $6
986 addq $22, $6, $22
987 cmpult $22, $6, $1
988 srl $4, 32, $6
989 zapnot $5, 15, $5
990 mulq $5, $6, $23
991 mulq $7, $5, $2
992 addq $1, $24, $24
993 addq $28, $23, $28
994 cmpult $28, $23, $1
995 mulq $6, $8, $6
996 beq $1, $213
997 sll $20, 32, $1
998 addq $6, $1, $6
999$213:
1000 sll $28, 32, $23
1001 ldq $1, 8($18)
1002 addq $2, $23, $2
1003 bis $2, $2, $7
1004 ldq $4, 24($17)
1005 addq $22, $7, $22
1006 srl $1, 32, $8
1007 cmpult $22, $7, $3
1008 zapnot $4, 15, $7
1009 mulq $8, $7, $25
1010 zapnot $1, 15, $5
1011 mulq $7, $5, $0
1012 srl $28, 32, $1
1013 cmpult $2, $23, $2
1014 addq $6, $1, $6
1230 addq $2, $6, $6 1015 addq $2, $6, $6
1231 addq $9, $6, $9 1016 addq $3, $6, $6
1232 cmpult $9, $6, $3 1017 addq $24, $6, $24
1233 addq $20, $3, $20 1018 cmpult $24, $6, $23
1234 mulq $28, $27, $5 1019 srl $4, 32, $6
1235 umulh $28, $27, $23 1020 mulq $5, $6, $5
1236 addq $19, $5, $19 1021 bis $31, 1, $21
1237 cmpult $19, $5, $1 1022 addq $25, $5, $25
1023 cmpult $25, $5, $1
1024 mulq $6, $8, $6
1025 beq $1, $217
1026 sll $21, 32, $1
1027 addq $6, $1, $6
1028$217:
1029 sll $25, 32, $5
1030 ldq $2, 16($18)
1031 addq $0, $5, $0
1032 bis $0, $0, $7
1033 ldq $4, 16($17)
1034 addq $22, $7, $22
1035 srl $2, 32, $8
1036 cmpult $22, $7, $3
1037 zapnot $4, 15, $7
1038 mulq $8, $7, $28
1039 srl $25, 32, $1
1040 addq $6, $1, $6
1041 cmpult $0, $5, $1
1042 zapnot $2, 15, $5
1043 addq $1, $6, $6
1044 addq $3, $6, $6
1045 addq $24, $6, $24
1046 cmpult $24, $6, $1
1047 srl $4, 32, $6
1048 mulq $5, $6, $25
1049 mulq $7, $5, $5
1238 addq $1, $23, $23 1050 addq $1, $23, $23
1239 addq $9, $23, $9 1051 addq $28, $25, $28
1240 cmpult $9, $23, $18 1052 cmpult $28, $25, $1
1241 addq $20, $18, $20 1053 mulq $6, $8, $6
1242 stq $19, 104($16) 1054 beq $1, $221
1243 bis $31, $31, $19 1055 sll $21, 32, $1
1244 mulq $28, $21, $7 1056 addq $6, $1, $6
1245 umulh $28, $21, $17 1057$221:
1246 addq $9, $7, $9 1058 sll $28, 32, $25
1247 cmpult $9, $7, $4 1059 ldq $2, 24($18)
1248 addq $4, $17, $17 1060 addq $5, $25, $5
1249 addq $20, $17, $20 1061 bis $5, $5, $7
1250 cmpult $20, $17, $10 1062 ldq $4, 8($17)
1251 addq $19, $10, $19 1063 addq $22, $7, $22
1252 stq $9, 112($16) 1064 srl $2, 32, $8
1253 stq $20, 120($16) 1065 cmpult $22, $7, $3
1254 ldq $9, 0($30) 1066 zapnot $4, 15, $7
1255 ldq $10, 8($30) 1067 mulq $8, $7, $0
1256 addq $30, 16, $30 1068 srl $28, 32, $1
1257 ret $31,($26),1 1069 addq $6, $1, $6
1070 cmpult $5, $25, $1
1071 zapnot $2, 15, $5
1072 addq $1, $6, $6
1073 addq $3, $6, $6
1074 addq $24, $6, $24
1075 cmpult $24, $6, $1
1076 srl $4, 32, $6
1077 mulq $5, $6, $25
1078 mulq $7, $5, $5
1079 addq $1, $23, $23
1080 addq $0, $25, $0
1081 cmpult $0, $25, $1
1082 mulq $6, $8, $6
1083 beq $1, $225
1084 sll $21, 32, $1
1085 addq $6, $1, $6
1086$225:
1087 sll $0, 32, $25
1088 ldq $2, 32($18)
1089 addq $5, $25, $5
1090 bis $5, $5, $7
1091 ldq $4, 0($17)
1092 addq $22, $7, $22
1093 srl $2, 32, $8
1094 cmpult $22, $7, $3
1095 zapnot $4, 15, $7
1096 mulq $8, $7, $28
1097 srl $0, 32, $1
1098 addq $6, $1, $6
1099 cmpult $5, $25, $1
1100 zapnot $2, 15, $5
1101 addq $1, $6, $6
1102 addq $3, $6, $6
1103 addq $24, $6, $24
1104 cmpult $24, $6, $1
1105 srl $4, 32, $6
1106 mulq $5, $6, $25
1107 mulq $7, $5, $2
1108 addq $1, $23, $23
1109 addq $28, $25, $28
1110 cmpult $28, $25, $1
1111 mulq $6, $8, $6
1112 beq $1, $229
1113 sll $21, 32, $1
1114 addq $6, $1, $6
1115$229:
1116 sll $28, 32, $25
1117 addq $2, $25, $2
1118 bis $2, $2, $7
1119 addq $22, $7, $22
1120 stq $22, 32($16)
1121 ldq $4, 0($17)
1122 ldq $5, 40($18)
1123 cmpult $22, $7, $3
1124 zapnot $4, 15, $7
1125 srl $5, 32, $8
1126 mulq $8, $7, $0
1127 srl $28, 32, $1
1128 cmpult $2, $25, $2
1129 addq $6, $1, $6
1130 addq $2, $6, $6
1131 addq $3, $6, $6
1132 addq $24, $6, $24
1133 cmpult $24, $6, $1
1134 srl $4, 32, $6
1135 zapnot $5, 15, $5
1136 mulq $5, $6, $22
1137 mulq $7, $5, $2
1138 addq $1, $23, $23
1139 addq $0, $22, $0
1140 cmpult $0, $22, $1
1141 mulq $6, $8, $6
1142 beq $1, $233
1143 sll $21, 32, $1
1144 addq $6, $1, $6
1145$233:
1146 sll $0, 32, $22
1147 ldq $1, 32($18)
1148 addq $2, $22, $2
1149 bis $2, $2, $7
1150 ldq $4, 8($17)
1151 addq $24, $7, $24
1152 srl $1, 32, $8
1153 cmpult $24, $7, $3
1154 zapnot $4, 15, $7
1155 mulq $8, $7, $25
1156 zapnot $1, 15, $5
1157 mulq $7, $5, $21
1158 srl $0, 32, $1
1159 cmpult $2, $22, $2
1160 addq $6, $1, $6
1161 addq $2, $6, $6
1162 addq $3, $6, $6
1163 addq $23, $6, $23
1164 cmpult $23, $6, $22
1165 srl $4, 32, $6
1166 mulq $5, $6, $5
1167 bis $31, 1, $20
1168 addq $25, $5, $25
1169 cmpult $25, $5, $1
1170 mulq $6, $8, $6
1171 beq $1, $237
1172 sll $20, 32, $1
1173 addq $6, $1, $6
1174$237:
1175 sll $25, 32, $5
1176 ldq $2, 24($18)
1177 addq $21, $5, $21
1178 bis $21, $21, $7
1179 ldq $4, 16($17)
1180 addq $24, $7, $24
1181 srl $2, 32, $8
1182 cmpult $24, $7, $3
1183 zapnot $4, 15, $7
1184 mulq $8, $7, $28
1185 srl $25, 32, $1
1186 addq $6, $1, $6
1187 cmpult $21, $5, $1
1188 zapnot $2, 15, $5
1189 addq $1, $6, $6
1190 addq $3, $6, $6
1191 addq $23, $6, $23
1192 cmpult $23, $6, $1
1193 srl $4, 32, $6
1194 mulq $5, $6, $25
1195 mulq $7, $5, $5
1196 addq $1, $22, $22
1197 addq $28, $25, $28
1198 cmpult $28, $25, $1
1199 mulq $6, $8, $6
1200 beq $1, $241
1201 sll $20, 32, $1
1202 addq $6, $1, $6
1203$241:
1204 sll $28, 32, $25
1205 ldq $2, 16($18)
1206 addq $5, $25, $5
1207 bis $5, $5, $7
1208 ldq $4, 24($17)
1209 addq $24, $7, $24
1210 srl $2, 32, $8
1211 cmpult $24, $7, $3
1212 zapnot $4, 15, $7
1213 mulq $8, $7, $0
1214 srl $28, 32, $1
1215 addq $6, $1, $6
1216 cmpult $5, $25, $1
1217 zapnot $2, 15, $5
1218 addq $1, $6, $6
1219 addq $3, $6, $6
1220 addq $23, $6, $23
1221 cmpult $23, $6, $1
1222 srl $4, 32, $6
1223 mulq $5, $6, $25
1224 mulq $7, $5, $5
1225 addq $1, $22, $22
1226 addq $0, $25, $0
1227 cmpult $0, $25, $1
1228 mulq $6, $8, $6
1229 beq $1, $245
1230 sll $20, 32, $1
1231 addq $6, $1, $6
1232$245:
1233 sll $0, 32, $25
1234 ldq $2, 8($18)
1235 addq $5, $25, $5
1236 bis $5, $5, $7
1237 ldq $4, 32($17)
1238 addq $24, $7, $24
1239 srl $2, 32, $8
1240 cmpult $24, $7, $3
1241 zapnot $4, 15, $7
1242 mulq $8, $7, $28
1243 srl $0, 32, $1
1244 addq $6, $1, $6
1245 cmpult $5, $25, $1
1246 zapnot $2, 15, $5
1247 addq $1, $6, $6
1248 addq $3, $6, $6
1249 addq $23, $6, $23
1250 cmpult $23, $6, $1
1251 srl $4, 32, $6
1252 mulq $5, $6, $25
1253 mulq $7, $5, $5
1254 addq $1, $22, $22
1255 addq $28, $25, $28
1256 cmpult $28, $25, $1
1257 mulq $6, $8, $6
1258 beq $1, $249
1259 sll $20, 32, $1
1260 addq $6, $1, $6
1261$249:
1262 sll $28, 32, $25
1263 ldq $2, 0($18)
1264 addq $5, $25, $5
1265 bis $5, $5, $7
1266 ldq $4, 40($17)
1267 addq $24, $7, $24
1268 srl $2, 32, $8
1269 cmpult $24, $7, $3
1270 zapnot $4, 15, $7
1271 mulq $8, $7, $0
1272 srl $28, 32, $1
1273 addq $6, $1, $6
1274 cmpult $5, $25, $1
1275 zapnot $2, 15, $5
1276 addq $1, $6, $6
1277 addq $3, $6, $6
1278 addq $23, $6, $23
1279 cmpult $23, $6, $1
1280 srl $4, 32, $6
1281 mulq $5, $6, $25
1282 mulq $7, $5, $2
1283 addq $1, $22, $22
1284 addq $0, $25, $0
1285 cmpult $0, $25, $1
1286 mulq $6, $8, $6
1287 beq $1, $253
1288 sll $20, 32, $1
1289 addq $6, $1, $6
1290$253:
1291 sll $0, 32, $25
1292 addq $2, $25, $2
1293 bis $2, $2, $7
1294 addq $24, $7, $24
1295 stq $24, 40($16)
1296 ldq $4, 48($17)
1297 ldq $5, 0($18)
1298 cmpult $24, $7, $3
1299 zapnot $4, 15, $7
1300 srl $5, 32, $8
1301 mulq $8, $7, $28
1302 srl $0, 32, $1
1303 cmpult $2, $25, $2
1304 addq $6, $1, $6
1305 addq $2, $6, $6
1306 addq $3, $6, $6
1307 addq $23, $6, $23
1308 cmpult $23, $6, $1
1309 srl $4, 32, $6
1310 zapnot $5, 15, $5
1311 mulq $5, $6, $24
1312 mulq $7, $5, $2
1313 addq $1, $22, $22
1314 addq $28, $24, $28
1315 cmpult $28, $24, $1
1316 mulq $6, $8, $6
1317 beq $1, $257
1318 sll $20, 32, $1
1319 addq $6, $1, $6
1320$257:
1321 sll $28, 32, $24
1322 ldq $1, 8($18)
1323 addq $2, $24, $2
1324 bis $2, $2, $7
1325 ldq $4, 40($17)
1326 addq $23, $7, $23
1327 srl $1, 32, $8
1328 cmpult $23, $7, $3
1329 zapnot $4, 15, $7
1330 mulq $8, $7, $25
1331 zapnot $1, 15, $5
1332 mulq $7, $5, $0
1333 srl $28, 32, $1
1334 cmpult $2, $24, $2
1335 addq $6, $1, $6
1336 addq $2, $6, $6
1337 addq $3, $6, $6
1338 addq $22, $6, $22
1339 cmpult $22, $6, $24
1340 srl $4, 32, $6
1341 mulq $5, $6, $5
1342 bis $31, 1, $21
1343 addq $25, $5, $25
1344 cmpult $25, $5, $1
1345 mulq $6, $8, $6
1346 beq $1, $261
1347 sll $21, 32, $1
1348 addq $6, $1, $6
1349$261:
1350 sll $25, 32, $5
1351 ldq $2, 16($18)
1352 addq $0, $5, $0
1353 bis $0, $0, $7
1354 ldq $4, 32($17)
1355 addq $23, $7, $23
1356 srl $2, 32, $8
1357 cmpult $23, $7, $3
1358 zapnot $4, 15, $7
1359 mulq $8, $7, $28
1360 srl $25, 32, $1
1361 addq $6, $1, $6
1362 cmpult $0, $5, $1
1363 zapnot $2, 15, $5
1364 addq $1, $6, $6
1365 addq $3, $6, $6
1366 addq $22, $6, $22
1367 cmpult $22, $6, $1
1368 srl $4, 32, $6
1369 mulq $5, $6, $25
1370 mulq $7, $5, $5
1371 addq $1, $24, $24
1372 addq $28, $25, $28
1373 cmpult $28, $25, $1
1374 mulq $6, $8, $6
1375 beq $1, $265
1376 sll $21, 32, $1
1377 addq $6, $1, $6
1378$265:
1379 sll $28, 32, $25
1380 ldq $2, 24($18)
1381 addq $5, $25, $5
1382 bis $5, $5, $7
1383 ldq $4, 24($17)
1384 addq $23, $7, $23
1385 srl $2, 32, $8
1386 cmpult $23, $7, $3
1387 zapnot $4, 15, $7
1388 mulq $8, $7, $0
1389 srl $28, 32, $1
1390 addq $6, $1, $6
1391 cmpult $5, $25, $1
1392 zapnot $2, 15, $5
1393 addq $1, $6, $6
1394 addq $3, $6, $6
1395 addq $22, $6, $22
1396 cmpult $22, $6, $1
1397 srl $4, 32, $6
1398 mulq $5, $6, $25
1399 mulq $7, $5, $5
1400 addq $1, $24, $24
1401 addq $0, $25, $0
1402 cmpult $0, $25, $1
1403 mulq $6, $8, $6
1404 beq $1, $269
1405 sll $21, 32, $1
1406 addq $6, $1, $6
1407$269:
1408 sll $0, 32, $25
1409 ldq $2, 32($18)
1410 addq $5, $25, $5
1411 bis $5, $5, $7
1412 ldq $4, 16($17)
1413 addq $23, $7, $23
1414 srl $2, 32, $8
1415 cmpult $23, $7, $3
1416 zapnot $4, 15, $7
1417 mulq $8, $7, $28
1418 srl $0, 32, $1
1419 addq $6, $1, $6
1420 cmpult $5, $25, $1
1421 zapnot $2, 15, $5
1422 addq $1, $6, $6
1423 addq $3, $6, $6
1424 addq $22, $6, $22
1425 cmpult $22, $6, $1
1426 srl $4, 32, $6
1427 mulq $5, $6, $25
1428 mulq $7, $5, $5
1429 addq $1, $24, $24
1430 addq $28, $25, $28
1431 cmpult $28, $25, $1
1432 mulq $6, $8, $6
1433 beq $1, $273
1434 sll $21, 32, $1
1435 addq $6, $1, $6
1436$273:
1437 sll $28, 32, $25
1438 ldq $2, 40($18)
1439 addq $5, $25, $5
1440 bis $5, $5, $7
1441 ldq $4, 8($17)
1442 addq $23, $7, $23
1443 srl $2, 32, $8
1444 cmpult $23, $7, $3
1445 zapnot $4, 15, $7
1446 mulq $8, $7, $0
1447 srl $28, 32, $1
1448 addq $6, $1, $6
1449 cmpult $5, $25, $1
1450 zapnot $2, 15, $5
1451 addq $1, $6, $6
1452 addq $3, $6, $6
1453 addq $22, $6, $22
1454 cmpult $22, $6, $1
1455 srl $4, 32, $6
1456 mulq $5, $6, $25
1457 mulq $7, $5, $5
1458 addq $1, $24, $24
1459 addq $0, $25, $0
1460 cmpult $0, $25, $1
1461 mulq $6, $8, $6
1462 beq $1, $277
1463 sll $21, 32, $1
1464 addq $6, $1, $6
1465$277:
1466 sll $0, 32, $25
1467 ldq $2, 48($18)
1468 addq $5, $25, $5
1469 bis $5, $5, $7
1470 ldq $4, 0($17)
1471 addq $23, $7, $23
1472 srl $2, 32, $8
1473 cmpult $23, $7, $3
1474 zapnot $4, 15, $7
1475 mulq $8, $7, $28
1476 srl $0, 32, $1
1477 addq $6, $1, $6
1478 cmpult $5, $25, $1
1479 zapnot $2, 15, $5
1480 addq $1, $6, $6
1481 addq $3, $6, $6
1482 addq $22, $6, $22
1483 cmpult $22, $6, $1
1484 srl $4, 32, $6
1485 mulq $5, $6, $25
1486 mulq $7, $5, $2
1487 addq $1, $24, $24
1488 addq $28, $25, $28
1489 cmpult $28, $25, $1
1490 mulq $6, $8, $6
1491 beq $1, $281
1492 sll $21, 32, $1
1493 addq $6, $1, $6
1494$281:
1495 sll $28, 32, $25
1496 addq $2, $25, $2
1497 bis $2, $2, $7
1498 addq $23, $7, $23
1499 stq $23, 48($16)
1500 ldq $4, 0($17)
1501 ldq $5, 56($18)
1502 cmpult $23, $7, $3
1503 zapnot $4, 15, $7
1504 srl $5, 32, $8
1505 mulq $8, $7, $0
1506 srl $28, 32, $1
1507 cmpult $2, $25, $2
1508 addq $6, $1, $6
1509 addq $2, $6, $6
1510 addq $3, $6, $6
1511 addq $22, $6, $22
1512 cmpult $22, $6, $1
1513 srl $4, 32, $6
1514 zapnot $5, 15, $5
1515 mulq $5, $6, $23
1516 mulq $7, $5, $2
1517 addq $1, $24, $24
1518 addq $0, $23, $0
1519 cmpult $0, $23, $1
1520 mulq $6, $8, $6
1521 beq $1, $285
1522 sll $21, 32, $1
1523 addq $6, $1, $6
1524$285:
1525 sll $0, 32, $23
1526 ldq $1, 48($18)
1527 addq $2, $23, $2
1528 bis $2, $2, $7
1529 ldq $4, 8($17)
1530 addq $22, $7, $22
1531 srl $1, 32, $8
1532 cmpult $22, $7, $3
1533 zapnot $4, 15, $7
1534 mulq $8, $7, $25
1535 zapnot $1, 15, $5
1536 mulq $7, $5, $21
1537 srl $0, 32, $1
1538 cmpult $2, $23, $2
1539 addq $6, $1, $6
1540 addq $2, $6, $6
1541 addq $3, $6, $6
1542 addq $24, $6, $24
1543 cmpult $24, $6, $23
1544 srl $4, 32, $6
1545 mulq $5, $6, $5
1546 bis $31, 1, $20
1547 addq $25, $5, $25
1548 cmpult $25, $5, $1
1549 mulq $6, $8, $6
1550 beq $1, $289
1551 sll $20, 32, $1
1552 addq $6, $1, $6
1553$289:
1554 sll $25, 32, $5
1555 ldq $2, 40($18)
1556 addq $21, $5, $21
1557 bis $21, $21, $7
1558 ldq $4, 16($17)
1559 addq $22, $7, $22
1560 srl $2, 32, $8
1561 cmpult $22, $7, $3
1562 zapnot $4, 15, $7
1563 mulq $8, $7, $28
1564 srl $25, 32, $1
1565 addq $6, $1, $6
1566 cmpult $21, $5, $1
1567 zapnot $2, 15, $5
1568 addq $1, $6, $6
1569 addq $3, $6, $6
1570 addq $24, $6, $24
1571 cmpult $24, $6, $1
1572 srl $4, 32, $6
1573 mulq $5, $6, $25
1574 mulq $7, $5, $5
1575 addq $1, $23, $23
1576 addq $28, $25, $28
1577 cmpult $28, $25, $1
1578 mulq $6, $8, $6
1579 beq $1, $293
1580 sll $20, 32, $1
1581 addq $6, $1, $6
1582$293:
1583 sll $28, 32, $25
1584 ldq $2, 32($18)
1585 addq $5, $25, $5
1586 bis $5, $5, $7
1587 ldq $4, 24($17)
1588 addq $22, $7, $22
1589 srl $2, 32, $8
1590 cmpult $22, $7, $3
1591 zapnot $4, 15, $7
1592 mulq $8, $7, $0
1593 srl $28, 32, $1
1594 addq $6, $1, $6
1595 cmpult $5, $25, $1
1596 zapnot $2, 15, $5
1597 addq $1, $6, $6
1598 addq $3, $6, $6
1599 addq $24, $6, $24
1600 cmpult $24, $6, $1
1601 srl $4, 32, $6
1602 mulq $5, $6, $25
1603 mulq $7, $5, $5
1604 addq $1, $23, $23
1605 addq $0, $25, $0
1606 cmpult $0, $25, $1
1607 mulq $6, $8, $6
1608 beq $1, $297
1609 sll $20, 32, $1
1610 addq $6, $1, $6
1611$297:
1612 sll $0, 32, $25
1613 ldq $2, 24($18)
1614 addq $5, $25, $5
1615 bis $5, $5, $7
1616 ldq $4, 32($17)
1617 addq $22, $7, $22
1618 srl $2, 32, $8
1619 cmpult $22, $7, $3
1620 zapnot $4, 15, $7
1621 mulq $8, $7, $28
1622 srl $0, 32, $1
1623 addq $6, $1, $6
1624 cmpult $5, $25, $1
1625 zapnot $2, 15, $5
1626 addq $1, $6, $6
1627 addq $3, $6, $6
1628 addq $24, $6, $24
1629 cmpult $24, $6, $1
1630 srl $4, 32, $6
1631 mulq $5, $6, $25
1632 mulq $7, $5, $5
1633 addq $1, $23, $23
1634 addq $28, $25, $28
1635 cmpult $28, $25, $1
1636 mulq $6, $8, $6
1637 beq $1, $301
1638 sll $20, 32, $1
1639 addq $6, $1, $6
1640$301:
1641 sll $28, 32, $25
1642 ldq $2, 16($18)
1643 addq $5, $25, $5
1644 bis $5, $5, $7
1645 ldq $4, 40($17)
1646 addq $22, $7, $22
1647 srl $2, 32, $8
1648 cmpult $22, $7, $3
1649 zapnot $4, 15, $7
1650 mulq $8, $7, $0
1651 srl $28, 32, $1
1652 addq $6, $1, $6
1653 cmpult $5, $25, $1
1654 zapnot $2, 15, $5
1655 addq $1, $6, $6
1656 addq $3, $6, $6
1657 addq $24, $6, $24
1658 cmpult $24, $6, $1
1659 srl $4, 32, $6
1660 mulq $5, $6, $25
1661 mulq $7, $5, $5
1662 addq $1, $23, $23
1663 addq $0, $25, $0
1664 cmpult $0, $25, $1
1665 mulq $6, $8, $6
1666 beq $1, $305
1667 sll $20, 32, $1
1668 addq $6, $1, $6
1669$305:
1670 sll $0, 32, $25
1671 ldq $2, 8($18)
1672 addq $5, $25, $5
1673 bis $5, $5, $7
1674 ldq $4, 48($17)
1675 addq $22, $7, $22
1676 srl $2, 32, $8
1677 cmpult $22, $7, $3
1678 zapnot $4, 15, $7
1679 mulq $8, $7, $28
1680 srl $0, 32, $1
1681 addq $6, $1, $6
1682 cmpult $5, $25, $1
1683 zapnot $2, 15, $5
1684 addq $1, $6, $6
1685 addq $3, $6, $6
1686 addq $24, $6, $24
1687 cmpult $24, $6, $1
1688 srl $4, 32, $6
1689 mulq $5, $6, $25
1690 mulq $7, $5, $5
1691 addq $1, $23, $23
1692 addq $28, $25, $28
1693 cmpult $28, $25, $1
1694 mulq $6, $8, $6
1695 beq $1, $309
1696 sll $20, 32, $1
1697 addq $6, $1, $6
1698$309:
1699 sll $28, 32, $25
1700 ldq $2, 0($18)
1701 addq $5, $25, $5
1702 bis $5, $5, $7
1703 ldq $4, 56($17)
1704 addq $22, $7, $22
1705 srl $2, 32, $8
1706 cmpult $22, $7, $3
1707 zapnot $4, 15, $7
1708 mulq $8, $7, $0
1709 srl $28, 32, $1
1710 addq $6, $1, $6
1711 cmpult $5, $25, $1
1712 zapnot $2, 15, $5
1713 addq $1, $6, $6
1714 addq $3, $6, $6
1715 addq $24, $6, $24
1716 cmpult $24, $6, $1
1717 srl $4, 32, $6
1718 mulq $5, $6, $25
1719 mulq $7, $5, $2
1720 addq $1, $23, $23
1721 addq $0, $25, $0
1722 cmpult $0, $25, $1
1723 mulq $6, $8, $6
1724 beq $1, $313
1725 sll $20, 32, $1
1726 addq $6, $1, $6
1727$313:
1728 sll $0, 32, $25
1729 addq $2, $25, $2
1730 bis $2, $2, $7
1731 addq $22, $7, $22
1732 stq $22, 56($16)
1733 ldq $4, 56($17)
1734 ldq $5, 8($18)
1735 cmpult $22, $7, $3
1736 zapnot $4, 15, $7
1737 srl $5, 32, $8
1738 mulq $8, $7, $28
1739 srl $0, 32, $1
1740 cmpult $2, $25, $2
1741 addq $6, $1, $6
1742 addq $2, $6, $6
1743 addq $3, $6, $6
1744 addq $24, $6, $24
1745 cmpult $24, $6, $1
1746 srl $4, 32, $6
1747 zapnot $5, 15, $5
1748 mulq $5, $6, $22
1749 mulq $7, $5, $2
1750 addq $1, $23, $23
1751 addq $28, $22, $28
1752 cmpult $28, $22, $1
1753 mulq $6, $8, $6
1754 beq $1, $317
1755 sll $20, 32, $1
1756 addq $6, $1, $6
1757$317:
1758 sll $28, 32, $22
1759 ldq $1, 16($18)
1760 addq $2, $22, $2
1761 bis $2, $2, $7
1762 ldq $4, 48($17)
1763 addq $24, $7, $24
1764 srl $1, 32, $8
1765 cmpult $24, $7, $3
1766 zapnot $4, 15, $7
1767 mulq $8, $7, $25
1768 zapnot $1, 15, $5
1769 mulq $7, $5, $0
1770 srl $28, 32, $1
1771 cmpult $2, $22, $2
1772 addq $6, $1, $6
1773 addq $2, $6, $6
1774 addq $3, $6, $6
1775 addq $23, $6, $23
1776 cmpult $23, $6, $22
1777 srl $4, 32, $6
1778 mulq $5, $6, $5
1779 bis $31, 1, $21
1780 addq $25, $5, $25
1781 cmpult $25, $5, $1
1782 mulq $6, $8, $6
1783 beq $1, $321
1784 sll $21, 32, $1
1785 addq $6, $1, $6
1786$321:
1787 sll $25, 32, $5
1788 ldq $2, 24($18)
1789 addq $0, $5, $0
1790 bis $0, $0, $7
1791 ldq $4, 40($17)
1792 addq $24, $7, $24
1793 srl $2, 32, $8
1794 cmpult $24, $7, $3
1795 zapnot $4, 15, $7
1796 mulq $8, $7, $28
1797 srl $25, 32, $1
1798 addq $6, $1, $6
1799 cmpult $0, $5, $1
1800 zapnot $2, 15, $5
1801 addq $1, $6, $6
1802 addq $3, $6, $6
1803 addq $23, $6, $23
1804 cmpult $23, $6, $1
1805 srl $4, 32, $6
1806 mulq $5, $6, $25
1807 mulq $7, $5, $5
1808 addq $1, $22, $22
1809 addq $28, $25, $28
1810 cmpult $28, $25, $1
1811 mulq $6, $8, $6
1812 beq $1, $325
1813 sll $21, 32, $1
1814 addq $6, $1, $6
1815$325:
1816 sll $28, 32, $25
1817 ldq $2, 32($18)
1818 addq $5, $25, $5
1819 bis $5, $5, $7
1820 ldq $4, 32($17)
1821 addq $24, $7, $24
1822 srl $2, 32, $8
1823 cmpult $24, $7, $3
1824 zapnot $4, 15, $7
1825 mulq $8, $7, $0
1826 srl $28, 32, $1
1827 addq $6, $1, $6
1828 cmpult $5, $25, $1
1829 zapnot $2, 15, $5
1830 addq $1, $6, $6
1831 addq $3, $6, $6
1832 addq $23, $6, $23
1833 cmpult $23, $6, $1
1834 srl $4, 32, $6
1835 mulq $5, $6, $25
1836 mulq $7, $5, $5
1837 addq $1, $22, $22
1838 addq $0, $25, $0
1839 cmpult $0, $25, $1
1840 mulq $6, $8, $6
1841 beq $1, $329
1842 sll $21, 32, $1
1843 addq $6, $1, $6
1844$329:
1845 sll $0, 32, $25
1846 ldq $2, 40($18)
1847 addq $5, $25, $5
1848 bis $5, $5, $7
1849 ldq $4, 24($17)
1850 addq $24, $7, $24
1851 srl $2, 32, $8
1852 cmpult $24, $7, $3
1853 zapnot $4, 15, $7
1854 mulq $8, $7, $28
1855 srl $0, 32, $1
1856 addq $6, $1, $6
1857 cmpult $5, $25, $1
1858 zapnot $2, 15, $5
1859 addq $1, $6, $6
1860 addq $3, $6, $6
1861 addq $23, $6, $23
1862 cmpult $23, $6, $1
1863 srl $4, 32, $6
1864 mulq $5, $6, $25
1865 mulq $7, $5, $5
1866 addq $1, $22, $22
1867 addq $28, $25, $28
1868 cmpult $28, $25, $1
1869 mulq $6, $8, $6
1870 beq $1, $333
1871 sll $21, 32, $1
1872 addq $6, $1, $6
1873$333:
1874 sll $28, 32, $25
1875 ldq $2, 48($18)
1876 addq $5, $25, $5
1877 bis $5, $5, $7
1878 ldq $4, 16($17)
1879 addq $24, $7, $24
1880 srl $2, 32, $8
1881 cmpult $24, $7, $3
1882 zapnot $4, 15, $7
1883 mulq $8, $7, $0
1884 srl $28, 32, $1
1885 addq $6, $1, $6
1886 cmpult $5, $25, $1
1887 zapnot $2, 15, $5
1888 addq $1, $6, $6
1889 addq $3, $6, $6
1890 addq $23, $6, $23
1891 cmpult $23, $6, $1
1892 srl $4, 32, $6
1893 mulq $5, $6, $25
1894 mulq $7, $5, $5
1895 addq $1, $22, $22
1896 addq $0, $25, $0
1897 cmpult $0, $25, $1
1898 mulq $6, $8, $6
1899 beq $1, $337
1900 sll $21, 32, $1
1901 addq $6, $1, $6
1902$337:
1903 sll $0, 32, $25
1904 ldq $2, 56($18)
1905 addq $5, $25, $5
1906 bis $5, $5, $7
1907 ldq $4, 8($17)
1908 addq $24, $7, $24
1909 srl $2, 32, $8
1910 cmpult $24, $7, $3
1911 zapnot $4, 15, $7
1912 mulq $8, $7, $28
1913 srl $0, 32, $1
1914 addq $6, $1, $6
1915 cmpult $5, $25, $1
1916 zapnot $2, 15, $5
1917 addq $1, $6, $6
1918 addq $3, $6, $6
1919 addq $23, $6, $23
1920 cmpult $23, $6, $1
1921 srl $4, 32, $6
1922 mulq $5, $6, $25
1923 mulq $7, $5, $2
1924 addq $1, $22, $22
1925 addq $28, $25, $28
1926 cmpult $28, $25, $1
1927 mulq $6, $8, $6
1928 beq $1, $341
1929 sll $21, 32, $1
1930 addq $6, $1, $6
1931$341:
1932 sll $28, 32, $25
1933 addq $2, $25, $2
1934 bis $2, $2, $7
1935 addq $24, $7, $24
1936 stq $24, 64($16)
1937 ldq $4, 16($17)
1938 ldq $5, 56($18)
1939 cmpult $24, $7, $3
1940 zapnot $4, 15, $7
1941 srl $5, 32, $8
1942 mulq $8, $7, $0
1943 srl $28, 32, $1
1944 cmpult $2, $25, $2
1945 addq $6, $1, $6
1946 addq $2, $6, $6
1947 addq $3, $6, $6
1948 addq $23, $6, $23
1949 cmpult $23, $6, $1
1950 srl $4, 32, $6
1951 zapnot $5, 15, $5
1952 mulq $5, $6, $24
1953 mulq $7, $5, $2
1954 addq $1, $22, $22
1955 addq $0, $24, $0
1956 cmpult $0, $24, $1
1957 mulq $6, $8, $6
1958 beq $1, $345
1959 sll $21, 32, $1
1960 addq $6, $1, $6
1961$345:
1962 sll $0, 32, $24
1963 ldq $1, 48($18)
1964 addq $2, $24, $2
1965 bis $2, $2, $7
1966 ldq $4, 24($17)
1967 addq $23, $7, $23
1968 srl $1, 32, $8
1969 cmpult $23, $7, $3
1970 zapnot $4, 15, $7
1971 mulq $8, $7, $25
1972 zapnot $1, 15, $5
1973 mulq $7, $5, $21
1974 srl $0, 32, $1
1975 cmpult $2, $24, $2
1976 addq $6, $1, $6
1977 addq $2, $6, $6
1978 addq $3, $6, $6
1979 addq $22, $6, $22
1980 cmpult $22, $6, $24
1981 srl $4, 32, $6
1982 mulq $5, $6, $5
1983 bis $31, 1, $20
1984 addq $25, $5, $25
1985 cmpult $25, $5, $1
1986 mulq $6, $8, $6
1987 beq $1, $349
1988 sll $20, 32, $1
1989 addq $6, $1, $6
1990$349:
1991 sll $25, 32, $5
1992 ldq $2, 40($18)
1993 addq $21, $5, $21
1994 bis $21, $21, $7
1995 ldq $4, 32($17)
1996 addq $23, $7, $23
1997 srl $2, 32, $8
1998 cmpult $23, $7, $3
1999 zapnot $4, 15, $7
2000 mulq $8, $7, $28
2001 srl $25, 32, $1
2002 addq $6, $1, $6
2003 cmpult $21, $5, $1
2004 zapnot $2, 15, $5
2005 addq $1, $6, $6
2006 addq $3, $6, $6
2007 addq $22, $6, $22
2008 cmpult $22, $6, $1
2009 srl $4, 32, $6
2010 mulq $5, $6, $25
2011 mulq $7, $5, $5
2012 addq $1, $24, $24
2013 addq $28, $25, $28
2014 cmpult $28, $25, $1
2015 mulq $6, $8, $6
2016 beq $1, $353
2017 sll $20, 32, $1
2018 addq $6, $1, $6
2019$353:
2020 sll $28, 32, $25
2021 ldq $2, 32($18)
2022 addq $5, $25, $5
2023 bis $5, $5, $7
2024 ldq $4, 40($17)
2025 addq $23, $7, $23
2026 srl $2, 32, $8
2027 cmpult $23, $7, $3
2028 zapnot $4, 15, $7
2029 mulq $8, $7, $0
2030 srl $28, 32, $1
2031 addq $6, $1, $6
2032 cmpult $5, $25, $1
2033 zapnot $2, 15, $5
2034 addq $1, $6, $6
2035 addq $3, $6, $6
2036 addq $22, $6, $22
2037 cmpult $22, $6, $1
2038 srl $4, 32, $6
2039 mulq $5, $6, $25
2040 mulq $7, $5, $5
2041 addq $1, $24, $24
2042 addq $0, $25, $0
2043 cmpult $0, $25, $1
2044 mulq $6, $8, $6
2045 beq $1, $357
2046 sll $20, 32, $1
2047 addq $6, $1, $6
2048$357:
2049 sll $0, 32, $25
2050 ldq $2, 24($18)
2051 addq $5, $25, $5
2052 bis $5, $5, $7
2053 ldq $4, 48($17)
2054 addq $23, $7, $23
2055 srl $2, 32, $8
2056 cmpult $23, $7, $3
2057 zapnot $4, 15, $7
2058 mulq $8, $7, $28
2059 srl $0, 32, $1
2060 addq $6, $1, $6
2061 cmpult $5, $25, $1
2062 zapnot $2, 15, $5
2063 addq $1, $6, $6
2064 addq $3, $6, $6
2065 addq $22, $6, $22
2066 cmpult $22, $6, $1
2067 srl $4, 32, $6
2068 mulq $5, $6, $25
2069 mulq $7, $5, $5
2070 addq $1, $24, $24
2071 addq $28, $25, $28
2072 cmpult $28, $25, $1
2073 mulq $6, $8, $6
2074 beq $1, $361
2075 sll $20, 32, $1
2076 addq $6, $1, $6
2077$361:
2078 sll $28, 32, $25
2079 ldq $2, 16($18)
2080 addq $5, $25, $5
2081 bis $5, $5, $7
2082 ldq $4, 56($17)
2083 addq $23, $7, $23
2084 srl $2, 32, $8
2085 cmpult $23, $7, $3
2086 zapnot $4, 15, $7
2087 mulq $8, $7, $0
2088 srl $28, 32, $1
2089 addq $6, $1, $6
2090 cmpult $5, $25, $1
2091 zapnot $2, 15, $5
2092 addq $1, $6, $6
2093 addq $3, $6, $6
2094 addq $22, $6, $22
2095 cmpult $22, $6, $1
2096 srl $4, 32, $6
2097 mulq $5, $6, $25
2098 mulq $7, $5, $2
2099 addq $1, $24, $24
2100 addq $0, $25, $0
2101 cmpult $0, $25, $1
2102 mulq $6, $8, $6
2103 beq $1, $365
2104 sll $20, 32, $1
2105 addq $6, $1, $6
2106$365:
2107 sll $0, 32, $25
2108 addq $2, $25, $2
2109 bis $2, $2, $7
2110 addq $23, $7, $23
2111 stq $23, 72($16)
2112 ldq $4, 56($17)
2113 ldq $5, 24($18)
2114 cmpult $23, $7, $3
2115 zapnot $4, 15, $7
2116 srl $5, 32, $8
2117 mulq $8, $7, $28
2118 srl $0, 32, $1
2119 cmpult $2, $25, $2
2120 addq $6, $1, $6
2121 addq $2, $6, $6
2122 addq $3, $6, $6
2123 addq $22, $6, $22
2124 cmpult $22, $6, $1
2125 srl $4, 32, $6
2126 zapnot $5, 15, $5
2127 mulq $5, $6, $23
2128 mulq $7, $5, $2
2129 addq $1, $24, $24
2130 addq $28, $23, $28
2131 cmpult $28, $23, $1
2132 mulq $6, $8, $6
2133 beq $1, $369
2134 sll $20, 32, $1
2135 addq $6, $1, $6
2136$369:
2137 sll $28, 32, $23
2138 ldq $1, 32($18)
2139 addq $2, $23, $2
2140 bis $2, $2, $7
2141 ldq $4, 48($17)
2142 addq $22, $7, $22
2143 srl $1, 32, $8
2144 cmpult $22, $7, $3
2145 zapnot $4, 15, $7
2146 mulq $8, $7, $25
2147 zapnot $1, 15, $5
2148 mulq $7, $5, $0
2149 srl $28, 32, $1
2150 cmpult $2, $23, $2
2151 addq $6, $1, $6
2152 addq $2, $6, $6
2153 addq $3, $6, $6
2154 addq $24, $6, $24
2155 cmpult $24, $6, $23
2156 srl $4, 32, $6
2157 mulq $5, $6, $5
2158 bis $31, 1, $21
2159 addq $25, $5, $25
2160 cmpult $25, $5, $1
2161 mulq $6, $8, $6
2162 beq $1, $373
2163 sll $21, 32, $1
2164 addq $6, $1, $6
2165$373:
2166 sll $25, 32, $5
2167 ldq $2, 40($18)
2168 addq $0, $5, $0
2169 bis $0, $0, $7
2170 ldq $4, 40($17)
2171 addq $22, $7, $22
2172 srl $2, 32, $8
2173 cmpult $22, $7, $3
2174 zapnot $4, 15, $7
2175 mulq $8, $7, $28
2176 srl $25, 32, $1
2177 addq $6, $1, $6
2178 cmpult $0, $5, $1
2179 zapnot $2, 15, $5
2180 addq $1, $6, $6
2181 addq $3, $6, $6
2182 addq $24, $6, $24
2183 cmpult $24, $6, $1
2184 srl $4, 32, $6
2185 mulq $5, $6, $25
2186 mulq $7, $5, $5
2187 addq $1, $23, $23
2188 addq $28, $25, $28
2189 cmpult $28, $25, $1
2190 mulq $6, $8, $6
2191 beq $1, $377
2192 sll $21, 32, $1
2193 addq $6, $1, $6
2194$377:
2195 sll $28, 32, $25
2196 ldq $2, 48($18)
2197 addq $5, $25, $5
2198 bis $5, $5, $7
2199 ldq $4, 32($17)
2200 addq $22, $7, $22
2201 srl $2, 32, $8
2202 cmpult $22, $7, $3
2203 zapnot $4, 15, $7
2204 mulq $8, $7, $0
2205 srl $28, 32, $1
2206 addq $6, $1, $6
2207 cmpult $5, $25, $1
2208 zapnot $2, 15, $5
2209 addq $1, $6, $6
2210 addq $3, $6, $6
2211 addq $24, $6, $24
2212 cmpult $24, $6, $1
2213 srl $4, 32, $6
2214 mulq $5, $6, $25
2215 mulq $7, $5, $5
2216 addq $1, $23, $23
2217 addq $0, $25, $0
2218 cmpult $0, $25, $1
2219 mulq $6, $8, $6
2220 beq $1, $381
2221 sll $21, 32, $1
2222 addq $6, $1, $6
2223$381:
2224 sll $0, 32, $25
2225 ldq $2, 56($18)
2226 addq $5, $25, $5
2227 bis $5, $5, $7
2228 ldq $4, 24($17)
2229 addq $22, $7, $22
2230 srl $2, 32, $8
2231 cmpult $22, $7, $3
2232 zapnot $4, 15, $7
2233 mulq $8, $7, $28
2234 srl $0, 32, $1
2235 addq $6, $1, $6
2236 cmpult $5, $25, $1
2237 zapnot $2, 15, $5
2238 addq $1, $6, $6
2239 addq $3, $6, $6
2240 addq $24, $6, $24
2241 cmpult $24, $6, $1
2242 srl $4, 32, $6
2243 mulq $5, $6, $25
2244 mulq $7, $5, $2
2245 addq $1, $23, $23
2246 addq $28, $25, $28
2247 cmpult $28, $25, $1
2248 mulq $6, $8, $6
2249 beq $1, $385
2250 sll $21, 32, $1
2251 addq $6, $1, $6
2252$385:
2253 sll $28, 32, $25
2254 addq $2, $25, $2
2255 bis $2, $2, $7
2256 addq $22, $7, $22
2257 stq $22, 80($16)
2258 ldq $4, 32($17)
2259 ldq $5, 56($18)
2260 cmpult $22, $7, $3
2261 zapnot $4, 15, $7
2262 srl $5, 32, $8
2263 mulq $8, $7, $0
2264 srl $28, 32, $1
2265 cmpult $2, $25, $2
2266 addq $6, $1, $6
2267 addq $2, $6, $6
2268 addq $3, $6, $6
2269 addq $24, $6, $24
2270 cmpult $24, $6, $1
2271 srl $4, 32, $6
2272 zapnot $5, 15, $5
2273 mulq $5, $6, $22
2274 mulq $7, $5, $2
2275 addq $1, $23, $23
2276 addq $0, $22, $0
2277 cmpult $0, $22, $1
2278 mulq $6, $8, $6
2279 beq $1, $389
2280 sll $21, 32, $1
2281 addq $6, $1, $6
2282$389:
2283 sll $0, 32, $22
2284 ldq $1, 48($18)
2285 addq $2, $22, $2
2286 bis $2, $2, $7
2287 ldq $4, 40($17)
2288 addq $24, $7, $24
2289 srl $1, 32, $8
2290 cmpult $24, $7, $3
2291 zapnot $4, 15, $7
2292 mulq $8, $7, $25
2293 zapnot $1, 15, $5
2294 mulq $7, $5, $21
2295 srl $0, 32, $1
2296 cmpult $2, $22, $2
2297 addq $6, $1, $6
2298 addq $2, $6, $6
2299 addq $3, $6, $6
2300 addq $23, $6, $23
2301 cmpult $23, $6, $22
2302 srl $4, 32, $6
2303 mulq $5, $6, $5
2304 bis $31, 1, $20
2305 addq $25, $5, $25
2306 cmpult $25, $5, $1
2307 mulq $6, $8, $6
2308 beq $1, $393
2309 sll $20, 32, $1
2310 addq $6, $1, $6
2311$393:
2312 sll $25, 32, $5
2313 ldq $2, 40($18)
2314 addq $21, $5, $21
2315 bis $21, $21, $7
2316 ldq $4, 48($17)
2317 addq $24, $7, $24
2318 srl $2, 32, $8
2319 cmpult $24, $7, $3
2320 zapnot $4, 15, $7
2321 mulq $8, $7, $28
2322 srl $25, 32, $1
2323 addq $6, $1, $6
2324 cmpult $21, $5, $1
2325 zapnot $2, 15, $5
2326 addq $1, $6, $6
2327 addq $3, $6, $6
2328 addq $23, $6, $23
2329 cmpult $23, $6, $1
2330 srl $4, 32, $6
2331 mulq $5, $6, $25
2332 mulq $7, $5, $5
2333 addq $1, $22, $22
2334 addq $28, $25, $28
2335 cmpult $28, $25, $1
2336 mulq $6, $8, $6
2337 beq $1, $397
2338 sll $20, 32, $1
2339 addq $6, $1, $6
2340$397:
2341 sll $28, 32, $25
2342 ldq $2, 32($18)
2343 addq $5, $25, $5
2344 bis $5, $5, $7
2345 ldq $4, 56($17)
2346 addq $24, $7, $24
2347 srl $2, 32, $8
2348 cmpult $24, $7, $3
2349 zapnot $4, 15, $7
2350 mulq $8, $7, $21
2351 srl $28, 32, $1
2352 addq $6, $1, $6
2353 cmpult $5, $25, $1
2354 zapnot $2, 15, $5
2355 addq $1, $6, $6
2356 addq $3, $6, $6
2357 addq $23, $6, $23
2358 cmpult $23, $6, $1
2359 srl $4, 32, $6
2360 mulq $5, $6, $25
2361 mulq $7, $5, $2
2362 addq $1, $22, $22
2363 addq $21, $25, $21
2364 cmpult $21, $25, $1
2365 mulq $6, $8, $6
2366 beq $1, $401
2367 sll $20, 32, $1
2368 addq $6, $1, $6
2369$401:
2370 sll $21, 32, $25
2371 addq $2, $25, $2
2372 bis $2, $2, $7
2373 addq $24, $7, $24
2374 stq $24, 88($16)
2375 ldq $4, 56($17)
2376 ldq $5, 40($18)
2377 cmpult $24, $7, $3
2378 zapnot $4, 15, $7
2379 srl $5, 32, $8
2380 mulq $8, $7, $0
2381 srl $21, 32, $1
2382 cmpult $2, $25, $2
2383 addq $6, $1, $6
2384 addq $2, $6, $6
2385 addq $3, $6, $6
2386 addq $23, $6, $23
2387 cmpult $23, $6, $1
2388 srl $4, 32, $6
2389 zapnot $5, 15, $5
2390 mulq $5, $6, $24
2391 mulq $7, $5, $5
2392 addq $1, $22, $22
2393 addq $0, $24, $0
2394 cmpult $0, $24, $1
2395 mulq $6, $8, $6
2396 beq $1, $405
2397 sll $20, 32, $1
2398 addq $6, $1, $6
2399$405:
2400 sll $0, 32, $24
2401 ldq $2, 48($18)
2402 addq $5, $24, $5
2403 bis $5, $5, $7
2404 ldq $4, 48($17)
2405 addq $23, $7, $23
2406 srl $2, 32, $8
2407 cmpult $23, $7, $3
2408 zapnot $4, 15, $7
2409 mulq $8, $7, $28
2410 srl $0, 32, $1
2411 addq $6, $1, $6
2412 cmpult $5, $24, $1
2413 zapnot $2, 15, $5
2414 addq $1, $6, $6
2415 addq $3, $6, $6
2416 addq $22, $6, $22
2417 cmpult $22, $6, $24
2418 srl $4, 32, $6
2419 mulq $5, $6, $25
2420 mulq $7, $5, $5
2421 addq $28, $25, $28
2422 cmpult $28, $25, $1
2423 mulq $6, $8, $6
2424 beq $1, $409
2425 sll $20, 32, $1
2426 addq $6, $1, $6
2427$409:
2428 sll $28, 32, $25
2429 ldq $2, 56($18)
2430 addq $5, $25, $5
2431 bis $5, $5, $7
2432 ldq $4, 40($17)
2433 addq $23, $7, $23
2434 srl $2, 32, $8
2435 cmpult $23, $7, $3
2436 zapnot $4, 15, $7
2437 mulq $8, $7, $0
2438 srl $28, 32, $1
2439 addq $6, $1, $6
2440 cmpult $5, $25, $1
2441 zapnot $2, 15, $5
2442 addq $1, $6, $6
2443 addq $3, $6, $6
2444 addq $22, $6, $22
2445 cmpult $22, $6, $1
2446 srl $4, 32, $6
2447 mulq $5, $6, $25
2448 mulq $7, $5, $2
2449 addq $1, $24, $24
2450 addq $0, $25, $0
2451 cmpult $0, $25, $1
2452 mulq $6, $8, $6
2453 beq $1, $413
2454 sll $20, 32, $1
2455 addq $6, $1, $6
2456$413:
2457 sll $0, 32, $25
2458 addq $2, $25, $2
2459 bis $2, $2, $7
2460 addq $23, $7, $23
2461 stq $23, 96($16)
2462 ldq $4, 48($17)
2463 ldq $5, 56($18)
2464 cmpult $23, $7, $3
2465 zapnot $4, 15, $7
2466 srl $5, 32, $8
2467 mulq $8, $7, $28
2468 srl $0, 32, $1
2469 cmpult $2, $25, $2
2470 addq $6, $1, $6
2471 addq $2, $6, $6
2472 addq $3, $6, $6
2473 addq $22, $6, $22
2474 cmpult $22, $6, $1
2475 srl $4, 32, $6
2476 zapnot $5, 15, $5
2477 mulq $5, $6, $23
2478 mulq $7, $5, $5
2479 addq $1, $24, $24
2480 addq $28, $23, $28
2481 cmpult $28, $23, $1
2482 mulq $6, $8, $6
2483 beq $1, $417
2484 sll $20, 32, $1
2485 addq $6, $1, $6
2486$417:
2487 sll $28, 32, $23
2488 ldq $2, 48($18)
2489 addq $5, $23, $5
2490 bis $5, $5, $7
2491 ldq $4, 56($17)
2492 addq $22, $7, $22
2493 srl $2, 32, $8
2494 cmpult $22, $7, $3
2495 zapnot $4, 15, $7
2496 mulq $8, $7, $0
2497 srl $28, 32, $1
2498 addq $6, $1, $6
2499 cmpult $5, $23, $1
2500 zapnot $2, 15, $5
2501 addq $1, $6, $6
2502 addq $3, $6, $6
2503 addq $24, $6, $24
2504 cmpult $24, $6, $23
2505 srl $4, 32, $6
2506 mulq $5, $6, $25
2507 mulq $7, $5, $2
2508 addq $0, $25, $0
2509 cmpult $0, $25, $1
2510 mulq $6, $8, $6
2511 beq $1, $421
2512 sll $20, 32, $1
2513 addq $6, $1, $6
2514$421:
2515 sll $0, 32, $25
2516 addq $2, $25, $2
2517 bis $2, $2, $7
2518 addq $22, $7, $22
2519 stq $22, 104($16)
2520 ldq $4, 56($17)
2521 ldq $5, 56($18)
2522 cmpult $22, $7, $3
2523 zapnot $4, 15, $7
2524 srl $5, 32, $8
2525 mulq $8, $7, $28
2526 srl $0, 32, $1
2527 cmpult $2, $25, $2
2528 addq $6, $1, $6
2529 addq $2, $6, $6
2530 addq $3, $6, $6
2531 addq $24, $6, $24
2532 cmpult $24, $6, $1
2533 srl $4, 32, $6
2534 zapnot $5, 15, $5
2535 mulq $5, $6, $22
2536 mulq $7, $5, $2
2537 addq $1, $23, $23
2538 addq $28, $22, $28
2539 cmpult $28, $22, $1
2540 mulq $6, $8, $3
2541 beq $1, $425
2542 sll $20, 32, $1
2543 addq $3, $1, $3
2544$425:
2545 sll $28, 32, $22
2546 srl $28, 32, $1
2547 addq $2, $22, $2
2548 addq $3, $1, $3
2549 bis $2, $2, $7
2550 addq $24, $7, $24
2551 cmpult $7, $22, $1
2552 cmpult $24, $7, $2
2553 addq $1, $3, $6
2554 addq $2, $6, $6
2555 stq $24, 112($16)
2556 addq $23, $6, $23
2557 stq $23, 120($16)
2558 ret $31, ($26), 1
1258 .end bn_mul_comba8 2559 .end bn_mul_comba8
1259 .text 2560 .text
1260 .align 3 2561 .align 3
diff --git a/src/lib/libssl/src/crypto/bn/asm/mips3.s b/src/lib/libssl/src/crypto/bn/asm/mips3.s
index 191345d920..2df4dcd4b0 100644
--- a/src/lib/libssl/src/crypto/bn/asm/mips3.s
+++ b/src/lib/libssl/src/crypto/bn/asm/mips3.s
@@ -395,32 +395,32 @@ LEAF(bn_add_words)
395 395
396.L_bn_add_words_loop: 396.L_bn_add_words_loop:
397 ld ta0,0(a2) 397 ld ta0,0(a2)
398 subu a3,4
398 ld t1,8(a1) 399 ld t1,8(a1)
399 ld ta1,8(a2) 400 and AT,a3,MINUS4
400 ld t2,16(a1) 401 ld t2,16(a1)
401 ld ta2,16(a2) 402 PTR_ADD a2,32
402 ld t3,24(a1) 403 ld t3,24(a1)
403 ld ta3,24(a2) 404 PTR_ADD a0,32
405 ld ta1,-24(a2)
406 PTR_ADD a1,32
407 ld ta2,-16(a2)
408 ld ta3,-8(a2)
404 daddu ta0,t0 409 daddu ta0,t0
405 subu a3,4
406 sltu t8,ta0,t0 410 sltu t8,ta0,t0
407 daddu t0,ta0,v0 411 daddu t0,ta0,v0
408 PTR_ADD a0,32
409 sltu v0,t0,ta0 412 sltu v0,t0,ta0
410 sd t0,-32(a0) 413 sd t0,-32(a0)
411 daddu v0,t8 414 daddu v0,t8
412 415
413 daddu ta1,t1 416 daddu ta1,t1
414 PTR_ADD a1,32
415 sltu t9,ta1,t1 417 sltu t9,ta1,t1
416 daddu t1,ta1,v0 418 daddu t1,ta1,v0
417 PTR_ADD a2,32
418 sltu v0,t1,ta1 419 sltu v0,t1,ta1
419 sd t1,-24(a0) 420 sd t1,-24(a0)
420 daddu v0,t9 421 daddu v0,t9
421 422
422 daddu ta2,t2 423 daddu ta2,t2
423 and AT,a3,MINUS4
424 sltu t8,ta2,t2 424 sltu t8,ta2,t2
425 daddu t2,ta2,v0 425 daddu t2,ta2,v0
426 sltu v0,t2,ta2 426 sltu v0,t2,ta2
@@ -495,25 +495,26 @@ LEAF(bn_sub_words)
495 495
496.L_bn_sub_words_loop: 496.L_bn_sub_words_loop:
497 ld ta0,0(a2) 497 ld ta0,0(a2)
498 subu a3,4
498 ld t1,8(a1) 499 ld t1,8(a1)
499 ld ta1,8(a2) 500 and AT,a3,MINUS4
500 ld t2,16(a1) 501 ld t2,16(a1)
501 ld ta2,16(a2) 502 PTR_ADD a2,32
502 ld t3,24(a1) 503 ld t3,24(a1)
503 ld ta3,24(a2) 504 PTR_ADD a0,32
505 ld ta1,-24(a2)
506 PTR_ADD a1,32
507 ld ta2,-16(a2)
508 ld ta3,-8(a2)
504 sltu t8,t0,ta0 509 sltu t8,t0,ta0
505 dsubu t0,ta0 510 dsubu t0,ta0
506 subu a3,4
507 dsubu ta0,t0,v0 511 dsubu ta0,t0,v0
508 and AT,a3,MINUS4 512 sd ta0,-32(a0)
509 sd ta0,0(a0)
510 MOVNZ (t0,v0,t8) 513 MOVNZ (t0,v0,t8)
511 514
512 sltu t9,t1,ta1 515 sltu t9,t1,ta1
513 dsubu t1,ta1 516 dsubu t1,ta1
514 PTR_ADD a0,32
515 dsubu ta1,t1,v0 517 dsubu ta1,t1,v0
516 PTR_ADD a1,32
517 sd ta1,-24(a0) 518 sd ta1,-24(a0)
518 MOVNZ (t1,v0,t9) 519 MOVNZ (t1,v0,t9)
519 520
@@ -521,7 +522,6 @@ LEAF(bn_sub_words)
521 sltu t8,t2,ta2 522 sltu t8,t2,ta2
522 dsubu t2,ta2 523 dsubu t2,ta2
523 dsubu ta2,t2,v0 524 dsubu ta2,t2,v0
524 PTR_ADD a2,32
525 sd ta2,-16(a0) 525 sd ta2,-16(a0)
526 MOVNZ (t2,v0,t8) 526 MOVNZ (t2,v0,t8)
527 527
@@ -574,6 +574,51 @@ END(bn_sub_words)
574 574
575#undef MINUS4 575#undef MINUS4
576 576
577.align 5
578LEAF(bn_div_3_words)
579 .set reorder
580 move a3,a0 /* we know that bn_div_words doesn't
581 * touch a3, ta2, ta3 and preserves a2
582 * so that we can save two arguments
583 * and return address in registers
584 * instead of stack:-)
585 */
586 ld a0,(a3)
587 move ta2,a1
588 ld a1,-8(a3)
589 move ta3,ra
590 move v1,zero
591 li v0,-1
592 beq a0,a2,.L_bn_div_3_words_skip_div
593 bal bn_div_words
594 move ra,ta3
595.L_bn_div_3_words_skip_div:
596 dmultu ta2,v0
597 ld t2,-16(a3)
598 move ta0,zero
599 mfhi t1
600 mflo t0
601 sltu t8,t1,v1
602.L_bn_div_3_words_inner_loop:
603 bnez t8,.L_bn_div_3_words_inner_loop_done
604 sgeu AT,t2,t0
605 seq t9,t1,v1
606 and AT,t9
607 sltu t3,t0,ta2
608 daddu v1,a2
609 dsubu t1,t3
610 dsubu t0,ta2
611 sltu t8,t1,v1
612 sltu ta0,v1,a2
613 or t8,ta0
614 .set noreorder
615 beqzl AT,.L_bn_div_3_words_inner_loop
616 dsubu v0,1
617 .set reorder
618.L_bn_div_3_words_inner_loop_done:
619 jr ra
620END(bn_div_3_words)
621
577.align 5 622.align 5
578LEAF(bn_div_words) 623LEAF(bn_div_words)
579 .set noreorder 624 .set noreorder
@@ -633,16 +678,16 @@ LEAF(bn_div_words)
633 seq t8,HH,t1 678 seq t8,HH,t1
634 sltu AT,HH,t1 679 sltu AT,HH,t1
635 and t2,t8 680 and t2,t8
681 sltu v0,t0,a2
636 or AT,t2 682 or AT,t2
637 .set noreorder 683 .set noreorder
638 beqz AT,.L_bn_div_words_inner_loop1_done 684 beqz AT,.L_bn_div_words_inner_loop1_done
639 sltu t2,t0,a2 685 dsubu t1,v0
640 .set reorder
641 dsubu QT,1
642 dsubu t0,a2 686 dsubu t0,a2
643 dsubu t1,t2
644 b .L_bn_div_words_inner_loop1 687 b .L_bn_div_words_inner_loop1
645.L_bn_div_words_inner_loop1_done: 688 dsubu QT,1
689 .set reorder
690.L_bn_div_words_inner_loop1_done:
646 691
647 dsll a1,32 692 dsll a1,32
648 dsubu a0,t3,t0 693 dsubu a0,t3,t0
@@ -655,6 +700,7 @@ LEAF(bn_div_words)
655 ddivu zero,a0,DH 700 ddivu zero,a0,DH
656 mflo QT 701 mflo QT
657.L_bn_div_words_skip_div2: 702.L_bn_div_words_skip_div2:
703#undef DH
658 dmultu a2,QT 704 dmultu a2,QT
659 dsll t3,a0,32 705 dsll t3,a0,32
660 dsrl AT,a1,32 706 dsrl AT,a1,32
@@ -666,69 +712,26 @@ LEAF(bn_div_words)
666 seq t8,HH,t1 712 seq t8,HH,t1
667 sltu AT,HH,t1 713 sltu AT,HH,t1
668 and t2,t8 714 and t2,t8
715 sltu v1,t0,a2
669 or AT,t2 716 or AT,t2
670 .set noreorder 717 .set noreorder
671 beqz AT,.L_bn_div_words_inner_loop2_done 718 beqz AT,.L_bn_div_words_inner_loop2_done
672 sltu t2,t0,a2 719 dsubu t1,v1
673 .set reorder
674 dsubu QT,1
675 dsubu t0,a2 720 dsubu t0,a2
676 dsubu t1,t2
677 b .L_bn_div_words_inner_loop2 721 b .L_bn_div_words_inner_loop2
722 dsubu QT,1
723 .set reorder
678.L_bn_div_words_inner_loop2_done: 724.L_bn_div_words_inner_loop2_done:
725#undef HH
679 726
680 dsubu a0,t3,t0 727 dsubu a0,t3,t0
681 or v0,QT 728 or v0,QT
682 dsrl v1,a0,t9 /* v1 contains remainder if anybody wants it */ 729 dsrl v1,a0,t9 /* v1 contains remainder if anybody wants it */
683 dsrl a2,t9 /* restore a2 */ 730 dsrl a2,t9 /* restore a2 */
684 jr ra 731 jr ra
685#undef HH
686#undef DH
687#undef QT 732#undef QT
688END(bn_div_words) 733END(bn_div_words)
689 734
690.align 5
691LEAF(bn_div_3_words)
692 .set reorder
693 move a3,a0 /* we know that bn_div_words doesn't
694 * touch a3, ta2, ta3 and preserves a2
695 * so that we can save two arguments
696 * and return address in registers
697 * instead of stack:-)
698 */
699 ld a0,(a3)
700 move ta2,a2
701 move a2,a1
702 ld a1,-8(a3)
703 move ta3,ra
704 move v1,zero
705 li v0,-1
706 beq a0,a2,.L_bn_div_3_words_skip_div
707 jal bn_div_words
708 move ra,ta3
709.L_bn_div_3_words_skip_div:
710 dmultu ta2,v0
711 ld t2,-16(a3)
712 mflo t0
713 mfhi t1
714.L_bn_div_3_words_inner_loop:
715 sgeu AT,t2,t0
716 seq t9,t1,v1
717 sltu t8,t1,v1
718 and AT,t9
719 or AT,t8
720 bnez AT,.L_bn_div_3_words_inner_loop_done
721 daddu v1,a2
722 sltu t3,t0,ta2
723 sltu AT,v1,a2
724 dsubu v0,1
725 dsubu t0,ta2
726 dsubu t1,t3
727 beqz AT,.L_bn_div_3_words_inner_loop
728.L_bn_div_3_words_inner_loop_done:
729 jr ra
730END(bn_div_3_words)
731
732#define a_0 t0 735#define a_0 t0
733#define a_1 t1 736#define a_1 t1
734#define a_2 t2 737#define a_2 t2
diff --git a/src/lib/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h
index f935e1ca79..d8822610df 100644
--- a/src/lib/libssl/src/crypto/bn/bn.h
+++ b/src/lib/libssl/src/crypto/bn/bn.h
@@ -83,12 +83,12 @@ extern "C" {
83 * The reason for this flag is that when the particular C compiler 83 * The reason for this flag is that when the particular C compiler
84 * library routine is used, and the library is linked with a different 84 * library routine is used, and the library is linked with a different
85 * compiler, the library is missing. This mostly happens when the 85 * compiler, the library is missing. This mostly happens when the
86 * library is built with gcc and then linked using nornal cc. This would 86 * library is built with gcc and then linked using normal cc. This would
87 * be a common occurance because gcc normally produces code that is 87 * be a common occurrence because gcc normally produces code that is
88 * 2 times faster than system compilers for the big number stuff. 88 * 2 times faster than system compilers for the big number stuff.
89 * For machines with only one compiler (or shared libraries), this should 89 * For machines with only one compiler (or shared libraries), this should
90 * be on. Again this in only really a problem on machines 90 * be on. Again this in only really a problem on machines
91 * using "long long's", are 32bit, and are not using my assember code. */ 91 * using "long long's", are 32bit, and are not using my assembler code. */
92#if defined(MSDOS) || defined(WINDOWS) || defined(linux) 92#if defined(MSDOS) || defined(WINDOWS) || defined(linux)
93#define BN_DIV2W 93#define BN_DIV2W
94#endif 94#endif
@@ -118,8 +118,8 @@ extern "C" {
118 118
119/* This is where the long long data type is 64 bits, but long is 32. 119/* This is where the long long data type is 64 bits, but long is 32.
120 * For machines where there are 64bit registers, this is the mode to use. 120 * For machines where there are 64bit registers, this is the mode to use.
121 * IRIX, on R4000 and above should use this mode, along with the relevent 121 * IRIX, on R4000 and above should use this mode, along with the relevant
122 * assember code :-). Do NOT define BN_LLONG. 122 * assembler code :-). Do NOT define BN_LLONG.
123 */ 123 */
124#ifdef SIXTY_FOUR_BIT 124#ifdef SIXTY_FOUR_BIT
125#undef BN_LLONG 125#undef BN_LLONG
@@ -240,11 +240,15 @@ typedef struct bignum_st
240 240
241/* Used for temp variables */ 241/* Used for temp variables */
242#define BN_CTX_NUM 12 242#define BN_CTX_NUM 12
243#define BN_CTX_NUM_POS 12
243typedef struct bignum_ctx 244typedef struct bignum_ctx
244 { 245 {
245 int tos; 246 int tos;
246 BIGNUM bn[BN_CTX_NUM+1]; 247 BIGNUM bn[BN_CTX_NUM];
247 int flags; 248 int flags;
249 int depth;
250 int pos[BN_CTX_NUM_POS];
251 int too_many;
248 } BN_CTX; 252 } BN_CTX;
249 253
250typedef struct bn_blinding_st 254typedef struct bn_blinding_st
@@ -257,16 +261,15 @@ typedef struct bn_blinding_st
257 261
258/* Used for montgomery multiplication */ 262/* Used for montgomery multiplication */
259typedef struct bn_mont_ctx_st 263typedef struct bn_mont_ctx_st
260 { 264 {
261 int use_word; /* 0 for word form, 1 for long form */ 265 int ri; /* number of bits in R */
262 int ri; /* number of bits in R */ 266 BIGNUM RR; /* used to convert to montgomery form */
263 BIGNUM RR; /* used to convert to montgomery form */ 267 BIGNUM N; /* The modulus */
264 BIGNUM N; /* The modulus */ 268 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
265 BIGNUM Ni; /* The inverse of N */ 269 * (Ni is only stored for bignum algorithm) */
266 BN_ULONG n0; /* word form of inverse, normally only one of 270 BN_ULONG n0; /* least significant word of Ni */
267 * Ni or n0 is defined */
268 int flags; 271 int flags;
269 } BN_MONT_CTX; 272 } BN_MONT_CTX;
270 273
271/* Used for reciprocal division/mod functions 274/* Used for reciprocal division/mod functions
272 * It cannot be shared between threads 275 * It cannot be shared between threads
@@ -283,7 +286,26 @@ typedef struct bn_recp_ctx_st
283#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ 286#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
284 r,a,&((mont)->RR),(mont),ctx) 287 r,a,&((mont)->RR),(mont),ctx)
285 288
286#define BN_prime_checks (5) 289#define BN_prime_checks 0 /* default: select number of iterations
290 based on the size of the number */
291
292/* number of Miller-Rabin iterations for an error rate of less than 2^-80
293 * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
294 * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
295 * original paper: Damgaard, Landrock, Pomerance: Average case error estimates
296 * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
297#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
298 (b) >= 850 ? 3 : \
299 (b) >= 650 ? 4 : \
300 (b) >= 550 ? 5 : \
301 (b) >= 450 ? 6 : \
302 (b) >= 400 ? 7 : \
303 (b) >= 350 ? 8 : \
304 (b) >= 300 ? 9 : \
305 (b) >= 250 ? 12 : \
306 (b) >= 200 ? 15 : \
307 (b) >= 150 ? 18 : \
308 /* b >= 100 */ 27)
287 309
288#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) 310#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
289#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) 311#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
@@ -296,26 +318,16 @@ typedef struct bn_recp_ctx_st
296/*#define BN_ascii2bn(a) BN_hex2bn(a) */ 318/*#define BN_ascii2bn(a) BN_hex2bn(a) */
297/*#define BN_bn2ascii(a) BN_bn2hex(a) */ 319/*#define BN_bn2ascii(a) BN_bn2hex(a) */
298 320
299#define bn_expand(n,b) ((((((b+BN_BITS2-1))/BN_BITS2)) <= (n)->max)?\
300 (n):bn_expand2((n),(b)/BN_BITS2+1))
301#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b)))
302
303#define bn_fix_top(a) \
304 { \
305 BN_ULONG *ftl; \
306 if ((a)->top > 0) \
307 { \
308 for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
309 if (*(ftl--)) break; \
310 } \
311 }
312
313BIGNUM *BN_value_one(void); 321BIGNUM *BN_value_one(void);
314char * BN_options(void); 322char * BN_options(void);
315BN_CTX *BN_CTX_new(void); 323BN_CTX *BN_CTX_new(void);
316void BN_CTX_init(BN_CTX *c); 324void BN_CTX_init(BN_CTX *c);
317void BN_CTX_free(BN_CTX *c); 325void BN_CTX_free(BN_CTX *c);
326void BN_CTX_start(BN_CTX *ctx);
327BIGNUM *BN_CTX_get(BN_CTX *ctx);
328void BN_CTX_end(BN_CTX *ctx);
318int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); 329int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
330int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
319int BN_num_bits(const BIGNUM *a); 331int BN_num_bits(const BIGNUM *a);
320int BN_num_bits_word(BN_ULONG); 332int BN_num_bits_word(BN_ULONG);
321BIGNUM *BN_new(void); 333BIGNUM *BN_new(void);
@@ -329,13 +341,13 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
329int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 341int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
330int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 342int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
331int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 343int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
332int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); 344int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
333int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); 345int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
334int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, 346int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
335 BN_CTX *ctx); 347 BN_CTX *ctx);
336int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b,BN_CTX *ctx); 348int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
337int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); 349int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
338BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w); 350BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
339BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); 351BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
340int BN_mul_word(BIGNUM *a, BN_ULONG w); 352int BN_mul_word(BIGNUM *a, BN_ULONG w);
341int BN_add_word(BIGNUM *a, BN_ULONG w); 353int BN_add_word(BIGNUM *a, BN_ULONG w);
@@ -358,19 +370,18 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
358 BIGNUM *m,BN_CTX *ctx); 370 BIGNUM *m,BN_CTX *ctx);
359int BN_mask_bits(BIGNUM *a,int n); 371int BN_mask_bits(BIGNUM *a,int n);
360int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); 372int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
361#ifndef WIN16 373#ifndef NO_FP_API
362int BN_print_fp(FILE *fp, BIGNUM *a); 374int BN_print_fp(FILE *fp, const BIGNUM *a);
363#endif 375#endif
364#ifdef HEADER_BIO_H 376#ifdef HEADER_BIO_H
365int BN_print(BIO *fp, const BIGNUM *a); 377int BN_print(BIO *fp, const BIGNUM *a);
366#else 378#else
367int BN_print(char *fp, const BIGNUM *a); 379int BN_print(void *fp, const BIGNUM *a);
368#endif 380#endif
369int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx); 381int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx);
370int BN_rshift(BIGNUM *r, BIGNUM *a, int n); 382int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
371int BN_rshift1(BIGNUM *r, BIGNUM *a); 383int BN_rshift1(BIGNUM *r, BIGNUM *a);
372void BN_clear(BIGNUM *a); 384void BN_clear(BIGNUM *a);
373BIGNUM *bn_expand2(BIGNUM *b, int bits);
374BIGNUM *BN_dup(const BIGNUM *a); 385BIGNUM *BN_dup(const BIGNUM *a);
375int BN_ucmp(const BIGNUM *a, const BIGNUM *b); 386int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
376int BN_set_bit(BIGNUM *a, int n); 387int BN_set_bit(BIGNUM *a, int n);
@@ -381,19 +392,16 @@ int BN_hex2bn(BIGNUM **a, const char *str);
381int BN_dec2bn(BIGNUM **a, const char *str); 392int BN_dec2bn(BIGNUM **a, const char *str);
382int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); 393int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
383BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); 394BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
384BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int strong,BIGNUM *add, 395BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,BIGNUM *add,
385 BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg); 396 BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg);
386int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,void *), 397int BN_is_prime(const BIGNUM *p,int nchecks,
398 void (*callback)(int,int,void *),
387 BN_CTX *ctx,void *cb_arg); 399 BN_CTX *ctx,void *cb_arg);
400int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
401 void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
402 int do_trial_division);
388void ERR_load_BN_strings(void ); 403void ERR_load_BN_strings(void );
389 404
390BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
391BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
392void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
393BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
394BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
395BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
396
397BN_MONT_CTX *BN_MONT_CTX_new(void ); 405BN_MONT_CTX *BN_MONT_CTX_new(void );
398void BN_MONT_CTX_init(BN_MONT_CTX *ctx); 406void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
399int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont, 407int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
@@ -423,6 +431,39 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
423int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, 431int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
424 BN_RECP_CTX *recp, BN_CTX *ctx); 432 BN_RECP_CTX *recp, BN_CTX *ctx);
425 433
434/* library internal functions */
435
436#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->max)?\
437 (a):bn_expand2((a),(bits)/BN_BITS2+1))
438#define bn_wexpand(a,words) (((words) <= (a)->max)?(a):bn_expand2((a),(words)))
439BIGNUM *bn_expand2(BIGNUM *a, int words);
440
441#define bn_fix_top(a) \
442 { \
443 BN_ULONG *ftl; \
444 if ((a)->top > 0) \
445 { \
446 for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
447 if (*(ftl--)) break; \
448 } \
449 }
450
451BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
452BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
453void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
454BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
455BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
456BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
457
458#ifdef BN_DEBUG
459 void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n);
460# define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
461 fprintf(stderr,"\n");}
462# define bn_dump(a,n) bn_dump1(stderr,#a,a,n);
463#else
464# define bn_print(a)
465# define bn_dump(a,b)
466#endif
426 467
427/* BEGIN ERROR CODES */ 468/* BEGIN ERROR CODES */
428/* The following lines are auto generated by the script mkerr.pl. Any changes 469/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -438,6 +479,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
438#define BN_F_BN_BLINDING_UPDATE 103 479#define BN_F_BN_BLINDING_UPDATE 103
439#define BN_F_BN_BN2DEC 104 480#define BN_F_BN_BN2DEC 104
440#define BN_F_BN_BN2HEX 105 481#define BN_F_BN_BN2HEX 105
482#define BN_F_BN_CTX_GET 116
441#define BN_F_BN_CTX_NEW 106 483#define BN_F_BN_CTX_NEW 106
442#define BN_F_BN_DIV 107 484#define BN_F_BN_DIV 107
443#define BN_F_BN_EXPAND2 108 485#define BN_F_BN_EXPAND2 108
@@ -459,6 +501,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
459#define BN_R_INVALID_LENGTH 106 501#define BN_R_INVALID_LENGTH 106
460#define BN_R_NOT_INITIALIZED 107 502#define BN_R_NOT_INITIALIZED 107
461#define BN_R_NO_INVERSE 108 503#define BN_R_NO_INVERSE 108
504#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
462 505
463#ifdef __cplusplus 506#ifdef __cplusplus
464} 507}
diff --git a/src/lib/libssl/src/crypto/bn/bn_add.c b/src/lib/libssl/src/crypto/bn/bn_add.c
index c5ab066c9e..5d24691233 100644
--- a/src/lib/libssl/src/crypto/bn/bn_add.c
+++ b/src/lib/libssl/src/crypto/bn/bn_add.c
@@ -61,9 +61,9 @@
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62 62
63/* r can == a or b */ 63/* r can == a or b */
64int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b) 64int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
65 { 65 {
66 BIGNUM *tmp; 66 const BIGNUM *tmp;
67 67
68 bn_check_top(a); 68 bn_check_top(a);
69 bn_check_top(b); 69 bn_check_top(b);
diff --git a/src/lib/libssl/src/crypto/bn/bn_asm.c b/src/lib/libssl/src/crypto/bn/bn_asm.c
index 4d3da16a0c..3329cc18e6 100644
--- a/src/lib/libssl/src/crypto/bn/bn_asm.c
+++ b/src/lib/libssl/src/crypto/bn/bn_asm.c
@@ -56,31 +56,38 @@
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
63#ifdef BN_LLONG 69#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
64 70
65BN_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, BN_ULONG *ap, int num, BN_ULONG w)
66 { 72 {
67 BN_ULONG c1=0; 73 BN_ULONG c1=0;
68 74
69 bn_check_num(num); 75 assert(num >= 0);
70 if (num <= 0) return(c1); 76 if (num <= 0) return(c1);
71 77
72 for (;;) 78 while (num&~3)
73 { 79 {
74 mul_add(rp[0],ap[0],w,c1); 80 mul_add(rp[0],ap[0],w,c1);
75 if (--num == 0) break;
76 mul_add(rp[1],ap[1],w,c1); 81 mul_add(rp[1],ap[1],w,c1);
77 if (--num == 0) break;
78 mul_add(rp[2],ap[2],w,c1); 82 mul_add(rp[2],ap[2],w,c1);
79 if (--num == 0) break;
80 mul_add(rp[3],ap[3],w,c1); 83 mul_add(rp[3],ap[3],w,c1);
81 if (--num == 0) break; 84 ap+=4; rp+=4; num-=4;
82 ap+=4; 85 }
83 rp+=4; 86 if (num)
87 {
88 mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
89 mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
90 mul_add(rp[2],ap[2],w,c1); return c1;
84 } 91 }
85 92
86 return(c1); 93 return(c1);
@@ -90,63 +97,54 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
90 { 97 {
91 BN_ULONG c1=0; 98 BN_ULONG c1=0;
92 99
93 bn_check_num(num); 100 assert(num >= 0);
94 if (num <= 0) return(c1); 101 if (num <= 0) return(c1);
95 102
96 /* for (;;) */ 103 while (num&~3)
97 while (1) /* circumvent egcs-1.1.2 bug */
98 { 104 {
99 mul(rp[0],ap[0],w,c1); 105 mul(rp[0],ap[0],w,c1);
100 if (--num == 0) break;
101 mul(rp[1],ap[1],w,c1); 106 mul(rp[1],ap[1],w,c1);
102 if (--num == 0) break;
103 mul(rp[2],ap[2],w,c1); 107 mul(rp[2],ap[2],w,c1);
104 if (--num == 0) break;
105 mul(rp[3],ap[3],w,c1); 108 mul(rp[3],ap[3],w,c1);
106 if (--num == 0) break; 109 ap+=4; rp+=4; num-=4;
107 ap+=4; 110 }
108 rp+=4; 111 if (num)
112 {
113 mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
114 mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
115 mul(rp[2],ap[2],w,c1);
109 } 116 }
110 return(c1); 117 return(c1);
111 } 118 }
112 119
113void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) 120void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
114 { 121 {
115 bn_check_num(n); 122 assert(n >= 0);
116 if (n <= 0) return; 123 if (n <= 0) return;
117 for (;;) 124 while (n&~3)
118 { 125 {
119 BN_ULLONG t; 126 sqr(r[0],r[1],a[0]);
120 127 sqr(r[2],r[3],a[1]);
121 t=(BN_ULLONG)(a[0])*(a[0]); 128 sqr(r[4],r[5],a[2]);
122 r[0]=Lw(t); r[1]=Hw(t); 129 sqr(r[6],r[7],a[3]);
123 if (--n == 0) break; 130 a+=4; r+=8; n-=4;
124 131 }
125 t=(BN_ULLONG)(a[1])*(a[1]); 132 if (n)
126 r[2]=Lw(t); r[3]=Hw(t); 133 {
127 if (--n == 0) break; 134 sqr(r[0],r[1],a[0]); if (--n == 0) return;
128 135 sqr(r[2],r[3],a[1]); if (--n == 0) return;
129 t=(BN_ULLONG)(a[2])*(a[2]); 136 sqr(r[4],r[5],a[2]);
130 r[4]=Lw(t); r[5]=Hw(t);
131 if (--n == 0) break;
132
133 t=(BN_ULLONG)(a[3])*(a[3]);
134 r[6]=Lw(t); r[7]=Hw(t);
135 if (--n == 0) break;
136
137 a+=4;
138 r+=8;
139 } 137 }
140 } 138 }
141 139
142#else 140#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
143 141
144BN_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, BN_ULONG *ap, int num, BN_ULONG w)
145 { 143 {
146 BN_ULONG c=0; 144 BN_ULONG c=0;
147 BN_ULONG bl,bh; 145 BN_ULONG bl,bh;
148 146
149 bn_check_num(num); 147 assert(num >= 0);
150 if (num <= 0) return((BN_ULONG)0); 148 if (num <= 0) return((BN_ULONG)0);
151 149
152 bl=LBITS(w); 150 bl=LBITS(w);
@@ -173,7 +171,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
173 BN_ULONG carry=0; 171 BN_ULONG carry=0;
174 BN_ULONG bl,bh; 172 BN_ULONG bl,bh;
175 173
176 bn_check_num(num); 174 assert(num >= 0);
177 if (num <= 0) return((BN_ULONG)0); 175 if (num <= 0) return((BN_ULONG)0);
178 176
179 bl=LBITS(w); 177 bl=LBITS(w);
@@ -197,7 +195,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
197 195
198void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) 196void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
199 { 197 {
200 bn_check_num(n); 198 assert(n >= 0);
201 if (n <= 0) return; 199 if (n <= 0) return;
202 for (;;) 200 for (;;)
203 { 201 {
@@ -218,7 +216,7 @@ void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
218 } 216 }
219 } 217 }
220 218
221#endif 219#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
222 220
223#if defined(BN_LLONG) && defined(BN_DIV2W) 221#if defined(BN_LLONG) && defined(BN_DIV2W)
224 222
@@ -300,14 +298,14 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
300 ret|=q; 298 ret|=q;
301 return(ret); 299 return(ret);
302 } 300 }
303#endif 301#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */
304 302
305#ifdef BN_LLONG 303#ifdef BN_LLONG
306BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 304BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
307 { 305 {
308 BN_ULLONG ll=0; 306 BN_ULLONG ll=0;
309 307
310 bn_check_num(n); 308 assert(n >= 0);
311 if (n <= 0) return((BN_ULONG)0); 309 if (n <= 0) return((BN_ULONG)0);
312 310
313 for (;;) 311 for (;;)
@@ -338,12 +336,12 @@ BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
338 } 336 }
339 return((BN_ULONG)ll); 337 return((BN_ULONG)ll);
340 } 338 }
341#else 339#else /* !BN_LLONG */
342BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 340BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
343 { 341 {
344 BN_ULONG c,l,t; 342 BN_ULONG c,l,t;
345 343
346 bn_check_num(n); 344 assert(n >= 0);
347 if (n <= 0) return((BN_ULONG)0); 345 if (n <= 0) return((BN_ULONG)0);
348 346
349 c=0; 347 c=0;
@@ -387,14 +385,14 @@ BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
387 } 385 }
388 return((BN_ULONG)c); 386 return((BN_ULONG)c);
389 } 387 }
390#endif 388#endif /* !BN_LLONG */
391 389
392BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 390BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
393 { 391 {
394 BN_ULONG t1,t2; 392 BN_ULONG t1,t2;
395 int c=0; 393 int c=0;
396 394
397 bn_check_num(n); 395 assert(n >= 0);
398 if (n <= 0) return((BN_ULONG)0); 396 if (n <= 0) return((BN_ULONG)0);
399 397
400 for (;;) 398 for (;;)
@@ -433,6 +431,11 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
433#undef bn_sqr_comba8 431#undef bn_sqr_comba8
434#undef bn_sqr_comba4 432#undef bn_sqr_comba4
435 433
434/* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */
435/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */
436/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
437/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
438
436#ifdef BN_LLONG 439#ifdef BN_LLONG
437#define mul_add_c(a,b,c0,c1,c2) \ 440#define mul_add_c(a,b,c0,c1,c2) \
438 t=(BN_ULLONG)a*b; \ 441 t=(BN_ULLONG)a*b; \
@@ -460,7 +463,39 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
460 463
461#define sqr_add_c2(a,i,j,c0,c1,c2) \ 464#define sqr_add_c2(a,i,j,c0,c1,c2) \
462 mul_add_c2((a)[i],(a)[j],c0,c1,c2) 465 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
463#else 466
467#elif defined(BN_UMULT_HIGH)
468
469#define mul_add_c(a,b,c0,c1,c2) { \
470 BN_ULONG ta=(a),tb=(b); \
471 t1 = ta * tb; \
472 t2 = BN_UMULT_HIGH(ta,tb); \
473 c0 += t1; t2 += (c0<t1)?1:0; \
474 c1 += t2; c2 += (c1<t2)?1:0; \
475 }
476
477#define mul_add_c2(a,b,c0,c1,c2) { \
478 BN_ULONG ta=(a),tb=(b),t0; \
479 t1 = BN_UMULT_HIGH(ta,tb); \
480 t0 = ta * tb; \
481 t2 = t1+t1; c2 += (t2<t1)?1:0; \
482 t1 = t0+t0; t2 += (t1<t0)?1:0; \
483 c0 += t1; t2 += (c0<t1)?1:0; \
484 c1 += t2; c2 += (c1<t2)?1:0; \
485 }
486
487#define sqr_add_c(a,i,c0,c1,c2) { \
488 BN_ULONG ta=(a)[i]; \
489 t1 = ta * ta; \
490 t2 = BN_UMULT_HIGH(ta,ta); \
491 c0 += t1; t2 += (c0<t1)?1:0; \
492 c1 += t2; c2 += (c1<t2)?1:0; \
493 }
494
495#define sqr_add_c2(a,i,j,c0,c1,c2) \
496 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
497
498#else /* !BN_LLONG */
464#define mul_add_c(a,b,c0,c1,c2) \ 499#define mul_add_c(a,b,c0,c1,c2) \
465 t1=LBITS(a); t2=HBITS(a); \ 500 t1=LBITS(a); t2=HBITS(a); \
466 bl=LBITS(b); bh=HBITS(b); \ 501 bl=LBITS(b); bh=HBITS(b); \
@@ -487,7 +522,7 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
487 522
488#define sqr_add_c2(a,i,j,c0,c1,c2) \ 523#define sqr_add_c2(a,i,j,c0,c1,c2) \
489 mul_add_c2((a)[i],(a)[j],c0,c1,c2) 524 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
490#endif 525#endif /* !BN_LLONG */
491 526
492void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) 527void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
493 { 528 {
@@ -762,7 +797,7 @@ void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
762 r[6]=c1; 797 r[6]=c1;
763 r[7]=c2; 798 r[7]=c2;
764 } 799 }
765#else 800#else /* !BN_MUL_COMBA */
766 801
767/* hmm... is it faster just to do a multiply? */ 802/* hmm... is it faster just to do a multiply? */
768#undef bn_sqr_comba4 803#undef bn_sqr_comba4
@@ -799,4 +834,4 @@ void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
799 r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]); 834 r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]);
800 } 835 }
801 836
802#endif /* BN_COMBA */ 837#endif /* !BN_MUL_COMBA */
diff --git a/src/lib/libssl/src/crypto/bn/bn_comba.c b/src/lib/libssl/src/crypto/bn/bn_comba.c
index 7ad09b4a6d..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/bn_comba.c
+++ b/src/lib/libssl/src/crypto/bn/bn_comba.c
@@ -1,345 +0,0 @@
1/* crypto/bn/bn_comba.c */
2#include <stdio.h>
3#include "bn_lcl.h"
4/* Auto generated from crypto/bn/comba.pl
5 */
6
7#undef bn_mul_comba8
8#undef bn_mul_comba4
9#undef bn_sqr_comba8
10#undef bn_sqr_comba4
11
12#ifdef BN_LLONG
13#define mul_add_c(a,b,c0,c1,c2) \
14 t=(BN_ULLONG)a*b; \
15 t1=(BN_ULONG)Lw(t); \
16 t2=(BN_ULONG)Hw(t); \
17 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
18 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
19
20#define mul_add_c2(a,b,c0,c1,c2) \
21 t=(BN_ULLONG)a*b; \
22 tt=(t+t)&BN_MASK; \
23 if (tt < t) c2++; \
24 t1=(BN_ULONG)Lw(tt); \
25 t2=(BN_ULONG)Hw(tt); \
26 c0=(c0+t1)&BN_MASK2; \
27 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
28 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
29
30#define sqr_add_c(a,i,c0,c1,c2) \
31 t=(BN_ULLONG)a[i]*a[i]; \
32 t1=(BN_ULONG)Lw(t); \
33 t2=(BN_ULONG)Hw(t); \
34 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
35 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
36
37#define sqr_add_c2(a,i,j,c0,c1,c2) \
38 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
39#else
40#define mul_add_c(a,b,c0,c1,c2) \
41 t1=LBITS(a); t2=HBITS(a); \
42 bl=LBITS(b); bh=HBITS(b); \
43 mul64(t1,t2,bl,bh); \
44 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
45 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
46
47#define mul_add_c2(a,b,c0,c1,c2) \
48 t1=LBITS(a); t2=HBITS(a); \
49 bl=LBITS(b); bh=HBITS(b); \
50 mul64(t1,t2,bl,bh); \
51 if (t2 & BN_TBIT) c2++; \
52 t2=(t2+t2)&BN_MASK2; \
53 if (t1 & BN_TBIT) t2++; \
54 t1=(t1+t1)&BN_MASK2; \
55 c0=(c0+t1)&BN_MASK2; \
56 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
57 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
58
59#define sqr_add_c(a,i,c0,c1,c2) \
60 sqr64(t1,t2,(a)[i]); \
61 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
62 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
63
64#define sqr_add_c2(a,i,j,c0,c1,c2) \
65 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
66#endif
67
68void bn_mul_comba88(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
69void bn_mul_comba44(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
70void bn_sqr_comba88(BN_ULONG *r,BN_ULONG *a);
71void bn_sqr_comba44(BN_ULONG *r,BN_ULONG *a);
72
73void bn_mul_comba88(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
74 {
75#ifdef BN_LLONG
76 BN_ULLONG t;
77#else
78 BN_ULONG bl,bh;
79#endif
80 BN_ULONG t1,t2;
81 BN_ULONG c1,c2,c3;
82
83 c1=0;
84 c2=0;
85 c3=0;
86 mul_add_c(a[0],b[0],c1,c2,c3);
87 r[0]=c1;
88 c1=0;
89 mul_add_c(a[0],b[1],c2,c3,c1);
90 mul_add_c(a[1],b[0],c2,c3,c1);
91 r[1]=c2;
92 c2=0;
93 mul_add_c(a[2],b[0],c3,c1,c2);
94 mul_add_c(a[1],b[1],c3,c1,c2);
95 mul_add_c(a[0],b[2],c3,c1,c2);
96 r[2]=c3;
97 c3=0;
98 mul_add_c(a[0],b[3],c1,c2,c3);
99 mul_add_c(a[1],b[2],c1,c2,c3);
100 mul_add_c(a[2],b[1],c1,c2,c3);
101 mul_add_c(a[3],b[0],c1,c2,c3);
102 r[3]=c1;
103 c1=0;
104 mul_add_c(a[4],b[0],c2,c3,c1);
105 mul_add_c(a[3],b[1],c2,c3,c1);
106 mul_add_c(a[2],b[2],c2,c3,c1);
107 mul_add_c(a[1],b[3],c2,c3,c1);
108 mul_add_c(a[0],b[4],c2,c3,c1);
109 r[4]=c2;
110 c2=0;
111 mul_add_c(a[0],b[5],c3,c1,c2);
112 mul_add_c(a[1],b[4],c3,c1,c2);
113 mul_add_c(a[2],b[3],c3,c1,c2);
114 mul_add_c(a[3],b[2],c3,c1,c2);
115 mul_add_c(a[4],b[1],c3,c1,c2);
116 mul_add_c(a[5],b[0],c3,c1,c2);
117 r[5]=c3;
118 c3=0;
119 mul_add_c(a[6],b[0],c1,c2,c3);
120 mul_add_c(a[5],b[1],c1,c2,c3);
121 mul_add_c(a[4],b[2],c1,c2,c3);
122 mul_add_c(a[3],b[3],c1,c2,c3);
123 mul_add_c(a[2],b[4],c1,c2,c3);
124 mul_add_c(a[1],b[5],c1,c2,c3);
125 mul_add_c(a[0],b[6],c1,c2,c3);
126 r[6]=c1;
127 c1=0;
128 mul_add_c(a[0],b[7],c2,c3,c1);
129 mul_add_c(a[1],b[6],c2,c3,c1);
130 mul_add_c(a[2],b[5],c2,c3,c1);
131 mul_add_c(a[3],b[4],c2,c3,c1);
132 mul_add_c(a[4],b[3],c2,c3,c1);
133 mul_add_c(a[5],b[2],c2,c3,c1);
134 mul_add_c(a[6],b[1],c2,c3,c1);
135 mul_add_c(a[7],b[0],c2,c3,c1);
136 r[7]=c2;
137 c2=0;
138 mul_add_c(a[7],b[1],c3,c1,c2);
139 mul_add_c(a[6],b[2],c3,c1,c2);
140 mul_add_c(a[5],b[3],c3,c1,c2);
141 mul_add_c(a[4],b[4],c3,c1,c2);
142 mul_add_c(a[3],b[5],c3,c1,c2);
143 mul_add_c(a[2],b[6],c3,c1,c2);
144 mul_add_c(a[1],b[7],c3,c1,c2);
145 r[8]=c3;
146 c3=0;
147 mul_add_c(a[2],b[7],c1,c2,c3);
148 mul_add_c(a[3],b[6],c1,c2,c3);
149 mul_add_c(a[4],b[5],c1,c2,c3);
150 mul_add_c(a[5],b[4],c1,c2,c3);
151 mul_add_c(a[6],b[3],c1,c2,c3);
152 mul_add_c(a[7],b[2],c1,c2,c3);
153 r[9]=c1;
154 c1=0;
155 mul_add_c(a[7],b[3],c2,c3,c1);
156 mul_add_c(a[6],b[4],c2,c3,c1);
157 mul_add_c(a[5],b[5],c2,c3,c1);
158 mul_add_c(a[4],b[6],c2,c3,c1);
159 mul_add_c(a[3],b[7],c2,c3,c1);
160 r[10]=c2;
161 c2=0;
162 mul_add_c(a[4],b[7],c3,c1,c2);
163 mul_add_c(a[5],b[6],c3,c1,c2);
164 mul_add_c(a[6],b[5],c3,c1,c2);
165 mul_add_c(a[7],b[4],c3,c1,c2);
166 r[11]=c3;
167 c3=0;
168 mul_add_c(a[7],b[5],c1,c2,c3);
169 mul_add_c(a[6],b[6],c1,c2,c3);
170 mul_add_c(a[5],b[7],c1,c2,c3);
171 r[12]=c1;
172 c1=0;
173 mul_add_c(a[6],b[7],c2,c3,c1);
174 mul_add_c(a[7],b[6],c2,c3,c1);
175 r[13]=c2;
176 c2=0;
177 mul_add_c(a[7],b[7],c3,c1,c2);
178 r[14]=c3;
179 r[15]=c1;
180 }
181
182void bn_mul_comba44(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
183 {
184#ifdef BN_LLONG
185 BN_ULLONG t;
186#else
187 BN_ULONG bl,bh;
188#endif
189 BN_ULONG t1,t2;
190 BN_ULONG c1,c2,c3;
191
192 c1=0;
193 c2=0;
194 c3=0;
195 mul_add_c(a[0],b[0],c1,c2,c3);
196 r[0]=c1;
197 c1=0;
198 mul_add_c(a[0],b[1],c2,c3,c1);
199 mul_add_c(a[1],b[0],c2,c3,c1);
200 r[1]=c2;
201 c2=0;
202 mul_add_c(a[2],b[0],c3,c1,c2);
203 mul_add_c(a[1],b[1],c3,c1,c2);
204 mul_add_c(a[0],b[2],c3,c1,c2);
205 r[2]=c3;
206 c3=0;
207 mul_add_c(a[0],b[3],c1,c2,c3);
208 mul_add_c(a[1],b[2],c1,c2,c3);
209 mul_add_c(a[2],b[1],c1,c2,c3);
210 mul_add_c(a[3],b[0],c1,c2,c3);
211 r[3]=c1;
212 c1=0;
213 mul_add_c(a[3],b[1],c2,c3,c1);
214 mul_add_c(a[2],b[2],c2,c3,c1);
215 mul_add_c(a[1],b[3],c2,c3,c1);
216 r[4]=c2;
217 c2=0;
218 mul_add_c(a[2],b[3],c3,c1,c2);
219 mul_add_c(a[3],b[2],c3,c1,c2);
220 r[5]=c3;
221 c3=0;
222 mul_add_c(a[3],b[3],c1,c2,c3);
223 r[6]=c1;
224 r[7]=c2;
225 }
226
227void bn_sqr_comba88(BN_ULONG *r, BN_ULONG *a)
228 {
229#ifdef BN_LLONG
230 BN_ULLONG t,tt;
231#else
232 BN_ULONG bl,bh;
233#endif
234 BN_ULONG t1,t2;
235 BN_ULONG c1,c2,c3;
236
237 c1=0;
238 c2=0;
239 c3=0;
240 sqr_add_c(a,0,c1,c2,c3);
241 r[0]=c1;
242 c1=0;
243 sqr_add_c2(a,1,0,c2,c3,c1);
244 r[1]=c2;
245 c2=0;
246 sqr_add_c(a,1,c3,c1,c2);
247 sqr_add_c2(a,2,0,c3,c1,c2);
248 r[2]=c3;
249 c3=0;
250 sqr_add_c2(a,3,0,c1,c2,c3);
251 sqr_add_c2(a,2,1,c1,c2,c3);
252 r[3]=c1;
253 c1=0;
254 sqr_add_c(a,2,c2,c3,c1);
255 sqr_add_c2(a,3,1,c2,c3,c1);
256 sqr_add_c2(a,4,0,c2,c3,c1);
257 r[4]=c2;
258 c2=0;
259 sqr_add_c2(a,5,0,c3,c1,c2);
260 sqr_add_c2(a,4,1,c3,c1,c2);
261 sqr_add_c2(a,3,2,c3,c1,c2);
262 r[5]=c3;
263 c3=0;
264 sqr_add_c(a,3,c1,c2,c3);
265 sqr_add_c2(a,4,2,c1,c2,c3);
266 sqr_add_c2(a,5,1,c1,c2,c3);
267 sqr_add_c2(a,6,0,c1,c2,c3);
268 r[6]=c1;
269 c1=0;
270 sqr_add_c2(a,7,0,c2,c3,c1);
271 sqr_add_c2(a,6,1,c2,c3,c1);
272 sqr_add_c2(a,5,2,c2,c3,c1);
273 sqr_add_c2(a,4,3,c2,c3,c1);
274 r[7]=c2;
275 c2=0;
276 sqr_add_c(a,4,c3,c1,c2);
277 sqr_add_c2(a,5,3,c3,c1,c2);
278 sqr_add_c2(a,6,2,c3,c1,c2);
279 sqr_add_c2(a,7,1,c3,c1,c2);
280 r[8]=c3;
281 c3=0;
282 sqr_add_c2(a,7,2,c1,c2,c3);
283 sqr_add_c2(a,6,3,c1,c2,c3);
284 sqr_add_c2(a,5,4,c1,c2,c3);
285 r[9]=c1;
286 c1=0;
287 sqr_add_c(a,5,c2,c3,c1);
288 sqr_add_c2(a,6,4,c2,c3,c1);
289 sqr_add_c2(a,7,3,c2,c3,c1);
290 r[10]=c2;
291 c2=0;
292 sqr_add_c2(a,7,4,c3,c1,c2);
293 sqr_add_c2(a,6,5,c3,c1,c2);
294 r[11]=c3;
295 c3=0;
296 sqr_add_c(a,6,c1,c2,c3);
297 sqr_add_c2(a,7,5,c1,c2,c3);
298 r[12]=c1;
299 c1=0;
300 sqr_add_c2(a,7,6,c2,c3,c1);
301 r[13]=c2;
302 c2=0;
303 sqr_add_c(a,7,c3,c1,c2);
304 r[14]=c3;
305 r[15]=c1;
306 }
307
308void bn_sqr_comba44(BN_ULONG *r, BN_ULONG *a)
309 {
310#ifdef BN_LLONG
311 BN_ULLONG t,tt;
312#else
313 BN_ULONG bl,bh;
314#endif
315 BN_ULONG t1,t2;
316 BN_ULONG c1,c2,c3;
317
318 c1=0;
319 c2=0;
320 c3=0;
321 sqr_add_c(a,0,c1,c2,c3);
322 r[0]=c1;
323 c1=0;
324 sqr_add_c2(a,1,0,c2,c3,c1);
325 r[1]=c2;
326 c2=0;
327 sqr_add_c(a,1,c3,c1,c2);
328 sqr_add_c2(a,2,0,c3,c1,c2);
329 r[2]=c3;
330 c3=0;
331 sqr_add_c2(a,3,0,c1,c2,c3);
332 sqr_add_c2(a,2,1,c1,c2,c3);
333 r[3]=c1;
334 c1=0;
335 sqr_add_c(a,2,c2,c3,c1);
336 sqr_add_c2(a,3,1,c2,c3,c1);
337 r[4]=c2;
338 c2=0;
339 sqr_add_c2(a,3,2,c3,c1,c2);
340 r[5]=c3;
341 c3=0;
342 sqr_add_c(a,3,c1,c2,c3);
343 r[6]=c1;
344 r[7]=c2;
345 }
diff --git a/src/lib/libssl/src/crypto/bn/bn_ctx.c b/src/lib/libssl/src/crypto/bn/bn_ctx.c
new file mode 100644
index 0000000000..46132fd180
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/bn_ctx.c
@@ -0,0 +1,144 @@
1/* crypto/bn/bn_ctx.c */
2/* Written by Ulf Moeller for the OpenSSL project. */
3/* ====================================================================
4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
22 *
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * openssl-core@openssl.org.
27 *
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
31 *
32 * 6. Redistributions of any form whatsoever must retain the following
33 * acknowledgment:
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This product includes cryptographic software written by Eric Young
52 * (eay@cryptsoft.com). This product includes software written by Tim
53 * Hudson (tjh@cryptsoft.com).
54 *
55 */
56
57#ifndef BN_CTX_DEBUG
58# undef NDEBUG /* avoid conflicting definitions */
59# define NDEBUG
60#endif
61
62#include <stdio.h>
63#include <assert.h>
64#include "cryptlib.h"
65#include <openssl/bn.h>
66
67
68BN_CTX *BN_CTX_new(void)
69 {
70 BN_CTX *ret;
71
72 ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
73 if (ret == NULL)
74 {
75 BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
76 return(NULL);
77 }
78
79 BN_CTX_init(ret);
80 ret->flags=BN_FLG_MALLOCED;
81 return(ret);
82 }
83
84void BN_CTX_init(BN_CTX *ctx)
85 {
86 int i;
87 ctx->tos = 0;
88 ctx->flags = 0;
89 ctx->depth = 0;
90 ctx->too_many = 0;
91 for (i = 0; i < BN_CTX_NUM; i++)
92 BN_init(&(ctx->bn[i]));
93 }
94
95void BN_CTX_free(BN_CTX *ctx)
96 {
97 int i;
98
99 if (ctx == NULL) return;
100 assert(ctx->depth == 0);
101
102 for (i=0; i < BN_CTX_NUM; i++)
103 BN_clear_free(&(ctx->bn[i]));
104 if (ctx->flags & BN_FLG_MALLOCED)
105 Free(ctx);
106 }
107
108void BN_CTX_start(BN_CTX *ctx)
109 {
110 if (ctx->depth < BN_CTX_NUM_POS)
111 ctx->pos[ctx->depth] = ctx->tos;
112 ctx->depth++;
113 }
114
115BIGNUM *BN_CTX_get(BN_CTX *ctx)
116 {
117 if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)
118 {
119 if (!ctx->too_many)
120 {
121 BNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);
122 /* disable error code until BN_CTX_end is called: */
123 ctx->too_many = 1;
124 }
125 return NULL;
126 }
127 return (&(ctx->bn[ctx->tos++]));
128 }
129
130void BN_CTX_end(BN_CTX *ctx)
131 {
132 if (ctx == NULL) return;
133 assert(ctx->depth > 0);
134 if (ctx->depth == 0)
135 /* should never happen, but we can tolerate it if not in
136 * debug mode (could be a 'goto err' in the calling function
137 * before BN_CTX_start was reached) */
138 BN_CTX_start(ctx);
139
140 ctx->too_many = 0;
141 ctx->depth--;
142 if (ctx->depth < BN_CTX_NUM_POS)
143 ctx->tos = ctx->pos[ctx->depth];
144 }
diff --git a/src/lib/libssl/src/crypto/bn/bn_div.c b/src/lib/libssl/src/crypto/bn/bn_div.c
index 150dd289a5..07af1d3b44 100644
--- a/src/lib/libssl/src/crypto/bn/bn_div.c
+++ b/src/lib/libssl/src/crypto/bn/bn_div.c
@@ -63,9 +63,11 @@
63 63
64/* The old slow way */ 64/* The old slow way */
65#if 0 65#if 0
66int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx) 66int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
67 BN_CTX *ctx)
67 { 68 {
68 int i,nm,nd; 69 int i,nm,nd;
70 int ret = 0;
69 BIGNUM *D; 71 BIGNUM *D;
70 72
71 bn_check_top(m); 73 bn_check_top(m);
@@ -84,14 +86,17 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
84 return(1); 86 return(1);
85 } 87 }
86 88
87 D= &(ctx->bn[ctx->tos]); 89 BN_CTX_start(ctx);
88 if (dv == NULL) dv= &(ctx->bn[ctx->tos+1]); 90 D = BN_CTX_get(ctx);
89 if (rem == NULL) rem= &(ctx->bn[ctx->tos+2]); 91 if (dv == NULL) dv = BN_CTX_get(ctx);
92 if (rem == NULL) rem = BN_CTX_get(ctx);
93 if (D == NULL || dv == NULL || rem == NULL)
94 goto end;
90 95
91 nd=BN_num_bits(d); 96 nd=BN_num_bits(d);
92 nm=BN_num_bits(m); 97 nm=BN_num_bits(m);
93 if (BN_copy(D,d) == NULL) return(0); 98 if (BN_copy(D,d) == NULL) goto end;
94 if (BN_copy(rem,m) == NULL) return(0); 99 if (BN_copy(rem,m) == NULL) goto end;
95 100
96 /* The next 2 are needed so we can do a dv->d[0]|=1 later 101 /* The next 2 are needed so we can do a dv->d[0]|=1 later
97 * since BN_lshift1 will only work once there is a value :-) */ 102 * since BN_lshift1 will only work once there is a value :-) */
@@ -99,25 +104,54 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
99 bn_wexpand(dv,1); 104 bn_wexpand(dv,1);
100 dv->top=1; 105 dv->top=1;
101 106
102 if (!BN_lshift(D,D,nm-nd)) return(0); 107 if (!BN_lshift(D,D,nm-nd)) goto end;
103 for (i=nm-nd; i>=0; i--) 108 for (i=nm-nd; i>=0; i--)
104 { 109 {
105 if (!BN_lshift1(dv,dv)) return(0); 110 if (!BN_lshift1(dv,dv)) goto end;
106 if (BN_ucmp(rem,D) >= 0) 111 if (BN_ucmp(rem,D) >= 0)
107 { 112 {
108 dv->d[0]|=1; 113 dv->d[0]|=1;
109 if (!BN_usub(rem,rem,D)) return(0); 114 if (!BN_usub(rem,rem,D)) goto end;
110 } 115 }
111/* CAN IMPROVE (and have now :=) */ 116/* CAN IMPROVE (and have now :=) */
112 if (!BN_rshift1(D,D)) return(0); 117 if (!BN_rshift1(D,D)) goto end;
113 } 118 }
114 rem->neg=BN_is_zero(rem)?0:m->neg; 119 rem->neg=BN_is_zero(rem)?0:m->neg;
115 dv->neg=m->neg^d->neg; 120 dv->neg=m->neg^d->neg;
116 return(1); 121 ret = 1;
122 end:
123 BN_CTX_end(ctx);
124 return(ret);
117 } 125 }
118 126
119#else 127#else
120 128
129#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC) && !defined(BN_DIV3W)
130# if defined(__GNUC__) && __GNUC__>=2
131# if defined(__i386)
132 /*
133 * There were two reasons for implementing this template:
134 * - GNU C generates a call to a function (__udivdi3 to be exact)
135 * in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
136 * understand why...);
137 * - divl doesn't only calculate quotient, but also leaves
138 * remainder in %edx which we can definitely use here:-)
139 *
140 * <appro@fy.chalmers.se>
141 */
142# define bn_div_words(n0,n1,d0) \
143 ({ asm volatile ( \
144 "divl %4" \
145 : "=a"(q), "=d"(rem) \
146 : "a"(n1), "d"(n0), "g"(d0) \
147 : "cc"); \
148 q; \
149 })
150# define REMAINDER_IS_ALREADY_CALCULATED
151# endif /* __<cpu> */
152# endif /* __GNUC__ */
153#endif /* NO_ASM */
154
121int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, 155int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
122 BN_CTX *ctx) 156 BN_CTX *ctx)
123 { 157 {
@@ -144,13 +178,15 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
144 return(1); 178 return(1);
145 } 179 }
146 180
147 tmp= &(ctx->bn[ctx->tos]); 181 BN_CTX_start(ctx);
182 tmp=BN_CTX_get(ctx);
148 tmp->neg=0; 183 tmp->neg=0;
149 snum= &(ctx->bn[ctx->tos+1]); 184 snum=BN_CTX_get(ctx);
150 sdiv= &(ctx->bn[ctx->tos+2]); 185 sdiv=BN_CTX_get(ctx);
151 if (dv == NULL) 186 if (dv == NULL)
152 res= &(ctx->bn[ctx->tos+3]); 187 res=BN_CTX_get(ctx);
153 else res=dv; 188 else res=dv;
189 if (res == NULL) goto err;
154 190
155 /* First we normalise the numbers */ 191 /* First we normalise the numbers */
156 norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); 192 norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
@@ -202,97 +238,76 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
202 { 238 {
203 BN_ULONG q,l0; 239 BN_ULONG q,l0;
204#ifdef BN_DIV3W 240#ifdef BN_DIV3W
205 q=bn_div_3_words(wnump,d0,d1); 241 q=bn_div_3_words(wnump,d1,d0);
206#else 242#else
207
208#if !defined(NO_ASM) && !defined(PEDANTIC)
209# if defined(__GNUC__) && __GNUC__>=2
210# if defined(__i386)
211 /*
212 * There were two reasons for implementing this template:
213 * - GNU C generates a call to a function (__udivdi3 to be exact)
214 * in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
215 * understand why...);
216 * - divl doesn't only calculate quotient, but also leaves
217 * remainder in %edx which we can definitely use here:-)
218 *
219 * <appro@fy.chalmers.se>
220 */
221# define bn_div_words(n0,n1,d0) \
222 ({ asm volatile ( \
223 "divl %4" \
224 : "=a"(q), "=d"(rem) \
225 : "a"(n1), "d"(n0), "g"(d0) \
226 : "cc"); \
227 q; \
228 })
229# define REMINDER_IS_ALREADY_CALCULATED
230# endif /* __<cpu> */
231# endif /* __GNUC__ */
232#endif /* NO_ASM */
233 BN_ULONG n0,n1,rem=0; 243 BN_ULONG n0,n1,rem=0;
234 244
235 n0=wnump[0]; 245 n0=wnump[0];
236 n1=wnump[-1]; 246 n1=wnump[-1];
237 if (n0 == d0) 247 if (n0 == d0)
238 q=BN_MASK2; 248 q=BN_MASK2;
239 else 249 else /* n0 < d0 */
250 {
251#ifdef BN_LLONG
252 BN_ULLONG t2;
253
240#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words) 254#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
241 q=((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0; 255 q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
242#else 256#else
243 q=bn_div_words(n0,n1,d0); 257 q=bn_div_words(n0,n1,d0);
244#endif 258#endif
245 { 259
246#ifdef BN_LLONG 260#ifndef REMAINDER_IS_ALREADY_CALCULATED
247 BN_ULLONG t2; 261 /*
248 262 * rem doesn't have to be BN_ULLONG. The least we
249#ifndef REMINDER_IS_ALREADY_CALCULATED 263 * know it's less that d0, isn't it?
250 /* 264 */
251 * rem doesn't have to be BN_ULLONG. The least we 265 rem=(n1-q*d0)&BN_MASK2;
252 * know it's less that d0, isn't it?
253 */
254 rem=(n1-q*d0)&BN_MASK2;
255#endif 266#endif
256 t2=(BN_ULLONG)d1*q; 267 t2=(BN_ULLONG)d1*q;
268
269 for (;;)
270 {
271 if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))
272 break;
273 q--;
274 rem += d0;
275 if (rem < d0) break; /* don't let rem overflow */
276 t2 -= d1;
277 }
278#else /* !BN_LLONG */
279 BN_ULONG t2l,t2h,ql,qh;
257 280
258 for (;;) 281 q=bn_div_words(n0,n1,d0);
259 { 282#ifndef REMAINDER_IS_ALREADY_CALCULATED
260 if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2])) 283 rem=(n1-q*d0)&BN_MASK2;
261 break; 284#endif
262 q--; 285
263 rem += d0; 286#ifdef BN_UMULT_HIGH
264 if (rem < d0) break; /* don't let rem overflow */ 287 t2l = d1 * q;
265 t2 -= d1; 288 t2h = BN_UMULT_HIGH(d1,q);
266 }
267#else 289#else
268 BN_ULONG t2l,t2h,ql,qh; 290 t2l=LBITS(d1); t2h=HBITS(d1);
269 291 ql =LBITS(q); qh =HBITS(q);
270#ifndef REMINDER_IS_ALREADY_CALCULATED 292 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
271 /*
272 * It's more than enough with the only multiplication.
273 * See the comment above in BN_LLONG section...
274 */
275 rem=(n1-q*d0)&BN_MASK2;
276#endif 293#endif
277 t2l=LBITS(d1); t2h=HBITS(d1);
278 ql =LBITS(q); qh =HBITS(q);
279 mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
280 294
281 for (;;) 295 for (;;)
282 { 296 {
283 if ((t2h < rem) || 297 if ((t2h < rem) ||
284 ((t2h == rem) && (t2l <= wnump[-2]))) 298 ((t2h == rem) && (t2l <= wnump[-2])))
285 break; 299 break;
286 q--; 300 q--;
287 rem += d0; 301 rem += d0;
288 if (rem < d0) break; /* don't let rem overflow */ 302 if (rem < d0) break; /* don't let rem overflow */
289 if (t2l < d1) t2h--; t2l -= d1; 303 if (t2l < d1) t2h--; t2l -= d1;
304 }
305#endif /* !BN_LLONG */
290 } 306 }
291#endif
292 }
293#endif /* !BN_DIV3W */ 307#endif /* !BN_DIV3W */
294 wnum.d--; wnum.top++; 308
295 l0=bn_mul_words(tmp->d,sdiv->d,div_n,q); 309 l0=bn_mul_words(tmp->d,sdiv->d,div_n,q);
310 wnum.d--; wnum.top++;
296 tmp->d[div_n]=l0; 311 tmp->d[div_n]=l0;
297 for (j=div_n+1; j>0; j--) 312 for (j=div_n+1; j>0; j--)
298 if (tmp->d[j-1]) break; 313 if (tmp->d[j-1]) break;
@@ -318,8 +333,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
318 BN_rshift(rm,snum,norm_shift); 333 BN_rshift(rm,snum,norm_shift);
319 rm->neg=num->neg; 334 rm->neg=num->neg;
320 } 335 }
336 BN_CTX_end(ctx);
321 return(1); 337 return(1);
322err: 338err:
339 BN_CTX_end(ctx);
323 return(0); 340 return(0);
324 } 341 }
325 342
@@ -335,22 +352,27 @@ int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
335 if (BN_ucmp(m,d) < 0) 352 if (BN_ucmp(m,d) < 0)
336 return((BN_copy(rem,m) == NULL)?0:1); 353 return((BN_copy(rem,m) == NULL)?0:1);
337 354
338 dv= &(ctx->bn[ctx->tos]); 355 BN_CTX_start(ctx);
356 dv=BN_CTX_get(ctx);
339 357
340 if (!BN_copy(rem,m)) return(0); 358 if (!BN_copy(rem,m)) goto err;
341 359
342 nm=BN_num_bits(rem); 360 nm=BN_num_bits(rem);
343 nd=BN_num_bits(d); 361 nd=BN_num_bits(d);
344 if (!BN_lshift(dv,d,nm-nd)) return(0); 362 if (!BN_lshift(dv,d,nm-nd)) goto err;
345 for (i=nm-nd; i>=0; i--) 363 for (i=nm-nd; i>=0; i--)
346 { 364 {
347 if (BN_cmp(rem,dv) >= 0) 365 if (BN_cmp(rem,dv) >= 0)
348 { 366 {
349 if (!BN_sub(rem,rem,dv)) return(0); 367 if (!BN_sub(rem,rem,dv)) goto err;
350 } 368 }
351 if (!BN_rshift1(dv,dv)) return(0); 369 if (!BN_rshift1(dv,dv)) goto err;
352 } 370 }
371 BN_CTX_end(ctx);
353 return(1); 372 return(1);
373 err:
374 BN_CTX_end(ctx);
375 return(0);
354#else 376#else
355 return(BN_div(NULL,rem,m,d,ctx)); 377 return(BN_div(NULL,rem,m,d,ctx));
356#endif 378#endif
diff --git a/src/lib/libssl/src/crypto/bn/bn_err.c b/src/lib/libssl/src/crypto/bn/bn_err.c
index 73e80774e5..f3b9497dca 100644
--- a/src/lib/libssl/src/crypto/bn/bn_err.c
+++ b/src/lib/libssl/src/crypto/bn/bn_err.c
@@ -71,6 +71,7 @@ static ERR_STRING_DATA BN_str_functs[]=
71{ERR_PACK(0,BN_F_BN_BLINDING_UPDATE,0), "BN_BLINDING_update"}, 71{ERR_PACK(0,BN_F_BN_BLINDING_UPDATE,0), "BN_BLINDING_update"},
72{ERR_PACK(0,BN_F_BN_BN2DEC,0), "BN_bn2dec"}, 72{ERR_PACK(0,BN_F_BN_BN2DEC,0), "BN_bn2dec"},
73{ERR_PACK(0,BN_F_BN_BN2HEX,0), "BN_bn2hex"}, 73{ERR_PACK(0,BN_F_BN_BN2HEX,0), "BN_bn2hex"},
74{ERR_PACK(0,BN_F_BN_CTX_GET,0), "BN_CTX_get"},
74{ERR_PACK(0,BN_F_BN_CTX_NEW,0), "BN_CTX_new"}, 75{ERR_PACK(0,BN_F_BN_CTX_NEW,0), "BN_CTX_new"},
75{ERR_PACK(0,BN_F_BN_DIV,0), "BN_div"}, 76{ERR_PACK(0,BN_F_BN_DIV,0), "BN_div"},
76{ERR_PACK(0,BN_F_BN_EXPAND2,0), "bn_expand2"}, 77{ERR_PACK(0,BN_F_BN_EXPAND2,0), "bn_expand2"},
@@ -95,6 +96,7 @@ static ERR_STRING_DATA BN_str_reasons[]=
95{BN_R_INVALID_LENGTH ,"invalid length"}, 96{BN_R_INVALID_LENGTH ,"invalid length"},
96{BN_R_NOT_INITIALIZED ,"not initialized"}, 97{BN_R_NOT_INITIALIZED ,"not initialized"},
97{BN_R_NO_INVERSE ,"no inverse"}, 98{BN_R_NO_INVERSE ,"no inverse"},
99{BN_R_TOO_MANY_TEMPORARY_VARIABLES ,"too many temporary variables"},
98{0,NULL} 100{0,NULL}
99 }; 101 };
100 102
diff --git a/src/lib/libssl/src/crypto/bn/bn_exp.c b/src/lib/libssl/src/crypto/bn/bn_exp.c
index 2df1614ada..0c11601675 100644
--- a/src/lib/libssl/src/crypto/bn/bn_exp.c
+++ b/src/lib/libssl/src/crypto/bn/bn_exp.c
@@ -59,6 +59,12 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62#ifdef ATALLA
63# include <alloca.h>
64# include <atasi.h>
65# include <assert.h>
66# include <dlfcn.h>
67#endif
62 68
63#define TABLE_SIZE 16 69#define TABLE_SIZE 16
64 70
@@ -72,7 +78,8 @@ int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
72 bn_check_top(b); 78 bn_check_top(b);
73 bn_check_top(m); 79 bn_check_top(m);
74 80
75 t= &(ctx->bn[ctx->tos++]); 81 BN_CTX_start(ctx);
82 if ((t = BN_CTX_get(ctx)) == NULL) goto err;
76 if (a == b) 83 if (a == b)
77 { if (!BN_sqr(t,a,ctx)) goto err; } 84 { if (!BN_sqr(t,a,ctx)) goto err; }
78 else 85 else
@@ -80,7 +87,7 @@ int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
80 if (!BN_mod(ret,t,m,ctx)) goto err; 87 if (!BN_mod(ret,t,m,ctx)) goto err;
81 r=1; 88 r=1;
82err: 89err:
83 ctx->tos--; 90 BN_CTX_end(ctx);
84 return(r); 91 return(r);
85 } 92 }
86 93
@@ -91,8 +98,10 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx)
91 int i,bits,ret=0; 98 int i,bits,ret=0;
92 BIGNUM *v,*tmp; 99 BIGNUM *v,*tmp;
93 100
94 v= &(ctx->bn[ctx->tos++]); 101 BN_CTX_start(ctx);
95 tmp= &(ctx->bn[ctx->tos++]); 102 v = BN_CTX_get(ctx);
103 tmp = BN_CTX_get(ctx);
104 if (v == NULL || tmp == NULL) goto err;
96 105
97 if (BN_copy(v,a) == NULL) goto err; 106 if (BN_copy(v,a) == NULL) goto err;
98 bits=BN_num_bits(p); 107 bits=BN_num_bits(p);
@@ -113,7 +122,7 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx)
113 } 122 }
114 ret=1; 123 ret=1;
115err: 124err:
116 ctx->tos-=2; 125 BN_CTX_end(ctx);
117 return(ret); 126 return(ret);
118 } 127 }
119 128
@@ -122,15 +131,15 @@ err:
122/* this one works - simple but works */ 131/* this one works - simple but works */
123int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx) 132int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx)
124 { 133 {
125 int i,bits,ret=0,tos; 134 int i,bits,ret=0;
126 BIGNUM *v,*rr; 135 BIGNUM *v,*rr;
127 136
128 tos=ctx->tos; 137 BN_CTX_start(ctx);
129 v= &(ctx->bn[ctx->tos++]);
130 if ((r == a) || (r == p)) 138 if ((r == a) || (r == p))
131 rr= &(ctx->bn[ctx->tos++]); 139 rr = BN_CTX_get(ctx);
132 else 140 else
133 rr=r; 141 rr = r;
142 if ((v = BN_CTX_get(ctx)) == NULL) goto err;
134 143
135 if (BN_copy(v,a) == NULL) goto err; 144 if (BN_copy(v,a) == NULL) goto err;
136 bits=BN_num_bits(p); 145 bits=BN_num_bits(p);
@@ -149,11 +158,178 @@ int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx)
149 } 158 }
150 ret=1; 159 ret=1;
151err: 160err:
152 ctx->tos=tos;
153 if (r != rr) BN_copy(r,rr); 161 if (r != rr) BN_copy(r,rr);
162 BN_CTX_end(ctx);
154 return(ret); 163 return(ret);
155 } 164 }
156 165
166#ifdef ATALLA
167
168/*
169 * This routine will dynamically check for the existance of an Atalla AXL-200
170 * SSL accelerator module. If one is found, the variable
171 * asi_accelerator_present is set to 1 and the function pointers
172 * ptr_ASI_xxxxxx above will be initialized to corresponding ASI API calls.
173 */
174typedef int tfnASI_GetPerformanceStatistics(int reset_flag,
175 unsigned int *ret_buf);
176typedef int tfnASI_GetHardwareConfig(long card_num, unsigned int *ret_buf);
177typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey,
178 unsigned char *output,
179 unsigned char *input,
180 unsigned int modulus_len);
181
182static tfnASI_GetHardwareConfig *ptr_ASI_GetHardwareConfig;
183static tfnASI_RSAPrivateKeyOpFn *ptr_ASI_RSAPrivateKeyOpFn;
184static tfnASI_GetPerformanceStatistics *ptr_ASI_GetPerformanceStatistics;
185static int asi_accelerator_present;
186static int tried_atalla;
187
188void atalla_initialize_accelerator_handle(void)
189 {
190 void *dl_handle;
191 int status;
192 unsigned int config_buf[1024];
193 static int tested;
194
195 if(tested)
196 return;
197
198 tested=1;
199
200 bzero((void *)config_buf, 1024);
201
202 /*
203 * Check to see if the library is present on the system
204 */
205 dl_handle = dlopen("atasi.so", RTLD_NOW);
206 if (dl_handle == (void *) NULL)
207 {
208/* printf("atasi.so library is not present on the system\n");
209 printf("No HW acceleration available\n");*/
210 return;
211 }
212
213 /*
214 * The library is present. Now we'll check to insure that the
215 * LDM is up and running. First we'll get the address of the
216 * function in the atasi library that we need to see if the
217 * LDM is operating.
218 */
219
220 ptr_ASI_GetHardwareConfig =
221 (tfnASI_GetHardwareConfig *)dlsym(dl_handle,"ASI_GetHardwareConfig");
222
223 if (ptr_ASI_GetHardwareConfig)
224 {
225 /*
226 * We found the call, now we'll get our config
227 * status. If we get a non 0 result, the LDM is not
228 * running and we cannot use the Atalla ASI *
229 * library.
230 */
231 status = (*ptr_ASI_GetHardwareConfig)(0L, config_buf);
232 if (status != 0)
233 {
234 printf("atasi.so library is present but not initialized\n");
235 printf("No HW acceleration available\n");
236 return;
237 }
238 }
239 else
240 {
241/* printf("We found the library, but not the function. Very Strange!\n");*/
242 return ;
243 }
244
245 /*
246 * It looks like we have acceleration capabilities. Load up the
247 * pointers to our ASI API calls.
248 */
249 ptr_ASI_RSAPrivateKeyOpFn=
250 (tfnASI_RSAPrivateKeyOpFn *)dlsym(dl_handle, "ASI_RSAPrivateKeyOpFn");
251 if (ptr_ASI_RSAPrivateKeyOpFn == NULL)
252 {
253/* printf("We found the library, but no RSA function. Very Strange!\n");*/
254 return;
255 }
256
257 ptr_ASI_GetPerformanceStatistics =
258 (tfnASI_GetPerformanceStatistics *)dlsym(dl_handle, "ASI_GetPerformanceStatistics");
259 if (ptr_ASI_GetPerformanceStatistics == NULL)
260 {
261/* printf("We found the library, but no stat function. Very Strange!\n");*/
262 return;
263 }
264
265 /*
266 * Indicate that acceleration is available
267 */
268 asi_accelerator_present = 1;
269
270/* printf("This system has acceleration!\n");*/
271
272 return;
273 }
274
275/* make sure this only gets called once when bn_mod_exp calls bn_mod_exp_mont */
276int BN_mod_exp_atalla(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m)
277 {
278 unsigned char *abin;
279 unsigned char *pbin;
280 unsigned char *mbin;
281 unsigned char *rbin;
282 int an,pn,mn,ret;
283 RSAPrivateKey keydata;
284
285 atalla_initialize_accelerator_handle();
286 if(!asi_accelerator_present)
287 return 0;
288
289
290/* We should be able to run without size testing */
291# define ASIZE 128
292 an=BN_num_bytes(a);
293 pn=BN_num_bytes(p);
294 mn=BN_num_bytes(m);
295
296 if(an <= ASIZE && pn <= ASIZE && mn <= ASIZE)
297 {
298 int size=mn;
299
300 assert(an <= mn);
301 abin=alloca(size);
302 memset(abin,'\0',mn);
303 BN_bn2bin(a,abin+size-an);
304
305 pbin=alloca(pn);
306 BN_bn2bin(p,pbin);
307
308 mbin=alloca(size);
309 memset(mbin,'\0',mn);
310 BN_bn2bin(m,mbin+size-mn);
311
312 rbin=alloca(size);
313
314 memset(&keydata,'\0',sizeof keydata);
315 keydata.privateExponent.data=pbin;
316 keydata.privateExponent.len=pn;
317 keydata.modulus.data=mbin;
318 keydata.modulus.len=size;
319
320 ret=(*ptr_ASI_RSAPrivateKeyOpFn)(&keydata,rbin,abin,keydata.modulus.len);
321/*fprintf(stderr,"!%s\n",BN_bn2hex(a));*/
322 if(!ret)
323 {
324 BN_bin2bn(rbin,keydata.modulus.len,r);
325/*fprintf(stderr,"?%s\n",BN_bn2hex(r));*/
326 return 1;
327 }
328 }
329 return 0;
330 }
331#endif /* def ATALLA */
332
157int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, 333int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
158 BN_CTX *ctx) 334 BN_CTX *ctx)
159 { 335 {
@@ -163,6 +339,13 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
163 bn_check_top(p); 339 bn_check_top(p);
164 bn_check_top(m); 340 bn_check_top(m);
165 341
342#ifdef ATALLA
343 if(BN_mod_exp_atalla(r,a,p,m))
344 return 1;
345/* If it fails, try the other methods (but don't try atalla again) */
346 tried_atalla=1;
347#endif
348
166#ifdef MONT_MUL_MOD 349#ifdef MONT_MUL_MOD
167 /* I have finally been able to take out this pre-condition of 350 /* I have finally been able to take out this pre-condition of
168 * the top bit being set. It was caused by an error in BN_div 351 * the top bit being set. It was caused by an error in BN_div
@@ -180,6 +363,10 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
180 { ret=BN_mod_exp_simple(r,a,p,m,ctx); } 363 { ret=BN_mod_exp_simple(r,a,p,m,ctx); }
181#endif 364#endif
182 365
366#ifdef ATALLA
367 tried_atalla=0;
368#endif
369
183 return(ret); 370 return(ret);
184 } 371 }
185 372
@@ -193,7 +380,6 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
193 BIGNUM val[TABLE_SIZE]; 380 BIGNUM val[TABLE_SIZE];
194 BN_RECP_CTX recp; 381 BN_RECP_CTX recp;
195 382
196 aa= &(ctx->bn[ctx->tos++]);
197 bits=BN_num_bits(p); 383 bits=BN_num_bits(p);
198 384
199 if (bits == 0) 385 if (bits == 0)
@@ -201,6 +387,10 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
201 BN_one(r); 387 BN_one(r);
202 return(1); 388 return(1);
203 } 389 }
390
391 BN_CTX_start(ctx);
392 if ((aa = BN_CTX_get(ctx)) == NULL) goto err;
393
204 BN_RECP_CTX_init(&recp); 394 BN_RECP_CTX_init(&recp);
205 if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err; 395 if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;
206 396
@@ -289,7 +479,7 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
289 } 479 }
290 ret=1; 480 ret=1;
291err: 481err:
292 ctx->tos--; 482 BN_CTX_end(ctx);
293 for (i=0; i<ts; i++) 483 for (i=0; i<ts; i++)
294 BN_clear_free(&(val[i])); 484 BN_clear_free(&(val[i]));
295 BN_RECP_CTX_free(&recp); 485 BN_RECP_CTX_free(&recp);
@@ -312,19 +502,27 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
312 bn_check_top(p); 502 bn_check_top(p);
313 bn_check_top(m); 503 bn_check_top(m);
314 504
505#ifdef ATALLA
506 if(!tried_atalla && BN_mod_exp_atalla(rr,a,p,m))
507 return 1;
508/* If it fails, try the other methods */
509#endif
510
315 if (!(m->d[0] & 1)) 511 if (!(m->d[0] & 1))
316 { 512 {
317 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); 513 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);
318 return(0); 514 return(0);
319 } 515 }
320 d= &(ctx->bn[ctx->tos++]);
321 r= &(ctx->bn[ctx->tos++]);
322 bits=BN_num_bits(p); 516 bits=BN_num_bits(p);
323 if (bits == 0) 517 if (bits == 0)
324 { 518 {
325 BN_one(r); 519 BN_one(rr);
326 return(1); 520 return(1);
327 } 521 }
522 BN_CTX_start(ctx);
523 d = BN_CTX_get(ctx);
524 r = BN_CTX_get(ctx);
525 if (d == NULL || r == NULL) goto err;
328 526
329 /* If this is not done, things will break in the montgomery 527 /* If this is not done, things will break in the montgomery
330 * part */ 528 * part */
@@ -432,7 +630,7 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
432 ret=1; 630 ret=1;
433err: 631err:
434 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); 632 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
435 ctx->tos-=2; 633 BN_CTX_end(ctx);
436 for (i=0; i<ts; i++) 634 for (i=0; i<ts; i++)
437 BN_clear_free(&(val[i])); 635 BN_clear_free(&(val[i]));
438 return(ret); 636 return(ret);
@@ -448,7 +646,6 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
448 BIGNUM *d; 646 BIGNUM *d;
449 BIGNUM val[TABLE_SIZE]; 647 BIGNUM val[TABLE_SIZE];
450 648
451 d= &(ctx->bn[ctx->tos++]);
452 bits=BN_num_bits(p); 649 bits=BN_num_bits(p);
453 650
454 if (bits == 0) 651 if (bits == 0)
@@ -457,6 +654,9 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
457 return(1); 654 return(1);
458 } 655 }
459 656
657 BN_CTX_start(ctx);
658 if ((d = BN_CTX_get(ctx)) == NULL) goto err;
659
460 BN_init(&(val[0])); 660 BN_init(&(val[0]));
461 ts=1; 661 ts=1;
462 if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */ 662 if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */
@@ -541,7 +741,7 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
541 } 741 }
542 ret=1; 742 ret=1;
543err: 743err:
544 ctx->tos--; 744 BN_CTX_end(ctx);
545 for (i=0; i<ts; i++) 745 for (i=0; i<ts; i++)
546 BN_clear_free(&(val[i])); 746 BN_clear_free(&(val[i]));
547 return(ret); 747 return(ret);
diff --git a/src/lib/libssl/src/crypto/bn/bn_exp2.c b/src/lib/libssl/src/crypto/bn/bn_exp2.c
index 1132d53365..4f4e9e3299 100644
--- a/src/lib/libssl/src/crypto/bn/bn_exp2.c
+++ b/src/lib/libssl/src/crypto/bn/bn_exp2.c
@@ -9,7 +9,7 @@
9 * bits=1 75.4% 79.4% 9 * bits=1 75.4% 79.4%
10 * bits=2 61.2% 62.4% 10 * bits=2 61.2% 62.4%
11 * bits=3 61.3% 59.3% 11 * bits=3 61.3% 59.3%
12 * The lack of speed improvment is also a function of the pre-calculation 12 * The lack of speed improvement is also a function of the pre-calculation
13 * which could be removed. 13 * which could be removed.
14 */ 14 */
15#define EXP2_TABLE_BITS 2 /* 1 2 3 4 5 */ 15#define EXP2_TABLE_BITS 2 /* 1 2 3 4 5 */
@@ -35,15 +35,19 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
35 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); 35 BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);
36 return(0); 36 return(0);
37 } 37 }
38 d= &(ctx->bn[ctx->tos++]);
39 r= &(ctx->bn[ctx->tos++]);
40 bits1=BN_num_bits(p1); 38 bits1=BN_num_bits(p1);
41 bits2=BN_num_bits(p2); 39 bits2=BN_num_bits(p2);
42 if ((bits1 == 0) && (bits2 == 0)) 40 if ((bits1 == 0) && (bits2 == 0))
43 { 41 {
44 BN_one(r); 42 BN_one(rr);
45 return(1); 43 return(1);
46 } 44 }
45
46 BN_CTX_start(ctx);
47 d = BN_CTX_get(ctx);
48 r = BN_CTX_get(ctx);
49 if (d == NULL || r == NULL) goto err;
50
47 bits=(bits1 > bits2)?bits1:bits2; 51 bits=(bits1 > bits2)?bits1:bits2;
48 52
49 /* If this is not done, things will break in the montgomery 53 /* If this is not done, things will break in the montgomery
@@ -183,7 +187,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
183 ret=1; 187 ret=1;
184err: 188err:
185 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); 189 if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
186 ctx->tos-=2; 190 BN_CTX_end(ctx);
187 for (i=0; i<ts; i++) 191 for (i=0; i<ts; i++)
188 { 192 {
189 for (j=0; j<ts; j++) 193 for (j=0; j<ts; j++)
diff --git a/src/lib/libssl/src/crypto/bn/bn_gcd.c b/src/lib/libssl/src/crypto/bn/bn_gcd.c
index 64a76f4498..398207196b 100644
--- a/src/lib/libssl/src/crypto/bn/bn_gcd.c
+++ b/src/lib/libssl/src/crypto/bn/bn_gcd.c
@@ -61,6 +61,7 @@
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62 62
63static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); 63static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
64
64int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx) 65int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
65 { 66 {
66 BIGNUM *a,*b,*t; 67 BIGNUM *a,*b,*t;
@@ -69,8 +70,10 @@ int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
69 bn_check_top(in_a); 70 bn_check_top(in_a);
70 bn_check_top(in_b); 71 bn_check_top(in_b);
71 72
72 a= &(ctx->bn[ctx->tos]); 73 BN_CTX_start(ctx);
73 b= &(ctx->bn[ctx->tos+1]); 74 a = BN_CTX_get(ctx);
75 b = BN_CTX_get(ctx);
76 if (a == NULL || b == NULL) goto err;
74 77
75 if (BN_copy(a,in_a) == NULL) goto err; 78 if (BN_copy(a,in_a) == NULL) goto err;
76 if (BN_copy(b,in_b) == NULL) goto err; 79 if (BN_copy(b,in_b) == NULL) goto err;
@@ -82,6 +85,7 @@ int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
82 if (BN_copy(r,t) == NULL) goto err; 85 if (BN_copy(r,t) == NULL) goto err;
83 ret=1; 86 ret=1;
84err: 87err:
88 BN_CTX_end(ctx);
85 return(ret); 89 return(ret);
86 } 90 }
87 91
@@ -142,20 +146,22 @@ err:
142/* solves ax == 1 (mod n) */ 146/* solves ax == 1 (mod n) */
143BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) 147BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
144 { 148 {
145 BIGNUM *A,*B,*X,*Y,*M,*D,*R; 149 BIGNUM *A,*B,*X,*Y,*M,*D,*R=NULL;
146 BIGNUM *T,*ret=NULL; 150 BIGNUM *T,*ret=NULL;
147 int sign; 151 int sign;
148 152
149 bn_check_top(a); 153 bn_check_top(a);
150 bn_check_top(n); 154 bn_check_top(n);
151 155
152 A= &(ctx->bn[ctx->tos]); 156 BN_CTX_start(ctx);
153 B= &(ctx->bn[ctx->tos+1]); 157 A = BN_CTX_get(ctx);
154 X= &(ctx->bn[ctx->tos+2]); 158 B = BN_CTX_get(ctx);
155 D= &(ctx->bn[ctx->tos+3]); 159 X = BN_CTX_get(ctx);
156 M= &(ctx->bn[ctx->tos+4]); 160 D = BN_CTX_get(ctx);
157 Y= &(ctx->bn[ctx->tos+5]); 161 M = BN_CTX_get(ctx);
158 ctx->tos+=6; 162 Y = BN_CTX_get(ctx);
163 if (Y == NULL) goto err;
164
159 if (in == NULL) 165 if (in == NULL)
160 R=BN_new(); 166 R=BN_new();
161 else 167 else
@@ -198,7 +204,7 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
198 ret=R; 204 ret=R;
199err: 205err:
200 if ((ret == NULL) && (in == NULL)) BN_free(R); 206 if ((ret == NULL) && (in == NULL)) BN_free(R);
201 ctx->tos-=6; 207 BN_CTX_end(ctx);
202 return(ret); 208 return(ret);
203 } 209 }
204 210
diff --git a/src/lib/libssl/src/crypto/bn/bn_lcl.h b/src/lib/libssl/src/crypto/bn/bn_lcl.h
index 85a372695b..e36ccbc4c2 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lcl.h
+++ b/src/lib/libssl/src/crypto/bn/bn_lcl.h
@@ -73,18 +73,53 @@ extern "C" {
73#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ 73#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
74#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ 74#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
75 75
76#if 0 76#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC)
77#ifndef BN_MUL_COMBA 77/*
78/* #define bn_mul_comba8(r,a,b) bn_mul_normal(r,a,8,b,8) */ 78 * BN_UMULT_HIGH section.
79/* #define bn_mul_comba4(r,a,b) bn_mul_normal(r,a,4,b,4) */ 79 *
80#endif 80 * No, I'm not trying to overwhelm you when stating that the
81 81 * product of N-bit numbers is 2*N bits wide:-) No, I don't expect
82#ifndef BN_SQR_COMBA 82 * you to be impressed when I say that if the compiler doesn't
83/* This is probably faster than using the C code - I need to check */ 83 * support 2*N integer type, then you have to replace every N*N
84#define bn_sqr_comba8(r,a) bn_mul_normal(r,a,8,a,8) 84 * multiplication with 4 (N/2)*(N/2) accompanied by some shifts
85#define bn_sqr_comba4(r,a) bn_mul_normal(r,a,4,a,4) 85 * and additions which unavoidably results in severe performance
86#endif 86 * penalties. Of course provided that the hardware is capable of
87#endif 87 * producing 2*N result... That's when you normally start
88 * considering assembler implementation. However! It should be
89 * pointed out that some CPUs (most notably Alpha, PowerPC and
90 * upcoming IA-64 family:-) provide *separate* instruction
91 * calculating the upper half of the product placing the result
92 * into a general purpose register. Now *if* the compiler supports
93 * inline assembler, then it's not impossible to implement the
94 * "bignum" routines (and have the compiler optimize 'em)
95 * exhibiting "native" performance in C. That's what BN_UMULT_HIGH
96 * macro is about:-)
97 *
98 * <appro@fy.chalmers.se>
99 */
100# if defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
101# if defined(__DECC)
102# include <c_asm.h>
103# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
104# elif defined(__GNUC__)
105# define BN_UMULT_HIGH(a,b) ({ \
106 register BN_ULONG ret; \
107 asm ("umulh %1,%2,%0" \
108 : "=r"(ret) \
109 : "r"(a), "r"(b)); \
110 ret; })
111# endif /* compiler */
112# elif defined(_ARCH_PPC) && defined(__64BIT__) && defined(SIXTY_FOUR_BIT_LONG)
113# if defined(__GNUC__)
114# define BN_UMULT_HIGH(a,b) ({ \
115 register BN_ULONG ret; \
116 asm ("mulhdu %0,%1,%2" \
117 : "=r"(ret) \
118 : "r"(a), "r"(b)); \
119 ret; })
120# endif /* compiler */
121# endif /* cpu */
122#endif /* NO_ASM */
88 123
89/************************************************************* 124/*************************************************************
90 * Using the long long type 125 * Using the long long type
@@ -92,15 +127,12 @@ extern "C" {
92#define Lw(t) (((BN_ULONG)(t))&BN_MASK2) 127#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
93#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) 128#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
94 129
95/* These are used for internal error checking and are not normally used */ 130/* This is used for internal error checking and is not normally used */
96#ifdef BN_DEBUG 131#ifdef BN_DEBUG
97#define bn_check_top(a) \ 132# include <assert.h>
98 { if (((a)->top < 0) || ((a)->top > (a)->max)) \ 133# define bn_check_top(a) assert ((a)->top >= 0 && (a)->top <= (a)->max);
99 { char *nullp=NULL; *nullp='z'; } }
100#define bn_check_num(a) if ((a) < 0) { char *nullp=NULL; *nullp='z'; }
101#else 134#else
102#define bn_check_top(a) 135# define bn_check_top(a)
103#define bn_check_num(a)
104#endif 136#endif
105 137
106/* This macro is to add extra stuff for development checking */ 138/* This macro is to add extra stuff for development checking */
@@ -134,8 +166,6 @@ extern "C" {
134 bn_set_max(r); \ 166 bn_set_max(r); \
135 } 167 }
136 168
137/* #define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?(n):bn_expand2((n),(b))) */
138
139#ifdef BN_LLONG 169#ifdef BN_LLONG
140#define mul_add(r,a,w,c) { \ 170#define mul_add(r,a,w,c) { \
141 BN_ULLONG t; \ 171 BN_ULLONG t; \
@@ -151,6 +181,43 @@ extern "C" {
151 (c)= Hw(t); \ 181 (c)= Hw(t); \
152 } 182 }
153 183
184#define sqr(r0,r1,a) { \
185 BN_ULLONG t; \
186 t=(BN_ULLONG)(a)*(a); \
187 (r0)=Lw(t); \
188 (r1)=Hw(t); \
189 }
190
191#elif defined(BN_UMULT_HIGH)
192#define mul_add(r,a,w,c) { \
193 BN_ULONG high,low,ret,tmp=(a); \
194 ret = (r); \
195 high= BN_UMULT_HIGH(w,tmp); \
196 ret += (c); \
197 low = (w) * tmp; \
198 (c) = (ret<(c))?1:0; \
199 (c) += high; \
200 ret += low; \
201 (c) += (ret<low)?1:0; \
202 (r) = ret; \
203 }
204
205#define mul(r,a,w,c) { \
206 BN_ULONG high,low,ret,ta=(a); \
207 low = (w) * ta; \
208 high= BN_UMULT_HIGH(w,ta); \
209 ret = low + (c); \
210 (c) = high; \
211 (c) += (ret<low)?1:0; \
212 (r) = ret; \
213 }
214
215#define sqr(r0,r1,a) { \
216 BN_ULONG tmp=(a); \
217 (r0) = tmp * tmp; \
218 (r1) = BN_UMULT_HIGH(tmp,tmp); \
219 }
220
154#else 221#else
155/************************************************************* 222/*************************************************************
156 * No long long type 223 * No long long type
@@ -228,21 +295,7 @@ extern "C" {
228 (c)=h&BN_MASK2; \ 295 (c)=h&BN_MASK2; \
229 (r)=l&BN_MASK2; \ 296 (r)=l&BN_MASK2; \
230 } 297 }
231 298#endif /* !BN_LLONG */
232#endif
233
234OPENSSL_EXTERN int bn_limit_bits;
235OPENSSL_EXTERN int bn_limit_num; /* (1<<bn_limit_bits) */
236/* Recursive 'low' limit */
237OPENSSL_EXTERN int bn_limit_bits_low;
238OPENSSL_EXTERN int bn_limit_num_low; /* (1<<bn_limit_bits_low) */
239/* Do modified 'high' part calculation' */
240OPENSSL_EXTERN int bn_limit_bits_high;
241OPENSSL_EXTERN int bn_limit_num_high; /* (1<<bn_limit_bits_high) */
242OPENSSL_EXTERN int bn_limit_bits_mont;
243OPENSSL_EXTERN int bn_limit_num_mont; /* (1<<bn_limit_bits_mont) */
244
245BIGNUM *bn_expand2(BIGNUM *b, int bits);
246 299
247void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb); 300void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
248void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); 301void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
diff --git a/src/lib/libssl/src/crypto/bn/bn_lib.c b/src/lib/libssl/src/crypto/bn/bn_lib.c
index 5d62d88e8b..0e6b12d9c3 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lib.c
+++ b/src/lib/libssl/src/crypto/bn/bn_lib.c
@@ -71,14 +71,14 @@ const char *BN_version="Big Number" OPENSSL_VERSION_PTEXT;
71 * 7 - 128 == 4096 71 * 7 - 128 == 4096
72 * 8 - 256 == 8192 72 * 8 - 256 == 8192
73 */ 73 */
74OPENSSL_GLOBAL int bn_limit_bits=0; 74static int bn_limit_bits=0;
75OPENSSL_GLOBAL int bn_limit_num=8; /* (1<<bn_limit_bits) */ 75static int bn_limit_num=8; /* (1<<bn_limit_bits) */
76OPENSSL_GLOBAL int bn_limit_bits_low=0; 76static int bn_limit_bits_low=0;
77OPENSSL_GLOBAL int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */ 77static int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */
78OPENSSL_GLOBAL int bn_limit_bits_high=0; 78static int bn_limit_bits_high=0;
79OPENSSL_GLOBAL int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */ 79static int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */
80OPENSSL_GLOBAL int bn_limit_bits_mont=0; 80static int bn_limit_bits_mont=0;
81OPENSSL_GLOBAL int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */ 81static int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */
82 82
83void BN_set_params(int mult, int high, int low, int mont) 83void BN_set_params(int mult, int high, int low, int mont)
84 { 84 {
@@ -304,42 +304,10 @@ BIGNUM *BN_new(void)
304 return(ret); 304 return(ret);
305 } 305 }
306 306
307 307/* This is an internal function that should not be used in applications.
308BN_CTX *BN_CTX_new(void) 308 * It ensures that 'b' has enough room for a 'words' word number number.
309 { 309 * It is mostly used by the various BIGNUM routines. If there is an error,
310 BN_CTX *ret; 310 * NULL is returned. If not, 'b' is returned. */
311
312 ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
313 if (ret == NULL)
314 {
315 BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
316 return(NULL);
317 }
318
319 BN_CTX_init(ret);
320 ret->flags=BN_FLG_MALLOCED;
321 return(ret);
322 }
323
324void BN_CTX_init(BN_CTX *ctx)
325 {
326 memset(ctx,0,sizeof(BN_CTX));
327 ctx->tos=0;
328 ctx->flags=0;
329 }
330
331void BN_CTX_free(BN_CTX *c)
332 {
333 int i;
334
335 if(c == NULL)
336 return;
337
338 for (i=0; i<BN_CTX_NUM; i++)
339 BN_clear_free(&(c->bn[i]));
340 if (c->flags & BN_FLG_MALLOCED)
341 Free(c);
342 }
343 311
344BIGNUM *bn_expand2(BIGNUM *b, int words) 312BIGNUM *bn_expand2(BIGNUM *b, int words)
345 { 313 {
@@ -389,7 +357,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
389 * if A and B happen to share same cache line such code is going to 357 * if A and B happen to share same cache line such code is going to
390 * cause severe cache trashing. Both factors have severe impact on 358 * cause severe cache trashing. Both factors have severe impact on
391 * performance of modern CPUs and this is the reason why this 359 * performance of modern CPUs and this is the reason why this
392 * particulare piece of code is #ifdefed away and replaced by more 360 * particular piece of code is #ifdefed away and replaced by more
393 * "friendly" version found in #else section below. This comment 361 * "friendly" version found in #else section below. This comment
394 * also applies to BN_copy function. 362 * also applies to BN_copy function.
395 * 363 *
@@ -420,7 +388,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
420 A[0]=B[0]; 388 A[0]=B[0];
421 case 0: 389 case 0:
422 /* I need the 'case 0' entry for utrix cc. 390 /* I need the 'case 0' entry for utrix cc.
423 * If the optimiser is turned on, it does the 391 * If the optimizer is turned on, it does the
424 * switch table by doing 392 * switch table by doing
425 * a=top&7 393 * a=top&7
426 * a--; 394 * a--;
diff --git a/src/lib/libssl/src/crypto/bn/bn_mont.c b/src/lib/libssl/src/crypto/bn/bn_mont.c
index ee0f410c22..7bb0b91223 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mont.c
+++ b/src/lib/libssl/src/crypto/bn/bn_mont.c
@@ -57,25 +57,27 @@
57 */ 57 */
58 58
59/* 59/*
60 * Details about Montgomery multiplication algorithms can be found at: 60 * Details about Montgomery multiplication algorithms can be found at
61 * http://www.ece.orst.edu/ISL/Publications.html 61 * http://security.ece.orst.edu/publications.html, e.g.
62 * http://www.ece.orst.edu/ISL/Koc/papers/j37acmon.pdf 62 * http://security.ece.orst.edu/koc/papers/j37acmon.pdf and
63 * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf
63 */ 64 */
64 65
65#include <stdio.h> 66#include <stdio.h>
66#include "cryptlib.h" 67#include "cryptlib.h"
67#include "bn_lcl.h" 68#include "bn_lcl.h"
68 69
69#define MONT_WORD 70#define MONT_WORD /* use the faster word-based algorithm */
70 71
71int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, 72int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
72 BN_MONT_CTX *mont, BN_CTX *ctx) 73 BN_MONT_CTX *mont, BN_CTX *ctx)
73 { 74 {
74 BIGNUM *tmp,*tmp2; 75 BIGNUM *tmp,*tmp2;
75 76
76 tmp= &(ctx->bn[ctx->tos]); 77 BN_CTX_start(ctx);
77 tmp2= &(ctx->bn[ctx->tos]); 78 tmp = BN_CTX_get(ctx);
78 ctx->tos+=2; 79 tmp2 = BN_CTX_get(ctx);
80 if (tmp == NULL || tmp2 == NULL) goto err;
79 81
80 bn_check_top(tmp); 82 bn_check_top(tmp);
81 bn_check_top(tmp2); 83 bn_check_top(tmp2);
@@ -99,7 +101,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
99 } 101 }
100 /* reduce from aRR to aR */ 102 /* reduce from aRR to aR */
101 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err; 103 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
102 ctx->tos-=2; 104 BN_CTX_end(ctx);
103 return(1); 105 return(1);
104err: 106err:
105 return(0); 107 return(0);
@@ -108,160 +110,123 @@ err:
108int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont, 110int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
109 BN_CTX *ctx) 111 BN_CTX *ctx)
110 { 112 {
111#ifdef BN_RECURSION_MONT 113 int retn=0;
112 if (mont->use_word)
113#endif
114 {
115 BIGNUM *n,*r;
116 BN_ULONG *ap,*np,*rp,n0,v,*nrp;
117 int al,nl,max,i,x,ri;
118 int retn=0;
119 114
120 r= &(ctx->bn[ctx->tos]); 115#ifdef MONT_WORD
116 BIGNUM *n,*r;
117 BN_ULONG *ap,*np,*rp,n0,v,*nrp;
118 int al,nl,max,i,x,ri;
121 119
122 if (!BN_copy(r,a)) goto err1; 120 BN_CTX_start(ctx);
123 n= &(mont->N); 121 if ((r = BN_CTX_get(ctx)) == NULL) goto err;
124 122
125 ap=a->d; 123 if (!BN_copy(r,a)) goto err;
126 /* mont->ri is the size of mont->N in bits/words */ 124 n= &(mont->N);
127 al=ri=mont->ri/BN_BITS2;
128 125
129 nl=n->top; 126 ap=a->d;
130 if ((al == 0) || (nl == 0)) { r->top=0; return(1); } 127 /* mont->ri is the size of mont->N in bits (rounded up
128 to the word size) */
129 al=ri=mont->ri/BN_BITS2;
130
131 nl=n->top;
132 if ((al == 0) || (nl == 0)) { r->top=0; return(1); }
131 133
132 max=(nl+al+1); /* allow for overflow (no?) XXX */ 134 max=(nl+al+1); /* allow for overflow (no?) XXX */
133 if (bn_wexpand(r,max) == NULL) goto err1; 135 if (bn_wexpand(r,max) == NULL) goto err;
134 if (bn_wexpand(ret,max) == NULL) goto err1; 136 if (bn_wexpand(ret,max) == NULL) goto err;
135 137
136 r->neg=a->neg^n->neg; 138 r->neg=a->neg^n->neg;
137 np=n->d; 139 np=n->d;
138 rp=r->d; 140 rp=r->d;
139 nrp= &(r->d[nl]); 141 nrp= &(r->d[nl]);
140 142
141 /* clear the top words of T */ 143 /* clear the top words of T */
142#if 1 144#if 1
143 for (i=r->top; i<max; i++) /* memset? XXX */ 145 for (i=r->top; i<max; i++) /* memset? XXX */
144 r->d[i]=0; 146 r->d[i]=0;
145#else 147#else
146 memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG)); 148 memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG));
147#endif 149#endif
148 150
149 r->top=max; 151 r->top=max;
150 n0=mont->n0; 152 n0=mont->n0;
151 153
152#ifdef BN_COUNT 154#ifdef BN_COUNT
153printf("word BN_from_montgomery %d * %d\n",nl,nl); 155 printf("word BN_from_montgomery %d * %d\n",nl,nl);
154#endif 156#endif
155 for (i=0; i<nl; i++) 157 for (i=0; i<nl; i++)
156 { 158 {
157 v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2); 159 v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
158 nrp++; 160 nrp++;
159 rp++; 161 rp++;
160 if (((nrp[-1]+=v)&BN_MASK2) >= v) 162 if (((nrp[-1]+=v)&BN_MASK2) >= v)
161 continue; 163 continue;
162 else
163 {
164 if (((++nrp[0])&BN_MASK2) != 0) continue;
165 if (((++nrp[1])&BN_MASK2) != 0) continue;
166 for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
167 }
168 }
169 bn_fix_top(r);
170
171 /* mont->ri will be a multiple of the word size */
172#if 0
173 BN_rshift(ret,r,mont->ri);
174#else
175 x=ri;
176 rp=ret->d;
177 ap= &(r->d[x]);
178 if (r->top < x)
179 al=0;
180 else 164 else
181 al=r->top-x;
182 ret->top=al;
183 al-=4;
184 for (i=0; i<al; i+=4)
185 { 165 {
186 BN_ULONG t1,t2,t3,t4; 166 if (((++nrp[0])&BN_MASK2) != 0) continue;
187 167 if (((++nrp[1])&BN_MASK2) != 0) continue;
188 t1=ap[i+0]; 168 for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
189 t2=ap[i+1];
190 t3=ap[i+2];
191 t4=ap[i+3];
192 rp[i+0]=t1;
193 rp[i+1]=t2;
194 rp[i+2]=t3;
195 rp[i+3]=t4;
196 } 169 }
197 al+=4;
198 for (; i<al; i++)
199 rp[i]=ap[i];
200#endif
201
202 if (BN_ucmp(ret, &(mont->N)) >= 0)
203 {
204 BN_usub(ret,ret,&(mont->N)); /* XXX */
205 }
206 retn=1;
207err1:
208 return(retn);
209 } 170 }
210#ifdef BN_RECURSION_MONT 171 bn_fix_top(r);
211 else /* bignum version */ 172
173 /* mont->ri will be a multiple of the word size */
174#if 0
175 BN_rshift(ret,r,mont->ri);
176#else
177 x=ri;
178 rp=ret->d;
179 ap= &(r->d[x]);
180 if (r->top < x)
181 al=0;
182 else
183 al=r->top-x;
184 ret->top=al;
185 al-=4;
186 for (i=0; i<al; i+=4)
212 { 187 {
213 BIGNUM *t1,*t2,*t3; 188 BN_ULONG t1,t2,t3,t4;
214 int j,i; 189
215 190 t1=ap[i+0];
216#ifdef BN_COUNT 191 t2=ap[i+1];
217printf("number BN_from_montgomery\n"); 192 t3=ap[i+2];
218#endif 193 t4=ap[i+3];
219 194 rp[i+0]=t1;
220 t1= &(ctx->bn[ctx->tos]); 195 rp[i+1]=t2;
221 t2= &(ctx->bn[ctx->tos+1]); 196 rp[i+2]=t3;
222 t3= &(ctx->bn[ctx->tos+2]); 197 rp[i+3]=t4;
223
224 i=mont->Ni.top;
225 bn_wexpand(ret,i); /* perhaps only i*2 */
226 bn_wexpand(t1,i*4); /* perhaps only i*2 */
227 bn_wexpand(t2,i*2); /* perhaps only i */
228
229 bn_mul_low_recursive(t2->d,a->d,mont->Ni.d,i,t1->d);
230
231 BN_zero(t3);
232 BN_set_bit(t3,mont->N.top*BN_BITS2);
233 bn_sub_words(t3->d,t3->d,a->d,i);
234 bn_mul_high(ret->d,t2->d,mont->N.d,t3->d,i,t1->d);
235
236 /* hmm... if a is between i and 2*i, things are bad */
237 if (a->top > i)
238 {
239 j=(int)(bn_add_words(ret->d,ret->d,&(a->d[i]),i));
240 if (j) /* overflow */
241 bn_sub_words(ret->d,ret->d,mont->N.d,i);
242 }
243 ret->top=i;
244 bn_fix_top(ret);
245 if (a->d[0])
246 BN_add_word(ret,1); /* Always? */
247 else /* Very very rare */
248 {
249 for (i=1; i<mont->N.top-1; i++)
250 {
251 if (a->d[i])
252 {
253 BN_add_word(ret,1); /* Always? */
254 break;
255 }
256 }
257 }
258
259 if (BN_ucmp(ret,&(mont->N)) >= 0)
260 BN_usub(ret,ret,&(mont->N));
261
262 return(1);
263 } 198 }
199 al+=4;
200 for (; i<al; i++)
201 rp[i]=ap[i];
264#endif 202#endif
203#else /* !MONT_WORD */
204 BIGNUM *t1,*t2;
205
206 BN_CTX_start(ctx);
207 t1 = BN_CTX_get(ctx);
208 t2 = BN_CTX_get(ctx);
209 if (t1 == NULL || t2 == NULL) goto err;
210
211 if (!BN_copy(t1,a)) goto err;
212 BN_mask_bits(t1,mont->ri);
213
214 if (!BN_mul(t2,t1,&mont->Ni,ctx)) goto err;
215 BN_mask_bits(t2,mont->ri);
216
217 if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
218 if (!BN_add(t2,a,t1)) goto err;
219 BN_rshift(ret,t2,mont->ri);
220#endif /* MONT_WORD */
221
222 if (BN_ucmp(ret, &(mont->N)) >= 0)
223 {
224 BN_usub(ret,ret,&(mont->N));
225 }
226 retn=1;
227 err:
228 BN_CTX_end(ctx);
229 return(retn);
265 } 230 }
266 231
267BN_MONT_CTX *BN_MONT_CTX_new(void) 232BN_MONT_CTX *BN_MONT_CTX_new(void)
@@ -278,7 +243,6 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
278 243
279void BN_MONT_CTX_init(BN_MONT_CTX *ctx) 244void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
280 { 245 {
281 ctx->use_word=0;
282 ctx->ri=0; 246 ctx->ri=0;
283 BN_init(&(ctx->RR)); 247 BN_init(&(ctx->RR));
284 BN_init(&(ctx->N)); 248 BN_init(&(ctx->N));
@@ -306,85 +270,53 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
306 R= &(mont->RR); /* grab RR as a temp */ 270 R= &(mont->RR); /* grab RR as a temp */
307 BN_copy(&(mont->N),mod); /* Set N */ 271 BN_copy(&(mont->N),mod); /* Set N */
308 272
309#ifdef BN_RECURSION_MONT 273#ifdef MONT_WORD
310 if (mont->N.top < BN_MONT_CTX_SET_SIZE_WORD)
311#endif
312 { 274 {
313 BIGNUM tmod; 275 BIGNUM tmod;
314 BN_ULONG buf[2]; 276 BN_ULONG buf[2];
315 277
316 mont->use_word=1;
317
318 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2; 278 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
319 BN_zero(R); 279 BN_zero(R);
320 BN_set_bit(R,BN_BITS2); 280 BN_set_bit(R,BN_BITS2); /* R */
321 /* I was bad, this modification of a passed variable was
322 * breaking the multithreaded stuff :-(
323 * z=mod->top;
324 * mod->top=1; */
325 281
326 buf[0]=mod->d[0]; 282 buf[0]=mod->d[0]; /* tmod = N mod word size */
327 buf[1]=0; 283 buf[1]=0;
328 tmod.d=buf; 284 tmod.d=buf;
329 tmod.top=1; 285 tmod.top=1;
330 tmod.max=mod->max; 286 tmod.max=2;
331 tmod.neg=mod->neg; 287 tmod.neg=mod->neg;
332 288 /* Ri = R^-1 mod N*/
333 if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL) 289 if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)
334 goto err; 290 goto err;
335 BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */ 291 BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */
336 if (!BN_is_zero(&Ri)) 292 if (!BN_is_zero(&Ri))
337 {
338#if 1
339 BN_sub_word(&Ri,1); 293 BN_sub_word(&Ri,1);
340#else 294 else /* if N mod word size == 1 */
341 BN_usub(&Ri,&Ri,BN_value_one()); /* R*Ri - 1 */ 295 BN_set_word(&Ri,BN_MASK2); /* Ri-- (mod word size) */
342#endif 296 BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N,
343 } 297 * keep only least significant word: */
344 else
345 {
346 /* This is not common..., 1 in BN_MASK2,
347 * It happens when buf[0] was == 1. So for 8 bit,
348 * this is 1/256, 16bit, 1 in 2^16 etc.
349 */
350 BN_set_word(&Ri,BN_MASK2);
351 }
352 BN_div(&Ri,NULL,&Ri,&tmod,ctx);
353 mont->n0=Ri.d[0]; 298 mont->n0=Ri.d[0];
354 BN_free(&Ri); 299 BN_free(&Ri);
355 /* mod->top=z; */
356 } 300 }
357#ifdef BN_RECURSION_MONT 301#else /* !MONT_WORD */
358 else 302 { /* bignum version */
359 { 303 mont->ri=BN_num_bits(mod);
360 mont->use_word=0;
361 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
362#if 1
363 BN_zero(R); 304 BN_zero(R);
364 BN_set_bit(R,mont->ri); 305 BN_set_bit(R,mont->ri); /* R = 2^ri */
365#else 306 /* Ri = R^-1 mod N*/
366 BN_lshift(R,BN_value_one(),mont->ri); /* R */
367#endif
368 if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL) 307 if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL)
369 goto err; 308 goto err;
370 BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */ 309 BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */
371#if 1
372 BN_sub_word(&Ri,1); 310 BN_sub_word(&Ri,1);
373#else 311 /* Ni = (R*Ri-1) / N */
374 BN_usub(&Ri,&Ri,BN_value_one()); /* R*Ri - 1 */
375#endif
376 BN_div(&(mont->Ni),NULL,&Ri,mod,ctx); 312 BN_div(&(mont->Ni),NULL,&Ri,mod,ctx);
377 BN_free(&Ri); 313 BN_free(&Ri);
378 } 314 }
379#endif 315#endif
380 316
381 /* setup RR for conversions */ 317 /* setup RR for conversions */
382#if 1
383 BN_zero(&(mont->RR)); 318 BN_zero(&(mont->RR));
384 BN_set_bit(&(mont->RR),mont->ri*2); 319 BN_set_bit(&(mont->RR),mont->ri*2);
385#else
386 BN_lshift(mont->RR,BN_value_one(),mont->ri*2);
387#endif
388 BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx); 320 BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx);
389 321
390 return(1); 322 return(1);
@@ -399,7 +331,6 @@ BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
399 BN_copy(&(to->RR),&(from->RR)); 331 BN_copy(&(to->RR),&(from->RR));
400 BN_copy(&(to->N),&(from->N)); 332 BN_copy(&(to->N),&(from->N));
401 BN_copy(&(to->Ni),&(from->Ni)); 333 BN_copy(&(to->Ni),&(from->Ni));
402 to->use_word=from->use_word;
403 to->ri=from->ri; 334 to->ri=from->ri;
404 to->n0=from->n0; 335 to->n0=from->n0;
405 return(to); 336 return(to);
diff --git a/src/lib/libssl/src/crypto/bn/bn_mul.c b/src/lib/libssl/src/crypto/bn/bn_mul.c
index 38c47f3d1f..eb007e19e9 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mul.c
+++ b/src/lib/libssl/src/crypto/bn/bn_mul.c
@@ -66,7 +66,7 @@
66 * n2 must be a power of 2. 66 * n2 must be a power of 2.
67 * We multiply and return the result. 67 * We multiply and return the result.
68 * t must be 2*n2 words in size 68 * t must be 2*n2 words in size
69 * We calulate 69 * We calculate
70 * a[0]*b[0] 70 * a[0]*b[0]
71 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) 71 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
72 * a[1]*b[1] 72 * a[1]*b[1]
@@ -78,21 +78,23 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
78 unsigned int neg,zero; 78 unsigned int neg,zero;
79 BN_ULONG ln,lo,*p; 79 BN_ULONG ln,lo,*p;
80 80
81#ifdef BN_COUNT 81# ifdef BN_COUNT
82printf(" bn_mul_recursive %d * %d\n",n2,n2); 82 printf(" bn_mul_recursive %d * %d\n",n2,n2);
83#endif 83# endif
84#ifdef BN_MUL_COMBA 84# ifdef BN_MUL_COMBA
85/* if (n2 == 4) 85# if 0
86 if (n2 == 4)
86 { 87 {
87 bn_mul_comba4(r,a,b); 88 bn_mul_comba4(r,a,b);
88 return; 89 return;
89 } 90 }
90 else */ if (n2 == 8) 91# endif
92 if (n2 == 8)
91 { 93 {
92 bn_mul_comba8(r,a,b); 94 bn_mul_comba8(r,a,b);
93 return; 95 return;
94 } 96 }
95#endif 97# endif /* BN_MUL_COMBA */
96 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) 98 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
97 { 99 {
98 /* This should not happen */ 100 /* This should not happen */
@@ -136,7 +138,7 @@ printf(" bn_mul_recursive %d * %d\n",n2,n2);
136 break; 138 break;
137 } 139 }
138 140
139#ifdef BN_MUL_COMBA 141# ifdef BN_MUL_COMBA
140 if (n == 4) 142 if (n == 4)
141 { 143 {
142 if (!zero) 144 if (!zero)
@@ -158,7 +160,7 @@ printf(" bn_mul_recursive %d * %d\n",n2,n2);
158 bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n])); 160 bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n]));
159 } 161 }
160 else 162 else
161#endif 163# endif /* BN_MUL_COMBA */
162 { 164 {
163 p= &(t[n2*2]); 165 p= &(t[n2*2]);
164 if (!zero) 166 if (!zero)
@@ -219,12 +221,12 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
219 int n, BN_ULONG *t) 221 int n, BN_ULONG *t)
220 { 222 {
221 int i,j,n2=n*2; 223 int i,j,n2=n*2;
222 unsigned int c1; 224 unsigned int c1,c2,neg,zero;
223 BN_ULONG ln,lo,*p; 225 BN_ULONG ln,lo,*p;
224 226
225#ifdef BN_COUNT 227# ifdef BN_COUNT
226printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); 228 printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
227#endif 229# endif
228 if (n < 8) 230 if (n < 8)
229 { 231 {
230 i=tn+n; 232 i=tn+n;
@@ -233,17 +235,54 @@ printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
233 } 235 }
234 236
235 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 237 /* r=(a[0]-a[1])*(b[1]-b[0]) */
236 bn_sub_words(t, a, &(a[n]),n); /* + */ 238 c1=bn_cmp_words(a,&(a[n]),n);
237 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 239 c2=bn_cmp_words(&(b[n]),b,n);
238 240 zero=neg=0;
239/* if (n == 4) 241 switch (c1*3+c2)
242 {
243 case -4:
244 bn_sub_words(t, &(a[n]),a, n); /* - */
245 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
246 break;
247 case -3:
248 zero=1;
249 /* break; */
250 case -2:
251 bn_sub_words(t, &(a[n]),a, n); /* - */
252 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */
253 neg=1;
254 break;
255 case -1:
256 case 0:
257 case 1:
258 zero=1;
259 /* break; */
260 case 2:
261 bn_sub_words(t, a, &(a[n]),n); /* + */
262 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
263 neg=1;
264 break;
265 case 3:
266 zero=1;
267 /* break; */
268 case 4:
269 bn_sub_words(t, a, &(a[n]),n);
270 bn_sub_words(&(t[n]),&(b[n]),b, n);
271 break;
272 }
273 /* The zero case isn't yet implemented here. The speedup
274 would probably be negligible. */
275# if 0
276 if (n == 4)
240 { 277 {
241 bn_mul_comba4(&(t[n2]),t,&(t[n])); 278 bn_mul_comba4(&(t[n2]),t,&(t[n]));
242 bn_mul_comba4(r,a,b); 279 bn_mul_comba4(r,a,b);
243 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); 280 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
244 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2)); 281 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2));
245 } 282 }
246 else */ if (n == 8) 283 else
284# endif
285 if (n == 8)
247 { 286 {
248 bn_mul_comba8(&(t[n2]),t,&(t[n])); 287 bn_mul_comba8(&(t[n2]),t,&(t[n]));
249 bn_mul_comba8(r,a,b); 288 bn_mul_comba8(r,a,b);
@@ -308,7 +347,16 @@ printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
308 */ 347 */
309 348
310 c1=(int)(bn_add_words(t,r,&(r[n2]),n2)); 349 c1=(int)(bn_add_words(t,r,&(r[n2]),n2));
311 c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2)); 350
351 if (neg) /* if t[32] is negative */
352 {
353 c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2));
354 }
355 else
356 {
357 /* Might have a carry */
358 c1+=(int)(bn_add_words(&(t[n2]),&(t[n2]),t,n2));
359 }
312 360
313 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1]) 361 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
314 * r[10] holds (a[0]*b[0]) 362 * r[10] holds (a[0]*b[0])
@@ -345,9 +393,9 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
345 { 393 {
346 int n=n2/2; 394 int n=n2/2;
347 395
348#ifdef BN_COUNT 396# ifdef BN_COUNT
349printf(" bn_mul_low_recursive %d * %d\n",n2,n2); 397 printf(" bn_mul_low_recursive %d * %d\n",n2,n2);
350#endif 398# endif
351 399
352 bn_mul_recursive(r,a,b,n,&(t[0])); 400 bn_mul_recursive(r,a,b,n,&(t[0]));
353 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) 401 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
@@ -379,9 +427,9 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
379 int neg,oneg,zero; 427 int neg,oneg,zero;
380 BN_ULONG ll,lc,*lp,*mp; 428 BN_ULONG ll,lc,*lp,*mp;
381 429
382#ifdef BN_COUNT 430# ifdef BN_COUNT
383printf(" bn_mul_high %d * %d\n",n2,n2); 431 printf(" bn_mul_high %d * %d\n",n2,n2);
384#endif 432# endif
385 n=n2/2; 433 n=n2/2;
386 434
387 /* Calculate (al-ah)*(bh-bl) */ 435 /* Calculate (al-ah)*(bh-bl) */
@@ -424,14 +472,14 @@ printf(" bn_mul_high %d * %d\n",n2,n2);
424 oneg=neg; 472 oneg=neg;
425 /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */ 473 /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */
426 /* r[10] = (a[1]*b[1]) */ 474 /* r[10] = (a[1]*b[1]) */
427#ifdef BN_MUL_COMBA 475# ifdef BN_MUL_COMBA
428 if (n == 8) 476 if (n == 8)
429 { 477 {
430 bn_mul_comba8(&(t[0]),&(r[0]),&(r[n])); 478 bn_mul_comba8(&(t[0]),&(r[0]),&(r[n]));
431 bn_mul_comba8(r,&(a[n]),&(b[n])); 479 bn_mul_comba8(r,&(a[n]),&(b[n]));
432 } 480 }
433 else 481 else
434#endif 482# endif
435 { 483 {
436 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2])); 484 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2]));
437 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2])); 485 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2]));
@@ -555,19 +603,23 @@ printf(" bn_mul_high %d * %d\n",n2,n2);
555 } 603 }
556 } 604 }
557 } 605 }
558#endif 606#endif /* BN_RECURSION */
559 607
560int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) 608int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
561 { 609 {
562 int top,al,bl; 610 int top,al,bl;
563 BIGNUM *rr; 611 BIGNUM *rr;
612 int ret = 0;
613#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
614 int i;
615#endif
564#ifdef BN_RECURSION 616#ifdef BN_RECURSION
565 BIGNUM *t; 617 BIGNUM *t;
566 int i,j,k; 618 int j,k;
567#endif 619#endif
568 620
569#ifdef BN_COUNT 621#ifdef BN_COUNT
570printf("BN_mul %d * %d\n",a->top,b->top); 622 printf("BN_mul %d * %d\n",a->top,b->top);
571#endif 623#endif
572 624
573 bn_check_top(a); 625 bn_check_top(a);
@@ -585,115 +637,99 @@ printf("BN_mul %d * %d\n",a->top,b->top);
585 } 637 }
586 top=al+bl; 638 top=al+bl;
587 639
640 BN_CTX_start(ctx);
588 if ((r == a) || (r == b)) 641 if ((r == a) || (r == b))
589 rr= &(ctx->bn[ctx->tos+1]); 642 {
643 if ((rr = BN_CTX_get(ctx)) == NULL) goto err;
644 }
590 else 645 else
591 rr=r; 646 rr = r;
592 647
593#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 648#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
594 if (al == bl) 649 i = al-bl;
650#endif
651#ifdef BN_MUL_COMBA
652 if (i == 0)
595 { 653 {
596# ifdef BN_MUL_COMBA 654# if 0
597/* if (al == 4) 655 if (al == 4)
598 { 656 {
599 if (bn_wexpand(rr,8) == NULL) return(0); 657 if (bn_wexpand(rr,8) == NULL) goto err;
600 rr->top=8; 658 rr->top=8;
601 bn_mul_comba4(rr->d,a->d,b->d); 659 bn_mul_comba4(rr->d,a->d,b->d);
602 goto end; 660 goto end;
603 } 661 }
604 else */ if (al == 8) 662# endif
663 if (al == 8)
605 { 664 {
606 if (bn_wexpand(rr,16) == NULL) return(0); 665 if (bn_wexpand(rr,16) == NULL) goto err;
607 rr->top=16; 666 rr->top=16;
608 bn_mul_comba8(rr->d,a->d,b->d); 667 bn_mul_comba8(rr->d,a->d,b->d);
609 goto end; 668 goto end;
610 } 669 }
611 else
612# endif
613#ifdef BN_RECURSION
614 if (al < BN_MULL_SIZE_NORMAL)
615#endif
616 {
617 if (bn_wexpand(rr,top) == NULL) return(0);
618 rr->top=top;
619 bn_mul_normal(rr->d,a->d,al,b->d,bl);
620 goto end;
621 }
622# ifdef BN_RECURSION
623 goto symetric;
624# endif
625 } 670 }
626#endif 671#endif /* BN_MUL_COMBA */
627#ifdef BN_RECURSION 672#ifdef BN_RECURSION
628 else if ((al < BN_MULL_SIZE_NORMAL) || (bl < BN_MULL_SIZE_NORMAL)) 673 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))
629 { 674 {
630 if (bn_wexpand(rr,top) == NULL) return(0); 675 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
631 rr->top=top;
632 bn_mul_normal(rr->d,a->d,al,b->d,bl);
633 goto end;
634 }
635 else
636 {
637 i=(al-bl);
638 if ((i == 1) && !BN_get_flags(b,BN_FLG_STATIC_DATA))
639 { 676 {
640 bn_wexpand(b,al); 677 bn_wexpand(b,al);
641 b->d[bl]=0; 678 b->d[bl]=0;
642 bl++; 679 bl++;
643 goto symetric; 680 i--;
644 } 681 }
645 else if ((i == -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA)) 682 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))
646 { 683 {
647 bn_wexpand(a,bl); 684 bn_wexpand(a,bl);
648 a->d[al]=0; 685 a->d[al]=0;
649 al++; 686 al++;
650 goto symetric; 687 i++;
688 }
689 if (i == 0)
690 {
691 /* symmetric and > 4 */
692 /* 16 or larger */
693 j=BN_num_bits_word((BN_ULONG)al);
694 j=1<<(j-1);
695 k=j+j;
696 t = BN_CTX_get(ctx);
697 if (al == j) /* exact multiple */
698 {
699 bn_wexpand(t,k*2);
700 bn_wexpand(rr,k*2);
701 bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
702 }
703 else
704 {
705 bn_wexpand(a,k);
706 bn_wexpand(b,k);
707 bn_wexpand(t,k*4);
708 bn_wexpand(rr,k*4);
709 for (i=a->top; i<k; i++)
710 a->d[i]=0;
711 for (i=b->top; i<k; i++)
712 b->d[i]=0;
713 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
714 }
715 rr->top=top;
716 goto end;
651 } 717 }
652 } 718 }
653#endif 719#endif /* BN_RECURSION */
654 720 if (bn_wexpand(rr,top) == NULL) goto err;
655 /* asymetric and >= 4 */
656 if (bn_wexpand(rr,top) == NULL) return(0);
657 rr->top=top; 721 rr->top=top;
658 bn_mul_normal(rr->d,a->d,al,b->d,bl); 722 bn_mul_normal(rr->d,a->d,al,b->d,bl);
659 723
660#ifdef BN_RECURSION
661 if (0)
662 {
663symetric:
664 /* symetric and > 4 */
665 /* 16 or larger */
666 j=BN_num_bits_word((BN_ULONG)al);
667 j=1<<(j-1);
668 k=j+j;
669 t= &(ctx->bn[ctx->tos]);
670 if (al == j) /* exact multiple */
671 {
672 bn_wexpand(t,k*2);
673 bn_wexpand(rr,k*2);
674 bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
675 }
676 else
677 {
678 bn_wexpand(a,k);
679 bn_wexpand(b,k);
680 bn_wexpand(t,k*4);
681 bn_wexpand(rr,k*4);
682 for (i=a->top; i<k; i++)
683 a->d[i]=0;
684 for (i=b->top; i<k; i++)
685 b->d[i]=0;
686 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
687 }
688 rr->top=top;
689 }
690#endif
691#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 724#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
692end: 725end:
693#endif 726#endif
694 bn_fix_top(rr); 727 bn_fix_top(rr);
695 if (r != rr) BN_copy(r,rr); 728 if (r != rr) BN_copy(r,rr);
696 return(1); 729 ret=1;
730err:
731 BN_CTX_end(ctx);
732 return(ret);
697 } 733 }
698 734
699void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) 735void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
@@ -701,7 +737,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
701 BN_ULONG *rr; 737 BN_ULONG *rr;
702 738
703#ifdef BN_COUNT 739#ifdef BN_COUNT
704printf(" bn_mul_normal %d * %d\n",na,nb); 740 printf(" bn_mul_normal %d * %d\n",na,nb);
705#endif 741#endif
706 742
707 if (na < nb) 743 if (na < nb)
@@ -735,7 +771,7 @@ printf(" bn_mul_normal %d * %d\n",na,nb);
735void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 771void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
736 { 772 {
737#ifdef BN_COUNT 773#ifdef BN_COUNT
738printf(" bn_mul_low_normal %d * %d\n",n,n); 774 printf(" bn_mul_low_normal %d * %d\n",n,n);
739#endif 775#endif
740 bn_mul_words(r,a,n,b[0]); 776 bn_mul_words(r,a,n,b[0]);
741 777
@@ -753,4 +789,3 @@ printf(" bn_mul_low_normal %d * %d\n",n,n);
753 b+=4; 789 b+=4;
754 } 790 }
755 } 791 }
756
diff --git a/src/lib/libssl/src/crypto/bn/bn_opts.c b/src/lib/libssl/src/crypto/bn/bn_opts.c
index 381be529b2..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/bn_opts.c
+++ b/src/lib/libssl/src/crypto/bn/bn_opts.c
@@ -1,324 +0,0 @@
1/* crypto/bn/expspeed.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/* most of this code has been pilfered from my libdes speed.c program */
60
61#include <stdio.h>
62#include <stdlib.h>
63#include <signal.h>
64#include <string.h>
65#include <openssl/crypto.h>
66#include <openssl/tmdiff.h>
67#include <openssl/bn.h>
68#include <openssl/err.h>
69
70#define DEFAULT_SIZE 512
71#define DEFAULT_TIME 3
72
73int verbose=1;
74
75typedef struct parms_st
76 {
77 char *name;
78 void (*func)();
79 BIGNUM r;
80 BIGNUM a;
81 BIGNUM b;
82 BIGNUM c;
83 BIGNUM low;
84 BN_CTX *ctx;
85 BN_MONT_CTX *mont;
86 int w;
87 } PARMS;
88
89void do_mul_exp(int num,PARMS *p);
90void do_mul(int num,PARMS *p);
91void do_sqr(int num,PARMS *p);
92void do_mul_low(int num,PARMS *p);
93void do_mul_high(int num,PARMS *p);
94void do_from_montgomery(int num,PARMS *p);
95int time_it(int sec, PARMS *p);
96void do_it(int sec, PARMS *p);
97
98#define P_EXP 1
99#define P_MUL 2
100#define P_SQR 3
101#define P_MULL 4
102#define P_MULH 5
103#define P_MRED 6
104
105int main(int argc, char **argv)
106 {
107 PARMS p;
108 BN_MONT_CTX *mont;
109 int size=0,num;
110 char *name;
111 int type=P_EXP;
112
113 mont=BN_MONT_CTX_new();
114 p.mont=NULL;
115 p.ctx=BN_CTX_new();
116 BN_init(&p.r);
117 BN_init(&p.a);
118 BN_init(&p.b);
119 BN_init(&p.c);
120 BN_init(&p.low);
121 p.w=0;
122
123 for (;;)
124 {
125 if (argc > 1)
126 {
127 if (argv[1][0] == '-')
128 {
129 switch(argv[1][1])
130 {
131 case 'e': type=P_EXP; break;
132 case 'm': type=P_MUL; break;
133 case 's': type=P_SQR; break;
134 case 'l': type=P_MULL; break;
135 case 'h': type=P_MULH; break;
136 case 'r': type=P_MRED; break;
137 default:
138 fprintf(stderr,"options: -[emslhr]\n");
139 exit(1);
140 }
141 }
142 else
143 {
144 size=atoi(argv[1]);
145 }
146 argc--;
147 argv++;
148 }
149 else
150 break;
151 }
152 if (size == 0)
153 size=DEFAULT_SIZE;
154
155 printf("bit size:%5d\n",size);
156
157 BN_rand(&p.a,size,1,0);
158 BN_rand(&p.b,size,1,0);
159 BN_rand(&p.c,size,1,1);
160 BN_mod(&p.a,&p.a,&p.c,p.ctx);
161 BN_mod(&p.b,&p.b,&p.c,p.ctx);
162 p.w=(p.a.top+1)/2;
163
164 BN_mul(&p.low,&p.a,&p.b,p.ctx);
165 p.low.top=p.a.top;
166
167 switch(type)
168 {
169 case P_EXP:
170 p.name="r=a^b%c";
171 p.func=do_mul_exp;
172 p.mont=mont;
173 break;
174 case P_MUL:
175 p.name="r=a*b";
176 p.func=do_mul;
177 break;
178 case P_SQR:
179 p.name="r=a*a";
180 p.func=do_sqr;
181 break;
182 case P_MULL:
183 p.name="r=low(a*b)";
184 p.func=do_mul_low;
185 break;
186 case P_MULH:
187 p.name="r=high(a*b)";
188 p.func=do_mul_high;
189 break;
190 case P_MRED:
191 p.name="r=montgomery_reduction(a)";
192 p.func=do_from_montgomery;
193 p.mont=mont;
194 break;
195 default:
196 fprintf(stderr,"options: -[emslhr]\n");
197 exit(1);
198 }
199
200 num=time_it(DEFAULT_TIME,&p);
201 do_it(num,&p);
202 }
203
204void do_it(int num, PARMS *p)
205 {
206 char *start,*end;
207 int i,j,number;
208 double d;
209
210 start=ms_time_new();
211 end=ms_time_new();
212
213 number=BN_num_bits_word((BN_ULONG)BN_num_bits(&(p->c)))-
214 BN_num_bits_word(BN_BITS2)+2;
215 for (i=number-1; i >=0; i--)
216 {
217 if (i == 1) continue;
218 BN_set_params(i,i,i,1);
219 if (p->mont != NULL)
220 BN_MONT_CTX_set(p->mont,&(p->c),p->ctx);
221
222 printf("Timing %5d (%2d bit) %2d %2d %2d %2d :",
223 (1<<i)*BN_BITS2,i,
224 BN_get_params(0),
225 BN_get_params(1),
226 BN_get_params(2),
227 BN_get_params(3));
228 fflush(stdout);
229
230 ms_time_get(start);
231 p->func(num,p);
232 ms_time_get(end);
233 d=ms_time_diff(start,end);
234 printf("%6.6f sec, or %d in %.4f seconds\n",
235 (double)d/num,num,d);
236 }
237 }
238
239int time_it(int sec, PARMS *p)
240 {
241 char *start,*end;
242 int i,j;
243 double d;
244
245 if (p->mont != NULL)
246 BN_MONT_CTX_set(p->mont,&(p->c),p->ctx);
247
248 start=ms_time_new();
249 end=ms_time_new();
250
251 i=1;
252 for (;;)
253 {
254 if (verbose)
255 printf("timing %s for %d interations\n",p->name,i);
256
257 ms_time_get(start);
258 p->func(i,p);
259 ms_time_get(end);
260 d=ms_time_diff(start,end);
261
262 if (d < 0.01) i*=100;
263 else if (d < 0.1 ) i*=10;
264 else if (d > (double)sec) break;
265 else
266 {
267 i=(int)(1.0*i*sec/d);
268 break;
269 }
270 }
271 if (verbose)
272 printf("using %d interations\n",i);
273 return(i);
274 }
275
276void do_mul_exp(int num, PARMS *p)
277 {
278 int i;
279
280 for (i=0; i<num; i++)
281 BN_mod_exp_mont(&(p->r),&(p->a),&(p->b),&(p->c),
282 p->ctx,p->mont);
283 }
284
285void do_mul(int num, PARMS *p)
286 {
287 int i;
288
289 for (i=0; i<num; i++)
290 BN_mul(&(p->r),&(p->a),&(p->b),p->ctx);
291 }
292
293void do_sqr(int num, PARMS *p)
294 {
295 int i;
296
297 for (i=0; i<num; i++)
298 BN_sqr(&(p->r),&(p->a),p->ctx);
299 }
300
301void do_mul_low(int num, PARMS *p)
302 {
303 int i;
304
305 for (i=0; i<num; i++)
306 BN_mul_low(&(p->r),&(p->a),&(p->b),p->w,p->ctx);
307 }
308
309void do_mul_high(int num, PARMS *p)
310 {
311 int i;
312
313 for (i=0; i<num; i++)
314 BN_mul_low(&(p->r),&(p->a),&(p->b),&(p->low),p->w,p->ctx);
315 }
316
317void do_from_montgomery(int num, PARMS *p)
318 {
319 int i;
320
321 for (i=0; i<num; i++)
322 BN_from_montgomery(&(p->r),&(p->a),p->mont,p->ctx);
323 }
324
diff --git a/src/lib/libssl/src/crypto/bn/bn_prime.c b/src/lib/libssl/src/crypto/bn/bn_prime.c
index 6fa0f9be1e..a5f01b92eb 100644
--- a/src/lib/libssl/src/crypto/bn/bn_prime.c
+++ b/src/lib/libssl/src/crypto/bn/bn_prime.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-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 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <time.h> 113#include <time.h>
@@ -62,26 +115,29 @@
62#include "bn_lcl.h" 115#include "bn_lcl.h"
63#include <openssl/rand.h> 116#include <openssl/rand.h>
64 117
65/* The quick seive algorithm approach to weeding out primes is 118/* The quick sieve algorithm approach to weeding out primes is
66 * Philip Zimmermann's, as implemented in PGP. I have had a read of 119 * Philip Zimmermann's, as implemented in PGP. I have had a read of
67 * his comments and implemented my own version. 120 * his comments and implemented my own version.
68 */ 121 */
69#include "bn_prime.h" 122#include "bn_prime.h"
70 123
71static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx,BN_CTX *ctx2, 124static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
72 BN_MONT_CTX *mont); 125 const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont);
73static int probable_prime(BIGNUM *rnd, int bits); 126static int probable_prime(BIGNUM *rnd, int bits);
74static int probable_prime_dh(BIGNUM *rnd, int bits, 127static int probable_prime_dh(BIGNUM *rnd, int bits,
75 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); 128 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx);
76static int probable_prime_dh_strong(BIGNUM *rnd, int bits, 129static int probable_prime_dh_safe(BIGNUM *rnd, int bits,
77 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); 130 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx);
78BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int strong, BIGNUM *add, 131
132BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, BIGNUM *add,
79 BIGNUM *rem, void (*callback)(int,int,void *), void *cb_arg) 133 BIGNUM *rem, void (*callback)(int,int,void *), void *cb_arg)
80 { 134 {
81 BIGNUM *rnd=NULL; 135 BIGNUM *rnd=NULL;
82 BIGNUM t; 136 BIGNUM t;
137 int found=0;
83 int i,j,c1=0; 138 int i,j,c1=0;
84 BN_CTX *ctx; 139 BN_CTX *ctx;
140 int checks = BN_prime_checks_for_size(bits);
85 141
86 ctx=BN_CTX_new(); 142 ctx=BN_CTX_new();
87 if (ctx == NULL) goto err; 143 if (ctx == NULL) goto err;
@@ -100,9 +156,9 @@ loop:
100 } 156 }
101 else 157 else
102 { 158 {
103 if (strong) 159 if (safe)
104 { 160 {
105 if (!probable_prime_dh_strong(rnd,bits,add,rem,ctx)) 161 if (!probable_prime_dh_safe(rnd,bits,add,rem,ctx))
106 goto err; 162 goto err;
107 } 163 }
108 else 164 else
@@ -114,160 +170,185 @@ loop:
114 /* if (BN_mod_word(rnd,(BN_ULONG)3) == 1) goto loop; */ 170 /* if (BN_mod_word(rnd,(BN_ULONG)3) == 1) goto loop; */
115 if (callback != NULL) callback(0,c1++,cb_arg); 171 if (callback != NULL) callback(0,c1++,cb_arg);
116 172
117 if (!strong) 173 if (!safe)
118 { 174 {
119 i=BN_is_prime(rnd,BN_prime_checks,callback,ctx,cb_arg); 175 i=BN_is_prime_fasttest(rnd,checks,callback,ctx,cb_arg,0);
120 if (i == -1) goto err; 176 if (i == -1) goto err;
121 if (i == 0) goto loop; 177 if (i == 0) goto loop;
122 } 178 }
123 else 179 else
124 { 180 {
125 /* for a strong prime generation, 181 /* for "safe prime" generation,
126 * check that (p-1)/2 is prime. 182 * check that (p-1)/2 is prime.
127 * Since a prime is odd, We just 183 * Since a prime is odd, We just
128 * need to divide by 2 */ 184 * need to divide by 2 */
129 if (!BN_rshift1(&t,rnd)) goto err; 185 if (!BN_rshift1(&t,rnd)) goto err;
130 186
131 for (i=0; i<BN_prime_checks; i++) 187 for (i=0; i<checks; i++)
132 { 188 {
133 j=BN_is_prime(rnd,1,callback,ctx,cb_arg); 189 j=BN_is_prime_fasttest(rnd,1,callback,ctx,cb_arg,0);
134 if (j == -1) goto err; 190 if (j == -1) goto err;
135 if (j == 0) goto loop; 191 if (j == 0) goto loop;
136 192
137 j=BN_is_prime(&t,1,callback,ctx,cb_arg); 193 j=BN_is_prime_fasttest(&t,1,callback,ctx,cb_arg,0);
138 if (j == -1) goto err; 194 if (j == -1) goto err;
139 if (j == 0) goto loop; 195 if (j == 0) goto loop;
140 196
141 if (callback != NULL) callback(2,c1-1,cb_arg); 197 if (callback != NULL) callback(2,c1-1,cb_arg);
142 /* We have a strong prime test pass */ 198 /* We have a safe prime test pass */
143 } 199 }
144 } 200 }
145 /* we have a prime :-) */ 201 /* we have a prime :-) */
146 ret=rnd; 202 found = 1;
147err: 203err:
148 if ((ret == NULL) && (rnd != NULL)) BN_free(rnd); 204 if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd);
149 BN_free(&t); 205 BN_free(&t);
150 if (ctx != NULL) BN_CTX_free(ctx); 206 if (ctx != NULL) BN_CTX_free(ctx);
151 return(ret); 207 return(found ? rnd : NULL);
152 } 208 }
153 209
154int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *), 210int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
155 BN_CTX *ctx_passed, void *cb_arg) 211 BN_CTX *ctx_passed, void *cb_arg)
156 { 212 {
157 int i,j,c2=0,ret= -1; 213 return BN_is_prime_fasttest(a, checks, callback, ctx_passed, cb_arg, 0);
158 BIGNUM *check; 214 }
159 BN_CTX *ctx=NULL,*ctx2=NULL;
160 BN_MONT_CTX *mont=NULL;
161 215
216int BN_is_prime_fasttest(const BIGNUM *a, int checks,
217 void (*callback)(int,int,void *),
218 BN_CTX *ctx_passed, void *cb_arg,
219 int do_trial_division)
220 {
221 int i, j, ret = -1;
222 int k;
223 BN_CTX *ctx = NULL;
224 BIGNUM *A1, *A1_odd, *check; /* taken from ctx */
225 BN_MONT_CTX *mont = NULL;
226 const BIGNUM *A = NULL;
227
228 if (checks == BN_prime_checks)
229 checks = BN_prime_checks_for_size(BN_num_bits(a));
230
231 /* first look for small factors */
162 if (!BN_is_odd(a)) 232 if (!BN_is_odd(a))
163 return(0); 233 return(0);
234 if (do_trial_division)
235 {
236 for (i = 1; i < NUMPRIMES; i++)
237 if (BN_mod_word(a, primes[i]) == 0)
238 return 0;
239 if (callback != NULL) callback(1, -1, cb_arg);
240 }
241
164 if (ctx_passed != NULL) 242 if (ctx_passed != NULL)
165 ctx=ctx_passed; 243 ctx = ctx_passed;
166 else 244 else
167 if ((ctx=BN_CTX_new()) == NULL) goto err; 245 if ((ctx=BN_CTX_new()) == NULL)
168 246 goto err;
169 if ((ctx2=BN_CTX_new()) == NULL) goto err; 247 BN_CTX_start(ctx);
170 if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
171
172 check= &(ctx->bn[ctx->tos++]);
173 248
174 /* Setup the montgomery structure */ 249 /* A := abs(a) */
175 if (!BN_MONT_CTX_set(mont,a,ctx2)) goto err; 250 if (a->neg)
251 {
252 BIGNUM *t;
253 if ((t = BN_CTX_get(ctx)) == NULL) goto err;
254 BN_copy(t, a);
255 t->neg = 0;
256 A = t;
257 }
258 else
259 A = a;
260 A1 = BN_CTX_get(ctx);
261 A1_odd = BN_CTX_get(ctx);
262 check = BN_CTX_get(ctx);
263 if (check == NULL) goto err;
264
265 /* compute A1 := A - 1 */
266 if (!BN_copy(A1, A))
267 goto err;
268 if (!BN_sub_word(A1, 1))
269 goto err;
270 if (BN_is_zero(A1))
271 {
272 ret = 0;
273 goto err;
274 }
176 275
177 for (i=0; i<checks; i++) 276 /* write A1 as A1_odd * 2^k */
277 k = 1;
278 while (!BN_is_bit_set(A1, k))
279 k++;
280 if (!BN_rshift(A1_odd, A1, k))
281 goto err;
282
283 /* Montgomery setup for computations mod A */
284 mont = BN_MONT_CTX_new();
285 if (mont == NULL)
286 goto err;
287 if (!BN_MONT_CTX_set(mont, A, ctx))
288 goto err;
289
290 for (i = 0; i < checks; i++)
178 { 291 {
179 if (!BN_rand(check,BN_num_bits(a)-1,0,0)) goto err; 292 if (!BN_pseudo_rand(check, BN_num_bits(A1), 0, 0))
180 j=witness(check,a,ctx,ctx2,mont); 293 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 goto err;
299 /* now 1 <= check < A */
300
301 j = witness(check, A, A1, A1_odd, k, ctx, mont);
181 if (j == -1) goto err; 302 if (j == -1) goto err;
182 if (j) 303 if (j)
183 { 304 {
184 ret=0; 305 ret=0;
185 goto err; 306 goto err;
186 } 307 }
187 if (callback != NULL) callback(1,c2++,cb_arg); 308 if (callback != NULL) callback(1,i,cb_arg);
188 } 309 }
189 ret=1; 310 ret=1;
190err: 311err:
191 ctx->tos--; 312 if (ctx != NULL)
192 if ((ctx_passed == NULL) && (ctx != NULL)) 313 {
193 BN_CTX_free(ctx); 314 BN_CTX_end(ctx);
194 if (ctx2 != NULL) 315 if (ctx_passed == NULL)
195 BN_CTX_free(ctx2); 316 BN_CTX_free(ctx);
196 if (mont != NULL) BN_MONT_CTX_free(mont); 317 }
197 318 if (mont != NULL)
319 BN_MONT_CTX_free(mont);
320
198 return(ret); 321 return(ret);
199 } 322 }
200 323
201#define RECP_MUL_MOD 324static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
202 325 const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont)
203static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *ctx2,
204 BN_MONT_CTX *mont)
205 { 326 {
206 int k,i,ret= -1,good; 327 if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */
207 BIGNUM *d,*dd,*tmp,*d1,*d2,*n1; 328 return -1;
208 BIGNUM *mont_one,*mont_n1,*mont_a; 329 if (BN_is_one(w))
209 330 return 0; /* probably prime */
210 d1= &(ctx->bn[ctx->tos]); 331 if (BN_cmp(w, a1) == 0)
211 d2= &(ctx->bn[ctx->tos+1]); 332 return 0; /* w == -1 (mod a), 'a' is probably prime */
212 n1= &(ctx->bn[ctx->tos+2]); 333 while (--k)
213 ctx->tos+=3;
214
215 mont_one= &(ctx2->bn[ctx2->tos]);
216 mont_n1= &(ctx2->bn[ctx2->tos+1]);
217 mont_a= &(ctx2->bn[ctx2->tos+2]);
218 ctx2->tos+=3;
219
220 d=d1;
221 dd=d2;
222 if (!BN_one(d)) goto err;
223 if (!BN_sub(n1,n,d)) goto err; /* n1=n-1; */
224 k=BN_num_bits(n1);
225
226 if (!BN_to_montgomery(mont_one,BN_value_one(),mont,ctx2)) goto err;
227 if (!BN_to_montgomery(mont_n1,n1,mont,ctx2)) goto err;
228 if (!BN_to_montgomery(mont_a,a,mont,ctx2)) goto err;
229
230 BN_copy(d,mont_one);
231 for (i=k-1; i>=0; i--)
232 { 334 {
233 if ( (BN_cmp(d,mont_one) != 0) && 335 if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */
234 (BN_cmp(d,mont_n1) != 0)) 336 return -1;
235 good=1; 337 if (BN_is_one(w))
236 else 338 return 1; /* 'a' is composite, otherwise a previous 'w' would
237 good=0; 339 * have been == -1 (mod 'a') */
238 340 if (BN_cmp(w, a1) == 0)
239 BN_mod_mul_montgomery(dd,d,d,mont,ctx2); 341 return 0; /* w == -1 (mod a), 'a' is probably prime */
240
241 if (good && (BN_cmp(dd,mont_one) == 0))
242 {
243 ret=1;
244 goto err;
245 }
246 if (BN_is_bit_set(n1,i))
247 {
248 BN_mod_mul_montgomery(d,dd,mont_a,mont,ctx2);
249 }
250 else
251 {
252 tmp=d;
253 d=dd;
254 dd=tmp;
255 }
256 } 342 }
257 if (BN_cmp(d,mont_one) == 0) 343 /* If we get here, 'w' is the (a-1)/2-th power of the original 'w',
258 i=0; 344 * and it is neither -1 nor +1 -- so 'a' cannot be prime */
259 else i=1; 345 return 1;
260 ret=i;
261err:
262 ctx->tos-=3;
263 ctx2->tos-=3;
264 return(ret);
265 } 346 }
266 347
267static int probable_prime(BIGNUM *rnd, int bits) 348static int probable_prime(BIGNUM *rnd, int bits)
268 { 349 {
269 int i; 350 int i;
270 MS_STATIC BN_ULONG mods[NUMPRIMES]; 351 BN_ULONG mods[NUMPRIMES];
271 BN_ULONG delta,d; 352 BN_ULONG delta,d;
272 353
273again: 354again:
@@ -285,7 +366,7 @@ again:
285 d=delta; 366 d=delta;
286 delta+=2; 367 delta+=2;
287 /* perhaps need to check for overflow of 368 /* perhaps need to check for overflow of
288 * delta (but delta can be upto 2^32) 369 * delta (but delta can be up to 2^32)
289 * 21-May-98 eay - added overflow check */ 370 * 21-May-98 eay - added overflow check */
290 if (delta < d) goto again; 371 if (delta < d) goto again;
291 goto loop; 372 goto loop;
@@ -301,7 +382,8 @@ static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem,
301 int i,ret=0; 382 int i,ret=0;
302 BIGNUM *t1; 383 BIGNUM *t1;
303 384
304 t1= &(ctx->bn[ctx->tos++]); 385 BN_CTX_start(ctx);
386 if ((t1 = BN_CTX_get(ctx)) == NULL) goto err;
305 387
306 if (!BN_rand(rnd,bits,0,1)) goto err; 388 if (!BN_rand(rnd,bits,0,1)) goto err;
307 389
@@ -327,20 +409,22 @@ static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem,
327 } 409 }
328 ret=1; 410 ret=1;
329err: 411err:
330 ctx->tos--; 412 BN_CTX_end(ctx);
331 return(ret); 413 return(ret);
332 } 414 }
333 415
334static int probable_prime_dh_strong(BIGNUM *p, int bits, BIGNUM *padd, 416static int probable_prime_dh_safe(BIGNUM *p, int bits, BIGNUM *padd,
335 BIGNUM *rem, BN_CTX *ctx) 417 BIGNUM *rem, BN_CTX *ctx)
336 { 418 {
337 int i,ret=0; 419 int i,ret=0;
338 BIGNUM *t1,*qadd=NULL,*q=NULL; 420 BIGNUM *t1,*qadd,*q;
339 421
340 bits--; 422 bits--;
341 t1= &(ctx->bn[ctx->tos++]); 423 BN_CTX_start(ctx);
342 q= &(ctx->bn[ctx->tos++]); 424 t1 = BN_CTX_get(ctx);
343 qadd= &(ctx->bn[ctx->tos++]); 425 q = BN_CTX_get(ctx);
426 qadd = BN_CTX_get(ctx);
427 if (qadd == NULL) goto err;
344 428
345 if (!BN_rshift1(qadd,padd)) goto err; 429 if (!BN_rshift1(qadd,padd)) goto err;
346 430
@@ -376,72 +460,6 @@ static int probable_prime_dh_strong(BIGNUM *p, int bits, BIGNUM *padd,
376 } 460 }
377 ret=1; 461 ret=1;
378err: 462err:
379 ctx->tos-=3; 463 BN_CTX_end(ctx);
380 return(ret);
381 }
382
383#if 0
384static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx)
385 {
386 int k,i,nb,ret= -1;
387 BIGNUM *d,*dd,*tmp;
388 BIGNUM *d1,*d2,*x,*n1,*inv;
389
390 d1= &(ctx->bn[ctx->tos]);
391 d2= &(ctx->bn[ctx->tos+1]);
392 x= &(ctx->bn[ctx->tos+2]);
393 n1= &(ctx->bn[ctx->tos+3]);
394 inv=&(ctx->bn[ctx->tos+4]);
395 ctx->tos+=5;
396
397 d=d1;
398 dd=d2;
399 if (!BN_one(d)) goto err;
400 if (!BN_sub(n1,n,d)) goto err; /* n1=n-1; */
401 k=BN_num_bits(n1);
402
403 /* i=BN_num_bits(n); */
404#ifdef RECP_MUL_MOD
405 nb=BN_reciprocal(inv,n,ctx); /**/
406 if (nb == -1) goto err;
407#endif
408
409 for (i=k-1; i>=0; i--)
410 {
411 if (BN_copy(x,d) == NULL) goto err;
412#ifndef RECP_MUL_MOD
413 if (!BN_mod_mul(dd,d,d,n,ctx)) goto err;
414#else
415 if (!BN_mod_mul_reciprocal(dd,d,d,n,inv,nb,ctx)) goto err;
416#endif
417 if ( BN_is_one(dd) &&
418 !BN_is_one(x) &&
419 (BN_cmp(x,n1) != 0))
420 {
421 ret=1;
422 goto err;
423 }
424 if (BN_is_bit_set(n1,i))
425 {
426#ifndef RECP_MUL_MOD
427 if (!BN_mod_mul(d,dd,a,n,ctx)) goto err;
428#else
429 if (!BN_mod_mul_reciprocal(d,dd,a,n,inv,nb,ctx)) goto err;
430#endif
431 }
432 else
433 {
434 tmp=d;
435 d=dd;
436 dd=tmp;
437 }
438 }
439 if (BN_is_one(d))
440 i=0;
441 else i=1;
442 ret=i;
443err:
444 ctx->tos-=5;
445 return(ret); 464 return(ret);
446 } 465 }
447#endif
diff --git a/src/lib/libssl/src/crypto/bn/bn_prime.h b/src/lib/libssl/src/crypto/bn/bn_prime.h
index 6fce0210cd..b7cf9a9bfe 100644
--- a/src/lib/libssl/src/crypto/bn/bn_prime.h
+++ b/src/lib/libssl/src/crypto/bn/bn_prime.h
@@ -1,4 +1,4 @@
1/* crypto/bn/bn_prime.h */ 1/* Auto generated by bn_prime.pl */
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 *
@@ -61,7 +61,7 @@
61#else 61#else
62#define NUMPRIMES 54 62#define NUMPRIMES 54
63#endif 63#endif
64static unsigned int primes[NUMPRIMES]= 64static const unsigned int primes[NUMPRIMES]=
65 { 65 {
66 2, 3, 5, 7, 11, 13, 17, 19, 66 2, 3, 5, 7, 11, 13, 17, 19,
67 23, 29, 31, 37, 41, 43, 47, 53, 67 23, 29, 31, 37, 41, 43, 47, 53,
diff --git a/src/lib/libssl/src/crypto/bn/bn_prime.pl b/src/lib/libssl/src/crypto/bn/bn_prime.pl
index 979385a334..9fc3765486 100644
--- a/src/lib/libssl/src/crypto/bn/bn_prime.pl
+++ b/src/lib/libssl/src/crypto/bn/bn_prime.pl
@@ -18,13 +18,74 @@ loop: while ($#primes < $num-1)
18 push(@primes,$p); 18 push(@primes,$p);
19 } 19 }
20 20
21print <<"EOF"; 21# print <<"EOF";
22# /* Auto generated by bn_prime.pl */
23# /* Copyright (C) 1995-1997 Eric Young (eay\@mincom.oz.au).
24# * All rights reserved.
25# * Copyright remains Eric Young's, and as such any Copyright notices in
26# * the code are not to be removed.
27# * See the COPYRIGHT file in the SSLeay distribution for more details.
28# */
29#
30# EOF
31
32print <<\EOF;
22/* Auto generated by bn_prime.pl */ 33/* Auto generated by bn_prime.pl */
23/* Copyright (C) 1995-1997 Eric Young (eay\@mincom.oz.au). 34/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
24 * All rights reserved. 35 * All rights reserved.
36 *
37 * This package is an SSL implementation written
38 * by Eric Young (eay@cryptsoft.com).
39 * The implementation was written so as to conform with Netscapes SSL.
40 *
41 * This library is free for commercial and non-commercial use as long as
42 * the following conditions are aheared to. The following conditions
43 * apply to all code found in this distribution, be it the RC4, RSA,
44 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
45 * included with this distribution is covered by the same copyright terms
46 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
47 *
25 * Copyright remains Eric Young's, and as such any Copyright notices in 48 * Copyright remains Eric Young's, and as such any Copyright notices in
26 * the code are not to be removed. 49 * the code are not to be removed.
27 * See the COPYRIGHT file in the SSLeay distribution for more details. 50 * If this package is used in a product, Eric Young should be given attribution
51 * as the author of the parts of the library used.
52 * This can be in the form of a textual message at program startup or
53 * in documentation (online or textual) provided with the package.
54 *
55 * Redistribution and use in source and binary forms, with or without
56 * modification, are permitted provided that the following conditions
57 * are met:
58 * 1. Redistributions of source code must retain the copyright
59 * notice, this list of conditions and the following disclaimer.
60 * 2. Redistributions in binary form must reproduce the above copyright
61 * notice, this list of conditions and the following disclaimer in the
62 * documentation and/or other materials provided with the distribution.
63 * 3. All advertising materials mentioning features or use of this software
64 * must display the following acknowledgement:
65 * "This product includes cryptographic software written by
66 * Eric Young (eay@cryptsoft.com)"
67 * The word 'cryptographic' can be left out if the rouines from the library
68 * being used are not cryptographic related :-).
69 * 4. If you include any Windows specific code (or a derivative thereof) from
70 * the apps directory (application code) you must include an acknowledgement:
71 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
72 *
73 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
74 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
77 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
78 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
79 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
80 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
81 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
82 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
83 * SUCH DAMAGE.
84 *
85 * The licence and distribution terms for any publically available version or
86 * derivative of this code cannot be changed. i.e. this code cannot simply be
87 * copied and put under another distribution licence
88 * [including the GNU Public Licence.]
28 */ 89 */
29 90
30EOF 91EOF
@@ -43,7 +104,7 @@ printf "#define NUMPRIMES %d\n",$num;
43printf "#else\n"; 104printf "#else\n";
44printf "#define NUMPRIMES %d\n",$eight; 105printf "#define NUMPRIMES %d\n",$eight;
45printf "#endif\n"; 106printf "#endif\n";
46print "static unsigned int primes[NUMPRIMES]=\n\t{\n\t"; 107print "static const unsigned int primes[NUMPRIMES]=\n\t{\n\t";
47$init=0; 108$init=0;
48for ($i=0; $i <= $#primes; $i++) 109for ($i=0; $i <= $#primes; $i++)
49 { 110 {
diff --git a/src/lib/libssl/src/crypto/bn/bn_print.c b/src/lib/libssl/src/crypto/bn/bn_print.c
index 2f5ab2617b..782a96e7e0 100644
--- a/src/lib/libssl/src/crypto/bn/bn_print.c
+++ b/src/lib/libssl/src/crypto/bn/bn_print.c
@@ -137,7 +137,7 @@ char *BN_bn2dec(const BIGNUM *a)
137 } 137 }
138 lp--; 138 lp--;
139 /* We now have a series of blocks, BN_DEC_NUM chars 139 /* We now have a series of blocks, BN_DEC_NUM chars
140 * in length, where the last one needs trucation. 140 * in length, where the last one needs truncation.
141 * The blocks need to be reversed in order. */ 141 * The blocks need to be reversed in order. */
142 sprintf(p,BN_DEC_FMT1,*lp); 142 sprintf(p,BN_DEC_FMT1,*lp);
143 while (*p) p++; 143 while (*p) p++;
@@ -171,7 +171,7 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
171 num=i+neg; 171 num=i+neg;
172 if (bn == NULL) return(num); 172 if (bn == NULL) return(num);
173 173
174 /* a is the start of the hex digets, and it is 'i' long */ 174 /* a is the start of the hex digits, and it is 'i' long */
175 if (*bn == NULL) 175 if (*bn == NULL)
176 { 176 {
177 if ((ret=BN_new()) == NULL) return(0); 177 if ((ret=BN_new()) == NULL) return(0);
@@ -185,7 +185,7 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
185 /* i is the number of hex digests; */ 185 /* i is the number of hex digests; */
186 if (bn_expand(ret,i*4) == NULL) goto err; 186 if (bn_expand(ret,i*4) == NULL) goto err;
187 187
188 j=i; /* least significate 'hex' */ 188 j=i; /* least significant 'hex' */
189 m=0; 189 m=0;
190 h=0; 190 h=0;
191 while (j > 0) 191 while (j > 0)
@@ -236,8 +236,8 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
236 num=i+neg; 236 num=i+neg;
237 if (bn == NULL) return(num); 237 if (bn == NULL) return(num);
238 238
239 /* a is the start of the digets, and it is 'i' long. 239 /* a is the start of the digits, and it is 'i' long.
240 * We chop it into BN_DEC_NUM digets at a time */ 240 * We chop it into BN_DEC_NUM digits at a time */
241 if (*bn == NULL) 241 if (*bn == NULL)
242 { 242 {
243 if ((ret=BN_new()) == NULL) return(0); 243 if ((ret=BN_new()) == NULL) return(0);
@@ -278,9 +278,8 @@ err:
278 } 278 }
279 279
280#ifndef NO_BIO 280#ifndef NO_BIO
281
282#ifndef NO_FP_API 281#ifndef NO_FP_API
283int BN_print_fp(FILE *fp, BIGNUM *a) 282int BN_print_fp(FILE *fp, const BIGNUM *a)
284 { 283 {
285 BIO *b; 284 BIO *b;
286 int ret; 285 int ret;
@@ -319,5 +318,15 @@ int BN_print(BIO *bp, const BIGNUM *a)
319end: 318end:
320 return(ret); 319 return(ret);
321 } 320 }
321#endif
322 322
323#ifdef BN_DEBUG
324void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n)
325 {
326 int i;
327 fprintf(o, "%s=", a);
328 for (i=n-1;i>=0;i--)
329 fprintf(o, "%08lX", b[i]); /* assumes 32-bit BN_ULONG */
330 fprintf(o, "\n");
331 }
323#endif 332#endif
diff --git a/src/lib/libssl/src/crypto/bn/bn_rand.c b/src/lib/libssl/src/crypto/bn/bn_rand.c
index 91b8e34ae6..943712c15b 100644
--- a/src/lib/libssl/src/crypto/bn/bn_rand.c
+++ b/src/lib/libssl/src/crypto/bn/bn_rand.c
@@ -62,7 +62,7 @@
62#include "bn_lcl.h" 62#include "bn_lcl.h"
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) 65static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
66 { 66 {
67 unsigned char *buf=NULL; 67 unsigned char *buf=NULL;
68 int ret=0,bit,bytes,mask; 68 int ret=0,bit,bytes,mask;
@@ -81,9 +81,19 @@ int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
81 81
82 /* make a random number and set the top and bottom bits */ 82 /* make a random number and set the top and bottom bits */
83 time(&tim); 83 time(&tim);
84 RAND_seed(&tim,sizeof(tim)); 84 RAND_add(&tim,sizeof(tim),0);
85
86 if (pseudorand)
87 {
88 if (RAND_pseudo_bytes(buf, bytes) == -1)
89 goto err;
90 }
91 else
92 {
93 if (RAND_bytes(buf, bytes) <= 0)
94 goto err;
95 }
85 96
86 RAND_bytes(buf,(int)bytes);
87 if (top) 97 if (top)
88 { 98 {
89 if (bit == 0) 99 if (bit == 0)
@@ -115,3 +125,12 @@ err:
115 return(ret); 125 return(ret);
116 } 126 }
117 127
128int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
129 {
130 return bnrand(0, rnd, bits, top, bottom);
131 }
132
133int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
134 {
135 return bnrand(1, rnd, bits, top, bottom);
136 }
diff --git a/src/lib/libssl/src/crypto/bn/bn_recp.c b/src/lib/libssl/src/crypto/bn/bn_recp.c
index c1b0e230ea..a8796bd0aa 100644
--- a/src/lib/libssl/src/crypto/bn/bn_recp.c
+++ b/src/lib/libssl/src/crypto/bn/bn_recp.c
@@ -106,7 +106,8 @@ int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
106 int ret=0; 106 int ret=0;
107 BIGNUM *a; 107 BIGNUM *a;
108 108
109 a= &(ctx->bn[ctx->tos++]); 109 BN_CTX_start(ctx);
110 if ((a = BN_CTX_get(ctx)) == NULL) goto err;
110 if (y != NULL) 111 if (y != NULL)
111 { 112 {
112 if (x == y) 113 if (x == y)
@@ -120,33 +121,34 @@ int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
120 BN_div_recp(NULL,r,a,recp,ctx); 121 BN_div_recp(NULL,r,a,recp,ctx);
121 ret=1; 122 ret=1;
122err: 123err:
123 ctx->tos--; 124 BN_CTX_end(ctx);
124 return(ret); 125 return(ret);
125 } 126 }
126 127
127int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp, 128int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
128 BN_CTX *ctx) 129 BN_CTX *ctx)
129 { 130 {
130 int i,j,tos,ret=0,ex; 131 int i,j,ret=0;
131 BIGNUM *a,*b,*d,*r; 132 BIGNUM *a,*b,*d,*r;
132 133
133 tos=ctx->tos; 134 BN_CTX_start(ctx);
134 a= &(ctx->bn[ctx->tos++]); 135 a=BN_CTX_get(ctx);
135 b= &(ctx->bn[ctx->tos++]); 136 b=BN_CTX_get(ctx);
136 if (dv != NULL) 137 if (dv != NULL)
137 d=dv; 138 d=dv;
138 else 139 else
139 d= &(ctx->bn[ctx->tos++]); 140 d=BN_CTX_get(ctx);
140 if (rem != NULL) 141 if (rem != NULL)
141 r=rem; 142 r=rem;
142 else 143 else
143 r= &(ctx->bn[ctx->tos++]); 144 r=BN_CTX_get(ctx);
145 if (a == NULL || b == NULL || d == NULL || r == NULL) goto err;
144 146
145 if (BN_ucmp(m,&(recp->N)) < 0) 147 if (BN_ucmp(m,&(recp->N)) < 0)
146 { 148 {
147 BN_zero(d); 149 BN_zero(d);
148 BN_copy(r,m); 150 BN_copy(r,m);
149 ctx->tos=tos; 151 BN_CTX_end(ctx);
150 return(1); 152 return(1);
151 } 153 }
152 154
@@ -157,33 +159,24 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
157 */ 159 */
158 i=BN_num_bits(m); 160 i=BN_num_bits(m);
159 161
160 j=recp->num_bits*2; 162 j=recp->num_bits<<1;
161 if (j > i) 163 if (j>i) i=j;
162 { 164 j>>=1;
163 i=j;
164 ex=0;
165 }
166 else
167 {
168 ex=(i-j)/2;
169 }
170
171 j=i/2;
172 165
173 if (i != recp->shift) 166 if (i != recp->shift)
174 recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N), 167 recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N),
175 i,ctx); 168 i,ctx);
176 169
177 if (!BN_rshift(a,m,j-ex)) goto err; 170 if (!BN_rshift(a,m,j)) goto err;
178 if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err; 171 if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err;
179 if (!BN_rshift(d,b,j+ex)) goto err; 172 if (!BN_rshift(d,b,i-j)) goto err;
180 d->neg=0; 173 d->neg=0;
181 if (!BN_mul(b,&(recp->N),d,ctx)) goto err; 174 if (!BN_mul(b,&(recp->N),d,ctx)) goto err;
182 if (!BN_usub(r,m,b)) goto err; 175 if (!BN_usub(r,m,b)) goto err;
183 r->neg=0; 176 r->neg=0;
184 177
185 j=0;
186#if 1 178#if 1
179 j=0;
187 while (BN_ucmp(r,&(recp->N)) >= 0) 180 while (BN_ucmp(r,&(recp->N)) >= 0)
188 { 181 {
189 if (j++ > 2) 182 if (j++ > 2)
@@ -200,7 +193,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
200 d->neg=m->neg^recp->N.neg; 193 d->neg=m->neg^recp->N.neg;
201 ret=1; 194 ret=1;
202err: 195err:
203 ctx->tos=tos; 196 BN_CTX_end(ctx);
204 return(ret); 197 return(ret);
205 } 198 }
206 199
diff --git a/src/lib/libssl/src/crypto/bn/bn_sqr.c b/src/lib/libssl/src/crypto/bn/bn_sqr.c
index 12cce4d7ce..fe00c5f69a 100644
--- a/src/lib/libssl/src/crypto/bn/bn_sqr.c
+++ b/src/lib/libssl/src/crypto/bn/bn_sqr.c
@@ -65,14 +65,13 @@
65int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx) 65int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)
66 { 66 {
67 int max,al; 67 int max,al;
68 int ret = 0;
68 BIGNUM *tmp,*rr; 69 BIGNUM *tmp,*rr;
69 70
70#ifdef BN_COUNT 71#ifdef BN_COUNT
71printf("BN_sqr %d * %d\n",a->top,a->top); 72printf("BN_sqr %d * %d\n",a->top,a->top);
72#endif 73#endif
73 bn_check_top(a); 74 bn_check_top(a);
74 tmp= &(ctx->bn[ctx->tos]);
75 rr=(a != r)?r: (&ctx->bn[ctx->tos+1]);
76 75
77 al=a->top; 76 al=a->top;
78 if (al <= 0) 77 if (al <= 0)
@@ -81,8 +80,13 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
81 return(1); 80 return(1);
82 } 81 }
83 82
83 BN_CTX_start(ctx);
84 rr=(a != r) ? r : BN_CTX_get(ctx);
85 tmp=BN_CTX_get(ctx);
86 if (tmp == NULL) goto err;
87
84 max=(al+al); 88 max=(al+al);
85 if (bn_wexpand(rr,max+1) == NULL) return(0); 89 if (bn_wexpand(rr,max+1) == NULL) goto err;
86 90
87 r->neg=0; 91 r->neg=0;
88 if (al == 4) 92 if (al == 4)
@@ -120,18 +124,18 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
120 k=j+j; 124 k=j+j;
121 if (al == j) 125 if (al == j)
122 { 126 {
123 if (bn_wexpand(a,k*2) == NULL) return(0); 127 if (bn_wexpand(a,k*2) == NULL) goto err;
124 if (bn_wexpand(tmp,k*2) == NULL) return(0); 128 if (bn_wexpand(tmp,k*2) == NULL) goto err;
125 bn_sqr_recursive(rr->d,a->d,al,tmp->d); 129 bn_sqr_recursive(rr->d,a->d,al,tmp->d);
126 } 130 }
127 else 131 else
128 { 132 {
129 if (bn_wexpand(tmp,max) == NULL) return(0); 133 if (bn_wexpand(tmp,max) == NULL) goto err;
130 bn_sqr_normal(rr->d,a->d,al,tmp->d); 134 bn_sqr_normal(rr->d,a->d,al,tmp->d);
131 } 135 }
132 } 136 }
133#else 137#else
134 if (bn_wexpand(tmp,max) == NULL) return(0); 138 if (bn_wexpand(tmp,max) == NULL) goto err;
135 bn_sqr_normal(rr->d,a->d,al,tmp->d); 139 bn_sqr_normal(rr->d,a->d,al,tmp->d);
136#endif 140#endif
137 } 141 }
@@ -139,7 +143,10 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
139 rr->top=max; 143 rr->top=max;
140 if ((max > 0) && (rr->d[max-1] == 0)) rr->top--; 144 if ((max > 0) && (rr->d[max-1] == 0)) rr->top--;
141 if (rr != r) BN_copy(r,rr); 145 if (rr != r) BN_copy(r,rr);
142 return(1); 146 ret = 1;
147 err:
148 BN_CTX_end(ctx);
149 return(ret);
143 } 150 }
144 151
145/* tmp must have 2*n words */ 152/* tmp must have 2*n words */
@@ -185,7 +192,7 @@ void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)
185 * n must be a power of 2. 192 * n must be a power of 2.
186 * We multiply and return the result. 193 * We multiply and return the result.
187 * t must be 2*n words in size 194 * t must be 2*n words in size
188 * We calulate 195 * We calculate
189 * a[0]*b[0] 196 * a[0]*b[0]
190 * 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])
191 * a[1]*b[1] 198 * a[1]*b[1]
diff --git a/src/lib/libssl/src/crypto/bn/bn_word.c b/src/lib/libssl/src/crypto/bn/bn_word.c
index c0cfbc6797..73157a7d43 100644
--- a/src/lib/libssl/src/crypto/bn/bn_word.c
+++ b/src/lib/libssl/src/crypto/bn/bn_word.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
63BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w) 63BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
64 { 64 {
65#ifndef BN_LLONG 65#ifndef BN_LLONG
66 BN_ULONG ret=0; 66 BN_ULONG ret=0;
diff --git a/src/lib/libssl/src/crypto/bn/bnspeed.c b/src/lib/libssl/src/crypto/bn/bnspeed.c
index 0922aa3e16..20fc7e08ff 100644
--- a/src/lib/libssl/src/crypto/bn/bnspeed.c
+++ b/src/lib/libssl/src/crypto/bn/bnspeed.c
@@ -1,3 +1,5 @@
1/* unused */
2
1/* crypto/bn/bnspeed.c */ 3/* crypto/bn/bnspeed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 4/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 5 * All rights reserved.
diff --git a/src/lib/libssl/src/crypto/bn/bntest.c b/src/lib/libssl/src/crypto/bn/bntest.c
index df4b81f5b2..41c22f5954 100644
--- a/src/lib/libssl/src/crypto/bn/bntest.c
+++ b/src/lib/libssl/src/crypto/bn/bntest.c
@@ -72,6 +72,10 @@
72#include "../bio/bss_file.c" 72#include "../bio/bss_file.c"
73#endif 73#endif
74 74
75const int num0 = 100; /* number of tests */
76const int num1 = 50; /* additional tests for some functions */
77const int num2 = 5; /* number of tests for slow functions */
78
75int test_add(BIO *bp); 79int test_add(BIO *bp);
76int test_sub(BIO *bp); 80int test_sub(BIO *bp);
77int test_lshift1(BIO *bp); 81int test_lshift1(BIO *bp);
@@ -95,15 +99,33 @@ static int results=0;
95#include "bss_file.c" 99#include "bss_file.c"
96#endif 100#endif
97 101
98static unsigned char lst1[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9" 102static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9"
99"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0"; 103"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0";
100 104
105static const char rnd_seed[] = "string to make the random number generator think it has entropy";
106
107static void message(BIO *out, char *m)
108 {
109 fprintf(stderr, "test %s\n", m);
110#if defined(linux) || defined(__FreeBSD__) /* can we use GNU bc features? */
111 BIO_puts(out, "print \"test ");
112 BIO_puts(out, m);
113 BIO_puts(out, "\\n\"\n");
114#endif
115 }
116
101int main(int argc, char *argv[]) 117int main(int argc, char *argv[])
102 { 118 {
103 BN_CTX *ctx; 119 BN_CTX *ctx;
104 BIO *out; 120 BIO *out;
105 char *outfile=NULL; 121 char *outfile=NULL;
106 122
123 results = 0;
124
125 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
126 * even check its return value
127 * (which we should) */
128
107 argc--; 129 argc--;
108 argv++; 130 argv++;
109 while (argc >= 1) 131 while (argc >= 1)
@@ -141,78 +163,81 @@ int main(int argc, char *argv[])
141 if (!results) 163 if (!results)
142 BIO_puts(out,"obase=16\nibase=16\n"); 164 BIO_puts(out,"obase=16\nibase=16\n");
143 165
144 fprintf(stderr,"test BN_add\n"); 166 message(out,"BN_add");
145 if (!test_add(out)) goto err; 167 if (!test_add(out)) goto err;
146 fflush(stdout); 168 BIO_flush(out);
147 169
148 fprintf(stderr,"test BN_sub\n"); 170 message(out,"BN_sub");
149 if (!test_sub(out)) goto err; 171 if (!test_sub(out)) goto err;
150 fflush(stdout); 172 BIO_flush(out);
151 173
152 fprintf(stderr,"test BN_lshift1\n"); 174 message(out,"BN_lshift1");
153 if (!test_lshift1(out)) goto err; 175 if (!test_lshift1(out)) goto err;
154 fflush(stdout); 176 BIO_flush(out);
155 177
156 fprintf(stderr,"test BN_lshift (fixed)\n"); 178 message(out,"BN_lshift (fixed)");
157 if (!test_lshift(out,ctx,BN_bin2bn(lst1,sizeof(lst1)-1,NULL))) 179 if (!test_lshift(out,ctx,BN_bin2bn(lst,sizeof(lst)-1,NULL)))
158 goto err; 180 goto err;
159 fflush(stdout); 181 BIO_flush(out);
160 182
161 fprintf(stderr,"test BN_lshift\n"); 183 message(out,"BN_lshift");
162 if (!test_lshift(out,ctx,NULL)) goto err; 184 if (!test_lshift(out,ctx,NULL)) goto err;
163 fflush(stdout); 185 BIO_flush(out);
164 186
165 fprintf(stderr,"test BN_rshift1\n"); 187 message(out,"BN_rshift1");
166 if (!test_rshift1(out)) goto err; 188 if (!test_rshift1(out)) goto err;
167 fflush(stdout); 189 BIO_flush(out);
168 190
169 fprintf(stderr,"test BN_rshift\n"); 191 message(out,"BN_rshift");
170 if (!test_rshift(out,ctx)) goto err; 192 if (!test_rshift(out,ctx)) goto err;
171 fflush(stdout); 193 BIO_flush(out);
172 194
173 fprintf(stderr,"test BN_sqr\n"); 195 message(out,"BN_sqr");
174 if (!test_sqr(out,ctx)) goto err; 196 if (!test_sqr(out,ctx)) goto err;
175 fflush(stdout); 197 BIO_flush(out);
176 198
177 fprintf(stderr,"test BN_mul\n"); 199 message(out,"BN_mul");
178 if (!test_mul(out)) goto err; 200 if (!test_mul(out)) goto err;
179 fflush(stdout); 201 BIO_flush(out);
180 202
181 fprintf(stderr,"test BN_div\n"); 203 message(out,"BN_div");
182 if (!test_div(out,ctx)) goto err; 204 if (!test_div(out,ctx)) goto err;
183 fflush(stdout); 205 BIO_flush(out);
184 206
185 fprintf(stderr,"test BN_div_recp\n"); 207 message(out,"BN_div_recp");
186 if (!test_div_recp(out,ctx)) goto err; 208 if (!test_div_recp(out,ctx)) goto err;
187 fflush(stdout); 209 BIO_flush(out);
188 210
189 fprintf(stderr,"test BN_mod\n"); 211 message(out,"BN_mod");
190 if (!test_mod(out,ctx)) goto err; 212 if (!test_mod(out,ctx)) goto err;
191 fflush(stdout); 213 BIO_flush(out);
192 214
193 fprintf(stderr,"test BN_mod_mul\n"); 215 message(out,"BN_mod_mul");
194 if (!test_mod_mul(out,ctx)) goto err; 216 if (!test_mod_mul(out,ctx)) goto err;
195 fflush(stdout); 217 BIO_flush(out);
196 218
197/* 219 message(out,"BN_mont");
198 fprintf(stderr,"test BN_mont\n");
199 if (!test_mont(out,ctx)) goto err; 220 if (!test_mont(out,ctx)) goto err;
200 fflush(stdout); 221 BIO_flush(out);
201*/ 222
202 fprintf(stderr,"test BN_mod_exp\n"); 223 message(out,"BN_mod_exp");
203 if (!test_mod_exp(out,ctx)) goto err; 224 if (!test_mod_exp(out,ctx)) goto err;
204 fflush(stdout); 225 BIO_flush(out);
205 226
206 fprintf(stderr,"test BN_exp\n"); 227 message(out,"BN_exp");
207 if (!test_exp(out,ctx)) goto err; 228 if (!test_exp(out,ctx)) goto err;
208 fflush(stdout); 229 BIO_flush(out);
230
231 BN_CTX_free(ctx);
232 BIO_free(out);
209 233
210/**/ 234/**/
211 exit(0); 235 exit(0);
212err: 236err:
213 BIO_puts(out,"1\n"); /* make sure bc fails if we are piping to it */ 237 BIO_puts(out,"1\n"); /* make sure bc fails if we are piping to it */
238 BIO_flush(out);
214 ERR_load_crypto_strings(); 239 ERR_load_crypto_strings();
215 ERR_print_errors(out); 240 ERR_print_errors_fp(stderr);
216 exit(1); 241 exit(1);
217 return(1); 242 return(1);
218 } 243 }
@@ -228,7 +253,7 @@ int test_add(BIO *bp)
228 BN_init(&c); 253 BN_init(&c);
229 254
230 BN_rand(&a,512,0,0); 255 BN_rand(&a,512,0,0);
231 for (i=0; i<100; i++) 256 for (i=0; i<num0; i++)
232 { 257 {
233 BN_rand(&b,450+i,0,0); 258 BN_rand(&b,450+i,0,0);
234 a.neg=rand_neg(); 259 a.neg=rand_neg();
@@ -255,7 +280,7 @@ int test_add(BIO *bp)
255 BN_add(&c,&c,&a); 280 BN_add(&c,&c,&a);
256 if(!BN_is_zero(&c)) 281 if(!BN_is_zero(&c))
257 { 282 {
258 BIO_puts(bp,"Add test failed!\n"); 283 fprintf(stderr,"Add test failed!\n");
259 return 0; 284 return 0;
260 } 285 }
261 } 286 }
@@ -275,12 +300,21 @@ int test_sub(BIO *bp)
275 BN_init(&b); 300 BN_init(&b);
276 BN_init(&c); 301 BN_init(&c);
277 302
278 BN_rand(&a,512,0,0); 303 for (i=0; i<num0+num1; i++)
279 for (i=0; i<100; i++)
280 { 304 {
281 BN_rand(&b,400+i,0,0); 305 if (i < num1)
282 a.neg=rand_neg(); 306 {
283 b.neg=rand_neg(); 307 BN_rand(&a,512,0,0);
308 BN_copy(&b,&a);
309 if (BN_set_bit(&a,i)==0) return(0);
310 BN_add_word(&b,i);
311 }
312 else
313 {
314 BN_rand(&b,400+i-num1,0,0);
315 a.neg=rand_neg();
316 b.neg=rand_neg();
317 }
284 if (bp == NULL) 318 if (bp == NULL)
285 for (j=0; j<10000; j++) 319 for (j=0; j<10000; j++)
286 BN_sub(&c,&a,&b); 320 BN_sub(&c,&a,&b);
@@ -301,7 +335,7 @@ int test_sub(BIO *bp)
301 BN_sub(&c,&c,&a); 335 BN_sub(&c,&c,&a);
302 if(!BN_is_zero(&c)) 336 if(!BN_is_zero(&c))
303 { 337 {
304 BIO_puts(bp,"Subtract test failed!\n"); 338 fprintf(stderr,"Subtract test failed!\n");
305 return 0; 339 return 0;
306 } 340 }
307 } 341 }
@@ -323,10 +357,17 @@ int test_div(BIO *bp, BN_CTX *ctx)
323 BN_init(&d); 357 BN_init(&d);
324 BN_init(&e); 358 BN_init(&e);
325 359
326 BN_rand(&a,400,0,0); 360 for (i=0; i<num0+num1; i++)
327 for (i=0; i<100; i++)
328 { 361 {
329 BN_rand(&b,50+i,0,0); 362 if (i < num1)
363 {
364 BN_rand(&a,400,0,0);
365 BN_copy(&b,&a);
366 BN_lshift(&a,&a,i);
367 BN_add_word(&a,i);
368 }
369 else
370 BN_rand(&b,50+3*(i-num1),0,0);
330 a.neg=rand_neg(); 371 a.neg=rand_neg();
331 b.neg=rand_neg(); 372 b.neg=rand_neg();
332 if (bp == NULL) 373 if (bp == NULL)
@@ -360,7 +401,7 @@ int test_div(BIO *bp, BN_CTX *ctx)
360 BN_sub(&d,&d,&a); 401 BN_sub(&d,&d,&a);
361 if(!BN_is_zero(&d)) 402 if(!BN_is_zero(&d))
362 { 403 {
363 BIO_puts(bp,"Division test failed!\n"); 404 fprintf(stderr,"Division test failed!\n");
364 return 0; 405 return 0;
365 } 406 }
366 } 407 }
@@ -386,10 +427,17 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
386 BN_init(&d); 427 BN_init(&d);
387 BN_init(&e); 428 BN_init(&e);
388 429
389 BN_rand(&a,400,0,0); 430 for (i=0; i<num0+num1; i++)
390 for (i=0; i<100; i++)
391 { 431 {
392 BN_rand(&b,50+i,0,0); 432 if (i < num1)
433 {
434 BN_rand(&a,400,0,0);
435 BN_copy(&b,&a);
436 BN_lshift(&a,&a,i);
437 BN_add_word(&a,i);
438 }
439 else
440 BN_rand(&b,50+3*(i-num1),0,0);
393 a.neg=rand_neg(); 441 a.neg=rand_neg();
394 b.neg=rand_neg(); 442 b.neg=rand_neg();
395 BN_RECP_CTX_set(&recp,&b,ctx); 443 BN_RECP_CTX_set(&recp,&b,ctx);
@@ -424,7 +472,12 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
424 BN_sub(&d,&d,&a); 472 BN_sub(&d,&d,&a);
425 if(!BN_is_zero(&d)) 473 if(!BN_is_zero(&d))
426 { 474 {
427 BIO_puts(bp,"Reciprocal division test failed!\n"); 475 fprintf(stderr,"Reciprocal division test failed!\n");
476 fprintf(stderr,"a=");
477 BN_print_fp(stderr,&a);
478 fprintf(stderr,"\nb=");
479 BN_print_fp(stderr,&b);
480 fprintf(stderr,"\n");
428 return 0; 481 return 0;
429 } 482 }
430 } 483 }
@@ -451,11 +504,15 @@ int test_mul(BIO *bp)
451 BN_init(&d); 504 BN_init(&d);
452 BN_init(&e); 505 BN_init(&e);
453 506
454 BN_rand(&a,200,0,0); 507 for (i=0; i<num0+num1; i++)
455 for (i=0; i<100; i++)
456 { 508 {
457 BN_rand(&b,250+i,0,0); 509 if (i <= num1)
458 BN_rand(&b,200,0,0); 510 {
511 BN_rand(&a,100,0,0);
512 BN_rand(&b,100,0,0);
513 }
514 else
515 BN_rand(&b,i-num1,0,0);
459 a.neg=rand_neg(); 516 a.neg=rand_neg();
460 b.neg=rand_neg(); 517 b.neg=rand_neg();
461 if (bp == NULL) 518 if (bp == NULL)
@@ -478,7 +535,7 @@ int test_mul(BIO *bp)
478 BN_sub(&d,&d,&b); 535 BN_sub(&d,&d,&b);
479 if(!BN_is_zero(&d) || !BN_is_zero(&e)) 536 if(!BN_is_zero(&d) || !BN_is_zero(&e))
480 { 537 {
481 BIO_puts(bp,"Multiplication test failed!\n"); 538 fprintf(stderr,"Multiplication test failed!\n");
482 return 0; 539 return 0;
483 } 540 }
484 } 541 }
@@ -502,7 +559,7 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
502 BN_init(&d); 559 BN_init(&d);
503 BN_init(&e); 560 BN_init(&e);
504 561
505 for (i=0; i<40; i++) 562 for (i=0; i<num0; i++)
506 { 563 {
507 BN_rand(&a,40+i*10,0,0); 564 BN_rand(&a,40+i*10,0,0);
508 a.neg=rand_neg(); 565 a.neg=rand_neg();
@@ -526,7 +583,7 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
526 BN_sub(&d,&d,&a); 583 BN_sub(&d,&d,&a);
527 if(!BN_is_zero(&d) || !BN_is_zero(&e)) 584 if(!BN_is_zero(&d) || !BN_is_zero(&e))
528 { 585 {
529 BIO_puts(bp,"Square test failed!\n"); 586 fprintf(stderr,"Square test failed!\n");
530 return 0; 587 return 0;
531 } 588 }
532 } 589 }
@@ -557,9 +614,13 @@ int test_mont(BIO *bp, BN_CTX *ctx)
557 614
558 BN_rand(&a,100,0,0); /**/ 615 BN_rand(&a,100,0,0); /**/
559 BN_rand(&b,100,0,0); /**/ 616 BN_rand(&b,100,0,0); /**/
560 for (i=0; i<10; i++) 617 for (i=0; i<num2; i++)
561 { 618 {
562 BN_rand(&n,(100%BN_BITS2+1)*BN_BITS2*i*BN_BITS2,0,1); /**/ 619 int bits = (200*(i+1))/num2;
620
621 if (bits == 0)
622 continue;
623 BN_rand(&n,bits,0,1);
563 BN_MONT_CTX_set(mont,&n,ctx); 624 BN_MONT_CTX_set(mont,&n,ctx);
564 625
565 BN_to_montgomery(&A,&a,mont,ctx); 626 BN_to_montgomery(&A,&a,mont,ctx);
@@ -594,7 +655,7 @@ BN_num_bits(mont->N));
594 BN_sub(&d,&d,&A); 655 BN_sub(&d,&d,&A);
595 if(!BN_is_zero(&d)) 656 if(!BN_is_zero(&d))
596 { 657 {
597 BIO_puts(bp,"Montgomery multiplication test failed!\n"); 658 fprintf(stderr,"Montgomery multiplication test failed!\n");
598 return 0; 659 return 0;
599 } 660 }
600 } 661 }
@@ -622,7 +683,7 @@ int test_mod(BIO *bp, BN_CTX *ctx)
622 e=BN_new(); 683 e=BN_new();
623 684
624 BN_rand(a,1024,0,0); /**/ 685 BN_rand(a,1024,0,0); /**/
625 for (i=0; i<20; i++) 686 for (i=0; i<num0; i++)
626 { 687 {
627 BN_rand(b,450+i*10,0,0); /**/ 688 BN_rand(b,450+i*10,0,0); /**/
628 a->neg=rand_neg(); 689 a->neg=rand_neg();
@@ -647,7 +708,7 @@ int test_mod(BIO *bp, BN_CTX *ctx)
647 BN_sub(e,e,c); 708 BN_sub(e,e,c);
648 if(!BN_is_zero(e)) 709 if(!BN_is_zero(e))
649 { 710 {
650 BIO_puts(bp,"Modulo test failed!\n"); 711 fprintf(stderr,"Modulo test failed!\n");
651 return 0; 712 return 0;
652 } 713 }
653 } 714 }
@@ -671,10 +732,10 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
671 e=BN_new(); 732 e=BN_new();
672 733
673 BN_rand(c,1024,0,0); /**/ 734 BN_rand(c,1024,0,0); /**/
674 for (i=0; i<10; i++) 735 for (i=0; i<num0; i++)
675 { 736 {
676 BN_rand(a,475+i*10,0,0); /**/ 737 BN_rand(a,475+i*10,0,0); /**/
677 BN_rand(b,425+i*10,0,0); /**/ 738 BN_rand(b,425+i*11,0,0); /**/
678 a->neg=rand_neg(); 739 a->neg=rand_neg();
679 b->neg=rand_neg(); 740 b->neg=rand_neg();
680 /* if (bp == NULL) 741 /* if (bp == NULL)
@@ -709,7 +770,7 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
709 BN_div(a,b,d,c,ctx); 770 BN_div(a,b,d,c,ctx);
710 if(!BN_is_zero(b)) 771 if(!BN_is_zero(b))
711 { 772 {
712 BIO_puts(bp,"Modulo multiply test failed!\n"); 773 fprintf(stderr,"Modulo multiply test failed!\n");
713 return 0; 774 return 0;
714 } 775 }
715 } 776 }
@@ -733,7 +794,7 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx)
733 e=BN_new(); 794 e=BN_new();
734 795
735 BN_rand(c,30,0,1); /* must be odd for montgomery */ 796 BN_rand(c,30,0,1); /* must be odd for montgomery */
736 for (i=0; i<6; i++) 797 for (i=0; i<num2; i++)
737 { 798 {
738 BN_rand(a,20+i*5,0,0); /**/ 799 BN_rand(a,20+i*5,0,0); /**/
739 BN_rand(b,2+i,0,0); /**/ 800 BN_rand(b,2+i,0,0); /**/
@@ -760,7 +821,7 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx)
760 BN_div(a,b,e,c,ctx); 821 BN_div(a,b,e,c,ctx);
761 if(!BN_is_zero(b)) 822 if(!BN_is_zero(b))
762 { 823 {
763 BIO_puts(bp,"Modulo exponentiation test failed!\n"); 824 fprintf(stderr,"Modulo exponentiation test failed!\n");
764 return 0; 825 return 0;
765 } 826 }
766 } 827 }
@@ -784,7 +845,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
784 one=BN_new(); 845 one=BN_new();
785 BN_one(one); 846 BN_one(one);
786 847
787 for (i=0; i<6; i++) 848 for (i=0; i<num2; i++)
788 { 849 {
789 BN_rand(a,20+i*5,0,0); /**/ 850 BN_rand(a,20+i*5,0,0); /**/
790 BN_rand(b,2+i,0,0); /**/ 851 BN_rand(b,2+i,0,0); /**/
@@ -810,7 +871,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
810 BN_sub(e,e,d); 871 BN_sub(e,e,d);
811 if(!BN_is_zero(e)) 872 if(!BN_is_zero(e))
812 { 873 {
813 BIO_puts(bp,"Exponentiation test failed!\n"); 874 fprintf(stderr,"Exponentiation test failed!\n");
814 return 0; 875 return 0;
815 } 876 }
816 } 877 }
@@ -840,7 +901,7 @@ int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
840 BN_rand(a,200,0,0); /**/ 901 BN_rand(a,200,0,0); /**/
841 a->neg=rand_neg(); 902 a->neg=rand_neg();
842 } 903 }
843 for (i=0; i<70; i++) 904 for (i=0; i<num0; i++)
844 { 905 {
845 BN_lshift(b,a,i+1); 906 BN_lshift(b,a,i+1);
846 BN_add(c,c,c); 907 BN_add(c,c,c);
@@ -860,16 +921,16 @@ int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
860 BN_sub(d,d,b); 921 BN_sub(d,d,b);
861 if(!BN_is_zero(d)) 922 if(!BN_is_zero(d))
862 { 923 {
863 BIO_puts(bp,"Left shift test failed!\n"); 924 fprintf(stderr,"Left shift test failed!\n");
864 BIO_puts(bp,"a="); 925 fprintf(stderr,"a=");
865 BN_print(bp,a); 926 BN_print_fp(stderr,a);
866 BIO_puts(bp,"\nb="); 927 fprintf(stderr,"\nb=");
867 BN_print(bp,b); 928 BN_print_fp(stderr,b);
868 BIO_puts(bp,"\nc="); 929 fprintf(stderr,"\nc=");
869 BN_print(bp,c); 930 BN_print_fp(stderr,c);
870 BIO_puts(bp,"\nd="); 931 fprintf(stderr,"\nd=");
871 BN_print(bp,d); 932 BN_print_fp(stderr,d);
872 BIO_puts(bp,"\n"); 933 fprintf(stderr,"\n");
873 return 0; 934 return 0;
874 } 935 }
875 } 936 }
@@ -891,7 +952,7 @@ int test_lshift1(BIO *bp)
891 952
892 BN_rand(a,200,0,0); /**/ 953 BN_rand(a,200,0,0); /**/
893 a->neg=rand_neg(); 954 a->neg=rand_neg();
894 for (i=0; i<70; i++) 955 for (i=0; i<num0; i++)
895 { 956 {
896 BN_lshift1(b,a); 957 BN_lshift1(b,a);
897 if (bp != NULL) 958 if (bp != NULL)
@@ -909,7 +970,7 @@ int test_lshift1(BIO *bp)
909 BN_sub(a,b,c); 970 BN_sub(a,b,c);
910 if(!BN_is_zero(a)) 971 if(!BN_is_zero(a))
911 { 972 {
912 BIO_puts(bp,"Left shift one test failed!\n"); 973 fprintf(stderr,"Left shift one test failed!\n");
913 return 0; 974 return 0;
914 } 975 }
915 976
@@ -935,7 +996,7 @@ int test_rshift(BIO *bp,BN_CTX *ctx)
935 996
936 BN_rand(a,200,0,0); /**/ 997 BN_rand(a,200,0,0); /**/
937 a->neg=rand_neg(); 998 a->neg=rand_neg();
938 for (i=0; i<70; i++) 999 for (i=0; i<num0; i++)
939 { 1000 {
940 BN_rshift(b,a,i+1); 1001 BN_rshift(b,a,i+1);
941 BN_add(c,c,c); 1002 BN_add(c,c,c);
@@ -955,7 +1016,7 @@ int test_rshift(BIO *bp,BN_CTX *ctx)
955 BN_sub(d,d,b); 1016 BN_sub(d,d,b);
956 if(!BN_is_zero(d)) 1017 if(!BN_is_zero(d))
957 { 1018 {
958 BIO_puts(bp,"Right shift test failed!\n"); 1019 fprintf(stderr,"Right shift test failed!\n");
959 return 0; 1020 return 0;
960 } 1021 }
961 } 1022 }
@@ -978,7 +1039,7 @@ int test_rshift1(BIO *bp)
978 1039
979 BN_rand(a,200,0,0); /**/ 1040 BN_rand(a,200,0,0); /**/
980 a->neg=rand_neg(); 1041 a->neg=rand_neg();
981 for (i=0; i<70; i++) 1042 for (i=0; i<num0; i++)
982 { 1043 {
983 BN_rshift1(b,a); 1044 BN_rshift1(b,a);
984 if (bp != NULL) 1045 if (bp != NULL)
@@ -996,7 +1057,7 @@ int test_rshift1(BIO *bp)
996 BN_sub(c,c,b); 1057 BN_sub(c,c,b);
997 if(!BN_is_zero(c) && !BN_is_one(c)) 1058 if(!BN_is_zero(c) && !BN_is_one(c))
998 { 1059 {
999 BIO_puts(bp,"Right shift one test failed!\n"); 1060 fprintf(stderr,"Right shift one test failed!\n");
1000 return 0; 1061 return 0;
1001 } 1062 }
1002 BN_copy(a,b); 1063 BN_copy(a,b);
diff --git a/src/lib/libssl/src/crypto/bn/comba.pl b/src/lib/libssl/src/crypto/bn/comba.pl
index 211a8b45c7..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/comba.pl
+++ b/src/lib/libssl/src/crypto/bn/comba.pl
@@ -1,285 +0,0 @@
1#!/usr/local/bin/perl
2
3$num=8;
4$num2=8/2;
5
6print <<"EOF";
7/* crypto/bn/bn_comba.c */
8#include <stdio.h>
9#include "bn_lcl.h"
10/* Auto generated from crypto/bn/comba.pl
11 */
12
13#undef bn_mul_comba8
14#undef bn_mul_comba4
15#undef bn_sqr_comba8
16#undef bn_sqr_comba4
17
18#ifdef BN_LLONG
19#define mul_add_c(a,b,c0,c1,c2) \\
20 t=(BN_ULLONG)a*b; \\
21 t1=(BN_ULONG)Lw(t); \\
22 t2=(BN_ULONG)Hw(t); \\
23 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
24 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
25
26#define mul_add_c2(a,b,c0,c1,c2) \\
27 t=(BN_ULLONG)a*b; \\
28 tt=(t+t)&BN_MASK; \\
29 if (tt < t) c2++; \\
30 t1=(BN_ULONG)Lw(tt); \\
31 t2=(BN_ULONG)Hw(tt); \\
32 c0=(c0+t1)&BN_MASK2; \\
33 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \\
34 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
35
36#define sqr_add_c(a,i,c0,c1,c2) \\
37 t=(BN_ULLONG)a[i]*a[i]; \\
38 t1=(BN_ULONG)Lw(t); \\
39 t2=(BN_ULONG)Hw(t); \\
40 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
41 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
42
43#define sqr_add_c2(a,i,j,c0,c1,c2) \\
44 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
45#else
46#define mul_add_c(a,b,c0,c1,c2) \\
47 t1=LBITS(a); t2=HBITS(a); \\
48 bl=LBITS(b); bh=HBITS(b); \\
49 mul64(t1,t2,bl,bh); \\
50 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
51 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
52
53#define mul_add_c2(a,b,c0,c1,c2) \\
54 t1=LBITS(a); t2=HBITS(a); \\
55 bl=LBITS(b); bh=HBITS(b); \\
56 mul64(t1,t2,bl,bh); \\
57 if (t2 & BN_TBIT) c2++; \\
58 t2=(t2+t2)&BN_MASK2; \\
59 if (t1 & BN_TBIT) t2++; \\
60 t1=(t1+t1)&BN_MASK2; \\
61 c0=(c0+t1)&BN_MASK2; \\
62 if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \\
63 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
64
65#define sqr_add_c(a,i,c0,c1,c2) \\
66 sqr64(t1,t2,(a)[i]); \\
67 c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \\
68 c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
69
70#define sqr_add_c2(a,i,j,c0,c1,c2) \\
71 mul_add_c2((a)[i],(a)[j],c0,c1,c2)
72#endif
73
74void bn_mul_comba${num}(r,a,b)
75BN_ULONG *r,*a,*b;
76 {
77#ifdef BN_LLONG
78 BN_ULLONG t;
79#else
80 BN_ULONG bl,bh;
81#endif
82 BN_ULONG t1,t2;
83 BN_ULONG c1,c2,c3;
84
85EOF
86$ret=&combas_mul("r","a","b",$num,"c1","c2","c3");
87printf <<"EOF";
88 }
89
90void bn_mul_comba${num2}(r,a,b)
91BN_ULONG *r,*a,*b;
92 {
93#ifdef BN_LLONG
94 BN_ULLONG t;
95#else
96 BN_ULONG bl,bh;
97#endif
98 BN_ULONG t1,t2;
99 BN_ULONG c1,c2,c3;
100
101EOF
102$ret=&combas_mul("r","a","b",$num2,"c1","c2","c3");
103printf <<"EOF";
104 }
105
106void bn_sqr_comba${num}(r,a)
107BN_ULONG *r,*a;
108 {
109#ifdef BN_LLONG
110 BN_ULLONG t,tt;
111#else
112 BN_ULONG bl,bh;
113#endif
114 BN_ULONG t1,t2;
115 BN_ULONG c1,c2,c3;
116
117EOF
118$ret=&combas_sqr("r","a",$num,"c1","c2","c3");
119printf <<"EOF";
120 }
121
122void bn_sqr_comba${num2}(r,a)
123BN_ULONG *r,*a;
124 {
125#ifdef BN_LLONG
126 BN_ULLONG t,tt;
127#else
128 BN_ULONG bl,bh;
129#endif
130 BN_ULONG t1,t2;
131 BN_ULONG c1,c2,c3;
132
133EOF
134$ret=&combas_sqr("r","a",$num2,"c1","c2","c3");
135printf <<"EOF";
136 }
137EOF
138
139sub bn_str
140 {
141 local($var,$val)=@_;
142 print "\t$var=$val;\n";
143 }
144
145sub bn_ary
146 {
147 local($var,$idx)=@_;
148 return("${var}[$idx]");
149 }
150
151sub bn_clr
152 {
153 local($var)=@_;
154
155 print "\t$var=0;\n";
156 }
157
158sub bn_mad
159 {
160 local($a,$b,$c0,$c1,$c2,$num)=@_;
161
162 if ($num == 2)
163 { printf("\tmul_add_c2($a,$b,$c0,$c1,$c2);\n"); }
164 else
165 { printf("\tmul_add_c($a,$b,$c0,$c1,$c2);\n"); }
166 }
167
168sub bn_sad
169 {
170 local($a,$i,$j,$c0,$c1,$c2,$num)=@_;
171
172 if ($num == 2)
173 { printf("\tsqr_add_c2($a,$i,$j,$c0,$c1,$c2);\n"); }
174 else
175 { printf("\tsqr_add_c($a,$i,$c0,$c1,$c2);\n"); }
176 }
177
178sub combas_mul
179 {
180 local($r,$a,$b,$num,$c0,$c1,$c2)=@_;
181 local($i,$as,$ae,$bs,$be,$ai,$bi);
182 local($tot,$end);
183
184 $as=0;
185 $ae=0;
186 $bs=0;
187 $be=0;
188 $tot=$num+$num-1;
189 &bn_clr($c0);
190 &bn_clr($c1);
191 for ($i=0; $i<$tot; $i++)
192 {
193 $ai=$as;
194 $bi=$bs;
195 $end=$be+1;
196 @numa=@numb=();
197
198#print "($as $ae) ($bs $be) $bs -> $end [$i $num]\n";
199 for ($j=$bs; $j<$end; $j++)
200 {
201 push(@numa,$ai);
202 push(@numb,$bi);
203 $ai--;
204 $bi++;
205 }
206
207 if ($i & 1)
208 {
209 @numa=reverse(@numa);
210 @numb=reverse(@numb);
211 }
212
213 &bn_clr($c2);
214 for ($j=0; $j<=$#numa; $j++)
215 {
216 &bn_mad(&bn_ary($a,$numa[$j]),
217 &bn_ary($b,$numb[$j]),$c0,$c1,$c2,1);
218 }
219 &bn_str(&bn_ary($r,$i),$c0);
220 ($c0,$c1,$c2)=($c1,$c2,$c0);
221
222 $as++ if ($i < ($num-1));
223 $ae++ if ($i >= ($num-1));
224
225 $bs++ if ($i >= ($num-1));
226 $be++ if ($i < ($num-1));
227 }
228 &bn_str(&bn_ary($r,$i),$c0);
229 }
230
231sub combas_sqr
232 {
233 local($r,$a,$num,$c0,$c1,$c2)=@_;
234 local($i,$as,$ae,$bs,$be,$ai,$bi);
235 local($b,$tot,$end,$half);
236
237 $b=$a;
238 $as=0;
239 $ae=0;
240 $bs=0;
241 $be=0;
242 $tot=$num+$num-1;
243 &bn_clr($c0);
244 &bn_clr($c1);
245 for ($i=0; $i<$tot; $i++)
246 {
247 $ai=$as;
248 $bi=$bs;
249 $end=$be+1;
250 @numa=@numb=();
251
252#print "($as $ae) ($bs $be) $bs -> $end [$i $num]\n";
253 for ($j=$bs; $j<$end; $j++)
254 {
255 push(@numa,$ai);
256 push(@numb,$bi);
257 $ai--;
258 $bi++;
259 last if ($ai < $bi);
260 }
261 if (!($i & 1))
262 {
263 @numa=reverse(@numa);
264 @numb=reverse(@numb);
265 }
266
267 &bn_clr($c2);
268 for ($j=0; $j <= $#numa; $j++)
269 {
270 if ($numa[$j] == $numb[$j])
271 {&bn_sad($a,$numa[$j],$numb[$j],$c0,$c1,$c2,1);}
272 else
273 {&bn_sad($a,$numa[$j],$numb[$j],$c0,$c1,$c2,2);}
274 }
275 &bn_str(&bn_ary($r,$i),$c0);
276 ($c0,$c1,$c2)=($c1,$c2,$c0);
277
278 $as++ if ($i < ($num-1));
279 $ae++ if ($i >= ($num-1));
280
281 $bs++ if ($i >= ($num-1));
282 $be++ if ($i < ($num-1));
283 }
284 &bn_str(&bn_ary($r,$i),$c0);
285 }
diff --git a/src/lib/libssl/src/crypto/bn/d.c b/src/lib/libssl/src/crypto/bn/d.c
index ced2291b25..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/d.c
+++ b/src/lib/libssl/src/crypto/bn/d.c
@@ -1,72 +0,0 @@
1#include <stdio.h>
2#include <openssl/bio.h>
3#include "bn_lcl.h"
4
5#define SIZE_A (100*4+4)
6#define SIZE_B (13*4)
7
8main(argc,argv)
9int argc;
10char *argv[];
11 {
12 BN_CTX ctx;
13 BN_RECP_CTX recp;
14 BIGNUM a,b,dd,d,r,rr,t,l;
15 int i;
16
17 MemCheck_start();
18 MemCheck_on();
19 BN_CTX_init(&ctx);
20 BN_RECP_CTX_init(&recp);
21
22 BN_init(&r);
23 BN_init(&rr);
24 BN_init(&d);
25 BN_init(&dd);
26 BN_init(&a);
27 BN_init(&b);
28
29 {
30 BN_rand(&a,SIZE_A,0,0);
31 BN_rand(&b,SIZE_B,0,0);
32
33 a.neg=1;
34 BN_RECP_CTX_set(&recp,&b,&ctx);
35
36 BN_print_fp(stdout,&a); printf(" a\n");
37 BN_print_fp(stdout,&b); printf(" b\n");
38
39 BN_print_fp(stdout,&recp.N); printf(" N\n");
40 BN_print_fp(stdout,&recp.Nr); printf(" Nr num_bits=%d\n",recp.num_bits);
41
42 BN_div_recp(&r,&d,&a,&recp,&ctx);
43
44for (i=0; i<300; i++)
45 BN_div(&rr,&dd,&a,&b,&ctx);
46
47 BN_print_fp(stdout,&r); printf(" div recp\n");
48 BN_print_fp(stdout,&rr); printf(" div\n");
49 BN_print_fp(stdout,&d); printf(" rem recp\n");
50 BN_print_fp(stdout,&dd); printf(" rem\n");
51 }
52 BN_CTX_free(&ctx);
53 BN_RECP_CTX_free(&recp);
54
55 BN_free(&r);
56 BN_free(&rr);
57 BN_free(&d);
58 BN_free(&dd);
59 BN_free(&a);
60 BN_free(&b);
61
62 {
63 BIO *out;
64
65 if ((out=BIO_new(BIO_s_file())) != NULL)
66 BIO_set_fp(out,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
67
68 CRYPTO_mem_leaks(out);
69 BIO_free(out);
70 }
71
72 }
diff --git a/src/lib/libssl/src/crypto/bn/divtest.c b/src/lib/libssl/src/crypto/bn/divtest.c
new file mode 100644
index 0000000000..13ba86e3c4
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/divtest.c
@@ -0,0 +1,41 @@
1#include <openssl/bn.h>
2#include <openssl/rand.h>
3
4static int rand(n)
5{
6 unsigned char x[2];
7 RAND_pseudo_bytes(x,2);
8 return (x[0] + 2*x[1]);
9}
10
11static void bug(char *m, BIGNUM *a, BIGNUM *b)
12{
13 printf("%s!\na=",m);
14 BN_print_fp(stdout, a);
15 printf("\nb=");
16 BN_print_fp(stdout, b);
17 printf("\n");
18 fflush(stdout);
19}
20
21main()
22{
23 BIGNUM *a=BN_new(), *b=BN_new(), *c=BN_new(), *d=BN_new(),
24 *C=BN_new(), *D=BN_new();
25 BN_RECP_CTX *recp=BN_RECP_CTX_new();
26 BN_CTX *ctx=BN_CTX_new();
27
28 for(;;) {
29 BN_pseudo_rand(a,rand(),0,0);
30 BN_pseudo_rand(b,rand(),0,0);
31 if (BN_is_zero(b)) continue;
32
33 BN_RECP_CTX_set(recp,b,ctx);
34 if (BN_div(C,D,a,b,ctx) != 1)
35 bug("BN_div failed",a,b);
36 if (BN_div_recp(c,d,a,recp,ctx) != 1)
37 bug("BN_div_recp failed",a,b);
38 else if (BN_cmp(c,C) != 0 || BN_cmp(c,C) != 0)
39 bug("mismatch",a,b);
40 }
41}
diff --git a/src/lib/libssl/src/crypto/bn/exp.c b/src/lib/libssl/src/crypto/bn/exp.c
index ec443459d8..4865b0ef74 100644
--- a/src/lib/libssl/src/crypto/bn/exp.c
+++ b/src/lib/libssl/src/crypto/bn/exp.c
@@ -1,3 +1,5 @@
1/* unused */
2
1#include <stdio.h> 3#include <stdio.h>
2#include <openssl/tmdiff.h> 4#include <openssl/tmdiff.h>
3#include "bn_lcl.h" 5#include "bn_lcl.h"
diff --git a/src/lib/libssl/src/crypto/bn/expspeed.c b/src/lib/libssl/src/crypto/bn/expspeed.c
index 3656d5bb4c..2044ab9bff 100644
--- a/src/lib/libssl/src/crypto/bn/expspeed.c
+++ b/src/lib/libssl/src/crypto/bn/expspeed.c
@@ -1,3 +1,5 @@
1/* unused */
2
1/* crypto/bn/expspeed.c */ 3/* crypto/bn/expspeed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 4/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 5 * All rights reserved.
diff --git a/src/lib/libssl/src/crypto/bn/exptest.c b/src/lib/libssl/src/crypto/bn/exptest.c
index 9e4ae91d20..3e86f2ea0e 100644
--- a/src/lib/libssl/src/crypto/bn/exptest.c
+++ b/src/lib/libssl/src/crypto/bn/exptest.c
@@ -69,6 +69,8 @@
69 69
70#define NUM_BITS (BN_BITS*2) 70#define NUM_BITS (BN_BITS*2)
71 71
72static const char rnd_seed[] = "string to make the random number generator think it has entropy";
73
72int main(int argc, char *argv[]) 74int main(int argc, char *argv[])
73 { 75 {
74 BN_CTX *ctx; 76 BN_CTX *ctx;
@@ -77,6 +79,10 @@ int main(int argc, char *argv[])
77 unsigned char c; 79 unsigned char c;
78 BIGNUM *r_mont,*r_recp,*r_simple,*a,*b,*m; 80 BIGNUM *r_mont,*r_recp,*r_simple,*a,*b,*m;
79 81
82 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
83 * even check its return value
84 * (which we should) */
85
80 ERR_load_BN_strings(); 86 ERR_load_BN_strings();
81 87
82 ctx=BN_CTX_new(); 88 ctx=BN_CTX_new();
@@ -160,7 +166,16 @@ int main(int argc, char *argv[])
160 exit(1); 166 exit(1);
161 } 167 }
162 } 168 }
169 BN_free(r_mont);
170 BN_free(r_recp);
171 BN_free(r_simple);
172 BN_free(a);
173 BN_free(b);
174 BN_free(m);
175 BN_CTX_free(ctx);
176 ERR_remove_state(0);
163 CRYPTO_mem_leaks(out); 177 CRYPTO_mem_leaks(out);
178 BIO_free(out);
164 printf(" done\n"); 179 printf(" done\n");
165 exit(0); 180 exit(0);
166err: 181err:
diff --git a/src/lib/libssl/src/crypto/bn/new b/src/lib/libssl/src/crypto/bn/new
index 285d506f19..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/new
+++ b/src/lib/libssl/src/crypto/bn/new
@@ -1,23 +0,0 @@
1void BN_RECP_CTX_init(BN_RECP_CTX *recp);
2BN_RECP_CTX *BN_RECP_CTX_new();
3void BN_RECP_CTX_free(BN_RECP_CTX *recp);
4int BN_RECP_CTX_set(BN_RECP_CTX *recp,BIGNUM *div,BN_CTX *ctx);
5
6int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
7 BN_RECP_CTX *recp,BN_CTX *ctx);
8
9int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d,
10 BN_RECP_CTX *recp, BN_CTX *ctx);
11int BN_mod_recp(BIGNUM *rem, BIGNUM *m, BIGNUM *d,
12 BN_RECP_CTX *recp, BN_CTX *ctx);
13int BN_mod_mul_recp(BIGNUM *ret,BIGNUM *a,BIGNUM *b,BIGNUM *m
14
15int BN_mod_exp_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *p,
16 BN_MONT_CTX *m_ctx,BN_CTX *ctx);
17int BN_mod_exp2_montgomery(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2,
18 BIGNUM *p2,BN_MONT_CTX *m_ctx,BN_CTX *ctx);
19
20
21bn_div64 -> bn_div_words
22
23
diff --git a/src/lib/libssl/src/crypto/bn/old/b_sqr.c b/src/lib/libssl/src/crypto/bn/old/b_sqr.c
index 715cb1c8ab..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/b_sqr.c
+++ b/src/lib/libssl/src/crypto/bn/old/b_sqr.c
@@ -1,199 +0,0 @@
1/* crypto/bn/bn_mul.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 "bn_lcl.h"
62
63static int bn_mm(BIGNUM *m,BIGNUM *A,BIGNUM *B, BIGNUM *sk,BN_CTX *ctx);
64
65/* r must be different to a and b */
66/* int BN_mmul(r, a, b) */
67int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b)
68 {
69 BN_ULONG *ap,*bp,*rp;
70 BIGNUM *sk;
71 int i,n,ret;
72 int max,al,bl;
73 BN_CTX ctx;
74
75 bn_check_top(a);
76 bn_check_top(b);
77
78 al=a->top;
79 bl=b->top;
80 if ((al == 0) || (bl == 0))
81 {
82 r->top=0;
83 return(1);
84 }
85#ifdef BN_MUL_DEBUG
86printf("BN_mul(%d,%d)\n",a->top,b->top);
87#endif
88
89 if ( (bn_limit_bits > 0) &&
90 (bl > bn_limit_num) && (al > bn_limit_num))
91 {
92 n=(BN_num_bits_word(al|bl)-bn_limit_bits);
93 n*=2;
94 sk=(BIGNUM *)Malloc(sizeof(BIGNUM)*n);
95 memset(sk,0,sizeof(BIGNUM)*n);
96 memset(&ctx,0,sizeof(ctx));
97
98 ret=bn_mm(r,a,b,&(sk[0]),&ctx);
99 for (i=0; i<n; i+=2)
100 {
101 BN_clear_free(&sk[i]);
102 BN_clear_free(&sk[i+1]);
103 }
104 Free(sk);
105 return(ret);
106 }
107
108 max=(al+bl);
109 if (bn_wexpand(r,max) == NULL) return(0);
110 r->top=max;
111 r->neg=a->neg^b->neg;
112 ap=a->d;
113 bp=b->d;
114 rp=r->d;
115
116 rp[al]=bn_mul_words(rp,ap,al,*(bp++));
117 rp++;
118 for (i=1; i<bl; i++)
119 {
120 rp[al]=bn_mul_add_words(rp,ap,al,*(bp++));
121 rp++;
122 }
123 if ((max > 0) && (r->d[max-1] == 0)) r->top--;
124 return(1);
125 }
126
127
128#define ahal (sk[0])
129#define blbh (sk[1])
130
131/* r must be different to a and b */
132int bn_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BIGNUM *sk, BN_CTX *ctx)
133 {
134 int n,num,sqr=0;
135 int an,bn;
136 BIGNUM ah,al,bh,bl;
137
138 an=A->top;
139 bn=B->top;
140#ifdef BN_MUL_DEBUG
141printf("bn_mm(%d,%d)\n",A->top,B->top);
142#endif
143
144 if (A == B) sqr=1;
145 num=(an>bn)?an:bn;
146 n=(num+1)/2;
147 /* Are going to now chop things into 'num' word chunks. */
148
149 BN_init(&ah);
150 BN_init(&al);
151 BN_init(&bh);
152 BN_init(&bl);
153
154 bn_set_low (&al,A,n);
155 bn_set_high(&ah,A,n);
156 bn_set_low (&bl,B,n);
157 bn_set_high(&bh,B,n);
158
159 BN_sub(&ahal,&ah,&al);
160 BN_sub(&blbh,&bl,&bh);
161
162 if (num <= (bn_limit_num+bn_limit_num))
163 {
164 BN_mul(m,&ahal,&blbh);
165 if (sqr)
166 {
167 BN_sqr(&ahal,&al,ctx);
168 BN_sqr(&blbh,&ah,ctx);
169 }
170 else
171 {
172 BN_mul(&ahal,&al,&bl);
173 BN_mul(&blbh,&ah,&bh);
174 }
175 }
176 else
177 {
178 bn_mm(m,&ahal,&blbh,&(sk[2]),ctx);
179 bn_mm(&ahal,&al,&bl,&(sk[2]),ctx);
180 bn_mm(&blbh,&ah,&bh,&(sk[2]),ctx);
181 }
182
183 BN_add(m,m,&ahal);
184 BN_add(m,m,&blbh);
185
186 BN_lshift(m,m,n*BN_BITS2);
187 BN_lshift(&blbh,&blbh,n*BN_BITS2*2);
188
189 BN_add(m,m,&ahal);
190 BN_add(m,m,&blbh);
191
192 m->neg=A->neg^B->neg;
193 return(1);
194 }
195#undef ahal (sk[0])
196#undef blbh (sk[1])
197
198#include "bn_low.c"
199#include "bn_high.c"
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_com.c b/src/lib/libssl/src/crypto/bn/old/bn_com.c
index 7666b2304c..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_com.c
+++ b/src/lib/libssl/src/crypto/bn/old/bn_com.c
@@ -1,90 +0,0 @@
1/* crypto/bn/bn_mulw.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 "bn_lcl.h"
62
63#ifdef BN_LLONG
64
65ab
6612
67 a2 b2
68a1 b1
69
70abc
71123
72 a3 b3 c3
73 a2 b2 c2
74a1 b1 c1
75
76abcd
771234
78 a4 b4 c4 d4
79 a3 b3 c3 d3
80 a2 b2 c2 d2
81a1 b1 c1 d1
82
83abcde
8401234
85 a5 b5 c5 d5 e5
86 a4 b4 c4 d4 e4
87 a3 b3 c3 d3 e3
88 a2 b2 c2 d2 e2
89 a1 b1 c1 d1 e1
90a0 b0 c0 d0 e0
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_high.c b/src/lib/libssl/src/crypto/bn/old/bn_high.c
index 763bcb605b..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_high.c
+++ b/src/lib/libssl/src/crypto/bn/old/bn_high.c
@@ -1,135 +0,0 @@
1#include <stdio.h>
2#include "cryptlib.h"
3#include "bn_lcl.h"
4
5#undef BN_MUL_HIGH_DEBUG
6
7#ifdef BN_MUL_HIGH_DEBUG
8#define debug_BN_print(a,b,c) BN_print_fp(a,b); printf(c);
9#else
10#define debug_BN_print(a,b,c)
11#endif
12
13int BN_mul_high(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *low, int words);
14
15#undef t1
16#undef t2
17
18int BN_mul_high(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *low, int words)
19 {
20 int w2,borrow=0,full=0;
21 BIGNUM t1,t2,t3,h,ah,al,bh,bl,m,s0,s1;
22 BN_ULONG ul1,ul2;
23
24 BN_mul(r,a,b);
25 BN_rshift(r,r,words*BN_BITS2);
26 return(1);
27
28 w2=(words+1)/2;
29
30#ifdef BN_MUL_HIGH_DEBUG
31fprintf(stdout,"words=%d w2=%d\n",words,w2);
32#endif
33debug_BN_print(stdout,a," a\n");
34debug_BN_print(stdout,b," b\n");
35debug_BN_print(stdout,low," low\n");
36 BN_init(&al); BN_init(&ah);
37 BN_init(&bl); BN_init(&bh);
38 BN_init(&t1); BN_init(&t2); BN_init(&t3);
39 BN_init(&s0); BN_init(&s1);
40 BN_init(&h); BN_init(&m);
41
42 bn_set_low (&al,a,w2);
43 bn_set_high(&ah,a,w2);
44 bn_set_low (&bl,b,w2);
45 bn_set_high(&bh,b,w2);
46
47 bn_set_low(&s0,low,w2);
48 bn_set_high(&s1,low,w2);
49
50debug_BN_print(stdout,&al," al\n");
51debug_BN_print(stdout,&ah," ah\n");
52debug_BN_print(stdout,&bl," bl\n");
53debug_BN_print(stdout,&bh," bh\n");
54debug_BN_print(stdout,&s0," s0\n");
55debug_BN_print(stdout,&s1," s1\n");
56
57 /* Calculate (al-ah)*(bh-bl) */
58 BN_sub(&t1,&al,&ah);
59 BN_sub(&t2,&bh,&bl);
60 BN_mul(&m,&t1,&t2);
61
62 /* Calculate ah*bh */
63 BN_mul(&h,&ah,&bh);
64
65 /* s0 == low(al*bl)
66 * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl)
67 * We know s0 and s1 so the only unknown is high(al*bl)
68 * high(al*bl) == s1 - low(ah*bh+(al-ah)*(bh-bl)+s0)
69 */
70 BN_add(&m,&m,&h);
71 BN_add(&t2,&m,&s0);
72
73debug_BN_print(stdout,&t2," middle value\n");
74
75 /* Quick and dirty mask off of high words */
76 if (w2 < t2.top) t2.top=w2;
77#if 0
78 bn_set_low(&t3,&t2,w2);
79#endif
80
81debug_BN_print(stdout,&t2," low middle value\n");
82 BN_sub(&t1,&s1,&t2);
83
84 if (t1.neg)
85 {
86debug_BN_print(stdout,&t1," before\n");
87 BN_zero(&t2);
88 BN_set_bit(&t2,w2*BN_BITS2);
89 BN_add(&t1,&t2,&t1);
90 /* BN_mask_bits(&t1,w2*BN_BITS2); */
91 /* if (words < t1.top) t1.top=words; */
92debug_BN_print(stdout,&t1," after\n");
93 borrow=1;
94 }
95
96/* XXXXX SPEED THIS UP */
97 /* al*bl == high(al*bl)<<words+s0 */
98 BN_lshift(&t1,&t1,w2*BN_BITS2);
99 BN_add(&t1,&t1,&s0);
100 if (w2*2 < t1.top) t1.top=w2*2; /* This should not happen? */
101
102 /* We now have
103 * al*bl - t1
104 * (al-ah)*(bh-bl)+ah*bh - m
105 * ah*bh - h
106 */
107#if 0
108 BN_add(&m,&m,&t1);
109debug_BN_print(stdout,&t1," s10\n");
110debug_BN_print(stdout,&m," s21\n");
111debug_BN_print(stdout,&h," s32\n");
112 BN_lshift(&m,&m,w2*BN_BITS2);
113 BN_lshift(&h,&h,w2*2*BN_BITS2);
114 BN_add(r,&m,&t1);
115 BN_add(r,r,&h);
116 BN_rshift(r,r,w2*2*BN_BITS2);
117#else
118 BN_add(&m,&m,&t1); /* Do a cmp then +1 if needed? */
119 bn_set_high(&t3,&t1,w2);
120 BN_add(&m,&m,&t3);
121 bn_set_high(&t3,&m,w2);
122 BN_add(r,&h,&t3);
123#endif
124
125#ifdef BN_MUL_HIGH_DEBUG
126printf("carry=%d\n",borrow);
127#endif
128debug_BN_print(stdout,r," ret\n");
129 BN_free(&t1); BN_free(&t2);
130 BN_free(&m); BN_free(&h);
131 return(1);
132 }
133
134
135
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_ka.c b/src/lib/libssl/src/crypto/bn/old/bn_ka.c
index 378c94dc5a..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_ka.c
+++ b/src/lib/libssl/src/crypto/bn/old/bn_ka.c
@@ -1,567 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <strings.h>
4#include "bn_lcl.h"
5
6/* r is 2*n2 words in size,
7 * a and b are both n2 words in size.
8 * n2 must be a power of 2.
9 * We multiply and return the result.
10 * t must be 2*n2 words in size
11 * We calulate
12 * a[0]*b[0]
13 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
14 * a[1]*b[1]
15 */
16void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
17 BN_ULONG *t)
18 {
19 int n=n2/2;
20 int neg,zero,c1,c2;
21 BN_ULONG ln,lo,*p;
22
23#ifdef BN_COUNT
24printf(" bn_mul_recursive %d * %d\n",n2,n2);
25#endif
26 if (n2 <= 8)
27 {
28 if (n2 == 8)
29 bn_mul_comba8(r,a,b);
30 else
31 bn_mul_normal(r,a,n2,b,n2);
32 return;
33 }
34
35 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
36 {
37 /* This should not happen */
38 /*abort(); */
39 bn_mul_normal(r,a,n2,b,n2);
40 return;
41 }
42 /* r=(a[0]-a[1])*(b[1]-b[0]) */
43 c1=bn_cmp_words(a,&(a[n]),n);
44 c2=bn_cmp_words(&(b[n]),b,n);
45 zero=neg=0;
46 switch (c1*3+c2)
47 {
48 case -4:
49 bn_sub_words(t, &(a[n]),a, n); /* - */
50 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
51 break;
52 case -3:
53 zero=1;
54 break;
55 case -2:
56 bn_sub_words(t, &(a[n]),a, n); /* - */
57 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */
58 neg=1;
59 break;
60 case -1:
61 case 0:
62 case 1:
63 zero=1;
64 break;
65 case 2:
66 bn_sub_words(t, a, &(a[n]),n); /* + */
67 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
68 neg=1;
69 break;
70 case 3:
71 zero=1;
72 break;
73 case 4:
74 bn_sub_words(t, a, &(a[n]),n);
75 bn_sub_words(&(t[n]),&(b[n]),b, n);
76 break;
77 }
78
79 if (n == 8)
80 {
81 if (!zero)
82 bn_mul_comba8(&(t[n2]),t,&(t[n]));
83 else
84 memset(&(t[n2]),0,8*sizeof(BN_ULONG));
85
86 bn_mul_comba8(r,a,b);
87 bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n]));
88 }
89 else
90 {
91 p= &(t[n2*2]);
92 if (!zero)
93 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
94 else
95 memset(&(t[n2]),0,n*sizeof(BN_ULONG));
96 bn_mul_recursive(r,a,b,n,p);
97 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p);
98 }
99
100 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
101 * r[10] holds (a[0]*b[0])
102 * r[32] holds (b[1]*b[1])
103 */
104
105 c1=bn_add_words(t,r,&(r[n2]),n2);
106
107 if (neg) /* if t[32] is negative */
108 {
109 c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
110 }
111 else
112 {
113 /* Might have a carry */
114 c1+=bn_add_words(&(t[n2]),&(t[n2]),t,n2);
115 }
116
117 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
118 * r[10] holds (a[0]*b[0])
119 * r[32] holds (b[1]*b[1])
120 * c1 holds the carry bits
121 */
122 c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
123 if (c1)
124 {
125 p= &(r[n+n2]);
126 lo= *p;
127 ln=(lo+c1)&BN_MASK2;
128 *p=ln;
129
130 /* The overflow will stop before we over write
131 * words we should not overwrite */
132 if (ln < c1)
133 {
134 do {
135 p++;
136 lo= *p;
137 ln=(lo+1)&BN_MASK2;
138 *p=ln;
139 } while (ln == 0);
140 }
141 }
142 }
143
144/* n+tn is the word length
145 * t needs to be n*4 is size, as does r */
146void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
147 int n, BN_ULONG *t)
148 {
149 int n2=n*2,i,j;
150 int c1;
151 BN_ULONG ln,lo,*p;
152
153#ifdef BN_COUNT
154printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n);
155#endif
156 if (n < 8)
157 {
158 i=tn+n;
159 bn_mul_normal(r,a,i,b,i);
160 return;
161 }
162
163 /* r=(a[0]-a[1])*(b[1]-b[0]) */
164 bn_sub_words(t, a, &(a[n]),n); /* + */
165 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */
166
167 if (n == 8)
168 {
169 bn_mul_comba8(&(t[n2]),t,&(t[n]));
170 bn_mul_comba8(r,a,b);
171 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn);
172 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2));
173 }
174 else
175 {
176 p= &(t[n2*2]);
177 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p);
178 bn_mul_recursive(r,a,b,n,p);
179 i=n/2;
180 /* If there is only a bottom half to the number,
181 * just do it */
182 j=tn-i;
183 if (j == 0)
184 {
185 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p);
186 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2));
187 }
188 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */
189 {
190 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]),
191 j,i,p);
192 memset(&(r[n2+tn*2]),0,
193 sizeof(BN_ULONG)*(n2-tn*2));
194 }
195 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */
196 {
197 memset(&(r[n2]),0,sizeof(BN_ULONG)*(tn*2));
198 for (;;)
199 {
200 i/=2;
201 if (i < tn)
202 {
203 bn_mul_part_recursive(&(r[n2]),
204 &(a[n]),&(b[n]),
205 tn-i,i,p);
206 break;
207 }
208 else if (i == tn)
209 {
210 bn_mul_recursive(&(r[n2]),
211 &(a[n]),&(b[n]),
212 i,p);
213 break;
214 }
215 }
216 }
217 }
218
219 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
220 * r[10] holds (a[0]*b[0])
221 * r[32] holds (b[1]*b[1])
222 */
223
224 c1=bn_add_words(t,r,&(r[n2]),n2);
225 c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
226
227 /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
228 * r[10] holds (a[0]*b[0])
229 * r[32] holds (b[1]*b[1])
230 * c1 holds the carry bits
231 */
232 c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
233 if (c1)
234 {
235 p= &(r[n+n2]);
236 lo= *p;
237 ln=(lo+c1)&BN_MASK2;
238 *p=ln;
239
240 /* The overflow will stop before we over write
241 * words we should not overwrite */
242 if (ln < c1)
243 {
244 do {
245 p++;
246 lo= *p;
247 ln=(lo+1)&BN_MASK2;
248 *p=ln;
249 } while (ln == 0);
250 }
251 }
252 }
253
254/* r is 2*n words in size,
255 * a and b are both n words in size.
256 * n must be a power of 2.
257 * We multiply and return the result.
258 * t must be 2*n words in size
259 * We calulate
260 * a[0]*b[0]
261 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
262 * a[1]*b[1]
263 */
264void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *t)
265 {
266 int n=n2/2;
267 int zero,c1;
268 BN_ULONG ln,lo,*p;
269
270#ifdef BN_COUNT
271printf(" bn_sqr_recursive %d * %d\n",n2,n2);
272#endif
273 if (n2 == 4)
274 {
275 bn_sqr_comba4(r,a);
276 return;
277 }
278 else if (n2 == 8)
279 {
280 bn_sqr_comba8(r,a);
281 return;
282 }
283 if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL)
284 {
285 bn_sqr_normal(r,a,n2,t);
286 return;
287 abort();
288 }
289 /* r=(a[0]-a[1])*(a[1]-a[0]) */
290 c1=bn_cmp_words(a,&(a[n]),n);
291 zero=0;
292 if (c1 > 0)
293 bn_sub_words(t,a,&(a[n]),n);
294 else if (c1 < 0)
295 bn_sub_words(t,&(a[n]),a,n);
296 else
297 zero=1;
298
299 /* The result will always be negative unless it is zero */
300
301 if (n == 8)
302 {
303 if (!zero)
304 bn_sqr_comba8(&(t[n2]),t);
305 else
306 memset(&(t[n2]),0,8*sizeof(BN_ULONG));
307
308 bn_sqr_comba8(r,a);
309 bn_sqr_comba8(&(r[n2]),&(a[n]));
310 }
311 else
312 {
313 p= &(t[n2*2]);
314 if (!zero)
315 bn_sqr_recursive(&(t[n2]),t,n,p);
316 else
317 memset(&(t[n2]),0,n*sizeof(BN_ULONG));
318 bn_sqr_recursive(r,a,n,p);
319 bn_sqr_recursive(&(r[n2]),&(a[n]),n,p);
320 }
321
322 /* t[32] holds (a[0]-a[1])*(a[1]-a[0]), it is negative or zero
323 * r[10] holds (a[0]*b[0])
324 * r[32] holds (b[1]*b[1])
325 */
326
327 c1=bn_add_words(t,r,&(r[n2]),n2);
328
329 /* t[32] is negative */
330 c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
331
332 /* t[32] holds (a[0]-a[1])*(a[1]-a[0])+(a[0]*a[0])+(a[1]*a[1])
333 * r[10] holds (a[0]*a[0])
334 * r[32] holds (a[1]*a[1])
335 * c1 holds the carry bits
336 */
337 c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
338 if (c1)
339 {
340 p= &(r[n+n2]);
341 lo= *p;
342 ln=(lo+c1)&BN_MASK2;
343 *p=ln;
344
345 /* The overflow will stop before we over write
346 * words we should not overwrite */
347 if (ln < c1)
348 {
349 do {
350 p++;
351 lo= *p;
352 ln=(lo+1)&BN_MASK2;
353 *p=ln;
354 } while (ln == 0);
355 }
356 }
357 }
358
359#if 1
360/* a and b must be the same size, which is n2.
361 * r needs to be n2 words and t needs to be n2*2
362 */
363void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
364 BN_ULONG *t)
365 {
366 int n=n2/2;
367
368#ifdef BN_COUNT
369printf(" bn_mul_low_recursive %d * %d\n",n2,n2);
370#endif
371
372 bn_mul_recursive(r,a,b,n,&(t[0]));
373 if (n > BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
374 {
375 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2]));
376 bn_add_words(&(r[n]),&(r[n]),&(t[0]),n);
377 bn_mul_low_recursive(&(t[0]),&(a[n]),&(b[0]),n,&(t[n2]));
378 bn_add_words(&(r[n]),&(r[n]),&(t[0]),n);
379 }
380 else
381 {
382 bn_mul_low_normal(&(t[0]),&(a[0]),&(b[n]),n);
383 bn_mul_low_normal(&(t[n]),&(a[n]),&(b[0]),n);
384 bn_add_words(&(r[n]),&(r[n]),&(t[0]),n);
385 bn_add_words(&(r[n]),&(r[n]),&(t[n]),n);
386 }
387 }
388
389/* a and b must be the same size, which is n2.
390 * r needs to be n2 words and t needs to be n2*2
391 * l is the low words of the output.
392 * t needs to be n2*3
393 */
394void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
395 BN_ULONG *t)
396 {
397 int j,i,n,c1,c2;
398 int neg,oneg,zero;
399 BN_ULONG ll,lc,*lp,*mp;
400
401#ifdef BN_COUNT
402printf(" bn_mul_high %d * %d\n",n2,n2);
403#endif
404 n=(n2+1)/2;
405
406 /* Calculate (al-ah)*(bh-bl) */
407 neg=zero=0;
408 c1=bn_cmp_words(&(a[0]),&(a[n]),n);
409 c2=bn_cmp_words(&(b[n]),&(b[0]),n);
410 switch (c1*3+c2)
411 {
412 case -4:
413 bn_sub_words(&(r[0]),&(a[n]),&(a[0]),n);
414 bn_sub_words(&(r[n]),&(b[0]),&(b[n]),n);
415 break;
416 case -3:
417 zero=1;
418 break;
419 case -2:
420 bn_sub_words(&(r[0]),&(a[n]),&(a[0]),n);
421 bn_sub_words(&(r[n]),&(b[n]),&(b[0]),n);
422 neg=1;
423 break;
424 case -1:
425 case 0:
426 case 1:
427 zero=1;
428 break;
429 case 2:
430 bn_sub_words(&(r[0]),&(a[0]),&(a[n]),n);
431 bn_sub_words(&(r[n]),&(b[0]),&(b[n]),n);
432 neg=1;
433 break;
434 case 3:
435 zero=1;
436 break;
437 case 4:
438 bn_sub_words(&(r[0]),&(a[0]),&(a[n]),n);
439 bn_sub_words(&(r[n]),&(b[n]),&(b[0]),n);
440 break;
441 }
442
443 oneg=neg;
444 /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */
445 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2]));
446 /* r[10] = (a[1]*b[1]) */
447 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2]));
448
449 /* s0 == low(al*bl)
450 * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl)
451 * We know s0 and s1 so the only unknown is high(al*bl)
452 * high(al*bl) == s1 - low(ah*bh+s0+(al-ah)*(bh-bl))
453 * high(al*bl) == s1 - (r[0]+l[0]+t[0])
454 */
455 if (l != NULL)
456 {
457 lp= &(t[n2+n]);
458 c1=bn_add_words(lp,&(r[0]),&(l[0]),n);
459 }
460 else
461 {
462 c1=0;
463 lp= &(r[0]);
464 }
465
466 if (neg)
467 neg=bn_sub_words(&(t[n2]),lp,&(t[0]),n);
468 else
469 {
470 bn_add_words(&(t[n2]),lp,&(t[0]),n);
471 neg=0;
472 }
473
474 if (l != NULL)
475 {
476 bn_sub_words(&(t[n2+n]),&(l[n]),&(t[n2]),n);
477 }
478 else
479 {
480 lp= &(t[n2+n]);
481 mp= &(t[n2]);
482 for (i=0; i<n; i++)
483 lp[i]=((~mp[i])+1)&BN_MASK2;
484 }
485
486 /* s[0] = low(al*bl)
487 * t[3] = high(al*bl)
488 * t[10] = (a[0]-a[1])*(b[1]-b[0]) neg is the sign
489 * r[10] = (a[1]*b[1])
490 */
491 /* R[10] = al*bl
492 * R[21] = al*bl + ah*bh + (a[0]-a[1])*(b[1]-b[0])
493 * R[32] = ah*bh
494 */
495 /* R[1]=t[3]+l[0]+r[0](+-)t[0] (have carry/borrow)
496 * R[2]=r[0]+t[3]+r[1](+-)t[1] (have carry/borrow)
497 * R[3]=r[1]+(carry/borrow)
498 */
499 if (l != NULL)
500 {
501 lp= &(t[n2]);
502 c1= bn_add_words(lp,&(t[n2+n]),&(l[0]),n);
503 }
504 else
505 {
506 lp= &(t[n2+n]);
507 c1=0;
508 }
509 c1+=bn_add_words(&(t[n2]),lp, &(r[0]),n);
510 if (oneg)
511 c1-=bn_sub_words(&(t[n2]),&(t[n2]),&(t[0]),n);
512 else
513 c1+=bn_add_words(&(t[n2]),&(t[n2]),&(t[0]),n);
514
515 c2 =bn_add_words(&(r[0]),&(r[0]),&(t[n2+n]),n);
516 c2+=bn_add_words(&(r[0]),&(r[0]),&(r[n]),n);
517 if (oneg)
518 c2-=bn_sub_words(&(r[0]),&(r[0]),&(t[n]),n);
519 else
520 c2+=bn_add_words(&(r[0]),&(r[0]),&(t[n]),n);
521
522 if (c1 != 0) /* Add starting at r[0], could be +ve or -ve */
523 {
524 i=0;
525 if (c1 > 0)
526 {
527 lc=c1;
528 do {
529 ll=(r[i]+lc)&BN_MASK2;
530 r[i++]=ll;
531 lc=(lc > ll);
532 } while (lc);
533 }
534 else
535 {
536 lc= -c1;
537 do {
538 ll=r[i];
539 r[i++]=(ll-lc)&BN_MASK2;
540 lc=(lc > ll);
541 } while (lc);
542 }
543 }
544 if (c2 != 0) /* Add starting at r[1] */
545 {
546 i=n;
547 if (c2 > 0)
548 {
549 lc=c2;
550 do {
551 ll=(r[i]+lc)&BN_MASK2;
552 r[i++]=ll;
553 lc=(lc > ll);
554 } while (lc);
555 }
556 else
557 {
558 lc= -c2;
559 do {
560 ll=r[i];
561 r[i++]=(ll-lc)&BN_MASK2;
562 lc=(lc > ll);
563 } while (lc);
564 }
565 }
566 }
567#endif
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_low.c b/src/lib/libssl/src/crypto/bn/old/bn_low.c
index cbc406751c..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_low.c
+++ b/src/lib/libssl/src/crypto/bn/old/bn_low.c
@@ -1,194 +0,0 @@
1/* crypto/bn/bn_mul.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 "bn_lcl.h"
62
63static int bn_mm_low(BIGNUM *m,BIGNUM *A,BIGNUM *B, int num,
64 BIGNUM *sk,BN_CTX *ctx);
65int BN_mul_low(BIGNUM *r, BIGNUM *a, BIGNUM *b,int words);
66
67/* r must be different to a and b */
68int BN_mul_low(BIGNUM *r, BIGNUM *a, BIGNUM *b, int num)
69 {
70 BN_ULONG *ap,*bp,*rp;
71 BIGNUM *sk;
72 int j,i,n,ret;
73 int max,al,bl;
74 BN_CTX ctx;
75
76 bn_check_top(a);
77 bn_check_top(b);
78
79#ifdef BN_MUL_DEBUG
80printf("BN_mul_low(%d,%d,%d)\n",a->top,b->top,num);
81#endif
82
83 al=a->top;
84 bl=b->top;
85 if ((al == 0) || (bl == 0))
86 {
87 r->top=0;
88 return(1);
89 }
90
91 if ((bn_limit_bits_low > 0) && (num > bn_limit_num_low))
92 {
93 n=BN_num_bits_word(num*2)-bn_limit_bits_low;
94 n*=2;
95 sk=(BIGNUM *)Malloc(sizeof(BIGNUM)*n);
96 memset(sk,0,sizeof(BIGNUM)*n);
97 memset(&ctx,0,sizeof(ctx));
98
99 ret=bn_mm_low(r,a,b,num,&(sk[0]),&ctx);
100 for (i=0; i<n; i+=2)
101 {
102 BN_clear_free(&sk[i]);
103 BN_clear_free(&sk[i+1]);
104 }
105 Free(sk);
106 return(ret);
107 }
108
109 max=(al+bl);
110 if (bn_wexpand(r,max) == NULL) return(0);
111 r->neg=a->neg^b->neg;
112 ap=a->d;
113 bp=b->d;
114 rp=r->d;
115 r->top=(max > num)?num:max;
116
117 rp[al]=bn_mul_words(rp,ap,al,*(bp++));
118 rp++;
119 j=bl;
120 for (i=1; i<j; i++)
121 {
122 if (al >= num--)
123 {
124 al--;
125 if (al <= 0) break;
126 }
127 rp[al]=bn_mul_add_words(rp,ap,al,*(bp++));
128 rp++;
129 }
130
131 while ((r->top > 0) && (r->d[r->top-1] == 0))
132 r->top--;
133 return(1);
134 }
135
136
137#define t1 (sk[0])
138#define t2 (sk[1])
139
140/* r must be different to a and b */
141int bn_mm_low(BIGNUM *m, BIGNUM *A, BIGNUM *B, int num, BIGNUM *sk,
142 BN_CTX *ctx)
143 {
144 int n; /* ,sqr=0; */
145 int an,bn;
146 BIGNUM ah,al,bh,bl;
147
148 bn_wexpand(m,num+3);
149 an=A->top;
150 bn=B->top;
151
152#ifdef BN_MUL_DEBUG
153printf("bn_mm_low(%d,%d,%d)\n",A->top,B->top,num);
154#endif
155
156 n=(num+1)/2;
157
158 BN_init(&ah); BN_init(&al); BN_init(&bh); BN_init(&bl);
159
160 bn_set_low( &al,A,n);
161 bn_set_high(&ah,A,n);
162 bn_set_low( &bl,B,n);
163 bn_set_high(&bh,B,n);
164
165 if (num <= (bn_limit_num_low+bn_limit_num_low))
166 {
167 BN_mul(m,&al,&bl);
168 BN_mul_low(&t1,&al,&bh,n);
169 BN_mul_low(&t2,&ah,&bl,n);
170 }
171 else
172 {
173 bn_mm(m ,&al,&bl,&(sk[2]),ctx);
174 bn_mm_low(&t1,&al,&bh,n,&(sk[2]),ctx);
175 bn_mm_low(&t2,&ah,&bl,n,&(sk[2]),ctx);
176 }
177
178 BN_add(&t1,&t1,&t2);
179
180 /* We will now do an evil hack instead of
181 * BN_lshift(&t1,&t1,n*BN_BITS2);
182 * BN_add(m,m,&t1);
183 * BN_mask_bits(m,num*BN_BITS2);
184 */
185 bn_set_high(&ah,m,n); ah.max=num+2;
186 BN_add(&ah,&ah,&t1);
187 m->top=num;
188
189 m->neg=A->neg^B->neg;
190 return(1);
191 }
192
193#undef t1 (sk[0])
194#undef t2 (sk[1])
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_m.c b/src/lib/libssl/src/crypto/bn/old/bn_m.c
index 522beb02bc..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_m.c
+++ b/src/lib/libssl/src/crypto/bn/old/bn_m.c
@@ -1,139 +0,0 @@
1/* crypto/bn/bn_m.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 "bn_lcl.h"
62
63#define limit_bits 5 /* 2^5, or 32 words */
64#define limit_num (1<<limit_bits)
65
66int BN_m(BIGNUM *r, BIGNUM *a, BIGNUM *b)
67 {
68 BIGNUM *sk;
69 int i,n;
70
71 n=(BN_num_bits_word(a->top|b->top)-limit_bits);
72 n*=2;
73 sk=(BIGNUM *)malloc(sizeof(BIGNUM)*n);
74 for (i=0; i<n; i++)
75 BN_init(&(sk[i]));
76
77 return(BN_mm(r,a,b,&(sk[0])));
78 }
79
80#define ahal (sk[0])
81#define blbh (sk[1])
82
83/* r must be different to a and b */
84int BN_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BIGNUM *sk)
85 {
86 int i,num,anum,bnum;
87 int an,bn;
88 BIGNUM ah,al,bh,bl;
89
90 an=A->top;
91 bn=B->top;
92 if ((an <= limit_num) || (bn <= limit_num))
93 {
94 return(BN_mul(m,A,B));
95 }
96
97 anum=(an>bn)?an:bn;
98 num=(anum)/2;
99
100 /* Are going to now chop things into 'num' word chunks. */
101 bnum=num*BN_BITS2;
102
103 BN_init(&ahal);
104 BN_init(&blbh);
105 BN_init(&ah);
106 BN_init(&al);
107 BN_init(&bh);
108 BN_init(&bl);
109
110 al.top=num;
111 al.d=A->d;
112 ah.top=A->top-num;
113 ah.d= &(A->d[num]);
114
115 bl.top=num;
116 bl.d=B->d;
117 bh.top=B->top-num;
118 bh.d= &(B->d[num]);
119
120 BN_sub(&ahal,&ah,&al);
121 BN_sub(&blbh,&bl,&bh);
122
123 BN_mm(m,&ahal,&blbh,&(sk[2]));
124 BN_mm(&ahal,&al,&bl,&(sk[2]));
125 BN_mm(&blbh,&ah,&bh,&(sk[2]));
126
127 BN_add(m,m,&ahal);
128 BN_add(m,m,&blbh);
129
130 BN_lshift(m,m,bnum);
131 BN_add(m,m,&ahal);
132
133 BN_lshift(&blbh,&blbh,bnum*2);
134 BN_add(m,m,&blbh);
135
136 m->neg=A->neg^B->neg;
137 return(1);
138 }
139
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_mul.c.works b/src/lib/libssl/src/crypto/bn/old/bn_mul.c.works
index 6d565d44a2..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_mul.c.works
+++ b/src/lib/libssl/src/crypto/bn/old/bn_mul.c.works
@@ -1,219 +0,0 @@
1/* crypto/bn/bn_mul.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 "bn_lcl.h"
62
63int bn_mm(BIGNUM *m,BIGNUM *A,BIGNUM *B, BIGNUM *sk,BN_CTX *ctx);
64
65/* r must be different to a and b */
66int BN_mul(r, a, b)
67BIGNUM *r;
68BIGNUM *a;
69BIGNUM *b;
70 {
71 BN_ULONG *ap,*bp,*rp;
72 BIGNUM *sk;
73 int i,n,ret;
74 int max,al,bl;
75 BN_CTX ctx;
76
77 bn_check_top(a);
78 bn_check_top(b);
79
80 al=a->top;
81 bl=b->top;
82 if ((al == 0) || (bl == 0))
83 {
84 r->top=0;
85 return(1);
86 }
87#ifdef BN_MUL_DEBUG
88printf("BN_mul(%d,%d)\n",a->top,b->top);
89#endif
90
91#ifdef BN_RECURSION
92 if ( (bn_limit_bits > 0) &&
93 (bl > bn_limit_num) && (al > bn_limit_num))
94 {
95 n=(BN_num_bits_word(al|bl)-bn_limit_bits);
96 n*=2;
97 sk=(BIGNUM *)Malloc(sizeof(BIGNUM)*n);
98 memset(sk,0,sizeof(BIGNUM)*n);
99 memset(&ctx,0,sizeof(ctx));
100
101 ret=bn_mm(r,a,b,&(sk[0]),&ctx);
102 for (i=0; i<n; i+=2)
103 {
104 BN_clear_free(&sk[i]);
105 BN_clear_free(&sk[i+1]);
106 }
107 Free(sk);
108 return(ret);
109 }
110#endif
111
112 max=(al+bl);
113 if (bn_wexpand(r,max) == NULL) return(0);
114 r->top=max;
115 r->neg=a->neg^b->neg;
116 ap=a->d;
117 bp=b->d;
118 rp=r->d;
119
120#ifdef BN_RECURSION
121 if ((al == bl) && (al == 8))
122 {
123 bn_mul_comba8(rp,ap,bp);
124 }
125 else
126#endif
127 {
128 rp[al]=bn_mul_words(rp,ap,al,*(bp++));
129 rp++;
130 for (i=1; i<bl; i++)
131 {
132 rp[al]=bn_mul_add_words(rp,ap,al,*(bp++));
133 rp++;
134 }
135 }
136 if ((max > 0) && (r->d[max-1] == 0)) r->top--;
137 return(1);
138 }
139
140#ifdef BN_RECURSION
141
142#define ahal (sk[0])
143#define blbh (sk[1])
144
145/* r must be different to a and b */
146int bn_mm(m, A, B, sk,ctx)
147BIGNUM *m,*A,*B;
148BIGNUM *sk;
149BN_CTX *ctx;
150 {
151 int n,num,sqr=0;
152 int an,bn;
153 BIGNUM ah,al,bh,bl;
154
155 an=A->top;
156 bn=B->top;
157#ifdef BN_MUL_DEBUG
158printf("bn_mm(%d,%d)\n",A->top,B->top);
159#endif
160
161 if (A == B) sqr=1;
162 num=(an>bn)?an:bn;
163 n=(num+1)/2;
164 /* Are going to now chop things into 'num' word chunks. */
165
166 BN_init(&ah);
167 BN_init(&al);
168 BN_init(&bh);
169 BN_init(&bl);
170
171 bn_set_low (&al,A,n);
172 bn_set_high(&ah,A,n);
173 bn_set_low (&bl,B,n);
174 bn_set_high(&bh,B,n);
175
176 BN_sub(&ahal,&ah,&al);
177 BN_sub(&blbh,&bl,&bh);
178
179 if (num <= (bn_limit_num+bn_limit_num))
180 {
181 BN_mul(m,&ahal,&blbh);
182 if (sqr)
183 {
184 BN_sqr(&ahal,&al,ctx);
185 BN_sqr(&blbh,&ah,ctx);
186 }
187 else
188 {
189 BN_mul(&ahal,&al,&bl);
190 BN_mul(&blbh,&ah,&bh);
191 }
192 }
193 else
194 {
195 bn_mm(m,&ahal,&blbh,&(sk[2]),ctx);
196 bn_mm(&ahal,&al,&bl,&(sk[2]),ctx);
197 bn_mm(&blbh,&ah,&bh,&(sk[2]),ctx);
198 }
199
200 BN_add(m,m,&ahal);
201 BN_add(m,m,&blbh);
202
203 BN_lshift(m,m,n*BN_BITS2);
204 BN_lshift(&blbh,&blbh,n*BN_BITS2*2);
205
206 BN_add(m,m,&ahal);
207 BN_add(m,m,&blbh);
208
209 m->neg=A->neg^B->neg;
210 return(1);
211 }
212#undef ahal (sk[0])
213#undef blbh (sk[1])
214
215#include "bn_low.c"
216#include "bn_high.c"
217#include "f.c"
218
219#endif
diff --git a/src/lib/libssl/src/crypto/bn/old/bn_wmul.c b/src/lib/libssl/src/crypto/bn/old/bn_wmul.c
index a467b2f17a..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/bn_wmul.c
+++ b/src/lib/libssl/src/crypto/bn/old/bn_wmul.c
@@ -1,173 +0,0 @@
1#include <stdio.h>
2#include "bn_lcl.h"
3
4#if 1
5
6int bn_mull(BIGNUM *r,BIGNUM *a,BIGNUM *b, BN_CTX *ctx);
7
8int bn_mull(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
9 {
10 int top,i,j,k,al,bl;
11 BIGNUM *t;
12
13#ifdef BN_COUNT
14printf("bn_mull %d * %d\n",a->top,b->top);
15#endif
16
17 bn_check_top(a);
18 bn_check_top(b);
19 bn_check_top(r);
20
21 al=a->top;
22 bl=b->top;
23 r->neg=a->neg^b->neg;
24
25 top=al+bl;
26 if ((al < 4) || (bl < 4))
27 {
28 if (bn_wexpand(r,top) == NULL) return(0);
29 r->top=top;
30 bn_mul_normal(r->d,a->d,al,b->d,bl);
31 goto end;
32 }
33 else if (al == bl) /* A good start, they are the same size */
34 goto symetric;
35 else
36 {
37 i=(al-bl);
38 if ((i == 1) && !BN_get_flags(b,BN_FLG_STATIC_DATA))
39 {
40 bn_wexpand(b,al);
41 b->d[bl]=0;
42 bl++;
43 goto symetric;
44 }
45 else if ((i == -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA))
46 {
47 bn_wexpand(a,bl);
48 a->d[al]=0;
49 al++;
50 goto symetric;
51 }
52 }
53
54 /* asymetric and >= 4 */
55 if (bn_wexpand(r,top) == NULL) return(0);
56 r->top=top;
57 bn_mul_normal(r->d,a->d,al,b->d,bl);
58
59 if (0)
60 {
61 /* symetric and > 4 */
62symetric:
63 if (al == 4)
64 {
65 if (bn_wexpand(r,al*2) == NULL) return(0);
66 r->top=top;
67 bn_mul_comba4(r->d,a->d,b->d);
68 goto end;
69 }
70 if (al == 8)
71 {
72 if (bn_wexpand(r,al*2) == NULL) return(0);
73 r->top=top;
74 bn_mul_comba8(r->d,a->d,b->d);
75 goto end;
76 }
77 if (al <= BN_MULL_NORMAL_SIZE)
78 {
79 if (bn_wexpand(r,al*2) == NULL) return(0);
80 r->top=top;
81 bn_mul_normal(r->d,a->d,al,b->d,bl);
82 goto end;
83 }
84 /* 16 or larger */
85 j=BN_num_bits_word((BN_ULONG)al);
86 j=1<<(j-1);
87 k=j+j;
88 t= &(ctx->bn[ctx->tos]);
89 if (al == j) /* exact multiple */
90 {
91 bn_wexpand(t,k*2);
92 bn_wexpand(r,k*2);
93 bn_mul_recursive(r->d,a->d,b->d,al,t->d);
94 }
95 else
96 {
97 bn_wexpand(a,k);
98 bn_wexpand(b,k);
99 bn_wexpand(t,k*4);
100 bn_wexpand(r,k*4);
101 for (i=a->top; i<k; i++)
102 a->d[i]=0;
103 for (i=b->top; i<k; i++)
104 b->d[i]=0;
105 bn_mul_part_recursive(r->d,a->d,b->d,al-j,j,t->d);
106 }
107 r->top=top;
108 }
109end:
110 bn_fix_top(r);
111 return(1);
112 }
113#endif
114
115void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
116 {
117 BN_ULONG *rr;
118
119#ifdef BN_COUNT
120printf(" bn_mul_normal %d * %d\n",na,nb);
121#endif
122
123 if (na < nb)
124 {
125 int itmp;
126 BN_ULONG *ltmp;
127
128 itmp=na; na=nb; nb=itmp;
129 ltmp=a; a=b; b=ltmp;
130
131 }
132 rr= &(r[na]);
133 rr[0]=bn_mul_words(r,a,na,b[0]);
134
135 for (;;)
136 {
137 if (--nb <= 0) return;
138 rr[1]=bn_mul_add_words(&(r[1]),a,na,b[1]);
139 if (--nb <= 0) return;
140 rr[2]=bn_mul_add_words(&(r[2]),a,na,b[2]);
141 if (--nb <= 0) return;
142 rr[3]=bn_mul_add_words(&(r[3]),a,na,b[3]);
143 if (--nb <= 0) return;
144 rr[4]=bn_mul_add_words(&(r[4]),a,na,b[4]);
145 rr+=4;
146 r+=4;
147 b+=4;
148 }
149 }
150
151#if 1
152void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
153 {
154#ifdef BN_COUNT
155printf(" bn_mul_low_normal %d * %d\n",n,n);
156#endif
157 bn_mul_words(r,a,n,b[0]);
158
159 for (;;)
160 {
161 if (--n <= 0) return;
162 bn_mul_add_words(&(r[1]),a,n,b[1]);
163 if (--n <= 0) return;
164 bn_mul_add_words(&(r[2]),a,n,b[2]);
165 if (--n <= 0) return;
166 bn_mul_add_words(&(r[3]),a,n,b[3]);
167 if (--n <= 0) return;
168 bn_mul_add_words(&(r[4]),a,n,b[4]);
169 r+=4;
170 b+=4;
171 }
172 }
173#endif
diff --git a/src/lib/libssl/src/crypto/bn/old/build b/src/lib/libssl/src/crypto/bn/old/build
index 8cd99e5f17..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/build
+++ b/src/lib/libssl/src/crypto/bn/old/build
@@ -1,3 +0,0 @@
1#!/bin/sh -x
2
3gcc -g -I../../include test.c -L../.. -lcrypto
diff --git a/src/lib/libssl/src/crypto/bn/old/info b/src/lib/libssl/src/crypto/bn/old/info
index 5ac99c3b23..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/info
+++ b/src/lib/libssl/src/crypto/bn/old/info
@@ -1,22 +0,0 @@
1Given A1A0 * B1B0 == S3S2S1S0
2
3S0= low(A0*B0)
4S1= low( (A1-A0)*(B0-B1)) +low( A1*B1) +high(A0*B0)
5S2= high((A1-A0)*(B0-B1)) +high(A1*B1) +low( A1*B1)
6S3= high(A1*B1);
7
8Assume we know S1 and S0, and can calulate A1*B1 and high((A1-A0)*(B0-B1))
9
10k0= S0 == low(A0*B0)
11k1= S1
12k2= low( A1*B1)
13k3= high(A1*B1)
14k4= high((A1-A0)*(B0-B1))
15
16k1= low((A1-A0)*(B0-B1)) +k2 +high(A0*B0)
17S2= k4 +k3 +k2
18S3= k3
19
20S1-k2= low((A1-A0)*(B0-B1)) +high(A0*B0)
21
22We potentially have a carry or a borrow from S1
diff --git a/src/lib/libssl/src/crypto/bn/old/test.works b/src/lib/libssl/src/crypto/bn/old/test.works
index 127c7b415d..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/old/test.works
+++ b/src/lib/libssl/src/crypto/bn/old/test.works
@@ -1,205 +0,0 @@
1#include <stdio.h>
2#include "cryptlib.h"
3#include "bn_lcl.h"
4
5#define SIZE 128
6
7#define BN_MONT_CTX_set bn_mcs
8#define BN_from_montgomery bn_fm
9#define BN_mod_mul_montgomery bn_mmm
10#undef BN_to_montgomery
11#define BN_to_montgomery(r,a,mont,ctx) bn_mmm(\
12 r,a,(mont)->RR,(mont),ctx)
13
14main()
15 {
16 BIGNUM prime,a,b,r,A,B,R;
17 BN_MONT_CTX *mont;
18 BN_CTX *ctx;
19 int i;
20
21 ctx=BN_CTX_new();
22 BN_init(&prime);
23 BN_init(&a); BN_init(&b); BN_init(&r);
24 BN_init(&A); BN_init(&B); BN_init(&R);
25
26 BN_generate_prime(&prime,SIZE,0,NULL,NULL,NULL,NULL);
27 BN_rand(&A,SIZE,1,0);
28 BN_rand(&B,SIZE,1,0);
29 BN_mod(&A,&A,&prime,ctx);
30 BN_mod(&B,&B,&prime,ctx);
31
32 mont=BN_MONT_CTX_new();
33 BN_MONT_CTX_set(mont,&prime,ctx);
34
35 BN_to_montgomery(&a,&A,mont,ctx);
36 BN_to_montgomery(&b,&B,mont,ctx);
37
38 BN_mul(&r,&a,&b);
39 BN_print_fp(stdout,&r); printf("\n");
40 BN_from_montgomery(&r,&r,mont,ctx);
41 BN_print_fp(stdout,&r); printf("\n");
42 BN_from_montgomery(&r,&r,mont,ctx);
43 BN_print_fp(stdout,&r); printf("\n");
44
45 BN_mod_mul(&R,&A,&B,&prime,ctx);
46
47 BN_print_fp(stdout,&a); printf("\n");
48 BN_print_fp(stdout,&b); printf("\n");
49 BN_print_fp(stdout,&prime); printf("\n");
50 BN_print_fp(stdout,&r); printf("\n\n");
51
52 BN_print_fp(stdout,&A); printf("\n");
53 BN_print_fp(stdout,&B); printf("\n");
54 BN_print_fp(stdout,&prime); printf("\n");
55 BN_print_fp(stdout,&R); printf("\n\n");
56
57 BN_mul(&r,&a,&b);
58 BN_print_fp(stdout,&r); printf(" <- BA*DC\n");
59 BN_copy(&A,&r);
60 i=SIZE/2;
61 BN_mask_bits(&A,i*2);
62// BN_print_fp(stdout,&A); printf(" <- low(BA*DC)\n");
63 bn_do_lower(&r,&a,&b,&A,i);
64// BN_print_fp(stdout,&r); printf(" <- low(BA*DC)\n");
65 }
66
67int bn_mul_low(r,a,b,low,i)
68BIGNUM *r,*a,*b,*low;
69int i;
70 {
71 int w;
72 BIGNUM Kh,Km,t1,t2,h,ah,al,bh,bl,l,m,s0,s1;
73
74 BN_init(&Kh); BN_init(&Km); BN_init(&t1); BN_init(&t2); BN_init(&l);
75 BN_init(&ah); BN_init(&al); BN_init(&bh); BN_init(&bl); BN_init(&h);
76 BN_init(&m); BN_init(&s0); BN_init(&s1);
77
78 BN_copy(&al,a); BN_mask_bits(&al,i); BN_rshift(&ah,a,i);
79 BN_copy(&bl,b); BN_mask_bits(&bl,i); BN_rshift(&bh,b,i);
80
81
82 BN_sub(&t1,&al,&ah);
83 BN_sub(&t2,&bh,&bl);
84 BN_mul(&m,&t1,&t2);
85 BN_mul(&h,&ah,&bh);
86
87 BN_copy(&s0,low); BN_mask_bits(&s0,i);
88 BN_rshift(&s1,low,i);
89
90 BN_add(&t1,&h,&m);
91 BN_add(&t1,&t1,&s0);
92
93 BN_copy(&t2,&t1); BN_mask_bits(&t2,i);
94 BN_sub(&t1,&s1,&t2);
95 BN_lshift(&t1,&t1,i);
96 BN_add(&t1,&t1,&s0);
97 if (t1.neg)
98 {
99 BN_lshift(&t2,BN_value_one(),i*2);
100 BN_add(&t1,&t2,&t1);
101 BN_mask_bits(&t1,i*2);
102 }
103
104 BN_free(&Kh); BN_free(&Km); BN_free(&t1); BN_free(&t2);
105 BN_free(&ah); BN_free(&al); BN_free(&bh); BN_free(&bl);
106 }
107
108int BN_mod_mul_montgomery(r,a,b,mont,ctx)
109BIGNUM *r,*a,*b;
110BN_MONT_CTX *mont;
111BN_CTX *ctx;
112 {
113 BIGNUM *tmp;
114
115 tmp= &(ctx->bn[ctx->tos++]);
116
117 if (a == b)
118 {
119 if (!BN_sqr(tmp,a,ctx)) goto err;
120 }
121 else
122 {
123 if (!BN_mul(tmp,a,b)) goto err;
124 }
125 /* reduce from aRR to aR */
126 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
127 ctx->tos--;
128 return(1);
129err:
130 return(0);
131 }
132
133int BN_from_montgomery(r,a,mont,ctx)
134BIGNUM *r;
135BIGNUM *a;
136BN_MONT_CTX *mont;
137BN_CTX *ctx;
138 {
139 BIGNUM z1;
140 BIGNUM *t1,*t2;
141 BN_ULONG *ap,*bp,*rp;
142 int j,i,bl,al;
143
144 BN_init(&z1);
145 t1= &(ctx->bn[ctx->tos]);
146 t2= &(ctx->bn[ctx->tos+1]);
147
148 if (!BN_copy(t1,a)) goto err;
149 /* can cheat */
150 BN_mask_bits(t1,mont->ri);
151 if (!BN_mul(t2,t1,mont->Ni)) goto err;
152 BN_mask_bits(t2,mont->ri);
153
154 if (!BN_mul(t1,t2,mont->N)) goto err;
155 if (!BN_add(t2,t1,a)) goto err;
156
157 /* At this point, t2 has the bottom ri bits set to zero.
158 * This means that the bottom ri bits == the 1^ri minus the bottom
159 * ri bits of a.
160 * This means that only the bits above 'ri' in a need to be added,
161 * and XXXXXXXXXXXXXXXXXXXXXXXX
162 */
163BN_print_fp(stdout,t2); printf("\n");
164 BN_rshift(r,t2,mont->ri);
165
166 if (BN_ucmp(r,mont->N) >= 0)
167 bn_qsub(r,r,mont->N);
168
169 return(1);
170err:
171 return(0);
172 }
173
174int BN_MONT_CTX_set(mont,mod,ctx)
175BN_MONT_CTX *mont;
176BIGNUM *mod;
177BN_CTX *ctx;
178 {
179 BIGNUM *Ri=NULL,*R=NULL;
180
181 if (mont->RR == NULL) mont->RR=BN_new();
182 if (mont->N == NULL) mont->N=BN_new();
183
184 R=mont->RR; /* grab RR as a temp */
185 BN_copy(mont->N,mod); /* Set N */
186
187 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
188 BN_lshift(R,BN_value_one(),mont->ri); /* R */
189 if ((Ri=BN_mod_inverse(NULL,R,mod,ctx)) == NULL) goto err;/* Ri */
190 BN_lshift(Ri,Ri,mont->ri); /* R*Ri */
191 bn_qsub(Ri,Ri,BN_value_one()); /* R*Ri - 1 */
192 BN_div(Ri,NULL,Ri,mod,ctx);
193 if (mont->Ni != NULL) BN_free(mont->Ni);
194 mont->Ni=Ri; /* Ni=(R*Ri-1)/N */
195
196 /* setup RR for conversions */
197 BN_lshift(mont->RR,BN_value_one(),mont->ri*2);
198 BN_mod(mont->RR,mont->RR,mont->N,ctx);
199
200 return(1);
201err:
202 return(0);
203 }
204
205
diff --git a/src/lib/libssl/src/crypto/bn/test.c b/src/lib/libssl/src/crypto/bn/test.c
index a048b9f878..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/bn/test.c
+++ b/src/lib/libssl/src/crypto/bn/test.c
@@ -1,241 +0,0 @@
1#include <stdio.h>
2#include "cryptlib.h"
3#include "bn_lcl.h"
4
5#define SIZE 32
6
7#define BN_MONT_CTX_set bn_mcs
8#define BN_from_montgomery bn_fm
9#define BN_mod_mul_montgomery bn_mmm
10#undef BN_to_montgomery
11#define BN_to_montgomery(r,a,mont,ctx) bn_mmm(\
12 r,a,(mont)->RR,(mont),ctx)
13
14main()
15 {
16 BIGNUM prime,a,b,r,A,B,R;
17 BN_MONT_CTX *mont;
18 BN_CTX *ctx;
19 int i;
20
21 ctx=BN_CTX_new();
22 BN_init(&prime);
23 BN_init(&a); BN_init(&b); BN_init(&r);
24 BN_init(&A); BN_init(&B); BN_init(&R);
25
26 BN_generate_prime(&prime,SIZE,0,NULL,NULL,NULL,NULL);
27 BN_rand(&A,SIZE,1,0);
28 BN_rand(&B,SIZE,1,0);
29 BN_mod(&A,&A,&prime,ctx);
30 BN_mod(&B,&B,&prime,ctx);
31
32 i=A.top;
33 BN_mul(&R,&A,&B,ctx);
34 BN_mask_bits(&R,i*BN_BITS2);
35
36
37 BN_print_fp(stdout,&A); printf(" <- a\n");
38 BN_print_fp(stdout,&B); printf(" <- b\n");
39 BN_mul_high(&r,&A,&B,&R,i);
40 BN_print_fp(stdout,&r); printf(" <- high(BA*DC)\n");
41
42 BN_mask_bits(&A,i*32);
43 BN_mask_bits(&B,i*32);
44
45 BN_mul(&R,&A,&B);
46 BN_rshift(&R,&R,i*32);
47 BN_print_fp(stdout,&R); printf(" <- norm BA*DC\n");
48 BN_sub(&R,&R,&r);
49 BN_print_fp(stdout,&R); printf(" <- diff\n");
50 }
51
52#if 0
53int bn_mul_high(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *low, int words)
54 {
55 int i;
56 BIGNUM t1,t2,t3,h,ah,al,bh,bl,m,s0,s1;
57
58 BN_init(&al); BN_init(&ah);
59 BN_init(&bl); BN_init(&bh);
60 BN_init(&t1); BN_init(&t2); BN_init(&t3);
61 BN_init(&s0); BN_init(&s1);
62 BN_init(&h); BN_init(&m);
63
64 i=a->top;
65 if (i >= words)
66 {
67 al.top=words;
68 ah.top=a->top-words;
69 ah.d= &(a->d[ah.top]);
70 }
71 else
72 al.top=i;
73 al.d=a->d;
74
75 i=b->top;
76 if (i >= words)
77 {
78 bl.top=words;
79 bh.top=i-words;
80 bh.d= &(b->d[bh.top]);
81 }
82 else
83 bl.top=i;
84 bl.d=b->d;
85
86 i=low->top;
87 if (i >= words)
88 {
89 s0.top=words;
90 s1.top=i-words;
91 s1.d= &(low->d[s1.top]);
92 }
93 else
94 s0.top=i;
95 s0.d=low->d;
96
97al.max=al.top; ah.max=ah.top;
98bl.max=bl.top; bh.max=bh.top;
99s0.max=bl.top; s1.max=bh.top;
100
101 /* Calculate (al-ah)*(bh-bl) */
102 BN_sub(&t1,&al,&ah);
103 BN_sub(&t2,&bh,&bl);
104 BN_mul(&m,&t1,&t2);
105
106 /* Calculate ah*bh */
107 BN_mul(&h,&ah,&bh);
108
109 /* s0 == low(al*bl)
110 * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl)
111 * We know s0 and s1 so the only unknown is high(al*bl)
112 * high(al*bl) == s1 - low(ah*bh+(al-ah)*(bh-bl)+s0)
113 */
114 BN_add(&m,&m,&h);
115 BN_add(&t2,&m,&s0);
116 /* Quick and dirty mask off of high words */
117 t3.d=t2.d;
118 t3.top=(t2.top > words)?words:t2.top;
119 t3.neg=t2.neg;
120t3.max=t3.top;
121/* BN_print_fp(stdout,&s1); printf(" s1\n"); */
122/* BN_print_fp(stdout,&t2); printf(" middle value\n"); */
123/* BN_print_fp(stdout,&t3); printf(" low middle value\n"); */
124 BN_sub(&t1,&s1,&t3);
125
126 if (t1.neg)
127 {
128/*printf("neg fixup\n"); BN_print_fp(stdout,&t1); printf(" before\n"); */
129 BN_lshift(&t2,BN_value_one(),words*32);
130 BN_add(&t1,&t2,&t1);
131 BN_mask_bits(&t1,words*32);
132/* BN_print_fp(stdout,&t1); printf(" after\n"); */
133 }
134 /* al*bl == high(al*bl)<<words+s0 */
135 BN_lshift(&t1,&t1,words*32);
136 BN_add(&t1,&t1,&s0);
137
138 /* We now have
139 * al*bl - t1
140 * (al-ah)*(bh-bl)+ah*bh - m
141 * ah*bh - h
142 */
143 BN_copy(r,&t1);
144 BN_mask_bits(r,words*32*2);
145
146 /*BN_lshift(&m,&m,words*/
147
148 BN_free(&t1); BN_free(&t2);
149 BN_free(&m); BN_free(&h);
150 }
151
152int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_MONT_CTX *mont,
153 BN_CTX *ctx)
154 {
155 BIGNUM *tmp;
156
157 tmp= &(ctx->bn[ctx->tos++]);
158
159 if (a == b)
160 {
161 if (!BN_sqr(tmp,a,ctx)) goto err;
162 }
163 else
164 {
165 if (!BN_mul(tmp,a,b)) goto err;
166 }
167 /* reduce from aRR to aR */
168 if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
169 ctx->tos--;
170 return(1);
171err:
172 return(0);
173 }
174
175int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx)
176 {
177 BIGNUM z1;
178 BIGNUM *t1,*t2;
179 BN_ULONG *ap,*bp,*rp;
180 int j,i,bl,al;
181
182 BN_init(&z1);
183 t1= &(ctx->bn[ctx->tos]);
184 t2= &(ctx->bn[ctx->tos+1]);
185
186 if (!BN_copy(t1,a)) goto err;
187 /* can cheat */
188 BN_mask_bits(t1,mont->ri);
189 if (!BN_mul(t2,t1,mont->Ni)) goto err;
190 BN_mask_bits(t2,mont->ri);
191
192 if (!BN_mul(t1,t2,mont->N)) goto err;
193 if (!BN_add(t2,t1,a)) goto err;
194
195 /* At this point, t2 has the bottom ri bits set to zero.
196 * This means that the bottom ri bits == the 1^ri minus the bottom
197 * ri bits of a.
198 * This means that only the bits above 'ri' in a need to be added,
199 * and XXXXXXXXXXXXXXXXXXXXXXXX
200 */
201BN_print_fp(stdout,t2); printf("\n");
202 BN_rshift(r,t2,mont->ri);
203
204 if (BN_ucmp(r,mont->N) >= 0)
205 BN_usub(r,r,mont->N);
206
207 return(1);
208err:
209 return(0);
210 }
211
212int BN_MONT_CTX_set(BN_MONT_CTX *mont, BIGNUM *mod, BN_CTX *ctx)
213 {
214 BIGNUM *Ri=NULL,*R=NULL;
215
216 if (mont->RR == NULL) mont->RR=BN_new();
217 if (mont->N == NULL) mont->N=BN_new();
218
219 R=mont->RR; /* grab RR as a temp */
220 BN_copy(mont->N,mod); /* Set N */
221
222 mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
223 BN_lshift(R,BN_value_one(),mont->ri); /* R */
224 if ((Ri=BN_mod_inverse(NULL,R,mod,ctx)) == NULL) goto err;/* Ri */
225 BN_lshift(Ri,Ri,mont->ri); /* R*Ri */
226 BN_usub(Ri,Ri,BN_value_one()); /* R*Ri - 1 */
227 BN_div(Ri,NULL,Ri,mod,ctx);
228 if (mont->Ni != NULL) BN_free(mont->Ni);
229 mont->Ni=Ri; /* Ni=(R*Ri-1)/N */
230
231 /* setup RR for conversions */
232 BN_lshift(mont->RR,BN_value_one(),mont->ri*2);
233 BN_mod(mont->RR,mont->RR,mont->N,ctx);
234
235 return(1);
236err:
237 return(0);
238 }
239
240
241#endif
diff --git a/src/lib/libssl/src/crypto/buffer/Makefile.ssl b/src/lib/libssl/src/crypto/buffer/Makefile.ssl
index f23de89e33..506708c37f 100644
--- a/src/lib/libssl/src/crypto/buffer/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/buffer/Makefile.ssl
@@ -83,4 +83,5 @@ buffer.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
83buffer.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 83buffer.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
84buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85buffer.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 85buffer.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
86buffer.o: ../../include/openssl/stack.h ../cryptlib.h 86buffer.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87buffer.o: ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/cast/c_ecb.c b/src/lib/libssl/src/crypto/cast/c_ecb.c
index 33182f2b71..0b3da9ad87 100644
--- a/src/lib/libssl/src/crypto/cast/c_ecb.c
+++ b/src/lib/libssl/src/crypto/cast/c_ecb.c
@@ -60,7 +60,7 @@
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63char *CAST_version="CAST" OPENSSL_VERSION_PTEXT; 63const char *CAST_version="CAST" OPENSSL_VERSION_PTEXT;
64 64
65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, 65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
66 CAST_KEY *ks, int enc) 66 CAST_KEY *ks, int enc)
diff --git a/src/lib/libssl/src/crypto/cast/cast_lcl.h b/src/lib/libssl/src/crypto/cast/cast_lcl.h
index 83cf382a91..cfe3842e91 100644
--- a/src/lib/libssl/src/crypto/cast/cast_lcl.h
+++ b/src/lib/libssl/src/crypto/cast/cast_lcl.h
@@ -216,11 +216,11 @@
216 } 216 }
217#endif 217#endif
218 218
219OPENSSL_EXTERN CAST_LONG CAST_S_table0[256]; 219OPENSSL_EXTERN const CAST_LONG CAST_S_table0[256];
220OPENSSL_EXTERN CAST_LONG CAST_S_table1[256]; 220OPENSSL_EXTERN const CAST_LONG CAST_S_table1[256];
221OPENSSL_EXTERN CAST_LONG CAST_S_table2[256]; 221OPENSSL_EXTERN const CAST_LONG CAST_S_table2[256];
222OPENSSL_EXTERN CAST_LONG CAST_S_table3[256]; 222OPENSSL_EXTERN const CAST_LONG CAST_S_table3[256];
223OPENSSL_EXTERN CAST_LONG CAST_S_table4[256]; 223OPENSSL_EXTERN const CAST_LONG CAST_S_table4[256];
224OPENSSL_EXTERN CAST_LONG CAST_S_table5[256]; 224OPENSSL_EXTERN const CAST_LONG CAST_S_table5[256];
225OPENSSL_EXTERN CAST_LONG CAST_S_table6[256]; 225OPENSSL_EXTERN const CAST_LONG CAST_S_table6[256];
226OPENSSL_EXTERN CAST_LONG CAST_S_table7[256]; 226OPENSSL_EXTERN const CAST_LONG CAST_S_table7[256];
diff --git a/src/lib/libssl/src/crypto/cast/cast_s.h b/src/lib/libssl/src/crypto/cast/cast_s.h
index 9af28972c5..c483fd5e43 100644
--- a/src/lib/libssl/src/crypto/cast/cast_s.h
+++ b/src/lib/libssl/src/crypto/cast/cast_s.h
@@ -55,7 +55,7 @@
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 */
58OPENSSL_GLOBAL CAST_LONG CAST_S_table0[256]={ 58OPENSSL_GLOBAL const CAST_LONG CAST_S_table0[256]={
59 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a, 59 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a,
60 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949, 60 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949,
61 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675, 61 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675,
@@ -121,7 +121,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table0[256]={
121 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d, 121 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d,
122 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf, 122 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf,
123 }; 123 };
124OPENSSL_GLOBAL CAST_LONG CAST_S_table1[256]={ 124OPENSSL_GLOBAL const CAST_LONG CAST_S_table1[256]={
125 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380, 125 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380,
126 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651, 126 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651,
127 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba, 127 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba,
@@ -187,7 +187,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table1[256]={
187 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef, 187 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef,
188 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1, 188 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1,
189 }; 189 };
190OPENSSL_GLOBAL CAST_LONG CAST_S_table2[256]={ 190OPENSSL_GLOBAL const CAST_LONG CAST_S_table2[256]={
191 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907, 191 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907,
192 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90, 192 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90,
193 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae, 193 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae,
@@ -253,7 +253,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table2[256]={
253 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5, 253 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5,
254 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783, 254 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783,
255 }; 255 };
256OPENSSL_GLOBAL CAST_LONG CAST_S_table3[256]={ 256OPENSSL_GLOBAL const CAST_LONG CAST_S_table3[256]={
257 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298, 257 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298,
258 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1, 258 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1,
259 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120, 259 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120,
@@ -319,7 +319,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table3[256]={
319 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e, 319 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e,
320 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2, 320 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2,
321 }; 321 };
322OPENSSL_GLOBAL CAST_LONG CAST_S_table4[256]={ 322OPENSSL_GLOBAL const CAST_LONG CAST_S_table4[256]={
323 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911, 323 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911,
324 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f, 324 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f,
325 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00, 325 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00,
@@ -385,7 +385,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table4[256]={
385 0xe822fe15,0x88570983,0x750e6249,0xda627e55, 385 0xe822fe15,0x88570983,0x750e6249,0xda627e55,
386 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4, 386 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4,
387 }; 387 };
388OPENSSL_GLOBAL CAST_LONG CAST_S_table5[256]={ 388OPENSSL_GLOBAL const CAST_LONG CAST_S_table5[256]={
389 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c, 389 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c,
390 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac, 390 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac,
391 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9, 391 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9,
@@ -451,7 +451,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table5[256]={
451 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454, 451 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454,
452 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f, 452 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f,
453 }; 453 };
454OPENSSL_GLOBAL CAST_LONG CAST_S_table6[256]={ 454OPENSSL_GLOBAL const CAST_LONG CAST_S_table6[256]={
455 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693, 455 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693,
456 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f, 456 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f,
457 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82, 457 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82,
@@ -517,7 +517,7 @@ OPENSSL_GLOBAL CAST_LONG CAST_S_table6[256]={
517 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada, 517 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada,
518 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3, 518 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3,
519 }; 519 };
520OPENSSL_GLOBAL CAST_LONG CAST_S_table7[256]={ 520OPENSSL_GLOBAL const CAST_LONG CAST_S_table7[256]={
521 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095, 521 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095,
522 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5, 522 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5,
523 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174, 523 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174,
diff --git a/src/lib/libssl/src/crypto/cast/cast_spd.c b/src/lib/libssl/src/crypto/cast/cast_spd.c
index c0726906c2..0af915cf20 100644
--- a/src/lib/libssl/src/crypto/cast/cast_spd.c
+++ b/src/lib/libssl/src/crypto/cast/cast_spd.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libssl/src/crypto/cast/castopts.c b/src/lib/libssl/src/crypto/cast/castopts.c
index 642e9725af..c783796610 100644
--- a/src/lib/libssl/src/crypto/cast/castopts.c
+++ b/src/lib/libssl/src/crypto/cast/castopts.c
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
252 } 252 }
253 253
254#ifndef TIMES 254#ifndef TIMES
255 fprintf(stderr,"To get the most acurate results, try to run this\n"); 255 fprintf(stderr,"To get the most accurate results, try to run this\n");
256 fprintf(stderr,"program when this computer is idle.\n"); 256 fprintf(stderr,"program when this computer is idle.\n");
257#endif 257#endif
258 258
diff --git a/src/lib/libssl/src/crypto/cast/casttest.c b/src/lib/libssl/src/crypto/cast/casttest.c
index 3244b119e9..ab2aeac606 100644
--- a/src/lib/libssl/src/crypto/cast/casttest.c
+++ b/src/lib/libssl/src/crypto/cast/casttest.c
@@ -71,32 +71,32 @@ int main(int argc, char *argv[])
71 71
72#define FULL_TEST 72#define FULL_TEST
73 73
74unsigned char k[16]={ 74static unsigned char k[16]={
75 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 75 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
76 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A 76 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A
77 }; 77 };
78 78
79unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; 79static unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
80 80
81int k_len[3]={16,10,5}; 81static int k_len[3]={16,10,5};
82unsigned char c[3][8]={ 82static unsigned char c[3][8]={
83 {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2}, 83 {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2},
84 {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B}, 84 {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B},
85 {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}, 85 {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E},
86 }; 86 };
87unsigned char out[80]; 87static unsigned char out[80];
88 88
89unsigned char in_a[16]={ 89static unsigned char in_a[16]={
90 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 90 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
91 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; 91 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
92unsigned char in_b[16]={ 92static unsigned char in_b[16]={
93 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 93 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
94 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; 94 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
95 95
96unsigned char c_a[16]={ 96static unsigned char c_a[16]={
97 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6, 97 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6,
98 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92}; 98 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92};
99unsigned char c_b[16]={ 99static unsigned char c_b[16]={
100 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71, 100 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71,
101 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E}; 101 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E};
102 102
diff --git a/src/lib/libssl/src/crypto/comp/comp.h b/src/lib/libssl/src/crypto/comp/comp.h
index 93bd9c34c8..811cb5833d 100644
--- a/src/lib/libssl/src/crypto/comp/comp.h
+++ b/src/lib/libssl/src/crypto/comp/comp.h
@@ -17,6 +17,7 @@ typedef struct comp_method_st
17 int (*compress)(); 17 int (*compress)();
18 int (*expand)(); 18 int (*expand)();
19 long (*ctrl)(); 19 long (*ctrl)();
20 long (*callback_ctrl)();
20 } COMP_METHOD; 21 } COMP_METHOD;
21 22
22typedef struct comp_ctx_st 23typedef struct comp_ctx_st
diff --git a/src/lib/libssl/src/crypto/conf/conf.c b/src/lib/libssl/src/crypto/conf/conf.c
index 7d8b89168a..3031fa3b44 100644
--- a/src/lib/libssl/src/crypto/conf/conf.c
+++ b/src/lib/libssl/src/crypto/conf/conf.c
@@ -86,28 +86,25 @@ const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
86LHASH *CONF_load(LHASH *h, const char *file, long *line) 86LHASH *CONF_load(LHASH *h, const char *file, long *line)
87 { 87 {
88 LHASH *ltmp; 88 LHASH *ltmp;
89 FILE *in=NULL; 89 BIO *in=NULL;
90 90
91#ifdef VMS 91#ifdef VMS
92 in=fopen(file,"r"); 92 in=BIO_new_file(file, "r");
93#else 93#else
94 in=fopen(file,"rb"); 94 in=BIO_new_file(file, "rb");
95#endif 95#endif
96 if (in == NULL) 96 if (in == NULL)
97 { 97 {
98 SYSerr(SYS_F_FOPEN,get_last_sys_error());
99 ERR_set_error_data(BUF_strdup(file),
100 ERR_TXT_MALLOCED|ERR_TXT_STRING);
101 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); 98 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
102 return NULL; 99 return NULL;
103 } 100 }
104 101
105 ltmp = CONF_load_fp(h, in, line); 102 ltmp = CONF_load_bio(h, in, line);
106 fclose(in); 103 BIO_free(in);
107 104
108 return ltmp; 105 return ltmp;
109} 106}
110 107#ifndef NO_FP_API
111LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line) 108LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
112{ 109{
113 BIO *btmp; 110 BIO *btmp;
@@ -120,6 +117,7 @@ LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
120 BIO_free(btmp); 117 BIO_free(btmp);
121 return ltmp; 118 return ltmp;
122} 119}
120#endif
123 121
124LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line) 122LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line)
125 { 123 {
@@ -338,7 +336,7 @@ again:
338 ERR_R_MALLOC_FAILURE); 336 ERR_R_MALLOC_FAILURE);
339 goto err; 337 goto err;
340 } 338 }
341 vv=(CONF_VALUE *)lh_insert(ret,(char *)v); 339 vv=(CONF_VALUE *)lh_insert(ret,v);
342 if (vv != NULL) 340 if (vv != NULL)
343 { 341 {
344 sk_CONF_VALUE_delete_ptr(ts,vv); 342 sk_CONF_VALUE_delete_ptr(ts,vv);
@@ -380,7 +378,7 @@ char *CONF_get_string(LHASH *conf, char *section, char *name)
380 { 378 {
381 vv.name=name; 379 vv.name=name;
382 vv.section=section; 380 vv.section=section;
383 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); 381 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
384 if (v != NULL) return(v->value); 382 if (v != NULL) return(v->value);
385 if (strcmp(section,"ENV") == 0) 383 if (strcmp(section,"ENV") == 0)
386 { 384 {
@@ -390,7 +388,7 @@ char *CONF_get_string(LHASH *conf, char *section, char *name)
390 } 388 }
391 vv.section="default"; 389 vv.section="default";
392 vv.name=name; 390 vv.name=name;
393 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); 391 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
394 if (v != NULL) 392 if (v != NULL)
395 return(v->value); 393 return(v->value);
396 else 394 else
@@ -407,7 +405,7 @@ static CONF_VALUE *get_section(LHASH *conf, char *section)
407 if ((conf == NULL) || (section == NULL)) return(NULL); 405 if ((conf == NULL) || (section == NULL)) return(NULL);
408 vv.name=NULL; 406 vv.name=NULL;
409 vv.section=section; 407 vv.section=section;
410 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); 408 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
411 return(v); 409 return(v);
412 } 410 }
413 411
@@ -445,12 +443,12 @@ void CONF_free(LHASH *conf)
445 443
446 conf->down_load=0; /* evil thing to make sure the 'Free()' 444 conf->down_load=0; /* evil thing to make sure the 'Free()'
447 * works as expected */ 445 * works as expected */
448 lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf); 446 lh_doall_arg(conf,(void (*)())value_free_hash,conf);
449 447
450 /* We now have only 'section' entries in the hash table. 448 /* We now have only 'section' entries in the hash table.
451 * Due to problems with */ 449 * Due to problems with */
452 450
453 lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf); 451 lh_doall_arg(conf,(void (*)())value_free_stack,conf);
454 lh_free(conf); 452 lh_free(conf);
455 } 453 }
456 454
@@ -458,7 +456,7 @@ static void value_free_hash(CONF_VALUE *a, LHASH *conf)
458 { 456 {
459 if (a->name != NULL) 457 if (a->name != NULL)
460 { 458 {
461 a=(CONF_VALUE *)lh_delete(conf,(char *)a); 459 a=(CONF_VALUE *)lh_delete(conf,a);
462 } 460 }
463 } 461 }
464 462
@@ -710,7 +708,7 @@ static CONF_VALUE *new_section(LHASH *conf, char *section)
710 v->name=NULL; 708 v->name=NULL;
711 v->value=(char *)sk; 709 v->value=(char *)sk;
712 710
713 vv=(CONF_VALUE *)lh_insert(conf,(char *)v); 711 vv=(CONF_VALUE *)lh_insert(conf,v);
714 if (vv != NULL) 712 if (vv != NULL)
715 { 713 {
716#if !defined(NO_STDIO) && !defined(WIN16) 714#if !defined(NO_STDIO) && !defined(WIN16)
diff --git a/src/lib/libssl/src/crypto/conf/conf.h b/src/lib/libssl/src/crypto/conf/conf.h
index e7c5150097..21831a92a3 100644
--- a/src/lib/libssl/src/crypto/conf/conf.h
+++ b/src/lib/libssl/src/crypto/conf/conf.h
@@ -78,7 +78,9 @@ typedef struct
78DECLARE_STACK_OF(CONF_VALUE) 78DECLARE_STACK_OF(CONF_VALUE)
79 79
80LHASH *CONF_load(LHASH *conf,const char *file,long *eline); 80LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
81#ifndef NO_FP_API
81LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); 82LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
83#endif
82LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); 84LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
83STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section); 85STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section);
84char *CONF_get_string(LHASH *conf,char *group,char *name); 86char *CONF_get_string(LHASH *conf,char *group,char *name);
diff --git a/src/lib/libssl/src/crypto/cryptlib.c b/src/lib/libssl/src/crypto/cryptlib.c
index 356c476a99..a8f29f1e65 100644
--- a/src/lib/libssl/src/crypto/cryptlib.c
+++ b/src/lib/libssl/src/crypto/cryptlib.c
@@ -92,7 +92,9 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
92 "getservbyname", 92 "getservbyname",
93 "readdir", 93 "readdir",
94 "RSA_blinding", 94 "RSA_blinding",
95#if CRYPTO_NUM_LOCKS != 24 95 "dh",
96 "debug_malloc2",
97#if CRYPTO_NUM_LOCKS != 26
96# error "Inconsistency between crypto.h and cryptlib.c" 98# error "Inconsistency between crypto.h and cryptlib.c"
97#endif 99#endif
98 }; 100 };
@@ -181,7 +183,7 @@ unsigned long CRYPTO_thread_id(void)
181 ret=(unsigned long)GetCurrentTask(); 183 ret=(unsigned long)GetCurrentTask();
182#elif defined(WIN32) 184#elif defined(WIN32)
183 ret=(unsigned long)GetCurrentThreadId(); 185 ret=(unsigned long)GetCurrentThreadId();
184#elif defined(MSDOS) 186#elif defined(GETPID_IS_MEANINGLESS)
185 ret=1L; 187 ret=1L;
186#else 188#else
187 ret=(unsigned long)getpid(); 189 ret=(unsigned long)getpid();
diff --git a/src/lib/libssl/src/crypto/crypto-lib.com b/src/lib/libssl/src/crypto/crypto-lib.com
index bf916528eb..79d86771e8 100644
--- a/src/lib/libssl/src/crypto/crypto-lib.com
+++ b/src/lib/libssl/src/crypto/crypto-lib.com
@@ -14,7 +14,14 @@ $!
14$! It was re-written so it would try to determine what "C" compiler to use 14$! It was re-written so it would try to determine what "C" compiler to use
15$! or you can specify which "C" compiler to use. 15$! or you can specify which "C" compiler to use.
16$! 16$!
17$! Specify RSAREF as P1 to compile with the RSAREF library instead of 17$! Specify the following as P1 to build just that part or ALL to just
18$! build everything.
19$!
20$! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
21$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE
22$! ALL To do both LIBRARY and APPS
23$!
24$! Specify RSAREF as P2 to compile with the RSAREF library instead of
18$! the regular one. If you specify NORSAREF it will compile with the 25$! the regular one. If you specify NORSAREF it will compile with the
19$! regular RSAREF routines. (Note: If you are in the United States 26$! regular RSAREF routines. (Note: If you are in the United States
20$! you MUST compile with RSAREF unless you have a license from RSA). 27$! you MUST compile with RSAREF unless you have a license from RSA).
@@ -26,10 +33,10 @@ $! directory structure stored. You have to extract the file
26$! into the [.RSAREF] directory under the root directory as that 33$! into the [.RSAREF] directory under the root directory as that
27$! is where the scripts will look for the files. 34$! is where the scripts will look for the files.
28$! 35$!
29$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger 36$! Specify DEBUG or NODEBUG as P3 to compile with or without debugger
30$! information. 37$! information.
31$! 38$!
32$! Specify which compiler at P3 to try to compile under. 39$! Specify which compiler at P4 to try to compile under.
33$! 40$!
34$! VAXC For VAX C. 41$! VAXC For VAX C.
35$! DECC For DEC C. 42$! DECC For DEC C.
@@ -38,15 +45,15 @@ $!
38$! If you don't speficy a compiler, it will try to determine which 45$! If you don't speficy a compiler, it will try to determine which
39$! "C" compiler to use. 46$! "C" compiler to use.
40$! 47$!
41$! P4, if defined, sets a TCP/IP library to use, through one of the following 48$! P5, if defined, sets a TCP/IP library to use, through one of the following
42$! keywords: 49$! keywords:
43$! 50$!
44$! UCX for UCX 51$! UCX for UCX
45$! SOCKETSHR for SOCKETSHR+NETLIB 52$! SOCKETSHR for SOCKETSHR+NETLIB
46$! 53$!
47$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 54$! P6, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
48$! 55$!
49$! P6, if defined, sets a choice of crypto methods to compile. 56$! P7, if defined, sets a choice of crypto methods to compile.
50$! WARNING: this should only be done to recompile some part of an already 57$! WARNING: this should only be done to recompile some part of an already
51$! fully compiled library. 58$! fully compiled library.
52$! 59$!
@@ -79,12 +86,13 @@ $ ENDIF
79$! 86$!
80$! Define The Different Encryption Types. 87$! Define The Different Encryption Types.
81$! 88$!
82$ ENCRYPT_TYPES = ",MD2,MD5,SHA,MDC2,HMAC,RIPEMD,"+ - 89$ ENCRYPT_TYPES = "Basic,MD2,MD5,SHA,MDC2,HMAC,RIPEMD,"+ -
83 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ - 90 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ -
84 "BN,RSA,DSA,DH,"+ - 91 "BN,RSA,DSA,DH,"+ -
85 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ - 92 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ -
86 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - 93 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
87 "CONF,TXT_DB,PKCS7,PKCS12,COMP" 94 "CONF,TXT_DB,PKCS7,PKCS12,COMP"
95$ ENCRYPT_PROGRAMS = "DES,PKCS7"
88$! 96$!
89$! Check To Make Sure We Have Valid Command Line Parameters. 97$! Check To Make Sure We Have Valid Command Line Parameters.
90$! 98$!
@@ -136,6 +144,14 @@ $! Define The Library Name.
136$! 144$!
137$ LIB_NAME := 'EXE_DIR'LIBCRYPTO.OLB 145$ LIB_NAME := 'EXE_DIR'LIBCRYPTO.OLB
138$! 146$!
147$! Define The CRYPTO-LIB We Are To Use.
148$!
149$ CRYPTO_LIB := 'EXE_DIR'LIBCRYPTO.OLB
150$!
151$! Define The RSAREF-LIB We Are To Use.
152$!
153$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
154$!
139$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library... 155$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library...
140$! 156$!
141$ IF (F$SEARCH(LIB_NAME).EQS."") 157$ IF (F$SEARCH(LIB_NAME).EQS."")
@@ -149,9 +165,16 @@ $! End The Library Check.
149$! 165$!
150$ ENDIF 166$ ENDIF
151$! 167$!
168$! Build our options file for the application
169$!
170$ GOSUB CHECK_OPT_FILE
171$!
152$! Define The Different Encryption "library" Strings. 172$! Define The Different Encryption "library" Strings.
153$! 173$!
154$ LIB_ = "cryptlib,mem,cversion,ex_data,tmdiff,cpt_err" 174$ APPS_DES = "DES/DES,CBC3_ENC"
175$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
176$
177$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,tmdiff,cpt_err"
155$ LIB_MD2 = "md2_dgst,md2_one" 178$ LIB_MD2 = "md2_dgst,md2_one"
156$ LIB_MD5 = "md5_dgst,md5_one" 179$ LIB_MD5 = "md5_dgst,md5_one"
157$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one" 180$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one"
@@ -171,14 +194,14 @@ $ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey"
171$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64" 194$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
172$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64" 195$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
173$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper" 196$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
174$ IF F$TRNLNM("OPENSSL_NO_ASM") .NES. "" THEN LIB_BN_ASM = "bn_asm" 197$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm"
175$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_mul,"+ - 198$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,"+ -
176 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ - 199 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ -
177 "bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+",bn_recp,bn_mont,"+ - 200 "bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+",bn_recp,bn_mont,"+ -
178 "bn_mpi,bn_exp2" 201 "bn_mpi,bn_exp2"
179$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ - 202$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
180 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk" 203 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null"
181$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err" 204$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err,dsa_ossl"
182$ LIB_DH = "dh_gen,dh_key,dh_lib,dh_check,dh_err" 205$ LIB_DH = "dh_gen,dh_key,dh_lib,dh_check,dh_err"
183$ LIB_BUFFER = "buffer,buf_err" 206$ LIB_BUFFER = "buffer,buf_err"
184$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - 207$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
@@ -188,7 +211,7 @@ $ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
188 "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio" ! + ",bss_log" for syslog 211 "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio" ! + ",bss_log" for syslog
189$ LIB_STACK = "stack" 212$ LIB_STACK = "stack"
190$ LIB_LHASH = "lhash,lh_stats" 213$ LIB_LHASH = "lhash,lh_stats"
191$ LIB_RAND = "md_rand,randfile,rand_lib" 214$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd"
192$ LIB_ERR = "err,err_all,err_prn" 215$ LIB_ERR = "err,err_all,err_prn"
193$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err" 216$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
194$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ - 217$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ -
@@ -204,38 +227,39 @@ $ LIB_EVP_2 = "e_ecb_c,e_cbc_c,e_cfb_c,e_ofb_c,"+ -
204 "m_ripemd,"+ - 227 "m_ripemd,"+ -
205 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ - 228 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ -
206 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ - 229 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ -
207 "c_all,evp_lib,bio_ok,evp_pkey,evp_pbe,p5_crpt,p5_crpt2" 230 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
231 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
208$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ - 232$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
209 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,a_bmp,"+ - 233 "a_null,a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,a_bmp,"+ -
210 "a_enum,a_vis,a_utf8,a_sign,a_digest,a_verify,"+ - 234 "a_enum,a_vis,a_utf8,a_sign,a_digest,a_verify,a_mbstr,"+ -
211 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,"+ - 235 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,"+ -
212 "x_name,x_cinf,x_x509,x_crl,x_info,x_spki,nsseq,"+ - 236 "x_name,x_cinf,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ -
213 "d2i_r_pr,i2d_r_pr,d2i_r_pu,i2d_r_pu,"+ - 237 "d2i_r_pr,i2d_r_pr,d2i_r_pu,i2d_r_pu,"+ -
214 "d2i_s_pr,i2d_s_pr,d2i_s_pu,i2d_s_pu,"+ - 238 "d2i_s_pr,i2d_s_pr,d2i_s_pu,i2d_s_pu,"+ -
215 "d2i_pu,d2i_pr,i2d_pu,i2d_pr" 239 "d2i_pu,d2i_pr,i2d_pu,i2d_pr"
216$ LIB_ASN1_2 = "t_req,t_x509,t_crl,t_pkey,"+ - 240$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
217 "p7_i_s,p7_signi,p7_signd,p7_recip,p7_enc_c,p7_evp,"+ - 241 "p7_i_s,p7_signi,p7_signd,p7_recip,p7_enc_c,p7_evp,"+ -
218 "p7_dgst,p7_s_e,p7_enc,p7_lib,"+ - 242 "p7_dgst,p7_s_e,p7_enc,p7_lib,"+ -
219 "f_int,f_string,i2d_dhp,i2d_dsap,d2i_dhp,d2i_dsap,n_pkey,"+ - 243 "f_int,f_string,i2d_dhp,i2d_dsap,d2i_dhp,d2i_dsap,n_pkey,"+ -
220 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ - 244 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ -
221 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,"+ - 245 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ -
222 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey" 246 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey"
223$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err" 247$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err"
224$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ - 248$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ -
225 "x509_obj,x509_req,x509_vfy,"+ - 249 "x509_obj,x509_req,x509spki,x509_vfy,"+ -
226 "x509_set,x509rset,x509_err,"+ - 250 "x509_set,x509rset,x509_err,"+ -
227 "x509name,x509_v3,x509_ext,"+ - 251 "x509name,x509_v3,x509_ext,x509_att,"+ -
228 "x509type,x509_lu,x_all,x509_txt,"+ - 252 "x509type,x509_lu,x_all,x509_txt,"+ -
229 "by_file,by_dir" 253 "x509_trs,by_file,by_dir"
230$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ - 254$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
231 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ - 255 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
232 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld" 256 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info"
233$ LIB_CONF = "conf,conf_err" 257$ LIB_CONF = "conf,conf_err"
234$ LIB_TXT_DB = "txt_db" 258$ LIB_TXT_DB = "txt_db"
235$ LIB_PKCS7 = "pk7_lib,pkcs7err,pk7_doit" 259$ LIB_PKCS7 = "pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,pk7_mime"
236$ LIB_PKCS12 = "p12_add,p12_attr,p12_bags,p12_crpt,p12_crt,p12_decr,"+ - 260$ LIB_PKCS12 = "p12_add,p12_attr,p12_bags,p12_crpt,p12_crt,p12_decr,"+ -
237 "p12_init,p12_key,p12_kiss,p12_lib,p12_mac,p12_mutl,"+ - 261 "p12_init,p12_key,p12_kiss,p12_lib,p12_mac,p12_mutl,"+ -
238 "p12_sbag,p12_utl,pk12err" 262 "p12_sbag,p12_utl,p12_npas,pk12err"
239$ LIB_COMP = "comp_lib,"+ - 263$ LIB_COMP = "comp_lib,"+ -
240 "c_rle,c_zlib" 264 "c_rle,c_zlib"
241$! 265$!
@@ -248,7 +272,8 @@ $ COMPILEWITH_CC5 = ",md2_dgst,md5_dgst,mdc2dgst,sha_dgst,sha1dgst," + -
248$! 272$!
249$! Check To See If We Are Going To Use RSAREF. 273$! Check To See If We Are Going To Use RSAREF.
250$! 274$!
251$ IF (RSAREF.EQS."TRUE" .AND. ENCRYPT_TYPES - "RSA".NES.ENCRYPT_TYPES) 275$ IF (RSAREF.EQS."TRUE" .AND. ENCRYPT_TYPES - "RSA".NES.ENCRYPT_TYPES -
276 .AND. (BUILDALL .EQS. "TRUE" .OR. BUILDALL .EQS. "LIBRARY"))
252$ THEN 277$ THEN
253$! 278$!
254$! Check To See If The File [-.RSAREF]RSAREF.C Is Actually There. 279$! Check To See If The File [-.RSAREF]RSAREF.C Is Actually There.
@@ -340,6 +365,8 @@ $!
340$! Extract The Module Name From The Encryption List. 365$! Extract The Module Name From The Encryption List.
341$! 366$!
342$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES) 367$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES)
368$ IF MODULE_NAME.EQS."Basic" THEN MODULE_NAME = ""
369$ MODULE_NAME1 = MODULE_NAME
343$! 370$!
344$! Check To See If We Are At The End Of The Module List. 371$! Check To See If We Are At The End Of The Module List.
345$! 372$!
@@ -358,20 +385,10 @@ $! Increment The Moudle Counter.
358$! 385$!
359$ MODULE_COUNTER = MODULE_COUNTER + 1 386$ MODULE_COUNTER = MODULE_COUNTER + 1
360$! 387$!
361$! Tell The User What Module We Are Building. 388$! Create The Library and Apps Module Names.
362$!
363$ IF (MODULE_NAME.NES."")
364$ THEN
365$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME," Files."
366$ ENDIF
367$!
368$! Define A File Counter And Set It To "0".
369$!
370$ FILE_COUNTER = 0
371$!
372$! Create The Library Module Name.
373$! 389$!
374$ LIB_MODULE = "LIB_" + MODULE_NAME 390$ LIB_MODULE = "LIB_" + MODULE_NAME
391$ APPS_MODULE = "APPS_" + MODULE_NAME
375$ IF (MODULE_NAME.EQS."ASN1_2") 392$ IF (MODULE_NAME.EQS."ASN1_2")
376$ THEN 393$ THEN
377$ MODULE_NAME = "ASN1" 394$ MODULE_NAME = "ASN1"
@@ -381,6 +398,11 @@ $ THEN
381$ MODULE_NAME = "EVP" 398$ MODULE_NAME = "EVP"
382$ ENDIF 399$ ENDIF
383$! 400$!
401$! Set state (can be LIB and APPS)
402$!
403$ STATE = "LIB"
404$ IF BUILDALL .EQS. "APPS" THEN STATE = "APPS"
405$!
384$! Check if the library module name actually is defined 406$! Check if the library module name actually is defined
385$! 407$!
386$ IF F$TYPE('LIB_MODULE') .EQS. "" 408$ IF F$TYPE('LIB_MODULE') .EQS. ""
@@ -391,22 +413,92 @@ $ WRITE SYS$ERROR ""
391$ GOTO MODULE_NEXT 413$ GOTO MODULE_NEXT
392$ ENDIF 414$ ENDIF
393$! 415$!
416$! Top Of The Module Loop.
417$!
418$ MODULE_AGAIN:
419$!
420$! Tell The User What Module We Are Building.
421$!
422$ IF (MODULE_NAME1.NES."")
423$ THEN
424$ IF STATE .EQS. "LIB"
425$ THEN
426$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Library Files. (",BUILDALL,",",STATE,")"
427$ ELSE IF F$TYPE('APPS_MODULE') .NES. ""
428$ THEN
429$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Applications. (",BUILDALL,",",STATE,")"
430$ ENDIF
431$ ENDIF
432$ ENDIF
433$!
434$! Define A File Counter And Set It To "0".
435$!
436$ FILE_COUNTER = 0
437$ APPLICATION = ""
438$ APPLICATION_COUNTER = 0
439$!
394$! Top Of The File Loop. 440$! Top Of The File Loop.
395$! 441$!
396$ NEXT_FILE: 442$ NEXT_FILE:
397$! 443$!
398$! O.K, Extract The File Name From The File List. 444$! Look in the LIB_MODULE is we're in state LIB
445$!
446$ IF STATE .EQS. "LIB"
447$ THEN
448$!
449$! O.K, Extract The File Name From The File List.
450$!
451$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE')
452$!
453$! else
454$!
455$ ELSE
456$ FILE_NAME = ","
457$!
458$ IF F$TYPE('APPS_MODULE') .NES. ""
459$ THEN
460$!
461$! Extract The File Name From The File List.
462$! This part is a bit more complicated.
399$! 463$!
400$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE') 464$ IF APPLICATION .EQS. ""
465$ THEN
466$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
467$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
468$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
469$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
470$ FILE_COUNTER = 0
471$ ENDIF
472$
473$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
474$! SHOW SYMBOL APPLICATION*
475$!
476$ IF APPLICATION .NES. ";"
477$ THEN
478$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS)
479$ IF FILE_NAME .EQS. ","
480$ THEN
481$ APPLICATION = ""
482$ GOTO NEXT_FILE
483$ ENDIF
484$ ENDIF
485$ ENDIF
486$ ENDIF
401$! 487$!
402$! Check To See If We Are At The End Of The File List. 488$! Check To See If We Are At The End Of The File List.
403$! 489$!
404$ IF (FILE_NAME.EQS.",") 490$ IF (FILE_NAME.EQS.",")
405$ THEN 491$ THEN
406$! 492$!
407$! We Are At The End Of The File List, Goto FILE_DONE. 493$! We Are At The End Of The File List, Change State Or Goto FILE_DONE.
408$! 494$!
409$ GOTO FILE_DONE 495$ IF STATE .EQS. "LIB" .AND. BUILDALL .NES. "LIBRARY"
496$ THEN
497$ STATE = "APPS"
498$ GOTO MODULE_AGAIN
499$ ELSE
500$ GOTO FILE_DONE
501$ ENDIF
410$! 502$!
411$! End The File List Check. 503$! End The File List Check.
412$! 504$!
@@ -458,7 +550,7 @@ $! Tell The User We Are Compiling The File.
458$! 550$!
459$ IF (MODULE_NAME.EQS."") 551$ IF (MODULE_NAME.EQS."")
460$ THEN 552$ THEN
461 WRITE SYS$OUTPUT "Compiling The ",FILE_NAME," File." 553$ WRITE SYS$OUTPUT "Compiling The ",FILE_NAME," File. (",BUILDALL,",",STATE,")"
462$ ENDIF 554$ ENDIF
463$ IF (MODULE_NAME.NES."") 555$ IF (MODULE_NAME.NES."")
464$ THEN 556$ THEN
@@ -490,14 +582,17 @@ $ ENDIF
490$ ENDIF 582$ ENDIF
491$ ENDIF 583$ ENDIF
492$ ENDIF 584$ ENDIF
585$ IF STATE .EQS. "LIB"
586$ THEN
493$! 587$!
494$! Add It To The Library. 588$! Add It To The Library.
495$! 589$!
496$ LIBRARY/REPLACE 'LIB_NAME' 'OBJECT_FILE' 590$ LIBRARY/REPLACE 'LIB_NAME' 'OBJECT_FILE'
497$! 591$!
498$! Time To Clean Up The Object File. 592$! Time To Clean Up The Object File.
499$! 593$!
500$ DELETE 'OBJECT_FILE';* 594$ DELETE 'OBJECT_FILE';*
595$ ENDIF
501$! 596$!
502$! Go Back And Do It Again. 597$! Go Back And Do It Again.
503$! 598$!
@@ -507,6 +602,99 @@ $! All Done With This Library Part.
507$! 602$!
508$ FILE_DONE: 603$ FILE_DONE:
509$! 604$!
605$! Time To Build Some Applications
606$!
607$ IF F$TYPE('APPS_MODULE') .NES. "" .AND. BUILDALL .NES. "LIBRARY"
608$ THEN
609$ APPLICATION_COUNTER = 0
610$ NEXT_APPLICATION:
611$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
612$ IF APPLICATION .EQS. ";" THEN GOTO APPLICATION_DONE
613$
614$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
615$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
616$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
617$
618$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
619$! SHOW SYMBOL APPLICATION*
620$!
621$! Tell the user what happens
622$!
623$ WRITE SYS$OUTPUT " ",APPLICATION,".exe"
624$!
625$! Link The Program, Check To See If We Need To Link With RSAREF Or Not.
626$!
627$ IF (RSAREF.EQS."TRUE")
628$ THEN
629$!
630$! Check To See If We Are To Link With A Specific TCP/IP Library.
631$!
632$ IF (TCPIP_LIB.NES."")
633$ THEN
634$!
635$! Link With The RSAREF Library And A Specific TCP/IP Library.
636$!
637$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
638 'OBJ_DIR''APPLICATION_OBJECTS', -
639 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
640 'TCPIP_LIB','OPT_FILE'/OPTION
641$!
642$! Else...
643$!
644$ ELSE
645$!
646$! Link With The RSAREF Library And NO TCP/IP Library.
647$!
648$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
649 'OBJ_DIR''APPLICATION_OBJECTS', -
650 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
651 'OPT_FILE'/OPTION
652$!
653$! End The TCP/IP Library Check.
654$!
655$ ENDIF
656$!
657$! Else...
658$!
659$ ELSE
660$!
661$! Don't Link With The RSAREF Routines.
662$!
663$!
664$! Check To See If We Are To Link With A Specific TCP/IP Library.
665$!
666$ IF (TCPIP_LIB.NES."")
667$ THEN
668$!
669$! Don't Link With The RSAREF Routines And TCP/IP Library.
670$!
671$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
672 'OBJ_DIR''APPLICATION_OBJECTS', -
673 'CRYPTO_LIB'/LIBRARY, -
674 'TCPIP_LIB','OPT_FILE'/OPTION
675$!
676$! Else...
677$!
678$ ELSE
679$!
680$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
681$!
682$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
683 'OBJ_DIR''APPLICATION_OBJECTS',-
684 'CRYPTO_LIB'/LIBRARY, -
685 'OPT_FILE'/OPTION
686$!
687$! End The TCP/IP Library Check.
688$!
689$ ENDIF
690$!
691$! End The RSAREF Link Check.
692$!
693$ ENDIF
694$ GOTO NEXT_APPLICATION
695$ APPLICATION_DONE:
696$ ENDIF
697$!
510$! Go Back And Get The Next Module. 698$! Go Back And Get The Next Module.
511$! 699$!
512$ GOTO MODULE_NEXT 700$ GOTO MODULE_NEXT
@@ -653,17 +841,70 @@ $ CHECK_OPTIONS:
653$! 841$!
654$! Check To See If P1 Is Blank. 842$! Check To See If P1 Is Blank.
655$! 843$!
656$ IF (P1.EQS."NORSAREF") 844$ IF (P1.EQS."ALL")
657$ THEN 845$ THEN
658$! 846$!
659$! P1 Is NORSAREF, So Compile With The Regular RSA Libraries. 847$! P1 Is Blank, So Build Everything.
848$!
849$ BUILDALL = "TRUE"
850$!
851$! Else...
852$!
853$ ELSE
854$!
855$! Else, Check To See If P1 Has A Valid Arguement.
856$!
857$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."APPS")
858$ THEN
859$!
860$! A Valid Arguement.
861$!
862$ BUILDALL = P1
863$!
864$! Else...
865$!
866$ ELSE
867$!
868$! Tell The User We Don't Know What They Want.
869$!
870$ WRITE SYS$OUTPUT ""
871$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
872$ WRITE SYS$OUTPUT ""
873$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
874$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.SSL]LIBCRYPTO.OLB Library."
875$ WRITE SYS$OUTPUT " APPS : To Compile Just The [.xxx.EXE.SSL]*.EXE Programs."
876$ WRITE SYS$OUTPUT ""
877$ WRITE SYS$OUTPUT " Where 'xxx' Stands For:"
878$ WRITE SYS$OUTPUT ""
879$ WRITE SYS$OUTPUT " AXP : Alpha Architecture."
880$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
881$ WRITE SYS$OUTPUT ""
882$!
883$! Time To EXIT.
884$!
885$ EXIT
886$!
887$! End The Valid Arguement Check.
888$!
889$ ENDIF
890$!
891$! End The P1 Check.
892$!
893$ ENDIF
894$!
895$! Check To See If P2 Is Blank.
896$!
897$ IF (P2.EQS."NORSAREF")
898$ THEN
899$!
900$! P2 Is NORSAREF, So Compile With The Regular RSA Libraries.
660$! 901$!
661$ RSAREF = "FALSE" 902$ RSAREF = "FALSE"
662$ ELSE 903$ ELSE
663$! 904$!
664$! Check To See If We Are To Use The RSAREF Library. 905$! Check To See If We Are To Use The RSAREF Library.
665$! 906$!
666$ IF (P1.EQS."RSAREF") 907$ IF (P2.EQS."RSAREF")
667$ THEN 908$ THEN
668$! 909$!
669$! Check To Make Sure We Have The RSAREF Source Code Directory. 910$! Check To Make Sure We Have The RSAREF Source Code Directory.
@@ -697,7 +938,7 @@ $!
697$! They Entered An Invalid Option.. 938$! They Entered An Invalid Option..
698$! 939$!
699$ WRITE SYS$OUTPUT "" 940$ WRITE SYS$OUTPUT ""
700$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:" 941$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
701$ WRITE SYS$OUTPUT "" 942$ WRITE SYS$OUTPUT ""
702$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library." 943$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
703$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library." 944$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
@@ -711,16 +952,16 @@ $! End The Valid Arguement Check.
711$! 952$!
712$ ENDIF 953$ ENDIF
713$! 954$!
714$! End The P1 Check. 955$! End The P2 Check.
715$! 956$!
716$ ENDIF 957$ ENDIF
717$! 958$!
718$! Check To See If P2 Is Blank. 959$! Check To See If P3 Is Blank.
719$! 960$!
720$ IF (P2.EQS."NODEBUG") 961$ IF (P3.EQS."NODEBUG")
721$ THEN 962$ THEN
722$! 963$!
723$! P2 Is NODEBUG, So Compile Without The Debugger Information. 964$! P3 Is NODEBUG, So Compile Without The Debugger Information.
724$! 965$!
725$ DEBUGGER = "NODEBUG" 966$ DEBUGGER = "NODEBUG"
726$ TRACEBACK = "NOTRACEBACK" 967$ TRACEBACK = "NOTRACEBACK"
@@ -733,7 +974,7 @@ $ ELSE
733$! 974$!
734$! Check To See If We Are To Compile With Debugger Information. 975$! Check To See If We Are To Compile With Debugger Information.
735$! 976$!
736$ IF (P2.EQS."DEBUG") 977$ IF (P3.EQS."DEBUG")
737$ THEN 978$ THEN
738$! 979$!
739$! Compile With Debugger Information. 980$! Compile With Debugger Information.
@@ -750,7 +991,7 @@ $!
750$! They Entered An Invalid Option.. 991$! They Entered An Invalid Option..
751$! 992$!
752$ WRITE SYS$OUTPUT "" 993$ WRITE SYS$OUTPUT ""
753$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:" 994$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
754$ WRITE SYS$OUTPUT "" 995$ WRITE SYS$OUTPUT ""
755$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information." 996$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
756$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information." 997$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
@@ -764,7 +1005,7 @@ $! End The Valid Arguement Check.
764$! 1005$!
765$ ENDIF 1006$ ENDIF
766$! 1007$!
767$! End The P2 Check. 1008$! End The P3 Check.
768$! 1009$!
769$ ENDIF 1010$ ENDIF
770$! 1011$!
@@ -774,9 +1015,9 @@ $! Written By: Richard Levitte
774$! richard@levitte.org 1015$! richard@levitte.org
775$! 1016$!
776$! 1017$!
777$! Check To See If We Have A Option For P5. 1018$! Check To See If We Have A Option For P6.
778$! 1019$!
779$ IF (P5.EQS."") 1020$ IF (P6.EQS."")
780$ THEN 1021$ THEN
781$! 1022$!
782$! Get The Version Of VMS We Are Using. 1023$! Get The Version Of VMS We Are Using.
@@ -798,13 +1039,13 @@ $! End The VMS Version Check.
798$! 1039$!
799$ ENDIF 1040$ ENDIF
800$! 1041$!
801$! End The P5 Check. 1042$! End The P6 Check.
802$! 1043$!
803$ ENDIF 1044$ ENDIF
804$! 1045$!
805$! Check To See If P3 Is Blank. 1046$! Check To See If P4 Is Blank.
806$! 1047$!
807$ IF (P3.EQS."") 1048$ IF (P4.EQS."")
808$ THEN 1049$ THEN
809$! 1050$!
810$! O.K., The User Didn't Specify A Compiler, Let's Try To 1051$! O.K., The User Didn't Specify A Compiler, Let's Try To
@@ -817,7 +1058,7 @@ $ THEN
817$! 1058$!
818$! Looks Like GNUC, Set To Use GNUC. 1059$! Looks Like GNUC, Set To Use GNUC.
819$! 1060$!
820$ P3 = "GNUC" 1061$ P4 = "GNUC"
821$! 1062$!
822$! Else... 1063$! Else...
823$! 1064$!
@@ -830,7 +1071,7 @@ $ THEN
830$! 1071$!
831$! Looks Like DECC, Set To Use DECC. 1072$! Looks Like DECC, Set To Use DECC.
832$! 1073$!
833$ P3 = "DECC" 1074$ P4 = "DECC"
834$! 1075$!
835$! Else... 1076$! Else...
836$! 1077$!
@@ -838,7 +1079,7 @@ $ ELSE
838$! 1079$!
839$! Looks Like VAXC, Set To Use VAXC. 1080$! Looks Like VAXC, Set To Use VAXC.
840$! 1081$!
841$ P3 = "VAXC" 1082$ P4 = "VAXC"
842$! 1083$!
843$! End The VAXC Compiler Check. 1084$! End The VAXC Compiler Check.
844$! 1085$!
@@ -852,9 +1093,9 @@ $! End The Compiler Check.
852$! 1093$!
853$ ENDIF 1094$ ENDIF
854$! 1095$!
855$! Check To See If We Have A Option For P4. 1096$! Check To See If We Have A Option For P5.
856$! 1097$!
857$ IF (P4.EQS."") 1098$ IF (P5.EQS."")
858$ THEN 1099$ THEN
859$! 1100$!
860$! Find out what socket library we have available 1101$! Find out what socket library we have available
@@ -864,7 +1105,7 @@ $ THEN
864$! 1105$!
865$! We have SOCKETSHR, and it is my opinion that it's the best to use. 1106$! We have SOCKETSHR, and it is my opinion that it's the best to use.
866$! 1107$!
867$ P4 = "SOCKETSHR" 1108$ P5 = "SOCKETSHR"
868$! 1109$!
869$! Tell the user 1110$! Tell the user
870$! 1111$!
@@ -884,7 +1125,7 @@ $ THEN
884$! 1125$!
885$! Last resort: a UCX or UCX-compatible library 1126$! Last resort: a UCX or UCX-compatible library
886$! 1127$!
887$ P4 = "UCX" 1128$ P5 = "UCX"
888$! 1129$!
889$! Tell the user 1130$! Tell the user
890$! 1131$!
@@ -898,22 +1139,46 @@ $ ENDIF
898$! 1139$!
899$! Set Up Initial CC Definitions, Possibly With User Ones 1140$! Set Up Initial CC Definitions, Possibly With User Ones
900$! 1141$!
901$ CCDEFS = "VMS=1,TCPIP_TYPE_''P4'" 1142$ CCDEFS = "VMS=1,TCPIP_TYPE_''P5'"
1143$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
1144$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
1145$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
1146$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
1147$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
1148$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
1149$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
1150$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
1151$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
1152$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
1153$ IF F$TRNLNM("OPENSSL_NO_DES")
1154$ THEN
1155$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
1156$ ELSE
1157$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
1158$ ENDIF
1159$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
1160$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
1161$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
1162$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
1163$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
1164$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
1165$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
1166$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
902$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 1167$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
903$ CCEXTRAFLAGS = "" 1168$ CCEXTRAFLAGS = ""
904$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 1169$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
905$ CCDISABLEWARNINGS = "" 1170$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
906$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - 1171$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
907 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS 1172 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
908$! 1173$!
909$! Check To See If The User Entered A Valid Paramter. 1174$! Check To See If The User Entered A Valid Paramter.
910$! 1175$!
911$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC") 1176$ IF (P4.EQS."VAXC").OR.(P4.EQS."DECC").OR.(P4.EQS."GNUC")
912$ THEN 1177$ THEN
913$! 1178$!
914$! Check To See If The User Wanted DECC. 1179$! Check To See If The User Wanted DECC.
915$! 1180$!
916$ IF (P3.EQS."DECC") 1181$ IF (P4.EQS."DECC")
917$ THEN 1182$ THEN
918$! 1183$!
919$! Looks Like DECC, Set To Use DECC. 1184$! Looks Like DECC, Set To Use DECC.
@@ -942,7 +1207,7 @@ $ ENDIF
942$! 1207$!
943$! Check To See If We Are To Use VAXC. 1208$! Check To See If We Are To Use VAXC.
944$! 1209$!
945$ IF (P3.EQS."VAXC") 1210$ IF (P4.EQS."VAXC")
946$ THEN 1211$ THEN
947$! 1212$!
948$! Looks Like VAXC, Set To Use VAXC. 1213$! Looks Like VAXC, Set To Use VAXC.
@@ -980,7 +1245,7 @@ $ ENDIF
980$! 1245$!
981$! Check To See If We Are To Use GNU C. 1246$! Check To See If We Are To Use GNU C.
982$! 1247$!
983$ IF (P3.EQS."GNUC") 1248$ IF (P4.EQS."GNUC")
984$ THEN 1249$ THEN
985$! 1250$!
986$! Looks Like GNUC, Set To Use GNUC. 1251$! Looks Like GNUC, Set To Use GNUC.
@@ -1051,7 +1316,7 @@ $ CC4DISABLEWARNINGS = ""
1051$ ENDIF 1316$ ENDIF
1052$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS 1317$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS
1053$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS 1318$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
1054$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P2 .NES. "DEBUG" 1319$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P3 .NES. "DEBUG"
1055$ THEN 1320$ THEN
1056$ CC5 = CC + "/OPTIMIZE=NODISJOINT" 1321$ CC5 = CC + "/OPTIMIZE=NODISJOINT"
1057$ ELSE 1322$ ELSE
@@ -1070,7 +1335,7 @@ $!
1070$! Tell The User We Don't Know What They Want. 1335$! Tell The User We Don't Know What They Want.
1071$! 1336$!
1072$ WRITE SYS$OUTPUT "" 1337$ WRITE SYS$OUTPUT ""
1073$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:" 1338$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:"
1074$ WRITE SYS$OUTPUT "" 1339$ WRITE SYS$OUTPUT ""
1075$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C." 1340$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
1076$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C." 1341$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
@@ -1096,12 +1361,12 @@ $ WRITE SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO
1096$! 1361$!
1097$! Time to check the contents, and to make sure we get the correct library. 1362$! Time to check the contents, and to make sure we get the correct library.
1098$! 1363$!
1099$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" 1364$ IF P5.EQS."SOCKETSHR" .OR. P5.EQS."MULTINET" .OR. P5.EQS."UCX"
1100$ THEN 1365$ THEN
1101$! 1366$!
1102$! Check to see if SOCKETSHR was chosen 1367$! Check to see if SOCKETSHR was chosen
1103$! 1368$!
1104$ IF P4.EQS."SOCKETSHR" 1369$ IF P5.EQS."SOCKETSHR"
1105$ THEN 1370$ THEN
1106$! 1371$!
1107$! Set the library to use SOCKETSHR 1372$! Set the library to use SOCKETSHR
@@ -1114,12 +1379,12 @@ $ ENDIF
1114$! 1379$!
1115$! Check to see if MULTINET was chosen 1380$! Check to see if MULTINET was chosen
1116$! 1381$!
1117$ IF P4.EQS."MULTINET" 1382$ IF P5.EQS."MULTINET"
1118$ THEN 1383$ THEN
1119$! 1384$!
1120$! Set the library to use UCX emulation. 1385$! Set the library to use UCX emulation.
1121$! 1386$!
1122$ P4 = "UCX" 1387$ P5 = "UCX"
1123$! 1388$!
1124$! Done with MULTINET 1389$! Done with MULTINET
1125$! 1390$!
@@ -1127,7 +1392,7 @@ $ ENDIF
1127$! 1392$!
1128$! Check to see if UCX was chosen 1393$! Check to see if UCX was chosen
1129$! 1394$!
1130$ IF P4.EQS."UCX" 1395$ IF P5.EQS."UCX"
1131$ THEN 1396$ THEN
1132$! 1397$!
1133$! Set the library to use UCX. 1398$! Set the library to use UCX.
@@ -1156,7 +1421,7 @@ $!
1156$! Tell The User We Don't Know What They Want. 1421$! Tell The User We Don't Know What They Want.
1157$! 1422$!
1158$ WRITE SYS$OUTPUT "" 1423$ WRITE SYS$OUTPUT ""
1159$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:" 1424$ WRITE SYS$OUTPUT "The Option ",P5," Is Invalid. The Valid Options Are:"
1160$ WRITE SYS$OUTPUT "" 1425$ WRITE SYS$OUTPUT ""
1161$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library." 1426$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1162$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library." 1427$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
@@ -1173,9 +1438,9 @@ $!
1173$! Check if the user wanted to compile just a subset of all the encryption 1438$! Check if the user wanted to compile just a subset of all the encryption
1174$! methods. 1439$! methods.
1175$! 1440$!
1176$ IF P6 .NES. "" 1441$ IF P7 .NES. ""
1177$ THEN 1442$ THEN
1178$ ENCRYPT_TYPES = P6 1443$ ENCRYPT_TYPES = P7
1179$ ENDIF 1444$ ENDIF
1180$! 1445$!
1181$! Time To RETURN... 1446$! Time To RETURN...
diff --git a/src/lib/libssl/src/crypto/crypto.h b/src/lib/libssl/src/crypto/crypto.h
index 8ad8c25e5a..41c937966e 100644
--- a/src/lib/libssl/src/crypto/crypto.h
+++ b/src/lib/libssl/src/crypto/crypto.h
@@ -63,17 +63,25 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#include <stdlib.h>
67
66#ifndef NO_FP_API 68#ifndef NO_FP_API
67#include <stdio.h> 69#include <stdio.h>
68#endif 70#endif
69 71
70#include <openssl/stack.h> 72#include <openssl/stack.h>
73#include <openssl/safestack.h>
71#include <openssl/opensslv.h> 74#include <openssl/opensslv.h>
72 75
73#ifdef CHARSET_EBCDIC 76#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h> 77#include <openssl/ebcdic.h>
75#endif 78#endif
76 79
80#if defined(VMS) || defined(__VMS)
81#include "vms_idhacks.h"
82#endif
83
84
77/* Backward compatibility to SSLeay */ 85/* Backward compatibility to SSLeay */
78/* This is more to be used to check the correct DLL is being used 86/* This is more to be used to check the correct DLL is being used
79 * in the MS world. */ 87 * in the MS world. */
@@ -111,7 +119,9 @@ extern "C" {
111#define CRYPTO_LOCK_GETSERVBYNAME 21 119#define CRYPTO_LOCK_GETSERVBYNAME 21
112#define CRYPTO_LOCK_READDIR 22 120#define CRYPTO_LOCK_READDIR 22
113#define CRYPTO_LOCK_RSA_BLINDING 23 121#define CRYPTO_LOCK_RSA_BLINDING 23
114#define CRYPTO_NUM_LOCKS 24 122#define CRYPTO_LOCK_DH 24
123#define CRYPTO_LOCK_MALLOC2 25
124#define CRYPTO_NUM_LOCKS 26
115 125
116#define CRYPTO_LOCK 1 126#define CRYPTO_LOCK 1
117#define CRYPTO_UNLOCK 2 127#define CRYPTO_UNLOCK 2
@@ -147,14 +157,16 @@ extern "C" {
147#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ 157#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
148#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ 158#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
149 159
150/* 160/* The following are bit values to turn on or off options connected to the
151typedef struct crypto_mem_st 161 * malloc checking functionality */
152 { 162
153 char *(*malloc_func)(); 163/* Adds time to the memory checking information */
154 char *(*realloc_func)(); 164#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
155 void (*free_func)(); 165/* Adds thread number to the memory checking information */
156 } CRYPTO_MEM_FUNC; 166#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
157*/ 167
168#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
169
158 170
159/* predec of the BIO type */ 171/* predec of the BIO type */
160typedef struct bio_st BIO_dummy; 172typedef struct bio_st BIO_dummy;
@@ -165,24 +177,30 @@ typedef struct crypto_ex_data_st
165 int dummy; /* gcc is screwing up this data structure :-( */ 177 int dummy; /* gcc is screwing up this data structure :-( */
166 } CRYPTO_EX_DATA; 178 } CRYPTO_EX_DATA;
167 179
180/* Called when a new object is created */
181typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
182 int idx, long argl, void *argp);
183/* Called when an object is free()ed */
184typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
185 int idx, long argl, void *argp);
186/* Called when we need to dup an object */
187typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
188 int idx, long argl, void *argp);
189
168/* This stuff is basically class callback functions 190/* This stuff is basically class callback functions
169 * The current classes are SSL_CTX, SSL, SSL_SESION, and a few more */ 191 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
192
170typedef struct crypto_ex_data_func_st 193typedef struct crypto_ex_data_func_st
171 { 194 {
172 long argl; /* Arbitary long */ 195 long argl; /* Arbitary long */
173 char *argp; /* Arbitary char * */ 196 void *argp; /* Arbitary void * */
174 /* Called when a new object is created */ 197 CRYPTO_EX_new *new_func;
175 int (*new_func)(/*char *obj, 198 CRYPTO_EX_free *free_func;
176 char *item,int index,long argl,char *argp*/); 199 CRYPTO_EX_dup *dup_func;
177 /* Called when this object is free()ed */
178 void (*free_func)(/*char *obj,
179 char *item,int index,long argl,char *argp*/);
180
181 /* Called when we need to dup this one */
182 int (*dup_func)(/*char *obj_to,char *obj_from,
183 char **new,int index,long argl,char *argp*/);
184 } CRYPTO_EX_DATA_FUNCS; 200 } CRYPTO_EX_DATA_FUNCS;
185 201
202DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
203
186/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA 204/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
187 * entry. 205 * entry.
188 */ 206 */
@@ -194,63 +212,54 @@ typedef struct crypto_ex_data_func_st
194#define CRYPTO_EX_INDEX_X509_STORE 4 212#define CRYPTO_EX_INDEX_X509_STORE 4
195#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 213#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
196 214
197/* Use this for win32 DLL's */
198#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
199 (char *(*)())malloc,\
200 (char *(*)())realloc,\
201 (void (*)())free)
202 215
203#ifdef CRYPTO_MDEBUG_ALL 216/* This is the default callbacks, but we can have others as well:
204# ifndef CRYPTO_MDEBUG_TIME 217 * this is needed in Win32 where the application malloc and the
205# define CRYPTO_MDEBUG_TIME 218 * library malloc may not be the same.
206# endif 219 */
207# ifndef CRYPTO_MDEBUG_THREAD 220#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
208# define CRYPTO_MDEBUG_THREAD 221 malloc, realloc, free)
209# endif
210#endif
211 222
212#if defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD 223#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
213# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ 224# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
214# define CRYPTO_MDEBUG 225# define CRYPTO_MDEBUG
215# endif 226# endif
216#endif 227#endif
217 228
218#ifdef CRYPTO_MDEBUG 229/* Set standard debugging functions (not done by default
230 * unless CRYPTO_MDEBUG is defined) */
231#define CRYPTO_malloc_debug_init() do {\
232 CRYPTO_set_mem_debug_functions(\
233 (void (*)())CRYPTO_dbg_malloc,\
234 (void (*)())CRYPTO_dbg_realloc,\
235 (void (*)())CRYPTO_dbg_free,\
236 (void (*)())CRYPTO_dbg_set_options,\
237 (long (*)())CRYPTO_dbg_get_options);\
238 } while(0)
239
240int CRYPTO_mem_ctrl(int mode);
241int CRYPTO_is_mem_check_on(void);
242
243/* for applications */
219#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) 244#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
220#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) 245#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
246
247/* for library-internal use */
221#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) 248#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
222#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) 249#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
223#define Malloc(num) CRYPTO_dbg_malloc((int)num,__FILE__,__LINE__) 250#define is_MemCheck_on() CRYPTO_is_mem_check_on()
251
252#define Malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
224#define Realloc(addr,num) \ 253#define Realloc(addr,num) \
225 CRYPTO_dbg_realloc((char *)addr,(int)num,__FILE__,__LINE__) 254 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
226#define Remalloc(addr,num) \ 255#define Remalloc(addr,num) \
227 CRYPTO_dbg_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 256 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
228#define FreeFunc CRYPTO_dbg_free
229#define Free(addr) CRYPTO_dbg_free(addr)
230#define Malloc_locked(num) CRYPTO_malloc_locked((int)num)
231#define Free_locked(addr) CRYPTO_free_locked(addr)
232#else
233#define MemCheck_start()
234#define MemCheck_stop()
235#define MemCheck_on()
236#define MemCheck_off()
237#define Remalloc CRYPTO_remalloc
238#if defined(WIN32) || defined(MFUNC)
239#define Malloc CRYPTO_malloc
240#define Realloc(a,n) CRYPTO_realloc(a,(n))
241#define FreeFunc CRYPTO_free 257#define FreeFunc CRYPTO_free
242#define Free(addr) CRYPTO_free(addr) 258#define Free(addr) CRYPTO_free(addr)
243#define Malloc_locked CRYPTO_malloc_locked 259
260#define Malloc_locked(num) CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
244#define Free_locked(addr) CRYPTO_free_locked(addr) 261#define Free_locked(addr) CRYPTO_free_locked(addr)
245#else 262
246#define Malloc malloc
247#define Realloc realloc
248#define FreeFunc free
249#define Free(addr) free(addr)
250#define Malloc_locked malloc
251#define Free_locked(addr) free(addr)
252#endif /* WIN32 || MFUNC */
253#endif /* MDEBUG */
254 263
255/* Case insensiteve linking causes problems.... */ 264/* Case insensiteve linking causes problems.... */
256#if defined(WIN16) || defined(VMS) 265#if defined(WIN16) || defined(VMS)
@@ -261,15 +270,15 @@ typedef struct crypto_ex_data_func_st
261const char *SSLeay_version(int type); 270const char *SSLeay_version(int type);
262unsigned long SSLeay(void); 271unsigned long SSLeay(void);
263 272
264int CRYPTO_get_ex_new_index(int idx,STACK **sk,long argl,char *argp, 273int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
265 int (*new_func)(),int (*dup_func)(),void (*free_func)()); 274 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
266int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad,int idx,char *val); 275int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
267char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx); 276void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx);
268int CRYPTO_dup_ex_data(STACK *meth,CRYPTO_EX_DATA *from,CRYPTO_EX_DATA *to); 277int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to,
269void CRYPTO_free_ex_data(STACK *meth,char *obj,CRYPTO_EX_DATA *ad); 278 CRYPTO_EX_DATA *from);
270void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad); 279void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
280void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
271 281
272int CRYPTO_mem_ctrl(int mode);
273int CRYPTO_get_new_lockid(char *name); 282int CRYPTO_get_new_lockid(char *name);
274 283
275int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ 284int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
@@ -289,22 +298,51 @@ const char *CRYPTO_get_lock_name(int type);
289int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 298int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
290 int line); 299 int line);
291 300
292void CRYPTO_set_mem_functions(char *(*m)(),char *(*r)(), void (*free_func)()); 301/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
293void CRYPTO_get_mem_functions(char *(**m)(),char *(**r)(), void (**f)()); 302 * call the latter last if you need different functions */
294void CRYPTO_set_locked_mem_functions(char *(*m)(), void (*free_func)()); 303int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
295void CRYPTO_get_locked_mem_functions(char *(**m)(), void (**f)()); 304int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
305int CRYPTO_set_mem_debug_functions(void (*m)(),void (*r)(),void (*f)(),void (*so)(),long (*go)());
306void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
307void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
308void CRYPTO_get_mem_debug_functions(void (**m)(),void (**r)(),void (**f)(),void (**so)(),long (**go)());
296 309
297void *CRYPTO_malloc_locked(int num); 310void *CRYPTO_malloc_locked(int num, const char *file, int line);
298void CRYPTO_free_locked(void *); 311void CRYPTO_free_locked(void *);
299void *CRYPTO_malloc(int num); 312void *CRYPTO_malloc(int num, const char *file, int line);
300void CRYPTO_free(void *); 313void CRYPTO_free(void *);
301void *CRYPTO_realloc(void *addr,int num); 314void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
302void *CRYPTO_remalloc(void *addr,int num); 315void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
316
317void CRYPTO_set_mem_debug_options(long bits);
318long CRYPTO_get_mem_debug_options(void);
319
320#define CRYPTO_push_info(info) \
321 CRYPTO_push_info_(info, __FILE__, __LINE__);
322int CRYPTO_push_info_(const char *info, const char *file, int line);
323int CRYPTO_pop_info(void);
324int CRYPTO_remove_all_info(void);
325
326/* The last argument has the following significance:
327 *
328 * 0: called before the actual memory allocation has taken place
329 * 1: called after the actual memory allocation has taken place
330 */
331void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
332void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
333void CRYPTO_dbg_free(void *addr,int before_p);
334
335/* Tell the debugging code about options. By default, the following values
336 * apply:
337 *
338 * 0: Clear all options.
339 * 1: Set the "Show Time" option.
340 * 2: Set the "Show Thread Number" option.
341 * 3: 1 + 2
342 */
343void CRYPTO_dbg_set_options(long bits);
344long CRYPTO_dbg_get_options(void);
303 345
304void *CRYPTO_dbg_malloc(int num,const char *file,int line);
305void *CRYPTO_dbg_realloc(void *addr,int num,const char *file,int line);
306void CRYPTO_dbg_free(void *);
307void *CRYPTO_dbg_remalloc(void *addr,int num,const char *file,int line);
308#ifndef NO_FP_API 346#ifndef NO_FP_API
309void CRYPTO_mem_leaks_fp(FILE *); 347void CRYPTO_mem_leaks_fp(FILE *);
310#endif 348#endif
@@ -312,7 +350,7 @@ void CRYPTO_mem_leaks(struct bio_st *bio);
312/* unsigned long order, char *file, int line, int num_bytes, char *addr */ 350/* unsigned long order, char *file, int line, int num_bytes, char *addr */
313void CRYPTO_mem_leaks_cb(void (*cb)()); 351void CRYPTO_mem_leaks_cb(void (*cb)());
314 352
315void ERR_load_CRYPTO_strings(void ); 353void ERR_load_CRYPTO_strings(void);
316 354
317/* BEGIN ERROR CODES */ 355/* BEGIN ERROR CODES */
318/* The following lines are auto generated by the script mkerr.pl. Any changes 356/* The following lines are auto generated by the script mkerr.pl. Any changes
diff --git a/src/lib/libssl/src/crypto/des/Makefile.ssl b/src/lib/libssl/src/crypto/des/Makefile.ssl
index 7f9600cf02..41976655e9 100644
--- a/src/lib/libssl/src/crypto/des/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/des/Makefile.ssl
@@ -15,6 +15,7 @@ MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
16MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
17AR= ar r 17AR= ar r
18RANLIB= ranlib
18DES_ENC= des_enc.o fcrypt_b.o 19DES_ENC= des_enc.o fcrypt_b.o
19# or use 20# or use
20#DES_ENC= dx86-elf.o yx86-elf.o 21#DES_ENC= dx86-elf.o yx86-elf.o
@@ -162,14 +163,15 @@ enc_read.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
162enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 163enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
163enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 164enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
164enc_read.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 165enc_read.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
165enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 166enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
166enc_read.o: ../cryptlib.h des_locl.h 167enc_read.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
167enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
168enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 169enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
169enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 170enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
170enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 171enc_writ.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
171enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 172enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
172enc_writ.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h 173enc_writ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
174enc_writ.o: ../cryptlib.h des_locl.h
173fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h 175fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des.h
174fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h 176fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/e_os2.h
175fcrypt.o: ../../include/openssl/opensslconf.h 177fcrypt.o: ../../include/openssl/opensslconf.h
@@ -187,15 +189,15 @@ pcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h
187qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 189qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
188qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h 190qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h
189rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 191rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
190rand_key.o: ../../include/openssl/opensslconf.h des_locl.h 192rand_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h
191read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 193read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
192read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h 194read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h
193read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 195read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
194read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 196read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
195read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 197read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
196read_pwd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 198read_pwd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
197read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 199read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
198read_pwd.o: ../cryptlib.h des_locl.h 200read_pwd.o: ../../include/openssl/stack.h ../cryptlib.h des_locl.h
199rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 201rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
200rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h 202rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h
201set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 203set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
diff --git a/src/lib/libssl/src/crypto/des/cbc3_enc.c b/src/lib/libssl/src/crypto/des/cbc3_enc.c
index 3863a676d4..527e74f3de 100644
--- a/src/lib/libssl/src/crypto/des/cbc3_enc.c
+++ b/src/lib/libssl/src/crypto/des/cbc3_enc.c
@@ -58,7 +58,7 @@
58 58
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)
@@ -69,11 +69,14 @@ void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
69 69
70 if (enc == DES_ENCRYPT) 70 if (enc == DES_ENCRYPT)
71 { 71 {
72 des_cbc_encrypt(input,output,length,ks1,iv1,enc); 72 des_cbc_encrypt((unsigned char*)input,
73 (unsigned char*)output,length,ks1,iv1,enc);
73 if (length >= sizeof(des_cblock)) 74 if (length >= sizeof(des_cblock))
74 memcpy(niv1,output[off],sizeof(des_cblock)); 75 memcpy(niv1,output[off],sizeof(des_cblock));
75 des_cbc_encrypt(output,output,l8,ks2,iv1,!enc); 76 des_cbc_encrypt((unsigned char*)output,
76 des_cbc_encrypt(output,output,l8,ks1,iv2, enc); 77 (unsigned char*)output,l8,ks2,iv1,!enc);
78 des_cbc_encrypt((unsigned char*)output,
79 (unsigned char*)output,l8,ks1,iv2,enc);
77 if (length >= sizeof(des_cblock)) 80 if (length >= sizeof(des_cblock))
78 memcpy(niv2,output[off],sizeof(des_cblock)); 81 memcpy(niv2,output[off],sizeof(des_cblock));
79 } 82 }
@@ -81,11 +84,14 @@ void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
81 { 84 {
82 if (length >= sizeof(des_cblock)) 85 if (length >= sizeof(des_cblock))
83 memcpy(niv2,input[off],sizeof(des_cblock)); 86 memcpy(niv2,input[off],sizeof(des_cblock));
84 des_cbc_encrypt(input,output,l8,ks1,iv2,enc); 87 des_cbc_encrypt((unsigned char*)input,
85 des_cbc_encrypt(output,output,l8,ks2,iv1,!enc); 88 (unsigned char*)output,l8,ks1,iv2,enc);
89 des_cbc_encrypt((unsigned char*)output,
90 (unsigned char*)output,l8,ks2,iv1,!enc);
86 if (length >= sizeof(des_cblock)) 91 if (length >= sizeof(des_cblock))
87 memcpy(niv1,output[off],sizeof(des_cblock)); 92 memcpy(niv1,output[off],sizeof(des_cblock));
88 des_cbc_encrypt(output,output,length,ks1,iv1, enc); 93 des_cbc_encrypt((unsigned char*)output,
94 (unsigned char*)output,length,ks1,iv1,enc);
89 } 95 }
90 memcpy(*iv1,niv1,sizeof(des_cblock)); 96 memcpy(*iv1,niv1,sizeof(des_cblock));
91 memcpy(*iv2,niv2,sizeof(des_cblock)); 97 memcpy(*iv2,niv2,sizeof(des_cblock));
diff --git a/src/lib/libssl/src/crypto/des/des.c b/src/lib/libssl/src/crypto/des/des.c
index b2d7f0da78..91d7153b34 100644
--- a/src/lib/libssl/src/crypto/des/des.c
+++ b/src/lib/libssl/src/crypto/des/des.c
@@ -325,25 +325,25 @@ void usage(void)
325"des <options> [input-file [output-file]]", 325"des <options> [input-file [output-file]]",
326"options:", 326"options:",
327"-v : des(1) version number", 327"-v : des(1) version number",
328"-e : encrypt using sunOS compatible user key to DES key conversion.", 328"-e : encrypt using SunOS compatible user key to DES key conversion.",
329"-E : encrypt ", 329"-E : encrypt ",
330"-d : decrypt using sunOS compatible user key to DES key conversion.", 330"-d : decrypt using SunOS compatible user key to DES key conversion.",
331"-D : decrypt ", 331"-D : decrypt ",
332"-c[ckname] : generate a cbc_cksum using sunOS compatible user key to", 332"-c[ckname] : generate a cbc_cksum using SunOS compatible user key to",
333" DES key conversion and output to ckname (stdout default,", 333" DES key conversion and output to ckname (stdout default,",
334" stderr if data being output on stdout). The checksum is", 334" stderr if data being output on stdout). The checksum is",
335" generated before encryption and after decryption if used", 335" generated before encryption and after decryption if used",
336" in conjunction with -[eEdD].", 336" in conjunction with -[eEdD].",
337"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].", 337"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].",
338"-k key : use key 'key'", 338"-k key : use key 'key'",
339"-h : the key that is entered will be a hexidecimal number", 339"-h : the key that is entered will be a hexadecimal number",
340" that is used directly as the des key", 340" that is used directly as the des key",
341"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]", 341"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]",
342" (uuname is the filename to put in the uuencode header).", 342" (uuname is the filename to put in the uuencode header).",
343"-b : encrypt using DES in ecb encryption mode, the defaut is cbc mode.", 343"-b : encrypt using DES in ecb encryption mode, the default is cbc mode.",
344"-3 : encrypt using tripple DES encryption. This uses 2 keys", 344"-3 : encrypt using triple DES encryption. This uses 2 keys",
345" generated from the input key. If the input key is less", 345" generated from the input key. If the input key is less",
346" than 8 characters long, this is equivelent to normal", 346" than 8 characters long, this is equivalent to normal",
347" encryption. Default is triple cbc, -b makes it triple ecb.", 347" encryption. Default is triple cbc, -b makes it triple ecb.",
348NULL 348NULL
349}; 349};
@@ -425,7 +425,7 @@ void doencryption(void)
425 else 425 else
426 k2[i-8]=k; 426 k2[i-8]=k;
427 } 427 }
428 des_set_key(&k2,ks2); 428 des_set_key_unchecked(&k2,ks2);
429 memset(k2,0,sizeof(k2)); 429 memset(k2,0,sizeof(k2));
430 } 430 }
431 else if (longk || flag3) 431 else if (longk || flag3)
@@ -433,7 +433,7 @@ void doencryption(void)
433 if (flag3) 433 if (flag3)
434 { 434 {
435 des_string_to_2keys(key,&kk,&k2); 435 des_string_to_2keys(key,&kk,&k2);
436 des_set_key(&k2,ks2); 436 des_set_key_unchecked(&k2,ks2);
437 memset(k2,0,sizeof(k2)); 437 memset(k2,0,sizeof(k2));
438 } 438 }
439 else 439 else
@@ -455,7 +455,7 @@ void doencryption(void)
455 kk[i]=key[i]|0x80; 455 kk[i]=key[i]|0x80;
456 } 456 }
457 457
458 des_set_key(&kk,ks); 458 des_set_key_unchecked(&kk,ks);
459 memset(key,0,sizeof(key)); 459 memset(key,0,sizeof(key));
460 memset(kk,0,sizeof(kk)); 460 memset(kk,0,sizeof(kk));
461 /* woops - A bug that does not showup under unix :-( */ 461 /* woops - A bug that does not showup under unix :-( */
@@ -484,7 +484,7 @@ void doencryption(void)
484 if (feof(DES_IN)) 484 if (feof(DES_IN))
485 { 485 {
486 for (i=7-rem; i>0; i--) 486 for (i=7-rem; i>0; i--)
487 RAND_bytes(buf + l++, 1); 487 RAND_pseudo_bytes(buf + l++, 1);
488 buf[l++]=rem; 488 buf[l++]=rem;
489 ex=1; 489 ex=1;
490 len+=rem; 490 len+=rem;
diff --git a/src/lib/libssl/src/crypto/des/des.h b/src/lib/libssl/src/crypto/des/des.h
index 67f90aaf17..98a9c4127c 100644
--- a/src/lib/libssl/src/crypto/des/des.h
+++ b/src/lib/libssl/src/crypto/des/des.h
@@ -186,15 +186,20 @@ void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
186DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[], 186DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[],
187 long length,int out_count,des_cblock *seed); 187 long length,int out_count,des_cblock *seed);
188void des_random_seed(des_cblock *key); 188void des_random_seed(des_cblock *key);
189void des_random_key(des_cblock *ret); 189int des_random_key(des_cblock *ret);
190int des_read_password(des_cblock *key,const char *prompt,int verify); 190int des_read_password(des_cblock *key,const char *prompt,int verify);
191int des_read_2passwords(des_cblock *key1,des_cblock *key2, 191int des_read_2passwords(des_cblock *key1,des_cblock *key2,
192 const char *prompt,int verify); 192 const char *prompt,int verify);
193int des_read_pw_string(char *buf,int length,const char *prompt,int verify); 193int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
194void des_set_odd_parity(des_cblock *key); 194void des_set_odd_parity(des_cblock *key);
195int des_is_weak_key(const_des_cblock *key); 195int des_is_weak_key(const_des_cblock *key);
196/* des_set_key (= set_key = des_key_sched = key_sched) calls
197 * des_set_key_checked if global variable des_check_key is set,
198 * des_set_key_unchecked otherwise. */
196int des_set_key(const_des_cblock *key,des_key_schedule schedule); 199int des_set_key(const_des_cblock *key,des_key_schedule schedule);
197int des_key_sched(const_des_cblock *key,des_key_schedule schedule); 200int des_key_sched(const_des_cblock *key,des_key_schedule schedule);
201int des_set_key_checked(const_des_cblock *key,des_key_schedule schedule);
202void des_set_key_unchecked(const_des_cblock *key,des_key_schedule schedule);
198void des_string_to_key(const char *str,des_cblock *key); 203void des_string_to_key(const char *str,des_cblock *key);
199void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2); 204void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2);
200void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, 205void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
diff --git a/src/lib/libssl/src/crypto/des/des_locl.h b/src/lib/libssl/src/crypto/des/des_locl.h
index d6ea17cb68..4dfed199a7 100644
--- a/src/lib/libssl/src/crypto/des/des_locl.h
+++ b/src/lib/libssl/src/crypto/des/des_locl.h
@@ -72,7 +72,11 @@
72 72
73#ifndef MSDOS 73#ifndef MSDOS
74#if !defined(VMS) || defined(__DECC) 74#if !defined(VMS) || defined(__DECC)
75#include OPENSSL_UNISTD 75#ifdef OPENSSL_UNISTD
76# include OPENSSL_UNISTD
77#else
78# include <unistd.h>
79#endif
76#include <math.h> 80#include <math.h>
77#endif 81#endif
78#endif 82#endif
@@ -178,14 +182,14 @@
178#endif 182#endif
179 183
180/* The changes to this macro may help or hinder, depending on the 184/* The changes to this macro may help or hinder, depending on the
181 * compiler and the achitecture. gcc2 always seems to do well :-). 185 * compiler and the architecture. gcc2 always seems to do well :-).
182 * Inspired by Dana How <how@isl.stanford.edu> 186 * Inspired by Dana How <how@isl.stanford.edu>
183 * DO NOT use the alternative version on machines with 8 byte longs. 187 * DO NOT use the alternative version on machines with 8 byte longs.
184 * It does not seem to work on the Alpha, even when DES_LONG is 4 188 * It does not seem to work on the Alpha, even when DES_LONG is 4
185 * bytes, probably an issue of accessing non-word aligned objects :-( */ 189 * bytes, probably an issue of accessing non-word aligned objects :-( */
186#ifdef DES_PTR 190#ifdef DES_PTR
187 191
188/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there 192/* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there
189 * is no reason to not xor all the sub items together. This potentially 193 * is no reason to not xor all the sub items together. This potentially
190 * saves a register since things can be xored directly into L */ 194 * saves a register since things can be xored directly into L */
191 195
diff --git a/src/lib/libssl/src/crypto/des/des_opts.c b/src/lib/libssl/src/crypto/des/des_opts.c
index 746c456f8f..b2ca7ac31d 100644
--- a/src/lib/libssl/src/crypto/des/des_opts.c
+++ b/src/lib/libssl/src/crypto/des/des_opts.c
@@ -434,17 +434,17 @@ int main(int argc, char **argv)
434 } 434 }
435 435
436#ifndef TIMES 436#ifndef TIMES
437 fprintf(stderr,"To get the most acurate results, try to run this\n"); 437 fprintf(stderr,"To get the most accurate results, try to run this\n");
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(&key,sch); 441 des_set_key_unchecked(&key,sch);
442 des_set_key(&key2,sch2); 442 des_set_key_unchecked(&key2,sch2);
443 des_set_key(&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(&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;
diff --git a/src/lib/libssl/src/crypto/des/destest.c b/src/lib/libssl/src/crypto/des/destest.c
index 5a04fc9298..9ad4ecb072 100644
--- a/src/lib/libssl/src/crypto/des/destest.c
+++ b/src/lib/libssl/src/crypto/des/destest.c
@@ -234,7 +234,7 @@ static unsigned char cipher_ecb2[NUM_TESTS-1][8]={
234 {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}}; 234 {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}};
235 235
236static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; 236static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
237static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; 237static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86};
238static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; 238static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
239static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; 239static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
240/* Changed the following text constant to binary so it will work on ebcdic 240/* Changed the following text constant to binary so it will work on ebcdic
@@ -254,12 +254,24 @@ static unsigned char cbc_ok[32]={
254 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68, 254 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68,
255 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 255 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
256 256
257#ifdef SCREW_THE_PARITY
258#error "SCREW_THE_PARITY is not ment to be defined."
259#error "Original vectors are preserved for reference only."
260static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
257static unsigned char xcbc_ok[32]={ 261static unsigned char xcbc_ok[32]={
258 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48, 262 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48,
259 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD, 263 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD,
260 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76, 264 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76,
261 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2, 265 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2,
262 }; 266 };
267#else
268static unsigned char xcbc_ok[32]={
269 0x84,0x6B,0x29,0x14,0x85,0x1E,0x9A,0x29,
270 0x54,0x73,0x2F,0x8A,0xA0,0xA6,0x11,0xC1,
271 0x15,0xCD,0xC2,0xD7,0x95,0x1B,0x10,0x53,
272 0xA6,0x3C,0x5E,0x03,0xB2,0x1A,0xA3,0xC4,
273 };
274#endif
263 275
264static unsigned char cbc3_ok[32]={ 276static unsigned char cbc3_ok[32]={
265 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0, 277 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0,
@@ -309,8 +321,8 @@ static unsigned char ofb_cipher[24]=
309 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 321 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
310 }; 322 };
311 323
312DES_LONG cbc_cksum_ret=0xB462FEF7L; 324static DES_LONG cbc_cksum_ret=0xB462FEF7L;
313unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 325static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
314 326
315static char *pt(unsigned char *p); 327static char *pt(unsigned char *p);
316static int cfb_test(int bits, unsigned char *cfb_cipher); 328static int cfb_test(int bits, unsigned char *cfb_cipher);
@@ -331,17 +343,17 @@ int main(int argc, char *argv[])
331 343
332#ifndef NO_DESCBCM 344#ifndef NO_DESCBCM
333 printf("Doing cbcm\n"); 345 printf("Doing cbcm\n");
334 if ((j=des_key_sched(&cbc_key,ks)) != 0) 346 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
335 { 347 {
336 printf("Key error %d\n",j); 348 printf("Key error %d\n",j);
337 err=1; 349 err=1;
338 } 350 }
339 if ((j=des_key_sched(&cbc2_key,ks2)) != 0) 351 if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0)
340 { 352 {
341 printf("Key error %d\n",j); 353 printf("Key error %d\n",j);
342 err=1; 354 err=1;
343 } 355 }
344 if ((j=des_key_sched(&cbc3_key,ks3)) != 0) 356 if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0)
345 { 357 {
346 printf("Key error %d\n",j); 358 printf("Key error %d\n",j);
347 err=1; 359 err=1;
@@ -385,11 +397,7 @@ int main(int argc, char *argv[])
385 printf("Doing ecb\n"); 397 printf("Doing ecb\n");
386 for (i=0; i<NUM_TESTS; i++) 398 for (i=0; i<NUM_TESTS; i++)
387 { 399 {
388 if ((j=des_key_sched(&key_data[i],ks)) != 0) 400 des_set_key_unchecked(&key_data[i],ks);
389 {
390 printf("Key error %2d:%d\n",i+1,j);
391 err=1;
392 }
393 memcpy(in,plain_data[i],8); 401 memcpy(in,plain_data[i],8);
394 memset(out,0,8); 402 memset(out,0,8);
395 memset(outin,0,8); 403 memset(outin,0,8);
@@ -415,21 +423,9 @@ int main(int argc, char *argv[])
415 printf("Doing ede ecb\n"); 423 printf("Doing ede ecb\n");
416 for (i=0; i<(NUM_TESTS-1); i++) 424 for (i=0; i<(NUM_TESTS-1); i++)
417 { 425 {
418 if ((j=des_key_sched(&key_data[i],ks)) != 0) 426 des_set_key_unchecked(&key_data[i],ks);
419 { 427 des_set_key_unchecked(&key_data[i+1],ks2);
420 err=1; 428 des_set_key_unchecked(&key_data[i+2],ks3);
421 printf("Key error %2d:%d\n",i+1,j);
422 }
423 if ((j=des_key_sched(&key_data[i+1],ks2)) != 0)
424 {
425 printf("Key error %2d:%d\n",i+2,j);
426 err=1;
427 }
428 if ((j=des_key_sched(&key_data[i+2],ks3)) != 0)
429 {
430 printf("Key error %2d:%d\n",i+3,j);
431 err=1;
432 }
433 memcpy(in,plain_data[i],8); 429 memcpy(in,plain_data[i],8);
434 memset(out,0,8); 430 memset(out,0,8);
435 memset(outin,0,8); 431 memset(outin,0,8);
@@ -453,7 +449,7 @@ int main(int argc, char *argv[])
453#endif 449#endif
454 450
455 printf("Doing cbc\n"); 451 printf("Doing cbc\n");
456 if ((j=des_key_sched(&cbc_key,ks)) != 0) 452 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
457 { 453 {
458 printf("Key error %d\n",j); 454 printf("Key error %d\n",j);
459 err=1; 455 err=1;
@@ -464,7 +460,10 @@ int main(int argc, char *argv[])
464 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, 460 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
465 &iv3,DES_ENCRYPT); 461 &iv3,DES_ENCRYPT);
466 if (memcmp(cbc_out,cbc_ok,32) != 0) 462 if (memcmp(cbc_out,cbc_ok,32) != 0)
463 {
467 printf("cbc_encrypt encrypt error\n"); 464 printf("cbc_encrypt encrypt error\n");
465 err=1;
466 }
468 467
469 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 468 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
470 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, 469 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
@@ -477,7 +476,7 @@ int main(int argc, char *argv[])
477 476
478#ifndef LIBDES_LIT 477#ifndef LIBDES_LIT
479 printf("Doing desx cbc\n"); 478 printf("Doing desx cbc\n");
480 if ((j=des_key_sched(&cbc_key,ks)) != 0) 479 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
481 { 480 {
482 printf("Key error %d\n",j); 481 printf("Key error %d\n",j);
483 err=1; 482 err=1;
@@ -490,6 +489,7 @@ int main(int argc, char *argv[])
490 if (memcmp(cbc_out,xcbc_ok,32) != 0) 489 if (memcmp(cbc_out,xcbc_ok,32) != 0)
491 { 490 {
492 printf("des_xcbc_encrypt encrypt error\n"); 491 printf("des_xcbc_encrypt encrypt error\n");
492 err=1;
493 } 493 }
494 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 494 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
495 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, 495 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
@@ -502,17 +502,17 @@ int main(int argc, char *argv[])
502#endif 502#endif
503 503
504 printf("Doing ede cbc\n"); 504 printf("Doing ede cbc\n");
505 if ((j=des_key_sched(&cbc_key,ks)) != 0) 505 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
506 { 506 {
507 printf("Key error %d\n",j); 507 printf("Key error %d\n",j);
508 err=1; 508 err=1;
509 } 509 }
510 if ((j=des_key_sched(&cbc2_key,ks2)) != 0) 510 if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0)
511 { 511 {
512 printf("Key error %d\n",j); 512 printf("Key error %d\n",j);
513 err=1; 513 err=1;
514 } 514 }
515 if ((j=des_key_sched(&cbc3_key,ks3)) != 0) 515 if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0)
516 { 516 {
517 printf("Key error %d\n",j); 517 printf("Key error %d\n",j);
518 err=1; 518 err=1;
@@ -543,7 +543,7 @@ int main(int argc, char *argv[])
543 543
544#ifndef LIBDES_LIT 544#ifndef LIBDES_LIT
545 printf("Doing pcbc\n"); 545 printf("Doing pcbc\n");
546 if ((j=des_key_sched(&cbc_key,ks)) != 0) 546 if ((j=des_set_key_checked(&cbc_key,ks)) != 0)
547 { 547 {
548 printf("Key error %d\n",j); 548 printf("Key error %d\n",j);
549 err=1; 549 err=1;
@@ -606,7 +606,7 @@ int main(int argc, char *argv[])
606 printf("done\n"); 606 printf("done\n");
607 607
608 printf("Doing ofb\n"); 608 printf("Doing ofb\n");
609 des_key_sched(&ofb_key,ks); 609 des_set_key_checked(&ofb_key,ks);
610 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 610 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
611 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp); 611 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
612 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 612 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
@@ -635,7 +635,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
635 } 635 }
636 636
637 printf("Doing ofb64\n"); 637 printf("Doing ofb64\n");
638 des_key_sched(&ofb_key,ks); 638 des_set_key_checked(&ofb_key,ks);
639 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 639 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
640 memset(ofb_buf1,0,sizeof(ofb_buf1)); 640 memset(ofb_buf1,0,sizeof(ofb_buf1));
641 memset(ofb_buf2,0,sizeof(ofb_buf1)); 641 memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -660,7 +660,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
660 } 660 }
661 661
662 printf("Doing ede_ofb64\n"); 662 printf("Doing ede_ofb64\n");
663 des_key_sched(&ofb_key,ks); 663 des_set_key_checked(&ofb_key,ks);
664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
665 memset(ofb_buf1,0,sizeof(ofb_buf1)); 665 memset(ofb_buf1,0,sizeof(ofb_buf1));
666 memset(ofb_buf2,0,sizeof(ofb_buf1)); 666 memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -686,7 +686,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
686 } 686 }
687 687
688 printf("Doing cbc_cksum\n"); 688 printf("Doing cbc_cksum\n");
689 des_key_sched(&cbc_key,ks); 689 des_set_key_checked(&cbc_key,ks);
690 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv); 690 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
691 if (cs != cbc_cksum_ret) 691 if (cs != cbc_cksum_ret)
692 { 692 {
@@ -795,8 +795,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
795 err=1; 795 err=1;
796 } 796 }
797 printf("\n"); 797 printf("\n");
798 exit(err); 798 return(err);
799 return(0);
800 } 799 }
801 800
802static char *pt(unsigned char *p) 801static char *pt(unsigned char *p)
@@ -825,7 +824,7 @@ static int cfb_test(int bits, unsigned char *cfb_cipher)
825 des_key_schedule ks; 824 des_key_schedule ks;
826 int i,err=0; 825 int i,err=0;
827 826
828 des_key_sched(&cfb_key,ks); 827 des_set_key_checked(&cfb_key,ks);
829 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 828 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
830 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp, 829 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
831 DES_ENCRYPT); 830 DES_ENCRYPT);
@@ -854,7 +853,7 @@ static int cfb64_test(unsigned char *cfb_cipher)
854 des_key_schedule ks; 853 des_key_schedule ks;
855 int err=0,i,n; 854 int err=0,i,n;
856 855
857 des_key_sched(&cfb_key,ks); 856 des_set_key_checked(&cfb_key,ks);
858 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 857 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
859 n=0; 858 n=0;
860 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT); 859 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
@@ -887,7 +886,7 @@ static int ede_cfb64_test(unsigned char *cfb_cipher)
887 des_key_schedule ks; 886 des_key_schedule ks;
888 int err=0,i,n; 887 int err=0,i,n;
889 888
890 des_key_sched(&cfb_key,ks); 889 des_set_key_checked(&cfb_key,ks);
891 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 890 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
892 n=0; 891 n=0;
893 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n, 892 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
diff --git a/src/lib/libssl/src/crypto/des/enc_read.c b/src/lib/libssl/src/crypto/des/enc_read.c
index 694970ccd2..7399ff7269 100644
--- a/src/lib/libssl/src/crypto/des/enc_read.c
+++ b/src/lib/libssl/src/crypto/des/enc_read.c
@@ -147,7 +147,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
147 /* first - get the length */ 147 /* first - get the length */
148 while (net_num < HDRSIZE) 148 while (net_num < HDRSIZE)
149 { 149 {
150 i=read(fd,&(net[net_num]),HDRSIZE-net_num); 150 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
151#ifdef EINTR 151#ifdef EINTR
152 if ((i == -1) && (errno == EINTR)) continue; 152 if ((i == -1) && (errno == EINTR)) continue;
153#endif 153#endif
@@ -169,7 +169,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
169 net_num=0; 169 net_num=0;
170 while (net_num < rnum) 170 while (net_num < rnum)
171 { 171 {
172 i=read(fd,&(net[net_num]),rnum-net_num); 172 i=read(fd,(void *)&(net[net_num]),rnum-net_num);
173#ifdef EINTR 173#ifdef EINTR
174 if ((i == -1) && (errno == EINTR)) continue; 174 if ((i == -1) && (errno == EINTR)) continue;
175#endif 175#endif
diff --git a/src/lib/libssl/src/crypto/des/enc_writ.c b/src/lib/libssl/src/crypto/des/enc_writ.c
index ba3f0822ef..4d3452724e 100644
--- a/src/lib/libssl/src/crypto/des/enc_writ.c
+++ b/src/lib/libssl/src/crypto/des/enc_writ.c
@@ -130,12 +130,12 @@ int des_enc_write(int fd, const void *_buf, int len,
130 { 130 {
131 cp=shortbuf; 131 cp=shortbuf;
132 memcpy(shortbuf,buf,len); 132 memcpy(shortbuf,buf,len);
133 RAND_bytes(shortbuf+len, 8-len); 133 RAND_pseudo_bytes(shortbuf+len, 8-len);
134 rnum=8; 134 rnum=8;
135 } 135 }
136 else 136 else
137 { 137 {
138 cp=(unsigned char*)buf; 138 cp=buf;
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
@@ -152,13 +152,16 @@ int des_enc_write(int fd, const void *_buf, int len,
152 for (j=0; j<outnum; j+=i) 152 for (j=0; j<outnum; j+=i)
153 { 153 {
154 /* eay 26/08/92 I was not doing writing from where we 154 /* eay 26/08/92 I was not doing writing from where we
155 * got upto. */ 155 * got up to. */
156 i=write(fd,&(outbuf[j]),outnum-j); 156 i=write(fd,(void *)&(outbuf[j]),outnum-j);
157 if (i == -1) 157 if (i == -1)
158 { 158 {
159#ifdef EINTR
159 if (errno == EINTR) 160 if (errno == EINTR)
160 i=0; 161 i=0;
161 else /* This is really a bad error - very bad 162 else
163#endif
164 /* This is really a bad error - very bad
162 * It will stuff-up both ends. */ 165 * It will stuff-up both ends. */
163 return(-1); 166 return(-1);
164 } 167 }
diff --git a/src/lib/libssl/src/crypto/des/fcrypt.c b/src/lib/libssl/src/crypto/des/fcrypt.c
index f36746b376..fa1b8aa34a 100644
--- a/src/lib/libssl/src/crypto/des/fcrypt.c
+++ b/src/lib/libssl/src/crypto/des/fcrypt.c
@@ -1,7 +1,7 @@
1/* NOCW */ 1/* NOCW */
2#include <stdio.h> 2#include <stdio.h>
3 3
4/* This version of crypt has been developed from my MIT compatable 4/* This version of crypt has been developed from my MIT compatible
5 * DES library. 5 * DES library.
6 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au 6 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
7 * Eric Young (eay@cryptsoft.com) 7 * Eric Young (eay@cryptsoft.com)
@@ -11,7 +11,7 @@
11 * I have included directive PARA for shared memory computers. 11 * I have included directive PARA for shared memory computers.
12 * I have included a directive LONGCRYPT to using this routine to cipher 12 * I have included a directive LONGCRYPT to using this routine to cipher
13 * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN 13 * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN
14 * definition is the maximum of lenght of password and can changed. I have 14 * definition is the maximum of length of password and can changed. I have
15 * defined 24. 15 * defined 24.
16 */ 16 */
17 17
@@ -103,8 +103,8 @@ char *ret;
103 * returns *\0XXXXXXXXX 103 * returns *\0XXXXXXXXX
104 * The \0 makes the string look like * so the pwd "*" would 104 * The \0 makes the string look like * so the pwd "*" would
105 * crypt to "*". This was found when replacing the crypt in 105 * crypt to "*". This was found when replacing the crypt in
106 * our shared libraries. People found that the disbled 106 * our shared libraries. People found that the disabled
107 * accounts effectivly had no passwd :-(. */ 107 * accounts effectively had no passwd :-(. */
108 x=ret[0]=((salt[0] == '\0')?'A':salt[0]); 108 x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
109 Eswap0=con_salt[x]<<2; 109 Eswap0=con_salt[x]<<2;
110 x=ret[1]=((salt[1] == '\0')?'A':salt[1]); 110 x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
@@ -123,7 +123,7 @@ r=(r+7)/8;
123 for (; i<8; i++) 123 for (; i<8; i++)
124 key[i]=0; 124 key[i]=0;
125 125
126 des_set_key((des_cblock *)(key),ks); 126 des_set_key_unchecked(&key,ks);
127 fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); 127 fcrypt_body(&(out[0]),ks,Eswap0,Eswap1);
128 128
129 ll=out[0]; l2c(ll,b); 129 ll=out[0]; l2c(ll,b);
diff --git a/src/lib/libssl/src/crypto/des/fcrypt_b.c b/src/lib/libssl/src/crypto/des/fcrypt_b.c
index 9cbea97c1f..83c94054e3 100644
--- a/src/lib/libssl/src/crypto/des/fcrypt_b.c
+++ b/src/lib/libssl/src/crypto/des/fcrypt_b.c
@@ -58,7 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61/* This version of crypt has been developed from my MIT compatable 61/* This version of crypt has been developed from my MIT compatible
62 * DES library. 62 * DES library.
63 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au 63 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
64 * Eric Young (eay@cryptsoft.com) 64 * Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libssl/src/crypto/des/rand_key.c b/src/lib/libssl/src/crypto/des/rand_key.c
index fc11792cda..7816a8f25c 100644
--- a/src/lib/libssl/src/crypto/des/rand_key.c
+++ b/src/lib/libssl/src/crypto/des/rand_key.c
@@ -1,114 +1,69 @@
1/* crypto/des/rand_key.c */ 1/* crypto/des/rand_key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* ====================================================================
3 * All rights reserved. 3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
4 * 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 5 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
25 * are met: 7 * are met:
26 * 1. Redistributions of source code must retain the copyright 8 *
27 * notice, this list of conditions and the following disclaimer. 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
28 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in
30 * documentation and/or other materials provided with the distribution. 14 * the documentation and/or other materials provided with the
31 * 3. All advertising materials mentioning features or use of this software 15 * distribution.
32 * must display the following acknowledgement: 16 *
33 * "This product includes cryptographic software written by 17 * 3. All advertising materials mentioning features or use of this
34 * Eric Young (eay@cryptsoft.com)" 18 * software must display the following acknowledgment:
35 * The word 'cryptographic' can be left out if the rouines from the library 19 * "This product includes software developed by the OpenSSL Project
36 * being used are not cryptographic related :-). 20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
37 * 4. If you include any Windows specific code (or a derivative thereof) from 21 *
38 * the apps directory (application code) you must include an acknowledgement: 22 * 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)" 23 * endorse or promote products derived from this software without
40 * 24 * prior written permission. For written permission, please contact
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 25 * openssl-core@openssl.org.
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 *
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * 5. Products derived from this software may not be called "OpenSSL"
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 28 * nor may "OpenSSL" appear in their names without prior written
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * permission of the OpenSSL Project.
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 *
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * 6. Redistributions of any form whatsoever must retain the following
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * acknowledgment:
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * "This product includes software developed by the OpenSSL Project
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
51 * SUCH DAMAGE. 35 *
52 * 36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
53 * The licence and distribution terms for any publically available version or 37 * 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 38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * copied and put under another distribution licence 39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
56 * [including the GNU Public Licence.] 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 *
57 */ 54 */
58 55
59#include "des_locl.h" 56#include <openssl/des.h>
60#include <time.h> 57#include <openssl/rand.h>
61
62static int seed=0;
63static des_cblock init;
64 58
65void des_random_seed(des_cblock *key) 59void des_random_seed(des_cblock *key)
66 { 60 {
67 memcpy(&init,key,sizeof(des_cblock)); 61 RAND_seed(key, sizeof(des_cblock));
68 seed=1;
69 } 62 }
70 63
71void des_random_key(des_cblock *ret) 64int des_random_key(des_cblock *ret)
72 { 65 {
73 des_key_schedule ks; 66 int r = RAND_bytes((unsigned char *)ret, sizeof(des_cblock));
74 static DES_LONG c=0; 67 des_set_odd_parity(ret);
75 static unsigned short pid=0; 68 return r;
76 static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
77 des_cblock key;
78 unsigned char *p;
79 DES_LONG t;
80 int i;
81
82#ifdef MSDOS
83 pid=1;
84#else
85 if (!pid) pid=getpid();
86#endif
87 p=key;
88 if (seed)
89 {
90 for (i=0; i<8; i++)
91 {
92 data[i] ^= init[i];
93 init[i]=0;
94 }
95 seed=0;
96 }
97 t=(DES_LONG)time(NULL);
98 l2c(t,p);
99 t=(DES_LONG)((pid)|((c++)<<16));
100 l2c(t,p);
101
102 des_set_odd_parity(&data);
103 des_set_key(&data,ks);
104 des_cbc_cksum(key,&key,sizeof(key),ks,&data);
105
106 des_set_odd_parity(&key);
107 des_set_key(&key,ks);
108 des_cbc_cksum(key,&data,sizeof(key),ks,&key);
109
110 memcpy(ret,data,sizeof(key));
111 memset(key,0,sizeof(key));
112 memset(ks,0,sizeof(ks));
113 t=0;
114 } 69 }
diff --git a/src/lib/libssl/src/crypto/des/read_pwd.c b/src/lib/libssl/src/crypto/des/read_pwd.c
index fed49652c0..fa2d67da64 100644
--- a/src/lib/libssl/src/crypto/des/read_pwd.c
+++ b/src/lib/libssl/src/crypto/des/read_pwd.c
@@ -58,7 +58,11 @@
58 58
59#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) 59#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
60#include <openssl/opensslconf.h> 60#include <openssl/opensslconf.h>
61#include OPENSSL_UNISTD 61#ifdef OPENSSL_UNISTD
62# include OPENSSL_UNISTD
63#else
64# include <unistd.h>
65#endif
62/* If unistd.h defines _POSIX_VERSION, we conclude that we 66/* If unistd.h defines _POSIX_VERSION, we conclude that we
63 * are on a POSIX system and have sigaction and termios. */ 67 * are on a POSIX system and have sigaction and termios. */
64#if defined(_POSIX_VERSION) 68#if defined(_POSIX_VERSION)
@@ -123,7 +127,7 @@
123#undef SGTTY 127#undef SGTTY
124#endif 128#endif
125 129
126#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) 130#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE)
127#undef TERMIOS 131#undef TERMIOS
128#undef TERMIO 132#undef TERMIO
129#define SGTTY 133#define SGTTY
@@ -153,7 +157,7 @@
153#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) 157#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
154#endif 158#endif
155 159
156#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) 160#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) && !defined(MAC_OS_pre_X)
157#include <sys/ioctl.h> 161#include <sys/ioctl.h>
158#endif 162#endif
159 163
@@ -174,6 +178,15 @@ struct IOSB {
174 }; 178 };
175#endif 179#endif
176 180
181#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
182/*
183 * This one needs work. As a matter of fact the code is unoperational
184 * and this is only a trick to get it compiled.
185 * <appro@fy.chalmers.se>
186 */
187#define TTY_STRUCT int
188#endif
189
177#ifndef NX509_SIG 190#ifndef NX509_SIG
178#define NX509_SIG 32 191#define NX509_SIG 32
179#endif 192#endif
diff --git a/src/lib/libssl/src/crypto/des/rpc_enc.c b/src/lib/libssl/src/crypto/des/rpc_enc.c
index c96c204147..32d96d5cae 100644
--- a/src/lib/libssl/src/crypto/des/rpc_enc.c
+++ b/src/lib/libssl/src/crypto/des/rpc_enc.c
@@ -66,7 +66,7 @@ int _des_crypt(char *buf, int len, struct desparams *desp)
66 des_key_schedule ks; 66 des_key_schedule ks;
67 int enc; 67 int enc;
68 68
69 des_set_key(&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)
diff --git a/src/lib/libssl/src/crypto/des/set_key.c b/src/lib/libssl/src/crypto/des/set_key.c
index 52553a4c16..bbdc71ba6b 100644
--- a/src/lib/libssl/src/crypto/des/set_key.c
+++ b/src/lib/libssl/src/crypto/des/set_key.c
@@ -125,7 +125,7 @@ int des_is_weak_key(const_des_cblock *key)
125 int i; 125 int i;
126 126
127 for (i=0; i<NUM_WEAK_KEY; i++) 127 for (i=0; i<NUM_WEAK_KEY; i++)
128 /* Added == 0 to comparision, I obviously don't run 128 /* Added == 0 to comparison, I obviously don't run
129 * this section very often :-(, thanks to 129 * this section very often :-(, thanks to
130 * engineering@MorningStar.Com for the fix 130 * engineering@MorningStar.Com for the fix
131 * eay 93/06/29 131 * eay 93/06/29
@@ -145,11 +145,34 @@ int des_is_weak_key(const_des_cblock *key)
145#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ 145#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
146 (a)=(a)^(t)^(t>>(16-(n)))) 146 (a)=(a)^(t)^(t>>(16-(n))))
147 147
148int des_set_key(const_des_cblock *key, des_key_schedule schedule)
149 {
150 if (des_check_key)
151 {
152 return des_set_key_checked(key, schedule);
153 }
154 else
155 {
156 des_set_key_unchecked(key, schedule);
157 return 0;
158 }
159 }
160
148/* return 0 if key parity is odd (correct), 161/* return 0 if key parity is odd (correct),
149 * return -1 if key parity error, 162 * return -1 if key parity error,
150 * return -2 if illegal weak key. 163 * return -2 if illegal weak key.
151 */ 164 */
152int des_set_key(const_des_cblock *key, des_key_schedule schedule) 165int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule)
166 {
167 if (!check_parity(key))
168 return(-1);
169 if (des_is_weak_key(key))
170 return(-2);
171 des_set_key_unchecked(key, schedule);
172 return 0;
173 }
174
175void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
153 { 176 {
154 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 177 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
155 register DES_LONG c,d,t,s,t2; 178 register DES_LONG c,d,t,s,t2;
@@ -157,15 +180,6 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
157 register DES_LONG *k; 180 register DES_LONG *k;
158 register int i; 181 register int i;
159 182
160 if (des_check_key)
161 {
162 if (!check_parity(key))
163 return(-1);
164
165 if (des_is_weak_key(key))
166 return(-2);
167 }
168
169 k = &schedule->ks.deslong[0]; 183 k = &schedule->ks.deslong[0];
170 in = &(*key)[0]; 184 in = &(*key)[0];
171 185
@@ -225,7 +239,6 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
225 t2=((s>>16L)|(t&0xffff0000L)); 239 t2=((s>>16L)|(t&0xffff0000L));
226 *(k++)=ROTATE(t2,26)&0xffffffffL; 240 *(k++)=ROTATE(t2,26)&0xffffffffL;
227 } 241 }
228 return(0);
229 } 242 }
230 243
231int des_key_sched(const_des_cblock *key, des_key_schedule schedule) 244int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
diff --git a/src/lib/libssl/src/crypto/des/speed.c b/src/lib/libssl/src/crypto/des/speed.c
index da41abcb03..814b86f4ae 100644
--- a/src/lib/libssl/src/crypto/des/speed.c
+++ b/src/lib/libssl/src/crypto/des/speed.c
@@ -186,16 +186,16 @@ int main(int argc, char **argv)
186#endif 186#endif
187 187
188#ifndef TIMES 188#ifndef TIMES
189 printf("To get the most acurate results, try to run this\n"); 189 printf("To get the most accurate results, try to run this\n");
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(&key2,sch2); 193 des_set_key_unchecked(&key2,sch2);
194 des_set_key(&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(&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;
@@ -225,7 +225,7 @@ 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(&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;
diff --git a/src/lib/libssl/src/crypto/des/str2key.c b/src/lib/libssl/src/crypto/des/str2key.c
index 24841452f1..c6abb87201 100644
--- a/src/lib/libssl/src/crypto/des/str2key.c
+++ b/src/lib/libssl/src/crypto/des/str2key.c
@@ -58,8 +58,6 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61OPENSSL_EXTERN int des_check_key;
62
63void des_string_to_key(const char *str, des_cblock *key) 61void des_string_to_key(const char *str, des_cblock *key)
64 { 62 {
65 des_key_schedule ks; 63 des_key_schedule ks;
@@ -88,11 +86,8 @@ void des_string_to_key(const char *str, des_cblock *key)
88 } 86 }
89#endif 87#endif
90 des_set_odd_parity(key); 88 des_set_odd_parity(key);
91 i=des_check_key; 89 des_set_key_unchecked(key,ks);
92 des_check_key=0; 90 des_cbc_cksum((const unsigned char*)str,key,length,ks,key);
93 des_set_key(key,ks);
94 des_check_key=i;
95 des_cbc_cksum((unsigned char*)str,key,length,ks,key);
96 memset(ks,0,sizeof(ks)); 91 memset(ks,0,sizeof(ks));
97 des_set_odd_parity(key); 92 des_set_odd_parity(key);
98 } 93 }
@@ -150,13 +145,10 @@ void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2)
150#endif 145#endif
151 des_set_odd_parity(key1); 146 des_set_odd_parity(key1);
152 des_set_odd_parity(key2); 147 des_set_odd_parity(key2);
153 i=des_check_key; 148 des_set_key_unchecked(key1,ks);
154 des_check_key=0; 149 des_cbc_cksum((const unsigned char*)str,key1,length,ks,key1);
155 des_set_key(key1,ks); 150 des_set_key_unchecked(key2,ks);
156 des_cbc_cksum((unsigned char*)str,key1,length,ks,key1); 151 des_cbc_cksum((const unsigned char*)str,key2,length,ks,key2);
157 des_set_key(key2,ks);
158 des_cbc_cksum((unsigned char*)str,key2,length,ks,key2);
159 des_check_key=i;
160 memset(ks,0,sizeof(ks)); 152 memset(ks,0,sizeof(ks));
161 des_set_odd_parity(key1); 153 des_set_odd_parity(key1);
162 des_set_odd_parity(key2); 154 des_set_odd_parity(key2);
diff --git a/src/lib/libssl/src/crypto/dh/Makefile.ssl b/src/lib/libssl/src/crypto/dh/Makefile.ssl
index 3b5ec0e115..8df60872ef 100644
--- a/src/lib/libssl/src/crypto/dh/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/dh/Makefile.ssl
@@ -83,26 +83,30 @@ dh_check.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
83dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 83dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
84dh_check.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84dh_check.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85dh_check.o: ../../include/openssl/opensslconf.h 85dh_check.o: ../../include/openssl/opensslconf.h
86dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 86dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87dh_check.o: ../cryptlib.h 87dh_check.o: ../../include/openssl/stack.h ../cryptlib.h
88dh_err.o: ../../include/openssl/bn.h ../../include/openssl/dh.h 88dh_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
89dh_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 89dh_err.o: ../../include/openssl/dh.h ../../include/openssl/err.h
90dh_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
91dh_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90dh_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 92dh_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
91dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 93dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
92dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 94dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
93dh_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 95dh_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
94dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 96dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
95dh_gen.o: ../../include/openssl/stack.h ../cryptlib.h 97dh_gen.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
98dh_gen.o: ../cryptlib.h
96dh_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 99dh_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
97dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 100dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
98dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 101dh_key.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
99dh_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 102dh_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
100dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 103dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
101dh_key.o: ../../include/openssl/rand.h ../../include/openssl/stack.h 104dh_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
102dh_key.o: ../cryptlib.h 105dh_key.o: ../../include/openssl/stack.h ../cryptlib.h
103dh_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 106dh_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
104dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 107dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
105dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 108dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h
106dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 109dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
107dh_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 110dh_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
108dh_lib.o: ../../include/openssl/stack.h ../cryptlib.h 111dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
112dh_lib.o: ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/dh/dh.h b/src/lib/libssl/src/crypto/dh/dh.h
index 2cc3797a94..c15b2ad483 100644
--- a/src/lib/libssl/src/crypto/dh/dh.h
+++ b/src/lib/libssl/src/crypto/dh/dh.h
@@ -68,10 +68,28 @@ extern "C" {
68#endif 68#endif
69 69
70#include <openssl/bn.h> 70#include <openssl/bn.h>
71#include <openssl/crypto.h>
71 72
72#define DH_FLAG_CACHE_MONT_P 0x01 73#define DH_FLAG_CACHE_MONT_P 0x01
73 74
74typedef struct dh_st 75typedef struct dh_st DH;
76
77typedef struct dh_method {
78 const char *name;
79 /* Methods here */
80 int (*generate_key)(DH *dh);
81 int (*compute_key)(unsigned char *key,BIGNUM *pub_key,DH *dh);
82 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
83 const BIGNUM *m, BN_CTX *ctx,
84 BN_MONT_CTX *m_ctx); /* Can be null */
85
86 int (*init)(DH *dh);
87 int (*finish)(DH *dh);
88 int flags;
89 char *app_data;
90} DH_METHOD;
91
92struct dh_st
75 { 93 {
76 /* This first argument is used to pick up errors when 94 /* This first argument is used to pick up errors when
77 * a DH is passed instead of a EVP_PKEY */ 95 * a DH is passed instead of a EVP_PKEY */
@@ -80,12 +98,22 @@ typedef struct dh_st
80 BIGNUM *p; 98 BIGNUM *p;
81 BIGNUM *g; 99 BIGNUM *g;
82 int length; /* optional */ 100 int length; /* optional */
83 BIGNUM *pub_key; /* y */ 101 BIGNUM *pub_key; /* g^x */
84 BIGNUM *priv_key; /* x */ 102 BIGNUM *priv_key; /* x */
85 103
86 int flags; 104 int flags;
87 char *method_mont_p; 105 char *method_mont_p;
88 } DH; 106 /* Place holders if we want to do X9.42 DH */
107 BIGNUM *q;
108 BIGNUM *j;
109 unsigned char *seed;
110 int seedlen;
111 BIGNUM *counter;
112
113 int references;
114 CRYPTO_EX_DATA ex_data;
115 DH_METHOD *meth;
116 };
89 117
90#define DH_GENERATOR_2 2 118#define DH_GENERATOR_2 2
91/* #define DH_GENERATOR_3 3 */ 119/* #define DH_GENERATOR_3 3 */
@@ -93,10 +121,14 @@ typedef struct dh_st
93 121
94/* DH_check error codes */ 122/* DH_check error codes */
95#define DH_CHECK_P_NOT_PRIME 0x01 123#define DH_CHECK_P_NOT_PRIME 0x01
96#define DH_CHECK_P_NOT_STRONG_PRIME 0x02 124#define DH_CHECK_P_NOT_SAFE_PRIME 0x02
97#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 125#define DH_UNABLE_TO_CHECK_GENERATOR 0x04
98#define DH_NOT_SUITABLE_GENERATOR 0x08 126#define DH_NOT_SUITABLE_GENERATOR 0x08
99 127
128/* primes p where (p-1)/2 is prime too are called "safe"; we define
129 this for backward compatibility: */
130#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
131
100#define DHparams_dup(x) (DH *)ASN1_dup((int (*)())i2d_DHparams, \ 132#define DHparams_dup(x) (DH *)ASN1_dup((int (*)())i2d_DHparams, \
101 (char *(*)())d2i_DHparams,(char *)(x)) 133 (char *(*)())d2i_DHparams,(char *)(x))
102#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ 134#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
@@ -113,9 +145,20 @@ typedef struct dh_st
113 (unsigned char *)(x)) 145 (unsigned char *)(x))
114#endif 146#endif
115 147
148DH_METHOD *DH_OpenSSL(void);
149
150void DH_set_default_method(DH_METHOD *meth);
151DH_METHOD *DH_get_default_method(void);
152DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
153DH *DH_new_method(DH_METHOD *meth);
154
116DH * DH_new(void); 155DH * DH_new(void);
117void DH_free(DH *dh); 156void DH_free(DH *dh);
118int DH_size(DH *dh); 157int DH_size(DH *dh);
158int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
159 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
160int DH_set_ex_data(DH *d, int idx, void *arg);
161void *DH_get_ex_data(DH *d, int idx);
119DH * DH_generate_parameters(int prime_len,int generator, 162DH * DH_generate_parameters(int prime_len,int generator,
120 void (*callback)(int,int,void *),void *cb_arg); 163 void (*callback)(int,int,void *),void *cb_arg);
121int DH_check(DH *dh,int *codes); 164int DH_check(DH *dh,int *codes);
diff --git a/src/lib/libssl/src/crypto/dh/dh_check.c b/src/lib/libssl/src/crypto/dh/dh_check.c
index 95ce9cfad0..7e5cfd8bfc 100644
--- a/src/lib/libssl/src/crypto/dh/dh_check.c
+++ b/src/lib/libssl/src/crypto/dh/dh_check.c
@@ -61,7 +61,7 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63 63
64/* Check that p is a strong prime and 64/* Check that p is a safe prime and
65 * if g is 2, 3 or 5, check that is is a suitable generator 65 * if g is 2, 3 or 5, check that is is a suitable generator
66 * where 66 * where
67 * for 2, p mod 24 == 11 67 * for 2, p mod 24 == 11
@@ -88,11 +88,13 @@ int DH_check(DH *dh, int *ret)
88 l=BN_mod_word(dh->p,24); 88 l=BN_mod_word(dh->p,24);
89 if (l != 11) *ret|=DH_NOT_SUITABLE_GENERATOR; 89 if (l != 11) *ret|=DH_NOT_SUITABLE_GENERATOR;
90 } 90 }
91/* else if (BN_is_word(dh->g,DH_GENERATOR_3)) 91#if 0
92 else if (BN_is_word(dh->g,DH_GENERATOR_3))
92 { 93 {
93 l=BN_mod_word(dh->p,12); 94 l=BN_mod_word(dh->p,12);
94 if (l != 5) *ret|=DH_NOT_SUITABLE_GENERATOR; 95 if (l != 5) *ret|=DH_NOT_SUITABLE_GENERATOR;
95 }*/ 96 }
97#endif
96 else if (BN_is_word(dh->g,DH_GENERATOR_5)) 98 else if (BN_is_word(dh->g,DH_GENERATOR_5))
97 { 99 {
98 l=BN_mod_word(dh->p,10); 100 l=BN_mod_word(dh->p,10);
@@ -108,7 +110,7 @@ int DH_check(DH *dh, int *ret)
108 { 110 {
109 if (!BN_rshift1(q,dh->p)) goto err; 111 if (!BN_rshift1(q,dh->p)) goto err;
110 if (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL)) 112 if (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL))
111 *ret|=DH_CHECK_P_NOT_STRONG_PRIME; 113 *ret|=DH_CHECK_P_NOT_SAFE_PRIME;
112 } 114 }
113 ok=1; 115 ok=1;
114err: 116err:
diff --git a/src/lib/libssl/src/crypto/dh/dh_gen.c b/src/lib/libssl/src/crypto/dh/dh_gen.c
index b7bcd2c7a4..7a6a38fbb4 100644
--- a/src/lib/libssl/src/crypto/dh/dh_gen.c
+++ b/src/lib/libssl/src/crypto/dh/dh_gen.c
@@ -72,14 +72,14 @@
72 * Having said all that, 72 * Having said all that,
73 * there is another special case method for the generators 2, 3 and 5. 73 * there is another special case method for the generators 2, 3 and 5.
74 * for 2, p mod 24 == 11 74 * for 2, p mod 24 == 11
75 * for 3, p mod 12 == 5 <<<<< does not work for strong primes. 75 * for 3, p mod 12 == 5 <<<<< does not work for safe primes.
76 * for 5, p mod 10 == 3 or 7 76 * for 5, p mod 10 == 3 or 7
77 * 77 *
78 * Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the 78 * Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the
79 * special generators and for answering some of my questions. 79 * special generators and for answering some of my questions.
80 * 80 *
81 * I've implemented the second simple method :-). 81 * I've implemented the second simple method :-).
82 * Since DH should be using a strong 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
@@ -95,9 +95,10 @@ DH *DH_generate_parameters(int prime_len, int generator,
95 if (ret == NULL) goto err; 95 if (ret == NULL) goto err;
96 ctx=BN_CTX_new(); 96 ctx=BN_CTX_new();
97 if (ctx == NULL) goto err; 97 if (ctx == NULL) goto err;
98 t1= &(ctx->bn[0]); 98 BN_CTX_start(ctx);
99 t2= &(ctx->bn[1]); 99 t1 = BN_CTX_get(ctx);
100 ctx->tos=2; 100 t2 = BN_CTX_get(ctx);
101 if (t1 == NULL || t2 == NULL) goto err;
101 102
102 if (generator == DH_GENERATOR_2) 103 if (generator == DH_GENERATOR_2)
103 { 104 {
@@ -105,7 +106,7 @@ DH *DH_generate_parameters(int prime_len, int generator,
105 BN_set_word(t2,11); 106 BN_set_word(t2,11);
106 g=2; 107 g=2;
107 } 108 }
108#ifdef undef /* does not work for strong primes */ 109#ifdef undef /* does not work for safe primes */
109 else if (generator == DH_GENERATOR_3) 110 else if (generator == DH_GENERATOR_3)
110 { 111 {
111 BN_set_word(t1,12); 112 BN_set_word(t1,12);
@@ -138,7 +139,11 @@ err:
138 ok=0; 139 ok=0;
139 } 140 }
140 141
141 if (ctx != NULL) BN_CTX_free(ctx); 142 if (ctx != NULL)
143 {
144 BN_CTX_end(ctx);
145 BN_CTX_free(ctx);
146 }
142 if (!ok && (ret != NULL)) 147 if (!ok && (ret != NULL))
143 { 148 {
144 DH_free(ret); 149 DH_free(ret);
diff --git a/src/lib/libssl/src/crypto/dh/dh_key.c b/src/lib/libssl/src/crypto/dh/dh_key.c
index cede53bfc1..0c7eeaf260 100644
--- a/src/lib/libssl/src/crypto/dh/dh_key.c
+++ b/src/lib/libssl/src/crypto/dh/dh_key.c
@@ -62,8 +62,42 @@
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64 64
65static int generate_key(DH *dh);
66static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
67static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
68 const BIGNUM *m, BN_CTX *ctx,
69 BN_MONT_CTX *m_ctx);
70static int dh_init(DH *dh);
71static int dh_finish(DH *dh);
72
65int DH_generate_key(DH *dh) 73int DH_generate_key(DH *dh)
66 { 74 {
75 return dh->meth->generate_key(dh);
76 }
77
78int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
79 {
80 return dh->meth->compute_key(key, pub_key, dh);
81 }
82
83static DH_METHOD dh_ossl = {
84"OpenSSL DH Method",
85generate_key,
86compute_key,
87dh_bn_mod_exp,
88dh_init,
89dh_finish,
900,
91NULL
92};
93
94DH_METHOD *DH_OpenSSL(void)
95{
96 return &dh_ossl;
97}
98
99static int generate_key(DH *dh)
100 {
67 int ok=0; 101 int ok=0;
68 unsigned int i; 102 unsigned int i;
69 BN_CTX ctx; 103 BN_CTX ctx;
@@ -103,7 +137,8 @@ int DH_generate_key(DH *dh)
103 } 137 }
104 mont=(BN_MONT_CTX *)dh->method_mont_p; 138 mont=(BN_MONT_CTX *)dh->method_mont_p;
105 139
106 if (!BN_mod_exp_mont(pub_key,dh->g,priv_key,dh->p,&ctx,mont)) goto err; 140 if (!dh->meth->bn_mod_exp(dh, pub_key,dh->g,priv_key,dh->p,&ctx,mont))
141 goto err;
107 142
108 dh->pub_key=pub_key; 143 dh->pub_key=pub_key;
109 dh->priv_key=priv_key; 144 dh->priv_key=priv_key;
@@ -118,7 +153,7 @@ err:
118 return(ok); 153 return(ok);
119 } 154 }
120 155
121int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) 156static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
122 { 157 {
123 BN_CTX ctx; 158 BN_CTX ctx;
124 BN_MONT_CTX *mont; 159 BN_MONT_CTX *mont;
@@ -126,7 +161,8 @@ int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
126 int ret= -1; 161 int ret= -1;
127 162
128 BN_CTX_init(&ctx); 163 BN_CTX_init(&ctx);
129 tmp= &(ctx.bn[ctx.tos++]); 164 BN_CTX_start(&ctx);
165 tmp = BN_CTX_get(&ctx);
130 166
131 if (dh->priv_key == NULL) 167 if (dh->priv_key == NULL)
132 { 168 {
@@ -141,7 +177,7 @@ int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
141 } 177 }
142 178
143 mont=(BN_MONT_CTX *)dh->method_mont_p; 179 mont=(BN_MONT_CTX *)dh->method_mont_p;
144 if (!BN_mod_exp_mont(tmp,pub_key,dh->priv_key,dh->p,&ctx,mont)) 180 if (!dh->meth->bn_mod_exp(dh, tmp,pub_key,dh->priv_key,dh->p,&ctx,mont))
145 { 181 {
146 DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB); 182 DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB);
147 goto err; 183 goto err;
@@ -149,6 +185,27 @@ int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
149 185
150 ret=BN_bn2bin(tmp,key); 186 ret=BN_bn2bin(tmp,key);
151err: 187err:
188 BN_CTX_end(&ctx);
152 BN_CTX_free(&ctx); 189 BN_CTX_free(&ctx);
153 return(ret); 190 return(ret);
154 } 191 }
192
193static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
194 const BIGNUM *m, BN_CTX *ctx,
195 BN_MONT_CTX *m_ctx)
196{
197 return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
198}
199
200static int dh_init(DH *dh)
201{
202 dh->flags |= DH_FLAG_CACHE_MONT_P;
203 return(1);
204}
205
206static int dh_finish(DH *dh)
207{
208 if(dh->method_mont_p)
209 BN_MONT_CTX_free((BN_MONT_CTX *)dh->method_mont_p);
210 return(1);
211}
diff --git a/src/lib/libssl/src/crypto/dh/dh_lib.c b/src/lib/libssl/src/crypto/dh/dh_lib.c
index 61e0720e8a..6c21463028 100644
--- a/src/lib/libssl/src/crypto/dh/dh_lib.c
+++ b/src/lib/libssl/src/crypto/dh/dh_lib.c
@@ -63,16 +63,49 @@
63 63
64const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; 64const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
65 65
66static DH_METHOD *default_DH_method;
67static int dh_meth_num = 0;
68static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dh_meth = NULL;
69
70void DH_set_default_method(DH_METHOD *meth)
71{
72 default_DH_method = meth;
73}
74
75DH_METHOD *DH_get_default_method(void)
76{
77 if(!default_DH_method) default_DH_method = DH_OpenSSL();
78 return default_DH_method;
79}
80
81DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth)
82{
83 DH_METHOD *mtmp;
84 mtmp = dh->meth;
85 if (mtmp->finish) mtmp->finish(dh);
86 dh->meth = meth;
87 if (meth->init) meth->init(dh);
88 return mtmp;
89}
90
66DH *DH_new(void) 91DH *DH_new(void)
92{
93 return DH_new_method(NULL);
94}
95
96DH *DH_new_method(DH_METHOD *meth)
67 { 97 {
68 DH *ret; 98 DH *ret;
69
70 ret=(DH *)Malloc(sizeof(DH)); 99 ret=(DH *)Malloc(sizeof(DH));
100
71 if (ret == NULL) 101 if (ret == NULL)
72 { 102 {
73 DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE); 103 DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE);
74 return(NULL); 104 return(NULL);
75 } 105 }
106 if(!default_DH_method) default_DH_method = DH_OpenSSL();
107 if(meth) ret->meth = meth;
108 else ret->meth = default_DH_method;
76 ret->pad=0; 109 ret->pad=0;
77 ret->version=0; 110 ret->version=0;
78 ret->p=NULL; 111 ret->p=NULL;
@@ -80,23 +113,74 @@ DH *DH_new(void)
80 ret->length=0; 113 ret->length=0;
81 ret->pub_key=NULL; 114 ret->pub_key=NULL;
82 ret->priv_key=NULL; 115 ret->priv_key=NULL;
83 ret->flags=DH_FLAG_CACHE_MONT_P; 116 ret->q=NULL;
117 ret->j=NULL;
118 ret->seed = NULL;
119 ret->seedlen = 0;
120 ret->counter = NULL;
84 ret->method_mont_p=NULL; 121 ret->method_mont_p=NULL;
122 ret->references = 1;
123 ret->flags=ret->meth->flags;
124 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
125 {
126 Free(ret);
127 ret=NULL;
128 }
129 else
130 CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data);
85 return(ret); 131 return(ret);
86 } 132 }
87 133
88void DH_free(DH *r) 134void DH_free(DH *r)
89 { 135 {
136 int i;
90 if(r == NULL) return; 137 if(r == NULL) return;
138 i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH);
139#ifdef REF_PRINT
140 REF_PRINT("DH",r);
141#endif
142 if (i > 0) return;
143#ifdef REF_CHECK
144 if (i < 0)
145 {
146 fprintf(stderr,"DH_free, bad reference count\n");
147 abort();
148 }
149#endif
150
151 CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
152
153 if(r->meth->finish) r->meth->finish(r);
154
91 if (r->p != NULL) BN_clear_free(r->p); 155 if (r->p != NULL) BN_clear_free(r->p);
92 if (r->g != NULL) BN_clear_free(r->g); 156 if (r->g != NULL) BN_clear_free(r->g);
157 if (r->q != NULL) BN_clear_free(r->q);
158 if (r->j != NULL) BN_clear_free(r->j);
159 if (r->seed) Free(r->seed);
160 if (r->counter != NULL) BN_clear_free(r->counter);
93 if (r->pub_key != NULL) BN_clear_free(r->pub_key); 161 if (r->pub_key != NULL) BN_clear_free(r->pub_key);
94 if (r->priv_key != NULL) BN_clear_free(r->priv_key); 162 if (r->priv_key != NULL) BN_clear_free(r->priv_key);
95 if (r->method_mont_p != NULL)
96 BN_MONT_CTX_free((BN_MONT_CTX *)r->method_mont_p);
97 Free(r); 163 Free(r);
98 } 164 }
99 165
166int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
167 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
168 {
169 dh_meth_num++;
170 return(CRYPTO_get_ex_new_index(dh_meth_num-1,
171 &dh_meth,argl,argp,new_func,dup_func,free_func));
172 }
173
174int DH_set_ex_data(DH *d, int idx, void *arg)
175 {
176 return(CRYPTO_set_ex_data(&d->ex_data,idx,arg));
177 }
178
179void *DH_get_ex_data(DH *d, int idx)
180 {
181 return(CRYPTO_get_ex_data(&d->ex_data,idx));
182 }
183
100int DH_size(DH *dh) 184int DH_size(DH *dh)
101 { 185 {
102 return(BN_num_bytes(dh->p)); 186 return(BN_num_bytes(dh->p));
diff --git a/src/lib/libssl/src/crypto/dh/dhtest.c b/src/lib/libssl/src/crypto/dh/dhtest.c
index 770331971f..d66c28455e 100644
--- a/src/lib/libssl/src/crypto/dh/dhtest.c
+++ b/src/lib/libssl/src/crypto/dh/dhtest.c
@@ -65,6 +65,7 @@
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 69
69#ifdef NO_DH 70#ifdef NO_DH
70int main(int argc, char *argv[]) 71int main(int argc, char *argv[])
@@ -87,19 +88,23 @@ static void MS_CALLBACK cb(int p, int n, void *arg);
87#include "bss_file.c" 88#include "bss_file.c"
88#endif 89#endif
89 90
90BIO *out=NULL; 91static const char rnd_seed[] = "string to make the random number generator think it has entropy";
91 92
92int main(int argc, char *argv[]) 93int main(int argc, char *argv[])
93 { 94 {
94 DH *a,*b; 95 DH *a;
96 DH *b=NULL;
95 char buf[12]; 97 char buf[12];
96 unsigned char *abuf=NULL,*bbuf=NULL; 98 unsigned char *abuf=NULL,*bbuf=NULL;
97 int i,alen,blen,aout,bout,ret=1; 99 int i,alen,blen,aout,bout,ret=1;
100 BIO *out;
98 101
99#ifdef WIN32 102#ifdef WIN32
100 CRYPTO_malloc_init(); 103 CRYPTO_malloc_init();
101#endif 104#endif
102 105
106 RAND_seed(rnd_seed, sizeof rnd_seed);
107
103 out=BIO_new(BIO_s_file()); 108 out=BIO_new(BIO_s_file());
104 if (out == NULL) exit(1); 109 if (out == NULL) exit(1);
105 BIO_set_fp(out,stdout,BIO_NOCLOSE); 110 BIO_set_fp(out,stdout,BIO_NOCLOSE);
@@ -167,6 +172,9 @@ int main(int argc, char *argv[])
167err: 172err:
168 if (abuf != NULL) Free(abuf); 173 if (abuf != NULL) Free(abuf);
169 if (bbuf != NULL) Free(bbuf); 174 if (bbuf != NULL) Free(bbuf);
175 if(b != NULL) DH_free(b);
176 if(a != NULL) DH_free(a);
177 BIO_free(out);
170 exit(ret); 178 exit(ret);
171 return(ret); 179 return(ret);
172 } 180 }
diff --git a/src/lib/libssl/src/crypto/dsa/Makefile.ssl b/src/lib/libssl/src/crypto/dsa/Makefile.ssl
index 4bc74a2f7c..b0bcf974fb 100644
--- a/src/lib/libssl/src/crypto/dsa/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/dsa/Makefile.ssl
@@ -22,8 +22,10 @@ TEST=dsatest.c
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c dsa_err.c 25LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \
26LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o dsa_err.o 26 dsa_err.c dsa_ossl.c
27LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \
28 dsa_err.o dsa_ossl.o
27 29
28SRC= $(LIBSRC) 30SRC= $(LIBSRC)
29 31
@@ -86,25 +88,27 @@ dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
86dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 88dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
87dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 89dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
88dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h 90dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h
89dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/dh.h 91dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
90dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h 92dsa_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
91dsa_err.o: ../../include/openssl/opensslconf.h 93dsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
94dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
95dsa_err.o: ../../include/openssl/stack.h
92dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 96dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
93dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 97dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 98dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
95dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 99dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
96dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 100dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
97dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 101dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
98dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 102dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
99dsa_gen.o: ../cryptlib.h 103dsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h
100dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 104dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
101dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 105dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
102dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 106dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
103dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 107dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
104dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 108dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
105dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 109dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
106dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 110dsa_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
107dsa_key.o: ../cryptlib.h 111dsa_key.o: ../../include/openssl/stack.h ../cryptlib.h
108dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 112dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
109dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 113dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
110dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 114dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
@@ -113,6 +117,15 @@ dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
113dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 117dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 118dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
115dsa_lib.o: ../cryptlib.h 119dsa_lib.o: ../cryptlib.h
120dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
121dsa_ossl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
122dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
123dsa_ossl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
124dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
125dsa_ossl.o: ../../include/openssl/opensslconf.h
126dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
127dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
128dsa_ossl.o: ../cryptlib.h
116dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 129dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
117dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 130dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
118dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 131dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
diff --git a/src/lib/libssl/src/crypto/dsa/dsa.h b/src/lib/libssl/src/crypto/dsa/dsa.h
index 20b3f8d90a..68d9912cbc 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa.h
+++ b/src/lib/libssl/src/crypto/dsa/dsa.h
@@ -74,13 +74,41 @@ extern "C" {
74#endif 74#endif
75 75
76#include <openssl/bn.h> 76#include <openssl/bn.h>
77#include <openssl/crypto.h>
77#ifndef NO_DH 78#ifndef NO_DH
78# include <openssl/dh.h> 79# include <openssl/dh.h>
79#endif 80#endif
80 81
81#define DSA_FLAG_CACHE_MONT_P 0x01 82#define DSA_FLAG_CACHE_MONT_P 0x01
82 83
83typedef struct dsa_st 84typedef struct dsa_st DSA;
85
86typedef struct DSA_SIG_st
87 {
88 BIGNUM *r;
89 BIGNUM *s;
90 } DSA_SIG;
91
92typedef struct dsa_method {
93 const char *name;
94 DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
95 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
96 BIGNUM **rp);
97 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
98 DSA_SIG *sig, DSA *dsa);
99 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
100 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
101 BN_MONT_CTX *in_mont);
102 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
103 const BIGNUM *m, BN_CTX *ctx,
104 BN_MONT_CTX *m_ctx); /* Can be null */
105 int (*init)(DSA *dsa);
106 int (*finish)(DSA *dsa);
107 int flags;
108 char *app_data;
109} DSA_METHOD;
110
111struct dsa_st
84 { 112 {
85 /* This first variable is used to pick up errors where 113 /* This first variable is used to pick up errors where
86 * a DSA is passed instead of of a EVP_PKEY */ 114 * a DSA is passed instead of of a EVP_PKEY */
@@ -100,15 +128,10 @@ typedef struct dsa_st
100 int flags; 128 int flags;
101 /* Normally used to cache montgomery values */ 129 /* Normally used to cache montgomery values */
102 char *method_mont_p; 130 char *method_mont_p;
103
104 int references; 131 int references;
105 } DSA; 132 CRYPTO_EX_DATA ex_data;
106 133 DSA_METHOD *meth;
107typedef struct DSA_SIG_st 134 };
108 {
109 BIGNUM *r;
110 BIGNUM *s;
111 } DSA_SIG;
112 135
113#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ 136#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \
114 (char *(*)())d2i_DSAparams,(char *)(x)) 137 (char *(*)())d2i_DSAparams,(char *)(x))
@@ -131,7 +154,14 @@ DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
131int DSA_do_verify(const unsigned char *dgst,int dgst_len, 154int DSA_do_verify(const unsigned char *dgst,int dgst_len,
132 DSA_SIG *sig,DSA *dsa); 155 DSA_SIG *sig,DSA *dsa);
133 156
157DSA_METHOD *DSA_OpenSSL(void);
158
159void DSA_set_default_method(DSA_METHOD *);
160DSA_METHOD *DSA_get_default_method(void);
161DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *);
162
134DSA * DSA_new(void); 163DSA * DSA_new(void);
164DSA * DSA_new_method(DSA_METHOD *meth);
135int DSA_size(DSA *); 165int DSA_size(DSA *);
136 /* next 4 return -1 on error */ 166 /* next 4 return -1 on error */
137int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); 167int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
@@ -140,6 +170,10 @@ int DSA_sign(int type,const unsigned char *dgst,int dlen,
140int DSA_verify(int type,const unsigned char *dgst,int dgst_len, 170int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
141 unsigned char *sigbuf, int siglen, DSA *dsa); 171 unsigned char *sigbuf, int siglen, DSA *dsa);
142void DSA_free (DSA *r); 172void DSA_free (DSA *r);
173int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
174 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
175int DSA_set_ex_data(DSA *d, int idx, void *arg);
176void *DSA_get_ex_data(DSA *d, int idx);
143 177
144void ERR_load_DSA_strings(void ); 178void ERR_load_DSA_strings(void );
145 179
@@ -148,7 +182,7 @@ DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
148DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); 182DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
149DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len, 183DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len,
150 int *counter_ret, unsigned long *h_ret,void 184 int *counter_ret, unsigned long *h_ret,void
151 (*callback)(),char *cb_arg); 185 (*callback)(int, int, void *),void *cb_arg);
152int DSA_generate_key(DSA *a); 186int DSA_generate_key(DSA *a);
153int i2d_DSAPublicKey(DSA *a, unsigned char **pp); 187int i2d_DSAPublicKey(DSA *a, unsigned char **pp);
154int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); 188int i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
@@ -163,7 +197,11 @@ int DSAparams_print_fp(FILE *fp, DSA *x);
163int DSA_print_fp(FILE *bp, DSA *x, int off); 197int DSA_print_fp(FILE *bp, DSA *x, int off);
164#endif 198#endif
165 199
166int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg); 200#define DSS_prime_checks 50
201/* Primality test according to FIPS PUB 186[-1], Appendix 2.1:
202 * 50 rounds of Rabin-Miller */
203#define DSA_is_prime(n, callback, cb_arg) \
204 BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
167 205
168#ifndef NO_DH 206#ifndef NO_DH
169/* Convert DSA structure (key or just parameters) into DH structure 207/* Convert DSA structure (key or just parameters) into DH structure
@@ -184,7 +222,6 @@ DH *DSA_dup_DH(DSA *r);
184#define DSA_F_DSAPARAMS_PRINT_FP 101 222#define DSA_F_DSAPARAMS_PRINT_FP 101
185#define DSA_F_DSA_DO_SIGN 112 223#define DSA_F_DSA_DO_SIGN 112
186#define DSA_F_DSA_DO_VERIFY 113 224#define DSA_F_DSA_DO_VERIFY 113
187#define DSA_F_DSA_IS_PRIME 102
188#define DSA_F_DSA_NEW 103 225#define DSA_F_DSA_NEW 103
189#define DSA_F_DSA_PRINT 104 226#define DSA_F_DSA_PRINT 104
190#define DSA_F_DSA_PRINT_FP 105 227#define DSA_F_DSA_PRINT_FP 105
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_asn1.c b/src/lib/libssl/src/crypto/dsa/dsa_asn1.c
index 7523b21654..c9b32b4db7 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_asn1.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_asn1.c
@@ -83,7 +83,7 @@ DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, unsigned char **pp, long length)
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL) 84 if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL)
85 goto err_bn; 85 goto err_bn;
86 ASN1_BIT_STRING_free(bs); 86 M_ASN1_BIT_STRING_free(bs);
87 M_ASN1_D2I_Finish_2(a); 87 M_ASN1_D2I_Finish_2(a);
88 88
89err_bn: 89err_bn:
@@ -91,6 +91,6 @@ err_bn:
91err: 91err:
92 DSAerr(DSA_F_D2I_DSA_SIG,i); 92 DSAerr(DSA_F_D2I_DSA_SIG,i);
93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret); 93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret);
94 if (bs != NULL) ASN1_BIT_STRING_free(bs); 94 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
95 return(NULL); 95 return(NULL);
96} 96}
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_err.c b/src/lib/libssl/src/crypto/dsa/dsa_err.c
index 33a8270afd..38e4af968c 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_err.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_err.c
@@ -70,7 +70,6 @@ static ERR_STRING_DATA DSA_str_functs[]=
70{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"}, 70{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"},
71{ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, 71{ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"},
72{ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, 72{ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"},
73{ERR_PACK(0,DSA_F_DSA_IS_PRIME,0), "DSA_is_prime"},
74{ERR_PACK(0,DSA_F_DSA_NEW,0), "DSA_new"}, 73{ERR_PACK(0,DSA_F_DSA_NEW,0), "DSA_new"},
75{ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"}, 74{ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"},
76{ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"}, 75{ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"},
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_gen.c b/src/lib/libssl/src/crypto/dsa/dsa_gen.c
index b5e5ec06e5..2294a362d9 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_gen.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_gen.c
@@ -59,12 +59,18 @@
59#undef GENUINE_DSA 59#undef GENUINE_DSA
60 60
61#ifdef GENUINE_DSA 61#ifdef GENUINE_DSA
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) */
62#define HASH SHA 64#define HASH SHA
63#else 65#else
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
68 * FIPS PUB 180-1) */
64#define HASH SHA1 69#define HASH SHA1
65#endif 70#endif
66 71
67#ifndef NO_SHA 72#ifndef NO_SHA
73
68#include <stdio.h> 74#include <stdio.h>
69#include <time.h> 75#include <time.h>
70#include "cryptlib.h" 76#include "cryptlib.h"
@@ -74,8 +80,9 @@
74#include <openssl/rand.h> 80#include <openssl/rand.h>
75 81
76DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, 82DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
77 int *counter_ret, unsigned long *h_ret, void (*callback)(), 83 int *counter_ret, unsigned long *h_ret,
78 char *cb_arg) 84 void (*callback)(int, int, void *),
85 void *cb_arg)
79 { 86 {
80 int ok=0; 87 int ok=0;
81 unsigned char seed[SHA_DIGEST_LENGTH]; 88 unsigned char seed[SHA_DIGEST_LENGTH];
@@ -86,47 +93,63 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
86 BN_MONT_CTX *mont=NULL; 93 BN_MONT_CTX *mont=NULL;
87 int k,n=0,i,b,m=0; 94 int k,n=0,i,b,m=0;
88 int counter=0; 95 int counter=0;
89 BN_CTX *ctx=NULL,*ctx2=NULL; 96 int r=0;
97 BN_CTX *ctx=NULL,*ctx2=NULL,*ctx3=NULL;
90 unsigned int h=2; 98 unsigned int h=2;
91 DSA *ret=NULL; 99 DSA *ret=NULL;
92 100
93 if (bits < 512) bits=512; 101 if (bits < 512) bits=512;
94 bits=(bits+63)/64*64; 102 bits=(bits+63)/64*64;
95 103
104 if (seed_len < 20)
105 seed_in = NULL; /* seed buffer too small -- ignore */
106 if (seed_len > 20)
107 seed_len = 20; /* App. 2.2 of FIPS PUB 186 allows larger SEED,
108 * but our internal buffers are restricted to 160 bits*/
96 if ((seed_in != NULL) && (seed_len == 20)) 109 if ((seed_in != NULL) && (seed_len == 20))
97 memcpy(seed,seed_in,seed_len); 110 memcpy(seed,seed_in,seed_len);
98 111
99 if ((ctx=BN_CTX_new()) == NULL) goto err; 112 if ((ctx=BN_CTX_new()) == NULL) goto err;
100 if ((ctx2=BN_CTX_new()) == NULL) goto err; 113 if ((ctx2=BN_CTX_new()) == NULL) goto err;
114 if ((ctx3=BN_CTX_new()) == NULL) goto err;
101 if ((ret=DSA_new()) == NULL) goto err; 115 if ((ret=DSA_new()) == NULL) goto err;
102 116
103 if ((mont=BN_MONT_CTX_new()) == NULL) goto err; 117 if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
104 118
105 r0= &(ctx2->bn[0]); 119 BN_CTX_start(ctx2);
106 g= &(ctx2->bn[1]); 120 r0 = BN_CTX_get(ctx2);
107 W= &(ctx2->bn[2]); 121 g = BN_CTX_get(ctx2);
108 q= &(ctx2->bn[3]); 122 W = BN_CTX_get(ctx2);
109 X= &(ctx2->bn[4]); 123 q = BN_CTX_get(ctx2);
110 c= &(ctx2->bn[5]); 124 X = BN_CTX_get(ctx2);
111 p= &(ctx2->bn[6]); 125 c = BN_CTX_get(ctx2);
112 test= &(ctx2->bn[7]); 126 p = BN_CTX_get(ctx2);
127 test = BN_CTX_get(ctx2);
113 128
114 BN_lshift(test,BN_value_one(),bits-1); 129 BN_lshift(test,BN_value_one(),bits-1);
115 130
116 for (;;) 131 for (;;)
117 { 132 {
118 for (;;) 133 for (;;) /* find q */
119 { 134 {
135 int seed_is_random;
136
120 /* step 1 */ 137 /* step 1 */
121 if (callback != NULL) callback(0,m++,cb_arg); 138 if (callback != NULL) callback(0,m++,cb_arg);
122 139
123 if (!seed_len) 140 if (!seed_len)
124 RAND_bytes(seed,SHA_DIGEST_LENGTH); 141 {
142 RAND_pseudo_bytes(seed,SHA_DIGEST_LENGTH);
143 seed_is_random = 1;
144 }
125 else 145 else
126 seed_len=0; 146 {
127 147 seed_is_random = 0;
148 seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/
149 }
128 memcpy(buf,seed,SHA_DIGEST_LENGTH); 150 memcpy(buf,seed,SHA_DIGEST_LENGTH);
129 memcpy(buf2,seed,SHA_DIGEST_LENGTH); 151 memcpy(buf2,seed,SHA_DIGEST_LENGTH);
152 /* precompute "SEED + 1" for step 7: */
130 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) 153 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--)
131 { 154 {
132 buf[i]++; 155 buf[i]++;
@@ -142,10 +165,15 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
142 /* step 3 */ 165 /* step 3 */
143 md[0]|=0x80; 166 md[0]|=0x80;
144 md[SHA_DIGEST_LENGTH-1]|=0x01; 167 md[SHA_DIGEST_LENGTH-1]|=0x01;
145 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) abort(); 168 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) goto err;
146 169
147 /* step 4 */ 170 /* step 4 */
148 if (DSA_is_prime(q,callback,cb_arg) > 0) break; 171 r = BN_is_prime_fasttest(q, DSS_prime_checks, callback, ctx3, cb_arg, seed_is_random);
172 if (r > 0)
173 break;
174 if (r != 0)
175 goto err;
176
149 /* do a callback call */ 177 /* do a callback call */
150 /* step 5 */ 178 /* step 5 */
151 } 179 }
@@ -155,16 +183,22 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
155 183
156 /* step 6 */ 184 /* step 6 */
157 counter=0; 185 counter=0;
186 /* "offset = 2" */
158 187
159 n=(bits-1)/160; 188 n=(bits-1)/160;
160 b=(bits-1)-n*160; 189 b=(bits-1)-n*160;
161 190
162 for (;;) 191 for (;;)
163 { 192 {
193 if (callback != NULL && counter != 0)
194 callback(0,counter,cb_arg);
195
164 /* step 7 */ 196 /* step 7 */
165 BN_zero(W); 197 BN_zero(W);
198 /* now 'buf' contains "SEED + offset - 1" */
166 for (k=0; k<=n; k++) 199 for (k=0; k<=n; k++)
167 { 200 {
201 /* obtain "SEED + offset + k" by incrementing: */
168 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) 202 for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--)
169 { 203 {
170 buf[i]++; 204 buf[i]++;
@@ -174,7 +208,8 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
174 HASH(buf,SHA_DIGEST_LENGTH,md); 208 HASH(buf,SHA_DIGEST_LENGTH,md);
175 209
176 /* step 8 */ 210 /* step 8 */
177 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) abort(); 211 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0))
212 goto err;
178 BN_lshift(r0,r0,160*k); 213 BN_lshift(r0,r0,160*k);
179 BN_add(W,W,r0); 214 BN_add(W,W,r0);
180 } 215 }
@@ -194,23 +229,25 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
194 if (BN_cmp(p,test) >= 0) 229 if (BN_cmp(p,test) >= 0)
195 { 230 {
196 /* step 11 */ 231 /* step 11 */
197 if (DSA_is_prime(p,callback,cb_arg) > 0) 232 r = BN_is_prime_fasttest(p, DSS_prime_checks, callback, ctx3, cb_arg, 1);
198 goto end; 233 if (r > 0)
234 goto end; /* found it */
235 if (r != 0)
236 goto err;
199 } 237 }
200 238
201 /* step 13 */ 239 /* step 13 */
202 counter++; 240 counter++;
241 /* "offset = offset + n + 1" */
203 242
204 /* step 14 */ 243 /* step 14 */
205 if (counter >= 4096) break; 244 if (counter >= 4096) break;
206
207 if (callback != NULL) callback(0,counter,cb_arg);
208 } 245 }
209 } 246 }
210end: 247end:
211 if (callback != NULL) callback(2,1,cb_arg); 248 if (callback != NULL) callback(2,1,cb_arg);
212 249
213 /* We now need to gernerate g */ 250 /* We now need to generate g */
214 /* Set r0=(p-1)/q */ 251 /* Set r0=(p-1)/q */
215 BN_sub(test,p,BN_value_one()); 252 BN_sub(test,p,BN_value_one());
216 BN_div(r0,NULL,test,q,ctx); 253 BN_div(r0,NULL,test,q,ctx);
@@ -245,89 +282,13 @@ err:
245 if (h_ret != NULL) *h_ret=h; 282 if (h_ret != NULL) *h_ret=h;
246 } 283 }
247 if (ctx != NULL) BN_CTX_free(ctx); 284 if (ctx != NULL) BN_CTX_free(ctx);
248 if (ctx != NULL) BN_CTX_free(ctx2); 285 if (ctx2 != NULL)
249 if (mont != NULL) BN_MONT_CTX_free(mont);
250 return(ok?ret:NULL);
251 }
252
253int DSA_is_prime(BIGNUM *w, void (*callback)(), char *cb_arg)
254 {
255 int ok= -1,j,i,n;
256 BN_CTX *ctx=NULL,*ctx2=NULL;
257 BIGNUM *w_1,*b,*m,*z,*tmp,*mont_1;
258 int a;
259 BN_MONT_CTX *mont=NULL;
260
261 if (!BN_is_bit_set(w,0)) return(0);
262
263 if ((ctx=BN_CTX_new()) == NULL) goto err;
264 if ((ctx2=BN_CTX_new()) == NULL) goto err;
265 if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
266
267 m= &(ctx2->bn[2]);
268 b= &(ctx2->bn[3]);
269 z= &(ctx2->bn[4]);
270 w_1= &(ctx2->bn[5]);
271 tmp= &(ctx2->bn[6]);
272 mont_1= &(ctx2->bn[7]);
273
274 /* step 1 */
275 n=50;
276
277 /* step 2 */
278 if (!BN_sub(w_1,w,BN_value_one())) goto err;
279 for (a=1; !BN_is_bit_set(w_1,a); a++)
280 ;
281 if (!BN_rshift(m,w_1,a)) goto err;
282
283 BN_MONT_CTX_set(mont,w,ctx);
284 BN_to_montgomery(mont_1,BN_value_one(),mont,ctx);
285 BN_to_montgomery(w_1,w_1,mont,ctx);
286 for (i=1; i < n; i++)
287 { 286 {
288 /* step 3 */ 287 BN_CTX_end(ctx2);
289 BN_rand(b,BN_num_bits(w)-2/*-1*/,0,0); 288 BN_CTX_free(ctx2);
290 /* BN_set_word(b,0x10001L); */
291
292 /* step 4 */
293 j=0;
294 if (!BN_mod_exp_mont(z,b,m,w,ctx,mont)) goto err;
295
296 if (!BN_to_montgomery(z,z,mont,ctx)) goto err;
297
298 /* step 5 */
299 for (;;)
300 {
301 if (((j == 0) && (BN_cmp(z,mont_1) == 0)) ||
302 (BN_cmp(z,w_1) == 0))
303 break;
304
305 /* step 6 */
306 if ((j > 0) && (BN_cmp(z,mont_1) == 0))
307 {
308 ok=0;
309 goto err;
310 }
311
312 j++;
313 if (j >= a)
314 {
315 ok=0;
316 goto err;
317 }
318
319 if (!BN_mod_mul_montgomery(z,z,z,mont,ctx)) goto err;
320 if (callback != NULL) callback(1,j,cb_arg);
321 }
322 } 289 }
323 290 if (ctx3 != NULL) BN_CTX_free(ctx3);
324 ok=1; 291 if (mont != NULL) BN_MONT_CTX_free(mont);
325err: 292 return(ok?ret:NULL);
326 if (ok == -1) DSAerr(DSA_F_DSA_IS_PRIME,ERR_R_BN_LIB);
327 BN_CTX_free(ctx);
328 BN_CTX_free(ctx2);
329 BN_MONT_CTX_free(mont);
330
331 return(ok);
332 } 293 }
333#endif 294#endif
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_lib.c b/src/lib/libssl/src/crypto/dsa/dsa_lib.c
index ce8e204f7e..224e412afc 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_lib.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_lib.c
@@ -66,7 +66,38 @@
66 66
67const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; 67const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
68 68
69static DSA_METHOD *default_DSA_method;
70static int dsa_meth_num = 0;
71static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL;
72
73void DSA_set_default_method(DSA_METHOD *meth)
74{
75 default_DSA_method = meth;
76}
77
78DSA_METHOD *DSA_get_default_method(void)
79{
80 if(!default_DSA_method) default_DSA_method = DSA_OpenSSL();
81 return default_DSA_method;
82}
83
69DSA *DSA_new(void) 84DSA *DSA_new(void)
85{
86 return DSA_new_method(NULL);
87}
88
89DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth)
90{
91 DSA_METHOD *mtmp;
92 mtmp = dsa->meth;
93 if (mtmp->finish) mtmp->finish(dsa);
94 dsa->meth = meth;
95 if (meth->init) meth->init(dsa);
96 return mtmp;
97}
98
99
100DSA *DSA_new_method(DSA_METHOD *meth)
70 { 101 {
71 DSA *ret; 102 DSA *ret;
72 103
@@ -76,13 +107,15 @@ DSA *DSA_new(void)
76 DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); 107 DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE);
77 return(NULL); 108 return(NULL);
78 } 109 }
110 if(!default_DSA_method) default_DSA_method = DSA_OpenSSL();
111 if(meth) ret->meth = meth;
112 else ret->meth = default_DSA_method;
79 ret->pad=0; 113 ret->pad=0;
80 ret->version=0; 114 ret->version=0;
81 ret->write_params=1; 115 ret->write_params=1;
82 ret->p=NULL; 116 ret->p=NULL;
83 ret->q=NULL; 117 ret->q=NULL;
84 ret->g=NULL; 118 ret->g=NULL;
85 ret->flags=DSA_FLAG_CACHE_MONT_P;
86 119
87 ret->pub_key=NULL; 120 ret->pub_key=NULL;
88 ret->priv_key=NULL; 121 ret->priv_key=NULL;
@@ -92,6 +125,15 @@ DSA *DSA_new(void)
92 ret->method_mont_p=NULL; 125 ret->method_mont_p=NULL;
93 126
94 ret->references=1; 127 ret->references=1;
128 ret->flags=ret->meth->flags;
129 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
130 {
131 Free(ret);
132 ret=NULL;
133 }
134 else
135 CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data);
136
95 return(ret); 137 return(ret);
96 } 138 }
97 139
@@ -114,6 +156,10 @@ void DSA_free(DSA *r)
114 } 156 }
115#endif 157#endif
116 158
159 CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
160
161 if(r->meth->finish) r->meth->finish(r);
162
117 if (r->p != NULL) BN_clear_free(r->p); 163 if (r->p != NULL) BN_clear_free(r->p);
118 if (r->q != NULL) BN_clear_free(r->q); 164 if (r->q != NULL) BN_clear_free(r->q);
119 if (r->g != NULL) BN_clear_free(r->g); 165 if (r->g != NULL) BN_clear_free(r->g);
@@ -121,8 +167,6 @@ void DSA_free(DSA *r)
121 if (r->priv_key != NULL) BN_clear_free(r->priv_key); 167 if (r->priv_key != NULL) BN_clear_free(r->priv_key);
122 if (r->kinv != NULL) BN_clear_free(r->kinv); 168 if (r->kinv != NULL) BN_clear_free(r->kinv);
123 if (r->r != NULL) BN_clear_free(r->r); 169 if (r->r != NULL) BN_clear_free(r->r);
124 if (r->method_mont_p != NULL)
125 BN_MONT_CTX_free((BN_MONT_CTX *)r->method_mont_p);
126 Free(r); 170 Free(r);
127 } 171 }
128 172
@@ -145,6 +189,24 @@ int DSA_size(DSA *r)
145 return(ret); 189 return(ret);
146 } 190 }
147 191
192int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
193 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
194 {
195 dsa_meth_num++;
196 return(CRYPTO_get_ex_new_index(dsa_meth_num-1,
197 &dsa_meth,argl,argp,new_func,dup_func,free_func));
198 }
199
200int DSA_set_ex_data(DSA *d, int idx, void *arg)
201 {
202 return(CRYPTO_set_ex_data(&d->ex_data,idx,arg));
203 }
204
205void *DSA_get_ex_data(DSA *d, int idx)
206 {
207 return(CRYPTO_get_ex_data(&d->ex_data,idx));
208 }
209
148#ifndef NO_DH 210#ifndef NO_DH
149DH *DSA_dup_DH(DSA *r) 211DH *DSA_dup_DH(DSA *r)
150 { 212 {
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_ossl.c b/src/lib/libssl/src/crypto/dsa/dsa_ossl.c
new file mode 100644
index 0000000000..b51cf6ad8d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/dsa/dsa_ossl.c
@@ -0,0 +1,321 @@
1/* crypto/dsa/dsa_ossl.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/bn.h>
64#include <openssl/dsa.h>
65#include <openssl/rand.h>
66#include <openssl/asn1.h>
67
68static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
69static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
70static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
71 DSA *dsa);
72static int dsa_init(DSA *dsa);
73static int dsa_finish(DSA *dsa);
74static int dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
75 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
76 BN_MONT_CTX *in_mont);
77static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
78 const BIGNUM *m, BN_CTX *ctx,
79 BN_MONT_CTX *m_ctx);
80
81static DSA_METHOD openssl_dsa_meth = {
82"OpenSSL DSA method",
83dsa_do_sign,
84dsa_sign_setup,
85dsa_do_verify,
86dsa_mod_exp,
87dsa_bn_mod_exp,
88dsa_init,
89dsa_finish,
900,
91NULL
92};
93
94DSA_METHOD *DSA_OpenSSL(void)
95{
96 return &openssl_dsa_meth;
97}
98
99static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
100 {
101 BIGNUM *kinv=NULL,*r=NULL,*s=NULL;
102 BIGNUM m;
103 BIGNUM xr;
104 BN_CTX *ctx=NULL;
105 int i,reason=ERR_R_BN_LIB;
106 DSA_SIG *ret=NULL;
107
108 BN_init(&m);
109 BN_init(&xr);
110 s=BN_new();
111 if (s == NULL) goto err;
112
113 i=BN_num_bytes(dsa->q); /* should be 20 */
114 if ((dlen > i) || (dlen > 50))
115 {
116 reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;
117 goto err;
118 }
119
120 ctx=BN_CTX_new();
121 if (ctx == NULL) goto err;
122
123 if ((dsa->kinv == NULL) || (dsa->r == NULL))
124 {
125 if (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err;
126 }
127 else
128 {
129 kinv=dsa->kinv;
130 dsa->kinv=NULL;
131 r=dsa->r;
132 dsa->r=NULL;
133 }
134
135 if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err;
136
137 /* Compute s = inv(k) (m + xr) mod q */
138 if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */
139 if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */
140 if (BN_cmp(s,dsa->q) > 0)
141 BN_sub(s,s,dsa->q);
142 if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
143
144 ret=DSA_SIG_new();
145 if (ret == NULL) goto err;
146 ret->r = r;
147 ret->s = s;
148
149err:
150 if (!ret)
151 {
152 DSAerr(DSA_F_DSA_DO_SIGN,reason);
153 BN_free(r);
154 BN_free(s);
155 }
156 if (ctx != NULL) BN_CTX_free(ctx);
157 BN_clear_free(&m);
158 BN_clear_free(&xr);
159 if (kinv != NULL) /* dsa->kinv is NULL now if we used it */
160 BN_clear_free(kinv);
161 return(ret);
162 }
163
164static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
165 {
166 BN_CTX *ctx;
167 BIGNUM k,*kinv=NULL,*r=NULL;
168 int ret=0;
169
170 if (ctx_in == NULL)
171 {
172 if ((ctx=BN_CTX_new()) == NULL) goto err;
173 }
174 else
175 ctx=ctx_in;
176
177 BN_init(&k);
178 if ((r=BN_new()) == NULL) goto err;
179 kinv=NULL;
180
181 /* Get random k */
182 for (;;)
183 {
184 if (!BN_rand(&k, BN_num_bits(dsa->q), 1, 0)) goto err;
185 if (BN_cmp(&k,dsa->q) >= 0)
186 BN_sub(&k,&k,dsa->q);
187 if (!BN_is_zero(&k)) break;
188 }
189
190 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
191 {
192 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
193 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
194 dsa->p,ctx)) goto err;
195 }
196
197 /* Compute r = (g^k mod p) mod q */
198 if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx,
199 (BN_MONT_CTX *)dsa->method_mont_p)) goto err;
200 if (!BN_mod(r,r,dsa->q,ctx)) goto err;
201
202 /* Compute part of 's = inv(k) (m + xr) mod q' */
203 if ((kinv=BN_mod_inverse(NULL,&k,dsa->q,ctx)) == NULL) goto err;
204
205 if (*kinvp != NULL) BN_clear_free(*kinvp);
206 *kinvp=kinv;
207 kinv=NULL;
208 if (*rp != NULL) BN_clear_free(*rp);
209 *rp=r;
210 ret=1;
211err:
212 if (!ret)
213 {
214 DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
215 if (kinv != NULL) BN_clear_free(kinv);
216 if (r != NULL) BN_clear_free(r);
217 }
218 if (ctx_in == NULL) BN_CTX_free(ctx);
219 if (kinv != NULL) BN_clear_free(kinv);
220 BN_clear_free(&k);
221 return(ret);
222 }
223
224static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
225 DSA *dsa)
226 {
227 BN_CTX *ctx;
228 BIGNUM u1,u2,t1;
229 BN_MONT_CTX *mont=NULL;
230 int ret = -1;
231
232 if ((ctx=BN_CTX_new()) == NULL) goto err;
233 BN_init(&u1);
234 BN_init(&u2);
235 BN_init(&t1);
236
237 /* Calculate W = inv(S) mod Q
238 * save W in u2 */
239 if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;
240
241 /* save M in u1 */
242 if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err;
243
244 /* u1 = M * w mod q */
245 if (!BN_mod_mul(&u1,&u1,&u2,dsa->q,ctx)) goto err;
246
247 /* u2 = r * w mod q */
248 if (!BN_mod_mul(&u2,sig->r,&u2,dsa->q,ctx)) goto err;
249
250 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
251 {
252 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
253 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
254 dsa->p,ctx)) goto err;
255 }
256 mont=(BN_MONT_CTX *)dsa->method_mont_p;
257
258#if 0
259 {
260 BIGNUM t2;
261
262 BN_init(&t2);
263 /* v = ( g^u1 * y^u2 mod p ) mod q */
264 /* let t1 = g ^ u1 mod p */
265 if (!BN_mod_exp_mont(&t1,dsa->g,&u1,dsa->p,ctx,mont)) goto err;
266 /* let t2 = y ^ u2 mod p */
267 if (!BN_mod_exp_mont(&t2,dsa->pub_key,&u2,dsa->p,ctx,mont)) goto err;
268 /* let u1 = t1 * t2 mod p */
269 if (!BN_mod_mul(&u1,&t1,&t2,dsa->p,ctx)) goto err_bn;
270 BN_free(&t2);
271 }
272 /* let u1 = u1 mod q */
273 if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err;
274#else
275 {
276 if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2,
277 dsa->p,ctx,mont)) goto err;
278 /* BN_copy(&u1,&t1); */
279 /* let u1 = u1 mod q */
280 if (!BN_mod(&u1,&t1,dsa->q,ctx)) goto err;
281 }
282#endif
283 /* V is now in u1. If the signature is correct, it will be
284 * equal to R. */
285 ret=(BN_ucmp(&u1, sig->r) == 0);
286
287 err:
288 if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY,ERR_R_BN_LIB);
289 if (ctx != NULL) BN_CTX_free(ctx);
290 BN_free(&u1);
291 BN_free(&u2);
292 BN_free(&t1);
293 return(ret);
294 }
295
296static int dsa_init(DSA *dsa)
297{
298 dsa->flags|=DSA_FLAG_CACHE_MONT_P;
299 return(1);
300}
301
302static int dsa_finish(DSA *dsa)
303{
304 if(dsa->method_mont_p)
305 BN_MONT_CTX_free((BN_MONT_CTX *)dsa->method_mont_p);
306 return(1);
307}
308
309static int dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
310 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
311 BN_MONT_CTX *in_mont)
312{
313 return BN_mod_exp2_mont(rr, a1, p1, a2, p2, m, ctx, in_mont);
314}
315
316static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
317 const BIGNUM *m, BN_CTX *ctx,
318 BN_MONT_CTX *m_ctx)
319{
320 return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
321}
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_sign.c b/src/lib/libssl/src/crypto/dsa/dsa_sign.c
index 774c161964..89205026f0 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_sign.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_sign.c
@@ -67,73 +67,9 @@
67 67
68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
69 { 69 {
70 BIGNUM *kinv=NULL,*r=NULL,*s=NULL; 70 return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
71 BIGNUM m;
72 BIGNUM xr;
73 BN_CTX *ctx=NULL;
74 int i,reason=ERR_R_BN_LIB;
75 DSA_SIG *ret=NULL;
76
77 BN_init(&m);
78 BN_init(&xr);
79 s=BN_new();
80 if (s == NULL) goto err;
81
82 i=BN_num_bytes(dsa->q); /* should be 20 */
83 if ((dlen > i) || (dlen > 50))
84 {
85 reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;
86 goto err;
87 }
88
89 ctx=BN_CTX_new();
90 if (ctx == NULL) goto err;
91
92 if ((dsa->kinv == NULL) || (dsa->r == NULL))
93 {
94 if (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err;
95 }
96 else
97 {
98 kinv=dsa->kinv;
99 dsa->kinv=NULL;
100 r=dsa->r;
101 dsa->r=NULL;
102 }
103
104 if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err;
105
106 /* Compute s = inv(k) (m + xr) mod q */
107 if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */
108 if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */
109 if (BN_cmp(s,dsa->q) > 0)
110 BN_sub(s,s,dsa->q);
111 if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
112
113 ret=DSA_SIG_new();
114 if (ret == NULL) goto err;
115 ret->r = r;
116 ret->s = s;
117
118err:
119 if (!ret)
120 {
121 DSAerr(DSA_F_DSA_DO_SIGN,reason);
122 BN_free(r);
123 BN_free(s);
124 }
125 if (ctx != NULL) BN_CTX_free(ctx);
126 BN_clear_free(&m);
127 BN_clear_free(&xr);
128 if (kinv != NULL) /* dsa->kinv is NULL now if we used it */
129 BN_clear_free(kinv);
130 return(ret);
131 } 71 }
132 72
133/* data has already been hashed (probably with SHA or SHA-1). */
134
135/* unsigned char *sig: out */
136/* unsigned int *siglen: out */
137int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, 73int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
138 unsigned int *siglen, DSA *dsa) 74 unsigned int *siglen, DSA *dsa)
139 { 75 {
@@ -151,61 +87,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
151 87
152int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 88int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
153 { 89 {
154 BN_CTX *ctx; 90 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
155 BIGNUM k,*kinv=NULL,*r=NULL;
156 int ret=0;
157
158 if (ctx_in == NULL)
159 {
160 if ((ctx=BN_CTX_new()) == NULL) goto err;
161 }
162 else
163 ctx=ctx_in;
164
165 BN_init(&k);
166 if ((r=BN_new()) == NULL) goto err;
167 kinv=NULL;
168
169 /* Get random k */
170 for (;;)
171 {
172 if (!BN_rand(&k, BN_num_bits(dsa->q), 1, 0)) goto err;
173 if (BN_cmp(&k,dsa->q) >= 0)
174 BN_sub(&k,&k,dsa->q);
175 if (!BN_is_zero(&k)) break;
176 }
177
178 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
179 {
180 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
181 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
182 dsa->p,ctx)) goto err;
183 }
184
185 /* Compute r = (g^k mod p) mod q */
186 if (!BN_mod_exp_mont(r,dsa->g,&k,dsa->p,ctx,
187 (BN_MONT_CTX *)dsa->method_mont_p)) goto err;
188 if (!BN_mod(r,r,dsa->q,ctx)) goto err;
189
190 /* Compute part of 's = inv(k) (m + xr) mod q' */
191 if ((kinv=BN_mod_inverse(NULL,&k,dsa->q,ctx)) == NULL) goto err;
192
193 if (*kinvp != NULL) BN_clear_free(*kinvp);
194 *kinvp=kinv;
195 kinv=NULL;
196 if (*rp != NULL) BN_clear_free(*rp);
197 *rp=r;
198 ret=1;
199err:
200 if (!ret)
201 {
202 DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
203 if (kinv != NULL) BN_clear_free(kinv);
204 if (r != NULL) BN_clear_free(r);
205 }
206 if (ctx_in == NULL) BN_CTX_free(ctx);
207 if (kinv != NULL) BN_clear_free(kinv);
208 BN_clear_free(&k);
209 return(ret);
210 } 91 }
211 92
diff --git a/src/lib/libssl/src/crypto/dsa/dsa_vrf.c b/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
index ff552208aa..03277f80fd 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
+++ b/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
@@ -69,73 +69,7 @@
69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
70 DSA *dsa) 70 DSA *dsa)
71 { 71 {
72 BN_CTX *ctx; 72 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
73 BIGNUM u1,u2,t1;
74 BN_MONT_CTX *mont=NULL;
75 int ret = -1;
76
77 if ((ctx=BN_CTX_new()) == NULL) goto err;
78 BN_init(&u1);
79 BN_init(&u2);
80 BN_init(&t1);
81
82 /* Calculate W = inv(S) mod Q
83 * save W in u2 */
84 if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;
85
86 /* save M in u1 */
87 if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err;
88
89 /* u1 = M * w mod q */
90 if (!BN_mod_mul(&u1,&u1,&u2,dsa->q,ctx)) goto err;
91
92 /* u2 = r * w mod q */
93 if (!BN_mod_mul(&u2,sig->r,&u2,dsa->q,ctx)) goto err;
94
95 if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
96 {
97 if ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
98 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,
99 dsa->p,ctx)) goto err;
100 }
101 mont=(BN_MONT_CTX *)dsa->method_mont_p;
102
103#if 0
104 {
105 BIGNUM t2;
106
107 BN_init(&t2);
108 /* v = ( g^u1 * y^u2 mod p ) mod q */
109 /* let t1 = g ^ u1 mod p */
110 if (!BN_mod_exp_mont(&t1,dsa->g,&u1,dsa->p,ctx,mont)) goto err;
111 /* let t2 = y ^ u2 mod p */
112 if (!BN_mod_exp_mont(&t2,dsa->pub_key,&u2,dsa->p,ctx,mont)) goto err;
113 /* let u1 = t1 * t2 mod p */
114 if (!BN_mod_mul(&u1,&t1,&t2,dsa->p,ctx)) goto err_bn;
115 BN_free(&t2);
116 }
117 /* let u1 = u1 mod q */
118 if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err;
119#else
120 {
121 if (!BN_mod_exp2_mont(&t1,dsa->g,&u1,dsa->pub_key,&u2,dsa->p,ctx,mont))
122 goto err;
123 /* BN_copy(&u1,&t1); */
124 /* let u1 = u1 mod q */
125 if (!BN_mod(&u1,&t1,dsa->q,ctx)) goto err;
126 }
127#endif
128 /* V is now in u1. If the signature is correct, it will be
129 * equal to R. */
130 ret=(BN_ucmp(&u1, sig->r) == 0);
131
132 err:
133 if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY,ERR_R_BN_LIB);
134 if (ctx != NULL) BN_CTX_free(ctx);
135 BN_free(&u1);
136 BN_free(&u2);
137 BN_free(&t1);
138 return(ret);
139 } 73 }
140 74
141/* data has already been hashed (probably with SHA or SHA-1). */ 75/* data has already been hashed (probably with SHA or SHA-1). */
diff --git a/src/lib/libssl/src/crypto/dsa/dsatest.c b/src/lib/libssl/src/crypto/dsa/dsatest.c
index fc25c9a1b7..309a7cda89 100644
--- a/src/lib/libssl/src/crypto/dsa/dsatest.c
+++ b/src/lib/libssl/src/crypto/dsa/dsatest.c
@@ -84,7 +84,10 @@ int main(int argc, char *argv[])
84#define MS_CALLBACK 84#define MS_CALLBACK
85#endif 85#endif
86 86
87static void MS_CALLBACK dsa_cb(int p, int n, char *arg); 87static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
88
89/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
90 * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
88static unsigned char seed[20]={ 91static unsigned char seed[20]={
89 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, 92 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40,
90 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, 93 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3,
@@ -120,6 +123,8 @@ static unsigned char out_g[]={
120 123
121static const unsigned char str1[]="12345678901234567890"; 124static const unsigned char str1[]="12345678901234567890";
122 125
126static const char rnd_seed[] = "string to make the random number generator think it has entropy";
127
123static BIO *bio_err=NULL; 128static BIO *bio_err=NULL;
124 129
125int main(int argc, char **argv) 130int main(int argc, char **argv)
@@ -131,15 +136,17 @@ int main(int argc, char **argv)
131 unsigned char sig[256]; 136 unsigned char sig[256];
132 unsigned int siglen; 137 unsigned int siglen;
133 138
139 ERR_load_crypto_strings();
140 RAND_seed(rnd_seed, sizeof rnd_seed);
141
134 if (bio_err == NULL) 142 if (bio_err == NULL)
135 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 143 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
136 144
137 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 145 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
138 146
139 BIO_printf(bio_err,"test generation of DSA parameters\n"); 147 BIO_printf(bio_err,"test generation of DSA parameters\n");
140 BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n"); 148
141 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb, 149 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
142 (char *)bio_err);
143 150
144 BIO_printf(bio_err,"seed\n"); 151 BIO_printf(bio_err,"seed\n");
145 for (i=0; i<20; i+=4) 152 for (i=0; i<20; i+=4)
@@ -193,13 +200,18 @@ end:
193 if (!ret) 200 if (!ret)
194 ERR_print_errors(bio_err); 201 ERR_print_errors(bio_err);
195 if (dsa != NULL) DSA_free(dsa); 202 if (dsa != NULL) DSA_free(dsa);
203 ERR_remove_state(0);
196 CRYPTO_mem_leaks(bio_err); 204 CRYPTO_mem_leaks(bio_err);
197 if (bio_err != NULL) BIO_free(bio_err); 205 if (bio_err != NULL)
206 {
207 BIO_free(bio_err);
208 bio_err = NULL;
209 }
198 exit(!ret); 210 exit(!ret);
199 return(0); 211 return(0);
200 } 212 }
201 213
202static void MS_CALLBACK dsa_cb(int p, int n, char *arg) 214static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
203 { 215 {
204 char c='*'; 216 char c='*';
205 static int ok=0,num=0; 217 static int ok=0,num=0;
@@ -208,8 +220,8 @@ static void MS_CALLBACK dsa_cb(int p, int n, char *arg)
208 if (p == 1) c='+'; 220 if (p == 1) c='+';
209 if (p == 2) { c='*'; ok++; } 221 if (p == 2) { c='*'; ok++; }
210 if (p == 3) c='\n'; 222 if (p == 3) c='\n';
211 BIO_write((BIO *)arg,&c,1); 223 BIO_write(arg,&c,1);
212 (void)BIO_flush((BIO *)arg); 224 (void)BIO_flush(arg);
213 225
214 if (!ok && (p == 0) && (num > 1)) 226 if (!ok && (p == 0) && (num > 1))
215 { 227 {
diff --git a/src/lib/libssl/src/crypto/ebcdic.c b/src/lib/libssl/src/crypto/ebcdic.c
new file mode 100644
index 0000000000..31397b2add
--- /dev/null
+++ b/src/lib/libssl/src/crypto/ebcdic.c
@@ -0,0 +1,217 @@
1/* crypto/ebcdic.c */
2
3#ifdef CHARSET_EBCDIC
4#include "ebcdic.h"
5/* Initial Port for Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>
6 * Adapted for OpenSSL-0.9.4 by <Martin.Kraemer@Mch.SNI.De>
7 */
8
9#ifdef _OSD_POSIX
10/*
11 "BS2000 OSD" is a POSIX subsystem on a main frame.
12 It is made by Siemens AG, Germany, for their BS2000 mainframe machines.
13 Within the POSIX subsystem, the same character set was chosen as in
14 "native BS2000", namely EBCDIC. (EDF04)
15
16 The name "ASCII" in these routines is misleading: actually, conversion
17 is not between EBCDIC and ASCII, but EBCDIC(EDF04) and ISO-8859.1;
18 that means that (western european) national characters are preserved.
19
20 This table is identical to the one used by rsh/rcp/ftp and other POSIX tools.
21*/
22
23/* Here's the bijective ebcdic-to-ascii table: */
24const unsigned char os_toascii[256] = {
25/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
26 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
27/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
28 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
29/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
30 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
31/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
32 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
33/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
34 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
35/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
36 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
37/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
38 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
39/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
40 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
41/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
42 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
43/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
44 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
45/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
46 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
47/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
48 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
49/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
50 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
51/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
52 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
53/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
54 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
55/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
56 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
57};
58
59
60/* The ascii-to-ebcdic table: */
61const unsigned char os_toebcdic[256] = {
62/*00*/ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
63 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
64/*10*/ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
65 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
66/*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
67 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
68/*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
69 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /*0123456789:;<=>?*/
70/*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
71 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /*@ABCDEFGHIJKLMNO*/
72/*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
73 0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d, /*PQRSTUVWXYZ[\]^_*/
74/*60*/ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
75 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /*`abcdefghijklmno*/
76/*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
77 0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07, /*pqrstuvwxyz{|}~.*/
78/*80*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
79 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /*................*/
80/*90*/ 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
81 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f, /*................*/
82/*a0*/ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
83 0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1, /*................*/
84/*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
85 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /*................*/
86/*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
87 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /*................*/
88/*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
89 0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59, /*................*/
90/*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
91 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /*................*/
92/*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
93 0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /*................*/
94};
95
96#else /*_OSD_POSIX*/
97
98/*
99This code does basic character mapping for IBM's TPF and OS/390 operating systems.
100It is a modified version of the BS2000 table.
101
102Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
103This table is bijective - there are no ambigous or duplicate characters.
104*/
105const unsigned char os_toascii[256] = {
106 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
107 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
108 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
109 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
110 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
111 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
112 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
113 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
114 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
115 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
116 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
117 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
118 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
119 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
120 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
121 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
122 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
123 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
124 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
125 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
126 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
127 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
128 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
129 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
130 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
131 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
132 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
133 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
134 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
135 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
136 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
137 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
138};
139
140
141/*
142The US-ASCII to EBCDIC (character set IBM-1047) table:
143This table is bijective (no ambiguous or duplicate characters)
144*/
145const unsigned char os_toebcdic[256] = {
146 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f: */
147 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
148 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f: */
149 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
150 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f: */
151 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
152 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f: */
153 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
154 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f: */
155 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
156 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f: */
157 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
158 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f: */
159 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
160 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f: */
161 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
162 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f: */
163 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
164 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f: */
165 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
166 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af: */
167 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
168 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf: */
169 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
170 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf: */
171 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
172 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df: */
173 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
174 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef: */
175 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
176 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */
177 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */
178};
179#endif /*_OSD_POSIX*/
180
181/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
182 * dest and srce may be identical, or separate memory blocks, but
183 * should not overlap. These functions intentionally have an interface
184 * compatible to memcpy(3).
185 */
186
187void *
188ebcdic2ascii(void *dest, const void *srce, size_t count)
189{
190 unsigned char *udest = dest;
191 const unsigned char *usrce = srce;
192
193 while (count-- != 0) {
194 *udest++ = os_toascii[*usrce++];
195 }
196
197 return dest;
198}
199
200void *
201ascii2ebcdic(void *dest, const void *srce, size_t count)
202{
203 unsigned char *udest = dest;
204 const unsigned char *usrce = srce;
205
206 while (count-- != 0) {
207 *udest++ = os_toebcdic[*usrce++];
208 }
209
210 return dest;
211}
212
213#else /*CHARSET_EBCDIC*/
214#ifdef PEDANTIC
215static void *dummy=&dummy;
216#endif
217#endif
diff --git a/src/lib/libssl/src/crypto/ebcdic.h b/src/lib/libssl/src/crypto/ebcdic.h
index d3b4e98b12..6d65afcf9e 100644
--- a/src/lib/libssl/src/crypto/ebcdic.h
+++ b/src/lib/libssl/src/crypto/ebcdic.h
@@ -1,17 +1,19 @@
1/* crypto/ebcdic.h */
2
1#ifndef HEADER_EBCDIC_H 3#ifndef HEADER_EBCDIC_H
2#define HEADER_EBCDIC_H 4#define HEADER_EBCDIC_H
3 5
4#include <sys/types.h> 6#include <sys/types.h>
5 7
6/* Avoid name clashes with other applications */ 8/* Avoid name clashes with other applications */
7#define os_toascii _eay2000_os_toascii 9#define os_toascii _openssl_os_toascii
8#define os_toebcdic _eay2000_os_toebcdic 10#define os_toebcdic _openssl_os_toebcdic
9#define ebcdic2ascii _eay2000_ebcdic2ascii 11#define ebcdic2ascii _openssl_ebcdic2ascii
10#define ascii2ebcdic _eay2000_ascii2ebcdic 12#define ascii2ebcdic _openssl_ascii2ebcdic
11 13
12extern const unsigned char os_toascii[256]; 14extern const unsigned char os_toascii[256];
13extern const unsigned char os_toebcdic[256]; 15extern const unsigned char os_toebcdic[256];
14void ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t count); 16void *ebcdic2ascii(void *dest, const void *srce, size_t count);
15void ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t count); 17void *ascii2ebcdic(void *dest, const void *srce, size_t count);
16 18
17#endif 19#endif
diff --git a/src/lib/libssl/src/crypto/err/Makefile.ssl b/src/lib/libssl/src/crypto/err/Makefile.ssl
index ae827edddb..fb74e4eb13 100644
--- a/src/lib/libssl/src/crypto/err/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/err/Makefile.ssl
@@ -82,8 +82,8 @@ err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 84err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
85err.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 85err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
86err.o: ../cryptlib.h 86err.o: ../../include/openssl/stack.h ../cryptlib.h
87err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 87err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
88err_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 88err_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
89err_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 89err_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -96,15 +96,16 @@ err_all.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
96err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h 96err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
97err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 97err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
98err_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h 98err_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
99err_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 99err_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
100err_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 100err_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
101err_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 101err_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
102err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 102err_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
103err_all.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 103err_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
104err_all.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 104err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
105err_all.o: ../../include/openssl/x509v3.h
105err_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 106err_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
106err_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 107err_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
107err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 108err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
108err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 109err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
109err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 110err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
110err_prn.o: ../cryptlib.h 111err_prn.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/err/err.c b/src/lib/libssl/src/crypto/err/err.c
index 8810d838c6..93c64cbc4f 100644
--- a/src/lib/libssl/src/crypto/err/err.c
+++ b/src/lib/libssl/src/crypto/err/err.c
@@ -91,7 +91,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
91{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, 91{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
92{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, 92{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
93{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, 93{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
94{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuation file routines"}, 94{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
95{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"}, 95{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"},
96{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, 96{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
97{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"}, 97{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"},
@@ -100,6 +100,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
100{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, 100{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
101{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, 101{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
102{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"}, 102{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
103{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
103{0,NULL}, 104{0,NULL},
104 }; 105 };
105 106
@@ -221,7 +222,7 @@ void ERR_load_strings(int lib, ERR_STRING_DATA *str)
221 while (str->error) 222 while (str->error)
222 { 223 {
223 str->error|=ERR_PACK(lib,0,0); 224 str->error|=ERR_PACK(lib,0,0);
224 lh_insert(error_hash,(char *)str); 225 lh_insert(error_hash,str);
225 str++; 226 str++;
226 } 227 }
227 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); 228 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
@@ -427,7 +428,7 @@ const char *ERR_lib_error_string(unsigned long e)
427 if (error_hash != NULL) 428 if (error_hash != NULL)
428 { 429 {
429 d.error=ERR_PACK(l,0,0); 430 d.error=ERR_PACK(l,0,0);
430 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); 431 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
431 } 432 }
432 433
433 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); 434 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH);
@@ -448,7 +449,7 @@ const char *ERR_func_error_string(unsigned long e)
448 if (error_hash != NULL) 449 if (error_hash != NULL)
449 { 450 {
450 d.error=ERR_PACK(l,f,0); 451 d.error=ERR_PACK(l,f,0);
451 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); 452 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
452 } 453 }
453 454
454 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH); 455 CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH);
@@ -469,12 +470,11 @@ const char *ERR_reason_error_string(unsigned long e)
469 if (error_hash != NULL) 470 if (error_hash != NULL)
470 { 471 {
471 d.error=ERR_PACK(l,0,r); 472 d.error=ERR_PACK(l,0,r);
472 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,(char *)&d); 473 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
473 if (p == NULL) 474 if (p == NULL)
474 { 475 {
475 d.error=ERR_PACK(0,0,r); 476 d.error=ERR_PACK(0,0,r);
476 p=(ERR_STRING_DATA *)lh_retrieve(error_hash, 477 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
477 (char *)&d);
478 } 478 }
479 } 479 }
480 480
@@ -517,7 +517,7 @@ void ERR_remove_state(unsigned long pid)
517 pid=(unsigned long)CRYPTO_thread_id(); 517 pid=(unsigned long)CRYPTO_thread_id();
518 tmp.pid=pid; 518 tmp.pid=pid;
519 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 519 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
520 p=(ERR_STATE *)lh_delete(thread_hash,(char *)&tmp); 520 p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
521 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 521 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
522 522
523 if (p != NULL) ERR_STATE_free(p); 523 if (p != NULL) ERR_STATE_free(p);
@@ -551,7 +551,7 @@ ERR_STATE *ERR_get_state(void)
551 else 551 else
552 { 552 {
553 tmp.pid=pid; 553 tmp.pid=pid;
554 ret=(ERR_STATE *)lh_retrieve(thread_hash,(char *)&tmp); 554 ret=(ERR_STATE *)lh_retrieve(thread_hash,&tmp);
555 CRYPTO_r_unlock(CRYPTO_LOCK_ERR); 555 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
556 } 556 }
557 557
@@ -569,7 +569,7 @@ ERR_STATE *ERR_get_state(void)
569 ret->err_data_flags[i]=0; 569 ret->err_data_flags[i]=0;
570 } 570 }
571 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 571 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
572 tmpp=(ERR_STATE *)lh_insert(thread_hash,(char *)ret); 572 tmpp=(ERR_STATE *)lh_insert(thread_hash,ret);
573 CRYPTO_w_unlock(CRYPTO_LOCK_ERR); 573 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
574 if (tmpp != NULL) /* old entry - should not happen */ 574 if (tmpp != NULL) /* old entry - should not happen */
575 { 575 {
diff --git a/src/lib/libssl/src/crypto/err/err.h b/src/lib/libssl/src/crypto/err/err.h
index 9411fb3568..15bafbff43 100644
--- a/src/lib/libssl/src/crypto/err/err.h
+++ b/src/lib/libssl/src/crypto/err/err.h
@@ -122,6 +122,7 @@ typedef struct err_state_st
122#define ERR_LIB_PKCS7 33 122#define ERR_LIB_PKCS7 33
123#define ERR_LIB_X509V3 34 123#define ERR_LIB_X509V3 34
124#define ERR_LIB_PKCS12 35 124#define ERR_LIB_PKCS12 35
125#define ERR_LIB_RAND 36
125 126
126#define ERR_LIB_USER 128 127#define ERR_LIB_USER 128
127 128
@@ -149,6 +150,7 @@ typedef struct err_state_st
149#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__) 150#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__)
150#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__) 151#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__)
151#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__) 152#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__)
153#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),ERR_file_name,__LINE__)
152 154
153/* Borland C seems too stupid to be able to shift and do longs in 155/* Borland C seems too stupid to be able to shift and do longs in
154 * the pre-processor :-( */ 156 * the pre-processor :-( */
@@ -160,7 +162,7 @@ typedef struct err_state_st
160#define ERR_GET_REASON(l) (int)((l)&0xfffL) 162#define ERR_GET_REASON(l) (int)((l)&0xfffL)
161#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) 163#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
162 164
163/* OS fuctions */ 165/* OS functions */
164#define SYS_F_FOPEN 1 166#define SYS_F_FOPEN 1
165#define SYS_F_CONNECT 2 167#define SYS_F_CONNECT 2
166#define SYS_F_GETSERVBYNAME 3 168#define SYS_F_GETSERVBYNAME 3
@@ -239,9 +241,9 @@ void ERR_print_errors(BIO *bp);
239void ERR_add_error_data(int num, ...); 241void ERR_add_error_data(int num, ...);
240#endif 242#endif
241void ERR_load_strings(int lib,ERR_STRING_DATA str[]); 243void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
242void ERR_load_ERR_strings(void ); 244void ERR_load_ERR_strings(void);
243void ERR_load_crypto_strings(void ); 245void ERR_load_crypto_strings(void);
244void ERR_free_strings(void ); 246void ERR_free_strings(void);
245 247
246void ERR_remove_state(unsigned long pid); /* if zero we look it up */ 248void ERR_remove_state(unsigned long pid); /* if zero we look it up */
247ERR_STATE *ERR_get_state(void); 249ERR_STATE *ERR_get_state(void);
diff --git a/src/lib/libssl/src/crypto/err/err_all.c b/src/lib/libssl/src/crypto/err/err_all.c
index ad820227d2..10c463b389 100644
--- a/src/lib/libssl/src/crypto/err/err_all.c
+++ b/src/lib/libssl/src/crypto/err/err_all.c
@@ -80,6 +80,7 @@
80#include <openssl/x509v3.h> 80#include <openssl/x509v3.h>
81#include <openssl/conf.h> 81#include <openssl/conf.h>
82#include <openssl/pkcs12.h> 82#include <openssl/pkcs12.h>
83#include <openssl/rand.h>
83#include <openssl/err.h> 84#include <openssl/err.h>
84 85
85void ERR_load_crypto_strings(void) 86void ERR_load_crypto_strings(void)
@@ -116,5 +117,6 @@ void ERR_load_crypto_strings(void)
116 ERR_load_CRYPTO_strings(); 117 ERR_load_CRYPTO_strings();
117 ERR_load_PKCS7_strings(); 118 ERR_load_PKCS7_strings();
118 ERR_load_PKCS12_strings(); 119 ERR_load_PKCS12_strings();
120 ERR_load_RAND_strings();
119#endif 121#endif
120 } 122 }
diff --git a/src/lib/libssl/src/crypto/err/openssl.ec b/src/lib/libssl/src/crypto/err/openssl.ec
index c2a8acff0c..e132ba3182 100644
--- a/src/lib/libssl/src/crypto/err/openssl.ec
+++ b/src/lib/libssl/src/crypto/err/openssl.ec
@@ -21,6 +21,7 @@ L PKCS12 crypto/pkcs12/pkcs12.h crypto/pkcs12/pk12err.c
21L RSAREF rsaref/rsaref.h rsaref/rsar_err.c 21L RSAREF rsaref/rsaref.h rsaref/rsar_err.c
22L SSL ssl/ssl.h ssl/ssl_err.c 22L SSL ssl/ssl.h ssl/ssl_err.c
23L COMP crypto/comp/comp.h crypto/comp/comp_err.c 23L COMP crypto/comp/comp.h crypto/comp/comp_err.c
24L RAND crypto/rand/rand.h crypto/rand/rand_err.c
24 25
25 26
26F RSAREF_F_RSA_BN2BIN 27F RSAREF_F_RSA_BN2BIN
@@ -47,11 +48,11 @@ R SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048
47R SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 48R SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
48R SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 49R SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
49R SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 50R SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051
50R SSL_R_TLSV1_ALERT_EXPORT_RESTRICION 1060 51R SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
51R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 52R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
52R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 53R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
53R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 54R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
54R SSL_R_TLSV1_ALERT_USER_CANCLED 1090 55R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
55R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 56R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
56 57
57R RSAREF_R_CONTENT_ENCODING 0x0400 58R RSAREF_R_CONTENT_ENCODING 0x0400
diff --git a/src/lib/libssl/src/crypto/evp/Makefile.ssl b/src/lib/libssl/src/crypto/evp/Makefile.ssl
index 753479a015..c763b5ccd6 100644
--- a/src/lib/libssl/src/crypto/evp/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/evp/Makefile.ssl
@@ -35,7 +35,8 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c \
35 m_ripemd.c \ 35 m_ripemd.c \
36 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ 36 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
37 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ 37 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
38 c_all.c evp_lib.c bio_ok.c evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c 38 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
39 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c
39 40
40LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \ 41LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
41 e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \ 42 e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \
@@ -50,7 +51,8 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
50 m_ripemd.o \ 51 m_ripemd.o \
51 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ 52 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
52 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \ 53 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \
53 c_all.o evp_lib.o bio_ok.o evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o 54 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \
55 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o
54 56
55SRC= $(LIBSRC) 57SRC= $(LIBSRC)
56 58
@@ -176,13 +178,45 @@ c_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
176c_all.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 178c_all.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
177c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 179c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
178c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 180c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
179c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 181c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h
180c_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
181c_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 182c_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
182c_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 183c_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
183c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 184c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
184c_all.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 185c_all.o: ../../include/openssl/stack.h ../cryptlib.h
185c_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 186c_allc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
187c_allc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
188c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
189c_allc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
190c_allc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
191c_allc.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
192c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
193c_allc.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
194c_allc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
195c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
196c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
197c_allc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
198c_allc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
199c_allc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
200c_allc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
201c_allc.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
202c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
203c_alld.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
204c_alld.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
205c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
206c_alld.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
207c_alld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
208c_alld.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
209c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
210c_alld.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
211c_alld.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
212c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
213c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
214c_alld.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
215c_alld.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
216c_alld.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
217c_alld.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
218c_alld.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
219c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
186digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 220digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
187digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 221digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
188digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 222digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
diff --git a/src/lib/libssl/src/crypto/evp/bio_b64.c b/src/lib/libssl/src/crypto/evp/bio_b64.c
index 84729119df..bd5e24f993 100644
--- a/src/lib/libssl/src/crypto/evp/bio_b64.c
+++ b/src/lib/libssl/src/crypto/evp/bio_b64.c
@@ -69,6 +69,7 @@ static int b64_read(BIO *h,char *buf,int size);
69static long b64_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long b64_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int b64_new(BIO *h); 70static int b64_new(BIO *h);
71static int b64_free(BIO *data); 71static int b64_free(BIO *data);
72static long b64_callback_ctrl(BIO *h,int cmd,void (*fp)());
72#define B64_BLOCK_SIZE 1024 73#define B64_BLOCK_SIZE 1024
73#define B64_BLOCK_SIZE2 768 74#define B64_BLOCK_SIZE2 768
74#define B64_NONE 0 75#define B64_NONE 0
@@ -100,6 +101,7 @@ static BIO_METHOD methods_b64=
100 b64_ctrl, 101 b64_ctrl,
101 b64_new, 102 b64_new,
102 b64_free, 103 b64_free,
104 b64_callback_ctrl,
103 }; 105 };
104 106
105BIO_METHOD *BIO_f_base64(void) 107BIO_METHOD *BIO_f_base64(void)
@@ -237,8 +239,8 @@ static int b64_read(BIO *b, char *out, int outl)
237 &(ctx->tmp[0])); 239 &(ctx->tmp[0]));
238 for (x=0; x < i; x++) 240 for (x=0; x < i; x++)
239 ctx->tmp[x]=p[x]; 241 ctx->tmp[x]=p[x];
240 EVP_DecodeInit(&ctx->base64);
241 } 242 }
243 EVP_DecodeInit(&ctx->base64);
242 ctx->start=0; 244 ctx->start=0;
243 break; 245 break;
244 } 246 }
@@ -522,3 +524,17 @@ again:
522 return(ret); 524 return(ret);
523 } 525 }
524 526
527static long b64_callback_ctrl(BIO *b, int cmd, void (*fp)())
528 {
529 long ret=1;
530
531 if (b->next_bio == NULL) return(0);
532 switch (cmd)
533 {
534 default:
535 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
536 break;
537 }
538 return(ret);
539 }
540
diff --git a/src/lib/libssl/src/crypto/evp/bio_enc.c b/src/lib/libssl/src/crypto/evp/bio_enc.c
index 0a7b1ecf07..629bf4b95d 100644
--- a/src/lib/libssl/src/crypto/evp/bio_enc.c
+++ b/src/lib/libssl/src/crypto/evp/bio_enc.c
@@ -69,6 +69,7 @@ static int enc_read(BIO *h,char *buf,int size);
69static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int enc_new(BIO *h); 70static 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,void (*fp)());
72#define ENC_BLOCK_SIZE (1024*4) 73#define ENC_BLOCK_SIZE (1024*4)
73 74
74typedef struct enc_struct 75typedef struct enc_struct
@@ -92,6 +93,7 @@ static BIO_METHOD methods_enc=
92 enc_ctrl, 93 enc_ctrl,
93 enc_new, 94 enc_new,
94 enc_free, 95 enc_free,
96 enc_callback_ctrl,
95 }; 97 };
96 98
97BIO_METHOD *BIO_f_cipher(void) 99BIO_METHOD *BIO_f_cipher(void)
@@ -184,9 +186,11 @@ static int enc_read(BIO *b, char *out, int outl)
184 ctx->ok=i; 186 ctx->ok=i;
185 ctx->buf_off=0; 187 ctx->buf_off=0;
186 } 188 }
187 else 189 else
190 {
188 ret=(ret == 0)?i:ret; 191 ret=(ret == 0)?i:ret;
189 break; 192 break;
193 }
190 } 194 }
191 else 195 else
192 { 196 {
@@ -194,13 +198,19 @@ static int enc_read(BIO *b, char *out, int outl)
194 (unsigned char *)ctx->buf,&ctx->buf_len, 198 (unsigned char *)ctx->buf,&ctx->buf_len,
195 (unsigned char *)&(ctx->buf[8]),i); 199 (unsigned char *)&(ctx->buf[8]),i);
196 ctx->cont=1; 200 ctx->cont=1;
201 /* Note: it is possible for EVP_CipherUpdate to
202 * decrypt zero bytes because this is or looks like
203 * the final block: if this happens we should retry
204 * and either read more data or decrypt the final
205 * block
206 */
207 if(ctx->buf_len == 0) continue;
197 } 208 }
198 209
199 if (ctx->buf_len <= outl) 210 if (ctx->buf_len <= outl)
200 i=ctx->buf_len; 211 i=ctx->buf_len;
201 else 212 else
202 i=outl; 213 i=outl;
203
204 if (i <= 0) break; 214 if (i <= 0) break;
205 memcpy(out,ctx->buf,i); 215 memcpy(out,ctx->buf,i);
206 ret+=i; 216 ret+=i;
@@ -360,6 +370,20 @@ again:
360 return(ret); 370 return(ret);
361 } 371 }
362 372
373static long enc_callback_ctrl(BIO *b, int cmd, void (*fp)())
374 {
375 long ret=1;
376
377 if (b->next_bio == NULL) return(0);
378 switch (cmd)
379 {
380 default:
381 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
382 break;
383 }
384 return(ret);
385 }
386
363/* 387/*
364void BIO_set_cipher_ctx(b,c) 388void BIO_set_cipher_ctx(b,c)
365BIO *b; 389BIO *b;
diff --git a/src/lib/libssl/src/crypto/evp/bio_md.c b/src/lib/libssl/src/crypto/evp/bio_md.c
index 317167f9c4..aef928dd8f 100644
--- a/src/lib/libssl/src/crypto/evp/bio_md.c
+++ b/src/lib/libssl/src/crypto/evp/bio_md.c
@@ -72,6 +72,8 @@ static int md_gets(BIO *h,char *str,int size);
72static long md_ctrl(BIO *h,int cmd,long arg1,char *arg2); 72static long md_ctrl(BIO *h,int cmd,long arg1,char *arg2);
73static int md_new(BIO *h); 73static int md_new(BIO *h);
74static int md_free(BIO *data); 74static int md_free(BIO *data);
75static long md_callback_ctrl(BIO *h,int cmd,void (*fp)());
76
75static BIO_METHOD methods_md= 77static BIO_METHOD methods_md=
76 { 78 {
77 BIO_TYPE_MD,"message digest", 79 BIO_TYPE_MD,"message digest",
@@ -82,6 +84,7 @@ static BIO_METHOD methods_md=
82 md_ctrl, 84 md_ctrl,
83 md_new, 85 md_new,
84 md_free, 86 md_free,
87 md_callback_ctrl,
85 }; 88 };
86 89
87BIO_METHOD *BIO_f_md(void) 90BIO_METHOD *BIO_f_md(void)
@@ -220,6 +223,20 @@ static long md_ctrl(BIO *b, int cmd, long num, char *ptr)
220 return(ret); 223 return(ret);
221 } 224 }
222 225
226static long md_callback_ctrl(BIO *b, int cmd, void (*fp)())
227 {
228 long ret=1;
229
230 if (b->next_bio == NULL) return(0);
231 switch (cmd)
232 {
233 default:
234 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
235 break;
236 }
237 return(ret);
238 }
239
223static int md_gets(BIO *bp, char *buf, int size) 240static int md_gets(BIO *bp, char *buf, int size)
224 { 241 {
225 EVP_MD_CTX *ctx; 242 EVP_MD_CTX *ctx;
diff --git a/src/lib/libssl/src/crypto/evp/bio_ok.c b/src/lib/libssl/src/crypto/evp/bio_ok.c
index 101275d648..e6ff5f2cdb 100644
--- a/src/lib/libssl/src/crypto/evp/bio_ok.c
+++ b/src/lib/libssl/src/crypto/evp/bio_ok.c
@@ -67,7 +67,7 @@
67 and everything was OK. BUT if user types wrong password 67 and everything was OK. BUT if user types wrong password
68 BIO_f_cipher outputs only garbage and my function crashes. Yes 68 BIO_f_cipher outputs only garbage and my function crashes. Yes
69 I can and I should fix my function, but BIO_f_cipher is 69 I can and I should fix my function, but BIO_f_cipher is
70 easy way to add encryption support to many exisiting applications 70 easy way to add encryption support to many existing applications
71 and it's hard to debug and fix them all. 71 and it's hard to debug and fix them all.
72 72
73 So I wanted another BIO which would catch the incorrect passwords and 73 So I wanted another BIO which would catch the incorrect passwords and
@@ -80,10 +80,10 @@
80 1) you must somehow separate checksum from actual data. 80 1) you must somehow separate checksum from actual data.
81 2) you need lot's of memory when reading the file, because you 81 2) you need lot's of memory when reading the file, because you
82 must read to the end of the file and verify the checksum before 82 must read to the end of the file and verify the checksum before
83 leting the application to read the data. 83 letting the application to read the data.
84 84
85 BIO_f_reliable tries to solve both problems, so that you can 85 BIO_f_reliable tries to solve both problems, so that you can
86 read and write arbitraly long streams using only fixed amount 86 read and write arbitrary long streams using only fixed amount
87 of memory. 87 of memory.
88 88
89 BIO_f_reliable splits data stream into blocks. Each block is prefixed 89 BIO_f_reliable splits data stream into blocks. Each block is prefixed
@@ -91,7 +91,7 @@
91 several Kbytes of memory to buffer single block before verifying 91 several Kbytes of memory to buffer single block before verifying
92 it's digest. 92 it's digest.
93 93
94 BIO_f_reliable goes futher and adds several important capabilities: 94 BIO_f_reliable goes further and adds several important capabilities:
95 95
96 1) the digest of the block is computed over the whole stream 96 1) the digest of the block is computed over the whole stream
97 -- so nobody can rearrange the blocks or remove or replace them. 97 -- so nobody can rearrange the blocks or remove or replace them.
@@ -110,7 +110,7 @@
110 and then compare the digest output. 110 and then compare the digest output.
111 111
112 Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I 112 Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I
113 initialy wrote and tested this code on x86 machine and wrote the 113 initially wrote and tested this code on x86 machine and wrote the
114 digests out in machine-dependent order :( There are people using 114 digests out in machine-dependent order :( There are people using
115 this code and I cannot change this easily without making existing 115 this code and I cannot change this easily without making existing
116 data files unreadable. 116 data files unreadable.
@@ -130,6 +130,8 @@ static int ok_read(BIO *h,char *buf,int size);
130static long ok_ctrl(BIO *h,int cmd,long arg1,char *arg2); 130static long ok_ctrl(BIO *h,int cmd,long arg1,char *arg2);
131static int ok_new(BIO *h); 131static int ok_new(BIO *h);
132static int ok_free(BIO *data); 132static int ok_free(BIO *data);
133static long ok_callback_ctrl(BIO *h,int cmd,void (*fp)());
134
133static void sig_out(BIO* b); 135static void sig_out(BIO* b);
134static void sig_in(BIO* b); 136static void sig_in(BIO* b);
135static void block_out(BIO* b); 137static void block_out(BIO* b);
@@ -173,6 +175,7 @@ static BIO_METHOD methods_ok=
173 ok_ctrl, 175 ok_ctrl,
174 ok_new, 176 ok_new,
175 ok_free, 177 ok_free,
178 ok_callback_ctrl,
176 }; 179 };
177 180
178BIO_METHOD *BIO_f_reliable(void) 181BIO_METHOD *BIO_f_reliable(void)
@@ -428,6 +431,20 @@ static long ok_ctrl(BIO *b, int cmd, long num, char *ptr)
428 return(ret); 431 return(ret);
429 } 432 }
430 433
434static long ok_callback_ctrl(BIO *b, int cmd, void (*fp)())
435 {
436 long ret=1;
437
438 if (b->next_bio == NULL) return(0);
439 switch (cmd)
440 {
441 default:
442 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
443 break;
444 }
445 return(ret);
446 }
447
431static void longswap(void *_ptr, int len) 448static void longswap(void *_ptr, int len)
432{ 449{
433#ifndef L_ENDIAN 450#ifndef L_ENDIAN
@@ -451,12 +468,12 @@ static void sig_out(BIO* b)
451 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return; 468 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return;
452 469
453 EVP_DigestInit(md, md->digest); 470 EVP_DigestInit(md, md->digest);
454 RAND_bytes(&(md->md.base[0]), md->digest->md_size); 471 RAND_pseudo_bytes(&(md->md.base[0]), md->digest->md_size);
455 memcpy(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]), md->digest->md_size); 472 memcpy(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]), md->digest->md_size);
456 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); 473 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size);
457 ctx->buf_len+= md->digest->md_size; 474 ctx->buf_len+= md->digest->md_size;
458 475
459 EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); 476 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
460 md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); 477 md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]));
461 ctx->buf_len+= md->digest->md_size; 478 ctx->buf_len+= md->digest->md_size;
462 ctx->blockout= 1; 479 ctx->blockout= 1;
@@ -480,7 +497,7 @@ static void sig_in(BIO* b)
480 longswap(&(md->md.base[0]), md->digest->md_size); 497 longswap(&(md->md.base[0]), md->digest->md_size);
481 ctx->buf_off+= md->digest->md_size; 498 ctx->buf_off+= md->digest->md_size;
482 499
483 EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); 500 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
484 md->digest->final(tmp, &(md->md.base[0])); 501 md->digest->final(tmp, &(md->md.base[0]));
485 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; 502 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0;
486 ctx->buf_off+= md->digest->md_size; 503 ctx->buf_off+= md->digest->md_size;
diff --git a/src/lib/libssl/src/crypto/evp/c_all.c b/src/lib/libssl/src/crypto/evp/c_all.c
index a4d3b43fb9..1e185830a3 100644
--- a/src/lib/libssl/src/crypto/evp/c_all.c
+++ b/src/lib/libssl/src/crypto/evp/c_all.c
@@ -59,135 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64 62
65void SSLeay_add_all_algorithms(void) 63void OpenSSL_add_all_algorithms(void)
66 { 64{
67 SSLeay_add_all_ciphers(); 65 OpenSSL_add_all_ciphers();
68 SSLeay_add_all_digests(); 66 OpenSSL_add_all_digests();
69 } 67}
70
71void SSLeay_add_all_ciphers(void)
72 {
73#ifndef NO_DES
74 EVP_add_cipher(EVP_des_cfb());
75 EVP_add_cipher(EVP_des_ede_cfb());
76 EVP_add_cipher(EVP_des_ede3_cfb());
77
78 EVP_add_cipher(EVP_des_ofb());
79 EVP_add_cipher(EVP_des_ede_ofb());
80 EVP_add_cipher(EVP_des_ede3_ofb());
81
82 EVP_add_cipher(EVP_desx_cbc());
83 EVP_add_cipher_alias(SN_desx_cbc,"DESX");
84 EVP_add_cipher_alias(SN_desx_cbc,"desx");
85
86 EVP_add_cipher(EVP_des_cbc());
87 EVP_add_cipher_alias(SN_des_cbc,"DES");
88 EVP_add_cipher_alias(SN_des_cbc,"des");
89 EVP_add_cipher(EVP_des_ede_cbc());
90 EVP_add_cipher(EVP_des_ede3_cbc());
91 EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
92 EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");
93
94 EVP_add_cipher(EVP_des_ecb());
95 EVP_add_cipher(EVP_des_ede());
96 EVP_add_cipher(EVP_des_ede3());
97#endif
98
99#ifndef NO_RC4
100 EVP_add_cipher(EVP_rc4());
101 EVP_add_cipher(EVP_rc4_40());
102#endif
103
104#ifndef NO_IDEA
105 EVP_add_cipher(EVP_idea_ecb());
106 EVP_add_cipher(EVP_idea_cfb());
107 EVP_add_cipher(EVP_idea_ofb());
108 EVP_add_cipher(EVP_idea_cbc());
109 EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
110 EVP_add_cipher_alias(SN_idea_cbc,"idea");
111#endif
112
113#ifndef NO_RC2
114 EVP_add_cipher(EVP_rc2_ecb());
115 EVP_add_cipher(EVP_rc2_cfb());
116 EVP_add_cipher(EVP_rc2_ofb());
117 EVP_add_cipher(EVP_rc2_cbc());
118 EVP_add_cipher(EVP_rc2_40_cbc());
119 EVP_add_cipher(EVP_rc2_64_cbc());
120 EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
121 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
122#endif
123
124#ifndef NO_BF
125 EVP_add_cipher(EVP_bf_ecb());
126 EVP_add_cipher(EVP_bf_cfb());
127 EVP_add_cipher(EVP_bf_ofb());
128 EVP_add_cipher(EVP_bf_cbc());
129 EVP_add_cipher_alias(SN_bf_cbc,"BF");
130 EVP_add_cipher_alias(SN_bf_cbc,"bf");
131 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
132#endif
133
134#ifndef NO_CAST
135 EVP_add_cipher(EVP_cast5_ecb());
136 EVP_add_cipher(EVP_cast5_cfb());
137 EVP_add_cipher(EVP_cast5_ofb());
138 EVP_add_cipher(EVP_cast5_cbc());
139 EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
140 EVP_add_cipher_alias(SN_cast5_cbc,"cast");
141 EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
142 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
143#endif
144
145#ifndef NO_RC5
146 EVP_add_cipher(EVP_rc5_32_12_16_ecb());
147 EVP_add_cipher(EVP_rc5_32_12_16_cfb());
148 EVP_add_cipher(EVP_rc5_32_12_16_ofb());
149 EVP_add_cipher(EVP_rc5_32_12_16_cbc());
150 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
151 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
152#endif
153 }
154
155
156void SSLeay_add_all_digests(void)
157 {
158#ifndef NO_MD2
159 EVP_add_digest(EVP_md2());
160#endif
161#ifndef NO_MD5
162 EVP_add_digest(EVP_md5());
163 EVP_add_digest_alias(SN_md5,"ssl2-md5");
164 EVP_add_digest_alias(SN_md5,"ssl3-md5");
165#endif
166#ifndef NO_SHA
167 EVP_add_digest(EVP_sha());
168#ifndef NO_DSA
169 EVP_add_digest(EVP_dss());
170#endif
171#endif
172#ifndef NO_SHA
173 EVP_add_digest(EVP_sha1());
174 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
175 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
176#ifndef NO_DSA
177 EVP_add_digest(EVP_dss1());
178 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
179 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
180 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
181#endif
182#endif
183#if !defined(NO_MDC2) && !defined(NO_DES)
184 EVP_add_digest(EVP_mdc2());
185#endif
186#ifndef NO_RIPEMD
187 EVP_add_digest(EVP_ripemd160());
188 EVP_add_digest_alias(SN_ripemd160,"ripemd");
189 EVP_add_digest_alias(SN_ripemd160,"rmd160");
190#endif
191 PKCS12_PBE_add();
192 PKCS5_PBE_add();
193 }
diff --git a/src/lib/libssl/src/crypto/evp/c_allc.c b/src/lib/libssl/src/crypto/evp/c_allc.c
new file mode 100644
index 0000000000..f24d3756c9
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/c_allc.c
@@ -0,0 +1,149 @@
1/* crypto/evp/c_allc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_ciphers(void)
66 {
67#ifndef NO_DES
68 EVP_add_cipher(EVP_des_cfb());
69 EVP_add_cipher(EVP_des_ede_cfb());
70 EVP_add_cipher(EVP_des_ede3_cfb());
71
72 EVP_add_cipher(EVP_des_ofb());
73 EVP_add_cipher(EVP_des_ede_ofb());
74 EVP_add_cipher(EVP_des_ede3_ofb());
75
76 EVP_add_cipher(EVP_desx_cbc());
77 EVP_add_cipher_alias(SN_desx_cbc,"DESX");
78 EVP_add_cipher_alias(SN_desx_cbc,"desx");
79
80 EVP_add_cipher(EVP_des_cbc());
81 EVP_add_cipher_alias(SN_des_cbc,"DES");
82 EVP_add_cipher_alias(SN_des_cbc,"des");
83 EVP_add_cipher(EVP_des_ede_cbc());
84 EVP_add_cipher(EVP_des_ede3_cbc());
85 EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
86 EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");
87
88 EVP_add_cipher(EVP_des_ecb());
89 EVP_add_cipher(EVP_des_ede());
90 EVP_add_cipher(EVP_des_ede3());
91#endif
92
93#ifndef NO_RC4
94 EVP_add_cipher(EVP_rc4());
95 EVP_add_cipher(EVP_rc4_40());
96#endif
97
98#ifndef NO_IDEA
99 EVP_add_cipher(EVP_idea_ecb());
100 EVP_add_cipher(EVP_idea_cfb());
101 EVP_add_cipher(EVP_idea_ofb());
102 EVP_add_cipher(EVP_idea_cbc());
103 EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
104 EVP_add_cipher_alias(SN_idea_cbc,"idea");
105#endif
106
107#ifndef NO_RC2
108 EVP_add_cipher(EVP_rc2_ecb());
109 EVP_add_cipher(EVP_rc2_cfb());
110 EVP_add_cipher(EVP_rc2_ofb());
111 EVP_add_cipher(EVP_rc2_cbc());
112 EVP_add_cipher(EVP_rc2_40_cbc());
113 EVP_add_cipher(EVP_rc2_64_cbc());
114 EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
115 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
116#endif
117
118#ifndef NO_BF
119 EVP_add_cipher(EVP_bf_ecb());
120 EVP_add_cipher(EVP_bf_cfb());
121 EVP_add_cipher(EVP_bf_ofb());
122 EVP_add_cipher(EVP_bf_cbc());
123 EVP_add_cipher_alias(SN_bf_cbc,"BF");
124 EVP_add_cipher_alias(SN_bf_cbc,"bf");
125 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
126#endif
127
128#ifndef NO_CAST
129 EVP_add_cipher(EVP_cast5_ecb());
130 EVP_add_cipher(EVP_cast5_cfb());
131 EVP_add_cipher(EVP_cast5_ofb());
132 EVP_add_cipher(EVP_cast5_cbc());
133 EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
134 EVP_add_cipher_alias(SN_cast5_cbc,"cast");
135 EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
136 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
137#endif
138
139#ifndef NO_RC5
140 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_ofb());
143 EVP_add_cipher(EVP_rc5_32_12_16_cbc());
144 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
145 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
146#endif
147 PKCS12_PBE_add();
148 PKCS5_PBE_add();
149 }
diff --git a/src/lib/libssl/src/crypto/evp/c_alld.c b/src/lib/libssl/src/crypto/evp/c_alld.c
new file mode 100644
index 0000000000..febe51a3ee
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/c_alld.c
@@ -0,0 +1,100 @@
1/* crypto/evp/c_alld.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_digests(void)
66 {
67#ifndef NO_MD2
68 EVP_add_digest(EVP_md2());
69#endif
70#ifndef NO_MD5
71 EVP_add_digest(EVP_md5());
72 EVP_add_digest_alias(SN_md5,"ssl2-md5");
73 EVP_add_digest_alias(SN_md5,"ssl3-md5");
74#endif
75#ifndef NO_SHA
76 EVP_add_digest(EVP_sha());
77#ifndef NO_DSA
78 EVP_add_digest(EVP_dss());
79#endif
80#endif
81#ifndef NO_SHA
82 EVP_add_digest(EVP_sha1());
83 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
84 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
85#ifndef NO_DSA
86 EVP_add_digest(EVP_dss1());
87 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
88 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
89 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
90#endif
91#endif
92#if !defined(NO_MDC2) && !defined(NO_DES)
93 EVP_add_digest(EVP_mdc2());
94#endif
95#ifndef NO_RIPEMD
96 EVP_add_digest(EVP_ripemd160());
97 EVP_add_digest_alias(SN_ripemd160,"ripemd");
98 EVP_add_digest_alias(SN_ripemd160,"rmd160");
99#endif
100 }
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_3d.c b/src/lib/libssl/src/crypto/evp/e_cbc_3d.c
index 02ccc6dc90..5d16b865c5 100644
--- a/src/lib/libssl/src/crypto/evp/e_cbc_3d.c
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_3d.c
@@ -115,8 +115,8 @@ static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
115 115
116 if (deskey != NULL) 116 if (deskey != NULL)
117 { 117 {
118 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 118 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
119 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 119 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
120 memcpy( (char *)ctx->c.des_ede.ks3, 120 memcpy( (char *)ctx->c.des_ede.ks3,
121 (char *)ctx->c.des_ede.ks1, 121 (char *)ctx->c.des_ede.ks1,
122 sizeof(ctx->c.des_ede.ks1)); 122 sizeof(ctx->c.des_ede.ks1));
@@ -134,9 +134,9 @@ static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
134 134
135 if (deskey != NULL) 135 if (deskey != NULL)
136 { 136 {
137 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 137 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
138 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 138 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
139 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 139 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
140 } 140 }
141 } 141 }
142 142
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_d.c b/src/lib/libssl/src/crypto/evp/e_cbc_d.c
index 9203f3f52d..5b4e5b8601 100644
--- a/src/lib/libssl/src/crypto/evp/e_cbc_d.c
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_d.c
@@ -93,7 +93,7 @@ static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
93 memcpy(&(ctx->oiv[0]),iv,8); 93 memcpy(&(ctx->oiv[0]),iv,8);
94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
95 if (deskey != NULL) 95 if (deskey != NULL)
96 des_set_key(deskey,ctx->c.des_ks); 96 des_set_key_unchecked(deskey,ctx->c.des_ks);
97 } 97 }
98 98
99static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 99static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_3d.c b/src/lib/libssl/src/crypto/evp/e_cfb_3d.c
index bd32b072e2..b364bd4e31 100644
--- a/src/lib/libssl/src/crypto/evp/e_cfb_3d.c
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_3d.c
@@ -116,8 +116,8 @@ static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
117 if (deskey != NULL) 117 if (deskey != NULL)
118 { 118 {
119 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 119 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
120 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 120 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
121 memcpy( (char *)ctx->c.des_ede.ks3, 121 memcpy( (char *)ctx->c.des_ede.ks3,
122 (char *)ctx->c.des_ede.ks1, 122 (char *)ctx->c.des_ede.ks1,
123 sizeof(ctx->c.des_ede.ks1)); 123 sizeof(ctx->c.des_ede.ks1));
@@ -136,9 +136,9 @@ static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
137 if (deskey != NULL) 137 if (deskey != NULL)
138 { 138 {
139 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 139 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
140 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 140 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
141 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 141 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
142 } 142 }
143 } 143 }
144 144
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_d.c b/src/lib/libssl/src/crypto/evp/e_cfb_d.c
index 6bdf20b646..9e1714bd15 100644
--- a/src/lib/libssl/src/crypto/evp/e_cfb_d.c
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_d.c
@@ -95,7 +95,7 @@ static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
95 memcpy(&(ctx->oiv[0]),iv,8); 95 memcpy(&(ctx->oiv[0]),iv,8);
96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
97 if (deskey != NULL) 97 if (deskey != NULL)
98 des_set_key(deskey,ctx->c.des_ks); 98 des_set_key_unchecked(deskey,ctx->c.des_ks);
99 } 99 }
100 100
101static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 101static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_3d.c b/src/lib/libssl/src/crypto/evp/e_ecb_3d.c
index 354a8b79a7..806e971d36 100644
--- a/src/lib/libssl/src/crypto/evp/e_ecb_3d.c
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_3d.c
@@ -110,8 +110,8 @@ static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
110 110
111 if (deskey != NULL) 111 if (deskey != NULL)
112 { 112 {
113 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 113 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
114 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 114 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
115 memcpy( (char *)ctx->c.des_ede.ks3, 115 memcpy( (char *)ctx->c.des_ede.ks3,
116 (char *)ctx->c.des_ede.ks1, 116 (char *)ctx->c.des_ede.ks1,
117 sizeof(ctx->c.des_ede.ks1)); 117 sizeof(ctx->c.des_ede.ks1));
@@ -125,9 +125,9 @@ static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
125 125
126 if (deskey != NULL) 126 if (deskey != NULL)
127 { 127 {
128 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 128 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
129 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 129 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
130 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 130 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
131 } 131 }
132 } 132 }
133 133
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_d.c b/src/lib/libssl/src/crypto/evp/e_ecb_d.c
index 5fb4e64b1c..c11bef55ef 100644
--- a/src/lib/libssl/src/crypto/evp/e_ecb_d.c
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_d.c
@@ -90,7 +90,7 @@ static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
90 des_cblock *deskey = (des_cblock *)key; 90 des_cblock *deskey = (des_cblock *)key;
91 91
92 if (deskey != NULL) 92 if (deskey != NULL)
93 des_set_key(deskey,ctx->c.des_ks); 93 des_set_key_unchecked(deskey,ctx->c.des_ks);
94 } 94 }
95 95
96static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 96static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_3d.c b/src/lib/libssl/src/crypto/evp/e_ofb_3d.c
index 5233567c0c..d1a33e2ecd 100644
--- a/src/lib/libssl/src/crypto/evp/e_ofb_3d.c
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_3d.c
@@ -116,8 +116,8 @@ static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
117 if (deskey != NULL) 117 if (deskey != NULL)
118 { 118 {
119 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 119 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
120 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 120 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
121 memcpy( (char *)ctx->c.des_ede.ks3, 121 memcpy( (char *)ctx->c.des_ede.ks3,
122 (char *)ctx->c.des_ede.ks1, 122 (char *)ctx->c.des_ede.ks1,
123 sizeof(ctx->c.des_ede.ks1)); 123 sizeof(ctx->c.des_ede.ks1));
@@ -136,9 +136,9 @@ static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
137 if (deskey != NULL) 137 if (deskey != NULL)
138 { 138 {
139 des_set_key(&deskey[0],ctx->c.des_ede.ks1); 139 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
140 des_set_key(&deskey[1],ctx->c.des_ede.ks2); 140 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
141 des_set_key(&deskey[2],ctx->c.des_ede.ks3); 141 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
142 } 142 }
143 } 143 }
144 144
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_d.c b/src/lib/libssl/src/crypto/evp/e_ofb_d.c
index 398b3a002e..d51ce230f4 100644
--- a/src/lib/libssl/src/crypto/evp/e_ofb_d.c
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_d.c
@@ -95,7 +95,7 @@ static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
95 memcpy(&(ctx->oiv[0]),iv,8); 95 memcpy(&(ctx->oiv[0]),iv,8);
96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 96 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
97 if (deskey != NULL) 97 if (deskey != NULL)
98 des_set_key(deskey,ctx->c.des_ks); 98 des_set_key_unchecked(deskey,ctx->c.des_ks);
99 } 99 }
100 100
101static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 101static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
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 3a6628a75c..7568fad4ff 100644
--- a/src/lib/libssl/src/crypto/evp/e_xcbc_d.c
+++ b/src/lib/libssl/src/crypto/evp/e_xcbc_d.c
@@ -94,7 +94,7 @@ static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 94 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
95 if (deskey != NULL) 95 if (deskey != NULL)
96 { 96 {
97 des_set_key(deskey,ctx->c.desx_cbc.ks); 97 des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks);
98 memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); 98 memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8);
99 memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); 99 memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8);
100 } 100 }
diff --git a/src/lib/libssl/src/crypto/evp/encode.c b/src/lib/libssl/src/crypto/evp/encode.c
index 0152624a76..14a4cb11f6 100644
--- a/src/lib/libssl/src/crypto/evp/encode.c
+++ b/src/lib/libssl/src/crypto/evp/encode.c
@@ -185,7 +185,7 @@ void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
185 *outl=ret; 185 *outl=ret;
186 } 186 }
187 187
188int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen) 188int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int dlen)
189 { 189 {
190 int i,ret=0; 190 int i,ret=0;
191 unsigned long l; 191 unsigned long l;
@@ -337,7 +337,7 @@ end:
337 return(rv); 337 return(rv);
338 } 338 }
339 339
340int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n) 340int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n)
341 { 341 {
342 int i,ret=0,a,b,c,d; 342 int i,ret=0,a,b,c,d;
343 unsigned long l; 343 unsigned long l;
diff --git a/src/lib/libssl/src/crypto/evp/evp.h b/src/lib/libssl/src/crypto/evp/evp.h
index 570fe27d39..54215b0905 100644
--- a/src/lib/libssl/src/crypto/evp/evp.h
+++ b/src/lib/libssl/src/crypto/evp/evp.h
@@ -149,7 +149,7 @@ extern "C" {
149 149
150/* Type needs to be a bit field 150/* Type needs to be a bit field
151 * Sub-type needs to be for variations on the method, as in, can it do 151 * Sub-type needs to be for variations on the method, as in, can it do
152 * arbitary encryption.... */ 152 * arbitrary encryption.... */
153typedef struct evp_pkey_st 153typedef struct evp_pkey_st
154 { 154 {
155 int type; 155 int type;
@@ -343,7 +343,7 @@ typedef struct evp_cipher_ctx_st
343 unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */ 343 unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */
344 int num; /* used by cfb/ofb mode */ 344 int num; /* used by cfb/ofb mode */
345 345
346 char *app_data; /* aplication stuff */ 346 char *app_data; /* application stuff */
347 union { 347 union {
348#ifndef NO_RC4 348#ifndef NO_RC4
349 struct 349 struct
@@ -421,9 +421,10 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
421#define EVP_MD_size(e) ((e)->md_size) 421#define EVP_MD_size(e) ((e)->md_size)
422#define EVP_MD_block_size(e) ((e)->block_size) 422#define EVP_MD_block_size(e) ((e)->block_size)
423 423
424#define EVP_MD_CTX_md(e) ((e)->digest)
424#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) 425#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
425#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) 426#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
426#define EVP_MD_CTX_type(e) ((e)->digest) 427#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
427 428
428#define EVP_CIPHER_nid(e) ((e)->nid) 429#define EVP_CIPHER_nid(e) ((e)->nid)
429#define EVP_CIPHER_block_size(e) ((e)->block_size) 430#define EVP_CIPHER_block_size(e) ((e)->block_size)
@@ -521,15 +522,14 @@ void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
521void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, 522void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,
522 int *outl,unsigned char *in,int inl); 523 int *outl,unsigned char *in,int inl);
523void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); 524void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
524int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int n); 525int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
525 526
526void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); 527void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
527int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, 528int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
528 unsigned char *in, int inl); 529 unsigned char *in, int inl);
529int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned 530int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
530 char *out, int *outl); 531 char *out, int *outl);
531int EVP_DecodeBlock(unsigned char *t, unsigned 532int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
532 char *f, int n);
533 533
534void ERR_load_EVP_strings(void ); 534void ERR_load_EVP_strings(void );
535 535
@@ -594,9 +594,12 @@ EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
594EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); 594EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
595EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); 595EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
596 596
597void SSLeay_add_all_algorithms(void); 597void OpenSSL_add_all_algorithms(void);
598void SSLeay_add_all_ciphers(void); 598void OpenSSL_add_all_ciphers(void);
599void SSLeay_add_all_digests(void); 599void OpenSSL_add_all_digests(void);
600#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
601#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
602#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
600 603
601int EVP_add_cipher(EVP_CIPHER *cipher); 604int EVP_add_cipher(EVP_CIPHER *cipher);
602int EVP_add_digest(EVP_MD *digest); 605int EVP_add_digest(EVP_MD *digest);
@@ -613,6 +616,18 @@ int EVP_PKEY_type(int type);
613int EVP_PKEY_bits(EVP_PKEY *pkey); 616int EVP_PKEY_bits(EVP_PKEY *pkey);
614int EVP_PKEY_size(EVP_PKEY *pkey); 617int EVP_PKEY_size(EVP_PKEY *pkey);
615int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); 618int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
619#ifndef NO_RSA
620int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key);
621RSA * EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
622#endif
623#ifndef NO_DSA
624int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key);
625DSA * EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
626#endif
627#ifndef NO_DH
628int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key);
629DH * EVP_PKEY_get1_DH(EVP_PKEY *pkey);
630#endif
616EVP_PKEY * EVP_PKEY_new(void); 631EVP_PKEY * EVP_PKEY_new(void);
617void EVP_PKEY_free(EVP_PKEY *pkey); 632void EVP_PKEY_free(EVP_PKEY *pkey);
618EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, 633EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp,
@@ -621,6 +636,8 @@ int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
621 636
622EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp, 637EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp,
623 long length); 638 long length);
639EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
640 long length);
624int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); 641int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
625 642
626int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from); 643int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from);
@@ -677,6 +694,9 @@ void EVP_PBE_cleanup(void);
677#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 694#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
678#define EVP_F_EVP_PKEY_DECRYPT 104 695#define EVP_F_EVP_PKEY_DECRYPT 104
679#define EVP_F_EVP_PKEY_ENCRYPT 105 696#define EVP_F_EVP_PKEY_ENCRYPT 105
697#define EVP_F_EVP_PKEY_GET1_DH 119
698#define EVP_F_EVP_PKEY_GET1_DSA 120
699#define EVP_F_EVP_PKEY_GET1_RSA 121
680#define EVP_F_EVP_PKEY_NEW 106 700#define EVP_F_EVP_PKEY_NEW 106
681#define EVP_F_EVP_SIGNFINAL 107 701#define EVP_F_EVP_SIGNFINAL 107
682#define EVP_F_EVP_VERIFYFINAL 108 702#define EVP_F_EVP_VERIFYFINAL 108
@@ -693,10 +713,13 @@ void EVP_PBE_cleanup(void);
693#define EVP_R_DIFFERENT_KEY_TYPES 101 713#define EVP_R_DIFFERENT_KEY_TYPES 101
694#define EVP_R_ENCODE_ERROR 115 714#define EVP_R_ENCODE_ERROR 115
695#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 715#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
716#define EVP_R_EXPECTING_AN_RSA_KEY 127
717#define EVP_R_EXPECTING_A_DH_KEY 128
718#define EVP_R_EXPECTING_A_DSA_KEY 129
696#define EVP_R_INPUT_NOT_INITIALIZED 111 719#define EVP_R_INPUT_NOT_INITIALIZED 111
697#define EVP_R_IV_TOO_LARGE 102 720#define EVP_R_IV_TOO_LARGE 102
698#define EVP_R_KEYGEN_FAILURE 120 721#define EVP_R_KEYGEN_FAILURE 120
699#define EVP_R_MISSING_PARMATERS 103 722#define EVP_R_MISSING_PARAMETERS 103
700#define EVP_R_NO_DSA_PARAMETERS 116 723#define EVP_R_NO_DSA_PARAMETERS 116
701#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 724#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
702#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 725#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
diff --git a/src/lib/libssl/src/crypto/evp/evp_err.c b/src/lib/libssl/src/crypto/evp/evp_err.c
index c61cc922e8..97953a0fc1 100644
--- a/src/lib/libssl/src/crypto/evp/evp_err.c
+++ b/src/lib/libssl/src/crypto/evp/evp_err.c
@@ -77,6 +77,9 @@ static ERR_STRING_DATA EVP_str_functs[]=
77{ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"}, 77{ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"},
78{ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"}, 78{ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"},
79{ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"}, 79{ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"},
80{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DH,0), "EVP_PKEY_get1_DH"},
81{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DSA,0), "EVP_PKEY_get1_DSA"},
82{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_RSA,0), "EVP_PKEY_get1_RSA"},
80{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"}, 83{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"},
81{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"}, 84{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"},
82{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"}, 85{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"},
@@ -96,10 +99,13 @@ static ERR_STRING_DATA EVP_str_reasons[]=
96{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"}, 99{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"},
97{EVP_R_ENCODE_ERROR ,"encode error"}, 100{EVP_R_ENCODE_ERROR ,"encode error"},
98{EVP_R_EVP_PBE_CIPHERINIT_ERROR ,"evp pbe cipherinit error"}, 101{EVP_R_EVP_PBE_CIPHERINIT_ERROR ,"evp pbe cipherinit error"},
102{EVP_R_EXPECTING_AN_RSA_KEY ,"expecting an rsa key"},
103{EVP_R_EXPECTING_A_DH_KEY ,"expecting a dh key"},
104{EVP_R_EXPECTING_A_DSA_KEY ,"expecting a dsa key"},
99{EVP_R_INPUT_NOT_INITIALIZED ,"input not initialized"}, 105{EVP_R_INPUT_NOT_INITIALIZED ,"input not initialized"},
100{EVP_R_IV_TOO_LARGE ,"iv too large"}, 106{EVP_R_IV_TOO_LARGE ,"iv too large"},
101{EVP_R_KEYGEN_FAILURE ,"keygen failure"}, 107{EVP_R_KEYGEN_FAILURE ,"keygen failure"},
102{EVP_R_MISSING_PARMATERS ,"missing parmaters"}, 108{EVP_R_MISSING_PARAMETERS ,"missing parameters"},
103{EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"}, 109{EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"},
104{EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"}, 110{EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"},
105{EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"}, 111{EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"},
diff --git a/src/lib/libssl/src/crypto/evp/evp_key.c b/src/lib/libssl/src/crypto/evp/evp_key.c
index 21eda418bc..667c21cca8 100644
--- a/src/lib/libssl/src/crypto/evp/evp_key.c
+++ b/src/lib/libssl/src/crypto/evp/evp_key.c
@@ -81,15 +81,18 @@ char *EVP_get_pw_prompt(void)
81 return(prompt_string); 81 return(prompt_string);
82 } 82 }
83 83
84#ifdef NO_DES 84/* For historical reasons, the standard function for reading passwords is
85int des_read_pw_string(char *buf,int len,const char *prompt,int verify); 85 * in the DES library -- if someone ever wants to disable DES,
86#endif 86 * this function will fail */
87
88int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) 87int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
89 { 88 {
89#ifndef NO_DES
90 if ((prompt == NULL) && (prompt_string[0] != '\0')) 90 if ((prompt == NULL) && (prompt_string[0] != '\0'))
91 prompt=prompt_string; 91 prompt=prompt_string;
92 return(des_read_pw_string(buf,len,prompt,verify)); 92 return(des_read_pw_string(buf,len,prompt,verify));
93#else
94 return -1;
95#endif
93 } 96 }
94 97
95int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt, 98int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt,
diff --git a/src/lib/libssl/src/crypto/evp/evp_lib.c b/src/lib/libssl/src/crypto/evp/evp_lib.c
index 3f9bf55828..a431945ef5 100644
--- a/src/lib/libssl/src/crypto/evp/evp_lib.c
+++ b/src/lib/libssl/src/crypto/evp/evp_lib.c
@@ -115,6 +115,7 @@ int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
115int EVP_CIPHER_type(const EVP_CIPHER *ctx) 115int EVP_CIPHER_type(const EVP_CIPHER *ctx)
116{ 116{
117 int nid; 117 int nid;
118 ASN1_OBJECT *otmp;
118 nid = EVP_CIPHER_nid(ctx); 119 nid = EVP_CIPHER_nid(ctx);
119 120
120 switch(nid) { 121 switch(nid) {
@@ -131,7 +132,10 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx)
131 return NID_rc4; 132 return NID_rc4;
132 133
133 default: 134 default:
134 135 /* Check it has an OID and it is valid */
136 otmp = OBJ_nid2obj(nid);
137 if(!otmp || !otmp->data) nid = NID_undef;
138 ASN1_OBJECT_free(otmp);
135 return nid; 139 return nid;
136 } 140 }
137} 141}
diff --git a/src/lib/libssl/src/crypto/evp/evp_pkey.c b/src/lib/libssl/src/crypto/evp/evp_pkey.c
index 421e452db1..d5e6f5880f 100644
--- a/src/lib/libssl/src/crypto/evp/evp_pkey.c
+++ b/src/lib/libssl/src/crypto/evp/evp_pkey.c
@@ -62,19 +62,22 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey);
66
65/* Extract a private key from a PKCS8 structure */ 67/* Extract a private key from a PKCS8 structure */
66 68
67EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) 69EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
68{ 70{
69 EVP_PKEY *pkey; 71 EVP_PKEY *pkey = NULL;
70#ifndef NO_RSA 72#ifndef NO_RSA
71 RSA *rsa; 73 RSA *rsa = NULL;
72#endif 74#endif
73#ifndef NO_DSA 75#ifndef NO_DSA
74 DSA *dsa; 76 DSA *dsa = NULL;
75 ASN1_INTEGER *dsapriv; 77 ASN1_INTEGER *privkey;
76 STACK *ndsa; 78 ASN1_TYPE *t1, *t2, *param = NULL;
77 BN_CTX *ctx; 79 STACK *ndsa = NULL;
80 BN_CTX *ctx = NULL;
78 int plen; 81 int plen;
79#endif 82#endif
80 X509_ALGOR *a; 83 X509_ALGOR *a;
@@ -82,21 +85,14 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
82 int pkeylen; 85 int pkeylen;
83 char obj_tmp[80]; 86 char obj_tmp[80];
84 87
85 switch (p8->broken) { 88 if(p8->pkey->type == V_ASN1_OCTET_STRING) {
86 case PKCS8_OK: 89 p8->broken = PKCS8_OK;
87 p = p8->pkey->value.octet_string->data; 90 p = p8->pkey->value.octet_string->data;
88 pkeylen = p8->pkey->value.octet_string->length; 91 pkeylen = p8->pkey->value.octet_string->length;
89 break; 92 } else {
90 93 p8->broken = PKCS8_NO_OCTET;
91 case PKCS8_NO_OCTET:
92 p = p8->pkey->value.sequence->data; 94 p = p8->pkey->value.sequence->data;
93 pkeylen = p8->pkey->value.sequence->length; 95 pkeylen = p8->pkey->value.sequence->length;
94 break;
95
96 default:
97 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE);
98 return NULL;
99 break;
100 } 96 }
101 if (!(pkey = EVP_PKEY_new())) { 97 if (!(pkey = EVP_PKEY_new())) {
102 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 98 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
@@ -121,65 +117,83 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
121 * be recalculated. 117 * be recalculated.
122 */ 118 */
123 119
124 /* Check for broken Netscape Database DSA PKCS#8, UGH! */ 120 /* Check for broken DSA PKCS#8, UGH! */
125 if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { 121 if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) {
126 if(!(ndsa = ASN1_seq_unpack(p, pkeylen, 122 if(!(ndsa = ASN1_seq_unpack(p, pkeylen,
127 (char *(*)())d2i_ASN1_INTEGER, 123 (char *(*)())d2i_ASN1_TYPE,
128 ASN1_STRING_free))) { 124 ASN1_TYPE_free))) {
129 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 125 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
130 return NULL; 126 goto dsaerr;
131 } 127 }
132 if(sk_num(ndsa) != 2 ) { 128 if(sk_num(ndsa) != 2 ) {
133 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 129 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
134 sk_pop_free(ndsa, ASN1_STRING_free); 130 goto dsaerr;
135 return NULL;
136 } 131 }
137 dsapriv = (ASN1_INTEGER *) sk_pop(ndsa); 132 /* Handle Two broken types:
138 sk_pop_free(ndsa, ASN1_STRING_free); 133 * SEQUENCE {parameters, priv_key}
139 } else if (!(dsapriv=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) { 134 * SEQUENCE {pub_key, priv_key}
135 */
136
137 t1 = (ASN1_TYPE *)sk_value(ndsa, 0);
138 t2 = (ASN1_TYPE *)sk_value(ndsa, 1);
139 if(t1->type == V_ASN1_SEQUENCE) {
140 p8->broken = PKCS8_EMBEDDED_PARAM;
141 param = t1;
142 } else if(a->parameter->type == V_ASN1_SEQUENCE) {
143 p8->broken = PKCS8_NS_DB;
144 param = a->parameter;
145 } else {
140 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 146 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
141 return NULL; 147 goto dsaerr;
142 } 148 }
143 /* Retrieve parameters */ 149
144 if (a->parameter->type != V_ASN1_SEQUENCE) { 150 if(t2->type != V_ASN1_INTEGER) {
145 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_NO_DSA_PARAMETERS); 151 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
146 return NULL; 152 goto dsaerr;
153 }
154 privkey = t2->value.integer;
155 } else if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) {
156 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
157 goto dsaerr;
147 } 158 }
148 p = a->parameter->value.sequence->data; 159 p = param->value.sequence->data;
149 plen = a->parameter->value.sequence->length; 160 plen = param->value.sequence->length;
150 if (!(dsa = d2i_DSAparams (NULL, &p, plen))) { 161 if (!(dsa = d2i_DSAparams (NULL, &p, plen))) {
151 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 162 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
152 return NULL; 163 goto dsaerr;
153 } 164 }
154 /* We have parameters now set private key */ 165 /* We have parameters now set private key */
155 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(dsapriv, NULL))) { 166 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
156 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR); 167 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR);
157 DSA_free (dsa); 168 goto dsaerr;
158 return NULL;
159 } 169 }
160 /* Calculate public key (ouch!) */ 170 /* Calculate public key (ouch!) */
161 if (!(dsa->pub_key = BN_new())) { 171 if (!(dsa->pub_key = BN_new())) {
162 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 172 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
163 DSA_free (dsa); 173 goto dsaerr;
164 return NULL;
165 } 174 }
166 if (!(ctx = BN_CTX_new())) { 175 if (!(ctx = BN_CTX_new())) {
167 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); 176 EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE);
168 DSA_free (dsa); 177 goto dsaerr;
169 return NULL;
170 } 178 }
171 179
172 if (!BN_mod_exp(dsa->pub_key, dsa->g, 180 if (!BN_mod_exp(dsa->pub_key, dsa->g,
173 dsa->priv_key, dsa->p, ctx)) { 181 dsa->priv_key, dsa->p, ctx)) {
174 182
175 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR); 183 EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR);
176 BN_CTX_free (ctx); 184 goto dsaerr;
177 DSA_free (dsa);
178 return NULL;
179 } 185 }
180 186
181 EVP_PKEY_assign_DSA (pkey, dsa); 187 EVP_PKEY_assign_DSA(pkey, dsa);
182 BN_CTX_free (ctx); 188 BN_CTX_free (ctx);
189 sk_pop_free(ndsa, ASN1_TYPE_free);
190 break;
191 dsaerr:
192 BN_CTX_free (ctx);
193 sk_pop_free(ndsa, ASN1_TYPE_free);
194 DSA_free(dsa);
195 EVP_PKEY_free(pkey);
196 return NULL;
183 break; 197 break;
184#endif 198#endif
185 default: 199 default:
@@ -193,30 +207,35 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
193 return pkey; 207 return pkey;
194} 208}
195 209
210PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
211{
212 return EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK);
213}
214
196/* Turn a private key into a PKCS8 structure */ 215/* Turn a private key into a PKCS8 structure */
197 216
198PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey) 217PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken)
199{ 218{
200 PKCS8_PRIV_KEY_INFO *p8; 219 PKCS8_PRIV_KEY_INFO *p8;
201#ifndef NO_DSA 220
202 ASN1_INTEGER *dpkey;
203 unsigned char *p, *q;
204 int len;
205#endif
206 if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) { 221 if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) {
207 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); 222 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
208 return NULL; 223 return NULL;
209 } 224 }
225 p8->broken = broken;
210 ASN1_INTEGER_set (p8->version, 0); 226 ASN1_INTEGER_set (p8->version, 0);
211 if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) { 227 if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) {
212 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); 228 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
213 PKCS8_PRIV_KEY_INFO_free (p8); 229 PKCS8_PRIV_KEY_INFO_free (p8);
214 return NULL; 230 return NULL;
215 } 231 }
232 p8->pkey->type = V_ASN1_OCTET_STRING;
216 switch (EVP_PKEY_type(pkey->type)) { 233 switch (EVP_PKEY_type(pkey->type)) {
217#ifndef NO_RSA 234#ifndef NO_RSA
218 case EVP_PKEY_RSA: 235 case EVP_PKEY_RSA:
219 236
237 if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE;
238
220 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption); 239 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption);
221 p8->pkeyalg->parameter->type = V_ASN1_NULL; 240 p8->pkeyalg->parameter->type = V_ASN1_NULL;
222 if (!ASN1_pack_string ((char *)pkey, i2d_PrivateKey, 241 if (!ASN1_pack_string ((char *)pkey, i2d_PrivateKey,
@@ -229,36 +248,11 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
229#endif 248#endif
230#ifndef NO_DSA 249#ifndef NO_DSA
231 case EVP_PKEY_DSA: 250 case EVP_PKEY_DSA:
232 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa); 251 if(!dsa_pkey2pkcs8(p8, pkey)) {
233
234 /* get paramaters and place in AlgorithmIdentifier */
235 len = i2d_DSAparams (pkey->pkey.dsa, NULL);
236 if (!(p = Malloc(len))) {
237 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
238 PKCS8_PRIV_KEY_INFO_free (p8); 252 PKCS8_PRIV_KEY_INFO_free (p8);
239 return NULL; 253 return NULL;
240 } 254 }
241 q = p; 255
242 i2d_DSAparams (pkey->pkey.dsa, &q);
243 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
244 p8->pkeyalg->parameter->value.sequence = ASN1_STRING_new();
245 ASN1_STRING_set(p8->pkeyalg->parameter->value.sequence, p, len);
246 Free(p);
247 /* Get private key into an integer and pack */
248 if (!(dpkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) {
249 EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
250 PKCS8_PRIV_KEY_INFO_free (p8);
251 return NULL;
252 }
253
254 if (!ASN1_pack_string((char *)dpkey, i2d_ASN1_INTEGER,
255 &p8->pkey->value.octet_string)) {
256 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
257 ASN1_INTEGER_free (dpkey);
258 PKCS8_PRIV_KEY_INFO_free (p8);
259 return NULL;
260 }
261 ASN1_INTEGER_free (dpkey);
262 break; 256 break;
263#endif 257#endif
264 default: 258 default:
@@ -266,9 +260,8 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
266 PKCS8_PRIV_KEY_INFO_free (p8); 260 PKCS8_PRIV_KEY_INFO_free (p8);
267 return NULL; 261 return NULL;
268 } 262 }
269 p8->pkey->type = V_ASN1_OCTET_STRING; 263 RAND_add(p8->pkey->value.octet_string->data,
270 RAND_seed (p8->pkey->value.octet_string->data, 264 p8->pkey->value.octet_string->length, 0);
271 p8->pkey->value.octet_string->length);
272 return p8; 265 return p8;
273} 266}
274 267
@@ -295,4 +288,112 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken)
295 } 288 }
296} 289}
297 290
291#ifndef NO_DSA
292static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey)
293{
294 ASN1_STRING *params;
295 ASN1_INTEGER *prkey;
296 ASN1_TYPE *ttmp;
297 STACK *ndsa;
298 unsigned char *p, *q;
299 int len;
300 p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa);
301 len = i2d_DSAparams (pkey->pkey.dsa, NULL);
302 if (!(p = Malloc(len))) {
303 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
304 PKCS8_PRIV_KEY_INFO_free (p8);
305 return 0;
306 }
307 q = p;
308 i2d_DSAparams (pkey->pkey.dsa, &q);
309 params = ASN1_STRING_new();
310 ASN1_STRING_set(params, p, len);
311 Free(p);
312 /* Get private key into integer */
313 if (!(prkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) {
314 EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
315 return 0;
316 }
317
318 switch(p8->broken) {
298 319
320 case PKCS8_OK:
321 case PKCS8_NO_OCTET:
322
323 if (!ASN1_pack_string((char *)prkey, i2d_ASN1_INTEGER,
324 &p8->pkey->value.octet_string)) {
325 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
326 M_ASN1_INTEGER_free (prkey);
327 return 0;
328 }
329
330 M_ASN1_INTEGER_free (prkey);
331 p8->pkeyalg->parameter->value.sequence = params;
332 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
333
334 break;
335
336 case PKCS8_NS_DB:
337
338 p8->pkeyalg->parameter->value.sequence = params;
339 p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE;
340 ndsa = sk_new_null();
341 ttmp = ASN1_TYPE_new();
342 if (!(ttmp->value.integer = BN_to_ASN1_INTEGER (pkey->pkey.dsa->pub_key, NULL))) {
343 EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR);
344 PKCS8_PRIV_KEY_INFO_free(p8);
345 return 0;
346 }
347 ttmp->type = V_ASN1_INTEGER;
348 sk_push(ndsa, (char *)ttmp);
349
350 ttmp = ASN1_TYPE_new();
351 ttmp->value.integer = prkey;
352 ttmp->type = V_ASN1_INTEGER;
353 sk_push(ndsa, (char *)ttmp);
354
355 p8->pkey->value.octet_string = ASN1_OCTET_STRING_new();
356
357 if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE,
358 &p8->pkey->value.octet_string->data,
359 &p8->pkey->value.octet_string->length)) {
360
361 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
362 sk_pop_free(ndsa, ASN1_TYPE_free);
363 M_ASN1_INTEGER_free(prkey);
364 return 0;
365 }
366 sk_pop_free(ndsa, ASN1_TYPE_free);
367 break;
368
369 case PKCS8_EMBEDDED_PARAM:
370
371 p8->pkeyalg->parameter->type = V_ASN1_NULL;
372 ndsa = sk_new_null();
373 ttmp = ASN1_TYPE_new();
374 ttmp->value.sequence = params;
375 ttmp->type = V_ASN1_SEQUENCE;
376 sk_push(ndsa, (char *)ttmp);
377
378 ttmp = ASN1_TYPE_new();
379 ttmp->value.integer = prkey;
380 ttmp->type = V_ASN1_INTEGER;
381 sk_push(ndsa, (char *)ttmp);
382
383 p8->pkey->value.octet_string = ASN1_OCTET_STRING_new();
384
385 if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE,
386 &p8->pkey->value.octet_string->data,
387 &p8->pkey->value.octet_string->length)) {
388
389 EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE);
390 sk_pop_free(ndsa, ASN1_TYPE_free);
391 M_ASN1_INTEGER_free (prkey);
392 return 0;
393 }
394 sk_pop_free(ndsa, ASN1_TYPE_free);
395 break;
396 }
397 return 1;
398}
399#endif
diff --git a/src/lib/libssl/src/crypto/evp/p_lib.c b/src/lib/libssl/src/crypto/evp/p_lib.c
index 3422b77de6..4cb387f8de 100644
--- a/src/lib/libssl/src/crypto/evp/p_lib.c
+++ b/src/lib/libssl/src/crypto/evp/p_lib.c
@@ -119,7 +119,7 @@ int EVP_PKEY_copy_parameters(EVP_PKEY *to, EVP_PKEY *from)
119 119
120 if (EVP_PKEY_missing_parameters(from)) 120 if (EVP_PKEY_missing_parameters(from))
121 { 121 {
122 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARMATERS); 122 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS);
123 goto err; 123 goto err;
124 } 124 }
125#ifndef NO_DSA 125#ifndef NO_DSA
@@ -202,8 +202,66 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)
202 pkey->type=EVP_PKEY_type(type); 202 pkey->type=EVP_PKEY_type(type);
203 pkey->save_type=type; 203 pkey->save_type=type;
204 pkey->pkey.ptr=key; 204 pkey->pkey.ptr=key;
205 return(1); 205 return(key != NULL);
206 }
207
208#ifndef NO_RSA
209int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
210{
211 int ret = EVP_PKEY_assign_RSA(pkey, key);
212 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_RSA);
213 return ret;
214}
215
216RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
217 {
218 if(pkey->type != EVP_PKEY_RSA) {
219 EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
220 return NULL;
221 }
222 CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_RSA);
223 return pkey->pkey.rsa;
224}
225#endif
226
227#ifndef NO_DSA
228int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
229{
230 int ret = EVP_PKEY_assign_DSA(pkey, key);
231 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DSA);
232 return ret;
233}
234
235DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
236 {
237 if(pkey->type != EVP_PKEY_DSA) {
238 EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY);
239 return NULL;
240 }
241 CRYPTO_add(&pkey->pkey.dsa->references, 1, CRYPTO_LOCK_DSA);
242 return pkey->pkey.dsa;
243}
244#endif
245
246#ifndef NO_DH
247
248int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
249{
250 int ret = EVP_PKEY_assign_DH(pkey, key);
251 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DH);
252 return ret;
253}
254
255DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
256 {
257 if(pkey->type != EVP_PKEY_DH) {
258 EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY);
259 return NULL;
206 } 260 }
261 CRYPTO_add(&pkey->pkey.dh->references, 1, CRYPTO_LOCK_DH);
262 return pkey->pkey.dh;
263}
264#endif
207 265
208int EVP_PKEY_type(int type) 266int EVP_PKEY_type(int type)
209 { 267 {
@@ -244,7 +302,7 @@ void EVP_PKEY_free(EVP_PKEY *x)
244 } 302 }
245#endif 303#endif
246 EVP_PKEY_free_it(x); 304 EVP_PKEY_free_it(x);
247 Free((char *)x); 305 Free(x);
248 } 306 }
249 307
250static void EVP_PKEY_free_it(EVP_PKEY *x) 308static void EVP_PKEY_free_it(EVP_PKEY *x)
diff --git a/src/lib/libssl/src/crypto/evp/p_open.c b/src/lib/libssl/src/crypto/evp/p_open.c
index ddb9fd6942..b9ca7892c2 100644
--- a/src/lib/libssl/src/crypto/evp/p_open.c
+++ b/src/lib/libssl/src/crypto/evp/p_open.c
@@ -110,4 +110,10 @@ int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
110 EVP_DecryptInit(ctx,NULL,NULL,NULL); 110 EVP_DecryptInit(ctx,NULL,NULL,NULL);
111 return(i); 111 return(i);
112 } 112 }
113#else /* !NO_RSA */
114
115# ifdef PEDANTIC
116static void *dummy=&dummy;
117# endif
118
113#endif 119#endif
diff --git a/src/lib/libssl/src/crypto/evp/p_seal.c b/src/lib/libssl/src/crypto/evp/p_seal.c
index 09b46f4b0e..d449e892bf 100644
--- a/src/lib/libssl/src/crypto/evp/p_seal.c
+++ b/src/lib/libssl/src/crypto/evp/p_seal.c
@@ -73,9 +73,10 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
73 int i; 73 int i;
74 74
75 if (npubk <= 0) return(0); 75 if (npubk <= 0) return(0);
76 RAND_bytes(key,EVP_MAX_KEY_LENGTH); 76 if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0)
77 return(0);
77 if (type->iv_len > 0) 78 if (type->iv_len > 0)
78 RAND_bytes(iv,type->iv_len); 79 RAND_pseudo_bytes(iv,type->iv_len);
79 80
80 EVP_CIPHER_CTX_init(ctx); 81 EVP_CIPHER_CTX_init(ctx);
81 EVP_EncryptInit(ctx,type,key,iv); 82 EVP_EncryptInit(ctx,type,key,iv);
diff --git a/src/lib/libssl/src/crypto/ex_data.c b/src/lib/libssl/src/crypto/ex_data.c
index 176574766b..a057dd3b68 100644
--- a/src/lib/libssl/src/crypto/ex_data.c
+++ b/src/lib/libssl/src/crypto/ex_data.c
@@ -63,15 +63,15 @@
63#include <openssl/lhash.h> 63#include <openssl/lhash.h>
64#include "cryptlib.h" 64#include "cryptlib.h"
65 65
66int CRYPTO_get_ex_new_index(int idx, STACK **skp, long argl, char *argp, 66int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
67 int (*new_func)(), int (*dup_func)(), void (*free_func)()) 67 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
68 { 68 {
69 int ret= -1; 69 int ret= -1;
70 CRYPTO_EX_DATA_FUNCS *a; 70 CRYPTO_EX_DATA_FUNCS *a;
71 71
72 MemCheck_off(); 72 MemCheck_off();
73 if (*skp == NULL) 73 if (*skp == NULL)
74 *skp=sk_new_null(); 74 *skp=sk_CRYPTO_EX_DATA_FUNCS_new_null();
75 if (*skp == NULL) 75 if (*skp == NULL)
76 { 76 {
77 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 77 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
@@ -88,23 +88,23 @@ int CRYPTO_get_ex_new_index(int idx, STACK **skp, long argl, char *argp,
88 a->new_func=new_func; 88 a->new_func=new_func;
89 a->dup_func=dup_func; 89 a->dup_func=dup_func;
90 a->free_func=free_func; 90 a->free_func=free_func;
91 while (sk_num(*skp) <= idx) 91 while (sk_CRYPTO_EX_DATA_FUNCS_num(*skp) <= idx)
92 { 92 {
93 if (!sk_push(*skp,NULL)) 93 if (!sk_CRYPTO_EX_DATA_FUNCS_push(*skp,NULL))
94 { 94 {
95 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 95 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
96 Free(a); 96 Free(a);
97 goto err; 97 goto err;
98 } 98 }
99 } 99 }
100 sk_set(*skp,idx, (char *)a); 100 sk_CRYPTO_EX_DATA_FUNCS_set(*skp,idx, a);
101 ret=idx; 101 ret=idx;
102err: 102err:
103 MemCheck_on(); 103 MemCheck_on();
104 return(idx); 104 return(idx);
105 } 105 }
106 106
107int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, char *val) 107int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
108 { 108 {
109 int i; 109 int i;
110 110
@@ -131,7 +131,7 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, char *val)
131 return(1); 131 return(1);
132 } 132 }
133 133
134char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx) 134void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx)
135 { 135 {
136 if (ad->sk == NULL) 136 if (ad->sk == NULL)
137 return(0); 137 return(0);
@@ -145,7 +145,7 @@ char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx)
145 * being duplicated, a pointer to the 145 * being duplicated, a pointer to the
146 * 'new' object to be inserted, the index, and the argi/argp 146 * 'new' object to be inserted, the index, and the argi/argp
147 */ 147 */
148int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to, 148int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to,
149 CRYPTO_EX_DATA *from) 149 CRYPTO_EX_DATA *from)
150 { 150 {
151 int i,j,m,r; 151 int i,j,m,r;
@@ -154,14 +154,14 @@ int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to,
154 154
155 if (meth == NULL) return(1); 155 if (meth == NULL) return(1);
156 if (from->sk == NULL) return(1); 156 if (from->sk == NULL) return(1);
157 m=sk_num(meth); 157 m=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
158 j=sk_num(from->sk); 158 j=sk_num(from->sk);
159 for (i=0; i<j; i++) 159 for (i=0; i<j; i++)
160 { 160 {
161 from_d=CRYPTO_get_ex_data(from,i); 161 from_d=CRYPTO_get_ex_data(from,i);
162 if (i < m) 162 if (i < m)
163 { 163 {
164 mm=(CRYPTO_EX_DATA_FUNCS *)sk_value(meth,i); 164 mm=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
165 if (mm->dup_func != NULL) 165 if (mm->dup_func != NULL)
166 r=mm->dup_func(to,from,(char **)&from_d,i, 166 r=mm->dup_func(to,from,(char **)&from_d,i,
167 mm->argl,mm->argp); 167 mm->argl,mm->argp);
@@ -172,18 +172,18 @@ int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to,
172 } 172 }
173 173
174/* Call each free callback */ 174/* Call each free callback */
175void CRYPTO_free_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad) 175void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad)
176 { 176 {
177 CRYPTO_EX_DATA_FUNCS *m; 177 CRYPTO_EX_DATA_FUNCS *m;
178 char *ptr; 178 void *ptr;
179 int i,max; 179 int i,max;
180 180
181 if (meth != NULL) 181 if (meth != NULL)
182 { 182 {
183 max=sk_num(meth); 183 max=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
184 for (i=0; i<max; i++) 184 for (i=0; i<max; i++)
185 { 185 {
186 m=(CRYPTO_EX_DATA_FUNCS *)sk_value(meth,i); 186 m=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
187 if ((m != NULL) && (m->free_func != NULL)) 187 if ((m != NULL) && (m->free_func != NULL))
188 { 188 {
189 ptr=CRYPTO_get_ex_data(ad,i); 189 ptr=CRYPTO_get_ex_data(ad,i);
@@ -198,19 +198,19 @@ void CRYPTO_free_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad)
198 } 198 }
199 } 199 }
200 200
201void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad) 201void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad)
202 { 202 {
203 CRYPTO_EX_DATA_FUNCS *m; 203 CRYPTO_EX_DATA_FUNCS *m;
204 char *ptr; 204 void *ptr;
205 int i,max; 205 int i,max;
206 206
207 ad->sk=NULL; 207 ad->sk=NULL;
208 if (meth != NULL) 208 if (meth != NULL)
209 { 209 {
210 max=sk_num(meth); 210 max=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
211 for (i=0; i<max; i++) 211 for (i=0; i<max; i++)
212 { 212 {
213 m=(CRYPTO_EX_DATA_FUNCS *)sk_value(meth,i); 213 m=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
214 if ((m != NULL) && (m->new_func != NULL)) 214 if ((m != NULL) && (m->new_func != NULL))
215 { 215 {
216 ptr=CRYPTO_get_ex_data(ad,i); 216 ptr=CRYPTO_get_ex_data(ad,i);
@@ -220,4 +220,4 @@ void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad)
220 } 220 }
221 } 221 }
222 222
223 223IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)
diff --git a/src/lib/libssl/src/crypto/hmac/hmac.c b/src/lib/libssl/src/crypto/hmac/hmac.c
index 5c349bbb56..23b7c98f8f 100644
--- a/src/lib/libssl/src/crypto/hmac/hmac.c
+++ b/src/lib/libssl/src/crypto/hmac/hmac.c
@@ -109,7 +109,7 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
109 memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx)); 109 memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx));
110 } 110 }
111 111
112void HMAC_Update(HMAC_CTX *ctx, unsigned char *data, int len) 112void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len)
113 { 113 {
114 EVP_DigestUpdate(&(ctx->md_ctx),data,len); 114 EVP_DigestUpdate(&(ctx->md_ctx),data,len);
115 } 115 }
@@ -134,7 +134,7 @@ void HMAC_cleanup(HMAC_CTX *ctx)
134 } 134 }
135 135
136unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 136unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
137 unsigned char *d, int n, unsigned char *md, 137 const unsigned char *d, int n, unsigned char *md,
138 unsigned int *md_len) 138 unsigned int *md_len)
139 { 139 {
140 HMAC_CTX c; 140 HMAC_CTX c;
diff --git a/src/lib/libssl/src/crypto/hmac/hmac.h b/src/lib/libssl/src/crypto/hmac/hmac.h
index f928975fcd..223eeda7f3 100644
--- a/src/lib/libssl/src/crypto/hmac/hmac.h
+++ b/src/lib/libssl/src/crypto/hmac/hmac.h
@@ -85,11 +85,11 @@ typedef struct hmac_ctx_st
85 85
86void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 86void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
87 const EVP_MD *md); 87 const EVP_MD *md);
88void HMAC_Update(HMAC_CTX *ctx,unsigned char *key, int len); 88void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
89void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 89void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
90void HMAC_cleanup(HMAC_CTX *ctx); 90void HMAC_cleanup(HMAC_CTX *ctx);
91unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 91unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
92 unsigned char *d, int n, unsigned char *md, 92 const unsigned char *d, int n, unsigned char *md,
93 unsigned int *md_len); 93 unsigned int *md_len);
94 94
95 95
diff --git a/src/lib/libssl/src/crypto/hmac/hmactest.c b/src/lib/libssl/src/crypto/hmac/hmactest.c
index 9a67dff36a..4b56b8ee13 100644
--- a/src/lib/libssl/src/crypto/hmac/hmactest.c
+++ b/src/lib/libssl/src/crypto/hmac/hmactest.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
73#include <openssl/ebcdic.h> 73#include <openssl/ebcdic.h>
74#endif 74#endif
75 75
76struct test_st 76static struct test_st
77 { 77 {
78 unsigned char key[16]; 78 unsigned char key[16];
79 int key_len; 79 int key_len;
diff --git a/src/lib/libssl/src/crypto/install.com b/src/lib/libssl/src/crypto/install.com
index b75d1b44b2..44cfc4e89a 100644
--- a/src/lib/libssl/src/crypto/install.com
+++ b/src/lib/libssl/src/crypto/install.com
@@ -90,6 +90,7 @@ $ COPY 'tmp' WRK_SSLINCLUDE: /LOG
90$ ELSE 90$ ELSE
91$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG 91$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG
92$ ENDIF 92$ ENDIF
93$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'tmp'
93$ GOTO LOOP_SDIRS 94$ GOTO LOOP_SDIRS
94$ LOOP_SDIRS_END: 95$ LOOP_SDIRS_END:
95$ 96$
diff --git a/src/lib/libssl/src/crypto/lhash/Makefile.ssl b/src/lib/libssl/src/crypto/lhash/Makefile.ssl
index d6845d6caa..eef4000460 100644
--- a/src/lib/libssl/src/crypto/lhash/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/lhash/Makefile.ssl
@@ -82,7 +82,8 @@ lh_stats.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82lh_stats.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82lh_stats.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 84lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
85lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 85lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
86lh_stats.o: ../cryptlib.h 86lh_stats.o: ../../include/openssl/stack.h ../cryptlib.h
87lhash.o: ../../include/openssl/crypto.h ../../include/openssl/lhash.h 87lhash.o: ../../include/openssl/crypto.h ../../include/openssl/lhash.h
88lhash.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 88lhash.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
89lhash.o: ../../include/openssl/stack.h
diff --git a/src/lib/libssl/src/crypto/lhash/lhash.c b/src/lib/libssl/src/crypto/lhash/lhash.c
index 801322beb6..6a340a2403 100644
--- a/src/lib/libssl/src/crypto/lhash/lhash.c
+++ b/src/lib/libssl/src/crypto/lhash/lhash.c
@@ -64,11 +64,11 @@
64 * 64 *
65 * 2.1 eay - Added an 'error in last operation' flag. eay 6-May-98 65 * 2.1 eay - Added an 'error in last operation' flag. eay 6-May-98
66 * 66 *
67 * 2.0 eay - Fixed a bug that occured when using lh_delete 67 * 2.0 eay - Fixed a bug that occurred when using lh_delete
68 * from inside lh_doall(). As entries were deleted, 68 * from inside lh_doall(). As entries were deleted,
69 * the 'table' was 'contract()ed', making some entries 69 * the 'table' was 'contract()ed', making some entries
70 * jump from the end of the table to the start, there by 70 * jump from the end of the table to the start, there by
71 * skiping the lh_doall() processing. eay - 4/12/95 71 * skipping the lh_doall() processing. eay - 4/12/95
72 * 72 *
73 * 1.9 eay - Fixed a memory leak in lh_free, the LHASH_NODEs 73 * 1.9 eay - Fixed a memory leak in lh_free, the LHASH_NODEs
74 * were not being free()ed. 21/11/95 74 * were not being free()ed. 21/11/95
@@ -107,12 +107,9 @@ const char *lh_version="lhash" OPENSSL_VERSION_PTEXT;
107#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ 107#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */
108#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ 108#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */
109 109
110
111#define P_CP char *
112#define P_CPP char *,char *
113static void expand(LHASH *lh); 110static void expand(LHASH *lh);
114static void contract(LHASH *lh); 111static void contract(LHASH *lh);
115static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash); 112static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash);
116 113
117LHASH *lh_new(unsigned long (*h)(), int (*c)()) 114LHASH *lh_new(unsigned long (*h)(), int (*c)())
118 { 115 {
@@ -152,7 +149,7 @@ LHASH *lh_new(unsigned long (*h)(), int (*c)())
152 ret->error=0; 149 ret->error=0;
153 return(ret); 150 return(ret);
154err1: 151err1:
155 Free((char *)ret); 152 Free(ret);
156err0: 153err0:
157 return(NULL); 154 return(NULL);
158 } 155 }
@@ -175,15 +172,15 @@ void lh_free(LHASH *lh)
175 n=nn; 172 n=nn;
176 } 173 }
177 } 174 }
178 Free((char *)lh->b); 175 Free(lh->b);
179 Free((char *)lh); 176 Free(lh);
180 } 177 }
181 178
182char *lh_insert(LHASH *lh, char *data) 179void *lh_insert(LHASH *lh, void *data)
183 { 180 {
184 unsigned long hash; 181 unsigned long hash;
185 LHASH_NODE *nn,**rn; 182 LHASH_NODE *nn,**rn;
186 char *ret; 183 void *ret;
187 184
188 lh->error=0; 185 lh->error=0;
189 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))
@@ -217,11 +214,11 @@ char *lh_insert(LHASH *lh, char *data)
217 return(ret); 214 return(ret);
218 } 215 }
219 216
220char *lh_delete(LHASH *lh, char *data) 217void *lh_delete(LHASH *lh, void *data)
221 { 218 {
222 unsigned long hash; 219 unsigned long hash;
223 LHASH_NODE *nn,**rn; 220 LHASH_NODE *nn,**rn;
224 char *ret; 221 void *ret;
225 222
226 lh->error=0; 223 lh->error=0;
227 rn=getrn(lh,data,&hash); 224 rn=getrn(lh,data,&hash);
@@ -236,7 +233,7 @@ char *lh_delete(LHASH *lh, char *data)
236 nn= *rn; 233 nn= *rn;
237 *rn=nn->next; 234 *rn=nn->next;
238 ret=nn->data; 235 ret=nn->data;
239 Free((char *)nn); 236 Free(nn);
240 lh->num_delete++; 237 lh->num_delete++;
241 } 238 }
242 239
@@ -248,11 +245,11 @@ char *lh_delete(LHASH *lh, char *data)
248 return(ret); 245 return(ret);
249 } 246 }
250 247
251char *lh_retrieve(LHASH *lh, char *data) 248void *lh_retrieve(LHASH *lh, void *data)
252 { 249 {
253 unsigned long hash; 250 unsigned long hash;
254 LHASH_NODE **rn; 251 LHASH_NODE **rn;
255 char *ret; 252 void *ret;
256 253
257 lh->error=0; 254 lh->error=0;
258 rn=getrn(lh,data,&hash); 255 rn=getrn(lh,data,&hash);
@@ -275,7 +272,7 @@ void lh_doall(LHASH *lh, void (*func)())
275 lh_doall_arg(lh,func,NULL); 272 lh_doall_arg(lh,func,NULL);
276 } 273 }
277 274
278void lh_doall_arg(LHASH *lh, void (*func)(), char *arg) 275void lh_doall_arg(LHASH *lh, void (*func)(), void *arg)
279 { 276 {
280 int i; 277 int i;
281 LHASH_NODE *a,*n; 278 LHASH_NODE *a,*n;
@@ -332,7 +329,7 @@ static void expand(LHASH *lh)
332 if ((lh->p) >= lh->pmax) 329 if ((lh->p) >= lh->pmax)
333 { 330 {
334 j=(int)lh->num_alloc_nodes*2; 331 j=(int)lh->num_alloc_nodes*2;
335 n=(LHASH_NODE **)Realloc((char *)lh->b, 332 n=(LHASH_NODE **)Realloc(lh->b,
336 (unsigned int)sizeof(LHASH_NODE *)*j); 333 (unsigned int)sizeof(LHASH_NODE *)*j);
337 if (n == NULL) 334 if (n == NULL)
338 { 335 {
@@ -360,7 +357,7 @@ static void contract(LHASH *lh)
360 lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */ 357 lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */
361 if (lh->p == 0) 358 if (lh->p == 0)
362 { 359 {
363 n=(LHASH_NODE **)Realloc((char *)lh->b, 360 n=(LHASH_NODE **)Realloc(lh->b,
364 (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax)); 361 (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax));
365 if (n == NULL) 362 if (n == NULL)
366 { 363 {
@@ -391,7 +388,7 @@ static void contract(LHASH *lh)
391 } 388 }
392 } 389 }
393 390
394static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash) 391static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash)
395 { 392 {
396 LHASH_NODE **ret,*n1; 393 LHASH_NODE **ret,*n1;
397 unsigned long hash,nn; 394 unsigned long hash,nn;
@@ -426,8 +423,7 @@ static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash)
426 } 423 }
427 424
428/* 425/*
429static unsigned long lh_strhash(str) 426unsigned long lh_strhash(char *str)
430char *str;
431 { 427 {
432 int i,l; 428 int i,l;
433 unsigned long ret=0; 429 unsigned long ret=0;
diff --git a/src/lib/libssl/src/crypto/lhash/lhash.h b/src/lib/libssl/src/crypto/lhash/lhash.h
index 6e5a1fe708..6f6eeb2698 100644
--- a/src/lib/libssl/src/crypto/lhash/lhash.h
+++ b/src/lib/libssl/src/crypto/lhash/lhash.h
@@ -73,7 +73,7 @@ extern "C" {
73 73
74typedef struct lhash_node_st 74typedef struct lhash_node_st
75 { 75 {
76 char *data; 76 void *data;
77 struct lhash_node_st *next; 77 struct lhash_node_st *next;
78#ifndef NO_HASH_COMP 78#ifndef NO_HASH_COMP
79 unsigned long hash; 79 unsigned long hash;
@@ -116,13 +116,13 @@ typedef struct lhash_st
116 * in lh_insert(). */ 116 * in lh_insert(). */
117#define lh_error(lh) ((lh)->error) 117#define lh_error(lh) ((lh)->error)
118 118
119LHASH *lh_new(unsigned long (*h)(), int (*c)()); 119LHASH *lh_new(unsigned long (*h)(/* void *a */), int (*c)(/* void *a,void *b */));
120void lh_free(LHASH *lh); 120void lh_free(LHASH *lh);
121char *lh_insert(LHASH *lh, char *data); 121void *lh_insert(LHASH *lh, void *data);
122char *lh_delete(LHASH *lh, char *data); 122void *lh_delete(LHASH *lh, void *data);
123char *lh_retrieve(LHASH *lh, char *data); 123void *lh_retrieve(LHASH *lh, void *data);
124void lh_doall(LHASH *lh, void (*func)(/* char *b */)); 124 void lh_doall(LHASH *lh, void (*func)(/*void *b*/));
125void lh_doall_arg(LHASH *lh, void (*func)(/*char *a,char *b*/),char *arg); 125void lh_doall_arg(LHASH *lh, void (*func)(/*void *a,void *b*/),void *arg);
126unsigned long lh_strhash(const char *c); 126unsigned long lh_strhash(const char *c);
127 127
128#ifndef NO_FP_API 128#ifndef NO_FP_API
diff --git a/src/lib/libssl/src/crypto/md2/Makefile.ssl b/src/lib/libssl/src/crypto/md2/Makefile.ssl
index 4274354b5f..eab615a5be 100644
--- a/src/lib/libssl/src/crypto/md2/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/md2/Makefile.ssl
@@ -84,5 +84,5 @@ md2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
84md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 84md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
85md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 85md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
86md2_one.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h 86md2_one.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
87md2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 87md2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
88md2_one.o: ../cryptlib.h 88md2_one.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/md2/md2.h b/src/lib/libssl/src/crypto/md2/md2.h
index 0d3592506c..582bffb859 100644
--- a/src/lib/libssl/src/crypto/md2/md2.h
+++ b/src/lib/libssl/src/crypto/md2/md2.h
@@ -81,9 +81,9 @@ typedef struct MD2state_st
81 81
82const char *MD2_options(void); 82const char *MD2_options(void);
83void MD2_Init(MD2_CTX *c); 83void MD2_Init(MD2_CTX *c);
84void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len); 84void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
85void MD2_Final(unsigned char *md, MD2_CTX *c); 85void MD2_Final(unsigned char *md, MD2_CTX *c);
86unsigned char *MD2(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}
89#endif 89#endif
diff --git a/src/lib/libssl/src/crypto/md2/md2_dgst.c b/src/lib/libssl/src/crypto/md2/md2_dgst.c
index c7d8d6aef5..608baefa8f 100644
--- a/src/lib/libssl/src/crypto/md2/md2_dgst.c
+++ b/src/lib/libssl/src/crypto/md2/md2_dgst.c
@@ -69,9 +69,9 @@ const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
69 69
70#define UCHAR unsigned char 70#define UCHAR unsigned char
71 71
72static void md2_block(MD2_CTX *c, unsigned char *d); 72static void md2_block(MD2_CTX *c, const unsigned char *d);
73/* The magic S table - I have converted it to hex since it is 73/* The magic S table - I have converted it to hex since it is
74 * basicaly just a random byte string. */ 74 * basically just a random byte string. */
75static MD2_INT S[256]={ 75static MD2_INT S[256]={
76 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 76 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01,
77 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 77 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
@@ -123,7 +123,7 @@ void MD2_Init(MD2_CTX *c)
123 memset(c->data,0,MD2_BLOCK); 123 memset(c->data,0,MD2_BLOCK);
124 } 124 }
125 125
126void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len) 126void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
127 { 127 {
128 register UCHAR *p; 128 register UCHAR *p;
129 129
@@ -161,7 +161,7 @@ void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len)
161 c->num=(int)len; 161 c->num=(int)len;
162 } 162 }
163 163
164static void md2_block(MD2_CTX *c, unsigned char *d) 164static void md2_block(MD2_CTX *c, const unsigned char *d)
165 { 165 {
166 register MD2_INT t,*sp1,*sp2; 166 register MD2_INT t,*sp1,*sp2;
167 register int i,j; 167 register int i,j;
diff --git a/src/lib/libssl/src/crypto/md2/md2_one.c b/src/lib/libssl/src/crypto/md2/md2_one.c
index 7157299d95..b12c37ce4d 100644
--- a/src/lib/libssl/src/crypto/md2/md2_one.c
+++ b/src/lib/libssl/src/crypto/md2/md2_one.c
@@ -63,7 +63,7 @@
63/* This is a separate file so that #defines in cryptlib.h can 63/* This is a separate file so that #defines in cryptlib.h can
64 * map my MD functions to different names */ 64 * map my MD functions to different names */
65 65
66unsigned char *MD2(unsigned char *d, unsigned long n, unsigned char *md) 66unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
67 { 67 {
68 MD2_CTX c; 68 MD2_CTX c;
69 static unsigned char m[MD2_DIGEST_LENGTH]; 69 static unsigned char m[MD2_DIGEST_LENGTH];
diff --git a/src/lib/libssl/src/crypto/md2/md2test.c b/src/lib/libssl/src/crypto/md2/md2test.c
index 461d124957..e3f4fb4c34 100644
--- a/src/lib/libssl/src/crypto/md2/md2test.c
+++ b/src/lib/libssl/src/crypto/md2/md2test.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
73#include <openssl/ebcdic.h> 73#include <openssl/ebcdic.h>
74#endif 74#endif
75 75
76char *test[]={ 76static char *test[]={
77 "", 77 "",
78 "a", 78 "a",
79 "abc", 79 "abc",
@@ -84,7 +84,7 @@ char *test[]={
84 NULL, 84 NULL,
85 }; 85 };
86 86
87char *ret[]={ 87static char *ret[]={
88 "8350e5a3e24c153df2275c9f80692773", 88 "8350e5a3e24c153df2275c9f80692773",
89 "32ec01ec4a6dac72c0ab96fb34c0b5d1", 89 "32ec01ec4a6dac72c0ab96fb34c0b5d1",
90 "da853b0d3f88d99b30283a69e6ded6bb", 90 "da853b0d3f88d99b30283a69e6ded6bb",
diff --git a/src/lib/libssl/src/crypto/md32_common.h b/src/lib/libssl/src/crypto/md32_common.h
index 2b91f9eef2..1a404a458d 100644
--- a/src/lib/libssl/src/crypto/md32_common.h
+++ b/src/lib/libssl/src/crypto/md32_common.h
@@ -94,6 +94,8 @@
94 * in original (data) byte order, implemented externally (it 94 * in original (data) byte order, implemented externally (it
95 * actually is optional if data and host are of the same 95 * actually is optional if data and host are of the same
96 * "endianess"). 96 * "endianess").
97 * HASH_MAKE_STRING
98 * macro convering context variables to an ASCII hash string.
97 * 99 *
98 * Optional macros: 100 * Optional macros:
99 * 101 *
@@ -178,8 +180,17 @@
178#undef ROTATE 180#undef ROTATE
179#ifndef PEDANTIC 181#ifndef PEDANTIC
180# if defined(_MSC_VER) 182# if defined(_MSC_VER)
181# define ROTATE(a,n) _lrotl(a,n) 183# define ROTATE(a,n) _lrotl(a,n)
182# elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) 184# elif defined(__MWERKS__)
185# if defined(__POWERPC__)
186# define ROTATE(a,n) __rlwinm(a,n,0,31)
187# elif defined(__MC68K__)
188 /* Motorola specific tweak. <appro@fy.chalmers.se> */
189# define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
190# else
191# define ROTATE(a,n) __rol(a,n)
192# endif
193# elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM)
183 /* 194 /*
184 * Some GNU C inline assembler templates. Note that these are 195 * Some GNU C inline assembler templates. Note that these are
185 * rotates by *constant* number of bits! But that's exactly 196 * rotates by *constant* number of bits! But that's exactly
@@ -189,16 +200,16 @@
189 */ 200 */
190# if defined(__i386) 201# if defined(__i386)
191# define ROTATE(a,n) ({ register unsigned int ret; \ 202# define ROTATE(a,n) ({ register unsigned int ret; \
192 asm volatile ( \ 203 asm ( \
193 "roll %1,%0" \ 204 "roll %1,%0" \
194 : "=r"(ret) \ 205 : "=r"(ret) \
195 : "I"(n), "0"(a) \ 206 : "I"(n), "0"(a) \
196 : "cc"); \ 207 : "cc"); \
197 ret; \ 208 ret; \
198 }) 209 })
199# elif defined(__powerpc) 210# elif defined(__powerpc) || defined(__ppc)
200# define ROTATE(a,n) ({ register unsigned int ret; \ 211# define ROTATE(a,n) ({ register unsigned int ret; \
201 asm volatile ( \ 212 asm ( \
202 "rlwinm %0,%1,%2,0,31" \ 213 "rlwinm %0,%1,%2,0,31" \
203 : "=r"(ret) \ 214 : "=r"(ret) \
204 : "r"(a), "I"(n)); \ 215 : "r"(a), "I"(n)); \
@@ -211,18 +222,18 @@
211 * Engage compiler specific "fetch in reverse byte order" 222 * Engage compiler specific "fetch in reverse byte order"
212 * intrinsic function if available. 223 * intrinsic function if available.
213 */ 224 */
214# if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) 225# if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM)
215 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */ 226 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */
216# if defined(__i386) && !defined(I386_ONLY) 227# if defined(__i386) && !defined(I386_ONLY)
217# define BE_FETCH32(a) ({ register unsigned int l=(a);\ 228# define BE_FETCH32(a) ({ register unsigned int l=(a);\
218 asm volatile ( \ 229 asm ( \
219 "bswapl %0" \ 230 "bswapl %0" \
220 : "=r"(l) : "0"(l)); \ 231 : "=r"(l) : "0"(l)); \
221 l; \ 232 l; \
222 }) 233 })
223# elif defined(__powerpc) 234# elif defined(__powerpc)
224# define LE_FETCH32(a) ({ register unsigned int l; \ 235# define LE_FETCH32(a) ({ register unsigned int l; \
225 asm volatile ( \ 236 asm ( \
226 "lwbrx %0,0,%1" \ 237 "lwbrx %0,0,%1" \
227 : "=r"(l) \ 238 : "=r"(l) \
228 : "r"(a)); \ 239 : "r"(a)); \
@@ -231,7 +242,7 @@
231 242
232# elif defined(__sparc) && defined(ULTRASPARC) 243# elif defined(__sparc) && defined(ULTRASPARC)
233# define LE_FETCH32(a) ({ register unsigned int l; \ 244# define LE_FETCH32(a) ({ register unsigned int l; \
234 asm volatile ( \ 245 asm ( \
235 "lda [%1]#ASI_PRIMARY_LITTLE,%0"\ 246 "lda [%1]#ASI_PRIMARY_LITTLE,%0"\
236 : "=r"(l) \ 247 : "=r"(l) \
237 : "r"(a)); \ 248 : "r"(a)); \
@@ -399,8 +410,9 @@
399 * Time for some action:-) 410 * Time for some action:-)
400 */ 411 */
401 412
402void HASH_UPDATE (HASH_CTX *c, const unsigned char *data, unsigned long len) 413void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
403 { 414 {
415 const unsigned char *data=data_;
404 register HASH_LONG * p; 416 register HASH_LONG * p;
405 register unsigned long l; 417 register unsigned long l;
406 int sw,sc,ew,ec; 418 int sw,sc,ew,ec;
@@ -581,10 +593,11 @@ void HASH_FINAL (unsigned char *md, HASH_CTX *c)
581#endif 593#endif
582 HASH_BLOCK_HOST_ORDER (c,p,1); 594 HASH_BLOCK_HOST_ORDER (c,p,1);
583 595
584 l=c->A; HOST_l2c(l,md); 596#ifndef HASH_MAKE_STRING
585 l=c->B; HOST_l2c(l,md); 597#error "HASH_MAKE_STRING must be defined!"
586 l=c->C; HOST_l2c(l,md); 598#else
587 l=c->D; HOST_l2c(l,md); 599 HASH_MAKE_STRING(c,md);
600#endif
588 601
589 c->num=0; 602 c->num=0;
590 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack 603 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack
diff --git a/src/lib/libssl/src/crypto/md5/Makefile.ssl b/src/lib/libssl/src/crypto/md5/Makefile.ssl
index cc73fba2ba..d50f967be7 100644
--- a/src/lib/libssl/src/crypto/md5/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/md5/Makefile.ssl
@@ -19,6 +19,13 @@ AR= ar r
19MD5_ASM_OBJ= 19MD5_ASM_OBJ=
20 20
21CFLAGS= $(INCLUDES) $(CFLAG) 21CFLAGS= $(INCLUDES) $(CFLAG)
22
23# We let the C compiler driver to take care of .s files. This is done in
24# order to be excused from maintaining a separate set of architecture
25# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
26# gcc, then the driver will automatically translate it to -xarch=v8plus
27# and pass it down to assembler.
28AS=$(CC) -c
22ASFLAGS=$(CFLAGS) 29ASFLAGS=$(CFLAGS)
23 30
24GENERAL=Makefile 31GENERAL=Makefile
@@ -77,7 +84,7 @@ asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
77# if they didn't bother to upgrade GNU assembler. Such users should 84# if they didn't bother to upgrade GNU assembler. Such users should
78# not choose this option, but be adviced to *remove* GNU assembler 85# not choose this option, but be adviced to *remove* GNU assembler
79# or upgrade it. 86# or upgrade it.
80sm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S 87asm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
81 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \ 88 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
82 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o 89 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
83 90
diff --git a/src/lib/libssl/src/crypto/md5/md5.h b/src/lib/libssl/src/crypto/md5/md5.h
index bdab6d45e8..d10bc8397f 100644
--- a/src/lib/libssl/src/crypto/md5/md5.h
+++ b/src/lib/libssl/src/crypto/md5/md5.h
@@ -103,9 +103,9 @@ typedef struct MD5state_st
103 } MD5_CTX; 103 } MD5_CTX;
104 104
105void MD5_Init(MD5_CTX *c); 105void MD5_Init(MD5_CTX *c);
106void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len); 106void MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
107void MD5_Final(unsigned char *md, MD5_CTX *c); 107void MD5_Final(unsigned char *md, MD5_CTX *c);
108unsigned char *MD5(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
111} 111}
diff --git a/src/lib/libssl/src/crypto/md5/md5_dgst.c b/src/lib/libssl/src/crypto/md5/md5_dgst.c
index ba0115ae79..23d196b8d4 100644
--- a/src/lib/libssl/src/crypto/md5/md5_dgst.c
+++ b/src/lib/libssl/src/crypto/md5/md5_dgst.c
@@ -60,7 +60,7 @@
60#include "md5_locl.h" 60#include "md5_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63char *MD5_version="MD5" OPENSSL_VERSION_PTEXT; 63const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
64 64
65/* Implemented from RFC1321 The MD5 Message-Digest Algorithm 65/* Implemented from RFC1321 The MD5 Message-Digest Algorithm
66 */ 66 */
@@ -186,6 +186,9 @@ void md5_block_host_order (MD5_CTX *c, const void *data, int num)
186#endif 186#endif
187 187
188#ifndef md5_block_data_order 188#ifndef md5_block_data_order
189#ifdef X
190#undef X
191#endif
189void md5_block_data_order (MD5_CTX *c, const void *data_, int num) 192void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
190 { 193 {
191 const unsigned char *data=data_; 194 const unsigned char *data=data_;
@@ -204,16 +207,15 @@ void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
204 * 207 *
205 * <appro@fy.chalmers.se> 208 * <appro@fy.chalmers.se>
206 */ 209 */
207 MD5_LONG X[MD5_LBLOCK]; 210#ifndef MD32_XARRAY
208 /* 211 /* See comment in crypto/sha/sha_locl.h for details. */
209 * In case you wonder why don't I use c->data for this. 212 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
210 * RISCs usually have a handful of registers and if X is 213 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
211 * declared as automatic array good optimizing compiler 214# define X(i) XX##i
212 * shall accomodate at least part of it in register bank 215#else
213 * instead of memory. 216 MD5_LONG XX[MD5_LBLOCK];
214 * 217# define X(i) XX[i]
215 * <appro@fy.chalmers.se> 218#endif
216 */
217 219
218 A=c->A; 220 A=c->A;
219 B=c->B; 221 B=c->B;
@@ -222,75 +224,75 @@ void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
222 224
223 for (;num--;) 225 for (;num--;)
224 { 226 {
225 HOST_c2l(data,l); X[ 0]=l; HOST_c2l(data,l); X[ 1]=l; 227 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
226 /* Round 0 */ 228 /* Round 0 */
227 R0(A,B,C,D,X[ 0], 7,0xd76aa478L); HOST_c2l(data,l); X[ 2]=l; 229 R0(A,B,C,D,X( 0), 7,0xd76aa478L); HOST_c2l(data,l); X( 2)=l;
228 R0(D,A,B,C,X[ 1],12,0xe8c7b756L); HOST_c2l(data,l); X[ 3]=l; 230 R0(D,A,B,C,X( 1),12,0xe8c7b756L); HOST_c2l(data,l); X( 3)=l;
229 R0(C,D,A,B,X[ 2],17,0x242070dbL); HOST_c2l(data,l); X[ 4]=l; 231 R0(C,D,A,B,X( 2),17,0x242070dbL); HOST_c2l(data,l); X( 4)=l;
230 R0(B,C,D,A,X[ 3],22,0xc1bdceeeL); HOST_c2l(data,l); X[ 5]=l; 232 R0(B,C,D,A,X( 3),22,0xc1bdceeeL); HOST_c2l(data,l); X( 5)=l;
231 R0(A,B,C,D,X[ 4], 7,0xf57c0fafL); HOST_c2l(data,l); X[ 6]=l; 233 R0(A,B,C,D,X( 4), 7,0xf57c0fafL); HOST_c2l(data,l); X( 6)=l;
232 R0(D,A,B,C,X[ 5],12,0x4787c62aL); HOST_c2l(data,l); X[ 7]=l; 234 R0(D,A,B,C,X( 5),12,0x4787c62aL); HOST_c2l(data,l); X( 7)=l;
233 R0(C,D,A,B,X[ 6],17,0xa8304613L); HOST_c2l(data,l); X[ 8]=l; 235 R0(C,D,A,B,X( 6),17,0xa8304613L); HOST_c2l(data,l); X( 8)=l;
234 R0(B,C,D,A,X[ 7],22,0xfd469501L); HOST_c2l(data,l); X[ 9]=l; 236 R0(B,C,D,A,X( 7),22,0xfd469501L); HOST_c2l(data,l); X( 9)=l;
235 R0(A,B,C,D,X[ 8], 7,0x698098d8L); HOST_c2l(data,l); X[10]=l; 237 R0(A,B,C,D,X( 8), 7,0x698098d8L); HOST_c2l(data,l); X(10)=l;
236 R0(D,A,B,C,X[ 9],12,0x8b44f7afL); HOST_c2l(data,l); X[11]=l; 238 R0(D,A,B,C,X( 9),12,0x8b44f7afL); HOST_c2l(data,l); X(11)=l;
237 R0(C,D,A,B,X[10],17,0xffff5bb1L); HOST_c2l(data,l); X[12]=l; 239 R0(C,D,A,B,X(10),17,0xffff5bb1L); HOST_c2l(data,l); X(12)=l;
238 R0(B,C,D,A,X[11],22,0x895cd7beL); HOST_c2l(data,l); X[13]=l; 240 R0(B,C,D,A,X(11),22,0x895cd7beL); HOST_c2l(data,l); X(13)=l;
239 R0(A,B,C,D,X[12], 7,0x6b901122L); HOST_c2l(data,l); X[14]=l; 241 R0(A,B,C,D,X(12), 7,0x6b901122L); HOST_c2l(data,l); X(14)=l;
240 R0(D,A,B,C,X[13],12,0xfd987193L); HOST_c2l(data,l); X[15]=l; 242 R0(D,A,B,C,X(13),12,0xfd987193L); HOST_c2l(data,l); X(15)=l;
241 R0(C,D,A,B,X[14],17,0xa679438eL); 243 R0(C,D,A,B,X(14),17,0xa679438eL);
242 R0(B,C,D,A,X[15],22,0x49b40821L); 244 R0(B,C,D,A,X(15),22,0x49b40821L);
243 /* Round 1 */ 245 /* Round 1 */
244 R1(A,B,C,D,X[ 1], 5,0xf61e2562L); 246 R1(A,B,C,D,X( 1), 5,0xf61e2562L);
245 R1(D,A,B,C,X[ 6], 9,0xc040b340L); 247 R1(D,A,B,C,X( 6), 9,0xc040b340L);
246 R1(C,D,A,B,X[11],14,0x265e5a51L); 248 R1(C,D,A,B,X(11),14,0x265e5a51L);
247 R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL); 249 R1(B,C,D,A,X( 0),20,0xe9b6c7aaL);
248 R1(A,B,C,D,X[ 5], 5,0xd62f105dL); 250 R1(A,B,C,D,X( 5), 5,0xd62f105dL);
249 R1(D,A,B,C,X[10], 9,0x02441453L); 251 R1(D,A,B,C,X(10), 9,0x02441453L);
250 R1(C,D,A,B,X[15],14,0xd8a1e681L); 252 R1(C,D,A,B,X(15),14,0xd8a1e681L);
251 R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L); 253 R1(B,C,D,A,X( 4),20,0xe7d3fbc8L);
252 R1(A,B,C,D,X[ 9], 5,0x21e1cde6L); 254 R1(A,B,C,D,X( 9), 5,0x21e1cde6L);
253 R1(D,A,B,C,X[14], 9,0xc33707d6L); 255 R1(D,A,B,C,X(14), 9,0xc33707d6L);
254 R1(C,D,A,B,X[ 3],14,0xf4d50d87L); 256 R1(C,D,A,B,X( 3),14,0xf4d50d87L);
255 R1(B,C,D,A,X[ 8],20,0x455a14edL); 257 R1(B,C,D,A,X( 8),20,0x455a14edL);
256 R1(A,B,C,D,X[13], 5,0xa9e3e905L); 258 R1(A,B,C,D,X(13), 5,0xa9e3e905L);
257 R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L); 259 R1(D,A,B,C,X( 2), 9,0xfcefa3f8L);
258 R1(C,D,A,B,X[ 7],14,0x676f02d9L); 260 R1(C,D,A,B,X( 7),14,0x676f02d9L);
259 R1(B,C,D,A,X[12],20,0x8d2a4c8aL); 261 R1(B,C,D,A,X(12),20,0x8d2a4c8aL);
260 /* Round 2 */ 262 /* Round 2 */
261 R2(A,B,C,D,X[ 5], 4,0xfffa3942L); 263 R2(A,B,C,D,X( 5), 4,0xfffa3942L);
262 R2(D,A,B,C,X[ 8],11,0x8771f681L); 264 R2(D,A,B,C,X( 8),11,0x8771f681L);
263 R2(C,D,A,B,X[11],16,0x6d9d6122L); 265 R2(C,D,A,B,X(11),16,0x6d9d6122L);
264 R2(B,C,D,A,X[14],23,0xfde5380cL); 266 R2(B,C,D,A,X(14),23,0xfde5380cL);
265 R2(A,B,C,D,X[ 1], 4,0xa4beea44L); 267 R2(A,B,C,D,X( 1), 4,0xa4beea44L);
266 R2(D,A,B,C,X[ 4],11,0x4bdecfa9L); 268 R2(D,A,B,C,X( 4),11,0x4bdecfa9L);
267 R2(C,D,A,B,X[ 7],16,0xf6bb4b60L); 269 R2(C,D,A,B,X( 7),16,0xf6bb4b60L);
268 R2(B,C,D,A,X[10],23,0xbebfbc70L); 270 R2(B,C,D,A,X(10),23,0xbebfbc70L);
269 R2(A,B,C,D,X[13], 4,0x289b7ec6L); 271 R2(A,B,C,D,X(13), 4,0x289b7ec6L);
270 R2(D,A,B,C,X[ 0],11,0xeaa127faL); 272 R2(D,A,B,C,X( 0),11,0xeaa127faL);
271 R2(C,D,A,B,X[ 3],16,0xd4ef3085L); 273 R2(C,D,A,B,X( 3),16,0xd4ef3085L);
272 R2(B,C,D,A,X[ 6],23,0x04881d05L); 274 R2(B,C,D,A,X( 6),23,0x04881d05L);
273 R2(A,B,C,D,X[ 9], 4,0xd9d4d039L); 275 R2(A,B,C,D,X( 9), 4,0xd9d4d039L);
274 R2(D,A,B,C,X[12],11,0xe6db99e5L); 276 R2(D,A,B,C,X(12),11,0xe6db99e5L);
275 R2(C,D,A,B,X[15],16,0x1fa27cf8L); 277 R2(C,D,A,B,X(15),16,0x1fa27cf8L);
276 R2(B,C,D,A,X[ 2],23,0xc4ac5665L); 278 R2(B,C,D,A,X( 2),23,0xc4ac5665L);
277 /* Round 3 */ 279 /* Round 3 */
278 R3(A,B,C,D,X[ 0], 6,0xf4292244L); 280 R3(A,B,C,D,X( 0), 6,0xf4292244L);
279 R3(D,A,B,C,X[ 7],10,0x432aff97L); 281 R3(D,A,B,C,X( 7),10,0x432aff97L);
280 R3(C,D,A,B,X[14],15,0xab9423a7L); 282 R3(C,D,A,B,X(14),15,0xab9423a7L);
281 R3(B,C,D,A,X[ 5],21,0xfc93a039L); 283 R3(B,C,D,A,X( 5),21,0xfc93a039L);
282 R3(A,B,C,D,X[12], 6,0x655b59c3L); 284 R3(A,B,C,D,X(12), 6,0x655b59c3L);
283 R3(D,A,B,C,X[ 3],10,0x8f0ccc92L); 285 R3(D,A,B,C,X( 3),10,0x8f0ccc92L);
284 R3(C,D,A,B,X[10],15,0xffeff47dL); 286 R3(C,D,A,B,X(10),15,0xffeff47dL);
285 R3(B,C,D,A,X[ 1],21,0x85845dd1L); 287 R3(B,C,D,A,X( 1),21,0x85845dd1L);
286 R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL); 288 R3(A,B,C,D,X( 8), 6,0x6fa87e4fL);
287 R3(D,A,B,C,X[15],10,0xfe2ce6e0L); 289 R3(D,A,B,C,X(15),10,0xfe2ce6e0L);
288 R3(C,D,A,B,X[ 6],15,0xa3014314L); 290 R3(C,D,A,B,X( 6),15,0xa3014314L);
289 R3(B,C,D,A,X[13],21,0x4e0811a1L); 291 R3(B,C,D,A,X(13),21,0x4e0811a1L);
290 R3(A,B,C,D,X[ 4], 6,0xf7537e82L); 292 R3(A,B,C,D,X( 4), 6,0xf7537e82L);
291 R3(D,A,B,C,X[11],10,0xbd3af235L); 293 R3(D,A,B,C,X(11),10,0xbd3af235L);
292 R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL); 294 R3(C,D,A,B,X( 2),15,0x2ad7d2bbL);
293 R3(B,C,D,A,X[ 9],21,0xeb86d391L); 295 R3(B,C,D,A,X( 9),21,0xeb86d391L);
294 296
295 A = c->A += A; 297 A = c->A += A;
296 B = c->B += B; 298 B = c->B += B;
diff --git a/src/lib/libssl/src/crypto/md5/md5_locl.h b/src/lib/libssl/src/crypto/md5/md5_locl.h
index 9d04696dbd..06af633228 100644
--- a/src/lib/libssl/src/crypto/md5/md5_locl.h
+++ b/src/lib/libssl/src/crypto/md5/md5_locl.h
@@ -66,7 +66,7 @@
66#endif 66#endif
67 67
68#ifdef MD5_ASM 68#ifdef MD5_ASM
69# if defined(__i386) || defined(_M_IX86) 69# if 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(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);
@@ -77,11 +77,11 @@
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) 80#if 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)
84 * are in this case of the same "endianess" these two are 84 * are in this case of the same "endianness" these two are
85 * otherwise indistinguishable. But normally you don't want to 85 * otherwise indistinguishable. But normally you don't want to
86 * call the same function because unaligned access in places 86 * call the same function because unaligned access in places
87 * where alignment is expected is usually a "Bad Thing". Indeed, 87 * where alignment is expected is usually a "Bad Thing". Indeed,
@@ -112,6 +112,13 @@ void md5_block_data_order (MD5_CTX *c, const void *p,int num);
112#define HASH_UPDATE MD5_Update 112#define HASH_UPDATE MD5_Update
113#define HASH_TRANSFORM MD5_Transform 113#define HASH_TRANSFORM MD5_Transform
114#define HASH_FINAL MD5_Final 114#define HASH_FINAL MD5_Final
115#define HASH_MAKE_STRING(c,s) do { \
116 unsigned long ll; \
117 ll=(c)->A; HOST_l2c(ll,(s)); \
118 ll=(c)->B; HOST_l2c(ll,(s)); \
119 ll=(c)->C; HOST_l2c(ll,(s)); \
120 ll=(c)->D; HOST_l2c(ll,(s)); \
121 } while (0)
115#define HASH_BLOCK_HOST_ORDER md5_block_host_order 122#define HASH_BLOCK_HOST_ORDER md5_block_host_order
116#if !defined(L_ENDIAN) || defined(md5_block_data_order) 123#if !defined(L_ENDIAN) || defined(md5_block_data_order)
117#define HASH_BLOCK_DATA_ORDER md5_block_data_order 124#define HASH_BLOCK_DATA_ORDER md5_block_data_order
@@ -119,7 +126,7 @@ void md5_block_data_order (MD5_CTX *c, const void *p,int num);
119 * Little-endians (Intel and Alpha) feel better without this. 126 * Little-endians (Intel and Alpha) feel better without this.
120 * It looks like memcpy does better job than generic 127 * It looks like memcpy does better job than generic
121 * md5_block_data_order on copying-n-aligning input data. 128 * md5_block_data_order on copying-n-aligning input data.
122 * But franlky speaking I didn't expect such result on Alpha. 129 * But frankly speaking I didn't expect such result on Alpha.
123 * On the other hand I've got this with egcs-1.0.2 and if 130 * On the other hand I've got this with egcs-1.0.2 and if
124 * program is compiled with another (better?) compiler it 131 * program is compiled with another (better?) compiler it
125 * might turn out other way around. 132 * might turn out other way around.
@@ -140,7 +147,7 @@ void md5_block_data_order (MD5_CTX *c, const void *p,int num);
140*/ 147*/
141 148
142/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be 149/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
143 * simplified to the code below. Wei attributes these optimisations 150 * simplified to the code below. Wei attributes these optimizations
144 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. 151 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
145 */ 152 */
146#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) 153#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
diff --git a/src/lib/libssl/src/crypto/md5/md5_one.c b/src/lib/libssl/src/crypto/md5/md5_one.c
index 4b10e7f940..b89dec850d 100644
--- a/src/lib/libssl/src/crypto/md5/md5_one.c
+++ b/src/lib/libssl/src/crypto/md5/md5_one.c
@@ -64,7 +64,7 @@
64#include <openssl/ebcdic.h> 64#include <openssl/ebcdic.h>
65#endif 65#endif
66 66
67unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md) 67unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md)
68 { 68 {
69 MD5_CTX c; 69 MD5_CTX c;
70 static unsigned char m[MD5_DIGEST_LENGTH]; 70 static unsigned char m[MD5_DIGEST_LENGTH];
diff --git a/src/lib/libssl/src/crypto/md5/md5test.c b/src/lib/libssl/src/crypto/md5/md5test.c
index a192a62bb3..6bd8656302 100644
--- a/src/lib/libssl/src/crypto/md5/md5test.c
+++ b/src/lib/libssl/src/crypto/md5/md5test.c
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
69#else 69#else
70#include <openssl/md5.h> 70#include <openssl/md5.h>
71 71
72char *test[]={ 72static char *test[]={
73 "", 73 "",
74 "a", 74 "a",
75 "abc", 75 "abc",
@@ -80,7 +80,7 @@ char *test[]={
80 NULL, 80 NULL,
81 }; 81 };
82 82
83char *ret[]={ 83static char *ret[]={
84 "d41d8cd98f00b204e9800998ecf8427e", 84 "d41d8cd98f00b204e9800998ecf8427e",
85 "0cc175b9c0f1b6a831c399e269772661", 85 "0cc175b9c0f1b6a831c399e269772661",
86 "900150983cd24fb0d6963f7d28e17f72", 86 "900150983cd24fb0d6963f7d28e17f72",
diff --git a/src/lib/libssl/src/crypto/mdc2/Makefile.ssl b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
index f8c824c4a8..7c28103350 100644
--- a/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
@@ -83,7 +83,7 @@ mdc2_one.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
83mdc2_one.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 83mdc2_one.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
84mdc2_one.o: ../../include/openssl/err.h ../../include/openssl/mdc2.h 84mdc2_one.o: ../../include/openssl/err.h ../../include/openssl/mdc2.h
85mdc2_one.o: ../../include/openssl/opensslconf.h 85mdc2_one.o: ../../include/openssl/opensslconf.h
86mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 86mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87mdc2_one.o: ../cryptlib.h 87mdc2_one.o: ../../include/openssl/stack.h ../cryptlib.h
88mdc2dgst.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 88mdc2dgst.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
89mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h 89mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h
diff --git a/src/lib/libssl/src/crypto/mdc2/mdc2.h b/src/lib/libssl/src/crypto/mdc2/mdc2.h
index ec8e159fc9..00acd707cd 100644
--- a/src/lib/libssl/src/crypto/mdc2/mdc2.h
+++ b/src/lib/libssl/src/crypto/mdc2/mdc2.h
@@ -82,9 +82,10 @@ typedef struct mdc2_ctx_st
82 82
83 83
84void MDC2_Init(MDC2_CTX *c); 84void MDC2_Init(MDC2_CTX *c);
85void MDC2_Update(MDC2_CTX *c, unsigned char *data, unsigned long len); 85void MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len);
86void MDC2_Final(unsigned char *md, MDC2_CTX *c); 86void MDC2_Final(unsigned char *md, MDC2_CTX *c);
87unsigned char *MDC2(unsigned char *d, unsigned long n, unsigned char *md); 87unsigned char *MDC2(const unsigned char *d, unsigned long n,
88 unsigned char *md);
88 89
89#ifdef __cplusplus 90#ifdef __cplusplus
90} 91}
diff --git a/src/lib/libssl/src/crypto/mem.c b/src/lib/libssl/src/crypto/mem.c
index 61fc1e184e..5a661e5f45 100644
--- a/src/lib/libssl/src/crypto/mem.c
+++ b/src/lib/libssl/src/crypto/mem.c
@@ -59,371 +59,203 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/crypto.h> 61#include <openssl/crypto.h>
62#ifdef CRYPTO_MDEBUG_TIME
63# include <time.h>
64#endif
65#include <openssl/buffer.h>
66#include <openssl/bio.h>
67#include <openssl/lhash.h>
68#include "cryptlib.h" 62#include "cryptlib.h"
69 63
70/* #ifdef CRYPTO_MDEBUG */
71/* static int mh_mode=CRYPTO_MEM_CHECK_ON; */
72/* #else */
73static int mh_mode=CRYPTO_MEM_CHECK_OFF;
74/* #endif */
75/* State CRYPTO_MEM_CHECK_ON exists only temporarily when the library
76 * thinks that certain allocations should not be checked (e.g. the data
77 * structures used for memory checking). It is not suitable as an initial
78 * state: the library will unexpectedly enable memory checking when it
79 * executes one of those sections that want to disable checking
80 * temporarily.
81 *
82 * State CRYPTO_MEM_CHECK_ENABLE without ..._ON makes no sense whatsoever.
83 */
84
85static unsigned long order=0;
86
87static LHASH *mh=NULL;
88 64
89typedef struct mem_st 65static int allow_customize = 1; /* we provide flexible functions for */
90 { 66static int allow_customize_debug = 1;/* exchanging memory-related functions at
91 char *addr; 67 * run-time, but this must be done
92 int num; 68 * before any blocks are actually
93 const char *file; 69 * allocated; or we'll run into huge
94 int line; 70 * problems when malloc/free pairs
95#ifdef CRYPTO_MDEBUG_THREAD 71 * don't match etc. */
96 unsigned long thread; 72
73/* may be changed as long as `allow_customize' is set */
74static void *(*malloc_locked_func)(size_t) = malloc;
75static void (*free_locked_func)(void *) = free;
76static void *(*malloc_func)(size_t) = malloc;
77static void *(*realloc_func)(void *, size_t)= realloc;
78static void (*free_func)(void *) = free;
79
80/* may be changed as long as `allow_customize_debug' is set */
81/* XXX use correct function pointer types */
82#ifdef CRYPTO_MDEBUG
83 /* use default functions from mem_dbg.c */
84 static void (*malloc_debug_func)()= (void (*)())CRYPTO_dbg_malloc;
85 static void (*realloc_debug_func)()= (void (*)())CRYPTO_dbg_realloc;
86 static void (*free_debug_func)()= (void (*)())CRYPTO_dbg_free;
87 static void (*set_debug_options_func)()= (void (*)())CRYPTO_dbg_set_options;
88 static long (*get_debug_options_func)()= (long (*)())CRYPTO_dbg_get_options;
89#else
90 /* applications can use CRYPTO_malloc_debug_init() to select above case
91 * at run-time */
92 static void (*malloc_debug_func)()= NULL;
93 static void (*realloc_debug_func)()= NULL;
94 static void (*free_debug_func)()= NULL;
95 static void (*set_debug_options_func)()= NULL;
96 static long (*get_debug_options_func)()= NULL;
97#endif 97#endif
98 unsigned long order;
99#ifdef CRYPTO_MDEBUG_TIME
100 time_t time;
101#endif
102 } MEM;
103
104int CRYPTO_mem_ctrl(int mode)
105 {
106 int ret=mh_mode;
107
108 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
109 switch (mode)
110 {
111 /* for applications: */
112 case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
113 mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;
114 break;
115 case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */
116 mh_mode = 0;
117 break;
118 98
119 /* switch off temporarily (for library-internal use): */
120 case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
121 mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;
122 break;
123 case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
124 if (mh_mode&CRYPTO_MEM_CHECK_ON)
125 mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
126 break;
127 99
128 default: 100int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
129 break; 101 void (*f)(void *))
130 }
131 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
132 return(ret);
133 }
134
135static int mem_cmp(MEM *a, MEM *b)
136 {
137 return(a->addr - b->addr);
138 }
139
140static unsigned long mem_hash(MEM *a)
141 { 102 {
142 unsigned long ret; 103 if (!allow_customize)
143 104 return 0;
144 ret=(unsigned long)a->addr; 105 if ((m == NULL) || (r == NULL) || (f == NULL))
145 106 return 0;
146 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
147 return(ret);
148 }
149
150static char *(*malloc_locked_func)()=(char *(*)())malloc;
151static void (*free_locked_func)()=(void (*)())free;
152static char *(*malloc_func)()= (char *(*)())malloc;
153static char *(*realloc_func)()= (char *(*)())realloc;
154static void (*free_func)()= (void (*)())free;
155
156void CRYPTO_set_mem_functions(char *(*m)(), char *(*r)(), void (*f)())
157 {
158 if ((m == NULL) || (r == NULL) || (f == NULL)) return;
159 malloc_func=m; 107 malloc_func=m;
160 realloc_func=r; 108 realloc_func=r;
161 free_func=f; 109 free_func=f;
162 malloc_locked_func=m; 110 malloc_locked_func=m;
163 free_locked_func=f; 111 free_locked_func=f;
112 return 1;
164 } 113 }
165 114
166void CRYPTO_set_locked_mem_functions(char *(*m)(), void (*f)()) 115int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
167 { 116 {
168 if ((m == NULL) || (f == NULL)) return; 117 if (!allow_customize)
118 return 0;
119 if ((m == NULL) || (f == NULL))
120 return 0;
169 malloc_locked_func=m; 121 malloc_locked_func=m;
170 free_locked_func=f; 122 free_locked_func=f;
123 return 1;
124 }
125
126int CRYPTO_set_mem_debug_functions(void (*m)(), void (*r)(), void (*f)(),void (*so)(),long (*go)())
127 {
128 if (!allow_customize_debug)
129 return 0;
130 malloc_debug_func=m;
131 realloc_debug_func=r;
132 free_debug_func=f;
133 set_debug_options_func=so;
134 get_debug_options_func=go;
135 return 1;
171 } 136 }
172 137
173void CRYPTO_get_mem_functions(char *(**m)(), char *(**r)(), void (**f)()) 138void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
139 void (**f)(void *))
174 { 140 {
175 if (m != NULL) *m=malloc_func; 141 if (m != NULL) *m=malloc_func;
176 if (r != NULL) *r=realloc_func; 142 if (r != NULL) *r=realloc_func;
177 if (f != NULL) *f=free_func; 143 if (f != NULL) *f=free_func;
178 } 144 }
179 145
180void CRYPTO_get_locked_mem_functions(char *(**m)(), void (**f)()) 146void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
181 { 147 {
182 if (m != NULL) *m=malloc_locked_func; 148 if (m != NULL) *m=malloc_locked_func;
183 if (f != NULL) *f=free_locked_func; 149 if (f != NULL) *f=free_locked_func;
184 } 150 }
185 151
186void *CRYPTO_malloc_locked(int num) 152void CRYPTO_get_mem_debug_functions(void (**m)(), void (**r)(), void (**f)(),void (**so)(),long (**go)())
187 { 153 {
188 return(malloc_locked_func(num)); 154 if (m != NULL) *m=malloc_debug_func;
155 if (r != NULL) *r=realloc_debug_func;
156 if (f != NULL) *f=free_debug_func;
157 if (so != NULL) *so=set_debug_options_func;
158 if (go != NULL) *go=get_debug_options_func;
189 } 159 }
190 160
191void CRYPTO_free_locked(void *str)
192 {
193 free_locked_func(str);
194 }
195 161
196void *CRYPTO_malloc(int num) 162void *CRYPTO_malloc_locked(int num, const char *file, int line)
197 { 163 {
198 return(malloc_func(num)); 164 char *ret = NULL;
199 }
200 165
201void *CRYPTO_realloc(void *str, int num) 166 allow_customize = 0;
202 { 167 if (malloc_debug_func != NULL)
203 return(realloc_func(str,num));
204 }
205
206void CRYPTO_free(void *str)
207 {
208 free_func(str);
209 }
210
211static unsigned long break_order_num=0;
212void *CRYPTO_dbg_malloc(int num, const char *file, int line)
213 {
214 char *ret;
215 MEM *m,*mm;
216
217 if ((ret=malloc_func(num)) == NULL)
218 return(NULL);
219
220 if (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
221 { 168 {
222 MemCheck_off(); 169 allow_customize_debug = 0;
223 if ((m=(MEM *)Malloc(sizeof(MEM))) == NULL) 170 malloc_debug_func(NULL, num, file, line, 0);
224 {
225 Free(ret);
226 MemCheck_on();
227 return(NULL);
228 }
229 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
230 if (mh == NULL)
231 {
232 if ((mh=lh_new(mem_hash,mem_cmp)) == NULL)
233 {
234 Free(ret);
235 Free(m);
236 ret=NULL;
237 goto err;
238 }
239 }
240
241 m->addr=ret;
242 m->file=file;
243 m->line=line;
244 m->num=num;
245#ifdef CRYPTO_MDEBUG_THREAD
246 m->thread=CRYPTO_thread_id();
247#endif
248 if (order == break_order_num)
249 {
250 /* BREAK HERE */
251 m->order=order;
252 }
253 m->order=order++;
254#ifdef CRYPTO_MDEBUG_TIME
255 m->time=time(NULL);
256#endif
257 if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL)
258 {
259 /* Not good, but don't sweat it */
260 Free(mm);
261 }
262err:
263 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
264 MemCheck_on();
265 } 171 }
266 return(ret); 172 ret = malloc_locked_func(num);
173#ifdef LEVITTE_DEBUG
174 fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num);
175#endif
176 if (malloc_debug_func != NULL)
177 malloc_debug_func(ret, num, file, line, 1);
178
179 return ret;
267 } 180 }
268 181
269void CRYPTO_dbg_free(void *addr) 182void CRYPTO_free_locked(void *str)
270 { 183 {
271 MEM m,*mp; 184 if (free_debug_func != NULL)
272 185 free_debug_func(str, 0);
273 if ((mh_mode & CRYPTO_MEM_CHECK_ENABLE) && (mh != NULL)) 186#ifdef LEVITTE_DEBUG
274 { 187 fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str);
275 MemCheck_off(); 188#endif
276 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC); 189 free_locked_func(str);
277 m.addr=addr; 190 if (free_debug_func != NULL)
278 mp=(MEM *)lh_delete(mh,(char *)&m); 191 free_debug_func(NULL, 1);
279 if (mp != NULL)
280 Free(mp);
281 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
282 MemCheck_on();
283 }
284 free_func(addr);
285 } 192 }
286 193
287void *CRYPTO_dbg_realloc(void *addr, int num, const char *file, int line) 194void *CRYPTO_malloc(int num, const char *file, int line)
288 { 195 {
289 char *ret; 196 char *ret = NULL;
290 MEM m,*mp;
291
292 ret=realloc_func(addr,num);
293 if (ret == addr) return(ret);
294 197
295 if (mh_mode & CRYPTO_MEM_CHECK_ENABLE) 198 allow_customize = 0;
199 if (malloc_debug_func != NULL)
296 { 200 {
297 MemCheck_off(); 201 allow_customize_debug = 0;
298 if (ret == NULL) return(NULL); 202 malloc_debug_func(NULL, num, file, line, 0);
299 m.addr=addr;
300 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
301 mp=(MEM *)lh_delete(mh,(char *)&m);
302 if (mp != NULL)
303 {
304 mp->addr=ret;
305 lh_insert(mh,(char *)mp);
306 }
307 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
308 MemCheck_on();
309 } 203 }
310 return(ret); 204 ret = malloc_func(num);
311 } 205#ifdef LEVITTE_DEBUG
312 206 fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num);
313void *CRYPTO_remalloc(void *a, int n) 207#endif
314 { 208 if (malloc_debug_func != NULL)
315 if (a != NULL) Free(a); 209 malloc_debug_func(ret, num, file, line, 1);
316 a=(char *)Malloc(n);
317 return(a);
318 }
319 210
320void *CRYPTO_dbg_remalloc(void *a, int n, const char *file, int line) 211 return ret;
321 {
322 if (a != NULL) CRYPTO_dbg_free(a);
323 a=(char *)CRYPTO_dbg_malloc(n,file,line);
324 return(a);
325 } 212 }
326 213
327 214void *CRYPTO_realloc(void *str, int num, const char *file, int line)
328typedef struct mem_leak_st
329 { 215 {
330 BIO *bio; 216 char *ret = NULL;
331 int chunks;
332 long bytes;
333 } MEM_LEAK;
334 217
335static void print_leak(MEM *m, MEM_LEAK *l) 218 if (realloc_debug_func != NULL)
336 { 219 realloc_debug_func(str, NULL, num, file, line, 0);
337 char buf[128]; 220 ret = realloc_func(str,num);
338#ifdef CRYPTO_MDEBUG_TIME 221#ifdef LEVITTE_DEBUG
339 struct tm *lcl; 222 fprintf(stderr, "LEVITTE_DEBUG: | 0x%p -> 0x%p (%d)\n", str, ret, num);
340#endif 223#endif
224 if (realloc_debug_func != NULL)
225 realloc_debug_func(str, ret, num, file, line, 1);
341 226
342 if(m->addr == (char *)l->bio) 227 return ret;
343 return;
344
345#ifdef CRYPTO_MDEBUG_TIME
346 lcl = localtime(&m->time);
347#endif
348
349 sprintf(buf,
350#ifdef CRYPTO_MDEBUG_TIME
351 "[%02d:%02d:%02d] "
352#endif
353 "%5lu file=%s, line=%d, "
354#ifdef CRYPTO_MDEBUG_THREAD
355 "thread=%lu, "
356#endif
357 "number=%d, address=%08lX\n",
358#ifdef CRYPTO_MDEBUG_TIME
359 lcl->tm_hour,lcl->tm_min,lcl->tm_sec,
360#endif
361 m->order,m->file,m->line,
362#ifdef CRYPTO_MDEBUG_THREAD
363 m->thread,
364#endif
365 m->num,(unsigned long)m->addr);
366
367 BIO_puts(l->bio,buf);
368 l->chunks++;
369 l->bytes+=m->num;
370 } 228 }
371 229
372void CRYPTO_mem_leaks(BIO *b) 230void CRYPTO_free(void *str)
373 { 231 {
374 MEM_LEAK ml; 232 if (free_debug_func != NULL)
375 char buf[80]; 233 free_debug_func(str, 0);
376 234#ifdef LEVITTE_DEBUG
377 if (mh == NULL) return; 235 fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str);
378 ml.bio=b;
379 ml.bytes=0;
380 ml.chunks=0;
381 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
382 lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml);
383 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
384 if (ml.chunks != 0)
385 {
386 sprintf(buf,"%ld bytes leaked in %d chunks\n",
387 ml.bytes,ml.chunks);
388 BIO_puts(b,buf);
389 }
390
391#if 0
392 lh_stats_bio(mh,b);
393 lh_node_stats_bio(mh,b);
394 lh_node_usage_stats_bio(mh,b);
395#endif 236#endif
237 free_func(str);
238 if (free_debug_func != NULL)
239 free_debug_func(NULL, 1);
396 } 240 }
397 241
398static void (*mem_cb)()=NULL; 242void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
399
400static void cb_leak(MEM *m, char *cb)
401 { 243 {
402 void (*mem_callback)()=(void (*)())cb; 244 if (a != NULL) Free(a);
403 mem_callback(m->order,m->file,m->line,m->num,m->addr); 245 a=(char *)Malloc(num);
246 return(a);
404 } 247 }
405 248
406void CRYPTO_mem_leaks_cb(void (*cb)()) 249
250void CRYPTO_set_mem_debug_options(long bits)
407 { 251 {
408 if (mh == NULL) return; 252 if (set_debug_options_func != NULL)
409 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC); 253 set_debug_options_func(bits);
410 mem_cb=cb;
411 lh_doall_arg(mh,(void (*)())cb_leak,(char *)mem_cb);
412 mem_cb=NULL;
413 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
414 } 254 }
415 255
416#ifndef NO_FP_API 256long CRYPTO_get_mem_debug_options(void)
417void CRYPTO_mem_leaks_fp(FILE *fp)
418 { 257 {
419 BIO *b; 258 if (get_debug_options_func != NULL)
420 259 return get_debug_options_func();
421 if (mh == NULL) return; 260 return 0;
422 if ((b=BIO_new(BIO_s_file())) == NULL)
423 return;
424 BIO_set_fp(b,fp,BIO_NOCLOSE);
425 CRYPTO_mem_leaks(b);
426 BIO_free(b);
427 } 261 }
428#endif
429
diff --git a/src/lib/libssl/src/crypto/mem_dbg.c b/src/lib/libssl/src/crypto/mem_dbg.c
new file mode 100644
index 0000000000..14770c0733
--- /dev/null
+++ b/src/lib/libssl/src/crypto/mem_dbg.c
@@ -0,0 +1,703 @@
1/* crypto/mem_dbg.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <time.h>
62#include <openssl/crypto.h>
63#include <openssl/buffer.h>
64#include <openssl/bio.h>
65#include <openssl/lhash.h>
66#include "cryptlib.h"
67
68static int mh_mode=CRYPTO_MEM_CHECK_OFF;
69/* The state changes to CRYPTO_MEM_CHECK_ON | CRYPTO_MEM_CHECK_ENABLE
70 * when the application asks for it (usually after library initialisation
71 * for which no book-keeping is desired).
72 *
73 * State CRYPTO_MEM_CHECK_ON exists only temporarily when the library
74 * thinks that certain allocations should not be checked (e.g. the data
75 * structures used for memory checking). It is not suitable as an initial
76 * state: the library will unexpectedly enable memory checking when it
77 * executes one of those sections that want to disable checking
78 * temporarily.
79 *
80 * State CRYPTO_MEM_CHECK_ENABLE without ..._ON makes no sense whatsoever.
81 */
82
83static unsigned long order = 0; /* number of memory requests */
84static LHASH *mh=NULL; /* hash-table of memory requests (address as key) */
85
86
87typedef struct app_mem_info_st
88/* For application-defined information (static C-string `info')
89 * to be displayed in memory leak list.
90 * Each thread has its own stack. For applications, there is
91 * CRYPTO_push_info("...") to push an entry,
92 * CRYPTO_pop_info() to pop an entry,
93 * CRYPTO_remove_all_info() to pop all entries.
94 */
95 {
96 unsigned long thread;
97 const char *file;
98 int line;
99 const char *info;
100 struct app_mem_info_st *next; /* tail of thread's stack */
101 int references;
102 } APP_INFO;
103
104static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's
105 * that are at the top of their thread's stack
106 * (with `thread' as key) */
107
108typedef struct mem_st
109/* memory-block description */
110 {
111 char *addr;
112 int num;
113 const char *file;
114 int line;
115 unsigned long thread;
116 unsigned long order;
117 time_t time;
118 APP_INFO *app_info;
119 } MEM;
120
121static long options = /* extra information to be recorded */
122#if defined(CRYPTO_MDEBUG_TIME) || defined(CRYPTO_MDEBUG_ALL)
123 V_CRYPTO_MDEBUG_TIME |
124#endif
125#if defined(CRYPTO_MDEBUG_THREAD) || defined(CRYPTO_MDEBUG_ALL)
126 V_CRYPTO_MDEBUG_THREAD |
127#endif
128 0;
129
130
131static unsigned long disabling_thread = 0;
132
133int CRYPTO_mem_ctrl(int mode)
134 {
135 int ret=mh_mode;
136
137 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
138 switch (mode)
139 {
140 /* for applications: */
141 case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
142 mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;
143 disabling_thread = 0;
144 break;
145 case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */
146 mh_mode = 0;
147 disabling_thread = 0;
148 break;
149
150 /* switch off temporarily (for library-internal use): */
151 case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
152 if (mh_mode & CRYPTO_MEM_CHECK_ON)
153 {
154 mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;
155 if (disabling_thread != CRYPTO_thread_id()) /* otherwise we already have the MALLOC2 lock */
156 {
157 /* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
158 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
159 * somebody else holds CRYPTO_LOCK_MALLOC2 (and cannot release
160 * it because we block entry to this function).
161 * Give them a chance, first, and then claim the locks in
162 * appropriate order (long-time lock first).
163 */
164 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
165 /* Note that after we have waited for CRYPTO_LOCK_MALLOC2
166 * and CRYPTO_LOCK_MALLOC, we'll still be in the right
167 * "case" and "if" branch because MemCheck_start and
168 * MemCheck_stop may never be used while there are multiple
169 * OpenSSL threads. */
170 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
171 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
172 disabling_thread=CRYPTO_thread_id();
173 }
174 }
175 break;
176 case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
177 if (mh_mode & CRYPTO_MEM_CHECK_ON)
178 {
179 mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
180 if (disabling_thread != 0)
181 {
182 disabling_thread=0;
183 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
184 }
185 }
186 break;
187
188 default:
189 break;
190 }
191 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
192 return(ret);
193 }
194
195int CRYPTO_is_mem_check_on(void)
196 {
197 int ret = 0;
198
199 if (mh_mode & CRYPTO_MEM_CHECK_ON)
200 {
201 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
202
203 ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
204 && disabling_thread != CRYPTO_thread_id();
205
206 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
207 }
208 return(ret);
209 }
210
211
212void CRYPTO_dbg_set_options(long bits)
213 {
214 options = bits;
215 }
216
217long CRYPTO_dbg_get_options(void)
218 {
219 return options;
220 }
221
222static int mem_cmp(MEM *a, MEM *b)
223 {
224 return(a->addr - b->addr);
225 }
226
227static unsigned long mem_hash(MEM *a)
228 {
229 unsigned long ret;
230
231 ret=(unsigned long)a->addr;
232
233 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
234 return(ret);
235 }
236
237static int app_info_cmp(APP_INFO *a, APP_INFO *b)
238 {
239 return(a->thread != b->thread);
240 }
241
242static unsigned long app_info_hash(APP_INFO *a)
243 {
244 unsigned long ret;
245
246 ret=(unsigned long)a->thread;
247
248 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
249 return(ret);
250 }
251
252static APP_INFO *pop_info()
253 {
254 APP_INFO tmp;
255 APP_INFO *ret = NULL;
256
257 if (amih != NULL)
258 {
259 tmp.thread=CRYPTO_thread_id();
260 if ((ret=(APP_INFO *)lh_delete(amih,&tmp)) != NULL)
261 {
262 APP_INFO *next=ret->next;
263
264 if (next != NULL)
265 {
266 next->references++;
267 lh_insert(amih,(char *)next);
268 }
269#ifdef LEVITTE_DEBUG
270 if (ret->thread != tmp.thread)
271 {
272 fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
273 ret->thread, tmp.thread);
274 abort();
275 }
276#endif
277 if (--(ret->references) <= 0)
278 {
279 ret->next = NULL;
280 if (next != NULL)
281 next->references--;
282 Free(ret);
283 }
284 }
285 }
286 return(ret);
287 }
288
289int CRYPTO_push_info_(const char *info, const char *file, int line)
290 {
291 APP_INFO *ami, *amim;
292 int ret=0;
293
294 if (is_MemCheck_on())
295 {
296 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
297
298 if ((ami = (APP_INFO *)Malloc(sizeof(APP_INFO))) == NULL)
299 {
300 ret=0;
301 goto err;
302 }
303 if (amih == NULL)
304 {
305 if ((amih=lh_new(app_info_hash,app_info_cmp)) == NULL)
306 {
307 Free(ami);
308 ret=0;
309 goto err;
310 }
311 }
312
313 ami->thread=CRYPTO_thread_id();
314 ami->file=file;
315 ami->line=line;
316 ami->info=info;
317 ami->references=1;
318 ami->next=NULL;
319
320 if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL)
321 {
322#ifdef LEVITTE_DEBUG
323 if (ami->thread != amim->thread)
324 {
325 fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
326 amim->thread, ami->thread);
327 abort();
328 }
329#endif
330 ami->next=amim;
331 }
332 err:
333 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
334 }
335
336 return(ret);
337 }
338
339int CRYPTO_pop_info(void)
340 {
341 int ret=0;
342
343 if (is_MemCheck_on()) /* _must_ be true, or something went severely wrong */
344 {
345 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
346
347 ret=(pop_info() != NULL);
348
349 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
350 }
351 return(ret);
352 }
353
354int CRYPTO_remove_all_info(void)
355 {
356 int ret=0;
357
358 if (is_MemCheck_on()) /* _must_ be true */
359 {
360 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
361
362 while(pop_info() != NULL)
363 ret++;
364
365 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
366 }
367 return(ret);
368 }
369
370
371static unsigned long break_order_num=0;
372void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
373 int before_p)
374 {
375 MEM *m,*mm;
376 APP_INFO tmp,*amim;
377
378 switch(before_p & 127)
379 {
380 case 0:
381 break;
382 case 1:
383 if (addr == NULL)
384 break;
385
386 if (is_MemCheck_on())
387 {
388 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
389 if ((m=(MEM *)Malloc(sizeof(MEM))) == NULL)
390 {
391 Free(addr);
392 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
393 return;
394 }
395 if (mh == NULL)
396 {
397 if ((mh=lh_new(mem_hash,mem_cmp)) == NULL)
398 {
399 Free(addr);
400 Free(m);
401 addr=NULL;
402 goto err;
403 }
404 }
405
406 m->addr=addr;
407 m->file=file;
408 m->line=line;
409 m->num=num;
410 if (options & V_CRYPTO_MDEBUG_THREAD)
411 m->thread=CRYPTO_thread_id();
412 else
413 m->thread=0;
414
415 if (order == break_order_num)
416 {
417 /* BREAK HERE */
418 m->order=order;
419 }
420 m->order=order++;
421#ifdef LEVITTE_DEBUG
422 fprintf(stderr, "LEVITTE_DEBUG: [%5d] %c 0x%p (%d)\n",
423 m->order,
424 (before_p & 128) ? '*' : '+',
425 m->addr, m->num);
426#endif
427 if (options & V_CRYPTO_MDEBUG_TIME)
428 m->time=time(NULL);
429 else
430 m->time=0;
431
432 tmp.thread=CRYPTO_thread_id();
433 m->app_info=NULL;
434 if (amih != NULL
435 && (amim=(APP_INFO *)lh_retrieve(amih,(char *)&tmp)) != NULL)
436 {
437 m->app_info = amim;
438 amim->references++;
439 }
440
441 if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL)
442 {
443 /* Not good, but don't sweat it */
444 if (mm->app_info != NULL)
445 {
446 mm->app_info->references--;
447 }
448 Free(mm);
449 }
450 err:
451 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
452 }
453 break;
454 }
455 return;
456 }
457
458void CRYPTO_dbg_free(void *addr, int before_p)
459 {
460 MEM m,*mp;
461
462 switch(before_p)
463 {
464 case 0:
465 if (addr == NULL)
466 break;
467
468 if (is_MemCheck_on() && (mh != NULL))
469 {
470 MemCheck_off();
471
472 m.addr=addr;
473 mp=(MEM *)lh_delete(mh,(char *)&m);
474 if (mp != NULL)
475 {
476#ifdef LEVITTE_DEBUG
477 fprintf(stderr, "LEVITTE_DEBUG: [%5d] - 0x%p (%d)\n",
478 mp->order, mp->addr, mp->num);
479#endif
480 if (mp->app_info != NULL)
481 {
482 mp->app_info->references--;
483 }
484 Free(mp);
485 }
486
487 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
488 }
489 break;
490 case 1:
491 break;
492 }
493 }
494
495void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
496 const char *file, int line, int before_p)
497 {
498 MEM m,*mp;
499
500#ifdef LEVITTE_DEBUG
501 fprintf(stderr, "LEVITTE_DEBUG: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n",
502 addr1, addr2, num, file, line, before_p);
503#endif
504
505 switch(before_p)
506 {
507 case 0:
508 break;
509 case 1:
510 if (addr2 == NULL)
511 break;
512
513 if (addr1 == NULL)
514 {
515 CRYPTO_dbg_malloc(addr2, num, file, line, 128 | before_p);
516 break;
517 }
518
519 if (is_MemCheck_on())
520 {
521 MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
522
523 m.addr=addr1;
524 mp=(MEM *)lh_delete(mh,(char *)&m);
525 if (mp != NULL)
526 {
527#ifdef LEVITTE_DEBUG
528 fprintf(stderr, "LEVITTE_DEBUG: [%5d] * 0x%p (%d) -> 0x%p (%d)\n",
529 mp->order,
530 mp->addr, mp->num,
531 addr2, num);
532#endif
533 mp->addr=addr2;
534 mp->num=num;
535 lh_insert(mh,(char *)mp);
536 }
537
538 MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
539 }
540 break;
541 }
542 return;
543 }
544
545
546typedef struct mem_leak_st
547 {
548 BIO *bio;
549 int chunks;
550 long bytes;
551 } MEM_LEAK;
552
553static void print_leak(MEM *m, MEM_LEAK *l)
554 {
555 char buf[1024];
556 char *bufp = buf;
557 APP_INFO *amip;
558 int ami_cnt;
559 struct tm *lcl = NULL;
560 unsigned long ti;
561
562 if(m->addr == (char *)l->bio)
563 return;
564
565 if (options & V_CRYPTO_MDEBUG_TIME)
566 {
567 lcl = localtime(&m->time);
568
569 sprintf(bufp, "[%02d:%02d:%02d] ",
570 lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
571 bufp += strlen(bufp);
572 }
573
574 sprintf(bufp, "%5lu file=%s, line=%d, ",
575 m->order,m->file,m->line);
576 bufp += strlen(bufp);
577
578 if (options & V_CRYPTO_MDEBUG_THREAD)
579 {
580 sprintf(bufp, "thread=%lu, ", m->thread);
581 bufp += strlen(bufp);
582 }
583
584 sprintf(bufp, "number=%d, address=%08lX\n",
585 m->num,(unsigned long)m->addr);
586 bufp += strlen(bufp);
587
588 BIO_puts(l->bio,buf);
589
590 l->chunks++;
591 l->bytes+=m->num;
592
593 amip=m->app_info;
594 ami_cnt=0;
595 if (!amip)
596 return;
597 ti=amip->thread;
598
599 do
600 {
601 int buf_len;
602 int info_len;
603
604 ami_cnt++;
605 memset(buf,'>',ami_cnt);
606 sprintf(buf + ami_cnt,
607 " thread=%lu, file=%s, line=%d, info=\"",
608 amip->thread, amip->file, amip->line);
609 buf_len=strlen(buf);
610 info_len=strlen(amip->info);
611 if (128 - buf_len - 3 < info_len)
612 {
613 memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
614 buf_len = 128 - 3;
615 }
616 else
617 {
618 strcpy(buf + buf_len, amip->info);
619 buf_len = strlen(buf);
620 }
621 sprintf(buf + buf_len, "\"\n");
622
623 BIO_puts(l->bio,buf);
624
625 amip = amip->next;
626 }
627 while(amip && amip->thread == ti);
628
629#ifdef LEVITTE_DEBUG
630 if (amip)
631 {
632 fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
633 abort();
634 }
635#endif
636 }
637
638void CRYPTO_mem_leaks(BIO *b)
639 {
640 MEM_LEAK ml;
641 char buf[80];
642
643 if (mh == NULL) return;
644 ml.bio=b;
645 ml.bytes=0;
646 ml.chunks=0;
647 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
648 lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml);
649 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
650 if (ml.chunks != 0)
651 {
652 sprintf(buf,"%ld bytes leaked in %d chunks\n",
653 ml.bytes,ml.chunks);
654 BIO_puts(b,buf);
655 }
656
657#if 0
658 lh_stats_bio(mh,b);
659 lh_node_stats_bio(mh,b);
660 lh_node_usage_stats_bio(mh,b);
661#endif
662 }
663
664union void_fn_to_char_u
665 {
666 char *char_p;
667 void (*fn_p)();
668 };
669
670static void cb_leak(MEM *m, char *cb)
671 {
672 union void_fn_to_char_u mem_callback;
673
674 mem_callback.char_p=cb;
675 mem_callback.fn_p(m->order,m->file,m->line,m->num,m->addr);
676 }
677
678void CRYPTO_mem_leaks_cb(void (*cb)())
679 {
680 union void_fn_to_char_u mem_cb;
681
682 if (mh == NULL) return;
683 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
684 mem_cb.fn_p=cb;
685 lh_doall_arg(mh,(void (*)())cb_leak,mem_cb.char_p);
686 mem_cb.char_p=NULL;
687 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
688 }
689
690#ifndef NO_FP_API
691void CRYPTO_mem_leaks_fp(FILE *fp)
692 {
693 BIO *b;
694
695 if (mh == NULL) return;
696 if ((b=BIO_new(BIO_s_file())) == NULL)
697 return;
698 BIO_set_fp(b,fp,BIO_NOCLOSE);
699 CRYPTO_mem_leaks(b);
700 BIO_free(b);
701 }
702#endif
703
diff --git a/src/lib/libssl/src/crypto/objects/Makefile.ssl b/src/lib/libssl/src/crypto/objects/Makefile.ssl
index 53450f8754..f05e15df96 100644
--- a/src/lib/libssl/src/crypto/objects/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/objects/Makefile.ssl
@@ -37,9 +37,6 @@ top:
37 37
38all: obj_dat.h lib 38all: obj_dat.h lib
39 39
40obj_dat.h: objects.h obj_dat.pl
41 $(PERL) ./obj_dat.pl < objects.h > obj_dat.h
42
43lib: $(LIBOBJ) 40lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 41 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) 42 $(RANLIB) $(LIB)
diff --git a/src/lib/libssl/src/crypto/objects/o_names.c b/src/lib/libssl/src/crypto/objects/o_names.c
index 4da5e45b9c..d654eb220e 100644
--- a/src/lib/libssl/src/crypto/objects/o_names.c
+++ b/src/lib/libssl/src/crypto/objects/o_names.c
@@ -4,15 +4,25 @@
4 4
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 8
8/* I use the ex_data stuff to manage the identifiers for the obj_name_types 9/* I use the ex_data stuff to manage the identifiers for the obj_name_types
9 * that applications may define. I only really use the free function field. 10 * that applications may define. I only really use the free function field.
10 */ 11 */
11static LHASH *names_lh=NULL; 12static LHASH *names_lh=NULL;
12static int names_type_num=OBJ_NAME_TYPE_NUM; 13static int names_type_num=OBJ_NAME_TYPE_NUM;
13static STACK *names_cmp=NULL; 14
14static STACK *names_hash=NULL; 15typedef struct name_funcs_st
15static STACK *names_free=NULL; 16 {
17 unsigned long (*hash_func)();
18 int (*cmp_func)();
19 void (*free_func)();
20 } NAME_FUNCS;
21
22DECLARE_STACK_OF(NAME_FUNCS)
23IMPLEMENT_STACK_OF(NAME_FUNCS)
24
25STACK_OF(NAME_FUNCS) *name_funcs_stack;
16 26
17static unsigned long obj_name_hash(OBJ_NAME *a); 27static unsigned long obj_name_hash(OBJ_NAME *a);
18static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); 28static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b);
@@ -31,51 +41,57 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(), int (*cmp_func)(),
31 { 41 {
32 int ret; 42 int ret;
33 int i; 43 int i;
44 NAME_FUNCS *name_funcs;
34 45
35 if (names_free == NULL) 46 if (name_funcs_stack == NULL)
36 { 47 {
37 MemCheck_off(); 48 MemCheck_off();
38 names_hash=sk_new_null(); 49 name_funcs_stack=sk_NAME_FUNCS_new_null();
39 names_cmp=sk_new_null();
40 names_free=sk_new_null();
41 MemCheck_on(); 50 MemCheck_on();
42 } 51 }
43 if ((names_free == NULL) || (names_hash == NULL) || (names_cmp == NULL)) 52 if ((name_funcs_stack == NULL))
44 { 53 {
45 /* ERROR */ 54 /* ERROR */
46 return(0); 55 return(0);
47 } 56 }
48 ret=names_type_num; 57 ret=names_type_num;
49 names_type_num++; 58 names_type_num++;
50 for (i=sk_num(names_free); i<names_type_num; i++) 59 for (i=sk_NAME_FUNCS_num(name_funcs_stack); i<names_type_num; i++)
51 { 60 {
52 MemCheck_off(); 61 MemCheck_off();
53 sk_push(names_hash,(char *)strcmp); 62 name_funcs = Malloc(sizeof(NAME_FUNCS));
54 sk_push(names_cmp,(char *)lh_strhash); 63 name_funcs->hash_func = lh_strhash;
55 sk_push(names_free,NULL); 64 name_funcs->cmp_func = (int (*)())strcmp;
65 name_funcs->free_func = 0; /* NULL is often declared to
66 * ((void *)0), which according
67 * to Compaq C is not really
68 * compatible with a function
69 * pointer. -- Richard Levitte*/
70 sk_NAME_FUNCS_push(name_funcs_stack,name_funcs);
56 MemCheck_on(); 71 MemCheck_on();
57 } 72 }
73 name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
58 if (hash_func != NULL) 74 if (hash_func != NULL)
59 sk_set(names_hash,ret,(char *)hash_func); 75 name_funcs->hash_func = hash_func;
60 if (cmp_func != NULL) 76 if (cmp_func != NULL)
61 sk_set(names_cmp,ret,(char *)cmp_func); 77 name_funcs->cmp_func = cmp_func;
62 if (free_func != NULL) 78 if (free_func != NULL)
63 sk_set(names_free,ret,(char *)free_func); 79 name_funcs->free_func = free_func;
64 return(ret); 80 return(ret);
65 } 81 }
66 82
67static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) 83static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
68 { 84 {
69 int ret; 85 int ret;
70 int (*cmp)();
71 86
72 ret=a->type-b->type; 87 ret=a->type-b->type;
73 if (ret == 0) 88 if (ret == 0)
74 { 89 {
75 if ((names_cmp != NULL) && (sk_num(names_cmp) > a->type)) 90 if ((name_funcs_stack != NULL)
91 && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
76 { 92 {
77 cmp=(int (*)())sk_value(names_cmp,a->type); 93 ret=sk_NAME_FUNCS_value(name_funcs_stack,a->type)
78 ret=cmp(a->name,b->name); 94 ->cmp_func(a->name,b->name);
79 } 95 }
80 else 96 else
81 ret=strcmp(a->name,b->name); 97 ret=strcmp(a->name,b->name);
@@ -86,12 +102,11 @@ static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
86static unsigned long obj_name_hash(OBJ_NAME *a) 102static unsigned long obj_name_hash(OBJ_NAME *a)
87 { 103 {
88 unsigned long ret; 104 unsigned long ret;
89 unsigned long (*hash)();
90 105
91 if ((names_hash != NULL) && (sk_num(names_hash) > a->type)) 106 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
92 { 107 {
93 hash=(unsigned long (*)())sk_value(names_hash,a->type); 108 ret=sk_NAME_FUNCS_value(name_funcs_stack,a->type)
94 ret=hash(a->name); 109 ->hash_func(a->name);
95 } 110 }
96 else 111 else
97 { 112 {
@@ -117,7 +132,7 @@ const char *OBJ_NAME_get(const char *name, int type)
117 132
118 for (;;) 133 for (;;)
119 { 134 {
120 ret=(OBJ_NAME *)lh_retrieve(names_lh,(char *)&on); 135 ret=(OBJ_NAME *)lh_retrieve(names_lh,&on);
121 if (ret == NULL) return(NULL); 136 if (ret == NULL) return(NULL);
122 if ((ret->alias) && !alias) 137 if ((ret->alias) && !alias)
123 { 138 {
@@ -133,7 +148,6 @@ const char *OBJ_NAME_get(const char *name, int type)
133 148
134int OBJ_NAME_add(const char *name, int type, const char *data) 149int OBJ_NAME_add(const char *name, int type, const char *data)
135 { 150 {
136 void (*f)();
137 OBJ_NAME *onp,*ret; 151 OBJ_NAME *onp,*ret;
138 int alias; 152 int alias;
139 153
@@ -154,16 +168,20 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
154 onp->type=type; 168 onp->type=type;
155 onp->data=data; 169 onp->data=data;
156 170
157 ret=(OBJ_NAME *)lh_insert(names_lh,(char *)onp); 171 ret=(OBJ_NAME *)lh_insert(names_lh,onp);
158 if (ret != NULL) 172 if (ret != NULL)
159 { 173 {
160 /* free things */ 174 /* free things */
161 if ((names_free != NULL) && (sk_num(names_free) > ret->type)) 175 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type))
162 { 176 {
163 f=(void (*)())sk_value(names_free,ret->type); 177 /* XXX: I'm not sure I understand why the free
164 f(ret->name,ret->type,ret->data); 178 * function should get three arguments...
179 * -- Richard Levitte
180 */
181 sk_NAME_FUNCS_value(name_funcs_stack,ret->type)
182 ->free_func(ret->name,ret->type,ret->data);
165 } 183 }
166 Free((char *)ret); 184 Free(ret);
167 } 185 }
168 else 186 else
169 { 187 {
@@ -179,23 +197,26 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
179int OBJ_NAME_remove(const char *name, int type) 197int OBJ_NAME_remove(const char *name, int type)
180 { 198 {
181 OBJ_NAME on,*ret; 199 OBJ_NAME on,*ret;
182 void (*f)();
183 200
184 if (names_lh == NULL) return(0); 201 if (names_lh == NULL) return(0);
185 202
186 type&= ~OBJ_NAME_ALIAS; 203 type&= ~OBJ_NAME_ALIAS;
187 on.name=name; 204 on.name=name;
188 on.type=type; 205 on.type=type;
189 ret=(OBJ_NAME *)lh_delete(names_lh,(char *)&on); 206 ret=(OBJ_NAME *)lh_delete(names_lh,&on);
190 if (ret != NULL) 207 if (ret != NULL)
191 { 208 {
192 /* free things */ 209 /* free things */
193 if ((names_free != NULL) && (sk_num(names_free) > type)) 210 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type))
194 { 211 {
195 f=(void (*)())sk_value(names_free,type); 212 /* XXX: I'm not sure I understand why the free
196 f(ret->name,ret->type,ret->data); 213 * function should get three arguments...
214 * -- Richard Levitte
215 */
216 sk_NAME_FUNCS_value(name_funcs_stack,ret->type)
217 ->free_func(ret->name,ret->type,ret->data);
197 } 218 }
198 Free((char *)ret); 219 Free(ret);
199 return(1); 220 return(1);
200 } 221 }
201 else 222 else
@@ -215,6 +236,11 @@ static void names_lh_free(OBJ_NAME *onp, int type)
215 } 236 }
216 } 237 }
217 238
239static void name_funcs_free(NAME_FUNCS *ptr)
240 {
241 Free(ptr);
242 }
243
218void OBJ_NAME_cleanup(int type) 244void OBJ_NAME_cleanup(int type)
219 { 245 {
220 unsigned long down_load; 246 unsigned long down_load;
@@ -229,13 +255,9 @@ void OBJ_NAME_cleanup(int type)
229 if (type < 0) 255 if (type < 0)
230 { 256 {
231 lh_free(names_lh); 257 lh_free(names_lh);
232 sk_free(names_hash); 258 sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free);
233 sk_free(names_cmp);
234 sk_free(names_free);
235 names_lh=NULL; 259 names_lh=NULL;
236 names_hash=NULL; 260 name_funcs_stack = NULL;
237 names_cmp=NULL;
238 names_free=NULL;
239 } 261 }
240 else 262 else
241 names_lh->down_load=down_load; 263 names_lh->down_load=down_load;
diff --git a/src/lib/libssl/src/crypto/objects/obj_dat.c b/src/lib/libssl/src/crypto/objects/obj_dat.c
index d47b874399..da6df3762a 100644
--- a/src/lib/libssl/src/crypto/objects/obj_dat.c
+++ b/src/lib/libssl/src/crypto/objects/obj_dat.c
@@ -214,16 +214,12 @@ int OBJ_new_nid(int num)
214int OBJ_add_object(ASN1_OBJECT *obj) 214int OBJ_add_object(ASN1_OBJECT *obj)
215 { 215 {
216 ASN1_OBJECT *o; 216 ASN1_OBJECT *o;
217 ADDED_OBJ *ao[4],*aop; 217 ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
218 int i; 218 int i;
219 219
220 if (added == NULL) 220 if (added == NULL)
221 if (!init_added()) return(0); 221 if (!init_added()) return(0);
222 if ((o=OBJ_dup(obj)) == NULL) goto err; 222 if ((o=OBJ_dup(obj)) == NULL) goto err;
223 ao[ADDED_DATA]=NULL;
224 ao[ADDED_SNAME]=NULL;
225 ao[ADDED_LNAME]=NULL;
226 ao[ADDED_NID]=NULL;
227 ao[ADDED_NID]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ)); 223 ao[ADDED_NID]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ));
228 if ((o->length != 0) && (obj->data != NULL)) 224 if ((o->length != 0) && (obj->data != NULL))
229 ao[ADDED_DATA]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ)); 225 ao[ADDED_DATA]=(ADDED_OBJ *)Malloc(sizeof(ADDED_OBJ));
@@ -238,7 +234,7 @@ int OBJ_add_object(ASN1_OBJECT *obj)
238 { 234 {
239 ao[i]->type=i; 235 ao[i]->type=i;
240 ao[i]->obj=o; 236 ao[i]->obj=o;
241 aop=(ADDED_OBJ *)lh_insert(added,(char *)ao[i]); 237 aop=(ADDED_OBJ *)lh_insert(added,ao[i]);
242 /* memory leak, buit should not normally matter */ 238 /* memory leak, buit should not normally matter */
243 if (aop != NULL) 239 if (aop != NULL)
244 Free(aop); 240 Free(aop);
@@ -276,7 +272,7 @@ ASN1_OBJECT *OBJ_nid2obj(int n)
276 ad.type=ADDED_NID; 272 ad.type=ADDED_NID;
277 ad.obj= &ob; 273 ad.obj= &ob;
278 ob.nid=n; 274 ob.nid=n;
279 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 275 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
280 if (adp != NULL) 276 if (adp != NULL)
281 return(adp->obj); 277 return(adp->obj);
282 else 278 else
@@ -308,7 +304,7 @@ const char *OBJ_nid2sn(int n)
308 ad.type=ADDED_NID; 304 ad.type=ADDED_NID;
309 ad.obj= &ob; 305 ad.obj= &ob;
310 ob.nid=n; 306 ob.nid=n;
311 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 307 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
312 if (adp != NULL) 308 if (adp != NULL)
313 return(adp->obj->sn); 309 return(adp->obj->sn);
314 else 310 else
@@ -340,7 +336,7 @@ const char *OBJ_nid2ln(int n)
340 ad.type=ADDED_NID; 336 ad.type=ADDED_NID;
341 ad.obj= &ob; 337 ad.obj= &ob;
342 ob.nid=n; 338 ob.nid=n;
343 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 339 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
344 if (adp != NULL) 340 if (adp != NULL)
345 return(adp->obj->ln); 341 return(adp->obj->ln);
346 else 342 else
@@ -365,7 +361,7 @@ int OBJ_obj2nid(ASN1_OBJECT *a)
365 { 361 {
366 ad.type=ADDED_DATA; 362 ad.type=ADDED_DATA;
367 ad.obj=a; 363 ad.obj=a;
368 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 364 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
369 if (adp != NULL) return (adp->obj->nid); 365 if (adp != NULL) return (adp->obj->nid);
370 } 366 }
371 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ, 367 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,
@@ -504,7 +500,7 @@ int OBJ_ln2nid(const char *s)
504 { 500 {
505 ad.type=ADDED_LNAME; 501 ad.type=ADDED_LNAME;
506 ad.obj= &o; 502 ad.obj= &o;
507 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 503 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
508 if (adp != NULL) return (adp->obj->nid); 504 if (adp != NULL) return (adp->obj->nid);
509 } 505 }
510 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs,NUM_LN, 506 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs,NUM_LN,
@@ -523,7 +519,7 @@ int OBJ_sn2nid(const char *s)
523 { 519 {
524 ad.type=ADDED_SNAME; 520 ad.type=ADDED_SNAME;
525 ad.obj= &o; 521 ad.obj= &o;
526 adp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad); 522 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
527 if (adp != NULL) return (adp->obj->nid); 523 if (adp != NULL) return (adp->obj->nid);
528 } 524 }
529 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN, 525 op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN,
@@ -647,7 +643,7 @@ int OBJ_create(char *oid, char *sn, char *ln)
647 ok=OBJ_add_object(op); 643 ok=OBJ_add_object(op);
648err: 644err:
649 ASN1_OBJECT_free(op); 645 ASN1_OBJECT_free(op);
650 Free((char *)buf); 646 Free(buf);
651 return(ok); 647 return(ok);
652 } 648 }
653 649
diff --git a/src/lib/libssl/src/crypto/objects/obj_dat.pl b/src/lib/libssl/src/crypto/objects/obj_dat.pl
index 5043daef2a..e6e3c3b9c0 100644
--- a/src/lib/libssl/src/crypto/objects/obj_dat.pl
+++ b/src/lib/libssl/src/crypto/objects/obj_dat.pl
@@ -38,7 +38,10 @@ sub expand_obj
38 return(%objn); 38 return(%objn);
39 } 39 }
40 40
41while (<>) 41open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
42open (OUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
43
44while (<IN>)
42 { 45 {
43 next unless /^\#define\s+(\S+)\s+(.*)$/; 46 next unless /^\#define\s+(\S+)\s+(.*)$/;
44 $v=$1; 47 $v=$1;
@@ -55,6 +58,7 @@ while (<>)
55 $objd{$v}=$d; 58 $objd{$v}=$d;
56 } 59 }
57 } 60 }
61close IN;
58 62
59%ob=&expand_obj(*objd); 63%ob=&expand_obj(*objd);
60 64
@@ -132,7 +136,7 @@ foreach (sort obj_cmp @a)
132 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v)); 136 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v));
133 } 137 }
134 138
135print <<'EOF'; 139print OUT <<'EOF';
136/* lib/obj/obj_dat.h */ 140/* lib/obj/obj_dat.h */
137/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 141/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
138 * All rights reserved. 142 * All rights reserved.
@@ -193,21 +197,21 @@ print <<'EOF';
193 197
194/* THIS FILE IS GENERATED FROM Objects.h by obj_dat.pl via the 198/* THIS FILE IS GENERATED FROM Objects.h by obj_dat.pl via the
195 * following command: 199 * following command:
196 * perl obj_dat.pl < objects.h > obj_dat.h 200 * perl obj_dat.pl objects.h obj_dat.h
197 */ 201 */
198 202
199EOF 203EOF
200 204
201printf "#define NUM_NID %d\n",$n; 205printf OUT "#define NUM_NID %d\n",$n;
202printf "#define NUM_SN %d\n",$#sn+1; 206printf OUT "#define NUM_SN %d\n",$#sn+1;
203printf "#define NUM_LN %d\n",$#ln+1; 207printf OUT "#define NUM_LN %d\n",$#ln+1;
204printf "#define NUM_OBJ %d\n\n",$#ob+1; 208printf OUT "#define NUM_OBJ %d\n\n",$#ob+1;
205 209
206printf "static unsigned char lvalues[%d]={\n",$lvalues+1; 210printf OUT "static unsigned char lvalues[%d]={\n",$lvalues+1;
207print @lvalues; 211print OUT @lvalues;
208print "};\n\n"; 212print OUT "};\n\n";
209 213
210printf "static ASN1_OBJECT nid_objs[NUM_NID]={\n"; 214printf OUT "static ASN1_OBJECT nid_objs[NUM_NID]={\n";
211foreach (@out) 215foreach (@out)
212 { 216 {
213 if (length($_) > 75) 217 if (length($_) > 75)
@@ -218,30 +222,32 @@ foreach (@out)
218 $t=$out.$_.","; 222 $t=$out.$_.",";
219 if (length($t) > 70) 223 if (length($t) > 70)
220 { 224 {
221 print "$out\n"; 225 print OUT "$out\n";
222 $t="\t$_,"; 226 $t="\t$_,";
223 } 227 }
224 $out=$t; 228 $out=$t;
225 } 229 }
226 chop $out; 230 chop $out;
227 print "$out"; 231 print OUT "$out";
228 } 232 }
229 else 233 else
230 { print $_; } 234 { print OUT $_; }
231 } 235 }
232print "};\n\n"; 236print OUT "};\n\n";
237
238printf OUT "static ASN1_OBJECT *sn_objs[NUM_SN]={\n";
239print OUT @sn;
240print OUT "};\n\n";
233 241
234printf "static ASN1_OBJECT *sn_objs[NUM_SN]={\n"; 242printf OUT "static ASN1_OBJECT *ln_objs[NUM_LN]={\n";
235print @sn; 243print OUT @ln;
236print "};\n\n"; 244print OUT "};\n\n";
237 245
238printf "static ASN1_OBJECT *ln_objs[NUM_LN]={\n"; 246printf OUT "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n";
239print @ln; 247print OUT @ob;
240print "};\n\n"; 248print OUT "};\n\n";
241 249
242printf "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n"; 250close OUT;
243print @ob;
244print "};\n\n";
245 251
246sub der_it 252sub der_it
247 { 253 {
diff --git a/src/lib/libssl/src/crypto/objects/objects.h b/src/lib/libssl/src/crypto/objects/objects.h
index d03748e022..d1a5ad2502 100644
--- a/src/lib/libssl/src/crypto/objects/objects.h
+++ b/src/lib/libssl/src/crypto/objects/objects.h
@@ -110,10 +110,12 @@ extern "C" {
110#define NID_md5WithRSAEncryption 8 110#define NID_md5WithRSAEncryption 8
111#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L 111#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L
112 112
113#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES"
113#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" 114#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC"
114#define NID_pbeWithMD2AndDES_CBC 9 115#define NID_pbeWithMD2AndDES_CBC 9
115#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L 116#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L
116 117
118#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES"
117#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" 119#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC"
118#define NID_pbeWithMD5AndDES_CBC 10 120#define NID_pbeWithMD5AndDES_CBC 10
119#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L 121#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L
@@ -230,6 +232,7 @@ extern "C" {
230#define SN_idea_cbc "IDEA-CBC" 232#define SN_idea_cbc "IDEA-CBC"
231#define LN_idea_cbc "idea-cbc" 233#define LN_idea_cbc "idea-cbc"
232#define NID_idea_cbc 34 234#define NID_idea_cbc 34
235#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L
233 236
234#define SN_idea_cfb64 "IDEA-CFB" 237#define SN_idea_cfb64 "IDEA-CFB"
235#define LN_idea_cfb64 "idea-cfb" 238#define LN_idea_cfb64 "idea-cfb"
@@ -380,6 +383,7 @@ extern "C" {
380#define OBJ_dsa_2 OBJ_algorithm,12L 383#define OBJ_dsa_2 OBJ_algorithm,12L
381 384
382/* proposed by microsoft to RSA */ 385/* proposed by microsoft to RSA */
386#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64"
383#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" 387#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC"
384#define NID_pbeWithSHA1AndRC2_CBC 68 388#define NID_pbeWithSHA1AndRC2_CBC 68
385#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L 389#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L
@@ -499,6 +503,7 @@ extern "C" {
499#define SN_bf_cbc "BF-CBC" 503#define SN_bf_cbc "BF-CBC"
500#define LN_bf_cbc "bf-cbc" 504#define LN_bf_cbc "bf-cbc"
501#define NID_bf_cbc 91 505#define NID_bf_cbc 91
506#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L
502 507
503#define SN_bf_ecb "BF-ECB" 508#define SN_bf_ecb "BF-ECB"
504#define LN_bf_ecb "bf-ecb" 509#define LN_bf_ecb "bf-ecb"
@@ -627,7 +632,7 @@ extern "C" {
627#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L 632#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L
628 633
629/* The name should actually be rsaSignatureWithripemd160, but I'm going 634/* The name should actually be rsaSignatureWithripemd160, but I'm going
630 * to contiune using the convention I'm using with the other ciphers */ 635 * to continue using the convention I'm using with the other ciphers */
631#define SN_ripemd160WithRSA "RSA-RIPEMD160" 636#define SN_ripemd160WithRSA "RSA-RIPEMD160"
632#define LN_ripemd160WithRSA "ripemd160WithRSA" 637#define LN_ripemd160WithRSA "ripemd160WithRSA"
633#define NID_ripemd160WithRSA 119 638#define NID_ripemd160WithRSA 119
@@ -661,12 +666,12 @@ extern "C" {
661#define SN_rle_compression "RLE" 666#define SN_rle_compression "RLE"
662#define LN_rle_compression "run length compression" 667#define LN_rle_compression "run length compression"
663#define NID_rle_compression 124 668#define NID_rle_compression 124
664#define OBJ_rle_compression 1L,1L,1L,1L,666L.1L 669#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L
665 670
666#define SN_zlib_compression "ZLIB" 671#define SN_zlib_compression "ZLIB"
667#define LN_zlib_compression "zlib compression" 672#define LN_zlib_compression "zlib compression"
668#define NID_zlib_compression 125 673#define NID_zlib_compression 125
669#define OBJ_zlib_compression 1L,1L,1L,1L,666L.2L 674#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L
670 675
671#define SN_ext_key_usage "extendedKeyUsage" 676#define SN_ext_key_usage "extendedKeyUsage"
672#define LN_ext_key_usage "X509v3 Extended Key Usage" 677#define LN_ext_key_usage "X509v3 Extended Key Usage"
@@ -735,7 +740,7 @@ extern "C" {
735#define NID_ms_efs 138 740#define NID_ms_efs 138
736#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L 741#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L
737 742
738/* Addidional usage: Netscape */ 743/* Additional usage: Netscape */
739 744
740#define SN_ns_sgc "nsSGC" 745#define SN_ns_sgc "nsSGC"
741#define LN_ns_sgc "Netscape Server Gated Crypto" 746#define LN_ns_sgc "Netscape Server Gated Crypto"
@@ -767,26 +772,32 @@ extern "C" {
767#define OBJ_pkcs12 OBJ_pkcs,12L 772#define OBJ_pkcs12 OBJ_pkcs,12L
768#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 773#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1
769 774
775#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128"
770#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" 776#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4"
771#define NID_pbe_WithSHA1And128BitRC4 144 777#define NID_pbe_WithSHA1And128BitRC4 144
772#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L 778#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L
773 779
780#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40"
774#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" 781#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4"
775#define NID_pbe_WithSHA1And40BitRC4 145 782#define NID_pbe_WithSHA1And40BitRC4 145
776#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L 783#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L
777 784
785#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES"
778#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" 786#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC"
779#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 787#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146
780#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L 788#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L
781 789
790#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES"
782#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" 791#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC"
783#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 792#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147
784#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L 793#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L
785 794
795#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128"
786#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" 796#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC"
787#define NID_pbe_WithSHA1And128BitRC2_CBC 148 797#define NID_pbe_WithSHA1And128BitRC2_CBC 148
788#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L 798#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L
789 799
800#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40"
790#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" 801#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC"
791#define NID_pbe_WithSHA1And40BitRC2_CBC 149 802#define NID_pbe_WithSHA1And40BitRC2_CBC 149
792#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L 803#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L
@@ -876,20 +887,73 @@ extern "C" {
876#define SN_SMIMECapabilities "SMIME-CAPS" 887#define SN_SMIMECapabilities "SMIME-CAPS"
877#define LN_SMIMECapabilities "S/MIME Capabilities" 888#define LN_SMIMECapabilities "S/MIME Capabilities"
878#define NID_SMIMECapabilities 167 889#define NID_SMIMECapabilities 167
879#define OBJ_SMIMECapabilities OBJ_id_pkcs9,15L 890#define OBJ_SMIMECapabilities OBJ_pkcs9,15L
880 891
892#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64"
881#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" 893#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC"
882#define NID_pbeWithMD2AndRC2_CBC 168 894#define NID_pbeWithMD2AndRC2_CBC 168
883#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L 895#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L
884 896
897#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64"
885#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" 898#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC"
886#define NID_pbeWithMD5AndRC2_CBC 169 899#define NID_pbeWithMD5AndRC2_CBC 169
887#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L 900#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L
888 901
902#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES"
889#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" 903#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC"
890#define NID_pbeWithSHA1AndDES_CBC 170 904#define NID_pbeWithSHA1AndDES_CBC 170
891#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L 905#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L
892 906
907/* Extension request OIDs */
908
909#define LN_ms_ext_req "Microsoft Extension Request"
910#define SN_ms_ext_req "msExtReq"
911#define NID_ms_ext_req 171
912#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L
913
914#define LN_ext_req "Extension Request"
915#define SN_ext_req "extReq"
916#define NID_ext_req 172
917#define OBJ_ext_req OBJ_pkcs9,14L
918
919#define SN_name "name"
920#define LN_name "name"
921#define NID_name 173
922#define OBJ_name OBJ_X509,41L
923
924#define SN_dnQualifier "dnQualifier"
925#define LN_dnQualifier "dnQualifier"
926#define NID_dnQualifier 174
927#define OBJ_dnQualifier OBJ_X509,46L
928
929#define SN_id_pe "id-pe"
930#define NID_id_pe 175
931#define OBJ_id_pe OBJ_id_pkix,1L
932
933#define SN_id_ad "id-ad"
934#define NID_id_ad 176
935#define OBJ_id_ad OBJ_id_pkix,48L
936
937#define SN_info_access "authorityInfoAccess"
938#define LN_info_access "Authority Information Access"
939#define NID_info_access 177
940#define OBJ_info_access OBJ_id_pe,1L
941
942#define SN_ad_OCSP "OCSP"
943#define LN_ad_OCSP "OCSP"
944#define NID_ad_OCSP 178
945#define OBJ_ad_OCSP OBJ_id_ad,1L
946
947#define SN_ad_ca_issuers "caIssuers"
948#define LN_ad_ca_issuers "CA Issuers"
949#define NID_ad_ca_issuers 179
950#define OBJ_ad_ca_issuers OBJ_id_ad,2L
951
952#define SN_OSCP_sign "OCSPSigning"
953#define LN_OCSP_sign "OCSP Signing"
954#define NID_OCSP_sign 180
955#define OBJ_OCSP_sign OBJ_id_kp,9L
956
893#include <openssl/bio.h> 957#include <openssl/bio.h>
894#include <openssl/asn1.h> 958#include <openssl/asn1.h>
895 959
diff --git a/src/lib/libssl/src/crypto/opensslconf.h.in b/src/lib/libssl/src/crypto/opensslconf.h.in
index e4a8f8ad54..1b85ae5989 100644
--- a/src/lib/libssl/src/crypto/opensslconf.h.in
+++ b/src/lib/libssl/src/crypto/opensslconf.h.in
@@ -1,5 +1,4 @@
1/* crypto/opensslconf.h */ 1/* crypto/opensslconf.h.in */
2/* WARNING: This file is autogenerated by Configure */
3 2
4/* Generate 80386 code? */ 3/* Generate 80386 code? */
5#undef I386_ONLY 4#undef I386_ONLY
@@ -25,11 +24,25 @@
25#define RC2_INT unsigned int 24#define RC2_INT unsigned int
26#endif 25#endif
27 26
28#if defined(HEADER_RC4_H) && !defined(RC4_INT) 27#if defined(HEADER_RC4_H)
28#if !defined(RC4_INT)
29/* using int types make the structure larger but make the code faster 29/* using int types make the structure larger but make the code faster
30 * on most boxes I have tested - up to %20 faster. */ 30 * on most boxes I have tested - up to %20 faster. */
31/*
32 * I don't know what does "most" mean, but declaring "int" is a must on:
33 * - Intel P6 because partial register stalls are very expensive;
34 * - elder Alpha because it lacks byte load/store instructions;
35 */
31#define RC4_INT unsigned int 36#define RC4_INT unsigned int
32#endif 37#endif
38#if !defined(RC4_CHUNK)
39/*
40 * This enables code handling data aligned at natural CPU word
41 * boundary. See crypto/rc4/rc4_enc.c for further details.
42 */
43#undef RC4_CHUNK
44#endif
45#endif
33 46
34#if defined(HEADER_DES_H) && !defined(DES_LONG) 47#if defined(HEADER_DES_H) && !defined(DES_LONG)
35/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a 48/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
diff --git a/src/lib/libssl/src/crypto/opensslv.h b/src/lib/libssl/src/crypto/opensslv.h
index b841347f05..55d5d06cf5 100644
--- a/src/lib/libssl/src/crypto/opensslv.h
+++ b/src/lib/libssl/src/crypto/opensslv.h
@@ -7,15 +7,15 @@
7 * 0.9.3-dev 0x00903000 7 * 0.9.3-dev 0x00903000
8 * 0.9.3beta1 0x00903001 8 * 0.9.3beta1 0x00903001
9 * 0.9.3beta2-dev 0x00903002 9 * 0.9.3beta2-dev 0x00903002
10 * 0.9.3beta2 0x00903002 10 * 0.9.3beta2 0x00903002 (same as ...beta2-dev)
11 * 0.9.3 0x00903100 11 * 0.9.3 0x00903100
12 * 0.9.3a 0x00903101 12 * 0.9.3a 0x00903101
13 * 0.9.4 0x00904100 13 * 0.9.4 0x00904100
14 * 1.2.3z 0x1020311a 14 * 1.2.3z 0x1020311a
15 * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) 15 * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
16 */ 16 */
17#define OPENSSL_VERSION_NUMBER 0x00904100L 17#define OPENSSL_VERSION_NUMBER 0x00905100L
18#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.4 09 Aug 1999" 18#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.5 28 Feb 2000"
19#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 19#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
20 20
21#endif /* HEADER_OPENSSLV_H */ 21#endif /* HEADER_OPENSSLV_H */
diff --git a/src/lib/libssl/src/crypto/pem/pem.h b/src/lib/libssl/src/crypto/pem/pem.h
index fc333e42c8..e4bae0b4aa 100644
--- a/src/lib/libssl/src/crypto/pem/pem.h
+++ b/src/lib/libssl/src/crypto/pem/pem.h
@@ -103,13 +103,16 @@ extern "C" {
103 103
104#define PEM_STRING_X509_OLD "X509 CERTIFICATE" 104#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
105#define PEM_STRING_X509 "CERTIFICATE" 105#define PEM_STRING_X509 "CERTIFICATE"
106#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
106#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" 107#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
107#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" 108#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
108#define PEM_STRING_X509_CRL "X509 CRL" 109#define PEM_STRING_X509_CRL "X509 CRL"
109#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" 110#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
111#define PEM_STRING_PUBLIC "PUBLIC KEY"
110#define PEM_STRING_RSA "RSA PRIVATE KEY" 112#define PEM_STRING_RSA "RSA PRIVATE KEY"
111#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" 113#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
112#define PEM_STRING_DSA "DSA PRIVATE KEY" 114#define PEM_STRING_DSA "DSA PRIVATE KEY"
115#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
113#define PEM_STRING_PKCS7 "PKCS7" 116#define PEM_STRING_PKCS7 "PKCS7"
114#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" 117#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
115#define PEM_STRING_PKCS8INF "PRIVATE KEY" 118#define PEM_STRING_PKCS8INF "PRIVATE KEY"
@@ -528,7 +531,10 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str);
528 531
529DECLARE_PEM_rw(X509, X509) 532DECLARE_PEM_rw(X509, X509)
530 533
534DECLARE_PEM_rw(X509_AUX, X509)
535
531DECLARE_PEM_rw(X509_REQ, X509_REQ) 536DECLARE_PEM_rw(X509_REQ, X509_REQ)
537DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
532 538
533DECLARE_PEM_rw(X509_CRL, X509_CRL) 539DECLARE_PEM_rw(X509_CRL, X509_CRL)
534 540
@@ -545,6 +551,7 @@ DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
545DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) 551DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
546 552
547DECLARE_PEM_rw(RSAPublicKey, RSA) 553DECLARE_PEM_rw(RSAPublicKey, RSA)
554DECLARE_PEM_rw(RSA_PUBKEY, RSA)
548 555
549#endif 556#endif
550 557
@@ -552,6 +559,8 @@ DECLARE_PEM_rw(RSAPublicKey, RSA)
552 559
553DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) 560DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
554 561
562DECLARE_PEM_rw(DSA_PUBKEY, DSA)
563
555DECLARE_PEM_rw(DSAparams, DSA) 564DECLARE_PEM_rw(DSAparams, DSA)
556 565
557#endif 566#endif
@@ -564,10 +573,36 @@ DECLARE_PEM_rw(DHparams, DH)
564 573
565DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) 574DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
566 575
576DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
577
578int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
579 char *kstr, int klen,
580 pem_password_cb *cb, void *u);
567int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, 581int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
568 char *, int, pem_password_cb *, void *); 582 char *, int, pem_password_cb *, void *);
583int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
584 char *kstr, int klen,
585 pem_password_cb *cb, void *u);
586int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
587 char *kstr, int klen,
588 pem_password_cb *cb, void *u);
589EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
590
591int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
592 char *kstr, int klen,
593 pem_password_cb *cb, void *u);
594int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
595 char *kstr, int klen,
596 pem_password_cb *cb, void *u);
597int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
598 char *kstr, int klen,
599 pem_password_cb *cb, void *u);
600
601EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
602
569int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, 603int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
570 char *kstr,int klen, pem_password_cb *cd, void *u); 604 char *kstr,int klen, pem_password_cb *cd, void *u);
605
571#endif /* SSLEAY_MACROS */ 606#endif /* SSLEAY_MACROS */
572 607
573 608
@@ -579,6 +614,8 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
579/* Error codes for the PEM functions. */ 614/* Error codes for the PEM functions. */
580 615
581/* Function codes. */ 616/* Function codes. */
617#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
618#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
582#define PEM_F_DEF_CALLBACK 100 619#define PEM_F_DEF_CALLBACK 100
583#define PEM_F_LOAD_IV 101 620#define PEM_F_LOAD_IV 101
584#define PEM_F_PEM_ASN1_READ 102 621#define PEM_F_PEM_ASN1_READ 102
@@ -586,6 +623,7 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
586#define PEM_F_PEM_ASN1_WRITE 104 623#define PEM_F_PEM_ASN1_WRITE 104
587#define PEM_F_PEM_ASN1_WRITE_BIO 105 624#define PEM_F_PEM_ASN1_WRITE_BIO 105
588#define PEM_F_PEM_DO_HEADER 106 625#define PEM_F_PEM_DO_HEADER 106
626#define PEM_F_PEM_F_DO_PK8KEY_FP 122
589#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 627#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118
590#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 628#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
591#define PEM_F_PEM_READ 108 629#define PEM_F_PEM_READ 108
diff --git a/src/lib/libssl/src/crypto/pem/pem_all.c b/src/lib/libssl/src/crypto/pem/pem_all.c
index bc473f3cff..dc9c35b4b4 100644
--- a/src/lib/libssl/src/crypto/pem/pem_all.c
+++ b/src/lib/libssl/src/crypto/pem/pem_all.c
@@ -65,10 +65,21 @@
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
69static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa);
70#endif
71#ifndef NO_DSA
72static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa);
73#endif
74
68IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509) 75IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509)
69 76
77IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX)
78
70IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) 79IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ)
71 80
81IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ)
82
72IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL) 83IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL)
73 84
74IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7) 85IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7)
@@ -82,15 +93,92 @@ IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF,
82 93
83#ifndef NO_RSA 94#ifndef NO_RSA
84 95
85IMPLEMENT_PEM_rw_cb(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) 96/* We treat RSA or DSA private keys as a special case.
97 *
98 * For private keys we read in an EVP_PKEY structure with
99 * PEM_read_bio_PrivateKey() and extract the relevant private
100 * key: this means can handle "traditional" and PKCS#8 formats
101 * transparently.
102 */
103
104static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa)
105{
106 RSA *rtmp;
107 if(!key) return NULL;
108 rtmp = EVP_PKEY_get1_RSA(key);
109 EVP_PKEY_free(key);
110 if(!rtmp) return NULL;
111 if(rsa) {
112 RSA_free(*rsa);
113 *rsa = rtmp;
114 }
115 return rtmp;
116}
117
118RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb,
119 void *u)
120{
121 EVP_PKEY *pktmp;
122 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
123 return pkey_get_rsa(pktmp, rsa);
124}
125
126#ifndef NO_FP_API
127
128RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb,
129 void *u)
130{
131 EVP_PKEY *pktmp;
132 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
133 return pkey_get_rsa(pktmp, rsa);
134}
135
136#endif
86 137
138IMPLEMENT_PEM_write_cb(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
87IMPLEMENT_PEM_rw(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) 139IMPLEMENT_PEM_rw(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
140IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
88 141
89#endif 142#endif
90 143
91#ifndef NO_DSA 144#ifndef NO_DSA
92 145
93IMPLEMENT_PEM_rw_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) 146static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa)
147{
148 DSA *dtmp;
149 if(!key) return NULL;
150 dtmp = EVP_PKEY_get1_DSA(key);
151 EVP_PKEY_free(key);
152 if(!dtmp) return NULL;
153 if(dsa) {
154 DSA_free(*dsa);
155 *dsa = dtmp;
156 }
157 return dtmp;
158}
159
160DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb,
161 void *u)
162{
163 EVP_PKEY *pktmp;
164 pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
165 return pkey_get_dsa(pktmp, dsa);
166}
167
168IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
169IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
170
171#ifndef NO_FP_API
172
173DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb,
174 void *u)
175{
176 EVP_PKEY *pktmp;
177 pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
178 return pkey_get_dsa(pktmp, dsa);
179}
180
181#endif
94 182
95IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams) 183IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams)
96 184
@@ -111,3 +199,5 @@ IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
111 */ 199 */
112IMPLEMENT_PEM_read(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey) 200IMPLEMENT_PEM_read(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey)
113IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey) 201IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey)
202
203IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY)
diff --git a/src/lib/libssl/src/crypto/pem/pem_err.c b/src/lib/libssl/src/crypto/pem/pem_err.c
index fa70f60998..642129da20 100644
--- a/src/lib/libssl/src/crypto/pem/pem_err.c
+++ b/src/lib/libssl/src/crypto/pem/pem_err.c
@@ -65,6 +65,8 @@
65#ifndef NO_ERR 65#ifndef NO_ERR
66static ERR_STRING_DATA PEM_str_functs[]= 66static ERR_STRING_DATA PEM_str_functs[]=
67 { 67 {
68{ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_BIO,0), "d2i_PKCS8PrivateKey_bio"},
69{ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_FP,0), "d2i_PKCS8PrivateKey_fp"},
68{ERR_PACK(0,PEM_F_DEF_CALLBACK,0), "DEF_CALLBACK"}, 70{ERR_PACK(0,PEM_F_DEF_CALLBACK,0), "DEF_CALLBACK"},
69{ERR_PACK(0,PEM_F_LOAD_IV,0), "LOAD_IV"}, 71{ERR_PACK(0,PEM_F_LOAD_IV,0), "LOAD_IV"},
70{ERR_PACK(0,PEM_F_PEM_ASN1_READ,0), "PEM_ASN1_read"}, 72{ERR_PACK(0,PEM_F_PEM_ASN1_READ,0), "PEM_ASN1_read"},
@@ -72,6 +74,7 @@ static ERR_STRING_DATA PEM_str_functs[]=
72{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE,0), "PEM_ASN1_write"}, 74{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE,0), "PEM_ASN1_write"},
73{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE_BIO,0), "PEM_ASN1_write_bio"}, 75{ERR_PACK(0,PEM_F_PEM_ASN1_WRITE_BIO,0), "PEM_ASN1_write_bio"},
74{ERR_PACK(0,PEM_F_PEM_DO_HEADER,0), "PEM_do_header"}, 76{ERR_PACK(0,PEM_F_PEM_DO_HEADER,0), "PEM_do_header"},
77{ERR_PACK(0,PEM_F_PEM_F_DO_PK8KEY_FP,0), "PEM_F_DO_PK8KEY_FP"},
75{ERR_PACK(0,PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY,0), "PEM_F_PEM_WRITE_PKCS8PRIVATEKEY"}, 78{ERR_PACK(0,PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY,0), "PEM_F_PEM_WRITE_PKCS8PRIVATEKEY"},
76{ERR_PACK(0,PEM_F_PEM_GET_EVP_CIPHER_INFO,0), "PEM_get_EVP_CIPHER_INFO"}, 79{ERR_PACK(0,PEM_F_PEM_GET_EVP_CIPHER_INFO,0), "PEM_get_EVP_CIPHER_INFO"},
77{ERR_PACK(0,PEM_F_PEM_READ,0), "PEM_read"}, 80{ERR_PACK(0,PEM_F_PEM_READ,0), "PEM_read"},
diff --git a/src/lib/libssl/src/crypto/pem/pem_info.c b/src/lib/libssl/src/crypto/pem/pem_info.c
index fec18a4c2e..b65239a920 100644
--- a/src/lib/libssl/src/crypto/pem/pem_info.c
+++ b/src/lib/libssl/src/crypto/pem/pem_info.c
@@ -132,6 +132,17 @@ start:
132 } 132 }
133 pp=(char **)&(xi->x509); 133 pp=(char **)&(xi->x509);
134 } 134 }
135 else if ((strcmp(name,PEM_STRING_X509_TRUSTED) == 0))
136 {
137 d2i=(char *(*)())d2i_X509_AUX;
138 if (xi->x509 != NULL)
139 {
140 if (!sk_X509_INFO_push(ret,xi)) goto err;
141 if ((xi=X509_INFO_new()) == NULL) goto err;
142 goto start;
143 }
144 pp=(char **)&(xi->x509);
145 }
135 else if (strcmp(name,PEM_STRING_X509_CRL) == 0) 146 else if (strcmp(name,PEM_STRING_X509_CRL) == 0)
136 { 147 {
137 d2i=(char *(*)())d2i_X509_CRL; 148 d2i=(char *(*)())d2i_X509_CRL;
diff --git a/src/lib/libssl/src/crypto/pem/pem_lib.c b/src/lib/libssl/src/crypto/pem/pem_lib.c
index 90f02011ba..072211ba0f 100644
--- a/src/lib/libssl/src/crypto/pem/pem_lib.c
+++ b/src/lib/libssl/src/crypto/pem/pem_lib.c
@@ -75,8 +75,17 @@ const char *PEM_version="PEM" OPENSSL_VERSION_PTEXT;
75 75
76static int def_callback(char *buf, int num, int w, void *userdata); 76static int def_callback(char *buf, int num, int w, void *userdata);
77static int load_iv(unsigned char **fromp,unsigned char *to, int num); 77static int load_iv(unsigned char **fromp,unsigned char *to, int num);
78 78static int check_pem(const char *nm, const char *name);
79static int def_callback(char *buf, int num, int w, void *userdata) 79static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
80 int nid, const EVP_CIPHER *enc,
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)
80 { 89 {
81#ifdef NO_FP_API 90#ifdef NO_FP_API
82 /* We should not ever call the default callback routine from 91 /* We should not ever call the default callback routine from
@@ -86,6 +95,12 @@ static int def_callback(char *buf, int num, int w, void *userdata)
86#else 95#else
87 int i,j; 96 int i,j;
88 const char *prompt; 97 const char *prompt;
98 if(key) {
99 i=strlen(key);
100 i=(i > num)?num:i;
101 memcpy(buf,key,i);
102 return(i);
103 }
89 104
90 prompt=EVP_get_pw_prompt(); 105 prompt=EVP_get_pw_prompt();
91 if (prompt == NULL) 106 if (prompt == NULL)
@@ -168,6 +183,47 @@ char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x,
168 } 183 }
169#endif 184#endif
170 185
186static int check_pem(const char *nm, const char *name)
187{
188 /* Normal matching nm and name */
189 if (!strcmp(nm,name)) return 1;
190
191 /* Make PEM_STRING_EVP_PKEY match any private key */
192
193 if(!strcmp(nm,PEM_STRING_PKCS8) &&
194 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
195
196 if(!strcmp(nm,PEM_STRING_PKCS8INF) &&
197 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
198
199 if(!strcmp(nm,PEM_STRING_RSA) &&
200 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
201
202 if(!strcmp(nm,PEM_STRING_DSA) &&
203 !strcmp(name,PEM_STRING_EVP_PKEY)) return 1;
204
205 /* Permit older strings */
206
207 if(!strcmp(nm,PEM_STRING_X509_OLD) &&
208 !strcmp(name,PEM_STRING_X509)) return 1;
209
210 if(!strcmp(nm,PEM_STRING_X509_REQ_OLD) &&
211 !strcmp(name,PEM_STRING_X509_REQ)) return 1;
212
213 /* Allow normal certs to be read as trusted certs */
214 if(!strcmp(nm,PEM_STRING_X509) &&
215 !strcmp(name,PEM_STRING_X509_TRUSTED)) return 1;
216
217 if(!strcmp(nm,PEM_STRING_X509_OLD) &&
218 !strcmp(name,PEM_STRING_X509_TRUSTED)) return 1;
219
220 /* Some CAs use PKCS#7 with CERTIFICATE headers */
221 if(!strcmp(nm, PEM_STRING_X509) &&
222 !strcmp(name, PEM_STRING_PKCS7)) return 1;
223
224 return 0;
225}
226
171char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, 227char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
172 pem_password_cb *cb, void *u) 228 pem_password_cb *cb, void *u)
173 { 229 {
@@ -179,22 +235,13 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
179 235
180 for (;;) 236 for (;;)
181 { 237 {
182 if (!PEM_read_bio(bp,&nm,&header,&data,&len)) return(NULL); 238 if (!PEM_read_bio(bp,&nm,&header,&data,&len)) {
183 if ( (strcmp(nm,name) == 0) || 239 if(ERR_GET_REASON(ERR_peek_error()) ==
184 ((strcmp(nm,PEM_STRING_RSA) == 0) && 240 PEM_R_NO_START_LINE)
185 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) || 241 ERR_add_error_data(2, "Expecting: ", name);
186 ((strcmp(nm,PEM_STRING_DSA) == 0) && 242 return(NULL);
187 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) || 243 }
188 ((strcmp(nm,PEM_STRING_PKCS8) == 0) && 244 if(check_pem(nm, name)) break;
189 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||
190 ((strcmp(nm,PEM_STRING_PKCS8INF) == 0) &&
191 (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||
192 ((strcmp(nm,PEM_STRING_X509_OLD) == 0) &&
193 (strcmp(name,PEM_STRING_X509) == 0)) ||
194 ((strcmp(nm,PEM_STRING_X509_REQ_OLD) == 0) &&
195 (strcmp(name,PEM_STRING_X509_REQ) == 0))
196 )
197 break;
198 Free(nm); 245 Free(nm);
199 Free(header); 246 Free(header);
200 Free(data); 247 Free(data);
@@ -218,7 +265,7 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
218 X509_SIG *p8; 265 X509_SIG *p8;
219 int klen; 266 int klen;
220 char psbuf[PEM_BUFSIZE]; 267 char psbuf[PEM_BUFSIZE];
221 p8 = d2i_X509_SIG((X509_SIG **)x, &p, len); 268 p8 = d2i_X509_SIG(NULL, &p, len);
222 if(!p8) goto p8err; 269 if(!p8) goto p8err;
223 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u); 270 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u);
224 else klen=def_callback(psbuf,PEM_BUFSIZE,0,u); 271 else klen=def_callback(psbuf,PEM_BUFSIZE,0,u);
@@ -231,6 +278,10 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
231 X509_SIG_free(p8); 278 X509_SIG_free(p8);
232 if(!p8inf) goto p8err; 279 if(!p8inf) goto p8err;
233 ret = (char *)EVP_PKCS82PKEY(p8inf); 280 ret = (char *)EVP_PKCS82PKEY(p8inf);
281 if(x) {
282 if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
283 *x = ret;
284 }
234 PKCS8_PRIV_KEY_INFO_free(p8inf); 285 PKCS8_PRIV_KEY_INFO_free(p8inf);
235 } 286 }
236 } else ret=d2i(x,&p,len); 287 } else ret=d2i(x,&p,len);
@@ -321,8 +372,9 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
321#endif 372#endif
322 kstr=(unsigned char *)buf; 373 kstr=(unsigned char *)buf;
323 } 374 }
324 RAND_seed(data,i);/* put in the RSA key. */ 375 RAND_add(data,i,0);/* put in the RSA key. */
325 RAND_bytes(iv,8); /* Generate a salt */ 376 if (RAND_bytes(iv,8) <= 0) /* Generate a salt */
377 goto err;
326 /* The 'iv' is used as the iv and as a salt. It is 378 /* The 'iv' is used as the iv and as a salt. It is
327 * NOT taken from the BytesToKey function */ 379 * NOT taken from the BytesToKey function */
328 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL); 380 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL);
@@ -743,16 +795,44 @@ err:
743 return(0); 795 return(0);
744 } 796 }
745 797
746/* This function writes a private key in PKCS#8 format: it is a "drop in" 798/* These functions write a private key in PKCS#8 format: it is a "drop in"
747 * replacement for PEM_write_bio_PrivateKey(). As usual if 'enc' is NULL then 799 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
748 * it uses the unencrypted private key form. It uses PKCS#5 v2.0 password based 800 * is NULL then it uses the unencrypted private key form. The 'nid' versions
749 * encryption algorithms. 801 * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0.
750 */ 802 */
751 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
752int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, 811int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
753 char *kstr, int klen, 812 char *kstr, int klen,
754 pem_password_cb *cb, void *u) 813 pem_password_cb *cb, void *u)
755{ 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{
756 X509_SIG *p8; 836 X509_SIG *p8;
757 PKCS8_PRIV_KEY_INFO *p8inf; 837 PKCS8_PRIV_KEY_INFO *p8inf;
758 char buf[PEM_BUFSIZE]; 838 char buf[PEM_BUFSIZE];
@@ -762,7 +842,7 @@ int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
762 PEM_R_ERROR_CONVERTING_PRIVATE_KEY); 842 PEM_R_ERROR_CONVERTING_PRIVATE_KEY);
763 return 0; 843 return 0;
764 } 844 }
765 if(enc) { 845 if(enc || (nid != -1)) {
766 if(!kstr) { 846 if(!kstr) {
767 if(!cb) klen = def_callback(buf, PEM_BUFSIZE, 1, u); 847 if(!cb) klen = def_callback(buf, PEM_BUFSIZE, 1, u);
768 else klen = cb(buf, PEM_BUFSIZE, 1, u); 848 else klen = cb(buf, PEM_BUFSIZE, 1, u);
@@ -775,29 +855,109 @@ int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
775 855
776 kstr = buf; 856 kstr = buf;
777 } 857 }
778 p8 = PKCS8_encrypt(-1, enc, kstr, klen, NULL, 0, 0, p8inf); 858 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);
779 if(kstr == buf) memset(buf, 0, klen); 859 if(kstr == buf) memset(buf, 0, klen);
780 PKCS8_PRIV_KEY_INFO_free(p8inf); 860 PKCS8_PRIV_KEY_INFO_free(p8inf);
781 ret = PEM_write_bio_PKCS8(bp, p8); 861 if(isder) ret = i2d_PKCS8_bio(bp, p8);
862 else ret = PEM_write_bio_PKCS8(bp, p8);
782 X509_SIG_free(p8); 863 X509_SIG_free(p8);
783 return ret; 864 return ret;
784 } else { 865 } else {
785 ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf); 866 if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
867 else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf);
786 PKCS8_PRIV_KEY_INFO_free(p8inf); 868 PKCS8_PRIV_KEY_INFO_free(p8inf);
787 return ret; 869 return ret;
788 } 870 }
789} 871}
790 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
791int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, 929int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
792 char *kstr, int klen, pem_password_cb *cb, void *u) 930 char *kstr, int klen, pem_password_cb *cb, void *u)
793{ 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{
794 BIO *bp; 939 BIO *bp;
795 int ret; 940 int ret;
796 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { 941 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
797 PEMerr(PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY,ERR_R_BUF_LIB); 942 PEMerr(PEM_F_PEM_F_DO_PK8KEY_FP,ERR_R_BUF_LIB);
798 return(0); 943 return(0);
799 } 944 }
800 ret = PEM_write_bio_PKCS8PrivateKey(bp, x, enc, kstr, klen, cb, u); 945 ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u);
801 BIO_free(bp); 946 BIO_free(bp);
802 return ret; 947 return ret;
803} 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_seal.c b/src/lib/libssl/src/crypto/pem/pem_seal.c
index 23f95beb1e..126e29d375 100644
--- a/src/lib/libssl/src/crypto/pem/pem_seal.c
+++ b/src/lib/libssl/src/crypto/pem/pem_seal.c
@@ -175,4 +175,10 @@ err:
175 if (s != NULL) Free(s); 175 if (s != NULL) Free(s);
176 return(ret); 176 return(ret);
177 } 177 }
178#else /* !NO_RSA */
179
180# if PEDANTIC
181static void *dummy=&dummy;
182# endif
183
178#endif 184#endif
diff --git a/src/lib/libssl/src/crypto/perlasm/x86ms.pl b/src/lib/libssl/src/crypto/perlasm/x86ms.pl
index 51dcce067f..252a57bdb5 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86ms.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86ms.pl
@@ -341,7 +341,14 @@ sub main'set_label
341 $label{$_[0]}="${label}${_[0]}"; 341 $label{$_[0]}="${label}${_[0]}";
342 $label++; 342 $label++;
343 } 343 }
344 push(@out,"$label{$_[0]}:\n"); 344 if((defined $_[1]) && ($_[1] == 1))
345 {
346 push(@out,"$label{$_[0]}::\n");
347 }
348 else
349 {
350 push(@out,"$label{$_[0]}:\n");
351 }
345 } 352 }
346 353
347sub main'data_word 354sub main'data_word
diff --git a/src/lib/libssl/src/crypto/perlasm/x86unix.pl b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
index 8c456b14af..60d75f5ce4 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86unix.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
@@ -368,10 +368,10 @@ sub main'function_end_B
368 368
369 $func=$under.$func; 369 $func=$under.$func;
370 370
371 push(@out,".${func}_end:\n"); 371 push(@out,".L_${func}_end:\n");
372 if ($main'cpp) 372 if ($main'cpp)
373 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); } 373 { push(@out,"\tSIZE($func,.L_${func}_end-$func)\n"); }
374 else { push(@out,"\t.size\t$func,.${func}_end-$func\n"); } 374 else { push(@out,"\t.size\t$func,.L_${func}_end-$func\n"); }
375 push(@out,".ident \"desasm.pl\"\n"); 375 push(@out,".ident \"desasm.pl\"\n");
376 $stack=0; 376 $stack=0;
377 %label=(); 377 %label=();
diff --git a/src/lib/libssl/src/crypto/pkcs12/Makefile.ssl b/src/lib/libssl/src/crypto/pkcs12/Makefile.ssl
index 7b0c65fad9..5716f608b6 100644
--- a/src/lib/libssl/src/crypto/pkcs12/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/pkcs12/Makefile.ssl
@@ -1,5 +1,5 @@
1# 1#
2# SSLeay/crypto/asn1/Makefile 2# SSLeay/crypto/pkcs12/Makefile
3# 3#
4 4
5DIR= pkcs12 5DIR= pkcs12
@@ -24,10 +24,10 @@ APPS=
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c p12_decr.c \ 25LIBSRC= p12_add.c p12_attr.c p12_bags.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\ 26 p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c p12_mutl.c\
27 p12_sbag.c p12_utl.c pk12err.c 27 p12_sbag.c p12_utl.c p12_npas.c pk12err.c
28LIBOBJ= p12_add.o p12_attr.o p12_bags.o p12_crpt.o p12_crt.o p12_decr.o \ 28LIBOBJ= p12_add.o p12_attr.o p12_bags.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\ 29 p12_init.o p12_key.o p12_kiss.o p12_lib.o p12_mac.o p12_mutl.o\
30 p12_sbag.o p12_utl.o pk12err.o 30 p12_sbag.o p12_utl.o p12_npas.o pk12err.o
31 31
32SRC= $(LIBSRC) 32SRC= $(LIBSRC)
33 33
@@ -293,6 +293,23 @@ p12_mutl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
293p12_mutl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 293p12_mutl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
294p12_mutl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 294p12_mutl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
295p12_mutl.o: ../cryptlib.h 295p12_mutl.o: ../cryptlib.h
296p12_npas.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
297p12_npas.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
298p12_npas.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
299p12_npas.o: ../../include/openssl/des.h ../../include/openssl/dh.h
300p12_npas.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
301p12_npas.o: ../../include/openssl/err.h ../../include/openssl/evp.h
302p12_npas.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
303p12_npas.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
304p12_npas.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
305p12_npas.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h
306p12_npas.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
307p12_npas.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
308p12_npas.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
309p12_npas.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
310p12_npas.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
311p12_npas.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
312p12_npas.o: ../../include/openssl/x509_vfy.h
296p12_sbag.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 313p12_sbag.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
297p12_sbag.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 314p12_sbag.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
298p12_sbag.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 315p12_sbag.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_add.c b/src/lib/libssl/src/crypto/pkcs12/p12_add.c
index ae3d9de3b4..d045cbba8d 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_add.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_add.c
@@ -133,7 +133,7 @@ PKCS7 *PKCS12_pack_p7data (STACK *sk)
133 return NULL; 133 return NULL;
134 } 134 }
135 p7->type = OBJ_nid2obj(NID_pkcs7_data); 135 p7->type = OBJ_nid2obj(NID_pkcs7_data);
136 if (!(p7->d.data = ASN1_OCTET_STRING_new())) { 136 if (!(p7->d.data = M_ASN1_OCTET_STRING_new())) {
137 PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); 137 PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE);
138 return NULL; 138 return NULL;
139 } 139 }
@@ -157,20 +157,18 @@ PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,
157 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 157 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
158 return NULL; 158 return NULL;
159 } 159 }
160 p7->type = OBJ_nid2obj(NID_pkcs7_encrypted); 160 if(!PKCS7_set_type(p7, NID_pkcs7_encrypted)) {
161 if (!(p7->d.encrypted = PKCS7_ENCRYPT_new ())) { 161 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA,
162 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 162 PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE);
163 return NULL; 163 return NULL;
164 } 164 }
165 ASN1_INTEGER_set (p7->d.encrypted->version, 0);
166 p7->d.encrypted->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data);
167 if (!(pbe = PKCS5_pbe_set (pbe_nid, iter, salt, saltlen))) { 165 if (!(pbe = PKCS5_pbe_set (pbe_nid, iter, salt, saltlen))) {
168 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 166 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
169 return NULL; 167 return NULL;
170 } 168 }
171 X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); 169 X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm);
172 p7->d.encrypted->enc_data->algorithm = pbe; 170 p7->d.encrypted->enc_data->algorithm = pbe;
173 ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data); 171 M_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data);
174 if (!(p7->d.encrypted->enc_data->enc_data = 172 if (!(p7->d.encrypted->enc_data->enc_data =
175 PKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen, 173 PKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen,
176 (char *)bags, 1))) { 174 (char *)bags, 1))) {
@@ -191,24 +189,28 @@ X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
191 189
192 if (!(p8 = X509_SIG_new())) { 190 if (!(p8 = X509_SIG_new())) {
193 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); 191 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE);
194 return NULL; 192 goto err;
195 } 193 }
196 194
197 if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen); 195 if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen);
198 else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); 196 else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
199 if(!pbe) { 197 if(!pbe) {
200 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); 198 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB);
201 return NULL; 199 goto err;
202 } 200 }
203 X509_ALGOR_free(p8->algor); 201 X509_ALGOR_free(p8->algor);
204 p8->algor = pbe; 202 p8->algor = pbe;
205 ASN1_OCTET_STRING_free(p8->digest); 203 M_ASN1_OCTET_STRING_free(p8->digest);
206 if (!(p8->digest = 204 if (!(p8->digest =
207 PKCS12_i2d_encrypt (pbe, i2d_PKCS8_PRIV_KEY_INFO, pass, passlen, 205 PKCS12_i2d_encrypt (pbe, i2d_PKCS8_PRIV_KEY_INFO, pass, passlen,
208 (char *)p8inf, 0))) { 206 (char *)p8inf, 0))) {
209 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR); 207 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR);
210 return NULL; 208 goto err;
211 } 209 }
212 210
213 return p8; 211 return p8;
212
213 err:
214 X509_SIG_free(p8);
215 return NULL;
214} 216}
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_attr.c b/src/lib/libssl/src/crypto/pkcs12/p12_attr.c
index 31c9782b77..f559351d18 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_attr.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_attr.c
@@ -73,11 +73,11 @@ int PKCS12_add_localkeyid (PKCS12_SAFEBAG *bag, unsigned char *name,
73 return 0; 73 return 0;
74 } 74 }
75 keyid->type = V_ASN1_OCTET_STRING; 75 keyid->type = V_ASN1_OCTET_STRING;
76 if (!(oct = ASN1_OCTET_STRING_new())) { 76 if (!(oct = M_ASN1_OCTET_STRING_new())) {
77 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE); 77 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
78 return 0; 78 return 0;
79 } 79 }
80 if (!ASN1_OCTET_STRING_set(oct, name, namelen)) { 80 if (!M_ASN1_OCTET_STRING_set(oct, name, namelen)) {
81 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE); 81 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
82 return 0; 82 return 0;
83 } 83 }
@@ -115,11 +115,11 @@ int PKCS8_add_keyusage (PKCS8_PRIV_KEY_INFO *p8, int usage)
115 return 0; 115 return 0;
116 } 116 }
117 keyid->type = V_ASN1_BIT_STRING; 117 keyid->type = V_ASN1_BIT_STRING;
118 if (!(bstr = ASN1_BIT_STRING_new())) { 118 if (!(bstr = M_ASN1_BIT_STRING_new())) {
119 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE); 119 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
120 return 0; 120 return 0;
121 } 121 }
122 if (!ASN1_BIT_STRING_set(bstr, &us_val, 1)) { 122 if (!M_ASN1_BIT_STRING_set(bstr, &us_val, 1)) {
123 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE); 123 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
124 return 0; 124 return 0;
125 } 125 }
@@ -176,7 +176,7 @@ int PKCS12_add_friendlyname_uni (PKCS12_SAFEBAG *bag,
176 return 0; 176 return 0;
177 } 177 }
178 fname->type = V_ASN1_BMPSTRING; 178 fname->type = V_ASN1_BMPSTRING;
179 if (!(bmp = ASN1_BMPSTRING_new())) { 179 if (!(bmp = M_ASN1_BMPSTRING_new())) {
180 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI, 180 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI,
181 ERR_R_MALLOC_FAILURE); 181 ERR_R_MALLOC_FAILURE);
182 return 0; 182 return 0;
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_bags.c b/src/lib/libssl/src/crypto/pkcs12/p12_bags.c
index d6eab92c83..c358b06735 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_bags.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_bags.c
@@ -171,15 +171,15 @@ void PKCS12_BAGS_free (PKCS12_BAGS *a)
171 switch (OBJ_obj2nid(a->type)) { 171 switch (OBJ_obj2nid(a->type)) {
172 172
173 case NID_x509Certificate: 173 case NID_x509Certificate:
174 ASN1_OCTET_STRING_free (a->value.x509cert); 174 M_ASN1_OCTET_STRING_free (a->value.x509cert);
175 break; 175 break;
176 176
177 case NID_x509Crl: 177 case NID_x509Crl:
178 ASN1_OCTET_STRING_free (a->value.x509crl); 178 M_ASN1_OCTET_STRING_free (a->value.x509crl);
179 break; 179 break;
180 180
181 case NID_sdsiCertificate: 181 case NID_sdsiCertificate:
182 ASN1_IA5STRING_free (a->value.sdsicert); 182 M_ASN1_IA5STRING_free (a->value.sdsicert);
183 break; 183 break;
184 184
185 default: 185 default:
@@ -188,5 +188,5 @@ void PKCS12_BAGS_free (PKCS12_BAGS *a)
188 } 188 }
189 189
190 ASN1_OBJECT_free (a->type); 190 ASN1_OBJECT_free (a->type);
191 Free ((char *)a); 191 Free (a);
192} 192}
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c b/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
index 6de6f8128f..7b96584f07 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
@@ -70,10 +70,12 @@ EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC4, EVP_rc4(), EVP_sha1(),
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
73EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC, 74EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
74 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); 75 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
75EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC, 76EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC,
76 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); 77 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
78#endif
77#ifndef NO_RC2 79#ifndef NO_RC2
78EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(), 80EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(),
79 EVP_sha1(), PKCS12_PBE_keyivgen); 81 EVP_sha1(), PKCS12_PBE_keyivgen);
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_decr.c b/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
index d3d288e187..4be44eac50 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
@@ -155,7 +155,7 @@ ASN1_OCTET_STRING *PKCS12_i2d_encrypt (X509_ALGOR *algor, int (*i2d)(),
155 ASN1_OCTET_STRING *oct; 155 ASN1_OCTET_STRING *oct;
156 unsigned char *in, *p; 156 unsigned char *in, *p;
157 int inlen; 157 int inlen;
158 if (!(oct = ASN1_OCTET_STRING_new ())) { 158 if (!(oct = M_ASN1_OCTET_STRING_new ())) {
159 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE); 159 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE);
160 return NULL; 160 return NULL;
161 } 161 }
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_init.c b/src/lib/libssl/src/crypto/pkcs12/p12_init.c
index dc6ab41db8..d5d4884c82 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_init.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_init.c
@@ -69,11 +69,11 @@ 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 = ASN1_INTEGER_new ())) { 72 if (!(pkcs12->version = M_ASN1_INTEGER_new ())) {
73 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 73 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
74 return NULL; 74 return NULL;
75 } 75 }
76 ASN1_INTEGER_set (pkcs12->version, 3); 76 ASN1_INTEGER_set(pkcs12->version, 3);
77 if (!(pkcs12->authsafes = PKCS7_new())) { 77 if (!(pkcs12->authsafes = PKCS7_new())) {
78 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 78 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
79 return NULL; 79 return NULL;
@@ -82,7 +82,7 @@ PKCS12 *PKCS12_init (int mode)
82 switch (mode) { 82 switch (mode) {
83 case NID_pkcs7_data: 83 case NID_pkcs7_data:
84 if (!(pkcs12->authsafes->d.data = 84 if (!(pkcs12->authsafes->d.data =
85 ASN1_OCTET_STRING_new())) { 85 M_ASN1_OCTET_STRING_new())) {
86 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 86 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
87 return NULL; 87 return NULL;
88 } 88 }
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_key.c b/src/lib/libssl/src/crypto/pkcs12/p12_key.c
index 25d8cdae57..02fdd20e2f 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_key.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_key.c
@@ -64,7 +64,7 @@
64/* Uncomment out this line to get debugging info about key generation */ 64/* Uncomment out this line to get debugging info about key generation */
65/*#define DEBUG_KEYGEN*/ 65/*#define DEBUG_KEYGEN*/
66#ifdef DEBUG_KEYGEN 66#ifdef DEBUG_KEYGEN
67#include <bio.h> 67#include <openssl/bio.h>
68extern BIO *bio_err; 68extern BIO *bio_err;
69void h__dump (unsigned char *p, int len); 69void h__dump (unsigned char *p, int len);
70#endif 70#endif
@@ -104,13 +104,12 @@ int PKCS12_key_gen_uni (unsigned char *pass, int passlen, unsigned char *salt,
104#ifdef DEBUG_KEYGEN 104#ifdef DEBUG_KEYGEN
105 unsigned char *tmpout = out; 105 unsigned char *tmpout = out;
106 int tmpn = n; 106 int tmpn = n;
107 BIO_printf (bio_err, "KEYGEN DEBUG\n"); 107 fprintf(stderr, "KEYGEN DEBUG\n");
108 BIO_printf (bio_err, "ID %d, ITER %d\n", id, iter); 108 fprintf(stderr, "ID %d, ITER %d\n", id, iter);
109 BIO_printf (bio_err, "Password (length %d):\n", passlen); 109 fprintf(stderr, "Password (length %d):\n", passlen);
110 h__dump (pass, passlen); 110 h__dump(pass, passlen);
111 BIO_printf (bio_err, "Salt (length %d):\n", saltlen); 111 fprintf(stderr, "Salt (length %d):\n", saltlen);
112 h__dump (salt, saltlen); 112 h__dump(salt, saltlen);
113 BIO_printf (bio_err, "ID %d, ITER %d\n\n", id, iter);
114#endif 113#endif
115 v = EVP_MD_block_size (md_type); 114 v = EVP_MD_block_size (md_type);
116 u = EVP_MD_size (md_type); 115 u = EVP_MD_size (md_type);
@@ -150,8 +149,8 @@ int PKCS12_key_gen_uni (unsigned char *pass, int passlen, unsigned char *salt,
150 BN_free (Ij); 149 BN_free (Ij);
151 BN_free (Bpl1); 150 BN_free (Bpl1);
152#ifdef DEBUG_KEYGEN 151#ifdef DEBUG_KEYGEN
153 BIO_printf (bio_err, "Output KEY (length %d)\n", tmpn); 152 fprintf(stderr, "Output KEY (length %d)\n", tmpn);
154 h__dump (tmpout, tmpn); 153 h__dump(tmpout, tmpn);
155#endif 154#endif
156 return 1; 155 return 1;
157 } 156 }
@@ -176,7 +175,7 @@ int PKCS12_key_gen_uni (unsigned char *pass, int passlen, unsigned char *salt,
176#ifdef DEBUG_KEYGEN 175#ifdef DEBUG_KEYGEN
177void h__dump (unsigned char *p, int len) 176void h__dump (unsigned char *p, int len)
178{ 177{
179 for (; len --; p++) BIO_printf (bio_err, "%02X", *p); 178 for (; len --; p++) fprintf(stderr, "%02X", *p);
180 BIO_printf (bio_err, "\n"); 179 fprintf(stderr, "\n");
181} 180}
182#endif 181#endif
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_kiss.c b/src/lib/libssl/src/crypto/pkcs12/p12_kiss.c
index 767e1303da..08a60556e0 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_kiss.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_kiss.c
@@ -139,16 +139,16 @@ static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen,
139 sk_pop_free (asafes, PKCS7_free); 139 sk_pop_free (asafes, PKCS7_free);
140 return 0; 140 return 0;
141 } 141 }
142 if (!parse_bags (bags, pass, passlen, pkey, cert, ca, 142 if (!parse_bags(bags, pass, passlen, pkey, cert, ca,
143 &keyid, &keymatch)) { 143 &keyid, &keymatch)) {
144 sk_pop_free (bags, PKCS12_SAFEBAG_free); 144 sk_pop_free(bags, PKCS12_SAFEBAG_free);
145 sk_pop_free (asafes, PKCS7_free); 145 sk_pop_free(asafes, PKCS7_free);
146 return 0; 146 return 0;
147 } 147 }
148 sk_pop_free (bags, PKCS12_SAFEBAG_free); 148 sk_pop_free(bags, PKCS12_SAFEBAG_free);
149 } 149 }
150 sk_pop_free (asafes, PKCS7_free); 150 sk_pop_free(asafes, PKCS7_free);
151 if (keyid) ASN1_OCTET_STRING_free (keyid); 151 if (keyid) M_ASN1_OCTET_STRING_free(keyid);
152 return 1; 152 return 1;
153} 153}
154 154
@@ -158,8 +158,8 @@ static int parse_bags (STACK *bags, const char *pass, int passlen,
158 ASN1_OCTET_STRING **keyid, char *keymatch) 158 ASN1_OCTET_STRING **keyid, char *keymatch)
159{ 159{
160 int i; 160 int i;
161 for (i = 0; i < sk_num (bags); i++) { 161 for (i = 0; i < sk_num(bags); i++) {
162 if (!parse_bag ((PKCS12_SAFEBAG *)sk_value (bags, i), 162 if (!parse_bag((PKCS12_SAFEBAG *)sk_value (bags, i),
163 pass, passlen, pkey, cert, ca, keyid, 163 pass, passlen, pkey, cert, ca, keyid,
164 keymatch)) return 0; 164 keymatch)) return 0;
165 } 165 }
@@ -170,7 +170,7 @@ static int parse_bags (STACK *bags, const char *pass, int passlen,
170#define MATCH_CERT 0x2 170#define MATCH_CERT 0x2
171#define MATCH_ALL 0x3 171#define MATCH_ALL 0x3
172 172
173static int parse_bag (PKCS12_SAFEBAG *bag, const char *pass, int passlen, 173static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
174 EVP_PKEY **pkey, X509 **cert, STACK **ca, 174 EVP_PKEY **pkey, X509 **cert, STACK **ca,
175 ASN1_OCTET_STRING **keyid, 175 ASN1_OCTET_STRING **keyid,
176 char *keymatch) 176 char *keymatch)
@@ -187,9 +187,9 @@ static int parse_bag (PKCS12_SAFEBAG *bag, const char *pass, int passlen,
187 /* Check for any local key id matching (if needed) */ 187 /* Check for any local key id matching (if needed) */
188 if (lkey && ((*keymatch & MATCH_ALL) != MATCH_ALL)) { 188 if (lkey && ((*keymatch & MATCH_ALL) != MATCH_ALL)) {
189 if (*keyid) { 189 if (*keyid) {
190 if (ASN1_OCTET_STRING_cmp (*keyid, lkey)) lkey = NULL; 190 if (M_ASN1_OCTET_STRING_cmp(*keyid, lkey)) lkey = NULL;
191 } else { 191 } else {
192 if (!(*keyid = ASN1_OCTET_STRING_dup (lkey))) { 192 if (!(*keyid = M_ASN1_OCTET_STRING_dup(lkey))) {
193 PKCS12err(PKCS12_F_PARSE_BAGS,ERR_R_MALLOC_FAILURE); 193 PKCS12err(PKCS12_F_PARSE_BAGS,ERR_R_MALLOC_FAILURE);
194 return 0; 194 return 0;
195 } 195 }
@@ -200,16 +200,16 @@ static int parse_bag (PKCS12_SAFEBAG *bag, const char *pass, int passlen,
200 { 200 {
201 case NID_keyBag: 201 case NID_keyBag:
202 if (!lkey || !pkey) return 1; 202 if (!lkey || !pkey) return 1;
203 if (!(*pkey = EVP_PKCS82PKEY (bag->value.keybag))) return 0; 203 if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag))) return 0;
204 *keymatch |= MATCH_KEY; 204 *keymatch |= MATCH_KEY;
205 break; 205 break;
206 206
207 case NID_pkcs8ShroudedKeyBag: 207 case NID_pkcs8ShroudedKeyBag:
208 if (!lkey || !pkey) return 1; 208 if (!lkey || !pkey) return 1;
209 if (!(p8 = M_PKCS12_decrypt_skey (bag, pass, passlen))) 209 if (!(p8 = M_PKCS12_decrypt_skey(bag, pass, passlen)))
210 return 0; 210 return 0;
211 *pkey = EVP_PKCS82PKEY (p8); 211 *pkey = EVP_PKCS82PKEY(p8);
212 PKCS8_PRIV_KEY_INFO_free (p8); 212 PKCS8_PRIV_KEY_INFO_free(p8);
213 if (!(*pkey)) return 0; 213 if (!(*pkey)) return 0;
214 *keymatch |= MATCH_KEY; 214 *keymatch |= MATCH_KEY;
215 break; 215 break;
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_lib.c b/src/lib/libssl/src/crypto/pkcs12/p12_lib.c
index 00a6695d9b..7ca9c14908 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_lib.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_lib.c
@@ -104,8 +104,8 @@ PKCS12 *PKCS12_new(void)
104void PKCS12_free (PKCS12 *a) 104void PKCS12_free (PKCS12 *a)
105{ 105{
106 if (a == NULL) return; 106 if (a == NULL) return;
107 ASN1_INTEGER_free (a->version); 107 M_ASN1_INTEGER_free(a->version);
108 PKCS12_MAC_DATA_free (a->mac); 108 PKCS12_MAC_DATA_free (a->mac);
109 PKCS7_free (a->authsafes); 109 PKCS7_free (a->authsafes);
110 Free ((char *)a); 110 Free (a);
111} 111}
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_mac.c b/src/lib/libssl/src/crypto/pkcs12/p12_mac.c
index f163d4cfaa..f5ab0d6464 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_mac.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_mac.c
@@ -82,9 +82,9 @@ PKCS12_MAC_DATA *PKCS12_MAC_DATA_new(void)
82 ASN1_CTX c; 82 ASN1_CTX c;
83 M_ASN1_New_Malloc(ret, PKCS12_MAC_DATA); 83 M_ASN1_New_Malloc(ret, PKCS12_MAC_DATA);
84 ret->dinfo = X509_SIG_new(); 84 ret->dinfo = X509_SIG_new();
85 ret->salt = ASN1_OCTET_STRING_new(); 85 ret->salt = M_ASN1_OCTET_STRING_new();
86 ret->iter = NULL; 86 ret->iter = NULL;
87 return (ret); 87 return(ret);
88 M_ASN1_New_Error(ASN1_F_PKCS12_MAC_DATA_NEW); 88 M_ASN1_New_Error(ASN1_F_PKCS12_MAC_DATA_NEW);
89} 89}
90 90
@@ -94,9 +94,9 @@ PKCS12_MAC_DATA *d2i_PKCS12_MAC_DATA(PKCS12_MAC_DATA **a, unsigned char **pp,
94 M_ASN1_D2I_vars(a,PKCS12_MAC_DATA *,PKCS12_MAC_DATA_new); 94 M_ASN1_D2I_vars(a,PKCS12_MAC_DATA *,PKCS12_MAC_DATA_new);
95 M_ASN1_D2I_Init(); 95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence(); 96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get (ret->dinfo, d2i_X509_SIG); 97 M_ASN1_D2I_get(ret->dinfo, d2i_X509_SIG);
98 M_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING); 98 M_ASN1_D2I_get(ret->salt, d2i_ASN1_OCTET_STRING);
99 M_ASN1_D2I_get_opt (ret->iter, d2i_ASN1_INTEGER, V_ASN1_INTEGER); 99 M_ASN1_D2I_get_opt(ret->iter, d2i_ASN1_INTEGER, V_ASN1_INTEGER);
100 M_ASN1_D2I_Finish(a, PKCS12_MAC_DATA_free, ASN1_F_D2I_PKCS12_MAC_DATA); 100 M_ASN1_D2I_Finish(a, PKCS12_MAC_DATA_free, ASN1_F_D2I_PKCS12_MAC_DATA);
101} 101}
102 102
@@ -104,7 +104,7 @@ void PKCS12_MAC_DATA_free (PKCS12_MAC_DATA *a)
104{ 104{
105 if (a == NULL) return; 105 if (a == NULL) return;
106 X509_SIG_free (a->dinfo); 106 X509_SIG_free (a->dinfo);
107 ASN1_OCTET_STRING_free (a->salt); 107 M_ASN1_OCTET_STRING_free(a->salt);
108 ASN1_INTEGER_free (a->iter); 108 M_ASN1_INTEGER_free(a->iter);
109 Free ((char *)a); 109 Free (a);
110} 110}
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_mutl.c b/src/lib/libssl/src/crypto/pkcs12/p12_mutl.c
index bac558d6b9..f1094b3840 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_mutl.c
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_mutl.c
@@ -131,7 +131,7 @@ int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
131 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_GENERATION_ERROR); 131 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_GENERATION_ERROR);
132 return 0; 132 return 0;
133 } 133 }
134 if (!(ASN1_OCTET_STRING_set (p12->mac->dinfo->digest, mac, maclen))) { 134 if (!(M_ASN1_OCTET_STRING_set (p12->mac->dinfo->digest, mac, maclen))) {
135 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_STRING_SET_ERROR); 135 PKCS12err(PKCS12_F_PKCS12_SET_MAC,PKCS12_R_MAC_STRING_SET_ERROR);
136 return 0; 136 return 0;
137 } 137 }
@@ -142,13 +142,13 @@ int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
142int 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,
143 EVP_MD *md_type) 143 EVP_MD *md_type)
144{ 144{
145 if (!(p12->mac = PKCS12_MAC_DATA_new ())) return PKCS12_ERROR; 145 if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR;
146 if (iter > 1) { 146 if (iter > 1) {
147 if(!(p12->mac->iter = ASN1_INTEGER_new())) { 147 if(!(p12->mac->iter = M_ASN1_INTEGER_new())) {
148 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); 148 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
149 return 0; 149 return 0;
150 } 150 }
151 ASN1_INTEGER_set (p12->mac->iter, iter); 151 ASN1_INTEGER_set(p12->mac->iter, iter);
152 } 152 }
153 if (!saltlen) saltlen = PKCS12_SALT_LEN; 153 if (!saltlen) saltlen = PKCS12_SALT_LEN;
154 p12->mac->salt->length = saltlen; 154 p12->mac->salt->length = saltlen;
@@ -156,7 +156,10 @@ int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
156 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); 156 PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
157 return 0; 157 return 0;
158 } 158 }
159 if (!salt) RAND_bytes (p12->mac->salt->data, saltlen); 159 if (!salt) {
160 if (RAND_bytes (p12->mac->salt->data, saltlen) <= 0)
161 return 0;
162 }
160 else memcpy (p12->mac->salt->data, salt, saltlen); 163 else memcpy (p12->mac->salt->data, salt, saltlen);
161 p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type)); 164 p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type));
162 if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) { 165 if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) {
diff --git a/src/lib/libssl/src/crypto/pkcs12/p12_npas.c b/src/lib/libssl/src/crypto/pkcs12/p12_npas.c
new file mode 100644
index 0000000000..ee71707e2c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs12/p12_npas.c
@@ -0,0 +1,212 @@
1/* p12_npas.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 <stdlib.h>
61#include <string.h>
62#include <openssl/pem.h>
63#include <openssl/err.h>
64#include <openssl/pkcs12.h>
65
66/* PKCS#12 password change routine */
67
68static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass);
69static int newpass_bags(STACK *bags, char *oldpass, char *newpass);
70static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass);
71static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen);
72
73/*
74 * Change the password on a PKCS#12 structure.
75 */
76
77int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass)
78{
79
80/* Check for NULL PKCS12 structure */
81
82if(!p12) {
83 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_INVALID_NULL_PKCS12_POINTER);
84 return 0;
85}
86
87/* Check the mac */
88
89if (!PKCS12_verify_mac(p12, oldpass, -1)) {
90 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_MAC_VERIFY_FAILURE);
91 return 0;
92}
93
94if (!newpass_p12(p12, oldpass, newpass)) {
95 PKCS12err(PKCS12_F_PKCS12_NEWPASS,PKCS12_R_PARSE_ERROR);
96 return 0;
97}
98
99return 1;
100
101}
102
103/* Parse the outer PKCS#12 structure */
104
105static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
106{
107 STACK *asafes, *newsafes, *bags;
108 int i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;
109 PKCS7 *p7, *p7new;
110 ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;
111 unsigned char mac[EVP_MAX_MD_SIZE];
112 unsigned int maclen;
113 if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114 if(!(newsafes = sk_new(NULL))) return 0;
115 for (i = 0; i < sk_num (asafes); i++) {
116 p7 = (PKCS7 *) sk_value(asafes, i);
117 bagnid = OBJ_obj2nid(p7->type);
118 if (bagnid == NID_pkcs7_data) {
119 bags = M_PKCS12_unpack_p7data(p7);
120 } else if (bagnid == NID_pkcs7_encrypted) {
121 bags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);
122 alg_get(p7->d.encrypted->enc_data->algorithm,
123 &pbe_nid, &pbe_iter, &pbe_saltlen);
124 } else continue;
125 if (!bags) {
126 sk_pop_free(asafes, PKCS7_free);
127 return 0;
128 }
129 if (!newpass_bags(bags, oldpass, newpass)) {
130 sk_pop_free(bags, PKCS12_SAFEBAG_free);
131 sk_pop_free(asafes, PKCS7_free);
132 return 0;
133 }
134 /* Repack bag in same form with new password */
135 if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);
136 else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
137 pbe_saltlen, pbe_iter, bags);
138 sk_pop_free(bags, PKCS12_SAFEBAG_free);
139 if(!p7new) {
140 sk_pop_free(asafes, PKCS7_free);
141 return 0;
142 }
143 sk_push(newsafes, (char *)p7new);
144 }
145 sk_pop_free(asafes, PKCS7_free);
146
147 /* Repack safe: save old safe in case of error */
148
149 p12_data_tmp = p12->authsafes->d.data;
150 if(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr;
151 if(!M_PKCS12_pack_authsafes(p12, newsafes)) goto saferr;
152
153 if(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr;
154 if(!(macnew = ASN1_OCTET_STRING_new())) goto saferr;
155 if(!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr;
156 ASN1_OCTET_STRING_free(p12->mac->dinfo->digest);
157 p12->mac->dinfo->digest = macnew;
158 ASN1_OCTET_STRING_free(p12_data_tmp);
159
160 return 1;
161
162 saferr:
163 /* Restore old safe */
164 ASN1_OCTET_STRING_free(p12->authsafes->d.data);
165 ASN1_OCTET_STRING_free(macnew);
166 p12->authsafes->d.data = p12_data_tmp;
167 return 0;
168
169}
170
171
172static int newpass_bags(STACK *bags, char *oldpass, char *newpass)
173{
174 int i;
175 for (i = 0; i < sk_num(bags); i++) {
176 if (!newpass_bag((PKCS12_SAFEBAG *)sk_value(bags, i),
177 oldpass, newpass)) return 0;
178 }
179 return 1;
180}
181
182/* Change password of safebag: only needs handle shrouded keybags */
183
184static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass)
185{
186 PKCS8_PRIV_KEY_INFO *p8;
187 X509_SIG *p8new;
188 int p8_nid, p8_saltlen, p8_iter;
189
190 if(M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1;
191
192 if (!(p8 = M_PKCS12_decrypt_skey(bag, oldpass, -1))) return 0;
193 alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen);
194 if(!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen,
195 p8_iter, p8))) return 0;
196 X509_SIG_free(bag->value.shkeybag);
197 bag->value.shkeybag = p8new;
198 return 1;
199}
200
201static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen)
202{
203 PBEPARAM *pbe;
204 unsigned char *p;
205 p = alg->parameter->value.sequence->data;
206 pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
207 *pnid = OBJ_obj2nid(alg->algorithm);
208 *piter = ASN1_INTEGER_get(pbe->iter);
209 *psaltlen = pbe->salt->length;
210 PBEPARAM_free(pbe);
211 return 0;
212}
diff --git a/src/lib/libssl/src/crypto/pkcs12/pk12err.c b/src/lib/libssl/src/crypto/pkcs12/pk12err.c
index 38d7be7675..9d8de10e1e 100644
--- a/src/lib/libssl/src/crypto/pkcs12/pk12err.c
+++ b/src/lib/libssl/src/crypto/pkcs12/pk12err.c
@@ -79,6 +79,7 @@ static ERR_STRING_DATA PKCS12_str_functs[]=
79{ERR_PACK(0,PKCS12_F_PKCS12_KEY_GEN_UNI,0), "PKCS12_key_gen_uni"}, 79{ERR_PACK(0,PKCS12_F_PKCS12_KEY_GEN_UNI,0), "PKCS12_key_gen_uni"},
80{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_KEYBAG,0), "PKCS12_MAKE_KEYBAG"}, 80{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_KEYBAG,0), "PKCS12_MAKE_KEYBAG"},
81{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_SHKEYBAG,0), "PKCS12_MAKE_SHKEYBAG"}, 81{ERR_PACK(0,PKCS12_F_PKCS12_MAKE_SHKEYBAG,0), "PKCS12_MAKE_SHKEYBAG"},
82{ERR_PACK(0,PKCS12_F_PKCS12_NEWPASS,0), "PKCS12_newpass"},
82{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7DATA,0), "PKCS12_pack_p7data"}, 83{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7DATA,0), "PKCS12_pack_p7data"},
83{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7ENCDATA,0), "PKCS12_pack_p7encdata"}, 84{ERR_PACK(0,PKCS12_F_PKCS12_PACK_P7ENCDATA,0), "PKCS12_pack_p7encdata"},
84{ERR_PACK(0,PKCS12_F_PKCS12_PACK_SAFEBAG,0), "PKCS12_pack_safebag"}, 85{ERR_PACK(0,PKCS12_F_PKCS12_PACK_SAFEBAG,0), "PKCS12_pack_safebag"},
@@ -99,6 +100,7 @@ static ERR_STRING_DATA PKCS12_str_reasons[]=
99{PKCS12_R_DECODE_ERROR ,"decode error"}, 100{PKCS12_R_DECODE_ERROR ,"decode error"},
100{PKCS12_R_ENCODE_ERROR ,"encode error"}, 101{PKCS12_R_ENCODE_ERROR ,"encode error"},
101{PKCS12_R_ENCRYPT_ERROR ,"encrypt error"}, 102{PKCS12_R_ENCRYPT_ERROR ,"encrypt error"},
103{PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE,"error setting encrypted data type"},
102{PKCS12_R_INVALID_NULL_ARGUMENT ,"invalid null argument"}, 104{PKCS12_R_INVALID_NULL_ARGUMENT ,"invalid null argument"},
103{PKCS12_R_INVALID_NULL_PKCS12_POINTER ,"invalid null pkcs12 pointer"}, 105{PKCS12_R_INVALID_NULL_PKCS12_POINTER ,"invalid null pkcs12 pointer"},
104{PKCS12_R_IV_GEN_ERROR ,"iv gen error"}, 106{PKCS12_R_IV_GEN_ERROR ,"iv gen error"},
diff --git a/src/lib/libssl/src/crypto/pkcs12/pkcs12.h b/src/lib/libssl/src/crypto/pkcs12/pkcs12.h
index 4cfba5e6c6..254000fa12 100644
--- a/src/lib/libssl/src/crypto/pkcs12/pkcs12.h
+++ b/src/lib/libssl/src/crypto/pkcs12/pkcs12.h
@@ -273,6 +273,7 @@ int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);
273int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); 273int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
274PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); 274PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
275PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); 275PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
276int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
276 277
277/* BEGIN ERROR CODES */ 278/* BEGIN ERROR CODES */
278/* The following lines are auto generated by the script mkerr.pl. Any changes 279/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -296,6 +297,7 @@ PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
296#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 297#define PKCS12_F_PKCS12_KEY_GEN_UNI 111
297#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 298#define PKCS12_F_PKCS12_MAKE_KEYBAG 112
298#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 299#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113
300#define PKCS12_F_PKCS12_NEWPASS 128
299#define PKCS12_F_PKCS12_PACK_P7DATA 114 301#define PKCS12_F_PKCS12_PACK_P7DATA 114
300#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 302#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115
301#define PKCS12_F_PKCS12_PACK_SAFEBAG 117 303#define PKCS12_F_PKCS12_PACK_SAFEBAG 117
@@ -313,6 +315,7 @@ PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
313#define PKCS12_R_DECODE_ERROR 101 315#define PKCS12_R_DECODE_ERROR 101
314#define PKCS12_R_ENCODE_ERROR 102 316#define PKCS12_R_ENCODE_ERROR 102
315#define PKCS12_R_ENCRYPT_ERROR 103 317#define PKCS12_R_ENCRYPT_ERROR 103
318#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120
316#define PKCS12_R_INVALID_NULL_ARGUMENT 104 319#define PKCS12_R_INVALID_NULL_ARGUMENT 104
317#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 320#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105
318#define PKCS12_R_IV_GEN_ERROR 106 321#define PKCS12_R_IV_GEN_ERROR 106
diff --git a/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
index 6c4644b2f2..0e508386e8 100644
--- a/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
@@ -1,5 +1,5 @@
1# 1#
2# SSLeay/crypto/asn1/Makefile 2# SSLeay/crypto/pkcs7/Makefile
3# 3#
4 4
5DIR= pkcs7 5DIR= pkcs7
@@ -15,6 +15,9 @@ MAKEDEPEND= $(TOP)/util/domd $(TOP)
15MAKEFILE= Makefile.ssl 15MAKEFILE= Makefile.ssl
16AR= ar r 16AR= ar r
17 17
18PEX_LIBS=
19EX_LIBS=
20
18CFLAGS= $(INCLUDES) $(CFLAG) 21CFLAGS= $(INCLUDES) $(CFLAG)
19 22
20GENERAL=Makefile README 23GENERAL=Makefile README
@@ -22,8 +25,8 @@ TEST=
22APPS= 25APPS=
23 26
24LIB=$(TOP)/libcrypto.a 27LIB=$(TOP)/libcrypto.a
25LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c 28LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c pk7_mime.c
26LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o 29LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o pk7_smime.o pk7_attr.o pk7_mime.o
27 30
28SRC= $(LIBSRC) 31SRC= $(LIBSRC)
29 32
@@ -42,16 +45,16 @@ all: lib
42testapps: enc dec sign verify 45testapps: enc dec sign verify
43 46
44enc: enc.o lib 47enc: enc.o lib
45 $(CC) $(CFLAGS) -o enc enc.o $(LIB) 48 $(CC) $(CFLAGS) -o enc enc.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
46 49
47dec: dec.o lib 50dec: dec.o lib
48 $(CC) $(CFLAGS) -o dec dec.o $(LIB) 51 $(CC) $(CFLAGS) -o dec dec.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
49 52
50sign: sign.o lib 53sign: sign.o lib
51 $(CC) $(CFLAGS) -o sign sign.o $(LIB) 54 $(CC) $(CFLAGS) -o sign sign.o $(PEX_LIBS) $(LIB) $(EX_LIBS)
52 55
53verify: verify.o example.o lib 56verify: verify.o example.o lib
54 $(CC) $(CFLAGS) -o verify verify.o example.o $(LIB) 57 $(CC) $(CFLAGS) -o verify verify.o $(PEX_LIBS) example.o $(LIB) $(EX_LIBS)
55 58
56lib: $(LIBOBJ) 59lib: $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ) 60 $(AR) $(LIB) $(LIBOBJ)
@@ -90,18 +93,35 @@ dclean:
90 mv -f Makefile.new $(MAKEFILE) 93 mv -f Makefile.new $(MAKEFILE)
91 94
92clean: 95clean:
93 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 96 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff enc dec sign verify
94 97
95# DO NOT DELETE THIS LINE -- make depend depends on it. 98# DO NOT DELETE THIS LINE -- make depend depends on it.
96 99
100pk7_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
101pk7_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
102pk7_attr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
103pk7_attr.o: ../../include/openssl/des.h ../../include/openssl/dh.h
104pk7_attr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
105pk7_attr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
106pk7_attr.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
107pk7_attr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
108pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
109pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h
110pk7_attr.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
111pk7_attr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
112pk7_attr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
113pk7_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
114pk7_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
115pk7_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
97pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 116pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
98pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 117pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
99pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 118pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
100pk7_doit.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 119pk7_doit.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
101pk7_doit.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 120pk7_doit.o: ../../include/openssl/des.h ../../include/openssl/dh.h
102pk7_doit.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 121pk7_doit.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
103pk7_doit.o: ../../include/openssl/err.h ../../include/openssl/evp.h 122pk7_doit.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
104pk7_doit.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 123pk7_doit.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
124pk7_doit.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
105pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 125pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
106pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 126pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
107pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 127pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -110,7 +130,8 @@ pk7_doit.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
110pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 130pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
111pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 131pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
112pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 132pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
113pk7_doit.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 133pk7_doit.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
134pk7_doit.o: ../cryptlib.h
114pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 135pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
115pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 136pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
116pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 137pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -128,6 +149,42 @@ pk7_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
128pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 149pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
129pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 150pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
130pk7_lib.o: ../cryptlib.h 151pk7_lib.o: ../cryptlib.h
152pk7_mime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
153pk7_mime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
154pk7_mime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
155pk7_mime.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
156pk7_mime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
157pk7_mime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
158pk7_mime.o: ../../include/openssl/err.h ../../include/openssl/evp.h
159pk7_mime.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
160pk7_mime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
161pk7_mime.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
162pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
163pk7_mime.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
164pk7_mime.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
165pk7_mime.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
166pk7_mime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
167pk7_mime.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
168pk7_mime.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
169pk7_smime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
170pk7_smime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
171pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
172pk7_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
173pk7_smime.o: ../../include/openssl/des.h ../../include/openssl/dh.h
174pk7_smime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
175pk7_smime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
176pk7_smime.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
177pk7_smime.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
178pk7_smime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
179pk7_smime.o: ../../include/openssl/objects.h
180pk7_smime.o: ../../include/openssl/opensslconf.h
181pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
182pk7_smime.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
183pk7_smime.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
184pk7_smime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
185pk7_smime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
186pk7_smime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
187pk7_smime.o: ../../include/openssl/x509v3.h ../cryptlib.h
131pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 188pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
132pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 189pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
133pkcs7err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 190pkcs7err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
diff --git a/src/lib/libssl/src/crypto/pkcs7/bio_ber.c b/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
index 2f17723e98..4803966fd2 100644
--- a/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
+++ b/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
@@ -69,6 +69,7 @@ static int ber_read(BIO *h,char *buf,int size);
69static long ber_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long ber_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int ber_new(BIO *h); 70static int ber_new(BIO *h);
71static int ber_free(BIO *data); 71static int ber_free(BIO *data);
72static long ber_callback_ctrl(BIO *h,int cmd,void *(*fp)());
72#define BER_BUF_SIZE (32) 73#define BER_BUF_SIZE (32)
73 74
74/* This is used to hold the state of the BER objects being read. */ 75/* This is used to hold the state of the BER objects being read. */
@@ -92,7 +93,7 @@ typedef struct bio_ber_struct
92 /* most of the following are used when doing non-blocking IO */ 93 /* most of the following are used when doing non-blocking IO */
93 /* reading */ 94 /* reading */
94 long num_left; /* number of bytes still to read/write in block */ 95 long num_left; /* number of bytes still to read/write in block */
95 int depth; /* used with idefinite encoding. */ 96 int depth; /* used with indefinite encoding. */
96 int finished; /* No more read data */ 97 int finished; /* No more read data */
97 98
98 /* writting */ 99 /* writting */
@@ -115,6 +116,7 @@ static BIO_METHOD methods_ber=
115 ber_ctrl, 116 ber_ctrl,
116 ber_new, 117 ber_new,
117 ber_free, 118 ber_free,
119 ber_callback_ctrl,
118 }; 120 };
119 121
120BIO_METHOD *BIO_f_ber(void) 122BIO_METHOD *BIO_f_ber(void)
@@ -409,6 +411,20 @@ again:
409 return(ret); 411 return(ret);
410 } 412 }
411 413
414static long ber_callback_ctrl(BIO *b, int cmd, void *(*fp)())
415 {
416 long ret=1;
417
418 if (b->next_bio == NULL) return(0);
419 switch (cmd)
420 {
421 default:
422 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
423 break;
424 }
425 return(ret);
426 }
427
412/* 428/*
413void BIO_set_cipher_ctx(b,c) 429void BIO_set_cipher_ctx(b,c)
414BIO *b; 430BIO *b;
diff --git a/src/lib/libssl/src/crypto/pkcs7/dec.c b/src/lib/libssl/src/crypto/pkcs7/dec.c
index b3661f28d3..6752ec568a 100644
--- a/src/lib/libssl/src/crypto/pkcs7/dec.c
+++ b/src/lib/libssl/src/crypto/pkcs7/dec.c
@@ -57,6 +57,7 @@
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h>
60#include <openssl/bio.h> 61#include <openssl/bio.h>
61#include <openssl/x509.h> 62#include <openssl/x509.h>
62#include <openssl/pem.h> 63#include <openssl/pem.h>
@@ -85,7 +86,7 @@ char *argv[];
85 int i,printit=0; 86 int i,printit=0;
86 STACK_OF(PKCS7_SIGNER_INFO) *sk; 87 STACK_OF(PKCS7_SIGNER_INFO) *sk;
87 88
88 SSLeay_add_all_algorithms(); 89 OpenSSL_add_all_algorithms();
89 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 90 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
90 91
91 data=BIO_new(BIO_s_file()); 92 data=BIO_new(BIO_s_file());
@@ -121,9 +122,10 @@ char *argv[];
121 } 122 }
122 123
123 if ((in=BIO_new_file(keyfile,"r")) == NULL) goto err; 124 if ((in=BIO_new_file(keyfile,"r")) == NULL) goto err;
124 if ((x509=PEM_read_bio_X509(in,NULL,NULL)) == NULL) goto err; 125 if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err;
125 BIO_reset(in); 126 BIO_reset(in);
126 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL)) == NULL) goto err; 127 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL)
128 goto err;
127 BIO_free(in); 129 BIO_free(in);
128 130
129 if (pp == NULL) 131 if (pp == NULL)
@@ -131,7 +133,7 @@ char *argv[];
131 133
132 134
133 /* Load the PKCS7 object from a file */ 135 /* Load the PKCS7 object from a file */
134 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL)) == NULL) goto err; 136 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL,NULL)) == NULL) goto err;
135 137
136 138
137 139
@@ -148,7 +150,7 @@ char *argv[];
148 /* We need to process the data */ 150 /* We need to process the data */
149 /* We cannot support detached encryption */ 151 /* We cannot support detached encryption */
150 p7bio=PKCS7_dataDecode(p7,pkey,detached,x509); 152 p7bio=PKCS7_dataDecode(p7,pkey,detached,x509);
151 153
152 if (p7bio == NULL) 154 if (p7bio == NULL)
153 { 155 {
154 printf("problems decoding\n"); 156 printf("problems decoding\n");
diff --git a/src/lib/libssl/src/crypto/pkcs7/enc.c b/src/lib/libssl/src/crypto/pkcs7/enc.c
index 43bfd10a23..2b56c2eff3 100644
--- a/src/lib/libssl/src/crypto/pkcs7/enc.c
+++ b/src/lib/libssl/src/crypto/pkcs7/enc.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h>
59#include <openssl/bio.h> 60#include <openssl/bio.h>
60#include <openssl/x509.h> 61#include <openssl/x509.h>
61#include <openssl/pem.h> 62#include <openssl/pem.h>
@@ -76,7 +77,7 @@ char *argv[];
76 const EVP_CIPHER *cipher=NULL; 77 const EVP_CIPHER *cipher=NULL;
77 STACK_OF(X509) *recips=NULL; 78 STACK_OF(X509) *recips=NULL;
78 79
79 SSLeay_add_all_algorithms(); 80 OpenSSL_add_all_algorithms();
80 81
81 data=BIO_new(BIO_s_file()); 82 data=BIO_new(BIO_s_file());
82 while(argc > 1) 83 while(argc > 1)
@@ -98,7 +99,8 @@ char *argv[];
98 argc-=2; 99 argc-=2;
99 argv+=2; 100 argv+=2;
100 if (!(in=BIO_new_file(keyfile,"r"))) goto err; 101 if (!(in=BIO_new_file(keyfile,"r"))) goto err;
101 if (!(x509=PEM_read_bio_X509(in,NULL,NULL))) goto err; 102 if (!(x509=PEM_read_bio_X509(in,NULL,NULL,NULL)))
103 goto err;
102 if(!recips) recips = sk_X509_new_null(); 104 if(!recips) recips = sk_X509_new_null();
103 sk_X509_push(recips, x509); 105 sk_X509_push(recips, x509);
104 BIO_free(in); 106 BIO_free(in);
@@ -125,7 +127,14 @@ char *argv[];
125#else 127#else
126 PKCS7_set_type(p7,NID_pkcs7_enveloped); 128 PKCS7_set_type(p7,NID_pkcs7_enveloped);
127#endif 129#endif
128 if(!cipher) cipher = EVP_des_ede3_cbc(); 130 if(!cipher) {
131#ifndef NO_DES
132 cipher = EVP_des_ede3_cbc();
133#else
134 fprintf(stderr, "No cipher selected\n");
135 goto err;
136#endif
137 }
129 138
130 if (!PKCS7_set_cipher(p7,cipher)) goto err; 139 if (!PKCS7_set_cipher(p7,cipher)) goto err;
131 for(i = 0; i < sk_X509_num(recips); i++) { 140 for(i = 0; i < sk_X509_num(recips); i++) {
diff --git a/src/lib/libssl/src/crypto/pkcs7/example.c b/src/lib/libssl/src/crypto/pkcs7/example.c
index 7354890084..f6656be28e 100644
--- a/src/lib/libssl/src/crypto/pkcs7/example.c
+++ b/src/lib/libssl/src/crypto/pkcs7/example.c
@@ -1,5 +1,6 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h>
3#include <openssl/pkcs7.h> 4#include <openssl/pkcs7.h>
4#include <openssl/asn1_mac.h> 5#include <openssl/asn1_mac.h>
5 6
@@ -36,7 +37,7 @@ void add_signed_string(PKCS7_SIGNER_INFO *si, char *str)
36 signed_string_nid= 37 signed_string_nid=
37 OBJ_create("1.2.3.4.5","OID_example","Our example OID"); 38 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
38 os=ASN1_OCTET_STRING_new(); 39 os=ASN1_OCTET_STRING_new();
39 ASN1_OCTET_STRING_set(os,str,strlen(str)); 40 ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));
40 /* When we add, we do not free */ 41 /* When we add, we do not free */
41 PKCS7_add_signed_attribute(si,signed_string_nid, 42 PKCS7_add_signed_attribute(si,signed_string_nid,
42 V_ASN1_OCTET_STRING,(char *)os); 43 V_ASN1_OCTET_STRING,(char *)os);
@@ -68,7 +69,7 @@ int get_signed_string(PKCS7_SIGNER_INFO *si, char *buf, int len)
68 return(0); 69 return(0);
69 } 70 }
70 71
71static signed_seq2string_nid= -1; 72static int signed_seq2string_nid= -1;
72/* ########################################### */ 73/* ########################################### */
73int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) 74int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
74 { 75 {
@@ -86,8 +87,8 @@ int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
86 87
87 os1=ASN1_OCTET_STRING_new(); 88 os1=ASN1_OCTET_STRING_new();
88 os2=ASN1_OCTET_STRING_new(); 89 os2=ASN1_OCTET_STRING_new();
89 ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); 90 ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1));
90 ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); 91 ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1));
91 i =i2d_ASN1_OCTET_STRING(os1,NULL); 92 i =i2d_ASN1_OCTET_STRING(os1,NULL);
92 i+=i2d_ASN1_OCTET_STRING(os2,NULL); 93 i+=i2d_ASN1_OCTET_STRING(os2,NULL);
93 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); 94 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
@@ -197,7 +198,7 @@ X509_ATTRIBUTE *create_string(char *str)
197 signed_string_nid= 198 signed_string_nid=
198 OBJ_create("1.2.3.4.5","OID_example","Our example OID"); 199 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
199 os=ASN1_OCTET_STRING_new(); 200 os=ASN1_OCTET_STRING_new();
200 ASN1_OCTET_STRING_set(os,str,strlen(str)); 201 ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));
201 /* When we add, we do not free */ 202 /* When we add, we do not free */
202 ret=X509_ATTRIBUTE_create(signed_string_nid, 203 ret=X509_ATTRIBUTE_create(signed_string_nid,
203 V_ASN1_OCTET_STRING,(char *)os); 204 V_ASN1_OCTET_STRING,(char *)os);
@@ -250,8 +251,8 @@ X509_ATTRIBUTE *add_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
250 251
251 os1=ASN1_OCTET_STRING_new(); 252 os1=ASN1_OCTET_STRING_new();
252 os2=ASN1_OCTET_STRING_new(); 253 os2=ASN1_OCTET_STRING_new();
253 ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); 254 ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1));
254 ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); 255 ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1));
255 i =i2d_ASN1_OCTET_STRING(os1,NULL); 256 i =i2d_ASN1_OCTET_STRING(os1,NULL);
256 i+=i2d_ASN1_OCTET_STRING(os2,NULL); 257 i+=i2d_ASN1_OCTET_STRING(os2,NULL);
257 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); 258 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_attr.c b/src/lib/libssl/src/crypto/pkcs7/pk7_attr.c
new file mode 100644
index 0000000000..3b9c0fe3f2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_attr.c
@@ -0,0 +1,85 @@
1/* pk7_attr.c */
2/* S/MIME code.
3 * Copyright (C) 1997-8 Dr S N Henson (shenson@bigfoot.com)
4 * All Rights Reserved.
5 * Redistribution of this code without the authors permission is expressly
6 * prohibited.
7 */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <openssl/bio.h>
12#include <openssl/asn1.h>
13#include <openssl/pem.h>
14#include <openssl/pkcs7.h>
15#include <openssl/err.h>
16
17int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap)
18{
19 ASN1_STRING *seq;
20 unsigned char *p, *pp;
21 int len;
22 len=i2d_ASN1_SET(cap,NULL,i2d_X509_ALGOR, V_ASN1_SEQUENCE,
23 V_ASN1_UNIVERSAL, IS_SEQUENCE);
24 if(!(pp=(unsigned char *)Malloc(len))) {
25 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
26 return 0;
27 }
28 p=pp;
29 i2d_ASN1_SET(cap,&p,i2d_X509_ALGOR, V_ASN1_SEQUENCE,
30 V_ASN1_UNIVERSAL, IS_SEQUENCE);
31 if(!(seq = ASN1_STRING_new())) {
32 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
33 return 0;
34 }
35 if(!ASN1_STRING_set (seq, pp, len)) {
36 PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE);
37 return 0;
38 }
39 Free (pp);
40 return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
41 V_ASN1_SEQUENCE, seq);
42}
43
44STACK *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si)
45{
46 ASN1_TYPE *cap;
47 unsigned char *p;
48 cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities);
49 if (!cap) return NULL;
50 p = cap->value.sequence->data;
51 return d2i_ASN1_SET (NULL, &p, cap->value.sequence->length,
52 (char *(*)())d2i_X509_ALGOR, X509_ALGOR_free, V_ASN1_SEQUENCE,
53 V_ASN1_UNIVERSAL);
54}
55
56/* Basic smime-capabilities OID and optional integer arg */
57int PKCS7_simple_smimecap(STACK *sk, int nid, int arg)
58{
59 X509_ALGOR *alg;
60 if(!(alg = X509_ALGOR_new())) {
61 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
62 return 0;
63 }
64 ASN1_OBJECT_free(alg->algorithm);
65 alg->algorithm = OBJ_nid2obj (nid);
66 if (arg > 0) {
67 ASN1_INTEGER *nbit;
68 if(!(alg->parameter = ASN1_TYPE_new())) {
69 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
70 return 0;
71 }
72 if(!(nbit = ASN1_INTEGER_new())) {
73 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
74 return 0;
75 }
76 if(!ASN1_INTEGER_set (nbit, arg)) {
77 PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE);
78 return 0;
79 }
80 alg->parameter->value.integer = nbit;
81 alg->parameter->type = V_ASN1_INTEGER;
82 }
83 sk_push (sk, (char *)alg);
84 return 1;
85}
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c b/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
index dee81b547a..80ac5e34b4 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
@@ -61,6 +61,7 @@
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
64 65
65static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, 66static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
66 void *value); 67 void *value);
@@ -160,9 +161,10 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
160 BIO_get_cipher_ctx(btmp, &ctx); 161 BIO_get_cipher_ctx(btmp, &ctx);
161 keylen=EVP_CIPHER_key_length(evp_cipher); 162 keylen=EVP_CIPHER_key_length(evp_cipher);
162 ivlen=EVP_CIPHER_iv_length(evp_cipher); 163 ivlen=EVP_CIPHER_iv_length(evp_cipher);
163 RAND_bytes(key,keylen); 164 if (RAND_bytes(key,keylen) <= 0)
165 goto err;
164 xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher)); 166 xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher));
165 if (ivlen > 0) RAND_bytes(iv,ivlen); 167 if (ivlen > 0) RAND_pseudo_bytes(iv,ivlen);
166 EVP_CipherInit(ctx, evp_cipher, key, iv, 1); 168 EVP_CipherInit(ctx, evp_cipher, key, iv, 1);
167 169
168 if (ivlen > 0) { 170 if (ivlen > 0) {
@@ -204,7 +206,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
204 Free(tmp); 206 Free(tmp);
205 goto err; 207 goto err;
206 } 208 }
207 ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj); 209 M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj);
208 } 210 }
209 Free(tmp); 211 Free(tmp);
210 memset(key, 0, keylen); 212 memset(key, 0, keylen);
@@ -216,30 +218,23 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
216 btmp=NULL; 218 btmp=NULL;
217 } 219 }
218 220
219 if (bio == NULL) /* ??????????? */ 221 if (bio == NULL) {
220 {
221 if (p7->detached) 222 if (p7->detached)
222 bio=BIO_new(BIO_s_null()); 223 bio=BIO_new(BIO_s_null());
223 else 224 else {
224 {
225 bio=BIO_new(BIO_s_mem());
226 /* We need to set this so that when we have read all
227 * the data, the encrypt BIO, if present, will read
228 * EOF and encode the last few bytes */
229 BIO_set_mem_eof_return(bio,0);
230
231 if (PKCS7_type_is_signed(p7) && 225 if (PKCS7_type_is_signed(p7) &&
232 PKCS7_type_is_data(p7->d.sign->contents)) 226 PKCS7_type_is_data(p7->d.sign->contents)) {
233 {
234 ASN1_OCTET_STRING *os; 227 ASN1_OCTET_STRING *os;
235
236 os=p7->d.sign->contents->d.data; 228 os=p7->d.sign->contents->d.data;
237 if (os->length > 0) 229 if (os->length > 0) bio =
238 BIO_write(bio,(char *)os->data, 230 BIO_new_mem_buf(os->data, os->length);
239 os->length); 231 }
240 } 232 if(bio == NULL) {
233 bio=BIO_new(BIO_s_mem());
234 BIO_set_mem_eof_return(bio,0);
241 } 235 }
242 } 236 }
237 }
243 BIO_push(out,bio); 238 BIO_push(out,bio);
244 bio=NULL; 239 bio=NULL;
245 if (0) 240 if (0)
@@ -259,7 +254,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
259 { 254 {
260 int i,j; 255 int i,j;
261 BIO *out=NULL,*btmp=NULL,*etmp=NULL,*bio=NULL; 256 BIO *out=NULL,*btmp=NULL,*etmp=NULL,*bio=NULL;
262 char *tmp=NULL; 257 unsigned char *tmp=NULL;
263 X509_ALGOR *xa; 258 X509_ALGOR *xa;
264 ASN1_OCTET_STRING *data_body=NULL; 259 ASN1_OCTET_STRING *data_body=NULL;
265 const EVP_MD *evp_md; 260 const EVP_MD *evp_md;
@@ -270,6 +265,9 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
270 STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; 265 STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
271 X509_ALGOR *xalg=NULL; 266 X509_ALGOR *xalg=NULL;
272 PKCS7_RECIP_INFO *ri=NULL; 267 PKCS7_RECIP_INFO *ri=NULL;
268#ifndef NO_RC2
269 char is_rc2 = 0;
270#endif
273/* EVP_PKEY *pkey; */ 271/* EVP_PKEY *pkey; */
274#if 0 272#if 0
275 X509_STORE_CTX s_ctx; 273 X509_STORE_CTX s_ctx;
@@ -314,6 +312,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
314 goto err; 312 goto err;
315 } 313 }
316 314
315 if(EVP_CIPHER_nid(evp_cipher) == NID_rc2_cbc)
316 {
317#ifndef NO_RC2
318 is_rc2 = 1;
319#else
320 PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
321 goto err;
322#endif
323 }
324
317 /* We will be checking the signature */ 325 /* We will be checking the signature */
318 if (md_sk != NULL) 326 if (md_sk != NULL)
319 { 327 {
@@ -372,7 +380,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
372 ri=sk_PKCS7_RECIP_INFO_value(rsk,i); 380 ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
373 if(!X509_NAME_cmp(ri->issuer_and_serial->issuer, 381 if(!X509_NAME_cmp(ri->issuer_and_serial->issuer,
374 pcert->cert_info->issuer) && 382 pcert->cert_info->issuer) &&
375 !ASN1_INTEGER_cmp(pcert->cert_info->serialNumber, 383 !M_ASN1_INTEGER_cmp(pcert->cert_info->serialNumber,
376 ri->issuer_and_serial->serial)) break; 384 ri->issuer_and_serial->serial)) break;
377 ri=NULL; 385 ri=NULL;
378 } 386 }
@@ -383,17 +391,15 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
383 } 391 }
384 392
385 jj=EVP_PKEY_size(pkey); 393 jj=EVP_PKEY_size(pkey);
386 tmp=Malloc(jj+10); 394 tmp=(unsigned char *)Malloc(jj+10);
387 if (tmp == NULL) 395 if (tmp == NULL)
388 { 396 {
389 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE); 397 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE);
390 goto err; 398 goto err;
391 } 399 }
392 400
393 jj=EVP_PKEY_decrypt((unsigned char *)tmp, 401 jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key),
394 ASN1_STRING_data(ri->enc_key), 402 M_ASN1_STRING_length(ri->enc_key), pkey);
395 ASN1_STRING_length(ri->enc_key),
396 pkey);
397 if (jj <= 0) 403 if (jj <= 0)
398 { 404 {
399 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_EVP_LIB); 405 PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_EVP_LIB);
@@ -406,13 +412,25 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
406 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) 412 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
407 return(NULL); 413 return(NULL);
408 414
409 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) 415 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) {
410 { 416 /* HACK: some S/MIME clients don't use the same key
411 PKCS7err(PKCS7_F_PKCS7_DATADECODE, 417 * and effective key length. The key length is
418 * determined by the size of the decrypted RSA key.
419 * So we hack things to manually set the RC2 key
420 * because we currently can't do this with the EVP
421 * interface.
422 */
423#ifndef NO_RC2
424 if(is_rc2) RC2_set_key(&(evp_ctx->c.rc2_ks),jj, tmp,
425 EVP_CIPHER_CTX_key_length(evp_ctx)*8);
426 else
427#endif
428 {
429 PKCS7err(PKCS7_F_PKCS7_DATADECODE,
412 PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); 430 PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH);
413 goto err; 431 goto err;
414 } 432 }
415 EVP_CipherInit(evp_ctx,NULL,(unsigned char *)tmp,NULL,0); 433 } else EVP_CipherInit(evp_ctx,NULL,tmp,NULL,0);
416 434
417 memset(tmp,0,jj); 435 memset(tmp,0,jj);
418 436
@@ -430,6 +448,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
430 } 448 }
431 else 449 else
432 { 450 {
451#if 0
433 bio=BIO_new(BIO_s_mem()); 452 bio=BIO_new(BIO_s_mem());
434 /* We need to set this so that when we have read all 453 /* We need to set this so that when we have read all
435 * the data, the encrypt BIO, if present, will read 454 * the data, the encrypt BIO, if present, will read
@@ -438,6 +457,14 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
438 457
439 if (data_body->length > 0) 458 if (data_body->length > 0)
440 BIO_write(bio,(char *)data_body->data,data_body->length); 459 BIO_write(bio,(char *)data_body->data,data_body->length);
460#else
461 if (data_body->length > 0)
462 bio = BIO_new_mem_buf(data_body->data,data_body->length);
463 else {
464 bio=BIO_new(BIO_s_mem());
465 BIO_set_mem_eof_return(bio,0);
466 }
467#endif
441 } 468 }
442 BIO_push(out,bio); 469 BIO_push(out,bio);
443 bio=NULL; 470 bio=NULL;
@@ -479,12 +506,12 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
479 case NID_pkcs7_signedAndEnveloped: 506 case NID_pkcs7_signedAndEnveloped:
480 /* XXXXXXXXXXXXXXXX */ 507 /* XXXXXXXXXXXXXXXX */
481 si_sk=p7->d.signed_and_enveloped->signer_info; 508 si_sk=p7->d.signed_and_enveloped->signer_info;
482 os=ASN1_OCTET_STRING_new(); 509 os=M_ASN1_OCTET_STRING_new();
483 p7->d.signed_and_enveloped->enc_data->enc_data=os; 510 p7->d.signed_and_enveloped->enc_data->enc_data=os;
484 break; 511 break;
485 case NID_pkcs7_enveloped: 512 case NID_pkcs7_enveloped:
486 /* XXXXXXXXXXXXXXXX */ 513 /* XXXXXXXXXXXXXXXX */
487 os=ASN1_OCTET_STRING_new(); 514 os=M_ASN1_OCTET_STRING_new();
488 p7->d.enveloped->enc_data->enc_data=os; 515 p7->d.enveloped->enc_data->enc_data=os;
489 break; 516 break;
490 case NID_pkcs7_signed: 517 case NID_pkcs7_signed:
@@ -492,7 +519,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
492 os=p7->d.sign->contents->d.data; 519 os=p7->d.sign->contents->d.data;
493 /* If detached data then the content is excluded */ 520 /* If detached data then the content is excluded */
494 if(p7->detached) { 521 if(p7->detached) {
495 ASN1_OCTET_STRING_free(os); 522 M_ASN1_OCTET_STRING_free(os);
496 p7->d.sign->contents->d.data = NULL; 523 p7->d.sign->contents->d.data = NULL;
497 } 524 }
498 break; 525 break;
@@ -527,7 +554,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
527 PKCS7err(PKCS7_F_PKCS7_DATASIGN,PKCS7_R_INTERNAL_ERROR); 554 PKCS7err(PKCS7_F_PKCS7_DATASIGN,PKCS7_R_INTERNAL_ERROR);
528 goto err; 555 goto err;
529 } 556 }
530 if (EVP_MD_type(EVP_MD_CTX_type(mdc)) == j) 557 if (EVP_MD_CTX_type(mdc) == j)
531 break; 558 break;
532 else 559 else
533 btmp=btmp->next_bio; 560 btmp=btmp->next_bio;
@@ -561,10 +588,10 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
561 V_ASN1_UTCTIME,sign_time); 588 V_ASN1_UTCTIME,sign_time);
562 589
563 /* Add digest */ 590 /* Add digest */
564 md_tmp=EVP_MD_CTX_type(&ctx_tmp); 591 md_tmp=EVP_MD_CTX_md(&ctx_tmp);
565 EVP_DigestFinal(&ctx_tmp,md_data,&md_len); 592 EVP_DigestFinal(&ctx_tmp,md_data,&md_len);
566 digest=ASN1_OCTET_STRING_new(); 593 digest=M_ASN1_OCTET_STRING_new();
567 ASN1_OCTET_STRING_set(digest,md_data,md_len); 594 M_ASN1_OCTET_STRING_set(digest,md_data,md_len);
568 PKCS7_add_signed_attribute(si, 595 PKCS7_add_signed_attribute(si,
569 NID_pkcs9_messageDigest, 596 NID_pkcs9_messageDigest,
570 V_ASN1_OCTET_STRING,digest); 597 V_ASN1_OCTET_STRING,digest);
@@ -611,8 +638,17 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
611 goto err; 638 goto err;
612 } 639 }
613 BIO_get_mem_ptr(btmp,&buf_mem); 640 BIO_get_mem_ptr(btmp,&buf_mem);
614 ASN1_OCTET_STRING_set(os, 641 /* Mark the BIO read only then we can use its copy of the data
642 * instead of making an extra copy.
643 */
644 BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY);
645 BIO_set_mem_eof_return(btmp, 0);
646 os->data = (unsigned char *)buf_mem->data;
647 os->length = buf_mem->length;
648#if 0
649 M_ASN1_OCTET_STRING_set(os,
615 (unsigned char *)buf_mem->data,buf_mem->length); 650 (unsigned char *)buf_mem->data,buf_mem->length);
651#endif
616 } 652 }
617 if (pp != NULL) Free(pp); 653 if (pp != NULL) Free(pp);
618 pp=NULL; 654 pp=NULL;
@@ -658,6 +694,7 @@ int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio,
658 694
659 /* Lets verify */ 695 /* Lets verify */
660 X509_STORE_CTX_init(ctx,cert_store,x509,cert); 696 X509_STORE_CTX_init(ctx,cert_store,x509,cert);
697 X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_SMIME_SIGN);
661 i=X509_verify_cert(ctx); 698 i=X509_verify_cert(ctx);
662 if (i <= 0) 699 if (i <= 0)
663 { 700 {
@@ -709,7 +746,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
709 PKCS7_R_INTERNAL_ERROR); 746 PKCS7_R_INTERNAL_ERROR);
710 goto err; 747 goto err;
711 } 748 }
712 if (EVP_MD_type(EVP_MD_CTX_type(mdc)) == md_type) 749 if (EVP_MD_CTX_type(mdc) == md_type)
713 break; 750 break;
714 btmp=btmp->next_bio; 751 btmp=btmp->next_bio;
715 } 752 }
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_lib.c b/src/lib/libssl/src/crypto/pkcs7/pk7_lib.c
index 8b863d0558..45973fe850 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_lib.c
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_lib.c
@@ -123,7 +123,7 @@ int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data)
123 { 123 {
124 case NID_pkcs7_signed: 124 case NID_pkcs7_signed:
125 if (p7->d.sign->contents != NULL) 125 if (p7->d.sign->contents != NULL)
126 PKCS7_content_free(p7->d.sign->contents); 126 PKCS7_free(p7->d.sign->contents);
127 p7->d.sign->contents=p7_data; 127 p7->d.sign->contents=p7_data;
128 break; 128 break;
129 case NID_pkcs7_digest: 129 case NID_pkcs7_digest:
@@ -157,7 +157,7 @@ int PKCS7_set_type(PKCS7 *p7, int type)
157 break; 157 break;
158 case NID_pkcs7_data: 158 case NID_pkcs7_data:
159 p7->type=obj; 159 p7->type=obj;
160 if ((p7->d.data=ASN1_OCTET_STRING_new()) == NULL) 160 if ((p7->d.data=M_ASN1_OCTET_STRING_new()) == NULL)
161 goto err; 161 goto err;
162 break; 162 break;
163 case NID_pkcs7_signedAndEnveloped: 163 case NID_pkcs7_signedAndEnveloped:
@@ -165,9 +165,6 @@ int PKCS7_set_type(PKCS7 *p7, int type)
165 if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new()) 165 if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new())
166 == NULL) goto err; 166 == NULL) goto err;
167 ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1); 167 ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1);
168/* p7->d.signed_and_enveloped->enc_data->content_type=
169 OBJ_nid2obj(NID_pkcs7_encrypted);*/
170
171 break; 168 break;
172 case NID_pkcs7_enveloped: 169 case NID_pkcs7_enveloped:
173 p7->type=obj; 170 p7->type=obj;
@@ -175,8 +172,14 @@ int PKCS7_set_type(PKCS7 *p7, int type)
175 == NULL) goto err; 172 == NULL) goto err;
176 ASN1_INTEGER_set(p7->d.enveloped->version,0); 173 ASN1_INTEGER_set(p7->d.enveloped->version,0);
177 break; 174 break;
178 case NID_pkcs7_digest:
179 case NID_pkcs7_encrypted: 175 case NID_pkcs7_encrypted:
176 p7->type=obj;
177 if ((p7->d.encrypted=PKCS7_ENCRYPT_new())
178 == NULL) goto err;
179 ASN1_INTEGER_set(p7->d.encrypted->version,0);
180 break;
181
182 case NID_pkcs7_digest:
180 default: 183 default:
181 PKCS7err(PKCS7_F_PKCS7_SET_TYPE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE); 184 PKCS7err(PKCS7_F_PKCS7_SET_TYPE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
182 goto err; 185 goto err;
@@ -224,8 +227,13 @@ int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi)
224 } 227 }
225 if (!j) /* we need to add another algorithm */ 228 if (!j) /* we need to add another algorithm */
226 { 229 {
227 alg=X509_ALGOR_new(); 230 if(!(alg=X509_ALGOR_new())
231 || !(alg->parameter = ASN1_TYPE_new())) {
232 PKCS7err(PKCS7_F_PKCS7_ADD_SIGNER,ERR_R_MALLOC_FAILURE);
233 return(0);
234 }
228 alg->algorithm=OBJ_nid2obj(nid); 235 alg->algorithm=OBJ_nid2obj(nid);
236 alg->parameter->type = V_ASN1_NULL;
229 sk_X509_ALGOR_push(md_sk,alg); 237 sk_X509_ALGOR_push(md_sk,alg);
230 } 238 }
231 239
@@ -289,6 +297,9 @@ int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)
289int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, 297int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
290 EVP_MD *dgst) 298 EVP_MD *dgst)
291 { 299 {
300 char is_dsa;
301 if (pkey->type == EVP_PKEY_DSA) is_dsa = 1;
302 else is_dsa = 0;
292 /* We now need to add another PKCS7_SIGNER_INFO entry */ 303 /* We now need to add another PKCS7_SIGNER_INFO entry */
293 ASN1_INTEGER_set(p7i->version,1); 304 ASN1_INTEGER_set(p7i->version,1);
294 X509_NAME_set(&p7i->issuer_and_serial->issuer, 305 X509_NAME_set(&p7i->issuer_and_serial->issuer,
@@ -296,17 +307,16 @@ int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
296 307
297 /* because ASN1_INTEGER_set is used to set a 'long' we will do 308 /* because ASN1_INTEGER_set is used to set a 'long' we will do
298 * things the ugly way. */ 309 * things the ugly way. */
299 ASN1_INTEGER_free(p7i->issuer_and_serial->serial); 310 M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
300 p7i->issuer_and_serial->serial= 311 p7i->issuer_and_serial->serial=
301 ASN1_INTEGER_dup(X509_get_serialNumber(x509)); 312 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));
302 313
303 /* lets keep the pkey around for a while */ 314 /* lets keep the pkey around for a while */
304 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY); 315 CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
305 p7i->pkey=pkey; 316 p7i->pkey=pkey;
306 317
307 /* Set the algorithms */ 318 /* Set the algorithms */
308 if (pkey->type == EVP_PKEY_DSA) 319 if (is_dsa) p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
309 p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
310 else 320 else
311 p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst)); 321 p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst));
312 322
@@ -320,9 +330,12 @@ int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
320 330
321 if (p7i->digest_enc_alg->parameter != NULL) 331 if (p7i->digest_enc_alg->parameter != NULL)
322 ASN1_TYPE_free(p7i->digest_enc_alg->parameter); 332 ASN1_TYPE_free(p7i->digest_enc_alg->parameter);
323 if ((p7i->digest_enc_alg->parameter=ASN1_TYPE_new()) == NULL) 333 if(is_dsa) p7i->digest_enc_alg->parameter = NULL;
324 goto err; 334 else {
325 p7i->digest_enc_alg->parameter->type=V_ASN1_NULL; 335 if (!(p7i->digest_enc_alg->parameter=ASN1_TYPE_new()))
336 goto err;
337 p7i->digest_enc_alg->parameter->type=V_ASN1_NULL;
338 }
326 339
327 return(1); 340 return(1);
328err: 341err:
@@ -397,9 +410,9 @@ int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
397 X509_NAME_set(&p7i->issuer_and_serial->issuer, 410 X509_NAME_set(&p7i->issuer_and_serial->issuer,
398 X509_get_issuer_name(x509)); 411 X509_get_issuer_name(x509));
399 412
400 ASN1_INTEGER_free(p7i->issuer_and_serial->serial); 413 M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
401 p7i->issuer_and_serial->serial= 414 p7i->issuer_and_serial->serial=
402 ASN1_INTEGER_dup(X509_get_serialNumber(x509)); 415 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));
403 416
404 X509_ALGOR_free(p7i->key_enc_algor); 417 X509_ALGOR_free(p7i->key_enc_algor);
405 p7i->key_enc_algor=(X509_ALGOR *)ASN1_dup(i2d_X509_ALGOR, 418 p7i->key_enc_algor=(X509_ALGOR *)ASN1_dup(i2d_X509_ALGOR,
@@ -425,6 +438,7 @@ X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si)
425int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) 438int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
426 { 439 {
427 int i; 440 int i;
441 ASN1_OBJECT *objtmp;
428 PKCS7_ENC_CONTENT *ec; 442 PKCS7_ENC_CONTENT *ec;
429 443
430 i=OBJ_obj2nid(p7->type); 444 i=OBJ_obj2nid(p7->type);
@@ -441,7 +455,13 @@ int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
441 return(0); 455 return(0);
442 } 456 }
443 457
444 /* Setup cipher OID */ 458 /* Check cipher OID exists and has data in it*/
459 i = EVP_CIPHER_type(cipher);
460 if(i == NID_undef) {
461 PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
462 return(0);
463 }
464 objtmp = OBJ_nid2obj(i);
445 465
446 ec->cipher = cipher; 466 ec->cipher = cipher;
447 return 1; 467 return 1;
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c b/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c
new file mode 100644
index 0000000000..734643be28
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_mime.c
@@ -0,0 +1,673 @@
1/* pk7_mime.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 <ctype.h>
61#include "cryptlib.h"
62#include <openssl/rand.h>
63#include <openssl/x509.h>
64
65/* MIME and related routines */
66
67/* MIME format structures
68 * Note that all are translated to lower case apart from
69 * parameter values. Quotes are stripped off
70 */
71
72typedef struct {
73char *name; /* Name of line e.g. "content-type" */
74char *value; /* Value of line e.g. "text/plain" */
75STACK /* MIME_PARAM */ *params; /* Zero or more parameters */
76} MIME_HEADER;
77
78typedef struct {
79char *param_name; /* Param name e.g. "micalg" */
80char *param_value; /* Param value e.g. "sha1" */
81} MIME_PARAM;
82
83
84static int B64_write_PKCS7(BIO *bio, PKCS7 *p7);
85static PKCS7 *B64_read_PKCS7(BIO *bio);
86static char * strip_ends(char *name);
87static char * strip_start(char *name);
88static char * strip_end(char *name);
89static MIME_HEADER *mime_hdr_new(char *name, char *value);
90static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value);
91static STACK *mime_parse_hdr(BIO *bio);
92static int mime_hdr_cmp(MIME_HEADER **a, MIME_HEADER **b);
93static int mime_param_cmp(MIME_PARAM **a, MIME_PARAM **b);
94static void mime_param_free(MIME_PARAM *param);
95static int mime_bound_check(char *line, int linelen, char *bound, int blen);
96static int multi_split(BIO *bio, char *bound, STACK **ret);
97static int iscrlf(char c);
98static MIME_HEADER *mime_hdr_find(STACK *hdrs, char *name);
99static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name);
100static void mime_hdr_free(MIME_HEADER *hdr);
101
102#define MAX_SMLEN 1024
103#define mime_debug(x) /* x */
104
105
106typedef void (*stkfree)();
107
108/* Base 64 read and write of PKCS#7 structure */
109
110static int B64_write_PKCS7(BIO *bio, PKCS7 *p7)
111{
112 BIO *b64;
113 if(!(b64 = BIO_new(BIO_f_base64()))) {
114 PKCS7err(PKCS7_F_B64_WRITE_PKCS7,ERR_R_MALLOC_FAILURE);
115 return 0;
116 }
117 bio = BIO_push(b64, bio);
118 i2d_PKCS7_bio(bio, p7);
119 BIO_flush(bio);
120 bio = BIO_pop(bio);
121 BIO_free(b64);
122 return 1;
123}
124
125static PKCS7 *B64_read_PKCS7(BIO *bio)
126{
127 BIO *b64;
128 PKCS7 *p7;
129 if(!(b64 = BIO_new(BIO_f_base64()))) {
130 PKCS7err(PKCS7_F_B64_READ_PKCS7,ERR_R_MALLOC_FAILURE);
131 return 0;
132 }
133 bio = BIO_push(b64, bio);
134 if(!(p7 = d2i_PKCS7_bio(bio, NULL)))
135 PKCS7err(PKCS7_F_B64_READ_PKCS7,PKCS7_R_DECODE_ERROR);
136 BIO_flush(bio);
137 bio = BIO_pop(bio);
138 BIO_free(b64);
139 return p7;
140}
141
142/* SMIME sender */
143
144int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
145{
146 char linebuf[MAX_SMLEN];
147 char bound[33], c;
148 int i;
149 if((flags & PKCS7_DETACHED) && data) {
150 /* We want multipart/signed */
151 /* Generate a random boundary */
152 RAND_pseudo_bytes((unsigned char *)bound, 32);
153 for(i = 0; i < 32; i++) {
154 c = bound[i] & 0xf;
155 if(c < 10) c += '0';
156 else c += 'A' - 10;
157 bound[i] = c;
158 }
159 bound[32] = 0;
160 BIO_printf(bio, "MIME-Version: 1.0\n");
161 BIO_printf(bio, "Content-Type: multipart/signed ; ");
162 BIO_printf(bio, "protocol=\"application/x-pkcs7-signature\" ; ");
163 BIO_printf(bio, "micalg=sha1 ; boundary=\"----%s\"\n\n", bound);
164 BIO_printf(bio, "This is an S/MIME signed message\n\n");
165 /* Now write out the first part */
166 BIO_printf(bio, "------%s\r\n", bound);
167 if(flags & PKCS7_TEXT) BIO_printf(bio, "Content-Type: text/plain\n\n");
168 while((i = BIO_read(data, linebuf, MAX_SMLEN)) > 0)
169 BIO_write(bio, linebuf, i);
170 BIO_printf(bio, "\n------%s\n", bound);
171
172 /* Headers for signature */
173
174 BIO_printf(bio, "Content-Type: application/x-pkcs7-signature; name=\"smime.p7s\"\n");
175 BIO_printf(bio, "Content-Transfer-Encoding: base64\n");
176 BIO_printf(bio, "Content-Disposition: attachment; filename=\"smime.p7s\"\n\n");
177 B64_write_PKCS7(bio, p7);
178 BIO_printf(bio,"\n------%s--\n\n", bound);
179 return 1;
180 }
181 /* MIME headers */
182 BIO_printf(bio, "MIME-Version: 1.0\n");
183 BIO_printf(bio, "Content-Disposition: attachment; filename=\"smime.p7m\"\n");
184 BIO_printf(bio, "Content-Type: application/x-pkcs7-mime; name=\"smime.p7m\"\n");
185 BIO_printf(bio, "Content-Transfer-Encoding: base64\n\n");
186 B64_write_PKCS7(bio, p7);
187 BIO_printf(bio, "\n");
188 return 1;
189}
190
191/* SMIME reader: handle multipart/signed and opaque signing.
192 * in multipart case the content is placed in a memory BIO
193 * pointed to by "bcont". In opaque this is set to NULL
194 */
195
196PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont)
197{
198 BIO *p7in;
199 STACK *headers = NULL;
200 STACK *parts = NULL;
201 MIME_HEADER *hdr;
202 MIME_PARAM *prm;
203 PKCS7 *p7;
204 int ret;
205
206 if(bcont) *bcont = NULL;
207
208 if (!(headers = mime_parse_hdr(bio))) {
209 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_PARSE_ERROR);
210 return NULL;
211 }
212
213 if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
214 sk_pop_free(headers, mime_hdr_free);
215 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_CONTENT_TYPE);
216 return NULL;
217 }
218
219 /* Handle multipart/signed */
220
221 if(!strcmp(hdr->value, "multipart/signed")) {
222 /* Split into two parts */
223 prm = mime_param_find(hdr, "boundary");
224 if(!prm || !prm->param_value) {
225 sk_pop_free(headers, mime_hdr_free);
226 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BOUNDARY);
227 return NULL;
228 }
229 ret = multi_split(bio, prm->param_value, &parts);
230 sk_pop_free(headers, mime_hdr_free);
231 if(!ret || (sk_num(parts) != 2) ) {
232 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BODY_FAILURE);
233 sk_pop_free(parts, (stkfree)BIO_free);
234 return NULL;
235 }
236
237 /* Parse the signature piece */
238 p7in = (BIO *)sk_value(parts, 1);
239
240 if (!(headers = mime_parse_hdr(p7in))) {
241 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_SIG_PARSE_ERROR);
242 sk_pop_free(parts, (stkfree)BIO_free);
243 return NULL;
244 }
245
246 /* Get content type */
247
248 if(!(hdr = mime_hdr_find(headers, "content-type")) ||
249 !hdr->value) {
250 sk_pop_free(headers, mime_hdr_free);
251 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_SIG_CONTENT_TYPE);
252 return NULL;
253 }
254
255 if(strcmp(hdr->value, "application/x-pkcs7-signature") &&
256 strcmp(hdr->value, "application/pkcs7-signature")) {
257 sk_pop_free(headers, mime_hdr_free);
258 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_SIG_INVALID_MIME_TYPE);
259 ERR_add_error_data(2, "type: ", hdr->value);
260 sk_pop_free(parts, (stkfree)BIO_free);
261 return NULL;
262 }
263 sk_pop_free(headers, mime_hdr_free);
264 /* Read in PKCS#7 */
265 if(!(p7 = B64_read_PKCS7(p7in))) {
266 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_PKCS7_SIG_PARSE_ERROR);
267 sk_pop_free(parts, (stkfree)BIO_free);
268 return NULL;
269 }
270
271 if(bcont) {
272 *bcont = (BIO *)sk_value(parts, 0);
273 BIO_free(p7in);
274 sk_free(parts);
275 } else sk_pop_free(parts, (stkfree)BIO_free);
276 return p7;
277 }
278
279 /* OK, if not multipart/signed try opaque signature */
280
281 if (strcmp (hdr->value, "application/x-pkcs7-mime") &&
282 strcmp (hdr->value, "application/pkcs7-mime")) {
283 PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_INVALID_MIME_TYPE);
284 ERR_add_error_data(2, "type: ", hdr->value);
285 sk_pop_free(headers, mime_hdr_free);
286 return NULL;
287 }
288
289 sk_pop_free(headers, mime_hdr_free);
290
291 if(!(p7 = B64_read_PKCS7(bio))) {
292 PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_PKCS7_PARSE_ERROR);
293 return NULL;
294 }
295 return p7;
296
297}
298
299/* Copy text from one BIO to another making the output CRLF at EOL */
300int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
301{
302 char eol;
303 int len;
304 char linebuf[MAX_SMLEN];
305 if(flags & PKCS7_BINARY) {
306 while((len = BIO_read(in, linebuf, MAX_SMLEN)) > 0)
307 BIO_write(out, linebuf, len);
308 return 1;
309 }
310 if(flags & PKCS7_TEXT) BIO_printf(out, "Content-Type: text/plain\r\n\r\n");
311 while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) {
312 eol = 0;
313 while(iscrlf(linebuf[len - 1])) {
314 len--;
315 eol = 1;
316 }
317 BIO_write(out, linebuf, len);
318 if(eol) BIO_write(out, "\r\n", 2);
319 }
320 return 1;
321}
322
323/* Strip off headers if they are text/plain */
324int SMIME_text(BIO *in, BIO *out)
325{
326 char iobuf[4096];
327 int len;
328 STACK *headers;
329 MIME_HEADER *hdr;
330 if (!(headers = mime_parse_hdr(in))) {
331 PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_PARSE_ERROR);
332 return 0;
333 }
334 if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
335 PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_NO_CONTENT_TYPE);
336 sk_pop_free(headers, mime_hdr_free);
337 return 0;
338 }
339 if (strcmp (hdr->value, "text/plain")) {
340 PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_INVALID_MIME_TYPE);
341 ERR_add_error_data(2, "type: ", hdr->value);
342 sk_pop_free(headers, mime_hdr_free);
343 return 0;
344 }
345 sk_pop_free(headers, mime_hdr_free);
346 while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0)
347 BIO_write(out, iobuf, len);
348 return 1;
349}
350
351/* Split a multipart/XXX message body into component parts: result is
352 * canonical parts in a STACK of bios
353 */
354
355static int multi_split(BIO *bio, char *bound, STACK **ret)
356{
357 char linebuf[MAX_SMLEN];
358 int len, blen;
359 BIO *bpart = NULL;
360 STACK *parts;
361 char state, part, first;
362 blen = strlen(bound);
363 part = 0;
364 state = 0;
365 first = 1;
366 parts = sk_new(NULL);
367 *ret = parts;
368 while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
369 state = mime_bound_check(linebuf, len, bound, blen);
370 if(state == 1) {
371 first = 1;
372 part++;
373 } else if(state == 2) {
374 sk_push(parts, (char *)bpart);
375 return 1;
376 } else if(part) {
377 if(first) {
378 first = 0;
379 if(bpart) sk_push(parts, (char *)bpart);
380 bpart = BIO_new(BIO_s_mem());
381
382 } else BIO_write(bpart, "\r\n", 2);
383 /* Strip CR+LF from linebuf */
384 while(iscrlf(linebuf[len - 1])) len--;
385 BIO_write(bpart, linebuf, len);
386 }
387 }
388 return 0;
389}
390
391static int iscrlf(char c)
392{
393 if(c == '\r' || c == '\n') return 1;
394 return 0;
395}
396
397/* This is the big one: parse MIME header lines up to message body */
398
399#define MIME_INVALID 0
400#define MIME_START 1
401#define MIME_TYPE 2
402#define MIME_NAME 3
403#define MIME_VALUE 4
404#define MIME_QUOTE 5
405#define MIME_COMMENT 6
406
407
408static STACK *mime_parse_hdr(BIO *bio)
409{
410 char *p, *q, c;
411 char *ntmp;
412 char linebuf[MAX_SMLEN];
413 MIME_HEADER *mhdr = NULL;
414 STACK *headers;
415 int len, state, save_state = 0;
416 headers = sk_new(mime_hdr_cmp);
417 while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
418 /* If whitespace at line start then continuation line */
419 if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME;
420 else state = MIME_START;
421 ntmp = NULL;
422 /* Go through all characters */
423 for(p = linebuf, q = linebuf; (c = *p) && (c!='\r') && (c!='\n'); p++) {
424
425 /* State machine to handle MIME headers
426 * if this looks horrible that's because it *is*
427 */
428
429 switch(state) {
430 case MIME_START:
431 if(c == ':') {
432 state = MIME_TYPE;
433 *p = 0;
434 ntmp = strip_ends(q);
435 q = p + 1;
436 }
437 break;
438
439 case MIME_TYPE:
440 if(c == ';') {
441 mime_debug("Found End Value\n");
442 *p = 0;
443 mhdr = mime_hdr_new(ntmp, strip_ends(q));
444 sk_push(headers, (char *)mhdr);
445 ntmp = NULL;
446 q = p + 1;
447 state = MIME_NAME;
448 } else if(c == '(') {
449 save_state = state;
450 state = MIME_COMMENT;
451 }
452 break;
453
454 case MIME_COMMENT:
455 if(c == ')') {
456 state = save_state;
457 }
458 break;
459
460 case MIME_NAME:
461 if(c == '=') {
462 state = MIME_VALUE;
463 *p = 0;
464 ntmp = strip_ends(q);
465 q = p + 1;
466 }
467 break ;
468
469 case MIME_VALUE:
470 if(c == ';') {
471 state = MIME_NAME;
472 *p = 0;
473 mime_hdr_addparam(mhdr, ntmp, strip_ends(q));
474 ntmp = NULL;
475 q = p + 1;
476 } else if (c == '"') {
477 mime_debug("Found Quote\n");
478 state = MIME_QUOTE;
479 } else if(c == '(') {
480 save_state = state;
481 state = MIME_COMMENT;
482 }
483 break;
484
485 case MIME_QUOTE:
486 if(c == '"') {
487 mime_debug("Found Match Quote\n");
488 state = MIME_VALUE;
489 }
490 break;
491 }
492 }
493
494 if(state == MIME_TYPE) {
495 mhdr = mime_hdr_new(ntmp, strip_ends(q));
496 sk_push(headers, (char *)mhdr);
497 } else if(state == MIME_VALUE)
498 mime_hdr_addparam(mhdr, ntmp, strip_ends(q));
499 if(p == linebuf) break; /* Blank line means end of headers */
500}
501
502return headers;
503
504}
505
506static char *strip_ends(char *name)
507{
508 return strip_end(strip_start(name));
509}
510
511/* Strip a parameter of whitespace from start of param */
512static char *strip_start(char *name)
513{
514 char *p, c;
515 /* Look for first non white space or quote */
516 for(p = name; (c = *p) ;p++) {
517 if(c == '"') {
518 /* Next char is start of string if non null */
519 if(p[1]) return p + 1;
520 /* Else null string */
521 return NULL;
522 }
523 if(!isspace((unsigned char)c)) return p;
524 }
525 return NULL;
526}
527
528/* As above but strip from end of string : maybe should handle brackets? */
529static char *strip_end(char *name)
530{
531 char *p, c;
532 if(!name) return NULL;
533 /* Look for first non white space or quote */
534 for(p = name + strlen(name) - 1; p >= name ;p--) {
535 c = *p;
536 if(c == '"') {
537 if(p - 1 == name) return NULL;
538 *p = 0;
539 return name;
540 }
541 if(isspace((unsigned char)c)) *p = 0;
542 else return name;
543 }
544 return NULL;
545}
546
547static MIME_HEADER *mime_hdr_new(char *name, char *value)
548{
549 MIME_HEADER *mhdr;
550 char *tmpname, *tmpval, *p;
551 int c;
552 if(name) {
553 if(!(tmpname = BUF_strdup(name))) return NULL;
554 for(p = tmpname ; *p; p++) {
555 c = *p;
556 if(isupper(c)) {
557 c = tolower(c);
558 *p = c;
559 }
560 }
561 } else tmpname = NULL;
562 if(value) {
563 if(!(tmpval = BUF_strdup(value))) return NULL;
564 for(p = tmpval ; *p; p++) {
565 c = *p;
566 if(isupper(c)) {
567 c = tolower(c);
568 *p = c;
569 }
570 }
571 } else tmpval = NULL;
572 mhdr = (MIME_HEADER *) Malloc(sizeof(MIME_HEADER));
573 if(!mhdr) return NULL;
574 mhdr->name = tmpname;
575 mhdr->value = tmpval;
576 if(!(mhdr->params = sk_new(mime_param_cmp))) return NULL;
577 return mhdr;
578}
579
580static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
581{
582 char *tmpname, *tmpval, *p;
583 int c;
584 MIME_PARAM *mparam;
585 if(name) {
586 tmpname = BUF_strdup(name);
587 if(!tmpname) return 0;
588 for(p = tmpname ; *p; p++) {
589 c = *p;
590 if(isupper(c)) {
591 c = tolower(c);
592 *p = c;
593 }
594 }
595 } else tmpname = NULL;
596 if(value) {
597 tmpval = BUF_strdup(value);
598 if(!tmpval) return 0;
599 } else tmpval = NULL;
600 /* Parameter values are case sensitive so leave as is */
601 mparam = (MIME_PARAM *) Malloc(sizeof(MIME_PARAM));
602 if(!mparam) return 0;
603 mparam->param_name = tmpname;
604 mparam->param_value = tmpval;
605 sk_push(mhdr->params, (char *)mparam);
606 return 1;
607}
608
609static int mime_hdr_cmp(MIME_HEADER **a, MIME_HEADER **b)
610{
611 return(strcmp((*a)->name, (*b)->name));
612}
613
614static int mime_param_cmp(MIME_PARAM **a, MIME_PARAM **b)
615{
616 return(strcmp((*a)->param_name, (*b)->param_name));
617}
618
619/* Find a header with a given name (if possible) */
620
621static MIME_HEADER *mime_hdr_find(STACK *hdrs, char *name)
622{
623 MIME_HEADER htmp;
624 int idx;
625 htmp.name = name;
626 idx = sk_find(hdrs, (char *)&htmp);
627 if(idx < 0) return NULL;
628 return (MIME_HEADER *)sk_value(hdrs, idx);
629}
630
631static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name)
632{
633 MIME_PARAM param;
634 int idx;
635 param.param_name = name;
636 idx = sk_find(hdr->params, (char *)&param);
637 if(idx < 0) return NULL;
638 return (MIME_PARAM *)sk_value(hdr->params, idx);
639}
640
641static void mime_hdr_free(MIME_HEADER *hdr)
642{
643 if(hdr->name) Free(hdr->name);
644 if(hdr->value) Free(hdr->value);
645 if(hdr->params) sk_pop_free(hdr->params, mime_param_free);
646 Free(hdr);
647}
648
649static void mime_param_free(MIME_PARAM *param)
650{
651 if(param->param_name) Free(param->param_name);
652 if(param->param_value) Free(param->param_value);
653 Free(param);
654}
655
656/* Check for a multipart boundary. Returns:
657 * 0 : no boundary
658 * 1 : part boundary
659 * 2 : final boundary
660 */
661static int mime_bound_check(char *line, int linelen, char *bound, int blen)
662{
663 if(linelen == -1) linelen = strlen(line);
664 if(blen == -1) blen = strlen(bound);
665 /* Quickly eliminate if line length too short */
666 if(blen + 2 > linelen) return 0;
667 /* Check for part boundary */
668 if(!strncmp(line, "--", 2) && !strncmp(line + 2, bound, blen)) {
669 if(!strncmp(line + blen + 2, "--", 2)) return 2;
670 else return 1;
671 }
672 return 0;
673}
diff --git a/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c b/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
new file mode 100644
index 0000000000..b41f42ed04
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
@@ -0,0 +1,427 @@
1/* pk7_smime.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59/* Simple PKCS#7 processing functions */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
65
66PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
67 BIO *data, int flags)
68{
69 PKCS7 *p7;
70 PKCS7_SIGNER_INFO *si;
71 BIO *p7bio;
72 STACK *smcap;
73 int i;
74
75 if(!X509_check_private_key(signcert, pkey)) {
76 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
77 return NULL;
78 }
79
80 if(!(p7 = PKCS7_new())) {
81 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
82 return NULL;
83 }
84
85 PKCS7_set_type(p7, NID_pkcs7_signed);
86
87 PKCS7_content_new(p7, NID_pkcs7_data);
88
89 if (!(si = PKCS7_add_signature(p7,signcert,pkey,EVP_sha1()))) {
90 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR);
91 return NULL;
92 }
93
94 if(!(flags & PKCS7_NOCERTS)) {
95 PKCS7_add_certificate(p7, signcert);
96 if(certs) for(i = 0; i < sk_X509_num(certs); i++)
97 PKCS7_add_certificate(p7, sk_X509_value(certs, i));
98 }
99
100 if(!(p7bio = PKCS7_dataInit(p7, NULL))) {
101 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
102 return NULL;
103 }
104
105
106 SMIME_crlf_copy(data, p7bio, flags);
107
108 if(!(flags & PKCS7_NOATTR)) {
109 PKCS7_add_signed_attribute(si, NID_pkcs9_contentType,
110 V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data));
111 /* Add SMIMECapabilities */
112 if(!(smcap = sk_new(NULL))) {
113 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
114 return NULL;
115 }
116#ifndef NO_DES
117 PKCS7_simple_smimecap (smcap, NID_des_ede3_cbc, -1);
118#endif
119#ifndef NO_RC2
120 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 128);
121 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 64);
122#endif
123#ifndef NO_DES
124 PKCS7_simple_smimecap (smcap, NID_des_cbc, -1);
125#endif
126#ifndef NO_RC2
127 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40);
128#endif
129 PKCS7_add_attrib_smimecap (si, smcap);
130 sk_pop_free(smcap, X509_ALGOR_free);
131 }
132
133 if(flags & PKCS7_DETACHED)PKCS7_set_detached(p7, 1);
134
135 if (!PKCS7_dataFinal(p7,p7bio)) {
136 PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_DATASIGN);
137 return NULL;
138 }
139
140 BIO_free_all(p7bio);
141 return p7;
142}
143
144int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
145 BIO *indata, BIO *out, int flags)
146{
147 STACK_OF(X509) *signers;
148 X509 *signer;
149 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
150 PKCS7_SIGNER_INFO *si;
151 X509_STORE_CTX cert_ctx;
152 char buf[4096];
153 int i, j=0;
154 BIO *p7bio;
155 BIO *tmpout;
156
157 if(!p7) {
158 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_INVALID_NULL_POINTER);
159 return 0;
160 }
161
162 if(!PKCS7_type_is_signed(p7)) {
163 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_WRONG_CONTENT_TYPE);
164 return 0;
165 }
166
167 /* Check for no data and no content: no data to verify signature */
168 if(PKCS7_get_detached(p7) && !indata) {
169 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_NO_CONTENT);
170 return 0;
171 }
172
173 /* Check for data and content: two sets of data */
174 if(!PKCS7_get_detached(p7) && indata) {
175 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_CONTENT_AND_DATA_PRESENT);
176 return 0;
177 }
178
179 sinfos = PKCS7_get_signer_info(p7);
180
181 if(!sinfos || !sk_PKCS7_SIGNER_INFO_num(sinfos)) {
182 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_NO_SIGNATURES_ON_DATA);
183 return 0;
184 }
185
186
187 signers = PKCS7_get0_signers(p7, certs, flags);
188
189 if(!signers) return 0;
190
191 /* Now verify the certificates */
192
193 if (!(flags & PKCS7_NOVERIFY)) for (i = 0; i < sk_X509_num(signers); i++) {
194 signer = sk_X509_value (signers, i);
195 if (!(flags & PKCS7_NOCHAIN)) {
196 X509_STORE_CTX_init(&cert_ctx, store, signer,
197 p7->d.sign->cert);
198 X509_STORE_CTX_set_purpose(&cert_ctx,
199 X509_PURPOSE_SMIME_SIGN);
200 } else X509_STORE_CTX_init (&cert_ctx, store, signer, NULL);
201 i = X509_verify_cert(&cert_ctx);
202 if (i <= 0) j = X509_STORE_CTX_get_error(&cert_ctx);
203 X509_STORE_CTX_cleanup(&cert_ctx);
204 if (i <= 0) {
205 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_CERTIFICATE_VERIFY_ERROR);
206 ERR_add_error_data(2, "Verify error:",
207 X509_verify_cert_error_string(j));
208 sk_X509_free(signers);
209 return 0;
210 }
211 /* Check for revocation status here */
212 }
213
214 p7bio=PKCS7_dataInit(p7,indata);
215
216 if(flags & PKCS7_TEXT) {
217 if(!(tmpout = BIO_new(BIO_s_mem()))) {
218 PKCS7err(PKCS7_F_PKCS7_VERIFY,ERR_R_MALLOC_FAILURE);
219 goto err;
220 }
221 } else tmpout = out;
222
223 /* We now have to 'read' from p7bio to calculate digests etc. */
224 for (;;)
225 {
226 i=BIO_read(p7bio,buf,sizeof(buf));
227 if (i <= 0) break;
228 if (tmpout) BIO_write(tmpout, buf, i);
229 }
230
231 if(flags & PKCS7_TEXT) {
232 if(!SMIME_text(tmpout, out)) {
233 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_SMIME_TEXT_ERROR);
234 BIO_free(tmpout);
235 goto err;
236 }
237 BIO_free(tmpout);
238 }
239
240 /* Now Verify All Signatures */
241 if (!(flags & PKCS7_NOSIGS))
242 for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
243 {
244 si=sk_PKCS7_SIGNER_INFO_value(sinfos,i);
245 signer = sk_X509_value (signers, i);
246 j=PKCS7_signatureVerify(p7bio,p7,si, signer);
247 if (j <= 0) {
248 PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_SIGNATURE_FAILURE);
249 goto err;
250 }
251 }
252
253 sk_X509_free(signers);
254 if(indata) BIO_pop(p7bio);
255 BIO_free_all(p7bio);
256
257 return 1;
258
259 err:
260
261 sk_X509_free(signers);
262 BIO_free(p7bio);
263
264 return 0;
265}
266
267STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
268{
269 STACK_OF(X509) *signers;
270 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
271 PKCS7_SIGNER_INFO *si;
272 PKCS7_ISSUER_AND_SERIAL *ias;
273 X509 *signer;
274 int i;
275
276 if(!p7) {
277 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_INVALID_NULL_POINTER);
278 return NULL;
279 }
280
281 if(!PKCS7_type_is_signed(p7)) {
282 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_WRONG_CONTENT_TYPE);
283 return NULL;
284 }
285 if(!(signers = sk_X509_new(NULL))) {
286 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,ERR_R_MALLOC_FAILURE);
287 return NULL;
288 }
289
290 /* Collect all the signers together */
291
292 sinfos = PKCS7_get_signer_info(p7);
293
294 if(sk_PKCS7_SIGNER_INFO_num(sinfos) <= 0) {
295 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_NO_SIGNERS);
296 return 0;
297 }
298
299 for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
300 {
301 si = sk_PKCS7_SIGNER_INFO_value(sinfos, i);
302 ias = si->issuer_and_serial;
303 signer = NULL;
304 /* If any certificates passed they take priority */
305 if (certs) signer = X509_find_by_issuer_and_serial (certs,
306 ias->issuer, ias->serial);
307 if (!signer && !(flags & PKCS7_NOINTERN)
308 && p7->d.sign->cert) signer =
309 X509_find_by_issuer_and_serial (p7->d.sign->cert,
310 ias->issuer, ias->serial);
311 if (!signer) {
312 PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND);
313 sk_X509_free(signers);
314 return 0;
315 }
316
317 sk_X509_push(signers, signer);
318 }
319 return signers;
320}
321
322
323/* Build a complete PKCS#7 enveloped data */
324
325PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
326 int flags)
327{
328 PKCS7 *p7;
329 BIO *p7bio = NULL;
330 int i;
331 X509 *x509;
332 if(!(p7 = PKCS7_new())) {
333 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,ERR_R_MALLOC_FAILURE);
334 return NULL;
335 }
336
337 PKCS7_set_type(p7, NID_pkcs7_enveloped);
338 if(!PKCS7_set_cipher(p7, cipher)) {
339 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_ERROR_SETTING_CIPHER);
340 goto err;
341 }
342
343 for(i = 0; i < sk_X509_num(certs); i++) {
344 x509 = sk_X509_value(certs, i);
345 if(!PKCS7_add_recipient(p7, x509)) {
346 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,
347 PKCS7_R_ERROR_ADDING_RECIPIENT);
348 goto err;
349 }
350 }
351
352 if(!(p7bio = PKCS7_dataInit(p7, NULL))) {
353 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,ERR_R_MALLOC_FAILURE);
354 goto err;
355 }
356
357 SMIME_crlf_copy(in, p7bio, flags);
358
359 BIO_flush(p7bio);
360
361 if (!PKCS7_dataFinal(p7,p7bio)) {
362 PKCS7err(PKCS7_F_PKCS7_ENCRYPT,PKCS7_R_PKCS7_DATAFINAL_ERROR);
363 goto err;
364 }
365 BIO_free_all(p7bio);
366
367 return p7;
368
369 err:
370
371 BIO_free(p7bio);
372 PKCS7_free(p7);
373 return NULL;
374
375}
376
377int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
378{
379 BIO *tmpmem;
380 int ret, i;
381 char buf[4096];
382
383 if(!p7) {
384 PKCS7err(PKCS7_F_PKCS7_DECRYPT,PKCS7_R_INVALID_NULL_POINTER);
385 return 0;
386 }
387
388 if(!PKCS7_type_is_enveloped(p7)) {
389 PKCS7err(PKCS7_F_PKCS7_DECRYPT,PKCS7_R_WRONG_CONTENT_TYPE);
390 return 0;
391 }
392
393 if(!X509_check_private_key(cert, pkey)) {
394 PKCS7err(PKCS7_F_PKCS7_DECRYPT,
395 PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
396 return 0;
397 }
398
399 if(!(tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert))) {
400 PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_DECRYPT_ERROR);
401 return 0;
402 }
403
404 if (flags & PKCS7_TEXT) {
405 BIO *tmpbuf, *bread;
406 /* Encrypt BIOs can't do BIO_gets() so add a buffer BIO */
407 if(!(tmpbuf = BIO_new(BIO_f_buffer()))) {
408 PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
409 return 0;
410 }
411 if(!(bread = BIO_push(tmpbuf, tmpmem))) {
412 PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
413 return 0;
414 }
415 ret = SMIME_text(bread, data);
416 BIO_free_all(bread);
417 return ret;
418 } else {
419 for(;;) {
420 i = BIO_read(tmpmem, buf, sizeof(buf));
421 if(i <= 0) break;
422 BIO_write(data, buf, i);
423 }
424 BIO_free_all(tmpmem);
425 return 1;
426 }
427}
diff --git a/src/lib/libssl/src/crypto/pkcs7/pkcs7.h b/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
index c42bd6d391..3ec725d226 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
+++ b/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
@@ -71,8 +71,9 @@ extern "C" {
71#endif 71#endif
72 72
73#ifdef WIN32 73#ifdef WIN32
74/* Under Win32 this is defined in wincrypt.h */ 74/* Under Win32 thes are defined in wincrypt.h */
75#undef PKCS7_ISSUER_AND_SERIAL 75#undef PKCS7_ISSUER_AND_SERIAL
76#undef PKCS7_SIGNER_INFO
76#endif 77#endif
77 78
78/* 79/*
@@ -219,6 +220,7 @@ typedef struct pkcs7_st
219#define PKCS7_get_attributes(si) ((si)->unauth_attr) 220#define PKCS7_get_attributes(si) ((si)->unauth_attr)
220 221
221#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) 222#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
223#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
222#define PKCS7_type_is_signedAndEnveloped(a) \ 224#define PKCS7_type_is_signedAndEnveloped(a) \
223 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) 225 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
224#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) 226#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
@@ -236,6 +238,29 @@ typedef struct pkcs7_st
236#endif 238#endif
237#endif 239#endif
238 240
241/* S/MIME related flags */
242
243#define PKCS7_TEXT 0x1
244#define PKCS7_NOCERTS 0x2
245#define PKCS7_NOSIGS 0x4
246#define PKCS7_NOCHAIN 0x8
247#define PKCS7_NOINTERN 0x10
248#define PKCS7_NOVERIFY 0x20
249#define PKCS7_DETACHED 0x40
250#define PKCS7_BINARY 0x80
251#define PKCS7_NOATTR 0x100
252
253/* Flags: for compatibility with older code */
254
255#define SMIME_TEXT PKCS7_TEXT
256#define SMIME_NOCERTS PKCS7_NOCERTS
257#define SMIME_NOSIGS PKCS7_NOSIGS
258#define SMIME_NOCHAIN PKCS7_NOCHAIN
259#define SMIME_NOINTERN PKCS7_NOINTERN
260#define SMIME_NOVERIFY PKCS7_NOVERIFY
261#define SMIME_DETACHED PKCS7_DETACHED
262#define SMIME_BINARY PKCS7_BINARY
263#define SMIME_NOATTR PKCS7_NOATTR
239 264
240PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void ); 265PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void );
241void PKCS7_ISSUER_AND_SERIAL_free( 266void PKCS7_ISSUER_AND_SERIAL_free(
@@ -247,7 +272,7 @@ PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(
247 unsigned char **pp, long length); 272 unsigned char **pp, long length);
248 273
249#ifndef SSLEAY_MACROS 274#ifndef SSLEAY_MACROS
250int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,EVP_MD *type, 275int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
251 unsigned char *md,unsigned int *len); 276 unsigned char *md,unsigned int *len);
252#ifndef NO_FP_API 277#ifndef NO_FP_API
253PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); 278PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
@@ -368,6 +393,23 @@ int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
368int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); 393int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
369 394
370 395
396PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
397 BIO *data, int flags);
398int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
399 BIO *indata, BIO *out, int flags);
400STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
401PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
402 int flags);
403int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
404
405int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap);
406STACK *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
407int PKCS7_simple_smimecap(STACK *sk, int nid, int arg);
408
409int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
410PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
411int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
412int SMIME_text(BIO *in, BIO *out);
371 413
372/* BEGIN ERROR CODES */ 414/* BEGIN ERROR CODES */
373/* The following lines are auto generated by the script mkerr.pl. Any changes 415/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -377,6 +419,9 @@ int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
377/* Error codes for the PKCS7 functions. */ 419/* Error codes for the PKCS7 functions. */
378 420
379/* Function codes. */ 421/* Function codes. */
422#define PKCS7_F_B64_READ_PKCS7 120
423#define PKCS7_F_B64_WRITE_PKCS7 121
424#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118
380#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 425#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
381#define PKCS7_F_PKCS7_ADD_CRL 101 426#define PKCS7_F_PKCS7_ADD_CRL 101
382#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 427#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
@@ -386,20 +431,56 @@ int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk);
386#define PKCS7_F_PKCS7_DATAINIT 105 431#define PKCS7_F_PKCS7_DATAINIT 105
387#define PKCS7_F_PKCS7_DATASIGN 106 432#define PKCS7_F_PKCS7_DATASIGN 106
388#define PKCS7_F_PKCS7_DATAVERIFY 107 433#define PKCS7_F_PKCS7_DATAVERIFY 107
434#define PKCS7_F_PKCS7_DECRYPT 114
435#define PKCS7_F_PKCS7_ENCRYPT 115
436#define PKCS7_F_PKCS7_GET0_SIGNERS 124
389#define PKCS7_F_PKCS7_SET_CIPHER 108 437#define PKCS7_F_PKCS7_SET_CIPHER 108
390#define PKCS7_F_PKCS7_SET_CONTENT 109 438#define PKCS7_F_PKCS7_SET_CONTENT 109
391#define PKCS7_F_PKCS7_SET_TYPE 110 439#define PKCS7_F_PKCS7_SET_TYPE 110
440#define PKCS7_F_PKCS7_SIGN 116
392#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 441#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113
442#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119
443#define PKCS7_F_PKCS7_VERIFY 117
444#define PKCS7_F_SMIME_READ_PKCS7 122
445#define PKCS7_F_SMIME_TEXT 123
393 446
394/* Reason codes. */ 447/* Reason codes. */
448#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117
449#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144
395#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 450#define PKCS7_R_CIPHER_NOT_INITIALIZED 116
451#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118
452#define PKCS7_R_DECODE_ERROR 130
396#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 453#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100
454#define PKCS7_R_DECRYPT_ERROR 119
397#define PKCS7_R_DIGEST_FAILURE 101 455#define PKCS7_R_DIGEST_FAILURE 101
456#define PKCS7_R_ERROR_ADDING_RECIPIENT 120
457#define PKCS7_R_ERROR_SETTING_CIPHER 121
398#define PKCS7_R_INTERNAL_ERROR 102 458#define PKCS7_R_INTERNAL_ERROR 102
459#define PKCS7_R_INVALID_MIME_TYPE 131
460#define PKCS7_R_INVALID_NULL_POINTER 143
461#define PKCS7_R_MIME_NO_CONTENT_TYPE 132
462#define PKCS7_R_MIME_PARSE_ERROR 133
463#define PKCS7_R_MIME_SIG_PARSE_ERROR 134
399#define PKCS7_R_MISSING_CERIPEND_INFO 103 464#define PKCS7_R_MISSING_CERIPEND_INFO 103
465#define PKCS7_R_NO_CONTENT 122
466#define PKCS7_R_NO_CONTENT_TYPE 135
467#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136
468#define PKCS7_R_NO_MULTIPART_BOUNDARY 137
400#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 469#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115
470#define PKCS7_R_NO_SIGNATURES_ON_DATA 123
471#define PKCS7_R_NO_SIGNERS 142
472#define PKCS7_R_NO_SIG_CONTENT_TYPE 138
401#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 473#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104
474#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124
475#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125
476#define PKCS7_R_PKCS7_DATASIGN 126
477#define PKCS7_R_PKCS7_PARSE_ERROR 139
478#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140
479#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127
402#define PKCS7_R_SIGNATURE_FAILURE 105 480#define PKCS7_R_SIGNATURE_FAILURE 105
481#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128
482#define PKCS7_R_SIG_INVALID_MIME_TYPE 141
483#define PKCS7_R_SMIME_TEXT_ERROR 129
403#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 484#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106
404#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 485#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107
405#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 486#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108
diff --git a/src/lib/libssl/src/crypto/pkcs7/pkcs7err.c b/src/lib/libssl/src/crypto/pkcs7/pkcs7err.c
index 82be3c2ca1..813a8af9ed 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pkcs7err.c
+++ b/src/lib/libssl/src/crypto/pkcs7/pkcs7err.c
@@ -65,6 +65,9 @@
65#ifndef NO_ERR 65#ifndef NO_ERR
66static ERR_STRING_DATA PKCS7_str_functs[]= 66static ERR_STRING_DATA PKCS7_str_functs[]=
67 { 67 {
68{ERR_PACK(0,PKCS7_F_B64_READ_PKCS7,0), "B64_READ_PKCS7"},
69{ERR_PACK(0,PKCS7_F_B64_WRITE_PKCS7,0), "B64_WRITE_PKCS7"},
70{ERR_PACK(0,PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,0), "PKCS7_add_attrib_smimecap"},
68{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CERTIFICATE,0), "PKCS7_add_certificate"}, 71{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CERTIFICATE,0), "PKCS7_add_certificate"},
69{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CRL,0), "PKCS7_add_crl"}, 72{ERR_PACK(0,PKCS7_F_PKCS7_ADD_CRL,0), "PKCS7_add_crl"},
70{ERR_PACK(0,PKCS7_F_PKCS7_ADD_RECIPIENT_INFO,0), "PKCS7_add_recipient_info"}, 73{ERR_PACK(0,PKCS7_F_PKCS7_ADD_RECIPIENT_INFO,0), "PKCS7_add_recipient_info"},
@@ -74,23 +77,59 @@ static ERR_STRING_DATA PKCS7_str_functs[]=
74{ERR_PACK(0,PKCS7_F_PKCS7_DATAINIT,0), "PKCS7_dataInit"}, 77{ERR_PACK(0,PKCS7_F_PKCS7_DATAINIT,0), "PKCS7_dataInit"},
75{ERR_PACK(0,PKCS7_F_PKCS7_DATASIGN,0), "PKCS7_DATASIGN"}, 78{ERR_PACK(0,PKCS7_F_PKCS7_DATASIGN,0), "PKCS7_DATASIGN"},
76{ERR_PACK(0,PKCS7_F_PKCS7_DATAVERIFY,0), "PKCS7_dataVerify"}, 79{ERR_PACK(0,PKCS7_F_PKCS7_DATAVERIFY,0), "PKCS7_dataVerify"},
80{ERR_PACK(0,PKCS7_F_PKCS7_DECRYPT,0), "PKCS7_decrypt"},
81{ERR_PACK(0,PKCS7_F_PKCS7_ENCRYPT,0), "PKCS7_encrypt"},
82{ERR_PACK(0,PKCS7_F_PKCS7_GET0_SIGNERS,0), "PKCS7_get0_signers"},
77{ERR_PACK(0,PKCS7_F_PKCS7_SET_CIPHER,0), "PKCS7_set_cipher"}, 83{ERR_PACK(0,PKCS7_F_PKCS7_SET_CIPHER,0), "PKCS7_set_cipher"},
78{ERR_PACK(0,PKCS7_F_PKCS7_SET_CONTENT,0), "PKCS7_set_content"}, 84{ERR_PACK(0,PKCS7_F_PKCS7_SET_CONTENT,0), "PKCS7_set_content"},
79{ERR_PACK(0,PKCS7_F_PKCS7_SET_TYPE,0), "PKCS7_set_type"}, 85{ERR_PACK(0,PKCS7_F_PKCS7_SET_TYPE,0), "PKCS7_set_type"},
86{ERR_PACK(0,PKCS7_F_PKCS7_SIGN,0), "PKCS7_sign"},
80{ERR_PACK(0,PKCS7_F_PKCS7_SIGNATUREVERIFY,0), "PKCS7_signatureVerify"}, 87{ERR_PACK(0,PKCS7_F_PKCS7_SIGNATUREVERIFY,0), "PKCS7_signatureVerify"},
88{ERR_PACK(0,PKCS7_F_PKCS7_SIMPLE_SMIMECAP,0), "PKCS7_simple_smimecap"},
89{ERR_PACK(0,PKCS7_F_PKCS7_VERIFY,0), "PKCS7_verify"},
90{ERR_PACK(0,PKCS7_F_SMIME_READ_PKCS7,0), "SMIME_read_PKCS7"},
91{ERR_PACK(0,PKCS7_F_SMIME_TEXT,0), "SMIME_text"},
81{0,NULL} 92{0,NULL}
82 }; 93 };
83 94
84static ERR_STRING_DATA PKCS7_str_reasons[]= 95static ERR_STRING_DATA PKCS7_str_reasons[]=
85 { 96 {
97{PKCS7_R_CERTIFICATE_VERIFY_ERROR ,"certificate verify error"},
98{PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER ,"cipher has no object identifier"},
86{PKCS7_R_CIPHER_NOT_INITIALIZED ,"cipher not initialized"}, 99{PKCS7_R_CIPHER_NOT_INITIALIZED ,"cipher not initialized"},
100{PKCS7_R_CONTENT_AND_DATA_PRESENT ,"content and data present"},
101{PKCS7_R_DECODE_ERROR ,"decode error"},
87{PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH ,"decrypted key is wrong length"}, 102{PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH ,"decrypted key is wrong length"},
103{PKCS7_R_DECRYPT_ERROR ,"decrypt error"},
88{PKCS7_R_DIGEST_FAILURE ,"digest failure"}, 104{PKCS7_R_DIGEST_FAILURE ,"digest failure"},
105{PKCS7_R_ERROR_ADDING_RECIPIENT ,"error adding recipient"},
106{PKCS7_R_ERROR_SETTING_CIPHER ,"error setting cipher"},
89{PKCS7_R_INTERNAL_ERROR ,"internal error"}, 107{PKCS7_R_INTERNAL_ERROR ,"internal error"},
108{PKCS7_R_INVALID_MIME_TYPE ,"invalid mime type"},
109{PKCS7_R_INVALID_NULL_POINTER ,"invalid null pointer"},
110{PKCS7_R_MIME_NO_CONTENT_TYPE ,"mime no content type"},
111{PKCS7_R_MIME_PARSE_ERROR ,"mime parse error"},
112{PKCS7_R_MIME_SIG_PARSE_ERROR ,"mime sig parse error"},
90{PKCS7_R_MISSING_CERIPEND_INFO ,"missing ceripend info"}, 113{PKCS7_R_MISSING_CERIPEND_INFO ,"missing ceripend info"},
114{PKCS7_R_NO_CONTENT ,"no content"},
115{PKCS7_R_NO_CONTENT_TYPE ,"no content type"},
116{PKCS7_R_NO_MULTIPART_BODY_FAILURE ,"no multipart body failure"},
117{PKCS7_R_NO_MULTIPART_BOUNDARY ,"no multipart boundary"},
91{PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE,"no recipient matches certificate"}, 118{PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE,"no recipient matches certificate"},
119{PKCS7_R_NO_SIGNATURES_ON_DATA ,"no signatures on data"},
120{PKCS7_R_NO_SIGNERS ,"no signers"},
121{PKCS7_R_NO_SIG_CONTENT_TYPE ,"no sig content type"},
92{PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE,"operation not supported on this type"}, 122{PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE,"operation not supported on this type"},
123{PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR ,"pkcs7 add signature error"},
124{PKCS7_R_PKCS7_DATAFINAL_ERROR ,"pkcs7 datafinal error"},
125{PKCS7_R_PKCS7_DATASIGN ,"pkcs7 datasign"},
126{PKCS7_R_PKCS7_PARSE_ERROR ,"pkcs7 parse error"},
127{PKCS7_R_PKCS7_SIG_PARSE_ERROR ,"pkcs7 sig parse error"},
128{PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE,"private key does not match certificate"},
93{PKCS7_R_SIGNATURE_FAILURE ,"signature failure"}, 129{PKCS7_R_SIGNATURE_FAILURE ,"signature failure"},
130{PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND ,"signer certificate not found"},
131{PKCS7_R_SIG_INVALID_MIME_TYPE ,"sig invalid mime type"},
132{PKCS7_R_SMIME_TEXT_ERROR ,"smime text error"},
94{PKCS7_R_UNABLE_TO_FIND_CERTIFICATE ,"unable to find certificate"}, 133{PKCS7_R_UNABLE_TO_FIND_CERTIFICATE ,"unable to find certificate"},
95{PKCS7_R_UNABLE_TO_FIND_MEM_BIO ,"unable to find mem bio"}, 134{PKCS7_R_UNABLE_TO_FIND_MEM_BIO ,"unable to find mem bio"},
96{PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST ,"unable to find message digest"}, 135{PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST ,"unable to find message digest"},
diff --git a/src/lib/libssl/src/crypto/pkcs7/sign.c b/src/lib/libssl/src/crypto/pkcs7/sign.c
index d5f1154006..22290e192c 100644
--- a/src/lib/libssl/src/crypto/pkcs7/sign.c
+++ b/src/lib/libssl/src/crypto/pkcs7/sign.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h>
59#include <openssl/bio.h> 60#include <openssl/bio.h>
60#include <openssl/x509.h> 61#include <openssl/x509.h>
61#include <openssl/pem.h> 62#include <openssl/pem.h>
@@ -75,10 +76,18 @@ char *argv[];
75 int i; 76 int i;
76 int nodetach=0; 77 int nodetach=0;
77 78
79#ifndef NO_MD2
78 EVP_add_digest(EVP_md2()); 80 EVP_add_digest(EVP_md2());
81#endif
82#ifndef NO_MD5
79 EVP_add_digest(EVP_md5()); 83 EVP_add_digest(EVP_md5());
84#endif
85#ifndef NO_SHA1
80 EVP_add_digest(EVP_sha1()); 86 EVP_add_digest(EVP_sha1());
87#endif
88#ifndef NO_MDC2
81 EVP_add_digest(EVP_mdc2()); 89 EVP_add_digest(EVP_mdc2());
90#endif
82 91
83 data=BIO_new(BIO_s_file()); 92 data=BIO_new(BIO_s_file());
84again: 93again:
@@ -97,9 +106,9 @@ again:
97 BIO_set_fp(data,stdin,BIO_NOCLOSE); 106 BIO_set_fp(data,stdin,BIO_NOCLOSE);
98 107
99 if ((in=BIO_new_file("server.pem","r")) == NULL) goto err; 108 if ((in=BIO_new_file("server.pem","r")) == NULL) goto err;
100 if ((x509=PEM_read_bio_X509(in,NULL,NULL)) == NULL) goto err; 109 if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err;
101 BIO_reset(in); 110 BIO_reset(in);
102 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL)) == NULL) goto err; 111 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL) goto err;
103 BIO_free(in); 112 BIO_free(in);
104 113
105 p7=PKCS7_new(); 114 p7=PKCS7_new();
diff --git a/src/lib/libssl/src/crypto/pkcs7/verify.c b/src/lib/libssl/src/crypto/pkcs7/verify.c
index 32d9783e45..49fc8d8bed 100644
--- a/src/lib/libssl/src/crypto/pkcs7/verify.c
+++ b/src/lib/libssl/src/crypto/pkcs7/verify.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <string.h>
59#include <openssl/bio.h> 60#include <openssl/bio.h>
60#include <openssl/asn1.h> 61#include <openssl/asn1.h>
61#include <openssl/x509.h> 62#include <openssl/x509.h>
@@ -84,10 +85,18 @@ char *argv[];
84 85
85 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 86 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
86 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE); 87 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
88#ifndef NO_MD2
87 EVP_add_digest(EVP_md2()); 89 EVP_add_digest(EVP_md2());
90#endif
91#ifndef NO_MD5
88 EVP_add_digest(EVP_md5()); 92 EVP_add_digest(EVP_md5());
93#endif
94#ifndef NO_SHA1
89 EVP_add_digest(EVP_sha1()); 95 EVP_add_digest(EVP_sha1());
96#endif
97#ifndef NO_MDC2
90 EVP_add_digest(EVP_mdc2()); 98 EVP_add_digest(EVP_mdc2());
99#endif
91 100
92 data=BIO_new(BIO_s_file()); 101 data=BIO_new(BIO_s_file());
93 102
@@ -121,7 +130,7 @@ char *argv[];
121 130
122 131
123 /* Load the PKCS7 object from a file */ 132 /* Load the PKCS7 object from a file */
124 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL)) == NULL) goto err; 133 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL,NULL)) == NULL) goto err;
125 134
126 /* This stuff is being setup for certificate verification. 135 /* This stuff is being setup for certificate verification.
127 * When using SSL, it could be replaced with a 136 * When using SSL, it could be replaced with a
diff --git a/src/lib/libssl/src/crypto/rand/Makefile.ssl b/src/lib/libssl/src/crypto/rand/Makefile.ssl
index 014356cb18..be8eea34a2 100644
--- a/src/lib/libssl/src/crypto/rand/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/rand/Makefile.ssl
@@ -22,8 +22,8 @@ TEST= randtest.c
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC=md_rand.c randfile.c rand_lib.c 25LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c
26LIBOBJ=md_rand.o randfile.o rand_lib.o 26LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o
27 27
28SRC= $(LIBSRC) 28SRC= $(LIBSRC)
29 29
@@ -79,9 +79,14 @@ clean:
79# DO NOT DELETE THIS LINE -- make depend depends on it. 79# DO NOT DELETE THIS LINE -- make depend depends on it.
80 80
81md_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 81md_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
82md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 82md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
83md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 83md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
84md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
84md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 85md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
86rand_egd.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h
87rand_err.o: ../../include/openssl/err.h ../../include/openssl/rand.h
85rand_lib.o: ../../include/openssl/rand.h 88rand_lib.o: ../../include/openssl/rand.h
86randfile.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 89randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
87randfile.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h 90randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
91randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
92randfile.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
diff --git a/src/lib/libssl/src/crypto/rand/md_rand.c b/src/lib/libssl/src/crypto/rand/md_rand.c
index c9a071bd22..6b158f0349 100644
--- a/src/lib/libssl/src/crypto/rand/md_rand.c
+++ b/src/lib/libssl/src/crypto/rand/md_rand.c
@@ -56,15 +56,23 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#define ENTROPY_NEEDED 16 /* require 128 bits = 16 bytes of randomness */
60
61#ifndef MD_RAND_DEBUG
62# ifndef NDEBUG
63# define NDEBUG
64# endif
65#endif
66
67#include <assert.h>
59#include <stdio.h> 68#include <stdio.h>
60#include <sys/types.h>
61#include <fcntl.h>
62#include <time.h> 69#include <time.h>
63#include <string.h> 70#include <string.h>
64 71
65#include "openssl/e_os.h" 72#include "openssl/e_os.h"
66 73
67#include <openssl/crypto.h> 74#include <openssl/crypto.h>
75#include <openssl/err.h>
68 76
69#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND) 77#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
70#if !defined(NO_SHA) && !defined(NO_SHA1) 78#if !defined(NO_SHA) && !defined(NO_SHA1)
@@ -130,17 +138,23 @@ static int state_num=0,state_index=0;
130static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH]; 138static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH];
131static unsigned char md[MD_DIGEST_LENGTH]; 139static unsigned char md[MD_DIGEST_LENGTH];
132static long md_count[2]={0,0}; 140static long md_count[2]={0,0};
141static double entropy=0;
142static int initialized=0;
133 143
134const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT; 144const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
135 145
136static void ssleay_rand_cleanup(void); 146static void ssleay_rand_cleanup(void);
137static void ssleay_rand_seed(const void *buf, int num); 147static void ssleay_rand_seed(const void *buf, int num);
138static void ssleay_rand_bytes(unsigned char *buf, int num); 148static void ssleay_rand_add(const void *buf, int num, double add_entropy);
149static int ssleay_rand_bytes(unsigned char *buf, int num);
150static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
139 151
140RAND_METHOD rand_ssleay_meth={ 152RAND_METHOD rand_ssleay_meth={
141 ssleay_rand_seed, 153 ssleay_rand_seed,
142 ssleay_rand_bytes, 154 ssleay_rand_bytes,
143 ssleay_rand_cleanup, 155 ssleay_rand_cleanup,
156 ssleay_rand_add,
157 ssleay_rand_pseudo_bytes,
144 }; 158 };
145 159
146RAND_METHOD *RAND_SSLeay(void) 160RAND_METHOD *RAND_SSLeay(void)
@@ -156,22 +170,49 @@ static void ssleay_rand_cleanup(void)
156 memset(md,0,MD_DIGEST_LENGTH); 170 memset(md,0,MD_DIGEST_LENGTH);
157 md_count[0]=0; 171 md_count[0]=0;
158 md_count[1]=0; 172 md_count[1]=0;
173 entropy=0;
159 } 174 }
160 175
161static void ssleay_rand_seed(const void *buf, int num) 176static void ssleay_rand_add(const void *buf, int num, double add)
162 { 177 {
163 int i,j,k,st_idx,st_num; 178 int i,j,k,st_idx;
179 long md_c[2];
180 unsigned char local_md[MD_DIGEST_LENGTH];
164 MD_CTX m; 181 MD_CTX m;
165 182
166#ifdef NORAND 183#ifdef NORAND
167 return; 184 return;
168#endif 185#endif
169 186
187 /*
188 * (Based on the rand(3) manpage)
189 *
190 * The input is chopped up into units of 20 bytes (or less for
191 * the last block). Each of these blocks is run through the hash
192 * function as follows: The data passed to the hash function
193 * is the current 'md', the same number of bytes from the 'state'
194 * (the location determined by in incremented looping index) as
195 * the current 'block', the new key data 'block', and 'count'
196 * (which is incremented after each use).
197 * The result of this is kept in 'md' and also xored into the
198 * 'state' at the same locations that were used as input into the
199 * hash function.
200 */
201
170 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 202 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
171 st_idx=state_index; 203 st_idx=state_index;
172 st_num=state_num;
173 204
174 state_index=(state_index+num); 205 /* use our own copies of the counters so that even
206 * if a concurrent thread seeds with exactly the
207 * same data and uses the same subarray there's _some_
208 * difference */
209 md_c[0] = md_count[0];
210 md_c[1] = md_count[1];
211
212 memcpy(local_md, md, sizeof md);
213
214 /* state_index <= state_num <= STATE_SIZE */
215 state_index += num;
175 if (state_index >= STATE_SIZE) 216 if (state_index >= STATE_SIZE)
176 { 217 {
177 state_index%=STATE_SIZE; 218 state_index%=STATE_SIZE;
@@ -182,6 +223,14 @@ static void ssleay_rand_seed(const void *buf, int num)
182 if (state_index > state_num) 223 if (state_index > state_num)
183 state_num=state_index; 224 state_num=state_index;
184 } 225 }
226 /* state_index <= state_num <= STATE_SIZE */
227
228 /* state[st_idx], ..., state[(st_idx + num - 1) % STATE_SIZE]
229 * are what we will use now, but other threads may use them
230 * as well */
231
232 md_count[1] += (num / MD_DIGEST_LENGTH) + (num % MD_DIGEST_LENGTH > 0);
233
185 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 234 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
186 235
187 for (i=0; i<num; i+=MD_DIGEST_LENGTH) 236 for (i=0; i<num; i+=MD_DIGEST_LENGTH)
@@ -190,7 +239,7 @@ static void ssleay_rand_seed(const void *buf, int num)
190 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j; 239 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j;
191 240
192 MD_Init(&m); 241 MD_Init(&m);
193 MD_Update(&m,md,MD_DIGEST_LENGTH); 242 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
194 k=(st_idx+j)-STATE_SIZE; 243 k=(st_idx+j)-STATE_SIZE;
195 if (k > 0) 244 if (k > 0)
196 { 245 {
@@ -201,33 +250,107 @@ static void ssleay_rand_seed(const void *buf, int num)
201 MD_Update(&m,&(state[st_idx]),j); 250 MD_Update(&m,&(state[st_idx]),j);
202 251
203 MD_Update(&m,buf,j); 252 MD_Update(&m,buf,j);
204 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count)); 253 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
205 MD_Final(md,&m); 254 MD_Final(local_md,&m);
206 md_count[1]++; 255 md_c[1]++;
207 256
208 buf=(const char *)buf + j; 257 buf=(const char *)buf + j;
209 258
210 for (k=0; k<j; k++) 259 for (k=0; k<j; k++)
211 { 260 {
212 state[st_idx++]^=md[k]; 261 /* Parallel threads may interfere with this,
262 * but always each byte of the new state is
263 * the XOR of some previous value of its
264 * and local_md (itermediate values may be lost).
265 * Alway using locking could hurt performance more
266 * than necessary given that conflicts occur only
267 * when the total seeding is longer than the random
268 * state. */
269 state[st_idx++]^=local_md[k];
213 if (st_idx >= STATE_SIZE) 270 if (st_idx >= STATE_SIZE)
214 {
215 st_idx=0; 271 st_idx=0;
216 st_num=STATE_SIZE;
217 }
218 } 272 }
219 } 273 }
220 memset((char *)&m,0,sizeof(m)); 274 memset((char *)&m,0,sizeof(m));
275
276 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
277 /* Don't just copy back local_md into md -- this could mean that
278 * other thread's seeding remains without effect (except for
279 * the incremented counter). By XORing it we keep at least as
280 * much entropy as fits into md. */
281 for (k = 0; k < sizeof md; k++)
282 {
283 md[k] ^= local_md[k];
284 }
285 if (entropy < ENTROPY_NEEDED) /* stop counting when we have enough */
286 entropy += add;
287 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
288
289#ifndef THREADS
290 assert(md_c[1] == md_count[1]);
291#endif
221 } 292 }
222 293
223static void ssleay_rand_bytes(unsigned char *buf, int num) 294static void ssleay_rand_seed(const void *buf, int num)
295 {
296 ssleay_rand_add(buf, num, num);
297 }
298
299static void ssleay_rand_initialize(void)
224 { 300 {
225 int i,j,k,st_num,st_idx;
226 MD_CTX m;
227 static int init=1;
228 unsigned long l; 301 unsigned long l;
302#ifndef GETPID_IS_MEANINGLESS
303 pid_t curr_pid = getpid();
304#endif
229#ifdef DEVRANDOM 305#ifdef DEVRANDOM
230 int fd; 306 FILE *fh;
307#endif
308
309 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
310 /* put in some default random data, we need more than just this */
311#ifndef GETPID_IS_MEANINGLESS
312 l=curr_pid;
313 RAND_add(&l,sizeof(l),0);
314 l=getuid();
315 RAND_add(&l,sizeof(l),0);
316#endif
317 l=time(NULL);
318 RAND_add(&l,sizeof(l),0);
319
320#ifdef DEVRANDOM
321 /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
322 * have this. Use /dev/urandom if you can as /dev/random may block
323 * if it runs out of random entries. */
324
325 if ((fh = fopen(DEVRANDOM, "r")) != NULL)
326 {
327 unsigned char tmpbuf[ENTROPY_NEEDED];
328 int n;
329
330 setvbuf(fh, NULL, _IONBF, 0);
331 n=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh);
332 fclose(fh);
333 RAND_add(tmpbuf,sizeof tmpbuf,n);
334 memset(tmpbuf,0,n);
335 }
336#endif
337#ifdef PURIFY
338 memset(state,0,STATE_SIZE);
339 memset(md,0,MD_DIGEST_LENGTH);
340#endif
341 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
342 initialized=1;
343 }
344
345static int ssleay_rand_bytes(unsigned char *buf, int num)
346 {
347 int i,j,k,st_num,st_idx;
348 int ok;
349 long md_c[2];
350 unsigned char local_md[MD_DIGEST_LENGTH];
351 MD_CTX m;
352#ifndef GETPID_IS_MEANINGLESS
353 pid_t curr_pid = getpid();
231#endif 354#endif
232 355
233#ifdef PREDICT 356#ifdef PREDICT
@@ -236,65 +359,63 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
236 359
237 for (i=0; i<num; i++) 360 for (i=0; i<num; i++)
238 buf[i]=val++; 361 buf[i]=val++;
239 return; 362 return(1);
240 } 363 }
241#endif 364#endif
242 365
366 /*
367 * (Based on the rand(3) manpage:)
368 *
369 * For each group of 10 bytes (or less), we do the following:
370 *
371 * Input into the hash function the top 10 bytes from the
372 * local 'md' (which is initialized from the global 'md'
373 * before any bytes are generated), the bytes that are
374 * to be overwritten by the random bytes, and bytes from the
375 * 'state' (incrementing looping index). From this digest output
376 * (which is kept in 'md'), the top (up to) 10 bytes are
377 * returned to the caller and the bottom (up to) 10 bytes are xored
378 * into the 'state'.
379 * Finally, after we have finished 'num' random bytes for the
380 * caller, 'count' (which is incremented) and the local and global 'md'
381 * are fed into the hash function and the results are kept in the
382 * global 'md'.
383 */
384
243 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 385 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
244 386
245 if (init) 387 if (!initialized)
388 ssleay_rand_initialize();
389
390 ok = (entropy >= ENTROPY_NEEDED);
391 if (!ok)
246 { 392 {
247 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 393 /* If the PRNG state is not yet unpredictable, then seeing
248 /* put in some default random data, we need more than 394 * the PRNG output may help attackers to determine the new
249 * just this */ 395 * state; thus we have to decrease the entropy estimate.
250 RAND_seed(&m,sizeof(m)); 396 * Once we've had enough initial seeding we don't bother to
251#ifndef MSDOS 397 * adjust the entropy count, though, because we're not ambitious
252 l=getpid(); 398 * to provide *information-theoretic* randomness.
253 RAND_seed(&l,sizeof(l));
254 l=getuid();
255 RAND_seed(&l,sizeof(l));
256#endif
257 l=time(NULL);
258 RAND_seed(&l,sizeof(l));
259
260/* #ifdef DEVRANDOM */
261 /*
262 * Use a random entropy pool device.
263 * Linux 1.3.x, OpenBSD, and FreeBSD have
264 * this. Use /dev/urandom if you can
265 * as /dev/random will block if it runs out
266 * of random entries.
267 */ 399 */
268 if ((fd = open(DEVRANDOM, O_RDONLY)) != NULL) 400 entropy -= num;
269 { 401 if (entropy < 0)
270 unsigned char tmpbuf[32]; 402 entropy = 0;
271
272 read(fd, tmpbuf, sizeof(tmpbuf));
273 /* we don't care how many bytes we read,
274 * we will just copy the 'stack' if there is
275 * nothing else :-) */
276 /* the above comment is EVIL. Security software
277 * RELIES ON THESE PRIMITIVES HAVING MORE SECURE
278 * BEHAVIOUR! Secure entropy is required in
279 * many cases! */
280 RAND_seed(tmpbuf,32);
281 memset(tmpbuf,0,32);
282 }
283/* #endif */
284#ifdef PURIFY
285 memset(state,0,STATE_SIZE);
286 memset(md,0,MD_DIGEST_LENGTH);
287#endif
288 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
289 init=0;
290 } 403 }
291 404
292 st_idx=state_index; 405 st_idx=state_index;
293 st_num=state_num; 406 st_num=state_num;
407 md_c[0] = md_count[0];
408 md_c[1] = md_count[1];
409 memcpy(local_md, md, sizeof md);
410
294 state_index+=num; 411 state_index+=num;
295 if (state_index > state_num) 412 if (state_index > state_num)
296 state_index=(state_index%state_num); 413 state_index %= state_num;
414
415 /* state[st_idx], ..., state[(st_idx + num - 1) % st_num]
416 * are now ours (but other threads may use them too) */
297 417
418 md_count[0] += 1;
298 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 419 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
299 420
300 while (num > 0) 421 while (num > 0)
@@ -302,8 +423,15 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
302 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num; 423 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;
303 num-=j; 424 num-=j;
304 MD_Init(&m); 425 MD_Init(&m);
305 MD_Update(&m,&(md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2); 426#ifndef GETPID_IS_MEANINGLESS
306 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count)); 427 if (curr_pid) /* just in the first iteration to save time */
428 {
429 MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid);
430 curr_pid = 0;
431 }
432#endif
433 MD_Update(&m,&(local_md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2);
434 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
307#ifndef PURIFY 435#ifndef PURIFY
308 MD_Update(&m,buf,j); /* purify complains */ 436 MD_Update(&m,buf,j); /* purify complains */
309#endif 437#endif
@@ -315,23 +443,57 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
315 } 443 }
316 else 444 else
317 MD_Update(&m,&(state[st_idx]),j); 445 MD_Update(&m,&(state[st_idx]),j);
318 MD_Final(md,&m); 446 MD_Final(local_md,&m);
319 447
320 for (i=0; i<j; i++) 448 for (i=0; i<j; i++)
321 { 449 {
450 state[st_idx++]^=local_md[i]; /* may compete with other threads */
451 *(buf++)=local_md[i+MD_DIGEST_LENGTH/2];
322 if (st_idx >= st_num) 452 if (st_idx >= st_num)
323 st_idx=0; 453 st_idx=0;
324 state[st_idx++]^=md[i];
325 *(buf++)=md[i+MD_DIGEST_LENGTH/2];
326 } 454 }
327 } 455 }
328 456
329 MD_Init(&m); 457 MD_Init(&m);
330 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count)); 458 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
331 md_count[0]++; 459 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
460 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
332 MD_Update(&m,md,MD_DIGEST_LENGTH); 461 MD_Update(&m,md,MD_DIGEST_LENGTH);
333 MD_Final(md,&m); 462 MD_Final(md,&m);
463 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
464
334 memset(&m,0,sizeof(m)); 465 memset(&m,0,sizeof(m));
466 if (ok)
467 return(1);
468 else
469 {
470 RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
471 return(0);
472 }
473 }
474
475/* pseudo-random bytes that are guaranteed to be unique but not
476 unpredictable */
477static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
478 {
479 int ret, err;
480
481 ret = RAND_bytes(buf, num);
482 if (ret == 0)
483 {
484 err = ERR_peek_error();
485 if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
486 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
487 (void)ERR_get_error();
488 }
489 return (ret);
490 }
491
492int RAND_status(void)
493 {
494 if (!initialized)
495 ssleay_rand_initialize();
496 return (entropy >= ENTROPY_NEEDED);
335 } 497 }
336 498
337#ifdef WINDOWS 499#ifdef WINDOWS
@@ -358,12 +520,12 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
358 */ 520 */
359/* 521/*
360 * I have modified the loading of bytes via RAND_seed() mechanism since 522 * I have modified the loading of bytes via RAND_seed() mechanism since
361 * the origional would have been very very CPU intensive since RAND_seed() 523 * the original would have been very very CPU intensive since RAND_seed()
362 * does an MD5 per 16 bytes of input. The cost to digest 16 bytes is the same 524 * does an MD5 per 16 bytes of input. The cost to digest 16 bytes is the same
363 * as that to digest 56 bytes. So under the old system, a screen of 525 * as that to digest 56 bytes. So under the old system, a screen of
364 * 1024*768*256 would have been CPU cost of approximatly 49,000 56 byte MD5 526 * 1024*768*256 would have been CPU cost of approximately 49,000 56 byte MD5
365 * digests or digesting 2.7 mbytes. What I have put in place would 527 * digests or digesting 2.7 mbytes. What I have put in place would
366 * be 48 16k MD5 digests, or efectivly 48*16+48 MD5 bytes or 816 kbytes 528 * be 48 16k MD5 digests, or effectively 48*16+48 MD5 bytes or 816 kbytes
367 * or about 3.5 times as much. 529 * or about 3.5 times as much.
368 * - eric 530 * - eric
369 */ 531 */
diff --git a/src/lib/libssl/src/crypto/rand/md_rand_munged.c b/src/lib/libssl/src/crypto/rand/md_rand_munged.c
new file mode 100644
index 0000000000..1611bf335b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rand/md_rand_munged.c
@@ -0,0 +1,515 @@
1/* crypto/rand/md_rand.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <sys/types.h>
61#include <fcntl.h>
62#include <time.h>
63#include <string.h>
64
65#include "openssl/e_os.h"
66
67#include <openssl/crypto.h>
68
69#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
70#if !defined(NO_SHA) && !defined(NO_SHA1)
71#define USE_SHA1_RAND
72#elif !defined(NO_MD5)
73#define USE_MD5_RAND
74#elif !defined(NO_MDC2) && !defined(NO_DES)
75#define USE_MDC2_RAND
76#elif !defined(NO_MD2)
77#define USE_MD2_RAND
78#else
79#error No message digest algorithm available
80#endif
81#endif
82
83/* Changed how the state buffer used. I now attempt to 'wrap' such
84 * that I don't run over the same locations the next time go through
85 * the 1023 bytes - many thanks to
86 * Robert J. LeBlanc <rjl@renaissoft.com> for his comments
87 */
88
89#if defined(USE_MD5_RAND)
90#include <openssl/md5.h>
91#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
92#define MD_CTX MD5_CTX
93#define MD_Init(a) MD5_Init(a)
94#define MD_Update(a,b,c) MD5_Update(a,b,c)
95#define MD_Final(a,b) MD5_Final(a,b)
96#define MD(a,b,c) MD5(a,b,c)
97#elif defined(USE_SHA1_RAND)
98#include <openssl/sha.h>
99#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
100#define MD_CTX SHA_CTX
101#define MD_Init(a) SHA1_Init(a)
102#define MD_Update(a,b,c) SHA1_Update(a,b,c)
103#define MD_Final(a,b) SHA1_Final(a,b)
104#define MD(a,b,c) SHA1(a,b,c)
105#elif defined(USE_MDC2_RAND)
106#include <openssl/mdc2.h>
107#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
108#define MD_CTX MDC2_CTX
109#define MD_Init(a) MDC2_Init(a)
110#define MD_Update(a,b,c) MDC2_Update(a,b,c)
111#define MD_Final(a,b) MDC2_Final(a,b)
112#define MD(a,b,c) MDC2(a,b,c)
113#elif defined(USE_MD2_RAND)
114#include <openssl/md2.h>
115#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
116#define MD_CTX MD2_CTX
117#define MD_Init(a) MD2_Init(a)
118#define MD_Update(a,b,c) MD2_Update(a,b,c)
119#define MD_Final(a,b) MD2_Final(a,b)
120#define MD(a,b,c) MD2(a,b,c)
121#endif
122
123#include <openssl/rand.h>
124
125/* #define NORAND 1 */
126/* #define PREDICT 1 */
127
128#define STATE_SIZE 1023
129static int state_num=0,state_index=0;
130static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH];
131static unsigned char md[MD_DIGEST_LENGTH];
132static long md_count[2]={0,0};
133static double entropy=0;
134static int initialized=0;
135
136const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
137
138static void ssleay_rand_cleanup(void);
139static void ssleay_rand_seed(const void *buf, int num);
140static void ssleay_rand_add(const void *buf, int num, double add_entropy);
141static int ssleay_rand_bytes(unsigned char *buf, int num);
142static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
143
144RAND_METHOD rand_ssleay_meth={
145 ssleay_rand_seed,
146 ssleay_rand_bytes,
147 ssleay_rand_cleanup,
148 ssleay_rand_add,
149 ssleay_rand_pseudo_bytes,
150 };
151
152RAND_METHOD *RAND_SSLeay(void)
153 {
154 return(&rand_ssleay_meth);
155 }
156
157static void ssleay_rand_cleanup(void)
158 {
159 memset(state,0,sizeof(state));
160 state_num=0;
161 state_index=0;
162 memset(md,0,MD_DIGEST_LENGTH);
163 md_count[0]=0;
164 md_count[1]=0;
165 entropy=0;
166 }
167
168static void ssleay_rand_add(const void *buf, int num, double add)
169 {
170 int i,j,k,st_idx;
171 long md_c[2];
172 unsigned char local_md[MD_DIGEST_LENGTH];
173 MD_CTX m;
174
175#ifdef NORAND
176 return;
177#endif
178
179 /*
180 * (Based on the rand(3) manpage)
181 *
182 * The input is chopped up into units of 20 bytes (or less for
183 * the last block). Each of these blocks is run through the hash
184 * function as follows: The data passed to the hash function
185 * is the current 'md', the same number of bytes from the 'state'
186 * (the location determined by in incremented looping index) as
187 * the current 'block', the new key data 'block', and 'count'
188 * (which is incremented after each use).
189 * The result of this is kept in 'md' and also xored into the
190 * 'state' at the same locations that were used as input into the
191 * hash function.
192 */
193
194 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
195 st_idx=state_index;
196
197 /* use our own copies of the counters so that even
198 * if a concurrent thread seeds with exactly the
199 * same data and uses the same subarray there's _some_
200 * difference */
201 md_c[0] = md_count[0];
202 md_c[1] = md_count[1];
203
204 memcpy(local_md, md, sizeof md);
205
206 /* state_index <= state_num <= STATE_SIZE */
207 state_index += num;
208 if (state_index >= STATE_SIZE)
209 {
210 state_index%=STATE_SIZE;
211 state_num=STATE_SIZE;
212 }
213 else if (state_num < STATE_SIZE)
214 {
215 if (state_index > state_num)
216 state_num=state_index;
217 }
218 /* state_index <= state_num <= STATE_SIZE */
219
220 /* state[st_idx], ..., state[(st_idx + num - 1) % STATE_SIZE]
221 * are what we will use now, but other threads may use them
222 * as well */
223
224 md_count[1] += (num / MD_DIGEST_LENGTH) + (num % MD_DIGEST_LENGTH > 0);
225
226 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
227
228 for (i=0; i<num; i+=MD_DIGEST_LENGTH)
229 {
230 j=(num-i);
231 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j;
232
233 MD_Init(&m);
234 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
235 k=(st_idx+j)-STATE_SIZE;
236 if (k > 0)
237 {
238 MD_Update(&m,&(state[st_idx]),j-k);
239 MD_Update(&m,&(state[0]),k);
240 }
241 else
242 MD_Update(&m,&(state[st_idx]),j);
243
244 MD_Update(&m,buf,j);
245 MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count));
246 MD_Final(md,&m);
247 md_count[1]++;
248
249 buf=(const char *)buf + j;
250
251 for (k=0; k<j; k++)
252 {
253 state[st_idx++]^=md[k];
254 if (st_idx >= STATE_SIZE)
255 {
256 st_idx=0;
257 st_num=STATE_SIZE;
258 }
259 }
260 }
261 memset((char *)&m,0,sizeof(m));
262 }
263
264static void ssleay_rand_bytes(unsigned char *buf, int num)
265 {
266 int i,j,k,st_num,st_idx;
267 MD_CTX m;
268 static int init=1;
269 unsigned long l;
270#ifdef DEVRANDOM
271 int fd;
272#endif
273
274#ifdef PREDICT
275 {
276 static unsigned char val=0;
277
278 for (i=0; i<num; i++)
279 buf[i]=val++;
280 return;
281 }
282#endif
283
284 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
285
286 if (init)
287 {
288 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
289 /* put in some default random data, we need more than
290 * just this */
291 RAND_seed(&m,sizeof(m));
292#ifndef MSDOS
293 l=getpid();
294 RAND_seed(&l,sizeof(l));
295 l=getuid();
296 RAND_seed(&l,sizeof(l));
297#endif
298 l=time(NULL);
299 RAND_seed(&l,sizeof(l));
300
301/* #ifdef DEVRANDOM */
302 /*
303 * Use a random entropy pool device.
304 * Linux 1.3.x, OpenBSD, and FreeBSD have
305 * this. Use /dev/urandom if you can
306 * as /dev/random will block if it runs out
307 * of random entries.
308 */
309 if ((fd = open(DEVRANDOM, O_RDONLY)) != NULL)
310 {
311 unsigned char tmpbuf[32];
312
313 read(fd, tmpbuf, sizeof(tmpbuf));
314 /* we don't care how many bytes we read,
315 * we will just copy the 'stack' if there is
316 * nothing else :-) */
317 /* the above comment is EVIL. Security software
318 * RELIES ON THESE PRIMITIVES HAVING MORE SECURE
319 * BEHAVIOUR! Secure entropy is required in
320 * many cases! */
321 RAND_seed(tmpbuf,32);
322 memset(tmpbuf,0,32);
323 }
324/* #endif */
325#ifdef PURIFY
326 memset(state,0,STATE_SIZE);
327 memset(md,0,MD_DIGEST_LENGTH);
328#endif
329 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
330 init=0;
331 }
332
333 st_idx=state_index;
334 st_num=state_num;
335 state_index+=num;
336 if (state_index > state_num)
337 state_index=(state_index%state_num);
338
339 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
340
341 while (num > 0)
342 {
343 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;
344 num-=j;
345 MD_Init(&m);
346#ifndef GETPID_IS_MEANINGLESS
347 if (curr_pid) /* just in the first iteration to save time */
348 {
349 MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid);
350 curr_pid = 0;
351 }
352#endif
353 MD_Update(&m,&(local_md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2);
354 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
355#ifndef PURIFY
356 MD_Update(&m,buf,j); /* purify complains */
357#endif
358 k=(st_idx+j)-st_num;
359 if (k > 0)
360 {
361 MD_Update(&m,&(state[st_idx]),j-k);
362 MD_Update(&m,&(state[0]),k);
363 }
364 else
365 MD_Update(&m,&(state[st_idx]),j);
366 MD_Final(local_md,&m);
367
368 for (i=0; i<j; i++)
369 {
370 state[st_idx++]^=local_md[i]; /* may compete with other threads */
371 *(buf++)=local_md[i+MD_DIGEST_LENGTH/2];
372 if (st_idx >= st_num)
373 st_idx=0;
374 }
375 }
376
377 MD_Init(&m);
378 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
379 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
380 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
381 MD_Update(&m,md,MD_DIGEST_LENGTH);
382 MD_Final(md,&m);
383 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
384
385 memset(&m,0,sizeof(m));
386 if (ok)
387 return(1);
388 else
389 {
390 RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
391 return(0);
392 }
393 }
394
395/* pseudo-random bytes that are guaranteed to be unique but not
396 unpredictable */
397static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
398 {
399 int ret, err;
400
401 ret = RAND_bytes(buf, num);
402 if (ret == 0)
403 {
404 err = ERR_peek_error();
405 if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
406 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
407 (void)ERR_get_error();
408 }
409 return (ret);
410 }
411
412int RAND_status(void)
413 {
414 if (!initialized)
415 ssleay_rand_initialize();
416 return (entropy >= ENTROPY_NEEDED);
417 }
418
419#ifdef WINDOWS
420#include <windows.h>
421#include <openssl/rand.h>
422
423/*****************************************************************************
424 * Initialisation function for the SSL random generator. Takes the contents
425 * of the screen as random seed.
426 *
427 * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V.
428 *
429 * Code adapted from
430 * <URL:http://www.microsoft.com/kb/developr/win_dk/q97193.htm>;
431 * the original copyright message is:
432 *
433 * (C) Copyright Microsoft Corp. 1993. All rights reserved.
434 *
435 * You have a royalty-free right to use, modify, reproduce and
436 * distribute the Sample Files (and/or any modified version) in
437 * any way you find useful, provided that you agree that
438 * Microsoft has no warranty obligations or liability for any
439 * Sample Application Files which are modified.
440 */
441/*
442 * I have modified the loading of bytes via RAND_seed() mechanism since
443 * the original would have been very very CPU intensive since RAND_seed()
444 * does an MD5 per 16 bytes of input. The cost to digest 16 bytes is the same
445 * as that to digest 56 bytes. So under the old system, a screen of
446 * 1024*768*256 would have been CPU cost of approximately 49,000 56 byte MD5
447 * digests or digesting 2.7 mbytes. What I have put in place would
448 * be 48 16k MD5 digests, or effectively 48*16+48 MD5 bytes or 816 kbytes
449 * or about 3.5 times as much.
450 * - eric
451 */
452void RAND_screen(void)
453{
454 HDC hScrDC; /* screen DC */
455 HDC hMemDC; /* memory DC */
456 HBITMAP hBitmap; /* handle for our bitmap */
457 HBITMAP hOldBitmap; /* handle for previous bitmap */
458 BITMAP bm; /* bitmap properties */
459 unsigned int size; /* size of bitmap */
460 char *bmbits; /* contents of bitmap */
461 int w; /* screen width */
462 int h; /* screen height */
463 int y; /* y-coordinate of screen lines to grab */
464 int n = 16; /* number of screen lines to grab at a time */
465
466 /* Create a screen DC and a memory DC compatible to screen DC */
467 hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
468 hMemDC = CreateCompatibleDC(hScrDC);
469
470 /* Get screen resolution */
471 w = GetDeviceCaps(hScrDC, HORZRES);
472 h = GetDeviceCaps(hScrDC, VERTRES);
473
474 /* Create a bitmap compatible with the screen DC */
475 hBitmap = CreateCompatibleBitmap(hScrDC, w, n);
476
477 /* Select new bitmap into memory DC */
478 hOldBitmap = SelectObject(hMemDC, hBitmap);
479
480 /* Get bitmap properties */
481 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
482 size = (unsigned int)bm.bmWidthBytes * bm.bmHeight * bm.bmPlanes;
483
484 bmbits = Malloc(size);
485 if (bmbits) {
486 /* Now go through the whole screen, repeatedly grabbing n lines */
487 for (y = 0; y < h-n; y += n)
488 {
489 unsigned char md[MD_DIGEST_LENGTH];
490
491 /* Bitblt screen DC to memory DC */
492 BitBlt(hMemDC, 0, 0, w, n, hScrDC, 0, y, SRCCOPY);
493
494 /* Copy bitmap bits from memory DC to bmbits */
495 GetBitmapBits(hBitmap, size, bmbits);
496
497 /* Get the MD5 of the bitmap */
498 MD(bmbits,size,md);
499
500 /* Seed the random generator with the MD5 digest */
501 RAND_seed(md, MD_DIGEST_LENGTH);
502 }
503
504 Free(bmbits);
505 }
506
507 /* Select old bitmap back into memory DC */
508 hBitmap = SelectObject(hMemDC, hOldBitmap);
509
510 /* Clean up */
511 DeleteObject(hBitmap);
512 DeleteDC(hMemDC);
513 DeleteDC(hScrDC);
514}
515#endif
diff --git a/src/lib/libssl/src/crypto/rand/rand.h b/src/lib/libssl/src/crypto/rand/rand.h
index fd8ee38366..28f45ec052 100644
--- a/src/lib/libssl/src/crypto/rand/rand.h
+++ b/src/lib/libssl/src/crypto/rand/rand.h
@@ -66,24 +66,45 @@ extern "C" {
66typedef struct rand_meth_st 66typedef struct rand_meth_st
67 { 67 {
68 void (*seed)(const void *buf, int num); 68 void (*seed)(const void *buf, int num);
69 void (*bytes)(unsigned char *buf, int num); 69 int (*bytes)(unsigned char *buf, int num);
70 void (*cleanup)(void); 70 void (*cleanup)(void);
71 void (*add)(const void *buf, int num, double entropy);
72 int (*pseudorand)(unsigned char *buf, int num);
71 } RAND_METHOD; 73 } RAND_METHOD;
72 74
73void RAND_set_rand_method(RAND_METHOD *meth); 75void RAND_set_rand_method(RAND_METHOD *meth);
74RAND_METHOD *RAND_get_rand_method(void ); 76RAND_METHOD *RAND_get_rand_method(void );
75RAND_METHOD *RAND_SSLeay(void); 77RAND_METHOD *RAND_SSLeay(void);
76void RAND_cleanup(void ); 78void RAND_cleanup(void );
77void RAND_bytes(unsigned char *buf,int num); 79int RAND_bytes(unsigned char *buf,int num);
80int RAND_pseudo_bytes(unsigned char *buf,int num);
78void RAND_seed(const void *buf,int num); 81void RAND_seed(const void *buf,int num);
82void RAND_add(const void *buf,int num,double entropy);
79int RAND_load_file(const char *file,long max_bytes); 83int RAND_load_file(const char *file,long max_bytes);
80int RAND_write_file(const char *file); 84int RAND_write_file(const char *file);
81char *RAND_file_name(char *file,int num); 85const char *RAND_file_name(char *file,int num);
86int RAND_status(void);
87int RAND_egd(const char *path);
82#ifdef WINDOWS 88#ifdef WINDOWS
83void RAND_screen(void); 89void RAND_screen(void);
84#endif 90#endif
91void ERR_load_RAND_strings(void);
92
93/* BEGIN ERROR CODES */
94/* The following lines are auto generated by the script mkerr.pl. Any changes
95 * made after this point may be overwritten when the script is next run.
96 */
97
98/* Error codes for the RAND functions. */
99
100/* Function codes. */
101#define RAND_F_SSLEAY_RAND_BYTES 100
102
103/* Reason codes. */
104#define RAND_R_PRNG_NOT_SEEDED 100
105
85#ifdef __cplusplus 106#ifdef __cplusplus
86} 107}
87#endif 108#endif
88
89#endif 109#endif
110
diff --git a/src/lib/libssl/src/crypto/rand/rand_egd.c b/src/lib/libssl/src/crypto/rand/rand_egd.c
new file mode 100644
index 0000000000..d834408bd4
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rand/rand_egd.c
@@ -0,0 +1,110 @@
1/* crypto/rand/rand_egd.c */
2/* Written by Ulf Moeller for the OpenSSL project. */
3/* ====================================================================
4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
22 *
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * openssl-core@openssl.org.
27 *
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
31 *
32 * 6. Redistributions of any form whatsoever must retain the following
33 * acknowledgment:
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This product includes cryptographic software written by Eric Young
52 * (eay@cryptsoft.com). This product includes software written by Tim
53 * Hudson (tjh@cryptsoft.com).
54 *
55 */
56
57#include <openssl/rand.h>
58
59/* Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
60 */
61
62#if defined(WIN32) || defined(VMS) || defined(__VMS)
63int RAND_egd(const char *path)
64 {
65 return(-1);
66 }
67#else
68#include <openssl/opensslconf.h>
69#include OPENSSL_UNISTD
70#include <sys/types.h>
71#include <sys/socket.h>
72#include <sys/un.h>
73#include <string.h>
74
75#ifndef offsetof
76# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
77#endif
78
79int RAND_egd(const char *path)
80 {
81 int ret = -1;
82 struct sockaddr_un addr;
83 int len, num;
84 int fd = -1;
85 unsigned char buf[256];
86
87 memset(&addr, 0, sizeof(addr));
88 addr.sun_family = AF_UNIX;
89 if (strlen(path) > sizeof(addr.sun_path))
90 return (-1);
91 strcpy(addr.sun_path,path);
92 len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
93 fd = socket(AF_UNIX, SOCK_STREAM, 0);
94 if (fd == -1) return (-1);
95 if (connect(fd, (struct sockaddr *)&addr, len) == -1) goto err;
96 buf[0] = 1;
97 buf[1] = 255;
98 write(fd, buf, 2);
99 if (read(fd, buf, 1) != 1) goto err;
100 if (buf[0] == 0) goto err;
101 num = read(fd, buf, 255);
102 if (num < 1) goto err;
103 RAND_seed(buf, num);
104 if (RAND_status() == 1)
105 ret = num;
106 err:
107 if (fd != -1) close(fd);
108 return(ret);
109 }
110#endif
diff --git a/src/lib/libssl/src/crypto/rand/rand_err.c b/src/lib/libssl/src/crypto/rand/rand_err.c
new file mode 100644
index 0000000000..d1263edf80
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rand/rand_err.c
@@ -0,0 +1,93 @@
1/* crypto/rand/rand_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 */
59
60#include <stdio.h>
61#include <openssl/err.h>
62#include <openssl/rand.h>
63
64/* BEGIN ERROR CODES */
65#ifndef NO_ERR
66static ERR_STRING_DATA RAND_str_functs[]=
67 {
68{ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"},
69{0,NULL}
70 };
71
72static ERR_STRING_DATA RAND_str_reasons[]=
73 {
74{RAND_R_PRNG_NOT_SEEDED ,"prng not seeded"},
75{0,NULL}
76 };
77
78#endif
79
80void ERR_load_RAND_strings(void)
81 {
82 static int init=1;
83
84 if (init)
85 {
86 init=0;
87#ifndef NO_ERR
88 ERR_load_strings(ERR_LIB_RAND,RAND_str_functs);
89 ERR_load_strings(ERR_LIB_RAND,RAND_str_reasons);
90#endif
91
92 }
93 }
diff --git a/src/lib/libssl/src/crypto/rand/rand_lib.c b/src/lib/libssl/src/crypto/rand/rand_lib.c
index 34c6d5b968..b09a300c46 100644
--- a/src/lib/libssl/src/crypto/rand/rand_lib.c
+++ b/src/lib/libssl/src/crypto/rand/rand_lib.c
@@ -57,7 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <time.h> 60#include <time.h>
62#include <openssl/rand.h> 61#include <openssl/rand.h>
63 62
@@ -90,9 +89,22 @@ void RAND_seed(const void *buf, int num)
90 rand_meth->seed(buf,num); 89 rand_meth->seed(buf,num);
91 } 90 }
92 91
93void RAND_bytes(unsigned char *buf, int num) 92void RAND_add(const void *buf, int num, double entropy)
94 { 93 {
95 if (rand_meth != NULL) 94 if (rand_meth != NULL)
96 rand_meth->bytes(buf,num); 95 rand_meth->add(buf,num,entropy);
97 } 96 }
98 97
98int RAND_bytes(unsigned char *buf, int num)
99 {
100 if (rand_meth != NULL)
101 return rand_meth->bytes(buf,num);
102 return(-1);
103 }
104
105int RAND_pseudo_bytes(unsigned char *buf, int num)
106 {
107 if (rand_meth != NULL)
108 return rand_meth->pseudorand(buf,num);
109 return(-1);
110 }
diff --git a/src/lib/libssl/src/crypto/rand/randfile.c b/src/lib/libssl/src/crypto/rand/randfile.c
index 6829d4ec37..658a8d6b65 100644
--- a/src/lib/libssl/src/crypto/rand/randfile.c
+++ b/src/lib/libssl/src/crypto/rand/randfile.c
@@ -60,22 +60,35 @@
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#include <sys/types.h>
64#include <sys/stat.h>
65#include <sys/types.h>
66 63
67#include "openssl/e_os.h" 64#include "openssl/e_os.h"
68 65
66#ifdef VMS
67#include <unixio.h>
68#endif
69#ifndef NO_SYS_TYPES_H
70# include <sys/types.h>
71#endif
72#ifdef MAC_OS_pre_X
73# include <stat.h>
74#else
75# include <sys/stat.h>
76#endif
77
78#include <openssl/crypto.h>
69#include <openssl/rand.h> 79#include <openssl/rand.h>
70 80
71#undef BUFSIZE 81#undef BUFSIZE
72#define BUFSIZE 1024 82#define BUFSIZE 1024
73#define RAND_DATA 1024 83#define RAND_DATA 1024
74 84
75/* #define RFILE ".rand" - defined in ../../e_os.h */ 85/* #define RFILE ".rnd" - defined in ../../e_os.h */
76 86
77int RAND_load_file(const char *file, long bytes) 87int RAND_load_file(const char *file, long bytes)
78 { 88 {
89 /* If bytes >= 0, read up to 'bytes' bytes.
90 * if bytes == -1, read complete file. */
91
79 MS_STATIC unsigned char buf[BUFSIZE]; 92 MS_STATIC unsigned char buf[BUFSIZE];
80 struct stat sb; 93 struct stat sb;
81 int i,ret=0,n; 94 int i,ret=0,n;
@@ -85,23 +98,28 @@ int RAND_load_file(const char *file, long bytes)
85 98
86 i=stat(file,&sb); 99 i=stat(file,&sb);
87 /* If the state fails, put some crap in anyway */ 100 /* If the state fails, put some crap in anyway */
88 RAND_seed(&sb,sizeof(sb)); 101 RAND_add(&sb,sizeof(sb),0);
89 ret+=sizeof(sb);
90 if (i < 0) return(0); 102 if (i < 0) return(0);
91 if (bytes <= 0) return(ret); 103 if (bytes == 0) return(ret);
92 104
93 in=fopen(file,"rb"); 105 in=fopen(file,"rb");
94 if (in == NULL) goto err; 106 if (in == NULL) goto err;
95 for (;;) 107 for (;;)
96 { 108 {
97 n=(bytes < BUFSIZE)?(int)bytes:BUFSIZE; 109 if (bytes > 0)
110 n = (bytes < BUFSIZE)?(int)bytes:BUFSIZE;
111 else
112 n = BUFSIZE;
98 i=fread(buf,1,n,in); 113 i=fread(buf,1,n,in);
99 if (i <= 0) break; 114 if (i <= 0) break;
100 /* even if n != i, use the full array */ 115 /* even if n != i, use the full array */
101 RAND_seed(buf,n); 116 RAND_add(buf,n,i);
102 ret+=i; 117 ret+=i;
103 bytes-=n; 118 if (bytes > 0)
104 if (bytes <= 0) break; 119 {
120 bytes-=n;
121 if (bytes == 0) break;
122 }
105 } 123 }
106 fclose(in); 124 fclose(in);
107 memset(buf,0,BUFSIZE); 125 memset(buf,0,BUFSIZE);
@@ -112,29 +130,48 @@ err:
112int RAND_write_file(const char *file) 130int RAND_write_file(const char *file)
113 { 131 {
114 unsigned char buf[BUFSIZE]; 132 unsigned char buf[BUFSIZE];
115 int i,ret=0; 133 int i,ret=0,err=0;
116 FILE *out; 134 FILE *out = NULL;
117 int n; 135 int n;
118 136
119 /* Under VMS, fopen(file, "wb") will craete a new version of the 137#ifdef VMS
138 /* Under VMS, fopen(file, "wb") will create a new version of the
120 same file. This is not good, so let's try updating an existing 139 same file. This is not good, so let's try updating an existing
121 one, and create file only if it doesn't already exist. This 140 one, and create file only if it doesn't already exist. */
122 should be completely harmless on system that have no file 141 /* At the same time, if we just update a file, we also need to
123 versions. -- Richard Levitte */ 142 truncate it, and unfortunately, ftruncate() and truncate() do
143 not exist everywhere. All that remains is to delete old versions
144 of the random data file (done at the end). */
145#if 0
124 out=fopen(file,"rb+"); 146 out=fopen(file,"rb+");
125 if (out == NULL && errno == ENOENT) 147 if (out == NULL && errno != ENOENT)
148 goto err;
149#endif
150#endif
151
152 if (out == NULL)
126 { 153 {
127 errno = 0; 154#if defined O_CREAT && defined O_EXCL
155 /* chmod(..., 0600) is too late to protect the file,
156 * permissions should be restrictive from the start */
157 int fd = open(file, O_CREAT | O_EXCL, 0600);
158 if (fd != -1)
159 out = fdopen(fd, "wb");
160#else
128 out=fopen(file,"wb"); 161 out=fopen(file,"wb");
162#endif
129 } 163 }
130 if (out == NULL) goto err; 164 if (out == NULL) goto err;
165#ifndef NO_CHMOD
131 chmod(file,0600); 166 chmod(file,0600);
167#endif
132 n=RAND_DATA; 168 n=RAND_DATA;
133 for (;;) 169 for (;;)
134 { 170 {
135 i=(n > BUFSIZE)?BUFSIZE:n; 171 i=(n > BUFSIZE)?BUFSIZE:n;
136 n-=BUFSIZE; 172 n-=BUFSIZE;
137 RAND_bytes(buf,i); 173 if (RAND_bytes(buf,i) <= 0)
174 err=1;
138 i=fwrite(buf,1,i,out); 175 i=fwrite(buf,1,i,out);
139 if (i <= 0) 176 if (i <= 0)
140 { 177 {
@@ -144,13 +181,40 @@ int RAND_write_file(const char *file)
144 ret+=i; 181 ret+=i;
145 if (n <= 0) break; 182 if (n <= 0) break;
146 } 183 }
184#ifdef VMS
185 /* We may have updated an existing file using mode "rb+",
186 * now remove any old extra bytes */
187#if 0
188 if (ret > 0)
189 ftruncate(fileno(out), ret);
190#else
191 /* Try to delete older versions of the file, until there aren't
192 any */
193 {
194 char *tmpf;
195
196 tmpf = Malloc(strlen(file) + 4); /* to add ";-1" and a nul */
197 if (tmpf)
198 {
199 strcpy(tmpf, file);
200 strcat(tmpf, ";-1");
201 while(delete(tmpf) == 0)
202 ;
203 rename(file,";1"); /* Make sure it's version 1, or we
204 will reach the limit (32767) at
205 some point... */
206 }
207 }
208#endif
209#endif
210
147 fclose(out); 211 fclose(out);
148 memset(buf,0,BUFSIZE); 212 memset(buf,0,BUFSIZE);
149err: 213err:
150 return(ret); 214 return(err ? -1 : ret);
151 } 215 }
152 216
153char *RAND_file_name(char *buf, int size) 217const char *RAND_file_name(char *buf, int size)
154 { 218 {
155 char *s; 219 char *s;
156 char *ret=NULL; 220 char *ret=NULL;
diff --git a/src/lib/libssl/src/crypto/rand/randtest.c b/src/lib/libssl/src/crypto/rand/randtest.c
index f0706d779a..da96e3f695 100644
--- a/src/lib/libssl/src/crypto/rand/randtest.c
+++ b/src/lib/libssl/src/crypto/rand/randtest.c
@@ -73,7 +73,7 @@ int main()
73 /*double d; */ 73 /*double d; */
74 long d; 74 long d;
75 75
76 RAND_bytes(buf,2500); 76 RAND_pseudo_bytes(buf,2500);
77 77
78 n1=0; 78 n1=0;
79 for (i=0; i<16; i++) n2[i]=0; 79 for (i=0; i<16; i++) n2[i]=0;
diff --git a/src/lib/libssl/src/crypto/rc2/rc2speed.c b/src/lib/libssl/src/crypto/rc2/rc2speed.c
index c3da63e77e..9f7f5ccfa3 100644
--- a/src/lib/libssl/src/crypto/rc2/rc2speed.c
+++ b/src/lib/libssl/src/crypto/rc2/rc2speed.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libssl/src/crypto/rc2/rc2test.c b/src/lib/libssl/src/crypto/rc2/rc2test.c
index 6a5defa6ea..521269ded1 100644
--- a/src/lib/libssl/src/crypto/rc2/rc2test.c
+++ b/src/lib/libssl/src/crypto/rc2/rc2test.c
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
72#else 72#else
73#include <openssl/rc2.h> 73#include <openssl/rc2.h>
74 74
75unsigned char RC2key[4][16]={ 75static unsigned char RC2key[4][16]={
76 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 76 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -83,14 +83,14 @@ unsigned char RC2key[4][16]={
83 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F}, 83 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F},
84 }; 84 };
85 85
86unsigned char RC2plain[4][8]={ 86static unsigned char RC2plain[4][8]={
87 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 87 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
88 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 88 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
89 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, 89 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
90 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 90 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
91 }; 91 };
92 92
93unsigned char RC2cipher[4][8]={ 93static unsigned char RC2cipher[4][8]={
94 {0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7}, 94 {0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7},
95 {0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74}, 95 {0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74},
96 {0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E}, 96 {0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E},
diff --git a/src/lib/libssl/src/crypto/rc4/rc4.h b/src/lib/libssl/src/crypto/rc4/rc4.h
index 7418c2a9a2..8556dddab0 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4.h
+++ b/src/lib/libssl/src/crypto/rc4/rc4.h
@@ -77,8 +77,8 @@ typedef struct rc4_key_st
77 77
78 78
79const char *RC4_options(void); 79const char *RC4_options(void);
80void RC4_set_key(RC4_KEY *key, int len, unsigned char *data); 80void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
81void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, 81void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
82 unsigned char *outdata); 82 unsigned char *outdata);
83 83
84#ifdef __cplusplus 84#ifdef __cplusplus
diff --git a/src/lib/libssl/src/crypto/rc4/rc4_enc.c b/src/lib/libssl/src/crypto/rc4/rc4_enc.c
index 3256bea8cc..d5f18a3a70 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4_enc.c
+++ b/src/lib/libssl/src/crypto/rc4/rc4_enc.c
@@ -67,7 +67,7 @@
67 * Date: Wed, 14 Sep 1994 06:35:31 GMT 67 * Date: Wed, 14 Sep 1994 06:35:31 GMT
68 */ 68 */
69 69
70void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, 70void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
71 unsigned char *outdata) 71 unsigned char *outdata)
72 { 72 {
73 register RC4_INT *d; 73 register RC4_INT *d;
@@ -78,6 +78,190 @@ void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata,
78 y=key->y; 78 y=key->y;
79 d=key->data; 79 d=key->data;
80 80
81#if defined(RC4_CHUNK)
82 /*
83 * The original reason for implementing this(*) was the fact that
84 * pre-21164a Alpha CPUs don't have byte load/store instructions
85 * and e.g. a byte store has to be done with 64-bit load, shift,
86 * and, or and finally 64-bit store. Peaking data and operating
87 * at natural word size made it possible to reduce amount of
88 * instructions as well as to perform early read-ahead without
89 * suffering from RAW (read-after-write) hazard. This resulted
90 * in ~40%(**) performance improvement on 21064 box with gcc.
91 * But it's not only Alpha users who win here:-) Thanks to the
92 * early-n-wide read-ahead this implementation also exhibits
93 * >40% speed-up on SPARC and 20-30% on 64-bit MIPS (depending
94 * on sizeof(RC4_INT)).
95 *
96 * (*) "this" means code which recognizes the case when input
97 * and output pointers appear to be aligned at natural CPU
98 * word boundary
99 * (**) i.e. according to 'apps/openssl speed rc4' benchmark,
100 * crypto/rc4/rc4speed.c exhibits almost 70% speed-up...
101 *
102 * Cavets.
103 *
104 * - RC4_CHUNK="unsigned long long" should be a #1 choice for
105 * UltraSPARC. Unfortunately gcc generates very slow code
106 * (2.5-3 times slower than one generated by Sun's WorkShop
107 * C) and therefore gcc (at least 2.95 and earlier) should
108 * always be told that RC4_CHUNK="unsigned long".
109 *
110 * <appro@fy.chalmers.se>
111 */
112
113# define RC4_STEP ( \
114 x=(x+1) &0xff, \
115 tx=d[x], \
116 y=(tx+y)&0xff, \
117 ty=d[y], \
118 d[y]=tx, \
119 d[x]=ty, \
120 (RC4_CHUNK)d[(tx+ty)&0xff]\
121 )
122
123 if ( ( ((unsigned long)indata & (sizeof(RC4_CHUNK)-1)) |
124 ((unsigned long)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 )
125 {
126 RC4_CHUNK ichunk,otp;
127 const union { long one; char little; } is_endian = {1};
128
129 /*
130 * I reckon we can afford to implement both endian
131 * cases and to decide which way to take at run-time
132 * because the machine code appears to be very compact
133 * and redundant 1-2KB is perfectly tolerable (i.e.
134 * in case the compiler fails to eliminate it:-). By
135 * suggestion from Terrel Larson <terr@terralogic.net>
136 * who also stands for the is_endian union:-)
137 *
138 * Special notes.
139 *
140 * - is_endian is declared automatic as doing otherwise
141 * (declaring static) prevents gcc from eliminating
142 * the redundant code;
143 * - compilers (those I've tried) don't seem to have
144 * problems eliminating either the operators guarded
145 * by "if (sizeof(RC4_CHUNK)==8)" or the condition
146 * expressions themselves so I've got 'em to replace
147 * corresponding #ifdefs from the previous version;
148 * - I chose to let the redundant switch cases when
149 * sizeof(RC4_CHUNK)!=8 be (were also #ifdefed
150 * before);
151 * - in case you wonder "&(sizeof(RC4_CHUNK)*8-1)" in
152 * [LB]ESHFT guards against "shift is out of range"
153 * warnings when sizeof(RC4_CHUNK)!=8
154 *
155 * <appro@fy.chalmers.se>
156 */
157 if (!is_endian.little)
158 { /* BIG-ENDIAN CASE */
159# define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1))
160 for (;len&-sizeof(RC4_CHUNK);len-=sizeof(RC4_CHUNK))
161 {
162 ichunk = *(RC4_CHUNK *)indata;
163 otp = RC4_STEP<<BESHFT(0);
164 otp |= RC4_STEP<<BESHFT(1);
165 otp |= RC4_STEP<<BESHFT(2);
166 otp |= RC4_STEP<<BESHFT(3);
167 if (sizeof(RC4_CHUNK)==8)
168 {
169 otp |= RC4_STEP<<BESHFT(4);
170 otp |= RC4_STEP<<BESHFT(5);
171 otp |= RC4_STEP<<BESHFT(6);
172 otp |= RC4_STEP<<BESHFT(7);
173 }
174 *(RC4_CHUNK *)outdata = otp^ichunk;
175 indata += sizeof(RC4_CHUNK);
176 outdata += sizeof(RC4_CHUNK);
177 }
178 if (len)
179 {
180 RC4_CHUNK mask=(RC4_CHUNK)-1, ochunk;
181
182 ichunk = *(RC4_CHUNK *)indata;
183 ochunk = *(RC4_CHUNK *)outdata;
184 otp = 0;
185 i = BESHFT(0);
186 mask <<= (sizeof(RC4_CHUNK)-len)<<3;
187 switch (len&(sizeof(RC4_CHUNK)-1))
188 {
189 case 7: otp = RC4_STEP<<i, i-=8;
190 case 6: otp |= RC4_STEP<<i, i-=8;
191 case 5: otp |= RC4_STEP<<i, i-=8;
192 case 4: otp |= RC4_STEP<<i, i-=8;
193 case 3: otp |= RC4_STEP<<i, i-=8;
194 case 2: otp |= RC4_STEP<<i, i-=8;
195 case 1: otp |= RC4_STEP<<i, i-=8;
196 case 0: ; /*
197 * it's never the case,
198 * but it has to be here
199 * for ultrix?
200 */
201 }
202 ochunk &= ~mask;
203 ochunk |= (otp^ichunk) & mask;
204 *(RC4_CHUNK *)outdata = ochunk;
205 }
206 key->x=x;
207 key->y=y;
208 return;
209 }
210 else
211 { /* LITTLE-ENDIAN CASE */
212# define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1))
213 for (;len&-sizeof(RC4_CHUNK);len-=sizeof(RC4_CHUNK))
214 {
215 ichunk = *(RC4_CHUNK *)indata;
216 otp = RC4_STEP;
217 otp |= RC4_STEP<<8;
218 otp |= RC4_STEP<<16;
219 otp |= RC4_STEP<<24;
220 if (sizeof(RC4_CHUNK)==8)
221 {
222 otp |= RC4_STEP<<LESHFT(4);
223 otp |= RC4_STEP<<LESHFT(5);
224 otp |= RC4_STEP<<LESHFT(6);
225 otp |= RC4_STEP<<LESHFT(7);
226 }
227 *(RC4_CHUNK *)outdata = otp^ichunk;
228 indata += sizeof(RC4_CHUNK);
229 outdata += sizeof(RC4_CHUNK);
230 }
231 if (len)
232 {
233 RC4_CHUNK mask=(RC4_CHUNK)-1, ochunk;
234
235 ichunk = *(RC4_CHUNK *)indata;
236 ochunk = *(RC4_CHUNK *)outdata;
237 otp = 0;
238 i = 0;
239 mask >>= (sizeof(RC4_CHUNK)-len)<<3;
240 switch (len&(sizeof(RC4_CHUNK)-1))
241 {
242 case 7: otp = RC4_STEP, i+=8;
243 case 6: otp |= RC4_STEP<<i, i+=8;
244 case 5: otp |= RC4_STEP<<i, i+=8;
245 case 4: otp |= RC4_STEP<<i, i+=8;
246 case 3: otp |= RC4_STEP<<i, i+=8;
247 case 2: otp |= RC4_STEP<<i, i+=8;
248 case 1: otp |= RC4_STEP<<i, i+=8;
249 case 0: ; /*
250 * it's never the case,
251 * but it has to be here
252 * for ultrix?
253 */
254 }
255 ochunk &= ~mask;
256 ochunk |= (otp^ichunk) & mask;
257 *(RC4_CHUNK *)outdata = ochunk;
258 }
259 key->x=x;
260 key->y=y;
261 return;
262 }
263 }
264#endif
81#define LOOP(in,out) \ 265#define LOOP(in,out) \
82 x=((x+1)&0xff); \ 266 x=((x+1)&0xff); \
83 tx=d[x]; \ 267 tx=d[x]; \
diff --git a/src/lib/libssl/src/crypto/rc4/rc4_skey.c b/src/lib/libssl/src/crypto/rc4/rc4_skey.c
index c67a445f1f..bb10c1ebe2 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4_skey.c
+++ b/src/lib/libssl/src/crypto/rc4/rc4_skey.c
@@ -85,7 +85,7 @@ const char *RC4_options(void)
85 * Date: Wed, 14 Sep 1994 06:35:31 GMT 85 * Date: Wed, 14 Sep 1994 06:35:31 GMT
86 */ 86 */
87 87
88void RC4_set_key(RC4_KEY *key, int len, register unsigned char *data) 88void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
89 { 89 {
90 register RC4_INT tmp; 90 register RC4_INT tmp;
91 register int id1,id2; 91 register int id1,id2;
diff --git a/src/lib/libssl/src/crypto/rc4/rc4speed.c b/src/lib/libssl/src/crypto/rc4/rc4speed.c
index 4fb5ebf573..b448f4a5c6 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4speed.c
+++ b/src/lib/libssl/src/crypto/rc4/rc4speed.c
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
183#endif 183#endif
184 184
185#ifndef TIMES 185#ifndef TIMES
186 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
188#endif 188#endif
189 189
diff --git a/src/lib/libssl/src/crypto/rc4/rc4test.c b/src/lib/libssl/src/crypto/rc4/rc4test.c
index 5abf8cff30..3914eb6c38 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4test.c
+++ b/src/lib/libssl/src/crypto/rc4/rc4test.c
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
69#else 69#else
70#include <openssl/rc4.h> 70#include <openssl/rc4.h>
71 71
72unsigned char keys[7][30]={ 72static unsigned char keys[7][30]={
73 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, 73 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
74 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, 74 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
75 {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 75 {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
@@ -78,8 +78,8 @@ unsigned char keys[7][30]={
78 {4,0xef,0x01,0x23,0x45}, 78 {4,0xef,0x01,0x23,0x45},
79 }; 79 };
80 80
81unsigned char data_len[7]={8,8,8,20,28,10}; 81static unsigned char data_len[7]={8,8,8,20,28,10};
82unsigned char data[7][30]={ 82static unsigned char data[7][30]={
83 {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff}, 83 {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff},
84 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, 84 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
85 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, 85 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
@@ -94,7 +94,7 @@ unsigned char data[7][30]={
94 {0}, 94 {0},
95 }; 95 };
96 96
97unsigned char output[7][30]={ 97static unsigned char output[7][30]={
98 {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00}, 98 {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00},
99 {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00}, 99 {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00},
100 {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00}, 100 {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00},
diff --git a/src/lib/libssl/src/crypto/ripemd/Makefile.ssl b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
index 5b6d1d2599..c6153d4361 100644
--- a/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
@@ -102,6 +102,7 @@ clean:
102 102
103# DO NOT DELETE THIS LINE -- make depend depends on it. 103# DO NOT DELETE THIS LINE -- make depend depends on it.
104 104
105rmd_dgst.o: ../../include/openssl/opensslconf.h
105rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h 106rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
106rmd_dgst.o: rmd_locl.h rmdconst.h 107rmd_dgst.o: ../md32_common.h rmd_locl.h rmdconst.h
107rmd_one.o: ../../include/openssl/ripemd.h rmd_locl.h rmdconst.h 108rmd_one.o: ../../include/openssl/ripemd.h
diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rips.cpp b/src/lib/libssl/src/crypto/ripemd/asm/rips.cpp
index 321a98443e..f7a13677a9 100644
--- a/src/lib/libssl/src/crypto/ripemd/asm/rips.cpp
+++ b/src/lib/libssl/src/crypto/ripemd/asm/rips.cpp
@@ -34,6 +34,8 @@ void GetTSC(unsigned long& tsc)
34#include <stdlib.h> 34#include <stdlib.h>
35#include <openssl/ripemd.h> 35#include <openssl/ripemd.h>
36 36
37#define ripemd160_block_x86 ripemd160_block_asm_host_order
38
37extern "C" { 39extern "C" {
38void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num); 40void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num);
39} 41}
@@ -55,8 +57,10 @@ void main(int argc,char *argv[])
55 if (num == 0) num=16; 57 if (num == 0) num=16;
56 if (num > 250) num=16; 58 if (num > 250) num=16;
57 numm=num+2; 59 numm=num+2;
60#if 0
58 num*=64; 61 num*=64;
59 numm*=64; 62 numm*=64;
63#endif
60 64
61 for (j=0; j<6; j++) 65 for (j=0; j<6; j++)
62 { 66 {
@@ -71,7 +75,7 @@ void main(int argc,char *argv[])
71 GetTSC(e2); 75 GetTSC(e2);
72 ripemd160_block_x86(&ctx,buffer,num); 76 ripemd160_block_x86(&ctx,buffer,num);
73 } 77 }
74 printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num, 78 printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num*64,
75 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
76 } 80 }
77 } 81 }
diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm b/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm
index bd38791c13..f07d517857 100644
--- a/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm
+++ b/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm
@@ -8,1965 +8,1966 @@
8 .386 8 .386
9.model FLAT 9.model FLAT
10_TEXT SEGMENT 10_TEXT SEGMENT
11PUBLIC _ripemd160_block_x86 11PUBLIC _ripemd160_block_asm_host_order
12 12
13_ripemd160_block_x86 PROC NEAR 13_ripemd160_block_asm_host_order PROC NEAR
14 mov edx, DWORD PTR 4[esp]
15 mov eax, DWORD PTR 8[esp]
14 push esi 16 push esi
15 mov ecx, DWORD PTR 16[esp] 17 mov ecx, DWORD PTR [edx]
16 push edi 18 push edi
17 mov esi, DWORD PTR 16[esp] 19 mov esi, DWORD PTR 4[edx]
18 push ebp 20 push ebp
19 add ecx, esi 21 mov edi, DWORD PTR 8[edx]
20 push ebx 22 push ebx
21 sub ecx, 64 23 sub esp, 108
22 sub esp, 88
23 mov DWORD PTR [esp],ecx
24 mov edi, DWORD PTR 108[esp]
25L000start: 24L000start:
26 ; 25 ;
27 mov eax, DWORD PTR [esi] 26 mov ebx, DWORD PTR [eax]
28 mov ebx, DWORD PTR 4[esi] 27 mov ebp, DWORD PTR 4[eax]
29 mov DWORD PTR 4[esp],eax 28 mov DWORD PTR [esp],ebx
29 mov DWORD PTR 4[esp],ebp
30 mov ebx, DWORD PTR 8[eax]
31 mov ebp, DWORD PTR 12[eax]
30 mov DWORD PTR 8[esp],ebx 32 mov DWORD PTR 8[esp],ebx
31 mov eax, DWORD PTR 8[esi] 33 mov DWORD PTR 12[esp],ebp
32 mov ebx, DWORD PTR 12[esi] 34 mov ebx, DWORD PTR 16[eax]
33 mov DWORD PTR 12[esp],eax 35 mov ebp, DWORD PTR 20[eax]
34 mov DWORD PTR 16[esp],ebx 36 mov DWORD PTR 16[esp],ebx
35 mov eax, DWORD PTR 16[esi] 37 mov DWORD PTR 20[esp],ebp
36 mov ebx, DWORD PTR 20[esi] 38 mov ebx, DWORD PTR 24[eax]
37 mov DWORD PTR 20[esp],eax 39 mov ebp, DWORD PTR 28[eax]
38 mov DWORD PTR 24[esp],ebx 40 mov DWORD PTR 24[esp],ebx
39 mov eax, DWORD PTR 24[esi] 41 mov DWORD PTR 28[esp],ebp
40 mov ebx, DWORD PTR 28[esi] 42 mov ebx, DWORD PTR 32[eax]
41 mov DWORD PTR 28[esp],eax 43 mov ebp, DWORD PTR 36[eax]
42 mov DWORD PTR 32[esp],ebx 44 mov DWORD PTR 32[esp],ebx
43 mov eax, DWORD PTR 32[esi] 45 mov DWORD PTR 36[esp],ebp
44 mov ebx, DWORD PTR 36[esi] 46 mov ebx, DWORD PTR 40[eax]
45 mov DWORD PTR 36[esp],eax 47 mov ebp, DWORD PTR 44[eax]
46 mov DWORD PTR 40[esp],ebx 48 mov DWORD PTR 40[esp],ebx
47 mov eax, DWORD PTR 40[esi] 49 mov DWORD PTR 44[esp],ebp
48 mov ebx, DWORD PTR 44[esi] 50 mov ebx, DWORD PTR 48[eax]
49 mov DWORD PTR 44[esp],eax 51 mov ebp, DWORD PTR 52[eax]
50 mov DWORD PTR 48[esp],ebx 52 mov DWORD PTR 48[esp],ebx
51 mov eax, DWORD PTR 48[esi] 53 mov DWORD PTR 52[esp],ebp
52 mov ebx, DWORD PTR 52[esi] 54 mov ebx, DWORD PTR 56[eax]
53 mov DWORD PTR 52[esp],eax 55 mov ebp, DWORD PTR 60[eax]
54 mov DWORD PTR 56[esp],ebx 56 mov DWORD PTR 56[esp],ebx
55 mov eax, DWORD PTR 56[esi] 57 mov DWORD PTR 60[esp],ebp
56 mov ebx, DWORD PTR 60[esi] 58 mov eax, edi
57 mov DWORD PTR 60[esp],eax 59 mov ebx, DWORD PTR 12[edx]
58 mov DWORD PTR 64[esp],ebx 60 mov ebp, DWORD PTR 16[edx]
59 add esi, 64
60 mov eax, DWORD PTR [edi]
61 mov DWORD PTR 112[esp],esi
62 mov ebx, DWORD PTR 4[edi]
63 mov ecx, DWORD PTR 8[edi]
64 mov edx, DWORD PTR 12[edi]
65 mov ebp, DWORD PTR 16[edi]
66 ; 0 61 ; 0
67 mov esi, ecx 62 xor eax, ebx
68 xor esi, edx 63 mov edx, DWORD PTR [esp]
69 mov edi, DWORD PTR 4[esp] 64 xor eax, esi
70 xor esi, ebx 65 add ecx, edx
71 add eax, edi 66 rol edi, 10
72 rol ecx, 10 67 add ecx, eax
73 add eax, esi 68 mov eax, esi
74 mov esi, ebx 69 rol ecx, 11
75 rol eax, 11 70 add ecx, ebp
76 add eax, ebp
77 ; 1 71 ; 1
78 xor esi, ecx 72 xor eax, edi
79 mov edi, DWORD PTR 8[esp] 73 mov edx, DWORD PTR 4[esp]
80 xor esi, eax 74 xor eax, ecx
81 add ebp, esi 75 add ebp, eax
82 mov esi, eax 76 mov eax, ecx
83 rol ebx, 10 77 rol esi, 10
84 add ebp, edi
85 xor esi, ebx
86 rol ebp, 14
87 add ebp, edx 78 add ebp, edx
79 xor eax, esi
80 rol ebp, 14
81 add ebp, ebx
88 ; 2 82 ; 2
89 mov edi, DWORD PTR 12[esp] 83 mov edx, DWORD PTR 8[esp]
90 xor esi, ebp 84 xor eax, ebp
91 add edx, edi 85 add ebx, edx
92 rol eax, 10 86 rol ecx, 10
93 add edx, esi 87 add ebx, eax
94 mov esi, ebp 88 mov eax, ebp
95 rol edx, 15 89 rol ebx, 15
96 add edx, ecx 90 add ebx, edi
97 ; 3 91 ; 3
98 xor esi, eax 92 xor eax, ecx
99 mov edi, DWORD PTR 16[esp] 93 mov edx, DWORD PTR 12[esp]
100 xor esi, edx 94 xor eax, ebx
101 add ecx, esi 95 add edi, eax
102 mov esi, edx 96 mov eax, ebx
103 rol ebp, 10 97 rol ebp, 10
104 add ecx, edi 98 add edi, edx
105 xor esi, ebp 99 xor eax, ebp
106 rol ecx, 12 100 rol edi, 12
107 add ecx, ebx 101 add edi, esi
108 ; 4 102 ; 4
109 mov edi, DWORD PTR 20[esp] 103 mov edx, DWORD PTR 16[esp]
110 xor esi, ecx 104 xor eax, edi
111 add ebx, edi 105 add esi, edx
112 rol edx, 10 106 rol ebx, 10
113 add ebx, esi 107 add esi, eax
114 mov esi, ecx 108 mov eax, edi
115 rol ebx, 5 109 rol esi, 5
116 add ebx, eax 110 add esi, ecx
117 ; 5 111 ; 5
118 xor esi, edx 112 xor eax, ebx
119 mov edi, DWORD PTR 24[esp] 113 mov edx, DWORD PTR 20[esp]
120 xor esi, ebx 114 xor eax, esi
121 add eax, esi 115 add ecx, eax
122 mov esi, ebx 116 mov eax, esi
123 rol ecx, 10 117 rol edi, 10
124 add eax, edi 118 add ecx, edx
125 xor esi, ecx 119 xor eax, edi
126 rol eax, 8 120 rol ecx, 8
127 add eax, ebp 121 add ecx, ebp
128 ; 6 122 ; 6
129 mov edi, DWORD PTR 28[esp] 123 mov edx, DWORD PTR 24[esp]
130 xor esi, eax 124 xor eax, ecx
131 add ebp, edi
132 rol ebx, 10
133 add ebp, esi
134 mov esi, eax
135 rol ebp, 7
136 add ebp, edx 125 add ebp, edx
126 rol esi, 10
127 add ebp, eax
128 mov eax, ecx
129 rol ebp, 7
130 add ebp, ebx
137 ; 7 131 ; 7
138 xor esi, ebx 132 xor eax, esi
139 mov edi, DWORD PTR 32[esp] 133 mov edx, DWORD PTR 28[esp]
140 xor esi, ebp 134 xor eax, ebp
141 add edx, esi 135 add ebx, eax
142 mov esi, ebp 136 mov eax, ebp
143 rol eax, 10 137 rol ecx, 10
144 add edx, edi 138 add ebx, edx
145 xor esi, eax 139 xor eax, ecx
146 rol edx, 9 140 rol ebx, 9
147 add edx, ecx 141 add ebx, edi
148 ; 8 142 ; 8
149 mov edi, DWORD PTR 36[esp] 143 mov edx, DWORD PTR 32[esp]
150 xor esi, edx 144 xor eax, ebx
151 add ecx, edi 145 add edi, edx
152 rol ebp, 10 146 rol ebp, 10
153 add ecx, esi 147 add edi, eax
154 mov esi, edx 148 mov eax, ebx
155 rol ecx, 11 149 rol edi, 11
156 add ecx, ebx 150 add edi, esi
157 ; 9 151 ; 9
158 xor esi, ebp 152 xor eax, ebp
159 mov edi, DWORD PTR 40[esp] 153 mov edx, DWORD PTR 36[esp]
160 xor esi, ecx 154 xor eax, edi
161 add ebx, esi 155 add esi, eax
162 mov esi, ecx 156 mov eax, edi
163 rol edx, 10 157 rol ebx, 10
164 add ebx, edi 158 add esi, edx
165 xor esi, edx 159 xor eax, ebx
166 rol ebx, 13 160 rol esi, 13
167 add ebx, eax 161 add esi, ecx
168 ; 10 162 ; 10
169 mov edi, DWORD PTR 44[esp] 163 mov edx, DWORD PTR 40[esp]
170 xor esi, ebx 164 xor eax, esi
171 add eax, edi 165 add ecx, edx
172 rol ecx, 10 166 rol edi, 10
173 add eax, esi 167 add ecx, eax
174 mov esi, ebx 168 mov eax, esi
175 rol eax, 14 169 rol ecx, 14
176 add eax, ebp 170 add ecx, ebp
177 ; 11 171 ; 11
178 xor esi, ecx 172 xor eax, edi
179 mov edi, DWORD PTR 48[esp] 173 mov edx, DWORD PTR 44[esp]
180 xor esi, eax 174 xor eax, ecx
181 add ebp, esi 175 add ebp, eax
182 mov esi, eax 176 mov eax, ecx
183 rol ebx, 10 177 rol esi, 10
184 add ebp, edi
185 xor esi, ebx
186 rol ebp, 15
187 add ebp, edx 178 add ebp, edx
179 xor eax, esi
180 rol ebp, 15
181 add ebp, ebx
188 ; 12 182 ; 12
189 mov edi, DWORD PTR 52[esp] 183 mov edx, DWORD PTR 48[esp]
190 xor esi, ebp 184 xor eax, ebp
191 add edx, edi 185 add ebx, edx
192 rol eax, 10 186 rol ecx, 10
193 add edx, esi 187 add ebx, eax
194 mov esi, ebp 188 mov eax, ebp
195 rol edx, 6 189 rol ebx, 6
196 add edx, ecx 190 add ebx, edi
197 ; 13 191 ; 13
198 xor esi, eax 192 xor eax, ecx
199 mov edi, DWORD PTR 56[esp] 193 mov edx, DWORD PTR 52[esp]
200 xor esi, edx 194 xor eax, ebx
201 add ecx, esi 195 add edi, eax
202 mov esi, edx 196 mov eax, ebx
203 rol ebp, 10 197 rol ebp, 10
204 add ecx, edi 198 add edi, edx
205 xor esi, ebp 199 xor eax, ebp
206 rol ecx, 7 200 rol edi, 7
207 add ecx, ebx 201 add edi, esi
208 ; 14 202 ; 14
209 mov edi, DWORD PTR 60[esp] 203 mov edx, DWORD PTR 56[esp]
210 xor esi, ecx 204 xor eax, edi
211 add ebx, edi 205 add esi, edx
212 rol edx, 10 206 rol ebx, 10
213 add ebx, esi 207 add esi, eax
214 mov esi, ecx 208 mov eax, edi
215 rol ebx, 9 209 rol esi, 9
216 add ebx, eax 210 add esi, ecx
217 ; 15 211 ; 15
218 xor esi, edx 212 xor eax, ebx
219 mov edi, DWORD PTR 64[esp] 213 mov edx, DWORD PTR 60[esp]
220 xor esi, ebx 214 xor eax, esi
221 add eax, esi 215 add ecx, eax
222 mov esi, -1 216 mov eax, -1
223 rol ecx, 10 217 rol edi, 10
224 add eax, edi 218 add ecx, edx
225 mov edi, DWORD PTR 32[esp] 219 mov edx, DWORD PTR 28[esp]
226 rol eax, 8 220 rol ecx, 8
227 add eax, ebp 221 add ecx, ebp
228 ; 16 222 ; 16
229 add ebp, edi
230 mov edi, ebx
231 sub esi, eax
232 and edi, eax
233 and esi, ecx
234 or edi, esi
235 mov esi, DWORD PTR 20[esp]
236 rol ebx, 10
237 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
238 mov edi, -1
239 rol ebp, 7
240 add ebp, edx 223 add ebp, edx
224 mov edx, esi
225 sub eax, ecx
226 and edx, ecx
227 and eax, edi
228 or edx, eax
229 mov eax, DWORD PTR 16[esp]
230 rol esi, 10
231 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
232 mov edx, -1
233 rol ebp, 7
234 add ebp, ebx
241 ; 17 235 ; 17
242 add edx, esi 236 add ebx, eax
243 mov esi, eax 237 mov eax, ecx
244 sub edi, ebp 238 sub edx, ebp
245 and esi, ebp 239 and eax, ebp
246 and edi, ebx 240 and edx, esi
247 or esi, edi 241 or eax, edx
248 mov edi, DWORD PTR 56[esp] 242 mov edx, DWORD PTR 52[esp]
249 rol eax, 10 243 rol ecx, 10
250 lea edx, DWORD PTR 1518500249[esi*1+edx] 244 lea ebx, DWORD PTR 1518500249[eax*1+ebx]
251 mov esi, -1 245 mov eax, -1
252 rol edx, 6 246 rol ebx, 6
253 add edx, ecx 247 add ebx, edi
254 ; 18 248 ; 18
255 add ecx, edi 249 add edi, edx
256 mov edi, ebp 250 mov edx, ebp
257 sub esi, edx 251 sub eax, ebx
258 and edi, edx 252 and edx, ebx
259 and esi, eax 253 and eax, ecx
260 or edi, esi 254 or edx, eax
261 mov esi, DWORD PTR 8[esp] 255 mov eax, DWORD PTR 4[esp]
262 rol ebp, 10 256 rol ebp, 10
263 lea ecx, DWORD PTR 1518500249[edi*1+ecx] 257 lea edi, DWORD PTR 1518500249[edx*1+edi]
264 mov edi, -1 258 mov edx, -1
265 rol ecx, 8 259 rol edi, 8
266 add ecx, ebx 260 add edi, esi
267 ; 19 261 ; 19
268 add ebx, esi 262 add esi, eax
269 mov esi, edx 263 mov eax, ebx
270 sub edi, ecx 264 sub edx, edi
271 and esi, ecx 265 and eax, edi
272 and edi, ebp 266 and edx, ebp
273 or esi, edi 267 or eax, edx
274 mov edi, DWORD PTR 44[esp] 268 mov edx, DWORD PTR 40[esp]
275 rol edx, 10 269 rol ebx, 10
276 lea ebx, DWORD PTR 1518500249[esi*1+ebx] 270 lea esi, DWORD PTR 1518500249[eax*1+esi]
277 mov esi, -1 271 mov eax, -1
278 rol ebx, 13 272 rol esi, 13
279 add ebx, eax 273 add esi, ecx
280 ; 20 274 ; 20
281 add eax, edi 275 add ecx, edx
282 mov edi, ecx 276 mov edx, edi
283 sub esi, ebx 277 sub eax, esi
284 and edi, ebx 278 and edx, esi
285 and esi, edx 279 and eax, ebx
286 or edi, esi 280 or edx, eax
287 mov esi, DWORD PTR 28[esp] 281 mov eax, DWORD PTR 24[esp]
288 rol ecx, 10 282 rol edi, 10
289 lea eax, DWORD PTR 1518500249[edi*1+eax] 283 lea ecx, DWORD PTR 1518500249[edx*1+ecx]
290 mov edi, -1 284 mov edx, -1
291 rol eax, 11 285 rol ecx, 11
292 add eax, ebp 286 add ecx, ebp
293 ; 21 287 ; 21
294 add ebp, esi 288 add ebp, eax
295 mov esi, ebx 289 mov eax, esi
296 sub edi, eax 290 sub edx, ecx
297 and esi, eax 291 and eax, ecx
298 and edi, ecx 292 and edx, edi
299 or esi, edi 293 or eax, edx
300 mov edi, DWORD PTR 64[esp] 294 mov edx, DWORD PTR 60[esp]
301 rol ebx, 10 295 rol esi, 10
302 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 296 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
303 mov esi, -1 297 mov eax, -1
304 rol ebp, 9 298 rol ebp, 9
305 add ebp, edx 299 add ebp, ebx
306 ; 22 300 ; 22
307 add edx, edi 301 add ebx, edx
308 mov edi, eax 302 mov edx, ecx
309 sub esi, ebp 303 sub eax, ebp
310 and edi, ebp 304 and edx, ebp
311 and esi, ebx 305 and eax, esi
312 or edi, esi 306 or edx, eax
313 mov esi, DWORD PTR 16[esp] 307 mov eax, DWORD PTR 12[esp]
314 rol eax, 10 308 rol ecx, 10
315 lea edx, DWORD PTR 1518500249[edi*1+edx] 309 lea ebx, DWORD PTR 1518500249[edx*1+ebx]
316 mov edi, -1 310 mov edx, -1
317 rol edx, 7 311 rol ebx, 7
318 add edx, ecx 312 add ebx, edi
319 ; 23 313 ; 23
320 add ecx, esi 314 add edi, eax
321 mov esi, ebp 315 mov eax, ebp
322 sub edi, edx 316 sub edx, ebx
323 and esi, edx 317 and eax, ebx
324 and edi, eax 318 and edx, ecx
325 or esi, edi 319 or eax, edx
326 mov edi, DWORD PTR 52[esp] 320 mov edx, DWORD PTR 48[esp]
327 rol ebp, 10 321 rol ebp, 10
328 lea ecx, DWORD PTR 1518500249[esi*1+ecx] 322 lea edi, DWORD PTR 1518500249[eax*1+edi]
329 mov esi, -1 323 mov eax, -1
330 rol ecx, 15 324 rol edi, 15
331 add ecx, ebx 325 add edi, esi
332 ; 24 326 ; 24
333 add ebx, edi 327 add esi, edx
334 mov edi, edx 328 mov edx, ebx
335 sub esi, ecx 329 sub eax, edi
336 and edi, ecx 330 and edx, edi
337 and esi, ebp 331 and eax, ebp
338 or edi, esi 332 or edx, eax
339 mov esi, DWORD PTR 4[esp] 333 mov eax, DWORD PTR [esp]
340 rol edx, 10 334 rol ebx, 10
341 lea ebx, DWORD PTR 1518500249[edi*1+ebx] 335 lea esi, DWORD PTR 1518500249[edx*1+esi]
342 mov edi, -1 336 mov edx, -1
343 rol ebx, 7 337 rol esi, 7
344 add ebx, eax 338 add esi, ecx
345 ; 25 339 ; 25
346 add eax, esi 340 add ecx, eax
347 mov esi, ecx 341 mov eax, edi
348 sub edi, ebx 342 sub edx, esi
349 and esi, ebx 343 and eax, esi
350 and edi, edx 344 and edx, ebx
351 or esi, edi 345 or eax, edx
352 mov edi, DWORD PTR 40[esp] 346 mov edx, DWORD PTR 36[esp]
353 rol ecx, 10 347 rol edi, 10
354 lea eax, DWORD PTR 1518500249[esi*1+eax] 348 lea ecx, DWORD PTR 1518500249[eax*1+ecx]
355 mov esi, -1 349 mov eax, -1
356 rol eax, 12 350 rol ecx, 12
357 add eax, ebp 351 add ecx, ebp
358 ; 26 352 ; 26
359 add ebp, edi
360 mov edi, ebx
361 sub esi, eax
362 and edi, eax
363 and esi, ecx
364 or edi, esi
365 mov esi, DWORD PTR 24[esp]
366 rol ebx, 10
367 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
368 mov edi, -1
369 rol ebp, 15
370 add ebp, edx 353 add ebp, edx
354 mov edx, esi
355 sub eax, ecx
356 and edx, ecx
357 and eax, edi
358 or edx, eax
359 mov eax, DWORD PTR 20[esp]
360 rol esi, 10
361 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
362 mov edx, -1
363 rol ebp, 15
364 add ebp, ebx
371 ; 27 365 ; 27
372 add edx, esi 366 add ebx, eax
373 mov esi, eax 367 mov eax, ecx
374 sub edi, ebp 368 sub edx, ebp
375 and esi, ebp 369 and eax, ebp
376 and edi, ebx 370 and edx, esi
377 or esi, edi 371 or eax, edx
378 mov edi, DWORD PTR 12[esp] 372 mov edx, DWORD PTR 8[esp]
379 rol eax, 10 373 rol ecx, 10
380 lea edx, DWORD PTR 1518500249[esi*1+edx] 374 lea ebx, DWORD PTR 1518500249[eax*1+ebx]
381 mov esi, -1 375 mov eax, -1
382 rol edx, 9 376 rol ebx, 9
383 add edx, ecx 377 add ebx, edi
384 ; 28 378 ; 28
385 add ecx, edi 379 add edi, edx
386 mov edi, ebp 380 mov edx, ebp
387 sub esi, edx 381 sub eax, ebx
388 and edi, edx 382 and edx, ebx
389 and esi, eax 383 and eax, ecx
390 or edi, esi 384 or edx, eax
391 mov esi, DWORD PTR 60[esp] 385 mov eax, DWORD PTR 56[esp]
392 rol ebp, 10 386 rol ebp, 10
393 lea ecx, DWORD PTR 1518500249[edi*1+ecx] 387 lea edi, DWORD PTR 1518500249[edx*1+edi]
394 mov edi, -1 388 mov edx, -1
395 rol ecx, 11 389 rol edi, 11
396 add ecx, ebx 390 add edi, esi
397 ; 29 391 ; 29
398 add ebx, esi 392 add esi, eax
399 mov esi, edx 393 mov eax, ebx
400 sub edi, ecx 394 sub edx, edi
401 and esi, ecx 395 and eax, edi
402 and edi, ebp 396 and edx, ebp
403 or esi, edi 397 or eax, edx
404 mov edi, DWORD PTR 48[esp] 398 mov edx, DWORD PTR 44[esp]
405 rol edx, 10 399 rol ebx, 10
406 lea ebx, DWORD PTR 1518500249[esi*1+ebx] 400 lea esi, DWORD PTR 1518500249[eax*1+esi]
407 mov esi, -1 401 mov eax, -1
408 rol ebx, 7 402 rol esi, 7
409 add ebx, eax 403 add esi, ecx
410 ; 30 404 ; 30
411 add eax, edi 405 add ecx, edx
412 mov edi, ecx 406 mov edx, edi
413 sub esi, ebx 407 sub eax, esi
414 and edi, ebx 408 and edx, esi
415 and esi, edx 409 and eax, ebx
416 or edi, esi 410 or edx, eax
417 mov esi, DWORD PTR 36[esp] 411 mov eax, DWORD PTR 32[esp]
418 rol ecx, 10 412 rol edi, 10
419 lea eax, DWORD PTR 1518500249[edi*1+eax] 413 lea ecx, DWORD PTR 1518500249[edx*1+ecx]
420 mov edi, -1 414 mov edx, -1
421 rol eax, 13 415 rol ecx, 13
422 add eax, ebp 416 add ecx, ebp
423 ; 31 417 ; 31
424 add ebp, esi 418 add ebp, eax
425 mov esi, ebx 419 mov eax, esi
426 sub edi, eax 420 sub edx, ecx
427 and esi, eax 421 and eax, ecx
428 and edi, ecx 422 and edx, edi
429 or esi, edi 423 or eax, edx
430 mov edi, -1 424 mov edx, -1
431 rol ebx, 10 425 rol esi, 10
432 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 426 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
433 sub edi, eax 427 sub edx, ecx
434 rol ebp, 12 428 rol ebp, 12
435 add ebp, edx 429 add ebp, ebx
436 ; 32 430 ; 32
437 mov esi, DWORD PTR 16[esp] 431 mov eax, DWORD PTR 12[esp]
438 or edi, ebp 432 or edx, ebp
439 add edx, esi 433 add ebx, eax
440 xor edi, ebx 434 xor edx, esi
441 mov esi, -1 435 mov eax, -1
442 rol eax, 10 436 rol ecx, 10
443 lea edx, DWORD PTR 1859775393[edi*1+edx] 437 lea ebx, DWORD PTR 1859775393[edx*1+ebx]
444 sub esi, ebp 438 sub eax, ebp
445 rol edx, 11 439 rol ebx, 11
446 add edx, ecx 440 add ebx, edi
447 ; 33 441 ; 33
448 mov edi, DWORD PTR 44[esp] 442 mov edx, DWORD PTR 40[esp]
449 or esi, edx 443 or eax, ebx
450 add ecx, edi 444 add edi, edx
451 xor esi, eax 445 xor eax, ecx
452 mov edi, -1 446 mov edx, -1
453 rol ebp, 10 447 rol ebp, 10
454 lea ecx, DWORD PTR 1859775393[esi*1+ecx] 448 lea edi, DWORD PTR 1859775393[eax*1+edi]
455 sub edi, edx 449 sub edx, ebx
456 rol ecx, 13 450 rol edi, 13
457 add ecx, ebx 451 add edi, esi
458 ; 34 452 ; 34
459 mov esi, DWORD PTR 60[esp] 453 mov eax, DWORD PTR 56[esp]
460 or edi, ecx 454 or edx, edi
461 add ebx, esi 455 add esi, eax
462 xor edi, ebp 456 xor edx, ebp
463 mov esi, -1 457 mov eax, -1
464 rol edx, 10 458 rol ebx, 10
465 lea ebx, DWORD PTR 1859775393[edi*1+ebx] 459 lea esi, DWORD PTR 1859775393[edx*1+esi]
466 sub esi, ecx 460 sub eax, edi
467 rol ebx, 6 461 rol esi, 6
468 add ebx, eax 462 add esi, ecx
469 ; 35 463 ; 35
470 mov edi, DWORD PTR 20[esp] 464 mov edx, DWORD PTR 16[esp]
471 or esi, ebx 465 or eax, esi
472 add eax, edi 466 add ecx, edx
473 xor esi, edx 467 xor eax, ebx
474 mov edi, -1 468 mov edx, -1
475 rol ecx, 10 469 rol edi, 10
476 lea eax, DWORD PTR 1859775393[esi*1+eax] 470 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
477 sub edi, ebx 471 sub edx, esi
478 rol eax, 7 472 rol ecx, 7
479 add eax, ebp 473 add ecx, ebp
480 ; 36 474 ; 36
481 mov esi, DWORD PTR 40[esp] 475 mov eax, DWORD PTR 36[esp]
482 or edi, eax 476 or edx, ecx
483 add ebp, esi 477 add ebp, eax
484 xor edi, ecx 478 xor edx, edi
485 mov esi, -1 479 mov eax, -1
486 rol ebx, 10 480 rol esi, 10
487 lea ebp, DWORD PTR 1859775393[edi*1+ebp] 481 lea ebp, DWORD PTR 1859775393[edx*1+ebp]
488 sub esi, eax 482 sub eax, ecx
489 rol ebp, 14 483 rol ebp, 14
490 add ebp, edx 484 add ebp, ebx
491 ; 37 485 ; 37
492 mov edi, DWORD PTR 64[esp] 486 mov edx, DWORD PTR 60[esp]
493 or esi, ebp 487 or eax, ebp
494 add edx, edi 488 add ebx, edx
495 xor esi, ebx 489 xor eax, esi
496 mov edi, -1 490 mov edx, -1
497 rol eax, 10 491 rol ecx, 10
498 lea edx, DWORD PTR 1859775393[esi*1+edx] 492 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
499 sub edi, ebp 493 sub edx, ebp
500 rol edx, 9 494 rol ebx, 9
501 add edx, ecx 495 add ebx, edi
502 ; 38 496 ; 38
503 mov esi, DWORD PTR 36[esp] 497 mov eax, DWORD PTR 32[esp]
504 or edi, edx 498 or edx, ebx
505 add ecx, esi 499 add edi, eax
506 xor edi, eax 500 xor edx, ecx
507 mov esi, -1 501 mov eax, -1
508 rol ebp, 10 502 rol ebp, 10
509 lea ecx, DWORD PTR 1859775393[edi*1+ecx] 503 lea edi, DWORD PTR 1859775393[edx*1+edi]
510 sub esi, edx 504 sub eax, ebx
511 rol ecx, 13 505 rol edi, 13
512 add ecx, ebx 506 add edi, esi
513 ; 39 507 ; 39
514 mov edi, DWORD PTR 8[esp] 508 mov edx, DWORD PTR 4[esp]
515 or esi, ecx 509 or eax, edi
516 add ebx, edi 510 add esi, edx
517 xor esi, ebp 511 xor eax, ebp
518 mov edi, -1 512 mov edx, -1
519 rol edx, 10 513 rol ebx, 10
520 lea ebx, DWORD PTR 1859775393[esi*1+ebx] 514 lea esi, DWORD PTR 1859775393[eax*1+esi]
521 sub edi, ecx 515 sub edx, edi
522 rol ebx, 15 516 rol esi, 15
523 add ebx, eax 517 add esi, ecx
524 ; 40 518 ; 40
525 mov esi, DWORD PTR 12[esp] 519 mov eax, DWORD PTR 8[esp]
526 or edi, ebx 520 or edx, esi
527 add eax, esi 521 add ecx, eax
528 xor edi, edx 522 xor edx, ebx
529 mov esi, -1 523 mov eax, -1
530 rol ecx, 10 524 rol edi, 10
531 lea eax, DWORD PTR 1859775393[edi*1+eax] 525 lea ecx, DWORD PTR 1859775393[edx*1+ecx]
532 sub esi, ebx 526 sub eax, esi
533 rol eax, 14 527 rol ecx, 14
534 add eax, ebp 528 add ecx, ebp
535 ; 41 529 ; 41
536 mov edi, DWORD PTR 32[esp] 530 mov edx, DWORD PTR 28[esp]
537 or esi, eax 531 or eax, ecx
538 add ebp, edi
539 xor esi, ecx
540 mov edi, -1
541 rol ebx, 10
542 lea ebp, DWORD PTR 1859775393[esi*1+ebp]
543 sub edi, eax
544 rol ebp, 8
545 add ebp, edx 532 add ebp, edx
533 xor eax, edi
534 mov edx, -1
535 rol esi, 10
536 lea ebp, DWORD PTR 1859775393[eax*1+ebp]
537 sub edx, ecx
538 rol ebp, 8
539 add ebp, ebx
546 ; 42 540 ; 42
547 mov esi, DWORD PTR 4[esp] 541 mov eax, DWORD PTR [esp]
548 or edi, ebp 542 or edx, ebp
549 add edx, esi 543 add ebx, eax
550 xor edi, ebx 544 xor edx, esi
551 mov esi, -1 545 mov eax, -1
552 rol eax, 10 546 rol ecx, 10
553 lea edx, DWORD PTR 1859775393[edi*1+edx] 547 lea ebx, DWORD PTR 1859775393[edx*1+ebx]
554 sub esi, ebp 548 sub eax, ebp
555 rol edx, 13 549 rol ebx, 13
556 add edx, ecx 550 add ebx, edi
557 ; 43 551 ; 43
558 mov edi, DWORD PTR 28[esp] 552 mov edx, DWORD PTR 24[esp]
559 or esi, edx 553 or eax, ebx
560 add ecx, edi 554 add edi, edx
561 xor esi, eax 555 xor eax, ecx
562 mov edi, -1 556 mov edx, -1
563 rol ebp, 10 557 rol ebp, 10
564 lea ecx, DWORD PTR 1859775393[esi*1+ecx] 558 lea edi, DWORD PTR 1859775393[eax*1+edi]
565 sub edi, edx 559 sub edx, ebx
566 rol ecx, 6 560 rol edi, 6
567 add ecx, ebx 561 add edi, esi
568 ; 44 562 ; 44
569 mov esi, DWORD PTR 56[esp] 563 mov eax, DWORD PTR 52[esp]
570 or edi, ecx 564 or edx, edi
571 add ebx, esi 565 add esi, eax
572 xor edi, ebp 566 xor edx, ebp
573 mov esi, -1 567 mov eax, -1
574 rol edx, 10 568 rol ebx, 10
575 lea ebx, DWORD PTR 1859775393[edi*1+ebx] 569 lea esi, DWORD PTR 1859775393[edx*1+esi]
576 sub esi, ecx 570 sub eax, edi
577 rol ebx, 5 571 rol esi, 5
578 add ebx, eax 572 add esi, ecx
579 ; 45 573 ; 45
580 mov edi, DWORD PTR 48[esp] 574 mov edx, DWORD PTR 44[esp]
581 or esi, ebx 575 or eax, esi
582 add eax, edi 576 add ecx, edx
583 xor esi, edx 577 xor eax, ebx
584 mov edi, -1 578 mov edx, -1
585 rol ecx, 10 579 rol edi, 10
586 lea eax, DWORD PTR 1859775393[esi*1+eax] 580 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
587 sub edi, ebx 581 sub edx, esi
588 rol eax, 12 582 rol ecx, 12
589 add eax, ebp 583 add ecx, ebp
590 ; 46 584 ; 46
591 mov esi, DWORD PTR 24[esp] 585 mov eax, DWORD PTR 20[esp]
592 or edi, eax 586 or edx, ecx
593 add ebp, esi 587 add ebp, eax
594 xor edi, ecx 588 xor edx, edi
595 mov esi, -1 589 mov eax, -1
596 rol ebx, 10 590 rol esi, 10
597 lea ebp, DWORD PTR 1859775393[edi*1+ebp] 591 lea ebp, DWORD PTR 1859775393[edx*1+ebp]
598 sub esi, eax 592 sub eax, ecx
599 rol ebp, 7 593 rol ebp, 7
600 add ebp, edx 594 add ebp, ebx
601 ; 47 595 ; 47
602 mov edi, DWORD PTR 52[esp] 596 mov edx, DWORD PTR 48[esp]
603 or esi, ebp 597 or eax, ebp
604 add edx, edi 598 add ebx, edx
605 xor esi, ebx 599 xor eax, esi
606 mov edi, -1 600 mov edx, -1
607 rol eax, 10 601 rol ecx, 10
608 lea edx, DWORD PTR 1859775393[esi*1+edx] 602 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
609 mov esi, eax 603 mov eax, ecx
610 rol edx, 5 604 rol ebx, 5
611 add edx, ecx 605 add ebx, edi
612 ; 48 606 ; 48
613 sub edi, eax 607 sub edx, ecx
614 and esi, edx 608 and eax, ebx
615 and edi, ebp 609 and edx, ebp
616 or edi, esi 610 or edx, eax
617 mov esi, DWORD PTR 8[esp] 611 mov eax, DWORD PTR 4[esp]
618 rol ebp, 10 612 rol ebp, 10
619 lea ecx, DWORD PTR 2400959708[edi+ecx] 613 lea edi, DWORD PTR 2400959708[edx+edi]
620 mov edi, -1 614 mov edx, -1
621 add ecx, esi 615 add edi, eax
622 mov esi, ebp 616 mov eax, ebp
623 rol ecx, 11 617 rol edi, 11
624 add ecx, ebx 618 add edi, esi
625 ; 49 619 ; 49
626 sub edi, ebp 620 sub edx, ebp
627 and esi, ecx 621 and eax, edi
628 and edi, edx 622 and edx, ebx
629 or edi, esi 623 or edx, eax
630 mov esi, DWORD PTR 40[esp] 624 mov eax, DWORD PTR 36[esp]
631 rol edx, 10 625 rol ebx, 10
632 lea ebx, DWORD PTR 2400959708[edi+ebx] 626 lea esi, DWORD PTR 2400959708[edx+esi]
633 mov edi, -1 627 mov edx, -1
634 add ebx, esi 628 add esi, eax
635 mov esi, edx 629 mov eax, ebx
636 rol ebx, 12 630 rol esi, 12
637 add ebx, eax 631 add esi, ecx
638 ; 50 632 ; 50
639 sub edi, edx 633 sub edx, ebx
640 and esi, ebx 634 and eax, esi
641 and edi, ecx 635 and edx, edi
642 or edi, esi 636 or edx, eax
643 mov esi, DWORD PTR 48[esp] 637 mov eax, DWORD PTR 44[esp]
644 rol ecx, 10 638 rol edi, 10
645 lea eax, DWORD PTR 2400959708[edi+eax] 639 lea ecx, DWORD PTR 2400959708[edx+ecx]
646 mov edi, -1 640 mov edx, -1
647 add eax, esi 641 add ecx, eax
648 mov esi, ecx 642 mov eax, edi
649 rol eax, 14 643 rol ecx, 14
650 add eax, ebp 644 add ecx, ebp
651 ; 51 645 ; 51
652 sub edi, ecx 646 sub edx, edi
653 and esi, eax 647 and eax, ecx
654 and edi, ebx 648 and edx, esi
655 or edi, esi 649 or edx, eax
656 mov esi, DWORD PTR 44[esp] 650 mov eax, DWORD PTR 40[esp]
657 rol ebx, 10 651 rol esi, 10
658 lea ebp, DWORD PTR 2400959708[edi+ebp] 652 lea ebp, DWORD PTR 2400959708[edx+ebp]
659 mov edi, -1 653 mov edx, -1
660 add ebp, esi 654 add ebp, eax
661 mov esi, ebx 655 mov eax, esi
662 rol ebp, 15 656 rol ebp, 15
663 add ebp, edx 657 add ebp, ebx
664 ; 52 658 ; 52
665 sub edi, ebx 659 sub edx, esi
666 and esi, ebp 660 and eax, ebp
667 and edi, eax 661 and edx, ecx
668 or edi, esi 662 or edx, eax
669 mov esi, DWORD PTR 4[esp] 663 mov eax, DWORD PTR [esp]
670 rol eax, 10 664 rol ecx, 10
671 lea edx, DWORD PTR 2400959708[edi+edx] 665 lea ebx, DWORD PTR 2400959708[edx+ebx]
672 mov edi, -1 666 mov edx, -1
673 add edx, esi 667 add ebx, eax
674 mov esi, eax 668 mov eax, ecx
675 rol edx, 14 669 rol ebx, 14
676 add edx, ecx 670 add ebx, edi
677 ; 53 671 ; 53
678 sub edi, eax 672 sub edx, ecx
679 and esi, edx 673 and eax, ebx
680 and edi, ebp 674 and edx, ebp
681 or edi, esi 675 or edx, eax
682 mov esi, DWORD PTR 36[esp] 676 mov eax, DWORD PTR 32[esp]
683 rol ebp, 10 677 rol ebp, 10
684 lea ecx, DWORD PTR 2400959708[edi+ecx] 678 lea edi, DWORD PTR 2400959708[edx+edi]
685 mov edi, -1 679 mov edx, -1
686 add ecx, esi 680 add edi, eax
687 mov esi, ebp 681 mov eax, ebp
688 rol ecx, 15 682 rol edi, 15
689 add ecx, ebx 683 add edi, esi
690 ; 54 684 ; 54
691 sub edi, ebp 685 sub edx, ebp
692 and esi, ecx 686 and eax, edi
693 and edi, edx 687 and edx, ebx
694 or edi, esi 688 or edx, eax
695 mov esi, DWORD PTR 52[esp] 689 mov eax, DWORD PTR 48[esp]
696 rol edx, 10 690 rol ebx, 10
697 lea ebx, DWORD PTR 2400959708[edi+ebx] 691 lea esi, DWORD PTR 2400959708[edx+esi]
698 mov edi, -1 692 mov edx, -1
699 add ebx, esi 693 add esi, eax
700 mov esi, edx 694 mov eax, ebx
701 rol ebx, 9 695 rol esi, 9
702 add ebx, eax 696 add esi, ecx
703 ; 55 697 ; 55
704 sub edi, edx 698 sub edx, ebx
705 and esi, ebx 699 and eax, esi
706 and edi, ecx 700 and edx, edi
707 or edi, esi 701 or edx, eax
708 mov esi, DWORD PTR 20[esp] 702 mov eax, DWORD PTR 16[esp]
709 rol ecx, 10 703 rol edi, 10
710 lea eax, DWORD PTR 2400959708[edi+eax] 704 lea ecx, DWORD PTR 2400959708[edx+ecx]
711 mov edi, -1 705 mov edx, -1
712 add eax, esi 706 add ecx, eax
713 mov esi, ecx 707 mov eax, edi
714 rol eax, 8 708 rol ecx, 8
715 add eax, ebp 709 add ecx, ebp
716 ; 56 710 ; 56
717 sub edi, ecx 711 sub edx, edi
718 and esi, eax 712 and eax, ecx
719 and edi, ebx 713 and edx, esi
720 or edi, esi 714 or edx, eax
721 mov esi, DWORD PTR 56[esp] 715 mov eax, DWORD PTR 52[esp]
722 rol ebx, 10 716 rol esi, 10
723 lea ebp, DWORD PTR 2400959708[edi+ebp] 717 lea ebp, DWORD PTR 2400959708[edx+ebp]
724 mov edi, -1 718 mov edx, -1
725 add ebp, esi 719 add ebp, eax
726 mov esi, ebx 720 mov eax, esi
727 rol ebp, 9 721 rol ebp, 9
728 add ebp, edx 722 add ebp, ebx
729 ; 57 723 ; 57
730 sub edi, ebx 724 sub edx, esi
731 and esi, ebp 725 and eax, ebp
732 and edi, eax 726 and edx, ecx
733 or edi, esi 727 or edx, eax
734 mov esi, DWORD PTR 16[esp] 728 mov eax, DWORD PTR 12[esp]
735 rol eax, 10 729 rol ecx, 10
736 lea edx, DWORD PTR 2400959708[edi+edx] 730 lea ebx, DWORD PTR 2400959708[edx+ebx]
737 mov edi, -1 731 mov edx, -1
738 add edx, esi 732 add ebx, eax
739 mov esi, eax 733 mov eax, ecx
740 rol edx, 14 734 rol ebx, 14
741 add edx, ecx 735 add ebx, edi
742 ; 58 736 ; 58
743 sub edi, eax 737 sub edx, ecx
744 and esi, edx 738 and eax, ebx
745 and edi, ebp 739 and edx, ebp
746 or edi, esi 740 or edx, eax
747 mov esi, DWORD PTR 32[esp] 741 mov eax, DWORD PTR 28[esp]
748 rol ebp, 10 742 rol ebp, 10
749 lea ecx, DWORD PTR 2400959708[edi+ecx] 743 lea edi, DWORD PTR 2400959708[edx+edi]
750 mov edi, -1 744 mov edx, -1
751 add ecx, esi 745 add edi, eax
752 mov esi, ebp 746 mov eax, ebp
753 rol ecx, 5 747 rol edi, 5
754 add ecx, ebx 748 add edi, esi
755 ; 59 749 ; 59
756 sub edi, ebp 750 sub edx, ebp
757 and esi, ecx 751 and eax, edi
758 and edi, edx 752 and edx, ebx
759 or edi, esi 753 or edx, eax
760 mov esi, DWORD PTR 64[esp] 754 mov eax, DWORD PTR 60[esp]
761 rol edx, 10 755 rol ebx, 10
762 lea ebx, DWORD PTR 2400959708[edi+ebx] 756 lea esi, DWORD PTR 2400959708[edx+esi]
763 mov edi, -1 757 mov edx, -1
764 add ebx, esi 758 add esi, eax
765 mov esi, edx 759 mov eax, ebx
766 rol ebx, 6 760 rol esi, 6
767 add ebx, eax 761 add esi, ecx
768 ; 60 762 ; 60
769 sub edi, edx 763 sub edx, ebx
770 and esi, ebx 764 and eax, esi
771 and edi, ecx 765 and edx, edi
772 or edi, esi 766 or edx, eax
773 mov esi, DWORD PTR 60[esp] 767 mov eax, DWORD PTR 56[esp]
774 rol ecx, 10 768 rol edi, 10
775 lea eax, DWORD PTR 2400959708[edi+eax] 769 lea ecx, DWORD PTR 2400959708[edx+ecx]
776 mov edi, -1 770 mov edx, -1
777 add eax, esi 771 add ecx, eax
778 mov esi, ecx 772 mov eax, edi
779 rol eax, 8 773 rol ecx, 8
780 add eax, ebp 774 add ecx, ebp
781 ; 61 775 ; 61
782 sub edi, ecx 776 sub edx, edi
783 and esi, eax 777 and eax, ecx
784 and edi, ebx 778 and edx, esi
785 or edi, esi 779 or edx, eax
786 mov esi, DWORD PTR 24[esp] 780 mov eax, DWORD PTR 20[esp]
787 rol ebx, 10 781 rol esi, 10
788 lea ebp, DWORD PTR 2400959708[edi+ebp] 782 lea ebp, DWORD PTR 2400959708[edx+ebp]
789 mov edi, -1 783 mov edx, -1
790 add ebp, esi 784 add ebp, eax
791 mov esi, ebx 785 mov eax, esi
792 rol ebp, 6 786 rol ebp, 6
793 add ebp, edx 787 add ebp, ebx
794 ; 62 788 ; 62
795 sub edi, ebx 789 sub edx, esi
796 and esi, ebp 790 and eax, ebp
797 and edi, eax 791 and edx, ecx
798 or edi, esi 792 or edx, eax
799 mov esi, DWORD PTR 28[esp] 793 mov eax, DWORD PTR 24[esp]
800 rol eax, 10 794 rol ecx, 10
801 lea edx, DWORD PTR 2400959708[edi+edx] 795 lea ebx, DWORD PTR 2400959708[edx+ebx]
802 mov edi, -1 796 mov edx, -1
803 add edx, esi 797 add ebx, eax
804 mov esi, eax 798 mov eax, ecx
805 rol edx, 5 799 rol ebx, 5
806 add edx, ecx 800 add ebx, edi
807 ; 63 801 ; 63
808 sub edi, eax 802 sub edx, ecx
809 and esi, edx 803 and eax, ebx
810 and edi, ebp 804 and edx, ebp
811 or edi, esi 805 or edx, eax
812 mov esi, DWORD PTR 12[esp] 806 mov eax, DWORD PTR 8[esp]
813 rol ebp, 10 807 rol ebp, 10
814 lea ecx, DWORD PTR 2400959708[edi+ecx] 808 lea edi, DWORD PTR 2400959708[edx+edi]
815 mov edi, -1 809 mov edx, -1
816 add ecx, esi 810 add edi, eax
817 sub edi, ebp 811 sub edx, ebp
818 rol ecx, 12 812 rol edi, 12
819 add ecx, ebx 813 add edi, esi
820 ; 64 814 ; 64
821 mov esi, DWORD PTR 20[esp] 815 mov eax, DWORD PTR 16[esp]
822 or edi, edx 816 or edx, ebx
823 add ebx, esi 817 add esi, eax
824 xor edi, ecx 818 xor edx, edi
825 mov esi, -1 819 mov eax, -1
826 rol edx, 10 820 rol ebx, 10
827 lea ebx, DWORD PTR 2840853838[edi*1+ebx] 821 lea esi, DWORD PTR 2840853838[edx*1+esi]
828 sub esi, edx 822 sub eax, ebx
829 rol ebx, 9 823 rol esi, 9
830 add ebx, eax 824 add esi, ecx
831 ; 65 825 ; 65
832 mov edi, DWORD PTR 4[esp] 826 mov edx, DWORD PTR [esp]
833 or esi, ecx 827 or eax, edi
834 add eax, edi 828 add ecx, edx
835 xor esi, ebx 829 xor eax, esi
836 mov edi, -1 830 mov edx, -1
837 rol ecx, 10 831 rol edi, 10
838 lea eax, DWORD PTR 2840853838[esi*1+eax] 832 lea ecx, DWORD PTR 2840853838[eax*1+ecx]
839 sub edi, ecx 833 sub edx, edi
840 rol eax, 15 834 rol ecx, 15
841 add eax, ebp 835 add ecx, ebp
842 ; 66 836 ; 66
843 mov esi, DWORD PTR 24[esp] 837 mov eax, DWORD PTR 20[esp]
844 or edi, ebx 838 or edx, esi
845 add ebp, esi 839 add ebp, eax
846 xor edi, eax 840 xor edx, ecx
847 mov esi, -1 841 mov eax, -1
848 rol ebx, 10 842 rol esi, 10
849 lea ebp, DWORD PTR 2840853838[edi*1+ebp] 843 lea ebp, DWORD PTR 2840853838[edx*1+ebp]
850 sub esi, ebx 844 sub eax, esi
851 rol ebp, 5 845 rol ebp, 5
852 add ebp, edx 846 add ebp, ebx
853 ; 67 847 ; 67
854 mov edi, DWORD PTR 40[esp] 848 mov edx, DWORD PTR 36[esp]
855 or esi, eax 849 or eax, ecx
856 add edx, edi 850 add ebx, edx
857 xor esi, ebp 851 xor eax, ebp
858 mov edi, -1 852 mov edx, -1
859 rol eax, 10 853 rol ecx, 10
860 lea edx, DWORD PTR 2840853838[esi*1+edx] 854 lea ebx, DWORD PTR 2840853838[eax*1+ebx]
861 sub edi, eax 855 sub edx, ecx
862 rol edx, 11 856 rol ebx, 11
863 add edx, ecx 857 add ebx, edi
864 ; 68 858 ; 68
865 mov esi, DWORD PTR 32[esp] 859 mov eax, DWORD PTR 28[esp]
866 or edi, ebp 860 or edx, ebp
867 add ecx, esi 861 add edi, eax
868 xor edi, edx 862 xor edx, ebx
869 mov esi, -1 863 mov eax, -1
870 rol ebp, 10 864 rol ebp, 10
871 lea ecx, DWORD PTR 2840853838[edi*1+ecx] 865 lea edi, DWORD PTR 2840853838[edx*1+edi]
872 sub esi, ebp 866 sub eax, ebp
873 rol ecx, 6 867 rol edi, 6
874 add ecx, ebx 868 add edi, esi
875 ; 69 869 ; 69
876 mov edi, DWORD PTR 52[esp] 870 mov edx, DWORD PTR 48[esp]
877 or esi, edx 871 or eax, ebx
878 add ebx, edi 872 add esi, edx
879 xor esi, ecx 873 xor eax, edi
880 mov edi, -1 874 mov edx, -1
881 rol edx, 10 875 rol ebx, 10
882 lea ebx, DWORD PTR 2840853838[esi*1+ebx] 876 lea esi, DWORD PTR 2840853838[eax*1+esi]
883 sub edi, edx 877 sub edx, ebx
884 rol ebx, 8 878 rol esi, 8
885 add ebx, eax 879 add esi, ecx
886 ; 70 880 ; 70
887 mov esi, DWORD PTR 12[esp] 881 mov eax, DWORD PTR 8[esp]
888 or edi, ecx 882 or edx, edi
889 add eax, esi 883 add ecx, eax
890 xor edi, ebx 884 xor edx, esi
891 mov esi, -1 885 mov eax, -1
892 rol ecx, 10 886 rol edi, 10
893 lea eax, DWORD PTR 2840853838[edi*1+eax] 887 lea ecx, DWORD PTR 2840853838[edx*1+ecx]
894 sub esi, ecx 888 sub eax, edi
895 rol eax, 13 889 rol ecx, 13
896 add eax, ebp 890 add ecx, ebp
897 ; 71 891 ; 71
898 mov edi, DWORD PTR 44[esp] 892 mov edx, DWORD PTR 40[esp]
899 or esi, ebx 893 or eax, esi
900 add ebp, edi
901 xor esi, eax
902 mov edi, -1
903 rol ebx, 10
904 lea ebp, DWORD PTR 2840853838[esi*1+ebp]
905 sub edi, ebx
906 rol ebp, 12
907 add ebp, edx 894 add ebp, edx
895 xor eax, ecx
896 mov edx, -1
897 rol esi, 10
898 lea ebp, DWORD PTR 2840853838[eax*1+ebp]
899 sub edx, esi
900 rol ebp, 12
901 add ebp, ebx
908 ; 72 902 ; 72
909 mov esi, DWORD PTR 60[esp] 903 mov eax, DWORD PTR 56[esp]
910 or edi, eax 904 or edx, ecx
911 add edx, esi 905 add ebx, eax
912 xor edi, ebp 906 xor edx, ebp
913 mov esi, -1 907 mov eax, -1
914 rol eax, 10 908 rol ecx, 10
915 lea edx, DWORD PTR 2840853838[edi*1+edx] 909 lea ebx, DWORD PTR 2840853838[edx*1+ebx]
916 sub esi, eax 910 sub eax, ecx
917 rol edx, 5 911 rol ebx, 5
918 add edx, ecx 912 add ebx, edi
919 ; 73 913 ; 73
920 mov edi, DWORD PTR 8[esp] 914 mov edx, DWORD PTR 4[esp]
921 or esi, ebp 915 or eax, ebp
922 add ecx, edi 916 add edi, edx
923 xor esi, edx 917 xor eax, ebx
924 mov edi, -1 918 mov edx, -1
925 rol ebp, 10 919 rol ebp, 10
926 lea ecx, DWORD PTR 2840853838[esi*1+ecx] 920 lea edi, DWORD PTR 2840853838[eax*1+edi]
927 sub edi, ebp 921 sub edx, ebp
928 rol ecx, 12 922 rol edi, 12
929 add ecx, ebx 923 add edi, esi
930 ; 74 924 ; 74
931 mov esi, DWORD PTR 16[esp] 925 mov eax, DWORD PTR 12[esp]
932 or edi, edx 926 or edx, ebx
933 add ebx, esi 927 add esi, eax
934 xor edi, ecx 928 xor edx, edi
935 mov esi, -1 929 mov eax, -1
936 rol edx, 10 930 rol ebx, 10
937 lea ebx, DWORD PTR 2840853838[edi*1+ebx] 931 lea esi, DWORD PTR 2840853838[edx*1+esi]
938 sub esi, edx 932 sub eax, ebx
939 rol ebx, 13 933 rol esi, 13
940 add ebx, eax 934 add esi, ecx
941 ; 75 935 ; 75
942 mov edi, DWORD PTR 36[esp] 936 mov edx, DWORD PTR 32[esp]
943 or esi, ecx 937 or eax, edi
944 add eax, edi 938 add ecx, edx
945 xor esi, ebx 939 xor eax, esi
946 mov edi, -1 940 mov edx, -1
947 rol ecx, 10 941 rol edi, 10
948 lea eax, DWORD PTR 2840853838[esi*1+eax] 942 lea ecx, DWORD PTR 2840853838[eax*1+ecx]
949 sub edi, ecx 943 sub edx, edi
950 rol eax, 14 944 rol ecx, 14
951 add eax, ebp 945 add ecx, ebp
952 ; 76 946 ; 76
953 mov esi, DWORD PTR 48[esp] 947 mov eax, DWORD PTR 44[esp]
954 or edi, ebx 948 or edx, esi
955 add ebp, esi 949 add ebp, eax
956 xor edi, eax 950 xor edx, ecx
957 mov esi, -1 951 mov eax, -1
958 rol ebx, 10 952 rol esi, 10
959 lea ebp, DWORD PTR 2840853838[edi*1+ebp] 953 lea ebp, DWORD PTR 2840853838[edx*1+ebp]
960 sub esi, ebx 954 sub eax, esi
961 rol ebp, 11 955 rol ebp, 11
962 add ebp, edx 956 add ebp, ebx
963 ; 77 957 ; 77
964 mov edi, DWORD PTR 28[esp] 958 mov edx, DWORD PTR 24[esp]
965 or esi, eax 959 or eax, ecx
966 add edx, edi 960 add ebx, edx
967 xor esi, ebp 961 xor eax, ebp
968 mov edi, -1 962 mov edx, -1
969 rol eax, 10 963 rol ecx, 10
970 lea edx, DWORD PTR 2840853838[esi*1+edx] 964 lea ebx, DWORD PTR 2840853838[eax*1+ebx]
971 sub edi, eax 965 sub edx, ecx
972 rol edx, 8 966 rol ebx, 8
973 add edx, ecx 967 add ebx, edi
974 ; 78 968 ; 78
975 mov esi, DWORD PTR 64[esp] 969 mov eax, DWORD PTR 60[esp]
976 or edi, ebp 970 or edx, ebp
977 add ecx, esi 971 add edi, eax
978 xor edi, edx 972 xor edx, ebx
979 mov esi, -1 973 mov eax, -1
980 rol ebp, 10 974 rol ebp, 10
981 lea ecx, DWORD PTR 2840853838[edi*1+ecx] 975 lea edi, DWORD PTR 2840853838[edx*1+edi]
982 sub esi, ebp 976 sub eax, ebp
983 rol ecx, 5 977 rol edi, 5
984 add ecx, ebx 978 add edi, esi
985 ; 79 979 ; 79
986 mov edi, DWORD PTR 56[esp] 980 mov edx, DWORD PTR 52[esp]
987 or esi, edx 981 or eax, ebx
988 add ebx, edi 982 add esi, edx
989 xor esi, ecx 983 xor eax, edi
990 mov edi, DWORD PTR 108[esp] 984 mov edx, DWORD PTR 128[esp]
991 rol edx, 10 985 rol ebx, 10
992 lea ebx, DWORD PTR 2840853838[esi*1+ebx] 986 lea esi, DWORD PTR 2840853838[eax*1+esi]
993 mov DWORD PTR 68[esp],eax 987 mov DWORD PTR 64[esp],ecx
994 rol ebx, 6 988 rol esi, 6
995 add ebx, eax 989 add esi, ecx
996 mov eax, DWORD PTR [edi] 990 mov ecx, DWORD PTR [edx]
997 mov DWORD PTR 72[esp],ebx 991 mov DWORD PTR 68[esp],esi
998 mov DWORD PTR 76[esp],ecx 992 mov DWORD PTR 72[esp],edi
999 mov ebx, DWORD PTR 4[edi] 993 mov esi, DWORD PTR 4[edx]
1000 mov DWORD PTR 80[esp],edx 994 mov DWORD PTR 76[esp],ebx
1001 mov ecx, DWORD PTR 8[edi] 995 mov edi, DWORD PTR 8[edx]
1002 mov DWORD PTR 84[esp],ebp 996 mov DWORD PTR 80[esp],ebp
1003 mov edx, DWORD PTR 12[edi] 997 mov ebx, DWORD PTR 12[edx]
1004 mov ebp, DWORD PTR 16[edi] 998 mov ebp, DWORD PTR 16[edx]
1005 ; 80 999 ; 80
1006 mov edi, -1 1000 mov edx, -1
1007 sub edi, edx 1001 sub edx, ebx
1008 mov esi, DWORD PTR 24[esp] 1002 mov eax, DWORD PTR 20[esp]
1009 or edi, ecx 1003 or edx, edi
1010 add eax, esi 1004 add ecx, eax
1011 xor edi, ebx 1005 xor edx, esi
1012 mov esi, -1 1006 mov eax, -1
1013 rol ecx, 10 1007 rol edi, 10
1014 lea eax, DWORD PTR 1352829926[edi*1+eax] 1008 lea ecx, DWORD PTR 1352829926[edx*1+ecx]
1015 sub esi, ecx 1009 sub eax, edi
1016 rol eax, 8 1010 rol ecx, 8
1017 add eax, ebp 1011 add ecx, ebp
1018 ; 81 1012 ; 81
1019 mov edi, DWORD PTR 60[esp] 1013 mov edx, DWORD PTR 56[esp]
1020 or esi, ebx 1014 or eax, esi
1021 add ebp, edi
1022 xor esi, eax
1023 mov edi, -1
1024 rol ebx, 10
1025 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1026 sub edi, ebx
1027 rol ebp, 9
1028 add ebp, edx 1015 add ebp, edx
1016 xor eax, ecx
1017 mov edx, -1
1018 rol esi, 10
1019 lea ebp, DWORD PTR 1352829926[eax*1+ebp]
1020 sub edx, esi
1021 rol ebp, 9
1022 add ebp, ebx
1029 ; 82 1023 ; 82
1030 mov esi, DWORD PTR 32[esp] 1024 mov eax, DWORD PTR 28[esp]
1031 or edi, eax 1025 or edx, ecx
1032 add edx, esi 1026 add ebx, eax
1033 xor edi, ebp 1027 xor edx, ebp
1034 mov esi, -1 1028 mov eax, -1
1035 rol eax, 10 1029 rol ecx, 10
1036 lea edx, DWORD PTR 1352829926[edi*1+edx] 1030 lea ebx, DWORD PTR 1352829926[edx*1+ebx]
1037 sub esi, eax 1031 sub eax, ecx
1038 rol edx, 9 1032 rol ebx, 9
1039 add edx, ecx 1033 add ebx, edi
1040 ; 83 1034 ; 83
1041 mov edi, DWORD PTR 4[esp] 1035 mov edx, DWORD PTR [esp]
1042 or esi, ebp 1036 or eax, ebp
1043 add ecx, edi 1037 add edi, edx
1044 xor esi, edx 1038 xor eax, ebx
1045 mov edi, -1 1039 mov edx, -1
1046 rol ebp, 10 1040 rol ebp, 10
1047 lea ecx, DWORD PTR 1352829926[esi*1+ecx] 1041 lea edi, DWORD PTR 1352829926[eax*1+edi]
1048 sub edi, ebp 1042 sub edx, ebp
1049 rol ecx, 11 1043 rol edi, 11
1050 add ecx, ebx 1044 add edi, esi
1051 ; 84 1045 ; 84
1052 mov esi, DWORD PTR 40[esp] 1046 mov eax, DWORD PTR 36[esp]
1053 or edi, edx 1047 or edx, ebx
1054 add ebx, esi 1048 add esi, eax
1055 xor edi, ecx 1049 xor edx, edi
1056 mov esi, -1 1050 mov eax, -1
1057 rol edx, 10 1051 rol ebx, 10
1058 lea ebx, DWORD PTR 1352829926[edi*1+ebx] 1052 lea esi, DWORD PTR 1352829926[edx*1+esi]
1059 sub esi, edx 1053 sub eax, ebx
1060 rol ebx, 13 1054 rol esi, 13
1061 add ebx, eax 1055 add esi, ecx
1062 ; 85 1056 ; 85
1063 mov edi, DWORD PTR 12[esp] 1057 mov edx, DWORD PTR 8[esp]
1064 or esi, ecx 1058 or eax, edi
1065 add eax, edi 1059 add ecx, edx
1066 xor esi, ebx 1060 xor eax, esi
1067 mov edi, -1 1061 mov edx, -1
1068 rol ecx, 10 1062 rol edi, 10
1069 lea eax, DWORD PTR 1352829926[esi*1+eax] 1063 lea ecx, DWORD PTR 1352829926[eax*1+ecx]
1070 sub edi, ecx 1064 sub edx, edi
1071 rol eax, 15 1065 rol ecx, 15
1072 add eax, ebp 1066 add ecx, ebp
1073 ; 86 1067 ; 86
1074 mov esi, DWORD PTR 48[esp] 1068 mov eax, DWORD PTR 44[esp]
1075 or edi, ebx 1069 or edx, esi
1076 add ebp, esi 1070 add ebp, eax
1077 xor edi, eax 1071 xor edx, ecx
1078 mov esi, -1 1072 mov eax, -1
1079 rol ebx, 10 1073 rol esi, 10
1080 lea ebp, DWORD PTR 1352829926[edi*1+ebp] 1074 lea ebp, DWORD PTR 1352829926[edx*1+ebp]
1081 sub esi, ebx 1075 sub eax, esi
1082 rol ebp, 15 1076 rol ebp, 15
1083 add ebp, edx 1077 add ebp, ebx
1084 ; 87 1078 ; 87
1085 mov edi, DWORD PTR 20[esp] 1079 mov edx, DWORD PTR 16[esp]
1086 or esi, eax 1080 or eax, ecx
1087 add edx, edi 1081 add ebx, edx
1088 xor esi, ebp 1082 xor eax, ebp
1089 mov edi, -1 1083 mov edx, -1
1090 rol eax, 10 1084 rol ecx, 10
1091 lea edx, DWORD PTR 1352829926[esi*1+edx] 1085 lea ebx, DWORD PTR 1352829926[eax*1+ebx]
1092 sub edi, eax 1086 sub edx, ecx
1093 rol edx, 5 1087 rol ebx, 5
1094 add edx, ecx 1088 add ebx, edi
1095 ; 88 1089 ; 88
1096 mov esi, DWORD PTR 56[esp] 1090 mov eax, DWORD PTR 52[esp]
1097 or edi, ebp 1091 or edx, ebp
1098 add ecx, esi 1092 add edi, eax
1099 xor edi, edx 1093 xor edx, ebx
1100 mov esi, -1 1094 mov eax, -1
1101 rol ebp, 10 1095 rol ebp, 10
1102 lea ecx, DWORD PTR 1352829926[edi*1+ecx] 1096 lea edi, DWORD PTR 1352829926[edx*1+edi]
1103 sub esi, ebp 1097 sub eax, ebp
1104 rol ecx, 7 1098 rol edi, 7
1105 add ecx, ebx 1099 add edi, esi
1106 ; 89 1100 ; 89
1107 mov edi, DWORD PTR 28[esp] 1101 mov edx, DWORD PTR 24[esp]
1108 or esi, edx 1102 or eax, ebx
1109 add ebx, edi 1103 add esi, edx
1110 xor esi, ecx 1104 xor eax, edi
1111 mov edi, -1 1105 mov edx, -1
1112 rol edx, 10 1106 rol ebx, 10
1113 lea ebx, DWORD PTR 1352829926[esi*1+ebx] 1107 lea esi, DWORD PTR 1352829926[eax*1+esi]
1114 sub edi, edx 1108 sub edx, ebx
1115 rol ebx, 7 1109 rol esi, 7
1116 add ebx, eax 1110 add esi, ecx
1117 ; 90 1111 ; 90
1118 mov esi, DWORD PTR 64[esp] 1112 mov eax, DWORD PTR 60[esp]
1119 or edi, ecx 1113 or edx, edi
1120 add eax, esi 1114 add ecx, eax
1121 xor edi, ebx 1115 xor edx, esi
1122 mov esi, -1 1116 mov eax, -1
1123 rol ecx, 10 1117 rol edi, 10
1124 lea eax, DWORD PTR 1352829926[edi*1+eax] 1118 lea ecx, DWORD PTR 1352829926[edx*1+ecx]
1125 sub esi, ecx 1119 sub eax, edi
1126 rol eax, 8 1120 rol ecx, 8
1127 add eax, ebp 1121 add ecx, ebp
1128 ; 91 1122 ; 91
1129 mov edi, DWORD PTR 36[esp] 1123 mov edx, DWORD PTR 32[esp]
1130 or esi, ebx 1124 or eax, esi
1131 add ebp, edi
1132 xor esi, eax
1133 mov edi, -1
1134 rol ebx, 10
1135 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1136 sub edi, ebx
1137 rol ebp, 11
1138 add ebp, edx 1125 add ebp, edx
1126 xor eax, ecx
1127 mov edx, -1
1128 rol esi, 10
1129 lea ebp, DWORD PTR 1352829926[eax*1+ebp]
1130 sub edx, esi
1131 rol ebp, 11
1132 add ebp, ebx
1139 ; 92 1133 ; 92
1140 mov esi, DWORD PTR 8[esp] 1134 mov eax, DWORD PTR 4[esp]
1141 or edi, eax 1135 or edx, ecx
1142 add edx, esi 1136 add ebx, eax
1143 xor edi, ebp 1137 xor edx, ebp
1144 mov esi, -1 1138 mov eax, -1
1145 rol eax, 10 1139 rol ecx, 10
1146 lea edx, DWORD PTR 1352829926[edi*1+edx] 1140 lea ebx, DWORD PTR 1352829926[edx*1+ebx]
1147 sub esi, eax 1141 sub eax, ecx
1148 rol edx, 14 1142 rol ebx, 14
1149 add edx, ecx 1143 add ebx, edi
1150 ; 93 1144 ; 93
1151 mov edi, DWORD PTR 44[esp] 1145 mov edx, DWORD PTR 40[esp]
1152 or esi, ebp 1146 or eax, ebp
1153 add ecx, edi 1147 add edi, edx
1154 xor esi, edx 1148 xor eax, ebx
1155 mov edi, -1 1149 mov edx, -1
1156 rol ebp, 10 1150 rol ebp, 10
1157 lea ecx, DWORD PTR 1352829926[esi*1+ecx] 1151 lea edi, DWORD PTR 1352829926[eax*1+edi]
1158 sub edi, ebp 1152 sub edx, ebp
1159 rol ecx, 14 1153 rol edi, 14
1160 add ecx, ebx 1154 add edi, esi
1161 ; 94 1155 ; 94
1162 mov esi, DWORD PTR 16[esp] 1156 mov eax, DWORD PTR 12[esp]
1163 or edi, edx 1157 or edx, ebx
1164 add ebx, esi 1158 add esi, eax
1165 xor edi, ecx 1159 xor edx, edi
1166 mov esi, -1 1160 mov eax, -1
1167 rol edx, 10 1161 rol ebx, 10
1168 lea ebx, DWORD PTR 1352829926[edi*1+ebx] 1162 lea esi, DWORD PTR 1352829926[edx*1+esi]
1169 sub esi, edx 1163 sub eax, ebx
1170 rol ebx, 12 1164 rol esi, 12
1171 add ebx, eax 1165 add esi, ecx
1172 ; 95 1166 ; 95
1173 mov edi, DWORD PTR 52[esp] 1167 mov edx, DWORD PTR 48[esp]
1174 or esi, ecx 1168 or eax, edi
1175 add eax, edi 1169 add ecx, edx
1176 xor esi, ebx 1170 xor eax, esi
1177 mov edi, -1 1171 mov edx, -1
1178 rol ecx, 10 1172 rol edi, 10
1179 lea eax, DWORD PTR 1352829926[esi*1+eax] 1173 lea ecx, DWORD PTR 1352829926[eax*1+ecx]
1180 mov esi, ecx 1174 mov eax, edi
1181 rol eax, 6 1175 rol ecx, 6
1182 add eax, ebp 1176 add ecx, ebp
1183 ; 96 1177 ; 96
1184 sub edi, ecx 1178 sub edx, edi
1185 and esi, eax 1179 and eax, ecx
1186 and edi, ebx 1180 and edx, esi
1187 or edi, esi 1181 or edx, eax
1188 mov esi, DWORD PTR 28[esp] 1182 mov eax, DWORD PTR 24[esp]
1189 rol ebx, 10 1183 rol esi, 10
1190 lea ebp, DWORD PTR 1548603684[edi+ebp] 1184 lea ebp, DWORD PTR 1548603684[edx+ebp]
1191 mov edi, -1 1185 mov edx, -1
1192 add ebp, esi 1186 add ebp, eax
1193 mov esi, ebx 1187 mov eax, esi
1194 rol ebp, 9 1188 rol ebp, 9
1195 add ebp, edx 1189 add ebp, ebx
1196 ; 97 1190 ; 97
1197 sub edi, ebx 1191 sub edx, esi
1198 and esi, ebp 1192 and eax, ebp
1199 and edi, eax 1193 and edx, ecx
1200 or edi, esi 1194 or edx, eax
1201 mov esi, DWORD PTR 48[esp] 1195 mov eax, DWORD PTR 44[esp]
1202 rol eax, 10 1196 rol ecx, 10
1203 lea edx, DWORD PTR 1548603684[edi+edx] 1197 lea ebx, DWORD PTR 1548603684[edx+ebx]
1204 mov edi, -1 1198 mov edx, -1
1205 add edx, esi 1199 add ebx, eax
1206 mov esi, eax 1200 mov eax, ecx
1207 rol edx, 13 1201 rol ebx, 13
1208 add edx, ecx 1202 add ebx, edi
1209 ; 98 1203 ; 98
1210 sub edi, eax 1204 sub edx, ecx
1211 and esi, edx 1205 and eax, ebx
1212 and edi, ebp 1206 and edx, ebp
1213 or edi, esi 1207 or edx, eax
1214 mov esi, DWORD PTR 16[esp] 1208 mov eax, DWORD PTR 12[esp]
1215 rol ebp, 10 1209 rol ebp, 10
1216 lea ecx, DWORD PTR 1548603684[edi+ecx] 1210 lea edi, DWORD PTR 1548603684[edx+edi]
1217 mov edi, -1 1211 mov edx, -1
1218 add ecx, esi 1212 add edi, eax
1219 mov esi, ebp 1213 mov eax, ebp
1220 rol ecx, 15 1214 rol edi, 15
1221 add ecx, ebx 1215 add edi, esi
1222 ; 99 1216 ; 99
1223 sub edi, ebp 1217 sub edx, ebp
1224 and esi, ecx 1218 and eax, edi
1225 and edi, edx 1219 and edx, ebx
1226 or edi, esi 1220 or edx, eax
1227 mov esi, DWORD PTR 32[esp] 1221 mov eax, DWORD PTR 28[esp]
1228 rol edx, 10 1222 rol ebx, 10
1229 lea ebx, DWORD PTR 1548603684[edi+ebx] 1223 lea esi, DWORD PTR 1548603684[edx+esi]
1230 mov edi, -1 1224 mov edx, -1
1231 add ebx, esi 1225 add esi, eax
1232 mov esi, edx 1226 mov eax, ebx
1233 rol ebx, 7 1227 rol esi, 7
1234 add ebx, eax 1228 add esi, ecx
1235 ; 100 1229 ; 100
1236 sub edi, edx 1230 sub edx, ebx
1237 and esi, ebx 1231 and eax, esi
1238 and edi, ecx 1232 and edx, edi
1239 or edi, esi 1233 or edx, eax
1240 mov esi, DWORD PTR 4[esp] 1234 mov eax, DWORD PTR [esp]
1241 rol ecx, 10 1235 rol edi, 10
1242 lea eax, DWORD PTR 1548603684[edi+eax] 1236 lea ecx, DWORD PTR 1548603684[edx+ecx]
1243 mov edi, -1 1237 mov edx, -1
1244 add eax, esi 1238 add ecx, eax
1245 mov esi, ecx 1239 mov eax, edi
1246 rol eax, 12 1240 rol ecx, 12
1247 add eax, ebp 1241 add ecx, ebp
1248 ; 101 1242 ; 101
1249 sub edi, ecx 1243 sub edx, edi
1250 and esi, eax 1244 and eax, ecx
1251 and edi, ebx 1245 and edx, esi
1252 or edi, esi 1246 or edx, eax
1253 mov esi, DWORD PTR 56[esp] 1247 mov eax, DWORD PTR 52[esp]
1254 rol ebx, 10 1248 rol esi, 10
1255 lea ebp, DWORD PTR 1548603684[edi+ebp] 1249 lea ebp, DWORD PTR 1548603684[edx+ebp]
1256 mov edi, -1 1250 mov edx, -1
1257 add ebp, esi 1251 add ebp, eax
1258 mov esi, ebx 1252 mov eax, esi
1259 rol ebp, 8 1253 rol ebp, 8
1260 add ebp, edx 1254 add ebp, ebx
1261 ; 102 1255 ; 102
1262 sub edi, ebx 1256 sub edx, esi
1263 and esi, ebp 1257 and eax, ebp
1264 and edi, eax 1258 and edx, ecx
1265 or edi, esi 1259 or edx, eax
1266 mov esi, DWORD PTR 24[esp] 1260 mov eax, DWORD PTR 20[esp]
1267 rol eax, 10 1261 rol ecx, 10
1268 lea edx, DWORD PTR 1548603684[edi+edx] 1262 lea ebx, DWORD PTR 1548603684[edx+ebx]
1269 mov edi, -1 1263 mov edx, -1
1270 add edx, esi 1264 add ebx, eax
1271 mov esi, eax 1265 mov eax, ecx
1272 rol edx, 9 1266 rol ebx, 9
1273 add edx, ecx 1267 add ebx, edi
1274 ; 103 1268 ; 103
1275 sub edi, eax 1269 sub edx, ecx
1276 and esi, edx 1270 and eax, ebx
1277 and edi, ebp 1271 and edx, ebp
1278 or edi, esi 1272 or edx, eax
1279 mov esi, DWORD PTR 44[esp] 1273 mov eax, DWORD PTR 40[esp]
1280 rol ebp, 10 1274 rol ebp, 10
1281 lea ecx, DWORD PTR 1548603684[edi+ecx] 1275 lea edi, DWORD PTR 1548603684[edx+edi]
1282 mov edi, -1 1276 mov edx, -1
1283 add ecx, esi 1277 add edi, eax
1284 mov esi, ebp 1278 mov eax, ebp
1285 rol ecx, 11 1279 rol edi, 11
1286 add ecx, ebx 1280 add edi, esi
1287 ; 104 1281 ; 104
1288 sub edi, ebp 1282 sub edx, ebp
1289 and esi, ecx 1283 and eax, edi
1290 and edi, edx 1284 and edx, ebx
1291 or edi, esi 1285 or edx, eax
1292 mov esi, DWORD PTR 60[esp] 1286 mov eax, DWORD PTR 56[esp]
1293 rol edx, 10 1287 rol ebx, 10
1294 lea ebx, DWORD PTR 1548603684[edi+ebx] 1288 lea esi, DWORD PTR 1548603684[edx+esi]
1295 mov edi, -1 1289 mov edx, -1
1296 add ebx, esi 1290 add esi, eax
1297 mov esi, edx 1291 mov eax, ebx
1298 rol ebx, 7 1292 rol esi, 7
1299 add ebx, eax 1293 add esi, ecx
1300 ; 105 1294 ; 105
1301 sub edi, edx 1295 sub edx, ebx
1302 and esi, ebx 1296 and eax, esi
1303 and edi, ecx 1297 and edx, edi
1304 or edi, esi 1298 or edx, eax
1305 mov esi, DWORD PTR 64[esp] 1299 mov eax, DWORD PTR 60[esp]
1306 rol ecx, 10 1300 rol edi, 10
1307 lea eax, DWORD PTR 1548603684[edi+eax] 1301 lea ecx, DWORD PTR 1548603684[edx+ecx]
1308 mov edi, -1 1302 mov edx, -1
1309 add eax, esi 1303 add ecx, eax
1310 mov esi, ecx 1304 mov eax, edi
1311 rol eax, 7 1305 rol ecx, 7
1312 add eax, ebp 1306 add ecx, ebp
1313 ; 106 1307 ; 106
1314 sub edi, ecx 1308 sub edx, edi
1315 and esi, eax 1309 and eax, ecx
1316 and edi, ebx 1310 and edx, esi
1317 or edi, esi 1311 or edx, eax
1318 mov esi, DWORD PTR 36[esp] 1312 mov eax, DWORD PTR 32[esp]
1319 rol ebx, 10 1313 rol esi, 10
1320 lea ebp, DWORD PTR 1548603684[edi+ebp] 1314 lea ebp, DWORD PTR 1548603684[edx+ebp]
1321 mov edi, -1 1315 mov edx, -1
1322 add ebp, esi 1316 add ebp, eax
1323 mov esi, ebx 1317 mov eax, esi
1324 rol ebp, 12 1318 rol ebp, 12
1325 add ebp, edx 1319 add ebp, ebx
1326 ; 107 1320 ; 107
1327 sub edi, ebx 1321 sub edx, esi
1328 and esi, ebp 1322 and eax, ebp
1329 and edi, eax 1323 and edx, ecx
1330 or edi, esi 1324 or edx, eax
1331 mov esi, DWORD PTR 52[esp] 1325 mov eax, DWORD PTR 48[esp]
1332 rol eax, 10 1326 rol ecx, 10
1333 lea edx, DWORD PTR 1548603684[edi+edx] 1327 lea ebx, DWORD PTR 1548603684[edx+ebx]
1334 mov edi, -1 1328 mov edx, -1
1335 add edx, esi 1329 add ebx, eax
1336 mov esi, eax 1330 mov eax, ecx
1337 rol edx, 7 1331 rol ebx, 7
1338 add edx, ecx 1332 add ebx, edi
1339 ; 108 1333 ; 108
1340 sub edi, eax 1334 sub edx, ecx
1341 and esi, edx 1335 and eax, ebx
1342 and edi, ebp 1336 and edx, ebp
1343 or edi, esi 1337 or edx, eax
1344 mov esi, DWORD PTR 20[esp] 1338 mov eax, DWORD PTR 16[esp]
1345 rol ebp, 10 1339 rol ebp, 10
1346 lea ecx, DWORD PTR 1548603684[edi+ecx] 1340 lea edi, DWORD PTR 1548603684[edx+edi]
1347 mov edi, -1 1341 mov edx, -1
1348 add ecx, esi 1342 add edi, eax
1349 mov esi, ebp 1343 mov eax, ebp
1350 rol ecx, 6 1344 rol edi, 6
1351 add ecx, ebx 1345 add edi, esi
1352 ; 109 1346 ; 109
1353 sub edi, ebp 1347 sub edx, ebp
1354 and esi, ecx 1348 and eax, edi
1355 and edi, edx 1349 and edx, ebx
1356 or edi, esi 1350 or edx, eax
1357 mov esi, DWORD PTR 40[esp] 1351 mov eax, DWORD PTR 36[esp]
1358 rol edx, 10 1352 rol ebx, 10
1359 lea ebx, DWORD PTR 1548603684[edi+ebx] 1353 lea esi, DWORD PTR 1548603684[edx+esi]
1360 mov edi, -1 1354 mov edx, -1
1361 add ebx, esi 1355 add esi, eax
1362 mov esi, edx 1356 mov eax, ebx
1363 rol ebx, 15 1357 rol esi, 15
1364 add ebx, eax 1358 add esi, ecx
1365 ; 110 1359 ; 110
1366 sub edi, edx 1360 sub edx, ebx
1367 and esi, ebx 1361 and eax, esi
1368 and edi, ecx 1362 and edx, edi
1369 or edi, esi 1363 or edx, eax
1370 mov esi, DWORD PTR 8[esp] 1364 mov eax, DWORD PTR 4[esp]
1371 rol ecx, 10 1365 rol edi, 10
1372 lea eax, DWORD PTR 1548603684[edi+eax] 1366 lea ecx, DWORD PTR 1548603684[edx+ecx]
1373 mov edi, -1 1367 mov edx, -1
1374 add eax, esi 1368 add ecx, eax
1375 mov esi, ecx 1369 mov eax, edi
1376 rol eax, 13 1370 rol ecx, 13
1377 add eax, ebp 1371 add ecx, ebp
1378 ; 111 1372 ; 111
1379 sub edi, ecx 1373 sub edx, edi
1380 and esi, eax 1374 and eax, ecx
1381 and edi, ebx 1375 and edx, esi
1382 or edi, esi 1376 or edx, eax
1383 mov esi, DWORD PTR 12[esp] 1377 mov eax, DWORD PTR 8[esp]
1384 rol ebx, 10 1378 rol esi, 10
1385 lea ebp, DWORD PTR 1548603684[edi+ebp] 1379 lea ebp, DWORD PTR 1548603684[edx+ebp]
1386 mov edi, -1 1380 mov edx, -1
1387 add ebp, esi 1381 add ebp, eax
1388 sub edi, eax 1382 sub edx, ecx
1389 rol ebp, 11 1383 rol ebp, 11
1390 add ebp, edx 1384 add ebp, ebx
1391 ; 112 1385 ; 112
1392 mov esi, DWORD PTR 64[esp] 1386 mov eax, DWORD PTR 60[esp]
1393 or edi, ebp 1387 or edx, ebp
1394 add edx, esi 1388 add ebx, eax
1395 xor edi, ebx 1389 xor edx, esi
1396 mov esi, -1 1390 mov eax, -1
1397 rol eax, 10 1391 rol ecx, 10
1398 lea edx, DWORD PTR 1836072691[edi*1+edx] 1392 lea ebx, DWORD PTR 1836072691[edx*1+ebx]
1399 sub esi, ebp 1393 sub eax, ebp
1400 rol edx, 9 1394 rol ebx, 9
1401 add edx, ecx 1395 add ebx, edi
1402 ; 113 1396 ; 113
1403 mov edi, DWORD PTR 24[esp] 1397 mov edx, DWORD PTR 20[esp]
1404 or esi, edx 1398 or eax, ebx
1405 add ecx, edi 1399 add edi, edx
1406 xor esi, eax 1400 xor eax, ecx
1407 mov edi, -1 1401 mov edx, -1
1408 rol ebp, 10 1402 rol ebp, 10
1409 lea ecx, DWORD PTR 1836072691[esi*1+ecx] 1403 lea edi, DWORD PTR 1836072691[eax*1+edi]
1410 sub edi, edx 1404 sub edx, ebx
1411 rol ecx, 7 1405 rol edi, 7
1412 add ecx, ebx 1406 add edi, esi
1413 ; 114 1407 ; 114
1414 mov esi, DWORD PTR 8[esp] 1408 mov eax, DWORD PTR 4[esp]
1415 or edi, ecx 1409 or edx, edi
1416 add ebx, esi 1410 add esi, eax
1417 xor edi, ebp 1411 xor edx, ebp
1418 mov esi, -1 1412 mov eax, -1
1419 rol edx, 10 1413 rol ebx, 10
1420 lea ebx, DWORD PTR 1836072691[edi*1+ebx] 1414 lea esi, DWORD PTR 1836072691[edx*1+esi]
1421 sub esi, ecx 1415 sub eax, edi
1422 rol ebx, 15 1416 rol esi, 15
1423 add ebx, eax 1417 add esi, ecx
1424 ; 115 1418 ; 115
1425 mov edi, DWORD PTR 16[esp] 1419 mov edx, DWORD PTR 12[esp]
1426 or esi, ebx 1420 or eax, esi
1427 add eax, edi 1421 add ecx, edx
1428 xor esi, edx 1422 xor eax, ebx
1429 mov edi, -1 1423 mov edx, -1
1430 rol ecx, 10 1424 rol edi, 10
1431 lea eax, DWORD PTR 1836072691[esi*1+eax] 1425 lea ecx, DWORD PTR 1836072691[eax*1+ecx]
1432 sub edi, ebx 1426 sub edx, esi
1433 rol eax, 11 1427 rol ecx, 11
1434 add eax, ebp 1428 add ecx, ebp
1435 ; 116 1429 ; 116
1436 mov esi, DWORD PTR 32[esp] 1430 mov eax, DWORD PTR 28[esp]
1437 or edi, eax 1431 or edx, ecx
1438 add ebp, esi 1432 add ebp, eax
1439 xor edi, ecx 1433 xor edx, edi
1440 mov esi, -1 1434 mov eax, -1
1441 rol ebx, 10 1435 rol esi, 10
1442 lea ebp, DWORD PTR 1836072691[edi*1+ebp] 1436 lea ebp, DWORD PTR 1836072691[edx*1+ebp]
1443 sub esi, eax 1437 sub eax, ecx
1444 rol ebp, 8 1438 rol ebp, 8
1445 add ebp, edx 1439 add ebp, ebx
1446 ; 117 1440 ; 117
1447 mov edi, DWORD PTR 60[esp] 1441 mov edx, DWORD PTR 56[esp]
1448 or esi, ebp 1442 or eax, ebp
1449 add edx, edi 1443 add ebx, edx
1450 xor esi, ebx 1444 xor eax, esi
1451 mov edi, -1 1445 mov edx, -1
1452 rol eax, 10 1446 rol ecx, 10
1453 lea edx, DWORD PTR 1836072691[esi*1+edx] 1447 lea ebx, DWORD PTR 1836072691[eax*1+ebx]
1454 sub edi, ebp 1448 sub edx, ebp
1455 rol edx, 6 1449 rol ebx, 6
1456 add edx, ecx 1450 add ebx, edi
1457 ; 118 1451 ; 118
1458 mov esi, DWORD PTR 28[esp] 1452 mov eax, DWORD PTR 24[esp]
1459 or edi, edx 1453 or edx, ebx
1460 add ecx, esi 1454 add edi, eax
1461 xor edi, eax 1455 xor edx, ecx
1462 mov esi, -1 1456 mov eax, -1
1463 rol ebp, 10 1457 rol ebp, 10
1464 lea ecx, DWORD PTR 1836072691[edi*1+ecx] 1458 lea edi, DWORD PTR 1836072691[edx*1+edi]
1465 sub esi, edx 1459 sub eax, ebx
1466 rol ecx, 6 1460 rol edi, 6
1467 add ecx, ebx 1461 add edi, esi
1468 ; 119 1462 ; 119
1469 mov edi, DWORD PTR 40[esp] 1463 mov edx, DWORD PTR 36[esp]
1470 or esi, ecx 1464 or eax, edi
1471 add ebx, edi 1465 add esi, edx
1472 xor esi, ebp 1466 xor eax, ebp
1473 mov edi, -1 1467 mov edx, -1
1474 rol edx, 10 1468 rol ebx, 10
1475 lea ebx, DWORD PTR 1836072691[esi*1+ebx] 1469 lea esi, DWORD PTR 1836072691[eax*1+esi]
1476 sub edi, ecx 1470 sub edx, edi
1477 rol ebx, 14 1471 rol esi, 14
1478 add ebx, eax 1472 add esi, ecx
1479 ; 120 1473 ; 120
1480 mov esi, DWORD PTR 48[esp] 1474 mov eax, DWORD PTR 44[esp]
1481 or edi, ebx 1475 or edx, esi
1482 add eax, esi 1476 add ecx, eax
1483 xor edi, edx 1477 xor edx, ebx
1484 mov esi, -1 1478 mov eax, -1
1485 rol ecx, 10 1479 rol edi, 10
1486 lea eax, DWORD PTR 1836072691[edi*1+eax] 1480 lea ecx, DWORD PTR 1836072691[edx*1+ecx]
1487 sub esi, ebx 1481 sub eax, esi
1488 rol eax, 12 1482 rol ecx, 12
1489 add eax, ebp 1483 add ecx, ebp
1490 ; 121 1484 ; 121
1491 mov edi, DWORD PTR 36[esp] 1485 mov edx, DWORD PTR 32[esp]
1492 or esi, eax 1486 or eax, ecx
1493 add ebp, edi
1494 xor esi, ecx
1495 mov edi, -1
1496 rol ebx, 10
1497 lea ebp, DWORD PTR 1836072691[esi*1+ebp]
1498 sub edi, eax
1499 rol ebp, 13
1500 add ebp, edx 1487 add ebp, edx
1488 xor eax, edi
1489 mov edx, -1
1490 rol esi, 10
1491 lea ebp, DWORD PTR 1836072691[eax*1+ebp]
1492 sub edx, ecx
1493 rol ebp, 13
1494 add ebp, ebx
1501 ; 122 1495 ; 122
1502 mov esi, DWORD PTR 52[esp] 1496 mov eax, DWORD PTR 48[esp]
1503 or edi, ebp 1497 or edx, ebp
1504 add edx, esi 1498 add ebx, eax
1505 xor edi, ebx 1499 xor edx, esi
1506 mov esi, -1 1500 mov eax, -1
1507 rol eax, 10 1501 rol ecx, 10
1508 lea edx, DWORD PTR 1836072691[edi*1+edx] 1502 lea ebx, DWORD PTR 1836072691[edx*1+ebx]
1509 sub esi, ebp 1503 sub eax, ebp
1510 rol edx, 5 1504 rol ebx, 5
1511 add edx, ecx 1505 add ebx, edi
1512 ; 123 1506 ; 123
1513 mov edi, DWORD PTR 12[esp] 1507 mov edx, DWORD PTR 8[esp]
1514 or esi, edx 1508 or eax, ebx
1515 add ecx, edi 1509 add edi, edx
1516 xor esi, eax 1510 xor eax, ecx
1517 mov edi, -1 1511 mov edx, -1
1518 rol ebp, 10 1512 rol ebp, 10
1519 lea ecx, DWORD PTR 1836072691[esi*1+ecx] 1513 lea edi, DWORD PTR 1836072691[eax*1+edi]
1520 sub edi, edx 1514 sub edx, ebx
1521 rol ecx, 14 1515 rol edi, 14
1522 add ecx, ebx 1516 add edi, esi
1523 ; 124 1517 ; 124
1524 mov esi, DWORD PTR 44[esp] 1518 mov eax, DWORD PTR 40[esp]
1525 or edi, ecx 1519 or edx, edi
1526 add ebx, esi 1520 add esi, eax
1527 xor edi, ebp 1521 xor edx, ebp
1528 mov esi, -1 1522 mov eax, -1
1529 rol edx, 10 1523 rol ebx, 10
1530 lea ebx, DWORD PTR 1836072691[edi*1+ebx] 1524 lea esi, DWORD PTR 1836072691[edx*1+esi]
1531 sub esi, ecx 1525 sub eax, edi
1532 rol ebx, 13 1526 rol esi, 13
1533 add ebx, eax 1527 add esi, ecx
1534 ; 125 1528 ; 125
1535 mov edi, DWORD PTR 4[esp] 1529 mov edx, DWORD PTR [esp]
1536 or esi, ebx 1530 or eax, esi
1537 add eax, edi 1531 add ecx, edx
1538 xor esi, edx 1532 xor eax, ebx
1539 mov edi, -1 1533 mov edx, -1
1540 rol ecx, 10 1534 rol edi, 10
1541 lea eax, DWORD PTR 1836072691[esi*1+eax] 1535 lea ecx, DWORD PTR 1836072691[eax*1+ecx]
1542 sub edi, ebx 1536 sub edx, esi
1543 rol eax, 13 1537 rol ecx, 13
1544 add eax, ebp 1538 add ecx, ebp
1545 ; 126 1539 ; 126
1546 mov esi, DWORD PTR 20[esp] 1540 mov eax, DWORD PTR 16[esp]
1547 or edi, eax 1541 or edx, ecx
1548 add ebp, esi 1542 add ebp, eax
1549 xor edi, ecx 1543 xor edx, edi
1550 mov esi, -1 1544 mov eax, -1
1551 rol ebx, 10 1545 rol esi, 10
1552 lea ebp, DWORD PTR 1836072691[edi*1+ebp] 1546 lea ebp, DWORD PTR 1836072691[edx*1+ebp]
1553 sub esi, eax 1547 sub eax, ecx
1554 rol ebp, 7 1548 rol ebp, 7
1555 add ebp, edx 1549 add ebp, ebx
1556 ; 127 1550 ; 127
1557 mov edi, DWORD PTR 56[esp] 1551 mov edx, DWORD PTR 52[esp]
1558 or esi, ebp 1552 or eax, ebp
1559 add edx, edi 1553 add ebx, edx
1560 xor esi, ebx 1554 xor eax, esi
1561 mov edi, DWORD PTR 36[esp] 1555 mov edx, DWORD PTR 32[esp]
1562 rol eax, 10 1556 rol ecx, 10
1563 lea edx, DWORD PTR 1836072691[esi*1+edx] 1557 lea ebx, DWORD PTR 1836072691[eax*1+ebx]
1564 mov esi, -1 1558 mov eax, -1
1565 rol edx, 5 1559 rol ebx, 5
1566 add edx, ecx 1560 add ebx, edi
1567 ; 128 1561 ; 128
1568 add ecx, edi 1562 add edi, edx
1569 mov edi, ebp 1563 mov edx, ebp
1570 sub esi, edx 1564 sub eax, ebx
1571 and edi, edx 1565 and edx, ebx
1572 and esi, eax 1566 and eax, ecx
1573 or edi, esi 1567 or edx, eax
1574 mov esi, DWORD PTR 28[esp] 1568 mov eax, DWORD PTR 24[esp]
1575 rol ebp, 10 1569 rol ebp, 10
1576 lea ecx, DWORD PTR 2053994217[edi*1+ecx] 1570 lea edi, DWORD PTR 2053994217[edx*1+edi]
1577 mov edi, -1 1571 mov edx, -1
1578 rol ecx, 15 1572 rol edi, 15
1579 add ecx, ebx 1573 add edi, esi
1580 ; 129 1574 ; 129
1581 add ebx, esi 1575 add esi, eax
1582 mov esi, edx 1576 mov eax, ebx
1583 sub edi, ecx 1577 sub edx, edi
1584 and esi, ecx 1578 and eax, edi
1585 and edi, ebp 1579 and edx, ebp
1586 or esi, edi 1580 or eax, edx
1587 mov edi, DWORD PTR 20[esp] 1581 mov edx, DWORD PTR 16[esp]
1588 rol edx, 10 1582 rol ebx, 10
1589 lea ebx, DWORD PTR 2053994217[esi*1+ebx] 1583 lea esi, DWORD PTR 2053994217[eax*1+esi]
1590 mov esi, -1 1584 mov eax, -1
1591 rol ebx, 5 1585 rol esi, 5
1592 add ebx, eax 1586 add esi, ecx
1593 ; 130 1587 ; 130
1594 add eax, edi 1588 add ecx, edx
1595 mov edi, ecx 1589 mov edx, edi
1596 sub esi, ebx 1590 sub eax, esi
1597 and edi, ebx 1591 and edx, esi
1598 and esi, edx 1592 and eax, ebx
1599 or edi, esi 1593 or edx, eax
1600 mov esi, DWORD PTR 8[esp] 1594 mov eax, DWORD PTR 4[esp]
1601 rol ecx, 10 1595 rol edi, 10
1602 lea eax, DWORD PTR 2053994217[edi*1+eax] 1596 lea ecx, DWORD PTR 2053994217[edx*1+ecx]
1603 mov edi, -1 1597 mov edx, -1
1604 rol eax, 8 1598 rol ecx, 8
1605 add eax, ebp 1599 add ecx, ebp
1606 ; 131 1600 ; 131
1607 add ebp, esi 1601 add ebp, eax
1608 mov esi, ebx 1602 mov eax, esi
1609 sub edi, eax 1603 sub edx, ecx
1610 and esi, eax 1604 and eax, ecx
1611 and edi, ecx 1605 and edx, edi
1612 or esi, edi 1606 or eax, edx
1613 mov edi, DWORD PTR 16[esp] 1607 mov edx, DWORD PTR 12[esp]
1614 rol ebx, 10 1608 rol esi, 10
1615 lea ebp, DWORD PTR 2053994217[esi*1+ebp] 1609 lea ebp, DWORD PTR 2053994217[eax*1+ebp]
1616 mov esi, -1 1610 mov eax, -1
1617 rol ebp, 11 1611 rol ebp, 11
1618 add ebp, edx 1612 add ebp, ebx
1619 ; 132 1613 ; 132
1620 add edx, edi 1614 add ebx, edx
1621 mov edi, eax 1615 mov edx, ecx
1622 sub esi, ebp 1616 sub eax, ebp
1623 and edi, ebp 1617 and edx, ebp
1624 and esi, ebx 1618 and eax, esi
1625 or edi, esi 1619 or edx, eax
1626 mov esi, DWORD PTR 48[esp] 1620 mov eax, DWORD PTR 44[esp]
1627 rol eax, 10 1621 rol ecx, 10
1628 lea edx, DWORD PTR 2053994217[edi*1+edx] 1622 lea ebx, DWORD PTR 2053994217[edx*1+ebx]
1629 mov edi, -1 1623 mov edx, -1
1630 rol edx, 14 1624 rol ebx, 14
1631 add edx, ecx 1625 add ebx, edi
1632 ; 133 1626 ; 133
1633 add ecx, esi 1627 add edi, eax
1634 mov esi, ebp 1628 mov eax, ebp
1635 sub edi, edx 1629 sub edx, ebx
1636 and esi, edx 1630 and eax, ebx
1637 and edi, eax 1631 and edx, ecx
1638 or esi, edi 1632 or eax, edx
1639 mov edi, DWORD PTR 64[esp] 1633 mov edx, DWORD PTR 60[esp]
1640 rol ebp, 10 1634 rol ebp, 10
1641 lea ecx, DWORD PTR 2053994217[esi*1+ecx] 1635 lea edi, DWORD PTR 2053994217[eax*1+edi]
1642 mov esi, -1 1636 mov eax, -1
1643 rol ecx, 14 1637 rol edi, 14
1644 add ecx, ebx 1638 add edi, esi
1645 ; 134 1639 ; 134
1646 add ebx, edi 1640 add esi, edx
1647 mov edi, edx 1641 mov edx, ebx
1648 sub esi, ecx 1642 sub eax, edi
1649 and edi, ecx 1643 and edx, edi
1650 and esi, ebp 1644 and eax, ebp
1651 or edi, esi 1645 or edx, eax
1652 mov esi, DWORD PTR 4[esp] 1646 mov eax, DWORD PTR [esp]
1653 rol edx, 10 1647 rol ebx, 10
1654 lea ebx, DWORD PTR 2053994217[edi*1+ebx] 1648 lea esi, DWORD PTR 2053994217[edx*1+esi]
1655 mov edi, -1 1649 mov edx, -1
1656 rol ebx, 6 1650 rol esi, 6
1657 add ebx, eax 1651 add esi, ecx
1658 ; 135 1652 ; 135
1659 add eax, esi 1653 add ecx, eax
1660 mov esi, ecx 1654 mov eax, edi
1661 sub edi, ebx 1655 sub edx, esi
1662 and esi, ebx 1656 and eax, esi
1663 and edi, edx 1657 and edx, ebx
1664 or esi, edi 1658 or eax, edx
1665 mov edi, DWORD PTR 24[esp] 1659 mov edx, DWORD PTR 20[esp]
1666 rol ecx, 10 1660 rol edi, 10
1667 lea eax, DWORD PTR 2053994217[esi*1+eax] 1661 lea ecx, DWORD PTR 2053994217[eax*1+ecx]
1668 mov esi, -1 1662 mov eax, -1
1669 rol eax, 14 1663 rol ecx, 14
1670 add eax, ebp 1664 add ecx, ebp
1671 ; 136 1665 ; 136
1672 add ebp, edi
1673 mov edi, ebx
1674 sub esi, eax
1675 and edi, eax
1676 and esi, ecx
1677 or edi, esi
1678 mov esi, DWORD PTR 52[esp]
1679 rol ebx, 10
1680 lea ebp, DWORD PTR 2053994217[edi*1+ebp]
1681 mov edi, -1
1682 rol ebp, 6
1683 add ebp, edx 1666 add ebp, edx
1667 mov edx, esi
1668 sub eax, ecx
1669 and edx, ecx
1670 and eax, edi
1671 or edx, eax
1672 mov eax, DWORD PTR 48[esp]
1673 rol esi, 10
1674 lea ebp, DWORD PTR 2053994217[edx*1+ebp]
1675 mov edx, -1
1676 rol ebp, 6
1677 add ebp, ebx
1684 ; 137 1678 ; 137
1685 add edx, esi 1679 add ebx, eax
1686 mov esi, eax 1680 mov eax, ecx
1687 sub edi, ebp 1681 sub edx, ebp
1688 and esi, ebp 1682 and eax, ebp
1689 and edi, ebx 1683 and edx, esi
1690 or esi, edi 1684 or eax, edx
1691 mov edi, DWORD PTR 12[esp] 1685 mov edx, DWORD PTR 8[esp]
1692 rol eax, 10 1686 rol ecx, 10
1693 lea edx, DWORD PTR 2053994217[esi*1+edx] 1687 lea ebx, DWORD PTR 2053994217[eax*1+ebx]
1694 mov esi, -1 1688 mov eax, -1
1695 rol edx, 9 1689 rol ebx, 9
1696 add edx, ecx 1690 add ebx, edi
1697 ; 138 1691 ; 138
1698 add ecx, edi 1692 add edi, edx
1699 mov edi, ebp 1693 mov edx, ebp
1700 sub esi, edx 1694 sub eax, ebx
1701 and edi, edx 1695 and edx, ebx
1702 and esi, eax 1696 and eax, ecx
1703 or edi, esi 1697 or edx, eax
1704 mov esi, DWORD PTR 56[esp] 1698 mov eax, DWORD PTR 52[esp]
1705 rol ebp, 10 1699 rol ebp, 10
1706 lea ecx, DWORD PTR 2053994217[edi*1+ecx] 1700 lea edi, DWORD PTR 2053994217[edx*1+edi]
1707 mov edi, -1 1701 mov edx, -1
1708 rol ecx, 12 1702 rol edi, 12
1709 add ecx, ebx 1703 add edi, esi
1710 ; 139 1704 ; 139
1711 add ebx, esi 1705 add esi, eax
1712 mov esi, edx 1706 mov eax, ebx
1713 sub edi, ecx 1707 sub edx, edi
1714 and esi, ecx 1708 and eax, edi
1715 and edi, ebp 1709 and edx, ebp
1716 or esi, edi 1710 or eax, edx
1717 mov edi, DWORD PTR 40[esp] 1711 mov edx, DWORD PTR 36[esp]
1718 rol edx, 10 1712 rol ebx, 10
1719 lea ebx, DWORD PTR 2053994217[esi*1+ebx] 1713 lea esi, DWORD PTR 2053994217[eax*1+esi]
1720 mov esi, -1 1714 mov eax, -1
1721 rol ebx, 9 1715 rol esi, 9
1722 add ebx, eax 1716 add esi, ecx
1723 ; 140 1717 ; 140
1724 add eax, edi 1718 add ecx, edx
1725 mov edi, ecx 1719 mov edx, edi
1726 sub esi, ebx 1720 sub eax, esi
1727 and edi, ebx 1721 and edx, esi
1728 and esi, edx 1722 and eax, ebx
1729 or edi, esi 1723 or edx, eax
1730 mov esi, DWORD PTR 32[esp] 1724 mov eax, DWORD PTR 28[esp]
1731 rol ecx, 10 1725 rol edi, 10
1732 lea eax, DWORD PTR 2053994217[edi*1+eax] 1726 lea ecx, DWORD PTR 2053994217[edx*1+ecx]
1733 mov edi, -1 1727 mov edx, -1
1734 rol eax, 12 1728 rol ecx, 12
1735 add eax, ebp 1729 add ecx, ebp
1736 ; 141 1730 ; 141
1737 add ebp, esi 1731 add ebp, eax
1738 mov esi, ebx 1732 mov eax, esi
1739 sub edi, eax 1733 sub edx, ecx
1740 and esi, eax 1734 and eax, ecx
1741 and edi, ecx 1735 and edx, edi
1742 or esi, edi 1736 or eax, edx
1743 mov edi, DWORD PTR 44[esp] 1737 mov edx, DWORD PTR 40[esp]
1744 rol ebx, 10 1738 rol esi, 10
1745 lea ebp, DWORD PTR 2053994217[esi*1+ebp] 1739 lea ebp, DWORD PTR 2053994217[eax*1+ebp]
1746 mov esi, -1 1740 mov eax, -1
1747 rol ebp, 5 1741 rol ebp, 5
1748 add ebp, edx 1742 add ebp, ebx
1749 ; 142 1743 ; 142
1750 add edx, edi 1744 add ebx, edx
1751 mov edi, eax 1745 mov edx, ecx
1752 sub esi, ebp 1746 sub eax, ebp
1753 and edi, ebp 1747 and edx, ebp
1754 and esi, ebx 1748 and eax, esi
1755 or edi, esi 1749 or edx, eax
1756 mov esi, DWORD PTR 60[esp] 1750 mov eax, DWORD PTR 56[esp]
1757 rol eax, 10 1751 rol ecx, 10
1758 lea edx, DWORD PTR 2053994217[edi*1+edx] 1752 lea ebx, DWORD PTR 2053994217[edx*1+ebx]
1759 mov edi, -1 1753 mov edx, -1
1760 rol edx, 15 1754 rol ebx, 15
1761 add edx, ecx 1755 add ebx, edi
1762 ; 143 1756 ; 143
1763 add ecx, esi 1757 add edi, eax
1764 mov esi, ebp 1758 mov eax, ebp
1765 sub edi, edx 1759 sub edx, ebx
1766 and esi, edx 1760 and eax, ebx
1767 and edi, eax 1761 and edx, ecx
1768 or edi, esi 1762 or edx, eax
1769 mov esi, edx 1763 mov eax, ebx
1770 rol ebp, 10 1764 rol ebp, 10
1771 lea ecx, DWORD PTR 2053994217[edi*1+ecx] 1765 lea edi, DWORD PTR 2053994217[edx*1+edi]
1772 xor esi, ebp 1766 xor eax, ebp
1773 rol ecx, 8 1767 rol edi, 8
1774 add ecx, ebx 1768 add edi, esi
1775 ; 144 1769 ; 144
1776 mov edi, DWORD PTR 52[esp] 1770 mov edx, DWORD PTR 48[esp]
1777 xor esi, ecx 1771 xor eax, edi
1778 add ebx, edi 1772 add esi, edx
1779 rol edx, 10 1773 rol ebx, 10
1780 add ebx, esi 1774 add esi, eax
1781 mov esi, ecx 1775 mov eax, edi
1782 rol ebx, 8 1776 rol esi, 8
1783 add ebx, eax 1777 add esi, ecx
1784 ; 145 1778 ; 145
1785 xor esi, edx 1779 xor eax, ebx
1786 mov edi, DWORD PTR 64[esp] 1780 mov edx, DWORD PTR 60[esp]
1787 xor esi, ebx 1781 xor eax, esi
1788 add eax, esi 1782 add ecx, eax
1789 mov esi, ebx 1783 mov eax, esi
1790 rol ecx, 10 1784 rol edi, 10
1791 add eax, edi 1785 add ecx, edx
1792 xor esi, ecx 1786 xor eax, edi
1793 rol eax, 5 1787 rol ecx, 5
1794 add eax, ebp 1788 add ecx, ebp
1795 ; 146 1789 ; 146
1796 mov edi, DWORD PTR 44[esp] 1790 mov edx, DWORD PTR 40[esp]
1797 xor esi, eax 1791 xor eax, ecx
1798 add ebp, edi
1799 rol ebx, 10
1800 add ebp, esi
1801 mov esi, eax
1802 rol ebp, 12
1803 add ebp, edx 1792 add ebp, edx
1793 rol esi, 10
1794 add ebp, eax
1795 mov eax, ecx
1796 rol ebp, 12
1797 add ebp, ebx
1804 ; 147 1798 ; 147
1805 xor esi, ebx 1799 xor eax, esi
1806 mov edi, DWORD PTR 20[esp] 1800 mov edx, DWORD PTR 16[esp]
1807 xor esi, ebp 1801 xor eax, ebp
1808 add edx, esi 1802 add ebx, eax
1809 mov esi, ebp 1803 mov eax, ebp
1810 rol eax, 10 1804 rol ecx, 10
1811 add edx, edi 1805 add ebx, edx
1812 xor esi, eax 1806 xor eax, ecx
1813 rol edx, 9 1807 rol ebx, 9
1814 add edx, ecx 1808 add ebx, edi
1815 ; 148 1809 ; 148
1816 mov edi, DWORD PTR 8[esp] 1810 mov edx, DWORD PTR 4[esp]
1817 xor esi, edx 1811 xor eax, ebx
1818 add ecx, edi 1812 add edi, edx
1819 rol ebp, 10 1813 rol ebp, 10
1820 add ecx, esi 1814 add edi, eax
1821 mov esi, edx 1815 mov eax, ebx
1822 rol ecx, 12 1816 rol edi, 12
1823 add ecx, ebx 1817 add edi, esi
1824 ; 149 1818 ; 149
1825 xor esi, ebp 1819 xor eax, ebp
1826 mov edi, DWORD PTR 24[esp] 1820 mov edx, DWORD PTR 20[esp]
1827 xor esi, ecx 1821 xor eax, edi
1828 add ebx, esi 1822 add esi, eax
1829 mov esi, ecx 1823 mov eax, edi
1830 rol edx, 10 1824 rol ebx, 10
1831 add ebx, edi 1825 add esi, edx
1832 xor esi, edx 1826 xor eax, ebx
1833 rol ebx, 5 1827 rol esi, 5
1834 add ebx, eax 1828 add esi, ecx
1835 ; 150 1829 ; 150
1836 mov edi, DWORD PTR 36[esp] 1830 mov edx, DWORD PTR 32[esp]
1837 xor esi, ebx 1831 xor eax, esi
1838 add eax, edi 1832 add ecx, edx
1839 rol ecx, 10 1833 rol edi, 10
1840 add eax, esi 1834 add ecx, eax
1841 mov esi, ebx 1835 mov eax, esi
1842 rol eax, 14 1836 rol ecx, 14
1843 add eax, ebp 1837 add ecx, ebp
1844 ; 151 1838 ; 151
1845 xor esi, ecx 1839 xor eax, edi
1846 mov edi, DWORD PTR 32[esp] 1840 mov edx, DWORD PTR 28[esp]
1847 xor esi, eax 1841 xor eax, ecx
1848 add ebp, esi 1842 add ebp, eax
1849 mov esi, eax 1843 mov eax, ecx
1850 rol ebx, 10 1844 rol esi, 10
1851 add ebp, edi
1852 xor esi, ebx
1853 rol ebp, 6
1854 add ebp, edx 1845 add ebp, edx
1846 xor eax, esi
1847 rol ebp, 6
1848 add ebp, ebx
1855 ; 152 1849 ; 152
1856 mov edi, DWORD PTR 28[esp] 1850 mov edx, DWORD PTR 24[esp]
1857 xor esi, ebp 1851 xor eax, ebp
1858 add edx, edi 1852 add ebx, edx
1859 rol eax, 10 1853 rol ecx, 10
1860 add edx, esi 1854 add ebx, eax
1861 mov esi, ebp 1855 mov eax, ebp
1862 rol edx, 8 1856 rol ebx, 8
1863 add edx, ecx 1857 add ebx, edi
1864 ; 153 1858 ; 153
1865 xor esi, eax 1859 xor eax, ecx
1866 mov edi, DWORD PTR 12[esp] 1860 mov edx, DWORD PTR 8[esp]
1867 xor esi, edx 1861 xor eax, ebx
1868 add ecx, esi 1862 add edi, eax
1869 mov esi, edx 1863 mov eax, ebx
1870 rol ebp, 10 1864 rol ebp, 10
1871 add ecx, edi 1865 add edi, edx
1872 xor esi, ebp 1866 xor eax, ebp
1873 rol ecx, 13 1867 rol edi, 13
1874 add ecx, ebx 1868 add edi, esi
1875 ; 154 1869 ; 154
1876 mov edi, DWORD PTR 56[esp] 1870 mov edx, DWORD PTR 52[esp]
1877 xor esi, ecx 1871 xor eax, edi
1878 add ebx, edi 1872 add esi, edx
1879 rol edx, 10 1873 rol ebx, 10
1880 add ebx, esi 1874 add esi, eax
1881 mov esi, ecx 1875 mov eax, edi
1882 rol ebx, 6 1876 rol esi, 6
1883 add ebx, eax 1877 add esi, ecx
1884 ; 155 1878 ; 155
1885 xor esi, edx 1879 xor eax, ebx
1886 mov edi, DWORD PTR 60[esp] 1880 mov edx, DWORD PTR 56[esp]
1887 xor esi, ebx 1881 xor eax, esi
1888 add eax, esi 1882 add ecx, eax
1889 mov esi, ebx 1883 mov eax, esi
1890 rol ecx, 10 1884 rol edi, 10
1891 add eax, edi 1885 add ecx, edx
1892 xor esi, ecx 1886 xor eax, edi
1893 rol eax, 5 1887 rol ecx, 5
1894 add eax, ebp 1888 add ecx, ebp
1895 ; 156 1889 ; 156
1896 mov edi, DWORD PTR 4[esp] 1890 mov edx, DWORD PTR [esp]
1897 xor esi, eax 1891 xor eax, ecx
1898 add ebp, edi
1899 rol ebx, 10
1900 add ebp, esi
1901 mov esi, eax
1902 rol ebp, 15
1903 add ebp, edx 1892 add ebp, edx
1893 rol esi, 10
1894 add ebp, eax
1895 mov eax, ecx
1896 rol ebp, 15
1897 add ebp, ebx
1904 ; 157 1898 ; 157
1905 xor esi, ebx 1899 xor eax, esi
1906 mov edi, DWORD PTR 16[esp] 1900 mov edx, DWORD PTR 12[esp]
1907 xor esi, ebp 1901 xor eax, ebp
1908 add edx, esi 1902 add ebx, eax
1909 mov esi, ebp 1903 mov eax, ebp
1910 rol eax, 10 1904 rol ecx, 10
1911 add edx, edi 1905 add ebx, edx
1912 xor esi, eax 1906 xor eax, ecx
1913 rol edx, 13 1907 rol ebx, 13
1914 add edx, ecx 1908 add ebx, edi
1915 ; 158 1909 ; 158
1916 mov edi, DWORD PTR 40[esp] 1910 mov edx, DWORD PTR 36[esp]
1917 xor esi, edx 1911 xor eax, ebx
1918 add ecx, edi 1912 add edi, edx
1919 rol ebp, 10 1913 rol ebp, 10
1920 add ecx, esi 1914 add edi, eax
1921 mov esi, edx 1915 mov eax, ebx
1922 rol ecx, 11 1916 rol edi, 11
1923 add ecx, ebx 1917 add edi, esi
1924 ; 159 1918 ; 159
1925 xor esi, ebp 1919 xor eax, ebp
1926 mov edi, DWORD PTR 48[esp] 1920 mov edx, DWORD PTR 44[esp]
1927 xor esi, ecx 1921 xor eax, edi
1928 add ebx, esi 1922 add esi, eax
1929 rol edx, 10 1923 rol ebx, 10
1930 add ebx, edi 1924 add esi, edx
1931 mov edi, DWORD PTR 108[esp] 1925 mov edx, DWORD PTR 128[esp]
1932 rol ebx, 11 1926 rol esi, 11
1927 add esi, ecx
1928 mov eax, DWORD PTR 4[edx]
1933 add ebx, eax 1929 add ebx, eax
1934 mov esi, DWORD PTR 4[edi] 1930 mov eax, DWORD PTR 72[esp]
1935 add edx, esi 1931 add ebx, eax
1936 mov esi, DWORD PTR 76[esp] 1932 mov eax, DWORD PTR 8[edx]
1937 add edx, esi 1933 add ebp, eax
1938 mov esi, DWORD PTR 8[edi] 1934 mov eax, DWORD PTR 76[esp]
1939 add ebp, esi 1935 add ebp, eax
1940 mov esi, DWORD PTR 80[esp] 1936 mov eax, DWORD PTR 12[edx]
1941 add ebp, esi 1937 add ecx, eax
1942 mov esi, DWORD PTR 12[edi] 1938 mov eax, DWORD PTR 80[esp]
1943 add eax, esi 1939 add ecx, eax
1944 mov esi, DWORD PTR 84[esp] 1940 mov eax, DWORD PTR 16[edx]
1945 add eax, esi 1941 add esi, eax
1946 mov esi, DWORD PTR 16[edi] 1942 mov eax, DWORD PTR 64[esp]
1947 add ebx, esi 1943 add esi, eax
1948 mov esi, DWORD PTR 68[esp] 1944 mov eax, DWORD PTR [edx]
1949 add ebx, esi 1945 add edi, eax
1950 mov esi, DWORD PTR [edi] 1946 mov eax, DWORD PTR 68[esp]
1951 add ecx, esi 1947 add edi, eax
1952 mov esi, DWORD PTR 72[esp] 1948 mov eax, DWORD PTR 136[esp]
1953 add ecx, esi 1949 mov DWORD PTR [edx],ebx
1954 mov DWORD PTR [edi],edx 1950 mov DWORD PTR 4[edx],ebp
1955 mov DWORD PTR 4[edi],ebp 1951 mov DWORD PTR 8[edx],ecx
1956 mov DWORD PTR 8[edi],eax 1952 sub eax, 1
1957 mov DWORD PTR 12[edi],ebx 1953 mov DWORD PTR 12[edx],esi
1958 mov DWORD PTR 16[edi],ecx 1954 mov DWORD PTR 16[edx],edi
1959 mov edi, DWORD PTR [esp] 1955 jle $L001get_out
1960 mov esi, DWORD PTR 112[esp] 1956 mov DWORD PTR 136[esp],eax
1961 cmp edi, esi 1957 mov edi, ecx
1962 mov edi, DWORD PTR 108[esp] 1958 mov eax, DWORD PTR 132[esp]
1963 jge L000start 1959 mov ecx, ebx
1964 add esp, 88 1960 add eax, 64
1961 mov esi, ebp
1962 mov DWORD PTR 132[esp],eax
1963 jmp L000start
1964$L001get_out:
1965 add esp, 108
1965 pop ebx 1966 pop ebx
1966 pop ebp 1967 pop ebp
1967 pop edi 1968 pop edi
1968 pop esi 1969 pop esi
1969 ret 1970 ret
1970_ripemd160_block_x86 ENDP 1971_ripemd160_block_asm_host_order ENDP
1971_TEXT ENDS 1972_TEXT ENDS
1972END 1973END
diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rmd-586.pl b/src/lib/libssl/src/crypto/ripemd/asm/rmd-586.pl
index e53c5fadba..0ab6f76bff 100644
--- a/src/lib/libssl/src/crypto/ripemd/asm/rmd-586.pl
+++ b/src/lib/libssl/src/crypto/ripemd/asm/rmd-586.pl
@@ -1,9 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3# Normal is the 3# Normal is the
4# ripemd160_block_x86(MD5_CTX *c, ULONG *X); 4# ripemd160_block_asm_host_order(RIPEMD160_CTX *c, ULONG *X,int blocks);
5# version, non-normal is the
6# ripemd160_block_x86(MD5_CTX *c, ULONG *X,int blocks);
7 5
8$normal=0; 6$normal=0;
9 7
@@ -12,13 +10,13 @@ require "x86asm.pl";
12 10
13&asm_init($ARGV[0],$0); 11&asm_init($ARGV[0],$0);
14 12
15$A="eax"; 13$A="ecx";
16$B="ebx"; 14$B="esi";
17$C="ecx"; 15$C="edi";
18$D="edx"; 16$D="ebx";
19$E="ebp"; 17$E="ebp";
20$tmp1="esi"; 18$tmp1="eax";
21$tmp2="edi"; 19$tmp2="edx";
22 20
23$KL1=0x5A827999; 21$KL1=0x5A827999;
24$KL2=0x6ED9EBA1; 22$KL2=0x6ED9EBA1;
@@ -58,13 +56,13 @@ $KR3=0x7A6D76E9;
58 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11, 56 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11,
59 ); 57 );
60 58
61&ripemd160_block("ripemd160_block_x86"); 59&ripemd160_block("ripemd160_block_asm_host_order");
62&asm_finish(); 60&asm_finish();
63 61
64sub Xv 62sub Xv
65 { 63 {
66 local($n)=@_; 64 local($n)=@_;
67 return(&swtmp($n+1)); 65 return(&swtmp($n));
68 # tmp on stack 66 # tmp on stack
69 } 67 }
70 68
@@ -82,7 +80,7 @@ sub RIP1
82 &comment($p++); 80 &comment($p++);
83 if ($p & 1) 81 if ($p & 1)
84 { 82 {
85 &mov($tmp1, $c) if $o == -1; 83 #&mov($tmp1, $c) if $o == -1;
86 &xor($tmp1, $d) if $o == -1; 84 &xor($tmp1, $d) if $o == -1;
87 &mov($tmp2, &Xv($pos)); 85 &mov($tmp2, &Xv($pos));
88 &xor($tmp1, $b); 86 &xor($tmp1, $b);
@@ -290,7 +288,7 @@ sub RIP5
290 &rotl($c, 10); 288 &rotl($c, 10);
291 &lea($a, &DWP($K,$a,$tmp1,1)); 289 &lea($a, &DWP($K,$a,$tmp1,1));
292 &sub($tmp2, &Np($d)) if $o <= 0; 290 &sub($tmp2, &Np($d)) if $o <= 0;
293 &mov(&swtmp(1+16), $A) if $o == 1; 291 &mov(&swtmp(16), $A) if $o == 1;
294 &mov($tmp1, &Np($d)) if $o == 2; 292 &mov($tmp1, &Np($d)) if $o == 2;
295 &rotl($a, $s); 293 &rotl($a, $s);
296 &add($a, $e); 294 &add($a, $e);
@@ -310,19 +308,25 @@ sub ripemd160_block
310 # D 12 308 # D 12
311 # E 16 309 # E 16
312 310
311 &mov($tmp2, &wparam(0));
312 &mov($tmp1, &wparam(1));
313 &push("esi"); 313 &push("esi");
314 &mov($C, &wparam(2)); 314 &mov($A, &DWP( 0,$tmp2,"",0));
315 &push("edi"); 315 &push("edi");
316 &mov($tmp1, &wparam(1)); # edi 316 &mov($B, &DWP( 4,$tmp2,"",0));
317 &push("ebp"); 317 &push("ebp");
318 &add($C, $tmp1); # offset we end at 318 &mov($C, &DWP( 8,$tmp2,"",0));
319 &push("ebx"); 319 &push("ebx");
320 &sub($C, 64); 320 &stack_push(16+5+6);
321 &stack_push(16+5+1); 321 # Special comment about the figure of 6.
322 # XXX 322 # Idea is to pad the current frame so
323 323 # that the top of the stack gets fairly
324 &mov(&swtmp(0), $C); 324 # aligned. Well, as you realize it would
325 &mov($tmp2, &wparam(0)); # Done at end of loop 325 # always depend on how the frame below is
326 # aligned. The good news are that gcc-2.95
327 # and later does keep first argument at
328 # least double-wise aligned.
329 # <appro@fy.chalmers.se>
326 330
327 &set_label("start") unless $normal; 331 &set_label("start") unless $normal;
328 &comment(""); 332 &comment("");
@@ -332,16 +336,12 @@ sub ripemd160_block
332 336
333 for ($z=0; $z<16; $z+=2) 337 for ($z=0; $z<16; $z+=2)
334 { 338 {
335 &mov($A, &DWP( $z*4,$tmp1,"",0)); 339 &mov($D, &DWP( $z*4,$tmp1,"",0));
336 &mov($B, &DWP( ($z+1)*4,$tmp1,"",0)); 340 &mov($E, &DWP( ($z+1)*4,$tmp1,"",0));
337 &mov(&swtmp(1+$z), $A); 341 &mov(&swtmp($z), $D);
338 &mov(&swtmp(1+$z+1), $B); 342 &mov(&swtmp($z+1), $E);
339 } 343 }
340 &add($tmp1, 64); 344 &mov($tmp1, $C);
341 &mov($A, &DWP( 0,$tmp2,"",0));
342 &mov(&wparam(1),$tmp1);
343 &mov($B, &DWP( 4,$tmp2,"",0));
344 &mov($C, &DWP( 8,$tmp2,"",0));
345 &mov($D, &DWP(12,$tmp2,"",0)); 345 &mov($D, &DWP(12,$tmp2,"",0));
346 &mov($E, &DWP(16,$tmp2,"",0)); 346 &mov($E, &DWP(16,$tmp2,"",0));
347 347
@@ -431,14 +431,14 @@ sub ripemd160_block
431 &RIP5($B,$C,$D,$E,$A,$wl[79],$sl[79],$KL4,1); 431 &RIP5($B,$C,$D,$E,$A,$wl[79],$sl[79],$KL4,1);
432 432
433 # &mov($tmp2, &wparam(0)); # moved into last RIP5 433 # &mov($tmp2, &wparam(0)); # moved into last RIP5
434 # &mov(&swtmp(1+16), $A); 434 # &mov(&swtmp(16), $A);
435 &mov($A, &DWP( 0,$tmp2,"",0)); 435 &mov($A, &DWP( 0,$tmp2,"",0));
436 &mov(&swtmp(1+17), $B); 436 &mov(&swtmp(16+1), $B);
437 &mov(&swtmp(1+18), $C); 437 &mov(&swtmp(16+2), $C);
438 &mov($B, &DWP( 4,$tmp2,"",0)); 438 &mov($B, &DWP( 4,$tmp2,"",0));
439 &mov(&swtmp(1+19), $D); 439 &mov(&swtmp(16+3), $D);
440 &mov($C, &DWP( 8,$tmp2,"",0)); 440 &mov($C, &DWP( 8,$tmp2,"",0));
441 &mov(&swtmp(1+20), $E); 441 &mov(&swtmp(16+4), $E);
442 &mov($D, &DWP(12,$tmp2,"",0)); 442 &mov($D, &DWP(12,$tmp2,"",0));
443 &mov($E, &DWP(16,$tmp2,"",0)); 443 &mov($E, &DWP(16,$tmp2,"",0));
444 444
@@ -531,46 +531,54 @@ sub ripemd160_block
531 531
532 &mov($tmp1, &DWP( 4,$tmp2,"",0)); # ctx->B 532 &mov($tmp1, &DWP( 4,$tmp2,"",0)); # ctx->B
533 &add($D, $tmp1); 533 &add($D, $tmp1);
534 &mov($tmp1, &swtmp(1+18)); # $c 534 &mov($tmp1, &swtmp(16+2)); # $c
535 &add($D, $tmp1); 535 &add($D, $tmp1);
536 536
537 &mov($tmp1, &DWP( 8,$tmp2,"",0)); # ctx->C 537 &mov($tmp1, &DWP( 8,$tmp2,"",0)); # ctx->C
538 &add($E, $tmp1); 538 &add($E, $tmp1);
539 &mov($tmp1, &swtmp(1+19)); # $d 539 &mov($tmp1, &swtmp(16+3)); # $d
540 &add($E, $tmp1); 540 &add($E, $tmp1);
541 541
542 &mov($tmp1, &DWP(12,$tmp2,"",0)); # ctx->D 542 &mov($tmp1, &DWP(12,$tmp2,"",0)); # ctx->D
543 &add($A, $tmp1); 543 &add($A, $tmp1);
544 &mov($tmp1, &swtmp(1+20)); # $e 544 &mov($tmp1, &swtmp(16+4)); # $e
545 &add($A, $tmp1); 545 &add($A, $tmp1);
546 546
547 547
548 &mov($tmp1, &DWP(16,$tmp2,"",0)); # ctx->E 548 &mov($tmp1, &DWP(16,$tmp2,"",0)); # ctx->E
549 &add($B, $tmp1); 549 &add($B, $tmp1);
550 &mov($tmp1, &swtmp(1+16)); # $a 550 &mov($tmp1, &swtmp(16+0)); # $a
551 &add($B, $tmp1); 551 &add($B, $tmp1);
552 552
553 &mov($tmp1, &DWP( 0,$tmp2,"",0)); # ctx->A 553 &mov($tmp1, &DWP( 0,$tmp2,"",0)); # ctx->A
554 &add($C, $tmp1); 554 &add($C, $tmp1);
555 &mov($tmp1, &swtmp(1+17)); # $b 555 &mov($tmp1, &swtmp(16+1)); # $b
556 &add($C, $tmp1); 556 &add($C, $tmp1);
557 557
558 &mov($tmp1, &wparam(2));
559
558 &mov(&DWP( 0,$tmp2,"",0), $D); 560 &mov(&DWP( 0,$tmp2,"",0), $D);
559 &mov(&DWP( 4,$tmp2,"",0), $E); 561 &mov(&DWP( 4,$tmp2,"",0), $E);
560 &mov(&DWP( 8,$tmp2,"",0), $A); 562 &mov(&DWP( 8,$tmp2,"",0), $A);
561 &mov(&DWP(12,$tmp2,"",0), $B); 563 &sub($tmp1,1);
562 &mov(&DWP(16,$tmp2,"",0), $C); 564 &mov(&DWP(12,$tmp2,"",0), $B);
565 &mov(&DWP(16,$tmp2,"",0), $C);
563 566
564 &mov($tmp2, &swtmp(0)); 567 &jle(&label("get_out"));
565 &mov($tmp1, &wparam(1)); 568
569 &mov(&wparam(2),$tmp1);
570 &mov($C, $A);
571 &mov($tmp1, &wparam(1));
572 &mov($A, $D);
573 &add($tmp1, 64);
574 &mov($B, $E);
575 &mov(&wparam(1),$tmp1);
566 576
567 &cmp($tmp2,$tmp1); 577 &jmp(&label("start"));
568 &mov($tmp2, &wparam(0));
569 578
570 # XXX 579 &set_label("get_out");
571 &jge(&label("start"));
572 580
573 &stack_pop(16+5+1); 581 &stack_pop(16+5+6);
574 582
575 &pop("ebx"); 583 &pop("ebx");
576 &pop("ebp"); 584 &pop("ebp");
diff --git a/src/lib/libssl/src/crypto/ripemd/ripemd.h b/src/lib/libssl/src/crypto/ripemd/ripemd.h
index ab76be4c33..dd1627cf40 100644
--- a/src/lib/libssl/src/crypto/ripemd/ripemd.h
+++ b/src/lib/libssl/src/crypto/ripemd/ripemd.h
@@ -67,26 +67,33 @@ extern "C" {
67#error RIPEMD is disabled. 67#error RIPEMD is disabled.
68#endif 68#endif
69 69
70#if defined(WIN16) || defined(__LP32__)
71#define RIPEMD160_LONG unsigned long
72#elif defined(_CRAY) || defined(__ILP64__)
73#define RIPEMD160_LONG unsigned long
74#define RIPEMD160_LONG_LOG2 3
75#else
76#define RIPEMD160_LONG unsigned int
77#endif
78
70#define RIPEMD160_CBLOCK 64 79#define RIPEMD160_CBLOCK 64
71#define RIPEMD160_LBLOCK 16 80#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4)
72#define RIPEMD160_BLOCK 16
73#define RIPEMD160_LAST_BLOCK 56
74#define RIPEMD160_LENGTH_BLOCK 8
75#define RIPEMD160_DIGEST_LENGTH 20 81#define RIPEMD160_DIGEST_LENGTH 20
76 82
77typedef struct RIPEMD160state_st 83typedef struct RIPEMD160state_st
78 { 84 {
79 unsigned long A,B,C,D,E; 85 RIPEMD160_LONG A,B,C,D,E;
80 unsigned long Nl,Nh; 86 RIPEMD160_LONG Nl,Nh;
81 unsigned long data[RIPEMD160_LBLOCK]; 87 RIPEMD160_LONG data[RIPEMD160_LBLOCK];
82 int num; 88 int num;
83 } RIPEMD160_CTX; 89 } RIPEMD160_CTX;
84 90
85void RIPEMD160_Init(RIPEMD160_CTX *c); 91void RIPEMD160_Init(RIPEMD160_CTX *c);
86void RIPEMD160_Update(RIPEMD160_CTX *c, unsigned char *data, unsigned long len); 92void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len);
87void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 93void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
88unsigned char *RIPEMD160(unsigned char *d, unsigned long n, unsigned char *md); 94unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
89void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b); 95 unsigned char *md);
96void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
90#ifdef __cplusplus 97#ifdef __cplusplus
91} 98}
92#endif 99#endif
diff --git a/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c b/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
index b590856229..bdfae270b6 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
+++ b/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
@@ -60,7 +60,7 @@
60#include "rmd_locl.h" 60#include "rmd_locl.h"
61#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
62 62
63char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; 63const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
64 64
65# ifdef RMD160_ASM 65# ifdef RMD160_ASM
66 void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num); 66 void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num);
@@ -68,6 +68,7 @@ char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
68# else 68# else
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
71void RIPEMD160_Init(RIPEMD160_CTX *c) 72void RIPEMD160_Init(RIPEMD160_CTX *c)
72 { 73 {
73 c->A=RIPEMD160_A; 74 c->A=RIPEMD160_A;
@@ -80,180 +81,21 @@ void RIPEMD160_Init(RIPEMD160_CTX *c)
80 c->num=0; 81 c->num=0;
81 } 82 }
82 83
83void RIPEMD160_Update(RIPEMD160_CTX *c, register unsigned char *data, 84#ifndef ripemd160_block_host_order
84 unsigned long len) 85#ifdef X
85 { 86#undef X
86 register ULONG *p;
87 int sw,sc;
88 ULONG l;
89
90 if (len == 0) return;
91
92 l=(c->Nl+(len<<3))&0xffffffffL;
93 if (l < c->Nl) /* overflow */
94 c->Nh++;
95 c->Nh+=(len>>29);
96 c->Nl=l;
97
98 if (c->num != 0)
99 {
100 p=c->data;
101 sw=c->num>>2;
102 sc=c->num&0x03;
103
104 if ((c->num+len) >= RIPEMD160_CBLOCK)
105 {
106 l= p[sw];
107 p_c2l(data,l,sc);
108 p[sw++]=l;
109 for (; sw<RIPEMD160_LBLOCK; sw++)
110 {
111 c2l(data,l);
112 p[sw]=l;
113 }
114 len-=(RIPEMD160_CBLOCK-c->num);
115
116 ripemd160_block(c,p,64);
117 c->num=0;
118 /* drop through and do the rest */
119 }
120 else
121 {
122 int ew,ec;
123
124 c->num+=(int)len;
125 if ((sc+len) < 4) /* ugly, add char's to a word */
126 {
127 l= p[sw];
128 p_c2l_p(data,l,sc,len);
129 p[sw]=l;
130 }
131 else
132 {
133 ew=(c->num>>2);
134 ec=(c->num&0x03);
135 l= p[sw];
136 p_c2l(data,l,sc);
137 p[sw++]=l;
138 for (; sw < ew; sw++)
139 { c2l(data,l); p[sw]=l; }
140 if (ec)
141 {
142 c2l_p(data,l,ec);
143 p[sw]=l;
144 }
145 }
146 return;
147 }
148 }
149 /* we now can process the input data in blocks of RIPEMD160_CBLOCK
150 * chars and save the leftovers to c->data. */
151#ifdef L_ENDIAN
152 if ((((unsigned long)data)%sizeof(ULONG)) == 0)
153 {
154 sw=(int)len/RIPEMD160_CBLOCK;
155 if (sw > 0)
156 {
157 sw*=RIPEMD160_CBLOCK;
158 ripemd160_block(c,(ULONG *)data,sw);
159 data+=sw;
160 len-=sw;
161 }
162 }
163#endif
164 p=c->data;
165 while (len >= RIPEMD160_CBLOCK)
166 {
167#if defined(L_ENDIAN) || defined(B_ENDIAN)
168 if (p != (unsigned long *)data)
169 memcpy(p,data,RIPEMD160_CBLOCK);
170 data+=RIPEMD160_CBLOCK;
171#ifdef B_ENDIAN
172 for (sw=(RIPEMD160_LBLOCK/4); sw; sw--)
173 {
174 Endian_Reverse32(p[0]);
175 Endian_Reverse32(p[1]);
176 Endian_Reverse32(p[2]);
177 Endian_Reverse32(p[3]);
178 p+=4;
179 }
180#endif
181#else
182 for (sw=(RIPEMD160_LBLOCK/4); sw; sw--)
183 {
184 c2l(data,l); *(p++)=l;
185 c2l(data,l); *(p++)=l;
186 c2l(data,l); *(p++)=l;
187 c2l(data,l); *(p++)=l;
188 }
189#endif 87#endif
190 p=c->data; 88#define X(i) XX[i]
191 ripemd160_block(c,p,64); 89void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
192 len-=RIPEMD160_CBLOCK;
193 }
194 sc=(int)len;
195 c->num=sc;
196 if (sc)
197 {
198 sw=sc>>2; /* words to copy */
199#ifdef L_ENDIAN
200 p[sw]=0;
201 memcpy(p,data,sc);
202#else
203 sc&=0x03;
204 for ( ; sw; sw--)
205 { c2l(data,l); *(p++)=l; }
206 c2l_p(data,l,sc);
207 *p=l;
208#endif
209 }
210 }
211
212void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b)
213 { 90 {
214 ULONG p[16]; 91 const RIPEMD160_LONG *XX=p;
215#if !defined(L_ENDIAN) 92 register unsigned long A,B,C,D,E;
216 ULONG *q; 93 register unsigned long a,b,c,d,e;
217 int i;
218#endif
219 94
220#if defined(B_ENDIAN) || defined(L_ENDIAN) 95 for (;num--;XX+=HASH_LBLOCK)
221 memcpy(p,b,64);
222#ifdef B_ENDIAN
223 q=p;
224 for (i=(RIPEMD160_LBLOCK/4); i; i--)
225 {
226 Endian_Reverse32(q[0]);
227 Endian_Reverse32(q[1]);
228 Endian_Reverse32(q[2]);
229 Endian_Reverse32(q[3]);
230 q+=4;
231 }
232#endif
233#else
234 q=p;
235 for (i=(RIPEMD160_LBLOCK/4); i; i--)
236 { 96 {
237 ULONG l;
238 c2l(b,l); *(q++)=l;
239 c2l(b,l); *(q++)=l;
240 c2l(b,l); *(q++)=l;
241 c2l(b,l); *(q++)=l;
242 }
243#endif
244 ripemd160_block(c,p,64);
245 }
246
247#ifndef RMD160_ASM
248
249void ripemd160_block(RIPEMD160_CTX *ctx, register ULONG *X, int num)
250 {
251 register ULONG A,B,C,D,E;
252 ULONG a,b,c,d,e;
253 97
254 for (;;) 98 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
255 {
256 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
257 99
258 RIP1(A,B,C,D,E,WL00,SL00); 100 RIP1(A,B,C,D,E,WL00,SL00);
259 RIP1(E,A,B,C,D,WL01,SL01); 101 RIP1(E,A,B,C,D,WL01,SL01);
@@ -436,80 +278,216 @@ void ripemd160_block(RIPEMD160_CTX *ctx, register ULONG *X, int num)
436 ctx->E=ctx->A+b+C; 278 ctx->E=ctx->A+b+C;
437 ctx->A=D; 279 ctx->A=D;
438 280
439 X+=16;
440 num-=64;
441 if (num <= 0) break;
442 } 281 }
443 } 282 }
444#endif 283#endif
445 284
446void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c) 285#ifndef ripemd160_block_data_order
286#ifdef X
287#undef X
288#endif
289void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num)
447 { 290 {
448 register int i,j; 291 const unsigned char *data=p;
449 register ULONG l; 292 register unsigned long A,B,C,D,E;
450 register ULONG *p; 293 unsigned long a,b,c,d,e,l;
451 static unsigned char end[4]={0x80,0x00,0x00,0x00}; 294#ifndef MD32_XARRAY
452 unsigned char *cp=end; 295 /* See comment in crypto/sha/sha_locl.h for details. */
453 296 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
454 /* c->num should definitly have room for at least one more byte. */ 297 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
455 p=c->data; 298# define X(i) XX##i
456 j=c->num; 299#else
457 i=j>>2; 300 RIPEMD160_LONG XX[16];
458 301# define X(i) XX[i]
459 /* purify often complains about the following line as an
460 * Uninitialized Memory Read. While this can be true, the
461 * following p_c2l macro will reset l when that case is true.
462 * This is because j&0x03 contains the number of 'valid' bytes
463 * already in p[i]. If and only if j&0x03 == 0, the UMR will
464 * occur but this is also the only time p_c2l will do
465 * l= *(cp++) instead of l|= *(cp++)
466 * Many thanks to Alex Tang <altitude@cic.net> for pickup this
467 * 'potential bug' */
468#ifdef PURIFY
469 if ((j&0x03) == 0) p[i]=0;
470#endif 302#endif
471 l=p[i]; 303
472 p_c2l(cp,l,j&0x03); 304 for (;num--;)
473 p[i]=l;
474 i++;
475 /* i is the next 'undefined word' */
476 if (c->num >= RIPEMD160_LAST_BLOCK)
477 { 305 {
478 for (; i<RIPEMD160_LBLOCK; i++)
479 p[i]=0;
480 ripemd160_block(c,p,64);
481 i=0;
482 }
483 for (; i<(RIPEMD160_LBLOCK-2); i++)
484 p[i]=0;
485 p[RIPEMD160_LBLOCK-2]=c->Nl;
486 p[RIPEMD160_LBLOCK-1]=c->Nh;
487 ripemd160_block(c,p,64);
488 cp=md;
489 l=c->A; l2c(l,cp);
490 l=c->B; l2c(l,cp);
491 l=c->C; l2c(l,cp);
492 l=c->D; l2c(l,cp);
493 l=c->E; l2c(l,cp);
494
495 /* clear stuff, ripemd160_block may be leaving some stuff on the stack
496 * but I'm not worried :-) */
497 c->num=0;
498/* memset((char *)&c,0,sizeof(c));*/
499 }
500 306
501#ifdef undef 307 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
502int printit(unsigned long *l) 308
503 { 309 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
504 int i,ii; 310 RIP1(A,B,C,D,E,WL00,SL00); HOST_c2l(data,l); X( 2)=l;
311 RIP1(E,A,B,C,D,WL01,SL01); HOST_c2l(data,l); X( 3)=l;
312 RIP1(D,E,A,B,C,WL02,SL02); HOST_c2l(data,l); X( 4)=l;
313 RIP1(C,D,E,A,B,WL03,SL03); HOST_c2l(data,l); X( 5)=l;
314 RIP1(B,C,D,E,A,WL04,SL04); HOST_c2l(data,l); X( 6)=l;
315 RIP1(A,B,C,D,E,WL05,SL05); HOST_c2l(data,l); X( 7)=l;
316 RIP1(E,A,B,C,D,WL06,SL06); HOST_c2l(data,l); X( 8)=l;
317 RIP1(D,E,A,B,C,WL07,SL07); HOST_c2l(data,l); X( 9)=l;
318 RIP1(C,D,E,A,B,WL08,SL08); HOST_c2l(data,l); X(10)=l;
319 RIP1(B,C,D,E,A,WL09,SL09); HOST_c2l(data,l); X(11)=l;
320 RIP1(A,B,C,D,E,WL10,SL10); HOST_c2l(data,l); X(12)=l;
321 RIP1(E,A,B,C,D,WL11,SL11); HOST_c2l(data,l); X(13)=l;
322 RIP1(D,E,A,B,C,WL12,SL12); HOST_c2l(data,l); X(14)=l;
323 RIP1(C,D,E,A,B,WL13,SL13); HOST_c2l(data,l); X(15)=l;
324 RIP1(B,C,D,E,A,WL14,SL14);
325 RIP1(A,B,C,D,E,WL15,SL15);
326
327 RIP2(E,A,B,C,D,WL16,SL16,KL1);
328 RIP2(D,E,A,B,C,WL17,SL17,KL1);
329 RIP2(C,D,E,A,B,WL18,SL18,KL1);
330 RIP2(B,C,D,E,A,WL19,SL19,KL1);
331 RIP2(A,B,C,D,E,WL20,SL20,KL1);
332 RIP2(E,A,B,C,D,WL21,SL21,KL1);
333 RIP2(D,E,A,B,C,WL22,SL22,KL1);
334 RIP2(C,D,E,A,B,WL23,SL23,KL1);
335 RIP2(B,C,D,E,A,WL24,SL24,KL1);
336 RIP2(A,B,C,D,E,WL25,SL25,KL1);
337 RIP2(E,A,B,C,D,WL26,SL26,KL1);
338 RIP2(D,E,A,B,C,WL27,SL27,KL1);
339 RIP2(C,D,E,A,B,WL28,SL28,KL1);
340 RIP2(B,C,D,E,A,WL29,SL29,KL1);
341 RIP2(A,B,C,D,E,WL30,SL30,KL1);
342 RIP2(E,A,B,C,D,WL31,SL31,KL1);
343
344 RIP3(D,E,A,B,C,WL32,SL32,KL2);
345 RIP3(C,D,E,A,B,WL33,SL33,KL2);
346 RIP3(B,C,D,E,A,WL34,SL34,KL2);
347 RIP3(A,B,C,D,E,WL35,SL35,KL2);
348 RIP3(E,A,B,C,D,WL36,SL36,KL2);
349 RIP3(D,E,A,B,C,WL37,SL37,KL2);
350 RIP3(C,D,E,A,B,WL38,SL38,KL2);
351 RIP3(B,C,D,E,A,WL39,SL39,KL2);
352 RIP3(A,B,C,D,E,WL40,SL40,KL2);
353 RIP3(E,A,B,C,D,WL41,SL41,KL2);
354 RIP3(D,E,A,B,C,WL42,SL42,KL2);
355 RIP3(C,D,E,A,B,WL43,SL43,KL2);
356 RIP3(B,C,D,E,A,WL44,SL44,KL2);
357 RIP3(A,B,C,D,E,WL45,SL45,KL2);
358 RIP3(E,A,B,C,D,WL46,SL46,KL2);
359 RIP3(D,E,A,B,C,WL47,SL47,KL2);
360
361 RIP4(C,D,E,A,B,WL48,SL48,KL3);
362 RIP4(B,C,D,E,A,WL49,SL49,KL3);
363 RIP4(A,B,C,D,E,WL50,SL50,KL3);
364 RIP4(E,A,B,C,D,WL51,SL51,KL3);
365 RIP4(D,E,A,B,C,WL52,SL52,KL3);
366 RIP4(C,D,E,A,B,WL53,SL53,KL3);
367 RIP4(B,C,D,E,A,WL54,SL54,KL3);
368 RIP4(A,B,C,D,E,WL55,SL55,KL3);
369 RIP4(E,A,B,C,D,WL56,SL56,KL3);
370 RIP4(D,E,A,B,C,WL57,SL57,KL3);
371 RIP4(C,D,E,A,B,WL58,SL58,KL3);
372 RIP4(B,C,D,E,A,WL59,SL59,KL3);
373 RIP4(A,B,C,D,E,WL60,SL60,KL3);
374 RIP4(E,A,B,C,D,WL61,SL61,KL3);
375 RIP4(D,E,A,B,C,WL62,SL62,KL3);
376 RIP4(C,D,E,A,B,WL63,SL63,KL3);
377
378 RIP5(B,C,D,E,A,WL64,SL64,KL4);
379 RIP5(A,B,C,D,E,WL65,SL65,KL4);
380 RIP5(E,A,B,C,D,WL66,SL66,KL4);
381 RIP5(D,E,A,B,C,WL67,SL67,KL4);
382 RIP5(C,D,E,A,B,WL68,SL68,KL4);
383 RIP5(B,C,D,E,A,WL69,SL69,KL4);
384 RIP5(A,B,C,D,E,WL70,SL70,KL4);
385 RIP5(E,A,B,C,D,WL71,SL71,KL4);
386 RIP5(D,E,A,B,C,WL72,SL72,KL4);
387 RIP5(C,D,E,A,B,WL73,SL73,KL4);
388 RIP5(B,C,D,E,A,WL74,SL74,KL4);
389 RIP5(A,B,C,D,E,WL75,SL75,KL4);
390 RIP5(E,A,B,C,D,WL76,SL76,KL4);
391 RIP5(D,E,A,B,C,WL77,SL77,KL4);
392 RIP5(C,D,E,A,B,WL78,SL78,KL4);
393 RIP5(B,C,D,E,A,WL79,SL79,KL4);
394
395 a=A; b=B; c=C; d=D; e=E;
396 /* Do other half */
397 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
398
399 RIP5(A,B,C,D,E,WR00,SR00,KR0);
400 RIP5(E,A,B,C,D,WR01,SR01,KR0);
401 RIP5(D,E,A,B,C,WR02,SR02,KR0);
402 RIP5(C,D,E,A,B,WR03,SR03,KR0);
403 RIP5(B,C,D,E,A,WR04,SR04,KR0);
404 RIP5(A,B,C,D,E,WR05,SR05,KR0);
405 RIP5(E,A,B,C,D,WR06,SR06,KR0);
406 RIP5(D,E,A,B,C,WR07,SR07,KR0);
407 RIP5(C,D,E,A,B,WR08,SR08,KR0);
408 RIP5(B,C,D,E,A,WR09,SR09,KR0);
409 RIP5(A,B,C,D,E,WR10,SR10,KR0);
410 RIP5(E,A,B,C,D,WR11,SR11,KR0);
411 RIP5(D,E,A,B,C,WR12,SR12,KR0);
412 RIP5(C,D,E,A,B,WR13,SR13,KR0);
413 RIP5(B,C,D,E,A,WR14,SR14,KR0);
414 RIP5(A,B,C,D,E,WR15,SR15,KR0);
415
416 RIP4(E,A,B,C,D,WR16,SR16,KR1);
417 RIP4(D,E,A,B,C,WR17,SR17,KR1);
418 RIP4(C,D,E,A,B,WR18,SR18,KR1);
419 RIP4(B,C,D,E,A,WR19,SR19,KR1);
420 RIP4(A,B,C,D,E,WR20,SR20,KR1);
421 RIP4(E,A,B,C,D,WR21,SR21,KR1);
422 RIP4(D,E,A,B,C,WR22,SR22,KR1);
423 RIP4(C,D,E,A,B,WR23,SR23,KR1);
424 RIP4(B,C,D,E,A,WR24,SR24,KR1);
425 RIP4(A,B,C,D,E,WR25,SR25,KR1);
426 RIP4(E,A,B,C,D,WR26,SR26,KR1);
427 RIP4(D,E,A,B,C,WR27,SR27,KR1);
428 RIP4(C,D,E,A,B,WR28,SR28,KR1);
429 RIP4(B,C,D,E,A,WR29,SR29,KR1);
430 RIP4(A,B,C,D,E,WR30,SR30,KR1);
431 RIP4(E,A,B,C,D,WR31,SR31,KR1);
432
433 RIP3(D,E,A,B,C,WR32,SR32,KR2);
434 RIP3(C,D,E,A,B,WR33,SR33,KR2);
435 RIP3(B,C,D,E,A,WR34,SR34,KR2);
436 RIP3(A,B,C,D,E,WR35,SR35,KR2);
437 RIP3(E,A,B,C,D,WR36,SR36,KR2);
438 RIP3(D,E,A,B,C,WR37,SR37,KR2);
439 RIP3(C,D,E,A,B,WR38,SR38,KR2);
440 RIP3(B,C,D,E,A,WR39,SR39,KR2);
441 RIP3(A,B,C,D,E,WR40,SR40,KR2);
442 RIP3(E,A,B,C,D,WR41,SR41,KR2);
443 RIP3(D,E,A,B,C,WR42,SR42,KR2);
444 RIP3(C,D,E,A,B,WR43,SR43,KR2);
445 RIP3(B,C,D,E,A,WR44,SR44,KR2);
446 RIP3(A,B,C,D,E,WR45,SR45,KR2);
447 RIP3(E,A,B,C,D,WR46,SR46,KR2);
448 RIP3(D,E,A,B,C,WR47,SR47,KR2);
449
450 RIP2(C,D,E,A,B,WR48,SR48,KR3);
451 RIP2(B,C,D,E,A,WR49,SR49,KR3);
452 RIP2(A,B,C,D,E,WR50,SR50,KR3);
453 RIP2(E,A,B,C,D,WR51,SR51,KR3);
454 RIP2(D,E,A,B,C,WR52,SR52,KR3);
455 RIP2(C,D,E,A,B,WR53,SR53,KR3);
456 RIP2(B,C,D,E,A,WR54,SR54,KR3);
457 RIP2(A,B,C,D,E,WR55,SR55,KR3);
458 RIP2(E,A,B,C,D,WR56,SR56,KR3);
459 RIP2(D,E,A,B,C,WR57,SR57,KR3);
460 RIP2(C,D,E,A,B,WR58,SR58,KR3);
461 RIP2(B,C,D,E,A,WR59,SR59,KR3);
462 RIP2(A,B,C,D,E,WR60,SR60,KR3);
463 RIP2(E,A,B,C,D,WR61,SR61,KR3);
464 RIP2(D,E,A,B,C,WR62,SR62,KR3);
465 RIP2(C,D,E,A,B,WR63,SR63,KR3);
466
467 RIP1(B,C,D,E,A,WR64,SR64);
468 RIP1(A,B,C,D,E,WR65,SR65);
469 RIP1(E,A,B,C,D,WR66,SR66);
470 RIP1(D,E,A,B,C,WR67,SR67);
471 RIP1(C,D,E,A,B,WR68,SR68);
472 RIP1(B,C,D,E,A,WR69,SR69);
473 RIP1(A,B,C,D,E,WR70,SR70);
474 RIP1(E,A,B,C,D,WR71,SR71);
475 RIP1(D,E,A,B,C,WR72,SR72);
476 RIP1(C,D,E,A,B,WR73,SR73);
477 RIP1(B,C,D,E,A,WR74,SR74);
478 RIP1(A,B,C,D,E,WR75,SR75);
479 RIP1(E,A,B,C,D,WR76,SR76);
480 RIP1(D,E,A,B,C,WR77,SR77);
481 RIP1(C,D,E,A,B,WR78,SR78);
482 RIP1(B,C,D,E,A,WR79,SR79);
483
484 D =ctx->B+c+D;
485 ctx->B=ctx->C+d+E;
486 ctx->C=ctx->D+e+A;
487 ctx->D=ctx->E+a+B;
488 ctx->E=ctx->A+b+C;
489 ctx->A=D;
505 490
506 for (i=0; i<2; i++)
507 {
508 for (ii=0; ii<8; ii++)
509 {
510 fprintf(stderr,"%08lx ",l[i*8+ii]);
511 }
512 fprintf(stderr,"\n");
513 } 491 }
514 } 492 }
515#endif 493#endif
diff --git a/src/lib/libssl/src/crypto/ripemd/rmd_locl.h b/src/lib/libssl/src/crypto/ripemd/rmd_locl.h
index d6ba02001a..145cf316b9 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_locl.h
+++ b/src/lib/libssl/src/crypto/ripemd/rmd_locl.h
@@ -58,134 +58,76 @@
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/opensslconf.h>
61#include <openssl/ripemd.h> 62#include <openssl/ripemd.h>
62 63
63#define ULONG unsigned long 64#ifndef RIPEMD160_LONG_LOG2
64#define UCHAR unsigned char 65#define RIPEMD160_LONG_LOG2 2 /* default to 32 bits */
65#define UINT unsigned int 66#endif
66 67
67#undef c2nl 68/*
68#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ 69 * DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c
69 l|=(((unsigned long)(*((c)++)))<<16), \ 70 * FOR EXPLANATIONS ON FOLLOWING "CODE."
70 l|=(((unsigned long)(*((c)++)))<< 8), \ 71 * <appro@fy.chalmers.se>
71 l|=(((unsigned long)(*((c)++))) )) 72 */
72 73#ifdef RMD160_ASM
73#undef p_c2nl 74# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
74#define p_c2nl(c,l,n) { \ 75# define ripemd160_block_host_order ripemd160_block_asm_host_order
75 switch (n) { \ 76# endif
76 case 0: l =((unsigned long)(*((c)++)))<<24; \ 77#endif
77 case 1: l|=((unsigned long)(*((c)++)))<<16; \ 78
78 case 2: l|=((unsigned long)(*((c)++)))<< 8; \ 79void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
79 case 3: l|=((unsigned long)(*((c)++))); \ 80void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);
80 } \ 81
81 } 82#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
82 83#define ripemd160_block_data_order ripemd160_block_host_order
83#undef c2nl_p 84#endif
84/* NOTE the pointer is not incremented at the end of this */ 85
85#define c2nl_p(c,l,n) { \ 86#define DATA_ORDER_IS_LITTLE_ENDIAN
86 l=0; \ 87
87 (c)+=n; \ 88#define HASH_LONG RIPEMD160_LONG
88 switch (n) { \ 89#define HASH_LONG_LOG2 RIPEMD160_LONG_LOG2
89 case 3: l =((unsigned long)(*(--(c))))<< 8; \ 90#define HASH_CTX RIPEMD160_CTX
90 case 2: l|=((unsigned long)(*(--(c))))<<16; \ 91#define HASH_CBLOCK RIPEMD160_CBLOCK
91 case 1: l|=((unsigned long)(*(--(c))))<<24; \ 92#define HASH_LBLOCK RIPEMD160_LBLOCK
92 } \ 93#define HASH_UPDATE RIPEMD160_Update
93 } 94#define HASH_TRANSFORM RIPEMD160_Transform
94 95#define HASH_FINAL RIPEMD160_Final
95#undef p_c2nl_p 96#define HASH_BLOCK_HOST_ORDER ripemd160_block_host_order
96#define p_c2nl_p(c,l,sc,len) { \ 97#define HASH_MAKE_STRING(c,s) do { \
97 switch (sc) \ 98 unsigned long ll; \
98 { \ 99 ll=(c)->A; HOST_l2c(ll,(s)); \
99 case 0: l =((unsigned long)(*((c)++)))<<24; \ 100 ll=(c)->B; HOST_l2c(ll,(s)); \
100 if (--len == 0) break; \ 101 ll=(c)->C; HOST_l2c(ll,(s)); \
101 case 1: l|=((unsigned long)(*((c)++)))<<16; \ 102 ll=(c)->D; HOST_l2c(ll,(s)); \
102 if (--len == 0) break; \ 103 ll=(c)->E; HOST_l2c(ll,(s)); \
103 case 2: l|=((unsigned long)(*((c)++)))<< 8; \ 104 } while (0)
104 } \ 105#if !defined(L_ENDIAN) || defined(ripemd160_block_data_order)
105 } 106#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
106
107#undef nl2c
108#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
109 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
110 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
111 *((c)++)=(unsigned char)(((l) )&0xff))
112
113#undef c2l
114#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
115 l|=(((unsigned long)(*((c)++)))<< 8), \
116 l|=(((unsigned long)(*((c)++)))<<16), \
117 l|=(((unsigned long)(*((c)++)))<<24))
118
119#undef p_c2l
120#define p_c2l(c,l,n) { \
121 switch (n) { \
122 case 0: l =((unsigned long)(*((c)++))); \
123 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
124 case 2: l|=((unsigned long)(*((c)++)))<<16; \
125 case 3: l|=((unsigned long)(*((c)++)))<<24; \
126 } \
127 }
128
129#undef c2l_p
130/* NOTE the pointer is not incremented at the end of this */
131#define c2l_p(c,l,n) { \
132 l=0; \
133 (c)+=n; \
134 switch (n) { \
135 case 3: l =((unsigned long)(*(--(c))))<<16; \
136 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
137 case 1: l|=((unsigned long)(*(--(c)))); \
138 } \
139 }
140
141#undef p_c2l_p
142#define p_c2l_p(c,l,sc,len) { \
143 switch (sc) \
144 { \
145 case 0: l =((unsigned long)(*((c)++))); \
146 if (--len == 0) break; \
147 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
148 if (--len == 0) break; \
149 case 2: l|=((unsigned long)(*((c)++)))<<16; \
150 } \
151 }
152
153#undef l2c
154#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
155 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
156 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
157 *((c)++)=(unsigned char)(((l)>>24)&0xff))
158
159#undef ROTATE
160#if defined(WIN32)
161#define ROTATE(a,n) _lrotl(a,n)
162#else
163#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
164#endif 107#endif
165 108
166/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */ 109#ifndef FLAT_INC
167#if defined(WIN32) 110#include "../md32_common.h"
168/* 5 instructions with rotate instruction, else 9 */
169#define Endian_Reverse32(a) \
170 { \
171 unsigned long l=(a); \
172 (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
173 }
174#else 111#else
175/* 6 instructions with rotate instruction, else 8 */ 112#include "md32_common.h"
176#define Endian_Reverse32(a) \
177 { \
178 unsigned long l=(a); \
179 l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
180 (a)=ROTATE(l,16L); \
181 }
182#endif 113#endif
183 114
115#if 0
184#define F1(x,y,z) ((x)^(y)^(z)) 116#define F1(x,y,z) ((x)^(y)^(z))
185#define F2(x,y,z) (((x)&(y))|((~x)&z)) 117#define F2(x,y,z) (((x)&(y))|((~x)&z))
186#define F3(x,y,z) (((x)|(~y))^(z)) 118#define F3(x,y,z) (((x)|(~y))^(z))
187#define F4(x,y,z) (((x)&(z))|((y)&(~(z)))) 119#define F4(x,y,z) (((x)&(z))|((y)&(~(z))))
188#define F5(x,y,z) ((x)^((y)|(~(z)))) 120#define F5(x,y,z) ((x)^((y)|(~(z))))
121#else
122/*
123 * Transformed F2 and F4 are courtesy of Wei Dai <weidai@eskimo.com>
124 */
125#define F1(x,y,z) ((x) ^ (y) ^ (z))
126#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
127#define F3(x,y,z) (((~(y)) | (x)) ^ (z))
128#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
129#define F5(x,y,z) (((~(z)) | (y)) ^ (x))
130#endif
189 131
190#define RIPEMD160_A 0x67452301L 132#define RIPEMD160_A 0x67452301L
191#define RIPEMD160_B 0xEFCDAB89L 133#define RIPEMD160_B 0xEFCDAB89L
@@ -196,27 +138,27 @@
196#include "rmdconst.h" 138#include "rmdconst.h"
197 139
198#define RIP1(a,b,c,d,e,w,s) { \ 140#define RIP1(a,b,c,d,e,w,s) { \
199 a+=F1(b,c,d)+X[w]; \ 141 a+=F1(b,c,d)+X(w); \
200 a=ROTATE(a,s)+e; \ 142 a=ROTATE(a,s)+e; \
201 c=ROTATE(c,10); } 143 c=ROTATE(c,10); }
202 144
203#define RIP2(a,b,c,d,e,w,s,K) { \ 145#define RIP2(a,b,c,d,e,w,s,K) { \
204 a+=F2(b,c,d)+X[w]+K; \ 146 a+=F2(b,c,d)+X(w)+K; \
205 a=ROTATE(a,s)+e; \ 147 a=ROTATE(a,s)+e; \
206 c=ROTATE(c,10); } 148 c=ROTATE(c,10); }
207 149
208#define RIP3(a,b,c,d,e,w,s,K) { \ 150#define RIP3(a,b,c,d,e,w,s,K) { \
209 a+=F3(b,c,d)+X[w]+K; \ 151 a+=F3(b,c,d)+X(w)+K; \
210 a=ROTATE(a,s)+e; \ 152 a=ROTATE(a,s)+e; \
211 c=ROTATE(c,10); } 153 c=ROTATE(c,10); }
212 154
213#define RIP4(a,b,c,d,e,w,s,K) { \ 155#define RIP4(a,b,c,d,e,w,s,K) { \
214 a+=F4(b,c,d)+X[w]+K; \ 156 a+=F4(b,c,d)+X(w)+K; \
215 a=ROTATE(a,s)+e; \ 157 a=ROTATE(a,s)+e; \
216 c=ROTATE(c,10); } 158 c=ROTATE(c,10); }
217 159
218#define RIP5(a,b,c,d,e,w,s,K) { \ 160#define RIP5(a,b,c,d,e,w,s,K) { \
219 a+=F5(b,c,d)+X[w]+K; \ 161 a+=F5(b,c,d)+X(w)+K; \
220 a=ROTATE(a,s)+e; \ 162 a=ROTATE(a,s)+e; \
221 c=ROTATE(c,10); } 163 c=ROTATE(c,10); }
222 164
diff --git a/src/lib/libssl/src/crypto/ripemd/rmd_one.c b/src/lib/libssl/src/crypto/ripemd/rmd_one.c
index 5b6ff14714..efdf2dd6ef 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_one.c
+++ b/src/lib/libssl/src/crypto/ripemd/rmd_one.c
@@ -57,9 +57,10 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "rmd_locl.h" 60#include <string.h>
61#include <openssl/ripemd.h>
61 62
62unsigned char *RIPEMD160(unsigned char *d, unsigned long n, 63unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
63 unsigned char *md) 64 unsigned char *md)
64 { 65 {
65 RIPEMD160_CTX c; 66 RIPEMD160_CTX c;
diff --git a/src/lib/libssl/src/crypto/ripemd/rmdtest.c b/src/lib/libssl/src/crypto/ripemd/rmdtest.c
index 5e93d4627c..5d79c99725 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmdtest.c
+++ b/src/lib/libssl/src/crypto/ripemd/rmdtest.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
73#include <openssl/ebcdic.h> 73#include <openssl/ebcdic.h>
74#endif 74#endif
75 75
76char *test[]={ 76static char *test[]={
77 "", 77 "",
78 "a", 78 "a",
79 "abc", 79 "abc",
@@ -85,7 +85,7 @@ char *test[]={
85 NULL, 85 NULL,
86 }; 86 };
87 87
88char *ret[]={ 88static char *ret[]={
89 "9c1185a5c5e9fc54612808977ee8f548b2258d31", 89 "9c1185a5c5e9fc54612808977ee8f548b2258d31",
90 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", 90 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
91 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", 91 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
diff --git a/src/lib/libssl/src/crypto/rsa/Makefile.ssl b/src/lib/libssl/src/crypto/rsa/Makefile.ssl
index 3bb89701a2..7b3960e70d 100644
--- a/src/lib/libssl/src/crypto/rsa/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/rsa/Makefile.ssl
@@ -18,14 +18,14 @@ AR= ar r
18CFLAGS= $(INCLUDES) $(CFLAG) 18CFLAGS= $(INCLUDES) $(CFLAG)
19 19
20GENERAL=Makefile 20GENERAL=Makefile
21TEST=rsa_oaep_test.c 21TEST=rsa_test.c
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ 25LIBSRC= 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 26 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c
27LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \ 27LIBOBJ= 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 28 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o
29 29
30SRC= $(LIBSRC) 30SRC= $(LIBSRC)
31 31
@@ -83,52 +83,61 @@ clean:
83rsa_chk.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 83rsa_chk.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
84rsa_chk.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 84rsa_chk.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
85rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 85rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
86rsa_chk.o: ../../include/openssl/stack.h 86rsa_chk.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 87rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
88rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 88rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
89rsa_eay.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 89rsa_eay.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
90rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 90rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
91rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 91rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
92rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 92rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
93rsa_eay.o: ../cryptlib.h 93rsa_eay.o: ../../include/openssl/stack.h ../cryptlib.h
94rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 94rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
95rsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 95rsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
96rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 96rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
97rsa_err.o: ../../include/openssl/stack.h 97rsa_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
98rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 98rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
99rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 99rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100rsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 100rsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
101rsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 101rsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
102rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 102rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
103rsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h 103rsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
104rsa_gen.o: ../cryptlib.h
104rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 105rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
105rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 106rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
106rsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 107rsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
107rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 108rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
108rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 109rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
109rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 110rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
110rsa_lib.o: ../cryptlib.h 111rsa_lib.o: ../../include/openssl/stack.h ../cryptlib.h
111rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 112rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
112rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 113rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113rsa_none.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 114rsa_none.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
114rsa_none.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 115rsa_none.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
115rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 116rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
116rsa_none.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 117rsa_none.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
117rsa_none.o: ../cryptlib.h 118rsa_none.o: ../../include/openssl/stack.h ../cryptlib.h
119rsa_null.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
120rsa_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
121rsa_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
122rsa_null.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
123rsa_null.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
124rsa_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
125rsa_null.o: ../../include/openssl/stack.h ../cryptlib.h
118rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 126rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
119rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 127rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120rsa_oaep.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 128rsa_oaep.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
121rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 129rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
122rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 130rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
123rsa_oaep.o: ../../include/openssl/rsa.h ../../include/openssl/sha.h 131rsa_oaep.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
124rsa_oaep.o: ../../include/openssl/stack.h ../cryptlib.h 132rsa_oaep.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
133rsa_oaep.o: ../cryptlib.h
125rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 134rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
126rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 135rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
127rsa_pk1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 136rsa_pk1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
128rsa_pk1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 137rsa_pk1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
129rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 138rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
130rsa_pk1.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 139rsa_pk1.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
131rsa_pk1.o: ../cryptlib.h 140rsa_pk1.o: ../../include/openssl/stack.h ../cryptlib.h
132rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 141rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
133rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 142rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
134rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 143rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -168,5 +177,5 @@ rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
168rsa_ssl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 177rsa_ssl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
169rsa_ssl.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 178rsa_ssl.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
170rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 179rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
171rsa_ssl.o: ../../include/openssl/rsa.h ../../include/openssl/stack.h 180rsa_ssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
172rsa_ssl.o: ../cryptlib.h 181rsa_ssl.o: ../../include/openssl/stack.h ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/rsa/rsa.h b/src/lib/libssl/src/crypto/rsa/rsa.h
index 9230b2fcc9..f9f9b5cfe9 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa.h
+++ b/src/lib/libssl/src/crypto/rsa/rsa.h
@@ -91,6 +91,18 @@ typedef struct rsa_meth_st
91 int (*finish)(RSA *rsa); /* called at free */ 91 int (*finish)(RSA *rsa); /* called at free */
92 int flags; /* RSA_METHOD_FLAG_* things */ 92 int flags; /* RSA_METHOD_FLAG_* things */
93 char *app_data; /* may be needed! */ 93 char *app_data; /* may be needed! */
94/* New sign and verify functions: some libraries don't allow arbitrary data
95 * to be signed/verified: this allows them to be used. Note: for this to work
96 * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
97 * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
98 * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
99 * option is set in 'flags'.
100 */
101 int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len,
102 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
103 int (*rsa_verify)(int dtype, unsigned char *m, unsigned int m_len,
104 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
105
94 } RSA_METHOD; 106 } RSA_METHOD;
95 107
96struct rsa_st 108struct rsa_st
@@ -140,12 +152,16 @@ struct rsa_st
140 */ 152 */
141#define RSA_FLAG_EXT_PKEY 0x20 153#define RSA_FLAG_EXT_PKEY 0x20
142 154
155/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
156 */
157#define RSA_FLAG_SIGN_VER 0x40
158
143#define RSA_PKCS1_PADDING 1 159#define RSA_PKCS1_PADDING 1
144#define RSA_SSLV23_PADDING 2 160#define RSA_SSLV23_PADDING 2
145#define RSA_NO_PADDING 3 161#define RSA_NO_PADDING 3
146#define RSA_PKCS1_OAEP_PADDING 4 162#define RSA_PKCS1_OAEP_PADDING 4
147 163
148#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,(char *)arg) 164#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
149#define RSA_get_app_data(s) RSA_get_ex_data(s,0) 165#define RSA_get_app_data(s) RSA_get_ex_data(s,0)
150 166
151RSA * RSA_new(void); 167RSA * RSA_new(void);
@@ -181,6 +197,8 @@ RSA_METHOD *RSA_PKCS1_RSAref(void);
181/* these are the actual SSLeay RSA functions */ 197/* these are the actual SSLeay RSA functions */
182RSA_METHOD *RSA_PKCS1_SSLeay(void); 198RSA_METHOD *RSA_PKCS1_SSLeay(void);
183 199
200RSA_METHOD *RSA_null_method(void);
201
184void ERR_load_RSA_strings(void ); 202void ERR_load_RSA_strings(void );
185 203
186RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length); 204RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length);
@@ -241,10 +259,10 @@ int RSA_padding_add_none(unsigned char *to,int tlen,
241int RSA_padding_check_none(unsigned char *to,int tlen, 259int RSA_padding_check_none(unsigned char *to,int tlen,
242 unsigned char *f,int fl,int rsa_len); 260 unsigned char *f,int fl,int rsa_len);
243 261
244int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), 262int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
245 int (*dup_func)(), void (*free_func)()); 263 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
246int RSA_set_ex_data(RSA *r,int idx,char *arg); 264int RSA_set_ex_data(RSA *r,int idx,void *arg);
247char *RSA_get_ex_data(RSA *r, int idx); 265void *RSA_get_ex_data(RSA *r, int idx);
248 266
249/* BEGIN ERROR CODES */ 267/* BEGIN ERROR CODES */
250/* The following lines are auto generated by the script mkerr.pl. Any changes 268/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -262,6 +280,7 @@ char *RSA_get_ex_data(RSA *r, int idx);
262#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 280#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104
263#define RSA_F_RSA_GENERATE_KEY 105 281#define RSA_F_RSA_GENERATE_KEY 105
264#define RSA_F_RSA_NEW_METHOD 106 282#define RSA_F_RSA_NEW_METHOD 106
283#define RSA_F_RSA_NULL 124
265#define RSA_F_RSA_PADDING_ADD_NONE 107 284#define RSA_F_RSA_PADDING_ADD_NONE 107
266#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 285#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121
267#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 286#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108
@@ -292,10 +311,11 @@ char *RSA_get_ex_data(RSA *r, int idx);
292#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 311#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
293#define RSA_R_DATA_TOO_SMALL 111 312#define RSA_R_DATA_TOO_SMALL 111
294#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 313#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122
295#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
296#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 314#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
297#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 315#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124
298#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 316#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
317#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
318#define RSA_R_INVALID_MESSAGE_LENGTH 131
299#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 319#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
300#define RSA_R_KEY_SIZE_TOO_SMALL 120 320#define RSA_R_KEY_SIZE_TOO_SMALL 120
301#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 321#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
@@ -304,6 +324,7 @@ char *RSA_get_ex_data(RSA *r, int idx);
304#define RSA_R_PADDING_CHECK_FAILED 114 324#define RSA_R_PADDING_CHECK_FAILED 114
305#define RSA_R_P_NOT_PRIME 128 325#define RSA_R_P_NOT_PRIME 128
306#define RSA_R_Q_NOT_PRIME 129 326#define RSA_R_Q_NOT_PRIME 129
327#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
307#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 328#define RSA_R_SSLV3_ROLLBACK_ATTACK 115
308#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 329#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
309#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 330#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
index 776324860c..179b7da90a 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
@@ -72,6 +72,8 @@
72#include <openssl/rsa.h> 72#include <openssl/rsa.h>
73#include <openssl/rand.h> 73#include <openssl/rand.h>
74 74
75#ifndef RSA_NULL
76
75static int RSA_eay_public_encrypt(int flen, unsigned char *from, 77static int RSA_eay_public_encrypt(int flen, unsigned char *from,
76 unsigned char *to, RSA *rsa,int padding); 78 unsigned char *to, RSA *rsa,int padding);
77static int RSA_eay_private_encrypt(int flen, unsigned char *from, 79static int RSA_eay_private_encrypt(int flen, unsigned char *from,
@@ -285,4 +287,4 @@ static int RSA_eay_finish(RSA *rsa)
285 return(1); 287 return(1);
286 } 288 }
287 289
288 290#endif
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_err.c b/src/lib/libssl/src/crypto/rsa/rsa_err.c
index 9fb15e398d..5cfbea2b03 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_err.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_err.c
@@ -73,6 +73,7 @@ static ERR_STRING_DATA RSA_str_functs[]=
73{ERR_PACK(0,RSA_F_RSA_EAY_PUBLIC_ENCRYPT,0), "RSA_EAY_PUBLIC_ENCRYPT"}, 73{ERR_PACK(0,RSA_F_RSA_EAY_PUBLIC_ENCRYPT,0), "RSA_EAY_PUBLIC_ENCRYPT"},
74{ERR_PACK(0,RSA_F_RSA_GENERATE_KEY,0), "RSA_generate_key"}, 74{ERR_PACK(0,RSA_F_RSA_GENERATE_KEY,0), "RSA_generate_key"},
75{ERR_PACK(0,RSA_F_RSA_NEW_METHOD,0), "RSA_new_method"}, 75{ERR_PACK(0,RSA_F_RSA_NEW_METHOD,0), "RSA_new_method"},
76{ERR_PACK(0,RSA_F_RSA_NULL,0), "RSA_NULL"},
76{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_NONE,0), "RSA_padding_add_none"}, 77{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_NONE,0), "RSA_padding_add_none"},
77{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_OAEP,0), "RSA_padding_add_PKCS1_OAEP"}, 78{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_OAEP,0), "RSA_padding_add_PKCS1_OAEP"},
78{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,0), "RSA_padding_add_PKCS1_type_1"}, 79{ERR_PACK(0,RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,0), "RSA_padding_add_PKCS1_type_1"},
@@ -106,10 +107,11 @@ static ERR_STRING_DATA RSA_str_reasons[]=
106{RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"}, 107{RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"},
107{RSA_R_DATA_TOO_SMALL ,"data too small"}, 108{RSA_R_DATA_TOO_SMALL ,"data too small"},
108{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE ,"data too small for key size"}, 109{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE ,"data too small for key size"},
109{RSA_R_D_E_NOT_CONGRUENT_TO_1 ,"d e not congruent to 1"},
110{RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY ,"digest too big for rsa key"}, 110{RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY ,"digest too big for rsa key"},
111{RSA_R_DMP1_NOT_CONGRUENT_TO_D ,"dmp1 not congruent to d"}, 111{RSA_R_DMP1_NOT_CONGRUENT_TO_D ,"dmp1 not congruent to d"},
112{RSA_R_DMQ1_NOT_CONGRUENT_TO_D ,"dmq1 not congruent to d"}, 112{RSA_R_DMQ1_NOT_CONGRUENT_TO_D ,"dmq1 not congruent to d"},
113{RSA_R_D_E_NOT_CONGRUENT_TO_1 ,"d e not congruent to 1"},
114{RSA_R_INVALID_MESSAGE_LENGTH ,"invalid message length"},
113{RSA_R_IQMP_NOT_INVERSE_OF_Q ,"iqmp not inverse of q"}, 115{RSA_R_IQMP_NOT_INVERSE_OF_Q ,"iqmp not inverse of q"},
114{RSA_R_KEY_SIZE_TOO_SMALL ,"key size too small"}, 116{RSA_R_KEY_SIZE_TOO_SMALL ,"key size too small"},
115{RSA_R_NULL_BEFORE_BLOCK_MISSING ,"null before block missing"}, 117{RSA_R_NULL_BEFORE_BLOCK_MISSING ,"null before block missing"},
@@ -118,6 +120,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
118{RSA_R_PADDING_CHECK_FAILED ,"padding check failed"}, 120{RSA_R_PADDING_CHECK_FAILED ,"padding check failed"},
119{RSA_R_P_NOT_PRIME ,"p not prime"}, 121{RSA_R_P_NOT_PRIME ,"p not prime"},
120{RSA_R_Q_NOT_PRIME ,"q not prime"}, 122{RSA_R_Q_NOT_PRIME ,"q not prime"},
123{RSA_R_RSA_OPERATIONS_NOT_SUPPORTED ,"rsa operations not supported"},
121{RSA_R_SSLV3_ROLLBACK_ATTACK ,"sslv3 rollback attack"}, 124{RSA_R_SSLV3_ROLLBACK_ATTACK ,"sslv3 rollback attack"},
122{RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"}, 125{RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
123{RSA_R_UNKNOWN_ALGORITHM_TYPE ,"unknown algorithm type"}, 126{RSA_R_UNKNOWN_ALGORITHM_TYPE ,"unknown algorithm type"},
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_gen.c b/src/lib/libssl/src/crypto/rsa/rsa_gen.c
index 3227dba794..b1ee5d8dce 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_gen.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_gen.c
@@ -85,6 +85,7 @@ err:
85 RSAerr(RSA_F_RSA_GENERATE_KEY,ERR_LIB_BN); 85 RSAerr(RSA_F_RSA_GENERATE_KEY,ERR_LIB_BN);
86 ok=0; 86 ok=0;
87 } 87 }
88 BN_CTX_end(ctx);
88 BN_CTX_free(ctx); 89 BN_CTX_free(ctx);
89 BN_CTX_free(ctx2); 90 BN_CTX_free(ctx2);
90 91
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_lib.c b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
index c0ca2923a6..074a4f5074 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_lib.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
@@ -67,7 +67,7 @@ const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
67 67
68static RSA_METHOD *default_RSA_meth=NULL; 68static RSA_METHOD *default_RSA_meth=NULL;
69static int rsa_meth_num=0; 69static int rsa_meth_num=0;
70static STACK *rsa_meth=NULL; 70static STACK_OF(CRYPTO_EX_DATA_FUNCS) *rsa_meth=NULL;
71 71
72RSA *RSA_new(void) 72RSA *RSA_new(void)
73 { 73 {
@@ -105,11 +105,15 @@ RSA *RSA_new_method(RSA_METHOD *meth)
105 105
106 if (default_RSA_meth == NULL) 106 if (default_RSA_meth == NULL)
107 { 107 {
108#ifdef RSA_NULL
109 default_RSA_meth=RSA_null_method();
110#else
108#ifdef RSAref 111#ifdef RSAref
109 default_RSA_meth=RSA_PKCS1_RSAref(); 112 default_RSA_meth=RSA_PKCS1_RSAref();
110#else 113#else
111 default_RSA_meth=RSA_PKCS1_SSLeay(); 114 default_RSA_meth=RSA_PKCS1_SSLeay();
112#endif 115#endif
116#endif
113 } 117 }
114 ret=(RSA *)Malloc(sizeof(RSA)); 118 ret=(RSA *)Malloc(sizeof(RSA));
115 if (ret == NULL) 119 if (ret == NULL)
@@ -146,7 +150,7 @@ RSA *RSA_new_method(RSA_METHOD *meth)
146 ret=NULL; 150 ret=NULL;
147 } 151 }
148 else 152 else
149 CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data); 153 CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data);
150 return(ret); 154 return(ret);
151 } 155 }
152 156
@@ -169,7 +173,7 @@ void RSA_free(RSA *r)
169 } 173 }
170#endif 174#endif
171 175
172 CRYPTO_free_ex_data(rsa_meth,(char *)r,&r->ex_data); 176 CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data);
173 177
174 if (r->meth->finish != NULL) 178 if (r->meth->finish != NULL)
175 r->meth->finish(r); 179 r->meth->finish(r);
@@ -187,20 +191,20 @@ void RSA_free(RSA *r)
187 Free(r); 191 Free(r);
188 } 192 }
189 193
190int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), 194int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
191 int (*dup_func)(), void (*free_func)()) 195 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
192 { 196 {
193 rsa_meth_num++; 197 rsa_meth_num++;
194 return(CRYPTO_get_ex_new_index(rsa_meth_num-1, 198 return(CRYPTO_get_ex_new_index(rsa_meth_num-1,
195 &rsa_meth,argl,argp,new_func,dup_func,free_func)); 199 &rsa_meth,argl,argp,new_func,dup_func,free_func));
196 } 200 }
197 201
198int RSA_set_ex_data(RSA *r, int idx, char *arg) 202int RSA_set_ex_data(RSA *r, int idx, void *arg)
199 { 203 {
200 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); 204 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
201 } 205 }
202 206
203char *RSA_get_ex_data(RSA *r, int idx) 207void *RSA_get_ex_data(RSA *r, int idx)
204 { 208 {
205 return(CRYPTO_get_ex_data(&r->ex_data,idx)); 209 return(CRYPTO_get_ex_data(&r->ex_data,idx));
206 } 210 }
@@ -265,19 +269,19 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
265 if (rsa->blinding != NULL) 269 if (rsa->blinding != NULL)
266 BN_BLINDING_free(rsa->blinding); 270 BN_BLINDING_free(rsa->blinding);
267 271
268 A= &(ctx->bn[0]); 272 BN_CTX_start(ctx);
269 ctx->tos++; 273 A = BN_CTX_get(ctx);
270 if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err; 274 if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err;
271 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; 275 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
272 276
273 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) 277 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
274 goto err; 278 goto err;
275 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); 279 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n);
276 ctx->tos--;
277 rsa->flags|=RSA_FLAG_BLINDING; 280 rsa->flags|=RSA_FLAG_BLINDING;
278 BN_free(Ai); 281 BN_free(Ai);
279 ret=1; 282 ret=1;
280err: 283err:
284 BN_CTX_end(ctx);
281 if (ctx != p_ctx) BN_CTX_free(ctx); 285 if (ctx != p_ctx) BN_CTX_free(ctx);
282 return(ret); 286 return(ret);
283 } 287 }
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_null.c b/src/lib/libssl/src/crypto/rsa/rsa_null.c
new file mode 100644
index 0000000000..7b58a0eca3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rsa/rsa_null.c
@@ -0,0 +1,149 @@
1/* rsa_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/bn.h>
62#include <openssl/rsa.h>
63#include <openssl/rand.h>
64
65/* This is a dummy RSA implementation that just returns errors when called.
66 * It is designed to allow some RSA functions to work while stopping those
67 * covered by the RSA patent. That is RSA, encryption, decryption, signing
68 * and verify is not allowed but RSA key generation, key checking and other
69 * operations (like storing RSA keys) are permitted.
70 */
71
72static int RSA_null_public_encrypt(int flen, unsigned char *from,
73 unsigned char *to, RSA *rsa,int padding);
74static int RSA_null_private_encrypt(int flen, unsigned char *from,
75 unsigned char *to, RSA *rsa,int padding);
76static int RSA_null_public_decrypt(int flen, unsigned char *from,
77 unsigned char *to, RSA *rsa,int padding);
78static int RSA_null_private_decrypt(int flen, unsigned char *from,
79 unsigned char *to, RSA *rsa,int padding);
80#if 0 /* not currently used */
81static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *i, RSA *rsa);
82#endif
83static int RSA_null_init(RSA *rsa);
84static int RSA_null_finish(RSA *rsa);
85static RSA_METHOD rsa_null_meth={
86 "Null RSA",
87 RSA_null_public_encrypt,
88 RSA_null_public_decrypt,
89 RSA_null_private_encrypt,
90 RSA_null_private_decrypt,
91 NULL, NULL,
92 RSA_null_init,
93 RSA_null_finish,
94 0,
95 NULL,
96 };
97
98RSA_METHOD *RSA_null_method(void)
99 {
100 return(&rsa_null_meth);
101 }
102
103static int RSA_null_public_encrypt(int flen, unsigned char *from,
104 unsigned char *to, RSA *rsa, int padding)
105 {
106 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
107 return -1;
108 }
109
110static int RSA_null_private_encrypt(int flen, unsigned char *from,
111 unsigned char *to, RSA *rsa, int padding)
112 {
113 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
114 return -1;
115 }
116
117static int RSA_null_private_decrypt(int flen, unsigned char *from,
118 unsigned char *to, RSA *rsa, int padding)
119 {
120 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
121 return -1;
122 }
123
124static int RSA_null_public_decrypt(int flen, unsigned char *from,
125 unsigned char *to, RSA *rsa, int padding)
126 {
127 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
128 return -1;
129 }
130
131#if 0 /* not currently used */
132static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
133 {
134 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
135 return -1;
136 }
137#endif
138
139static int RSA_null_init(RSA *rsa)
140 {
141 return(1);
142 }
143
144static int RSA_null_finish(RSA *rsa)
145 {
146 return(1);
147 }
148
149
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_oaep.c b/src/lib/libssl/src/crypto/rsa/rsa_oaep.c
index 843c40c864..1465c01f4f 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_oaep.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_oaep.c
@@ -50,7 +50,8 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
50 emlen - flen - 2 * SHA_DIGEST_LENGTH - 1); 50 emlen - flen - 2 * SHA_DIGEST_LENGTH - 1);
51 db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01; 51 db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01;
52 memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, (unsigned int) flen); 52 memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, (unsigned int) flen);
53 RAND_bytes(seed, SHA_DIGEST_LENGTH); 53 if (RAND_bytes(seed, SHA_DIGEST_LENGTH) <= 0)
54 return (0);
54#ifdef PKCS_TESTVECT 55#ifdef PKCS_TESTVECT
55 memcpy(seed, 56 memcpy(seed,
56 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f", 57 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f",
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_oaep_test.c b/src/lib/libssl/src/crypto/rsa/rsa_oaep_test.c
index 0d4e39d3da..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_oaep_test.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_oaep_test.c
@@ -1,309 +0,0 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "openssl/e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#ifdef NO_RSA
11int main(int argc, char *argv[])
12{
13 printf("No RSA support\n");
14 return(0);
15}
16#else
17#include <openssl/rsa.h>
18
19#define SetKey \
20 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
21 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
22 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
23 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
24 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
25 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
26 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
27 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
28 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
29 return (sizeof(ctext_ex) - 1);
30
31static int key1(RSA *key, unsigned char *c)
32 {
33 static unsigned char n[] =
34"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
35"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
36"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
37"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
38"\xF5";
39
40 static unsigned char e[] = "\x11";
41
42 static unsigned char d[] =
43"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
44"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
45"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
46"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
47
48 static unsigned char p[] =
49"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
50"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
51"\x0D";
52
53 static unsigned char q[] =
54"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
55"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
56"\x89";
57
58 static unsigned char dmp1[] =
59"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
60"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
61
62 static unsigned char dmq1[] =
63"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
64"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
65"\x51";
66
67 static unsigned char iqmp[] =
68"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
69"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
70
71 static unsigned char ctext_ex[] =
72"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
73"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
74"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
75"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
76
77 SetKey;
78 }
79
80static int key2(RSA *key, unsigned char *c)
81 {
82 static unsigned char n[] =
83"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
84"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
85"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
86"\x34\x77\xCF";
87
88 static unsigned char e[] = "\x3";
89
90 static unsigned char d[] =
91"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
92"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
93"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
94"\xE5\xEB";
95
96 static unsigned char p[] =
97"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
98"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
99
100 static unsigned char q[] =
101"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
102"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
103
104 static unsigned char dmp1[] =
105"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
106"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
107
108 static unsigned char dmq1[] =
109"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
110"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
111
112 static unsigned char iqmp[] =
113"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
114"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
115
116 static unsigned char ctext_ex[] =
117"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
118"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
119"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
120"\x62\x51";
121
122 SetKey;
123 }
124
125static int key3(RSA *key, unsigned char *c)
126 {
127 static unsigned char n[] =
128"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
129"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
130"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
131"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
132"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
133"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
134"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
135"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
136"\xCB";
137
138 static unsigned char e[] = "\x11";
139
140 static unsigned char d[] =
141"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
142"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
143"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
144"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
145"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
146"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
147"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
148"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
149"\xC1";
150
151 static unsigned char p[] =
152"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
153"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
154"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
155"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
156"\x99";
157
158 static unsigned char q[] =
159"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
160"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
161"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
162"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
163"\x03";
164
165 static unsigned char dmp1[] =
166"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
167"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
168"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
169"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
170
171 static unsigned char dmq1[] =
172"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
173"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
174"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
175"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
176
177 static unsigned char iqmp[] =
178"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
179"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
180"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
181"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
182"\xF7";
183
184 static unsigned char ctext_ex[] =
185"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
186"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
187"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
188"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
189"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
190"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
191"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
192"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
193
194 SetKey;
195 }
196
197static int pad_unknown(void)
198{
199 unsigned long l;
200 while ((l = ERR_get_error()) != 0)
201 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
202 return(1);
203 return(0);
204}
205
206int main()
207 {
208 int err=0;
209 int v;
210 RSA *key;
211 unsigned char ptext[256];
212 unsigned char ctext[256];
213 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
214 unsigned char ctext_ex[256];
215 int plen;
216 int clen = 0;
217 int num;
218
219 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
220
221 plen = sizeof(ptext_ex) - 1;
222
223 for (v = 0; v < 3; v++)
224 {
225 key = RSA_new();
226 switch (v) {
227 case 0:
228 clen = key1(key, ctext_ex);
229 break;
230 case 1:
231 clen = key2(key, ctext_ex);
232 break;
233 case 2:
234 clen = key3(key, ctext_ex);
235 break;
236 }
237
238 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
239 RSA_PKCS1_PADDING);
240 if (num != clen)
241 {
242 printf("PKCS#1 v1.5 encryption failed!\n");
243 err=1;
244 goto oaep;
245 }
246
247 num = RSA_private_decrypt(num, ctext, ptext, key,
248 RSA_PKCS1_PADDING);
249 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
250 {
251 printf("PKCS#1 v1.5 decryption failed!\n");
252 err=1;
253 }
254 else
255 printf("PKCS #1 v1.5 encryption/decryption ok\n");
256
257 oaep:
258 ERR_clear_error();
259 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
260 RSA_PKCS1_OAEP_PADDING);
261 if (num == -1 && pad_unknown())
262 {
263 printf("No OAEP support\n");
264 goto next;
265 }
266 if (num != clen)
267 {
268 printf("OAEP encryption failed!\n");
269 err=1;
270 goto next;
271 }
272
273 num = RSA_private_decrypt(num, ctext, ptext, key,
274 RSA_PKCS1_OAEP_PADDING);
275 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
276 {
277 printf("OAEP decryption (encrypted data) failed!\n");
278 err=1;
279 }
280 else if (memcmp(ctext, ctext_ex, num) == 0)
281 {
282 printf("OAEP test vector %d passed!\n", v);
283 goto next;
284 }
285
286 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
287 Try decrypting ctext_ex */
288
289 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
290 RSA_PKCS1_OAEP_PADDING);
291
292 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
293 {
294 printf("OAEP decryption (test vector data) failed!\n");
295 err=1;
296 }
297 else
298 printf("OAEP encryption/decryption ok\n");
299 next:
300 RSA_free(key);
301 }
302
303 ERR_remove_state(0);
304
305 CRYPTO_mem_leaks_fp(stdout);
306
307 return err;
308 }
309#endif
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_pk1.c b/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
index f0ae51f234..48a32bc264 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
@@ -79,7 +79,7 @@ int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
79 *(p++)=0; 79 *(p++)=0;
80 *(p++)=1; /* Private Key BT (Block Type) */ 80 *(p++)=1; /* Private Key BT (Block Type) */
81 81
82 /* padd out with 0xff data */ 82 /* pad out with 0xff data */
83 j=tlen-3-flen; 83 j=tlen-3-flen;
84 memset(p,0xff,j); 84 memset(p,0xff,j);
85 p+=j; 85 p+=j;
@@ -130,6 +130,11 @@ int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
130 } 130 }
131 i++; /* Skip over the '\0' */ 131 i++; /* Skip over the '\0' */
132 j-=i; 132 j-=i;
133 if (j > tlen)
134 {
135 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE);
136 return(-1);
137 }
133 memcpy(to,p,(unsigned int)j); 138 memcpy(to,p,(unsigned int)j);
134 139
135 return(j); 140 return(j);
@@ -155,12 +160,14 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
155 /* pad out with non-zero random data */ 160 /* pad out with non-zero random data */
156 j=tlen-3-flen; 161 j=tlen-3-flen;
157 162
158 RAND_bytes(p,j); 163 if (RAND_bytes(p,j) <= 0)
164 return(0);
159 for (i=0; i<j; i++) 165 for (i=0; i<j; i++)
160 { 166 {
161 if (*p == '\0') 167 if (*p == '\0')
162 do { 168 do {
163 RAND_bytes(p,1); 169 if (RAND_bytes(p,1) <= 0)
170 return(0);
164 } while (*p == '\0'); 171 } while (*p == '\0');
165 p++; 172 p++;
166 } 173 }
@@ -205,6 +212,11 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
205 } 212 }
206 i++; /* Skip over the '\0' */ 213 i++; /* Skip over the '\0' */
207 j-=i; 214 j-=i;
215 if (j > tlen)
216 {
217 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_DATA_TOO_LARGE);
218 return(-1);
219 }
208 memcpy(to,p,(unsigned int)j); 220 memcpy(to,p,(unsigned int)j);
209 221
210 return(j); 222 return(j);
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_saos.c b/src/lib/libssl/src/crypto/rsa/rsa_saos.c
index 73b8b0c7ad..61efb0b00f 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_saos.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_saos.c
@@ -136,7 +136,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype, unsigned char *m,
136 else 136 else
137 ret=1; 137 ret=1;
138err: 138err:
139 if (sig != NULL) ASN1_OCTET_STRING_free(sig); 139 if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
140 memset(s,0,(unsigned int)siglen); 140 memset(s,0,(unsigned int)siglen);
141 Free(s); 141 Free(s);
142 return(ret); 142 return(ret);
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_sign.c b/src/lib/libssl/src/crypto/rsa/rsa_sign.c
index 1740494a4c..05bb7fb74a 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_sign.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_sign.c
@@ -63,59 +63,77 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66/* Size of an SSL signature: MD5+SHA1 */
67#define SSL_SIG_LENGTH 36
68
66int RSA_sign(int type, unsigned char *m, unsigned int m_len, 69int RSA_sign(int type, unsigned char *m, unsigned int m_len,
67 unsigned char *sigret, unsigned int *siglen, RSA *rsa) 70 unsigned char *sigret, unsigned int *siglen, RSA *rsa)
68 { 71 {
69 X509_SIG sig; 72 X509_SIG sig;
70 ASN1_TYPE parameter; 73 ASN1_TYPE parameter;
71 int i,j,ret=1; 74 int i,j,ret=1;
72 unsigned char *p,*s; 75 unsigned char *p,*s = NULL;
73 X509_ALGOR algor; 76 X509_ALGOR algor;
74 ASN1_OCTET_STRING digest; 77 ASN1_OCTET_STRING digest;
75 78 if(rsa->flags & RSA_FLAG_SIGN_VER)
76 sig.algor= &algor; 79 return rsa->meth->rsa_sign(type, m, m_len, sigret, siglen, rsa);
77 sig.algor->algorithm=OBJ_nid2obj(type); 80 /* Special case: SSL signature, just check the length */
78 if (sig.algor->algorithm == NULL) 81 if(type == NID_md5_sha1) {
79 { 82 if(m_len != SSL_SIG_LENGTH) {
80 RSAerr(RSA_F_RSA_SIGN,RSA_R_UNKNOWN_ALGORITHM_TYPE); 83 RSAerr(RSA_F_RSA_SIGN,RSA_R_INVALID_MESSAGE_LENGTH);
81 return(0); 84 return(0);
82 }
83 if (sig.algor->algorithm->length == 0)
84 {
85 RSAerr(RSA_F_RSA_SIGN,RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
86 return(0);
87 } 85 }
88 parameter.type=V_ASN1_NULL; 86 i = SSL_SIG_LENGTH;
89 parameter.value.ptr=NULL; 87 s = m;
90 sig.algor->parameter= &parameter; 88 } else {
89 sig.algor= &algor;
90 sig.algor->algorithm=OBJ_nid2obj(type);
91 if (sig.algor->algorithm == NULL)
92 {
93 RSAerr(RSA_F_RSA_SIGN,RSA_R_UNKNOWN_ALGORITHM_TYPE);
94 return(0);
95 }
96 if (sig.algor->algorithm->length == 0)
97 {
98 RSAerr(RSA_F_RSA_SIGN,RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
99 return(0);
100 }
101 parameter.type=V_ASN1_NULL;
102 parameter.value.ptr=NULL;
103 sig.algor->parameter= &parameter;
91 104
92 sig.digest= &digest; 105 sig.digest= &digest;
93 sig.digest->data=m; 106 sig.digest->data=m;
94 sig.digest->length=m_len; 107 sig.digest->length=m_len;
95 108
96 i=i2d_X509_SIG(&sig,NULL); 109 i=i2d_X509_SIG(&sig,NULL);
110 }
97 j=RSA_size(rsa); 111 j=RSA_size(rsa);
98 if ((i-RSA_PKCS1_PADDING) > j) 112 if ((i-RSA_PKCS1_PADDING) > j)
99 { 113 {
100 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); 114 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
101 return(0); 115 return(0);
102 } 116 }
103 s=(unsigned char *)Malloc((unsigned int)j+1); 117 if(type != NID_md5_sha1) {
104 if (s == NULL) 118 s=(unsigned char *)Malloc((unsigned int)j+1);
105 { 119 if (s == NULL)
106 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE); 120 {
107 return(0); 121 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE);
108 } 122 return(0);
109 p=s; 123 }
110 i2d_X509_SIG(&sig,&p); 124 p=s;
125 i2d_X509_SIG(&sig,&p);
126 }
111 i=RSA_private_encrypt(i,s,sigret,rsa,RSA_PKCS1_PADDING); 127 i=RSA_private_encrypt(i,s,sigret,rsa,RSA_PKCS1_PADDING);
112 if (i <= 0) 128 if (i <= 0)
113 ret=0; 129 ret=0;
114 else 130 else
115 *siglen=i; 131 *siglen=i;
116 132
117 memset(s,0,(unsigned int)j+1); 133 if(type != NID_md5_sha1) {
118 Free(s); 134 memset(s,0,(unsigned int)j+1);
135 Free(s);
136 }
119 return(ret); 137 return(ret);
120 } 138 }
121 139
@@ -132,53 +150,68 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
132 return(0); 150 return(0);
133 } 151 }
134 152
153 if(rsa->flags & RSA_FLAG_SIGN_VER)
154 return rsa->meth->rsa_verify(dtype, m, m_len, sigbuf, siglen, rsa);
155
135 s=(unsigned char *)Malloc((unsigned int)siglen); 156 s=(unsigned char *)Malloc((unsigned int)siglen);
136 if (s == NULL) 157 if (s == NULL)
137 { 158 {
138 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE); 159 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE);
139 goto err; 160 goto err;
140 } 161 }
162 if((dtype == NID_md5_sha1) && (m_len != SSL_SIG_LENGTH) ) {
163 RSAerr(RSA_F_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH);
164 return(0);
165 }
141 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING); 166 i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);
142 167
143 if (i <= 0) goto err; 168 if (i <= 0) goto err;
144 169
145 p=s; 170 /* Special case: SSL signature */
146 sig=d2i_X509_SIG(NULL,&p,(long)i); 171 if(dtype == NID_md5_sha1) {
172 if((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH))
173 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
174 else ret = 1;
175 } else {
176 p=s;
177 sig=d2i_X509_SIG(NULL,&p,(long)i);
147 178
148 if (sig == NULL) goto err; 179 if (sig == NULL) goto err;
149 sigtype=OBJ_obj2nid(sig->algor->algorithm); 180 sigtype=OBJ_obj2nid(sig->algor->algorithm);
150 181
151 182
152#ifdef RSA_DEBUG 183 #ifdef RSA_DEBUG
153 /* put a backward compatability flag in EAY */ 184 /* put a backward compatibility flag in EAY */
154 fprintf(stderr,"in(%s) expect(%s)\n",OBJ_nid2ln(sigtype), 185 fprintf(stderr,"in(%s) expect(%s)\n",OBJ_nid2ln(sigtype),
155 OBJ_nid2ln(dtype)); 186 OBJ_nid2ln(dtype));
156#endif 187 #endif
157 if (sigtype != dtype) 188 if (sigtype != dtype)
158 {
159 if (((dtype == NID_md5) &&
160 (sigtype == NID_md5WithRSAEncryption)) ||
161 ((dtype == NID_md2) &&
162 (sigtype == NID_md2WithRSAEncryption)))
163 { 189 {
164 /* ok, we will let it through */ 190 if (((dtype == NID_md5) &&
165#if !defined(NO_STDIO) && !defined(WIN16) 191 (sigtype == NID_md5WithRSAEncryption)) ||
166 fprintf(stderr,"signature has problems, re-make with post SSLeay045\n"); 192 ((dtype == NID_md2) &&
167#endif 193 (sigtype == NID_md2WithRSAEncryption)))
194 {
195 /* ok, we will let it through */
196 #if !defined(NO_STDIO) && !defined(WIN16)
197 fprintf(stderr,"signature has problems, re-make with post SSLeay045\n");
198 #endif
199 }
200 else
201 {
202 RSAerr(RSA_F_RSA_VERIFY,
203 RSA_R_ALGORITHM_MISMATCH);
204 goto err;
205 }
168 } 206 }
169 else 207 if ( ((unsigned int)sig->digest->length != m_len) ||
208 (memcmp(m,sig->digest->data,m_len) != 0))
170 { 209 {
171 RSAerr(RSA_F_RSA_VERIFY,RSA_R_ALGORITHM_MISMATCH); 210 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
172 goto err;
173 } 211 }
174 } 212 else
175 if ( ((unsigned int)sig->digest->length != m_len) || 213 ret=1;
176 (memcmp(m,sig->digest->data,m_len) != 0)) 214 }
177 {
178 RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
179 }
180 else
181 ret=1;
182err: 215err:
183 if (sig != NULL) X509_SIG_free(sig); 216 if (sig != NULL) X509_SIG_free(sig);
184 memset(s,0,(unsigned int)siglen); 217 memset(s,0,(unsigned int)siglen);
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_ssl.c b/src/lib/libssl/src/crypto/rsa/rsa_ssl.c
index 1050844f8d..81a857c813 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_ssl.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_ssl.c
@@ -82,12 +82,14 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, unsigned char *from,
82 /* pad out with non-zero random data */ 82 /* pad out with non-zero random data */
83 j=tlen-3-8-flen; 83 j=tlen-3-8-flen;
84 84
85 RAND_bytes(p,j); 85 if (RAND_bytes(p,j) <= 0)
86 return(0);
86 for (i=0; i<j; i++) 87 for (i=0; i<j; i++)
87 { 88 {
88 if (*p == '\0') 89 if (*p == '\0')
89 do { 90 do {
90 RAND_bytes(p,1); 91 if (RAND_bytes(p,1) <= 0)
92 return(0);
91 } while (*p == '\0'); 93 } while (*p == '\0');
92 p++; 94 p++;
93 } 95 }
@@ -140,6 +142,11 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,
140 142
141 i++; /* Skip over the '\0' */ 143 i++; /* Skip over the '\0' */
142 j-=i; 144 j-=i;
145 if (j > tlen)
146 {
147 RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_DATA_TOO_LARGE);
148 return(-1);
149 }
143 memcpy(to,p,(unsigned int)j); 150 memcpy(to,p,(unsigned int)j);
144 151
145 return(j); 152 return(j);
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_test.c b/src/lib/libssl/src/crypto/rsa/rsa_test.c
new file mode 100644
index 0000000000..e5ae0c1f69
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rsa/rsa_test.c
@@ -0,0 +1,314 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "openssl/e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#include <openssl/rand.h>
11#ifdef NO_RSA
12int main(int argc, char *argv[])
13{
14 printf("No RSA support\n");
15 return(0);
16}
17#else
18#include <openssl/rsa.h>
19
20#define SetKey \
21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
22 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
23 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
24 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
25 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
26 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
27 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
28 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
29 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
30 return (sizeof(ctext_ex) - 1);
31
32static int key1(RSA *key, unsigned char *c)
33 {
34 static unsigned char n[] =
35"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
36"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
37"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
38"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
39"\xF5";
40
41 static unsigned char e[] = "\x11";
42
43 static unsigned char d[] =
44"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
45"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
46"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
47"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
48
49 static unsigned char p[] =
50"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
51"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
52"\x0D";
53
54 static unsigned char q[] =
55"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
56"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
57"\x89";
58
59 static unsigned char dmp1[] =
60"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
61"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
62
63 static unsigned char dmq1[] =
64"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
65"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
66"\x51";
67
68 static unsigned char iqmp[] =
69"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
70"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
71
72 static unsigned char ctext_ex[] =
73"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
74"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
75"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
76"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
77
78 SetKey;
79 }
80
81static int key2(RSA *key, unsigned char *c)
82 {
83 static unsigned char n[] =
84"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
85"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
86"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
87"\x34\x77\xCF";
88
89 static unsigned char e[] = "\x3";
90
91 static unsigned char d[] =
92"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
93"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
94"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
95"\xE5\xEB";
96
97 static unsigned char p[] =
98"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
99"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
100
101 static unsigned char q[] =
102"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
103"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
104
105 static unsigned char dmp1[] =
106"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
107"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
108
109 static unsigned char dmq1[] =
110"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
111"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
112
113 static unsigned char iqmp[] =
114"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
115"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
116
117 static unsigned char ctext_ex[] =
118"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
119"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
120"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
121"\x62\x51";
122
123 SetKey;
124 }
125
126static int key3(RSA *key, unsigned char *c)
127 {
128 static unsigned char n[] =
129"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
130"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
131"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
132"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
133"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
134"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
135"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
136"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
137"\xCB";
138
139 static unsigned char e[] = "\x11";
140
141 static unsigned char d[] =
142"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
143"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
144"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
145"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
146"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
147"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
148"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
149"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
150"\xC1";
151
152 static unsigned char p[] =
153"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
154"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
155"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
156"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
157"\x99";
158
159 static unsigned char q[] =
160"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
161"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
162"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
163"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
164"\x03";
165
166 static unsigned char dmp1[] =
167"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
168"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
169"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
170"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
171
172 static unsigned char dmq1[] =
173"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
174"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
175"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
176"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
177
178 static unsigned char iqmp[] =
179"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
180"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
181"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
182"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
183"\xF7";
184
185 static unsigned char ctext_ex[] =
186"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
187"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
188"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
189"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
190"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
191"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
192"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
193"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
194
195 SetKey;
196 }
197
198static int pad_unknown(void)
199{
200 unsigned long l;
201 while ((l = ERR_get_error()) != 0)
202 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
203 return(1);
204 return(0);
205}
206
207static const char rnd_seed[] = "string to make the random number generator think it has entropy";
208
209int main(int argc, char *argv[])
210 {
211 int err=0;
212 int v;
213 RSA *key;
214 unsigned char ptext[256];
215 unsigned char ctext[256];
216 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
217 unsigned char ctext_ex[256];
218 int plen;
219 int clen = 0;
220 int num;
221
222 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
223
224 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
225
226 plen = sizeof(ptext_ex) - 1;
227
228 for (v = 0; v < 3; v++)
229 {
230 key = RSA_new();
231 switch (v) {
232 case 0:
233 clen = key1(key, ctext_ex);
234 break;
235 case 1:
236 clen = key2(key, ctext_ex);
237 break;
238 case 2:
239 clen = key3(key, ctext_ex);
240 break;
241 }
242
243 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
244 RSA_PKCS1_PADDING);
245 if (num != clen)
246 {
247 printf("PKCS#1 v1.5 encryption failed!\n");
248 err=1;
249 goto oaep;
250 }
251
252 num = RSA_private_decrypt(num, ctext, ptext, key,
253 RSA_PKCS1_PADDING);
254 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
255 {
256 printf("PKCS#1 v1.5 decryption failed!\n");
257 err=1;
258 }
259 else
260 printf("PKCS #1 v1.5 encryption/decryption ok\n");
261
262 oaep:
263 ERR_clear_error();
264 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
265 RSA_PKCS1_OAEP_PADDING);
266 if (num == -1 && pad_unknown())
267 {
268 printf("No OAEP support\n");
269 goto next;
270 }
271 if (num != clen)
272 {
273 printf("OAEP encryption failed!\n");
274 err=1;
275 goto next;
276 }
277
278 num = RSA_private_decrypt(num, ctext, ptext, key,
279 RSA_PKCS1_OAEP_PADDING);
280 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
281 {
282 printf("OAEP decryption (encrypted data) failed!\n");
283 err=1;
284 }
285 else if (memcmp(ctext, ctext_ex, num) == 0)
286 {
287 printf("OAEP test vector %d passed!\n", v);
288 goto next;
289 }
290
291 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
292 Try decrypting ctext_ex */
293
294 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
295 RSA_PKCS1_OAEP_PADDING);
296
297 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
298 {
299 printf("OAEP decryption (test vector data) failed!\n");
300 err=1;
301 }
302 else
303 printf("OAEP encryption/decryption ok\n");
304 next:
305 RSA_free(key);
306 }
307
308 ERR_remove_state(0);
309
310 CRYPTO_mem_leaks_fp(stdout);
311
312 return err;
313 }
314#endif
diff --git a/src/lib/libssl/src/crypto/sha/Makefile.ssl b/src/lib/libssl/src/crypto/sha/Makefile.ssl
index 6ea5b1d719..79ef43aa34 100644
--- a/src/lib/libssl/src/crypto/sha/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/sha/Makefile.ssl
@@ -104,8 +104,8 @@ clean:
104sha1_one.o: ../../include/openssl/sha.h 104sha1_one.o: ../../include/openssl/sha.h
105sha1dgst.o: ../../include/openssl/opensslconf.h 105sha1dgst.o: ../../include/openssl/opensslconf.h
106sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 106sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
107sha1dgst.o: sha_locl.h 107sha1dgst.o: ../md32_common.h sha_locl.h
108sha_dgst.o: ../../include/openssl/opensslconf.h 108sha_dgst.o: ../../include/openssl/opensslconf.h
109sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 109sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
110sha_dgst.o: sha_locl.h 110sha_dgst.o: ../md32_common.h sha_locl.h
111sha_one.o: ../../include/openssl/sha.h 111sha_one.o: ../../include/openssl/sha.h
diff --git a/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm b/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm
index 61335666b9..699afdb022 100644
--- a/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm
+++ b/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm
@@ -8,302 +8,303 @@
8 .486 8 .486
9.model FLAT 9.model FLAT
10_TEXT SEGMENT 10_TEXT SEGMENT
11PUBLIC _sha1_block_x86 11PUBLIC _sha1_block_asm_data_order
12 12
13_sha1_block_x86 PROC NEAR 13_sha1_block_asm_data_order PROC NEAR
14 mov ecx, DWORD PTR 12[esp]
14 push esi 15 push esi
16 shl ecx, 6
17 mov esi, DWORD PTR 12[esp]
15 push ebp 18 push ebp
16 mov eax, DWORD PTR 20[esp] 19 add ecx, esi
17 mov esi, DWORD PTR 16[esp]
18 add eax, esi
19 mov ebp, DWORD PTR 12[esp]
20 push ebx 20 push ebx
21 sub eax, 64 21 mov ebp, DWORD PTR 16[esp]
22 push edi 22 push edi
23 mov ebx, DWORD PTR 4[ebp]
24 sub esp, 72
25 mov edx, DWORD PTR 12[ebp] 23 mov edx, DWORD PTR 12[ebp]
24 sub esp, 108
26 mov edi, DWORD PTR 16[ebp] 25 mov edi, DWORD PTR 16[ebp]
27 mov ecx, DWORD PTR 8[ebp] 26 mov ebx, DWORD PTR 8[ebp]
28 mov DWORD PTR 68[esp],eax 27 mov DWORD PTR 68[esp],ecx
29 ; First we need to setup the X array 28 ; First we need to setup the X array
30 mov eax, DWORD PTR [esi]
31L000start: 29L000start:
32 ; First, load the words onto the stack in network byte order 30 ; First, load the words onto the stack in network byte order
31 mov eax, DWORD PTR [esi]
32 mov ecx, DWORD PTR 4[esi]
33 bswap eax 33 bswap eax
34 bswap ecx
34 mov DWORD PTR [esp],eax 35 mov DWORD PTR [esp],eax
35 mov eax, DWORD PTR 4[esi] 36 mov DWORD PTR 4[esp],ecx
36 bswap eax
37 mov DWORD PTR 4[esp],eax
38 mov eax, DWORD PTR 8[esi] 37 mov eax, DWORD PTR 8[esi]
38 mov ecx, DWORD PTR 12[esi]
39 bswap eax 39 bswap eax
40 bswap ecx
40 mov DWORD PTR 8[esp],eax 41 mov DWORD PTR 8[esp],eax
41 mov eax, DWORD PTR 12[esi] 42 mov DWORD PTR 12[esp],ecx
42 bswap eax
43 mov DWORD PTR 12[esp],eax
44 mov eax, DWORD PTR 16[esi] 43 mov eax, DWORD PTR 16[esi]
44 mov ecx, DWORD PTR 20[esi]
45 bswap eax 45 bswap eax
46 bswap ecx
46 mov DWORD PTR 16[esp],eax 47 mov DWORD PTR 16[esp],eax
47 mov eax, DWORD PTR 20[esi] 48 mov DWORD PTR 20[esp],ecx
48 bswap eax
49 mov DWORD PTR 20[esp],eax
50 mov eax, DWORD PTR 24[esi] 49 mov eax, DWORD PTR 24[esi]
50 mov ecx, DWORD PTR 28[esi]
51 bswap eax 51 bswap eax
52 bswap ecx
52 mov DWORD PTR 24[esp],eax 53 mov DWORD PTR 24[esp],eax
53 mov eax, DWORD PTR 28[esi] 54 mov DWORD PTR 28[esp],ecx
54 bswap eax
55 mov DWORD PTR 28[esp],eax
56 mov eax, DWORD PTR 32[esi] 55 mov eax, DWORD PTR 32[esi]
56 mov ecx, DWORD PTR 36[esi]
57 bswap eax 57 bswap eax
58 bswap ecx
58 mov DWORD PTR 32[esp],eax 59 mov DWORD PTR 32[esp],eax
59 mov eax, DWORD PTR 36[esi] 60 mov DWORD PTR 36[esp],ecx
60 bswap eax
61 mov DWORD PTR 36[esp],eax
62 mov eax, DWORD PTR 40[esi] 61 mov eax, DWORD PTR 40[esi]
62 mov ecx, DWORD PTR 44[esi]
63 bswap eax 63 bswap eax
64 bswap ecx
64 mov DWORD PTR 40[esp],eax 65 mov DWORD PTR 40[esp],eax
65 mov eax, DWORD PTR 44[esi] 66 mov DWORD PTR 44[esp],ecx
66 bswap eax
67 mov DWORD PTR 44[esp],eax
68 mov eax, DWORD PTR 48[esi] 67 mov eax, DWORD PTR 48[esi]
68 mov ecx, DWORD PTR 52[esi]
69 bswap eax 69 bswap eax
70 bswap ecx
70 mov DWORD PTR 48[esp],eax 71 mov DWORD PTR 48[esp],eax
71 mov eax, DWORD PTR 52[esi] 72 mov DWORD PTR 52[esp],ecx
72 bswap eax
73 mov DWORD PTR 52[esp],eax
74 mov eax, DWORD PTR 56[esi] 73 mov eax, DWORD PTR 56[esi]
74 mov ecx, DWORD PTR 60[esi]
75 bswap eax 75 bswap eax
76 bswap ecx
76 mov DWORD PTR 56[esp],eax 77 mov DWORD PTR 56[esp],eax
77 mov eax, DWORD PTR 60[esi] 78 mov DWORD PTR 60[esp],ecx
78 bswap eax
79 mov DWORD PTR 60[esp],eax
80 ; We now have the X array on the stack 79 ; We now have the X array on the stack
81 ; starting at sp-4 80 ; starting at sp-4
82 mov DWORD PTR 64[esp],esi 81 mov DWORD PTR 132[esp],esi
82L001shortcut:
83 ; 83 ;
84 ; Start processing 84 ; Start processing
85 mov eax, DWORD PTR [ebp] 85 mov eax, DWORD PTR [ebp]
86 mov ecx, DWORD PTR 4[ebp]
86 ; 00_15 0 87 ; 00_15 0
87 mov esi, ecx 88 mov esi, ebx
88 mov ebp, eax 89 mov ebp, eax
89 xor esi, edx 90 xor esi, edx
90 rol ebp, 5 91 rol ebp, 5
91 and esi, ebx 92 and esi, ecx
92 add ebp, edi 93 add ebp, edi
93 ror ebx, 1 94 ror ecx, 1
94 mov edi, DWORD PTR [esp] 95 mov edi, DWORD PTR [esp]
95 ror ebx, 1 96 ror ecx, 1
96 xor esi, edx 97 xor esi, edx
97 lea ebp, DWORD PTR 1518500249[edi*1+ebp] 98 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
98 mov edi, ebx 99 mov edi, ecx
99 add esi, ebp 100 add esi, ebp
100 xor edi, ecx 101 xor edi, ebx
101 mov ebp, esi 102 mov ebp, esi
102 and edi, eax 103 and edi, eax
103 rol ebp, 5 104 rol ebp, 5
104 add ebp, edx 105 add ebp, edx
105 mov edx, DWORD PTR 4[esp] 106 mov edx, DWORD PTR 4[esp]
106 ror eax, 1 107 ror eax, 1
107 xor edi, ecx 108 xor edi, ebx
108 ror eax, 1 109 ror eax, 1
109 lea ebp, DWORD PTR 1518500249[edx*1+ebp] 110 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
110 add edi, ebp 111 add edi, ebp
111 ; 00_15 2 112 ; 00_15 2
112 mov edx, eax 113 mov edx, eax
113 mov ebp, edi 114 mov ebp, edi
114 xor edx, ebx 115 xor edx, ecx
115 rol ebp, 5 116 rol ebp, 5
116 and edx, esi 117 and edx, esi
117 add ebp, ecx 118 add ebp, ebx
118 ror esi, 1 119 ror esi, 1
119 mov ecx, DWORD PTR 8[esp] 120 mov ebx, DWORD PTR 8[esp]
120 ror esi, 1 121 ror esi, 1
121 xor edx, ebx 122 xor edx, ecx
122 lea ebp, DWORD PTR 1518500249[ecx*1+ebp] 123 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
123 mov ecx, esi 124 mov ebx, esi
124 add edx, ebp 125 add edx, ebp
125 xor ecx, eax 126 xor ebx, eax
126 mov ebp, edx 127 mov ebp, edx
127 and ecx, edi 128 and ebx, edi
128 rol ebp, 5 129 rol ebp, 5
129 add ebp, ebx 130 add ebp, ecx
130 mov ebx, DWORD PTR 12[esp] 131 mov ecx, DWORD PTR 12[esp]
131 ror edi, 1 132 ror edi, 1
132 xor ecx, eax 133 xor ebx, eax
133 ror edi, 1 134 ror edi, 1
134 lea ebp, DWORD PTR 1518500249[ebx*1+ebp] 135 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
135 add ecx, ebp 136 add ebx, ebp
136 ; 00_15 4 137 ; 00_15 4
137 mov ebx, edi 138 mov ecx, edi
138 mov ebp, ecx 139 mov ebp, ebx
139 xor ebx, esi 140 xor ecx, esi
140 rol ebp, 5 141 rol ebp, 5
141 and ebx, edx 142 and ecx, edx
142 add ebp, eax 143 add ebp, eax
143 ror edx, 1 144 ror edx, 1
144 mov eax, DWORD PTR 16[esp] 145 mov eax, DWORD PTR 16[esp]
145 ror edx, 1 146 ror edx, 1
146 xor ebx, esi 147 xor ecx, esi
147 lea ebp, DWORD PTR 1518500249[eax*1+ebp] 148 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
148 mov eax, edx 149 mov eax, edx
149 add ebx, ebp 150 add ecx, ebp
150 xor eax, edi 151 xor eax, edi
151 mov ebp, ebx 152 mov ebp, ecx
152 and eax, ecx 153 and eax, ebx
153 rol ebp, 5 154 rol ebp, 5
154 add ebp, esi 155 add ebp, esi
155 mov esi, DWORD PTR 20[esp] 156 mov esi, DWORD PTR 20[esp]
156 ror ecx, 1 157 ror ebx, 1
157 xor eax, edi 158 xor eax, edi
158 ror ecx, 1 159 ror ebx, 1
159 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 160 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
160 add eax, ebp 161 add eax, ebp
161 ; 00_15 6 162 ; 00_15 6
162 mov esi, ecx 163 mov esi, ebx
163 mov ebp, eax 164 mov ebp, eax
164 xor esi, edx 165 xor esi, edx
165 rol ebp, 5 166 rol ebp, 5
166 and esi, ebx 167 and esi, ecx
167 add ebp, edi 168 add ebp, edi
168 ror ebx, 1 169 ror ecx, 1
169 mov edi, DWORD PTR 24[esp] 170 mov edi, DWORD PTR 24[esp]
170 ror ebx, 1 171 ror ecx, 1
171 xor esi, edx 172 xor esi, edx
172 lea ebp, DWORD PTR 1518500249[edi*1+ebp] 173 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
173 mov edi, ebx 174 mov edi, ecx
174 add esi, ebp 175 add esi, ebp
175 xor edi, ecx 176 xor edi, ebx
176 mov ebp, esi 177 mov ebp, esi
177 and edi, eax 178 and edi, eax
178 rol ebp, 5 179 rol ebp, 5
179 add ebp, edx 180 add ebp, edx
180 mov edx, DWORD PTR 28[esp] 181 mov edx, DWORD PTR 28[esp]
181 ror eax, 1 182 ror eax, 1
182 xor edi, ecx 183 xor edi, ebx
183 ror eax, 1 184 ror eax, 1
184 lea ebp, DWORD PTR 1518500249[edx*1+ebp] 185 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
185 add edi, ebp 186 add edi, ebp
186 ; 00_15 8 187 ; 00_15 8
187 mov edx, eax 188 mov edx, eax
188 mov ebp, edi 189 mov ebp, edi
189 xor edx, ebx 190 xor edx, ecx
190 rol ebp, 5 191 rol ebp, 5
191 and edx, esi 192 and edx, esi
192 add ebp, ecx 193 add ebp, ebx
193 ror esi, 1 194 ror esi, 1
194 mov ecx, DWORD PTR 32[esp] 195 mov ebx, DWORD PTR 32[esp]
195 ror esi, 1 196 ror esi, 1
196 xor edx, ebx 197 xor edx, ecx
197 lea ebp, DWORD PTR 1518500249[ecx*1+ebp] 198 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
198 mov ecx, esi 199 mov ebx, esi
199 add edx, ebp 200 add edx, ebp
200 xor ecx, eax 201 xor ebx, eax
201 mov ebp, edx 202 mov ebp, edx
202 and ecx, edi 203 and ebx, edi
203 rol ebp, 5 204 rol ebp, 5
204 add ebp, ebx 205 add ebp, ecx
205 mov ebx, DWORD PTR 36[esp] 206 mov ecx, DWORD PTR 36[esp]
206 ror edi, 1 207 ror edi, 1
207 xor ecx, eax 208 xor ebx, eax
208 ror edi, 1 209 ror edi, 1
209 lea ebp, DWORD PTR 1518500249[ebx*1+ebp] 210 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
210 add ecx, ebp 211 add ebx, ebp
211 ; 00_15 10 212 ; 00_15 10
212 mov ebx, edi 213 mov ecx, edi
213 mov ebp, ecx 214 mov ebp, ebx
214 xor ebx, esi 215 xor ecx, esi
215 rol ebp, 5 216 rol ebp, 5
216 and ebx, edx 217 and ecx, edx
217 add ebp, eax 218 add ebp, eax
218 ror edx, 1 219 ror edx, 1
219 mov eax, DWORD PTR 40[esp] 220 mov eax, DWORD PTR 40[esp]
220 ror edx, 1 221 ror edx, 1
221 xor ebx, esi 222 xor ecx, esi
222 lea ebp, DWORD PTR 1518500249[eax*1+ebp] 223 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
223 mov eax, edx 224 mov eax, edx
224 add ebx, ebp 225 add ecx, ebp
225 xor eax, edi 226 xor eax, edi
226 mov ebp, ebx 227 mov ebp, ecx
227 and eax, ecx 228 and eax, ebx
228 rol ebp, 5 229 rol ebp, 5
229 add ebp, esi 230 add ebp, esi
230 mov esi, DWORD PTR 44[esp] 231 mov esi, DWORD PTR 44[esp]
231 ror ecx, 1 232 ror ebx, 1
232 xor eax, edi 233 xor eax, edi
233 ror ecx, 1 234 ror ebx, 1
234 lea ebp, DWORD PTR 1518500249[esi*1+ebp] 235 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
235 add eax, ebp 236 add eax, ebp
236 ; 00_15 12 237 ; 00_15 12
237 mov esi, ecx 238 mov esi, ebx
238 mov ebp, eax 239 mov ebp, eax
239 xor esi, edx 240 xor esi, edx
240 rol ebp, 5 241 rol ebp, 5
241 and esi, ebx 242 and esi, ecx
242 add ebp, edi 243 add ebp, edi
243 ror ebx, 1 244 ror ecx, 1
244 mov edi, DWORD PTR 48[esp] 245 mov edi, DWORD PTR 48[esp]
245 ror ebx, 1 246 ror ecx, 1
246 xor esi, edx 247 xor esi, edx
247 lea ebp, DWORD PTR 1518500249[edi*1+ebp] 248 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
248 mov edi, ebx 249 mov edi, ecx
249 add esi, ebp 250 add esi, ebp
250 xor edi, ecx 251 xor edi, ebx
251 mov ebp, esi 252 mov ebp, esi
252 and edi, eax 253 and edi, eax
253 rol ebp, 5 254 rol ebp, 5
254 add ebp, edx 255 add ebp, edx
255 mov edx, DWORD PTR 52[esp] 256 mov edx, DWORD PTR 52[esp]
256 ror eax, 1 257 ror eax, 1
257 xor edi, ecx 258 xor edi, ebx
258 ror eax, 1 259 ror eax, 1
259 lea ebp, DWORD PTR 1518500249[edx*1+ebp] 260 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
260 add edi, ebp 261 add edi, ebp
261 ; 00_15 14 262 ; 00_15 14
262 mov edx, eax 263 mov edx, eax
263 mov ebp, edi 264 mov ebp, edi
264 xor edx, ebx 265 xor edx, ecx
265 rol ebp, 5 266 rol ebp, 5
266 and edx, esi 267 and edx, esi
267 add ebp, ecx 268 add ebp, ebx
268 ror esi, 1 269 ror esi, 1
269 mov ecx, DWORD PTR 56[esp] 270 mov ebx, DWORD PTR 56[esp]
270 ror esi, 1 271 ror esi, 1
271 xor edx, ebx 272 xor edx, ecx
272 lea ebp, DWORD PTR 1518500249[ecx*1+ebp] 273 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
273 mov ecx, esi 274 mov ebx, esi
274 add edx, ebp 275 add edx, ebp
275 xor ecx, eax 276 xor ebx, eax
276 mov ebp, edx 277 mov ebp, edx
277 and ecx, edi 278 and ebx, edi
278 rol ebp, 5 279 rol ebp, 5
279 add ebp, ebx 280 add ebp, ecx
280 mov ebx, DWORD PTR 60[esp] 281 mov ecx, DWORD PTR 60[esp]
281 ror edi, 1 282 ror edi, 1
282 xor ecx, eax 283 xor ebx, eax
283 ror edi, 1 284 ror edi, 1
284 lea ebp, DWORD PTR 1518500249[ebx*1+ebp] 285 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
285 add ecx, ebp 286 add ebx, ebp
286 ; 16_19 16 287 ; 16_19 16
287 nop 288 nop
288 mov ebp, DWORD PTR [esp] 289 mov ebp, DWORD PTR [esp]
289 mov ebx, DWORD PTR 8[esp] 290 mov ecx, DWORD PTR 8[esp]
290 xor ebx, ebp 291 xor ecx, ebp
291 mov ebp, DWORD PTR 32[esp] 292 mov ebp, DWORD PTR 32[esp]
292 xor ebx, ebp 293 xor ecx, ebp
293 mov ebp, DWORD PTR 52[esp] 294 mov ebp, DWORD PTR 52[esp]
294 xor ebx, ebp 295 xor ecx, ebp
295 mov ebp, edi 296 mov ebp, edi
296 rol ebx, 1 297 rol ecx, 1
297 xor ebp, esi 298 xor ebp, esi
298 mov DWORD PTR [esp],ebx 299 mov DWORD PTR [esp],ecx
299 and ebp, edx 300 and ebp, edx
300 lea ebx, DWORD PTR 1518500249[eax*1+ebx] 301 lea ecx, DWORD PTR 1518500249[eax*1+ecx]
301 xor ebp, esi 302 xor ebp, esi
302 mov eax, ecx 303 mov eax, ebx
303 add ebx, ebp 304 add ecx, ebp
304 rol eax, 5 305 rol eax, 5
305 ror edx, 1 306 ror edx, 1
306 add ebx, eax 307 add ecx, eax
307 mov eax, DWORD PTR 4[esp] 308 mov eax, DWORD PTR 4[esp]
308 mov ebp, DWORD PTR 12[esp] 309 mov ebp, DWORD PTR 12[esp]
309 xor eax, ebp 310 xor eax, ebp
@@ -316,14 +317,14 @@ L000start:
316 mov ebp, edx 317 mov ebp, edx
317 xor ebp, edi 318 xor ebp, edi
318 mov DWORD PTR 4[esp],eax 319 mov DWORD PTR 4[esp],eax
319 and ebp, ecx 320 and ebp, ebx
320 lea eax, DWORD PTR 1518500249[esi*1+eax] 321 lea eax, DWORD PTR 1518500249[esi*1+eax]
321 xor ebp, edi 322 xor ebp, edi
322 mov esi, ebx 323 mov esi, ecx
323 rol esi, 5 324 rol esi, 5
324 ror ecx, 1 325 ror ebx, 1
325 add eax, esi 326 add eax, esi
326 ror ecx, 1 327 ror ebx, 1
327 add eax, ebp 328 add eax, ebp
328 ; 16_19 18 329 ; 16_19 18
329 mov ebp, DWORD PTR 8[esp] 330 mov ebp, DWORD PTR 8[esp]
@@ -333,17 +334,17 @@ L000start:
333 xor esi, ebp 334 xor esi, ebp
334 mov ebp, DWORD PTR 60[esp] 335 mov ebp, DWORD PTR 60[esp]
335 xor esi, ebp 336 xor esi, ebp
336 mov ebp, ecx 337 mov ebp, ebx
337 rol esi, 1 338 rol esi, 1
338 xor ebp, edx 339 xor ebp, edx
339 mov DWORD PTR 8[esp],esi 340 mov DWORD PTR 8[esp],esi
340 and ebp, ebx 341 and ebp, ecx
341 lea esi, DWORD PTR 1518500249[edi*1+esi] 342 lea esi, DWORD PTR 1518500249[edi*1+esi]
342 xor ebp, edx 343 xor ebp, edx
343 mov edi, eax 344 mov edi, eax
344 add esi, ebp 345 add esi, ebp
345 rol edi, 5 346 rol edi, 5
346 ror ebx, 1 347 ror ecx, 1
347 add esi, edi 348 add esi, edi
348 mov edi, DWORD PTR 12[esp] 349 mov edi, DWORD PTR 12[esp]
349 mov ebp, DWORD PTR 20[esp] 350 mov ebp, DWORD PTR 20[esp]
@@ -351,15 +352,15 @@ L000start:
351 mov ebp, DWORD PTR 44[esp] 352 mov ebp, DWORD PTR 44[esp]
352 xor edi, ebp 353 xor edi, ebp
353 mov ebp, DWORD PTR [esp] 354 mov ebp, DWORD PTR [esp]
354 ror ebx, 1 355 ror ecx, 1
355 xor edi, ebp 356 xor edi, ebp
356 rol edi, 1 357 rol edi, 1
357 mov ebp, ebx 358 mov ebp, ecx
358 xor ebp, ecx 359 xor ebp, ebx
359 mov DWORD PTR 12[esp],edi 360 mov DWORD PTR 12[esp],edi
360 and ebp, eax 361 and ebp, eax
361 lea edi, DWORD PTR 1518500249[edx*1+edi] 362 lea edi, DWORD PTR 1518500249[edx*1+edi]
362 xor ebp, ecx 363 xor ebp, ebx
363 mov edx, esi 364 mov edx, esi
364 rol edx, 5 365 rol edx, 5
365 ror eax, 1 366 ror eax, 1
@@ -378,54 +379,54 @@ L000start:
378 rol edx, 1 379 rol edx, 1
379 xor ebp, eax 380 xor ebp, eax
380 mov DWORD PTR 16[esp],edx 381 mov DWORD PTR 16[esp],edx
381 xor ebp, ebx 382 xor ebp, ecx
382 lea edx, DWORD PTR 1859775393[ecx*1+edx] 383 lea edx, DWORD PTR 1859775393[ebx*1+edx]
383 mov ecx, edi 384 mov ebx, edi
384 rol ecx, 5 385 rol ebx, 5
385 ror esi, 1 386 ror esi, 1
386 add ecx, ebp 387 add ebx, ebp
387 ror esi, 1 388 ror esi, 1
388 add edx, ecx 389 add edx, ebx
389 ; 20_39 21 390 ; 20_39 21
390 mov ecx, DWORD PTR 20[esp] 391 mov ebx, DWORD PTR 20[esp]
391 mov ebp, DWORD PTR 28[esp] 392 mov ebp, DWORD PTR 28[esp]
392 xor ecx, ebp 393 xor ebx, ebp
393 mov ebp, DWORD PTR 52[esp] 394 mov ebp, DWORD PTR 52[esp]
394 xor ecx, ebp 395 xor ebx, ebp
395 mov ebp, DWORD PTR 8[esp] 396 mov ebp, DWORD PTR 8[esp]
396 xor ecx, ebp 397 xor ebx, ebp
397 mov ebp, edi 398 mov ebp, edi
398 rol ecx, 1 399 rol ebx, 1
399 xor ebp, esi 400 xor ebp, esi
400 mov DWORD PTR 20[esp],ecx 401 mov DWORD PTR 20[esp],ebx
401 xor ebp, eax 402 xor ebp, eax
402 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 403 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
403 mov ebx, edx 404 mov ecx, edx
404 rol ebx, 5 405 rol ecx, 5
405 ror edi, 1 406 ror edi, 1
406 add ebx, ebp 407 add ecx, ebp
407 ror edi, 1 408 ror edi, 1
408 add ecx, ebx 409 add ebx, ecx
409 ; 20_39 22 410 ; 20_39 22
410 mov ebx, DWORD PTR 24[esp] 411 mov ecx, DWORD PTR 24[esp]
411 mov ebp, DWORD PTR 32[esp] 412 mov ebp, DWORD PTR 32[esp]
412 xor ebx, ebp 413 xor ecx, ebp
413 mov ebp, DWORD PTR 56[esp] 414 mov ebp, DWORD PTR 56[esp]
414 xor ebx, ebp 415 xor ecx, ebp
415 mov ebp, DWORD PTR 12[esp] 416 mov ebp, DWORD PTR 12[esp]
416 xor ebx, ebp 417 xor ecx, ebp
417 mov ebp, edx 418 mov ebp, edx
418 rol ebx, 1 419 rol ecx, 1
419 xor ebp, edi 420 xor ebp, edi
420 mov DWORD PTR 24[esp],ebx 421 mov DWORD PTR 24[esp],ecx
421 xor ebp, esi 422 xor ebp, esi
422 lea ebx, DWORD PTR 1859775393[eax*1+ebx] 423 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
423 mov eax, ecx 424 mov eax, ebx
424 rol eax, 5 425 rol eax, 5
425 ror edx, 1 426 ror edx, 1
426 add eax, ebp 427 add eax, ebp
427 ror edx, 1 428 ror edx, 1
428 add ebx, eax 429 add ecx, eax
429 ; 20_39 23 430 ; 20_39 23
430 mov eax, DWORD PTR 28[esp] 431 mov eax, DWORD PTR 28[esp]
431 mov ebp, DWORD PTR 36[esp] 432 mov ebp, DWORD PTR 36[esp]
@@ -434,17 +435,17 @@ L000start:
434 xor eax, ebp 435 xor eax, ebp
435 mov ebp, DWORD PTR 16[esp] 436 mov ebp, DWORD PTR 16[esp]
436 xor eax, ebp 437 xor eax, ebp
437 mov ebp, ecx 438 mov ebp, ebx
438 rol eax, 1 439 rol eax, 1
439 xor ebp, edx 440 xor ebp, edx
440 mov DWORD PTR 28[esp],eax 441 mov DWORD PTR 28[esp],eax
441 xor ebp, edi 442 xor ebp, edi
442 lea eax, DWORD PTR 1859775393[esi*1+eax] 443 lea eax, DWORD PTR 1859775393[esi*1+eax]
443 mov esi, ebx 444 mov esi, ecx
444 rol esi, 5 445 rol esi, 5
445 ror ecx, 1 446 ror ebx, 1
446 add esi, ebp 447 add esi, ebp
447 ror ecx, 1 448 ror ebx, 1
448 add eax, esi 449 add eax, esi
449 ; 20_39 24 450 ; 20_39 24
450 mov esi, DWORD PTR 32[esp] 451 mov esi, DWORD PTR 32[esp]
@@ -454,17 +455,17 @@ L000start:
454 xor esi, ebp 455 xor esi, ebp
455 mov ebp, DWORD PTR 20[esp] 456 mov ebp, DWORD PTR 20[esp]
456 xor esi, ebp 457 xor esi, ebp
457 mov ebp, ebx 458 mov ebp, ecx
458 rol esi, 1 459 rol esi, 1
459 xor ebp, ecx 460 xor ebp, ebx
460 mov DWORD PTR 32[esp],esi 461 mov DWORD PTR 32[esp],esi
461 xor ebp, edx 462 xor ebp, edx
462 lea esi, DWORD PTR 1859775393[edi*1+esi] 463 lea esi, DWORD PTR 1859775393[edi*1+esi]
463 mov edi, eax 464 mov edi, eax
464 rol edi, 5 465 rol edi, 5
465 ror ebx, 1 466 ror ecx, 1
466 add edi, ebp 467 add edi, ebp
467 ror ebx, 1 468 ror ecx, 1
468 add esi, edi 469 add esi, edi
469 ; 20_39 25 470 ; 20_39 25
470 mov edi, DWORD PTR 36[esp] 471 mov edi, DWORD PTR 36[esp]
@@ -476,9 +477,9 @@ L000start:
476 xor edi, ebp 477 xor edi, ebp
477 mov ebp, eax 478 mov ebp, eax
478 rol edi, 1 479 rol edi, 1
479 xor ebp, ebx
480 mov DWORD PTR 36[esp],edi
481 xor ebp, ecx 480 xor ebp, ecx
481 mov DWORD PTR 36[esp],edi
482 xor ebp, ebx
482 lea edi, DWORD PTR 1859775393[edx*1+edi] 483 lea edi, DWORD PTR 1859775393[edx*1+edi]
483 mov edx, esi 484 mov edx, esi
484 rol edx, 5 485 rol edx, 5
@@ -498,54 +499,54 @@ L000start:
498 rol edx, 1 499 rol edx, 1
499 xor ebp, eax 500 xor ebp, eax
500 mov DWORD PTR 40[esp],edx 501 mov DWORD PTR 40[esp],edx
501 xor ebp, ebx 502 xor ebp, ecx
502 lea edx, DWORD PTR 1859775393[ecx*1+edx] 503 lea edx, DWORD PTR 1859775393[ebx*1+edx]
503 mov ecx, edi 504 mov ebx, edi
504 rol ecx, 5 505 rol ebx, 5
505 ror esi, 1 506 ror esi, 1
506 add ecx, ebp 507 add ebx, ebp
507 ror esi, 1 508 ror esi, 1
508 add edx, ecx 509 add edx, ebx
509 ; 20_39 27 510 ; 20_39 27
510 mov ecx, DWORD PTR 44[esp] 511 mov ebx, DWORD PTR 44[esp]
511 mov ebp, DWORD PTR 52[esp] 512 mov ebp, DWORD PTR 52[esp]
512 xor ecx, ebp 513 xor ebx, ebp
513 mov ebp, DWORD PTR 12[esp] 514 mov ebp, DWORD PTR 12[esp]
514 xor ecx, ebp 515 xor ebx, ebp
515 mov ebp, DWORD PTR 32[esp] 516 mov ebp, DWORD PTR 32[esp]
516 xor ecx, ebp 517 xor ebx, ebp
517 mov ebp, edi 518 mov ebp, edi
518 rol ecx, 1 519 rol ebx, 1
519 xor ebp, esi 520 xor ebp, esi
520 mov DWORD PTR 44[esp],ecx 521 mov DWORD PTR 44[esp],ebx
521 xor ebp, eax 522 xor ebp, eax
522 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 523 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
523 mov ebx, edx 524 mov ecx, edx
524 rol ebx, 5 525 rol ecx, 5
525 ror edi, 1 526 ror edi, 1
526 add ebx, ebp 527 add ecx, ebp
527 ror edi, 1 528 ror edi, 1
528 add ecx, ebx 529 add ebx, ecx
529 ; 20_39 28 530 ; 20_39 28
530 mov ebx, DWORD PTR 48[esp] 531 mov ecx, DWORD PTR 48[esp]
531 mov ebp, DWORD PTR 56[esp] 532 mov ebp, DWORD PTR 56[esp]
532 xor ebx, ebp 533 xor ecx, ebp
533 mov ebp, DWORD PTR 16[esp] 534 mov ebp, DWORD PTR 16[esp]
534 xor ebx, ebp 535 xor ecx, ebp
535 mov ebp, DWORD PTR 36[esp] 536 mov ebp, DWORD PTR 36[esp]
536 xor ebx, ebp 537 xor ecx, ebp
537 mov ebp, edx 538 mov ebp, edx
538 rol ebx, 1 539 rol ecx, 1
539 xor ebp, edi 540 xor ebp, edi
540 mov DWORD PTR 48[esp],ebx 541 mov DWORD PTR 48[esp],ecx
541 xor ebp, esi 542 xor ebp, esi
542 lea ebx, DWORD PTR 1859775393[eax*1+ebx] 543 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
543 mov eax, ecx 544 mov eax, ebx
544 rol eax, 5 545 rol eax, 5
545 ror edx, 1 546 ror edx, 1
546 add eax, ebp 547 add eax, ebp
547 ror edx, 1 548 ror edx, 1
548 add ebx, eax 549 add ecx, eax
549 ; 20_39 29 550 ; 20_39 29
550 mov eax, DWORD PTR 52[esp] 551 mov eax, DWORD PTR 52[esp]
551 mov ebp, DWORD PTR 60[esp] 552 mov ebp, DWORD PTR 60[esp]
@@ -554,17 +555,17 @@ L000start:
554 xor eax, ebp 555 xor eax, ebp
555 mov ebp, DWORD PTR 40[esp] 556 mov ebp, DWORD PTR 40[esp]
556 xor eax, ebp 557 xor eax, ebp
557 mov ebp, ecx 558 mov ebp, ebx
558 rol eax, 1 559 rol eax, 1
559 xor ebp, edx 560 xor ebp, edx
560 mov DWORD PTR 52[esp],eax 561 mov DWORD PTR 52[esp],eax
561 xor ebp, edi 562 xor ebp, edi
562 lea eax, DWORD PTR 1859775393[esi*1+eax] 563 lea eax, DWORD PTR 1859775393[esi*1+eax]
563 mov esi, ebx 564 mov esi, ecx
564 rol esi, 5 565 rol esi, 5
565 ror ecx, 1 566 ror ebx, 1
566 add esi, ebp 567 add esi, ebp
567 ror ecx, 1 568 ror ebx, 1
568 add eax, esi 569 add eax, esi
569 ; 20_39 30 570 ; 20_39 30
570 mov esi, DWORD PTR 56[esp] 571 mov esi, DWORD PTR 56[esp]
@@ -574,17 +575,17 @@ L000start:
574 xor esi, ebp 575 xor esi, ebp
575 mov ebp, DWORD PTR 44[esp] 576 mov ebp, DWORD PTR 44[esp]
576 xor esi, ebp 577 xor esi, ebp
577 mov ebp, ebx 578 mov ebp, ecx
578 rol esi, 1 579 rol esi, 1
579 xor ebp, ecx 580 xor ebp, ebx
580 mov DWORD PTR 56[esp],esi 581 mov DWORD PTR 56[esp],esi
581 xor ebp, edx 582 xor ebp, edx
582 lea esi, DWORD PTR 1859775393[edi*1+esi] 583 lea esi, DWORD PTR 1859775393[edi*1+esi]
583 mov edi, eax 584 mov edi, eax
584 rol edi, 5 585 rol edi, 5
585 ror ebx, 1 586 ror ecx, 1
586 add edi, ebp 587 add edi, ebp
587 ror ebx, 1 588 ror ecx, 1
588 add esi, edi 589 add esi, edi
589 ; 20_39 31 590 ; 20_39 31
590 mov edi, DWORD PTR 60[esp] 591 mov edi, DWORD PTR 60[esp]
@@ -596,9 +597,9 @@ L000start:
596 xor edi, ebp 597 xor edi, ebp
597 mov ebp, eax 598 mov ebp, eax
598 rol edi, 1 599 rol edi, 1
599 xor ebp, ebx
600 mov DWORD PTR 60[esp],edi
601 xor ebp, ecx 600 xor ebp, ecx
601 mov DWORD PTR 60[esp],edi
602 xor ebp, ebx
602 lea edi, DWORD PTR 1859775393[edx*1+edi] 603 lea edi, DWORD PTR 1859775393[edx*1+edi]
603 mov edx, esi 604 mov edx, esi
604 rol edx, 5 605 rol edx, 5
@@ -618,54 +619,54 @@ L000start:
618 rol edx, 1 619 rol edx, 1
619 xor ebp, eax 620 xor ebp, eax
620 mov DWORD PTR [esp],edx 621 mov DWORD PTR [esp],edx
621 xor ebp, ebx 622 xor ebp, ecx
622 lea edx, DWORD PTR 1859775393[ecx*1+edx] 623 lea edx, DWORD PTR 1859775393[ebx*1+edx]
623 mov ecx, edi 624 mov ebx, edi
624 rol ecx, 5 625 rol ebx, 5
625 ror esi, 1 626 ror esi, 1
626 add ecx, ebp 627 add ebx, ebp
627 ror esi, 1 628 ror esi, 1
628 add edx, ecx 629 add edx, ebx
629 ; 20_39 33 630 ; 20_39 33
630 mov ecx, DWORD PTR 4[esp] 631 mov ebx, DWORD PTR 4[esp]
631 mov ebp, DWORD PTR 12[esp] 632 mov ebp, DWORD PTR 12[esp]
632 xor ecx, ebp 633 xor ebx, ebp
633 mov ebp, DWORD PTR 36[esp] 634 mov ebp, DWORD PTR 36[esp]
634 xor ecx, ebp 635 xor ebx, ebp
635 mov ebp, DWORD PTR 56[esp] 636 mov ebp, DWORD PTR 56[esp]
636 xor ecx, ebp 637 xor ebx, ebp
637 mov ebp, edi 638 mov ebp, edi
638 rol ecx, 1 639 rol ebx, 1
639 xor ebp, esi 640 xor ebp, esi
640 mov DWORD PTR 4[esp],ecx 641 mov DWORD PTR 4[esp],ebx
641 xor ebp, eax 642 xor ebp, eax
642 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 643 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
643 mov ebx, edx 644 mov ecx, edx
644 rol ebx, 5 645 rol ecx, 5
645 ror edi, 1 646 ror edi, 1
646 add ebx, ebp 647 add ecx, ebp
647 ror edi, 1 648 ror edi, 1
648 add ecx, ebx 649 add ebx, ecx
649 ; 20_39 34 650 ; 20_39 34
650 mov ebx, DWORD PTR 8[esp] 651 mov ecx, DWORD PTR 8[esp]
651 mov ebp, DWORD PTR 16[esp] 652 mov ebp, DWORD PTR 16[esp]
652 xor ebx, ebp 653 xor ecx, ebp
653 mov ebp, DWORD PTR 40[esp] 654 mov ebp, DWORD PTR 40[esp]
654 xor ebx, ebp 655 xor ecx, ebp
655 mov ebp, DWORD PTR 60[esp] 656 mov ebp, DWORD PTR 60[esp]
656 xor ebx, ebp 657 xor ecx, ebp
657 mov ebp, edx 658 mov ebp, edx
658 rol ebx, 1 659 rol ecx, 1
659 xor ebp, edi 660 xor ebp, edi
660 mov DWORD PTR 8[esp],ebx 661 mov DWORD PTR 8[esp],ecx
661 xor ebp, esi 662 xor ebp, esi
662 lea ebx, DWORD PTR 1859775393[eax*1+ebx] 663 lea ecx, DWORD PTR 1859775393[eax*1+ecx]
663 mov eax, ecx 664 mov eax, ebx
664 rol eax, 5 665 rol eax, 5
665 ror edx, 1 666 ror edx, 1
666 add eax, ebp 667 add eax, ebp
667 ror edx, 1 668 ror edx, 1
668 add ebx, eax 669 add ecx, eax
669 ; 20_39 35 670 ; 20_39 35
670 mov eax, DWORD PTR 12[esp] 671 mov eax, DWORD PTR 12[esp]
671 mov ebp, DWORD PTR 20[esp] 672 mov ebp, DWORD PTR 20[esp]
@@ -674,17 +675,17 @@ L000start:
674 xor eax, ebp 675 xor eax, ebp
675 mov ebp, DWORD PTR [esp] 676 mov ebp, DWORD PTR [esp]
676 xor eax, ebp 677 xor eax, ebp
677 mov ebp, ecx 678 mov ebp, ebx
678 rol eax, 1 679 rol eax, 1
679 xor ebp, edx 680 xor ebp, edx
680 mov DWORD PTR 12[esp],eax 681 mov DWORD PTR 12[esp],eax
681 xor ebp, edi 682 xor ebp, edi
682 lea eax, DWORD PTR 1859775393[esi*1+eax] 683 lea eax, DWORD PTR 1859775393[esi*1+eax]
683 mov esi, ebx 684 mov esi, ecx
684 rol esi, 5 685 rol esi, 5
685 ror ecx, 1 686 ror ebx, 1
686 add esi, ebp 687 add esi, ebp
687 ror ecx, 1 688 ror ebx, 1
688 add eax, esi 689 add eax, esi
689 ; 20_39 36 690 ; 20_39 36
690 mov esi, DWORD PTR 16[esp] 691 mov esi, DWORD PTR 16[esp]
@@ -694,17 +695,17 @@ L000start:
694 xor esi, ebp 695 xor esi, ebp
695 mov ebp, DWORD PTR 4[esp] 696 mov ebp, DWORD PTR 4[esp]
696 xor esi, ebp 697 xor esi, ebp
697 mov ebp, ebx 698 mov ebp, ecx
698 rol esi, 1 699 rol esi, 1
699 xor ebp, ecx 700 xor ebp, ebx
700 mov DWORD PTR 16[esp],esi 701 mov DWORD PTR 16[esp],esi
701 xor ebp, edx 702 xor ebp, edx
702 lea esi, DWORD PTR 1859775393[edi*1+esi] 703 lea esi, DWORD PTR 1859775393[edi*1+esi]
703 mov edi, eax 704 mov edi, eax
704 rol edi, 5 705 rol edi, 5
705 ror ebx, 1 706 ror ecx, 1
706 add edi, ebp 707 add edi, ebp
707 ror ebx, 1 708 ror ecx, 1
708 add esi, edi 709 add esi, edi
709 ; 20_39 37 710 ; 20_39 37
710 mov edi, DWORD PTR 20[esp] 711 mov edi, DWORD PTR 20[esp]
@@ -716,9 +717,9 @@ L000start:
716 xor edi, ebp 717 xor edi, ebp
717 mov ebp, eax 718 mov ebp, eax
718 rol edi, 1 719 rol edi, 1
719 xor ebp, ebx
720 mov DWORD PTR 20[esp],edi
721 xor ebp, ecx 720 xor ebp, ecx
721 mov DWORD PTR 20[esp],edi
722 xor ebp, ebx
722 lea edi, DWORD PTR 1859775393[edx*1+edi] 723 lea edi, DWORD PTR 1859775393[edx*1+edi]
723 mov edx, esi 724 mov edx, esi
724 rol edx, 5 725 rol edx, 5
@@ -738,57 +739,57 @@ L000start:
738 rol edx, 1 739 rol edx, 1
739 xor ebp, eax 740 xor ebp, eax
740 mov DWORD PTR 24[esp],edx 741 mov DWORD PTR 24[esp],edx
741 xor ebp, ebx 742 xor ebp, ecx
742 lea edx, DWORD PTR 1859775393[ecx*1+edx] 743 lea edx, DWORD PTR 1859775393[ebx*1+edx]
743 mov ecx, edi 744 mov ebx, edi
744 rol ecx, 5 745 rol ebx, 5
745 ror esi, 1 746 ror esi, 1
746 add ecx, ebp 747 add ebx, ebp
747 ror esi, 1 748 ror esi, 1
748 add edx, ecx 749 add edx, ebx
749 ; 20_39 39 750 ; 20_39 39
750 mov ecx, DWORD PTR 28[esp] 751 mov ebx, DWORD PTR 28[esp]
751 mov ebp, DWORD PTR 36[esp] 752 mov ebp, DWORD PTR 36[esp]
752 xor ecx, ebp 753 xor ebx, ebp
753 mov ebp, DWORD PTR 60[esp] 754 mov ebp, DWORD PTR 60[esp]
754 xor ecx, ebp 755 xor ebx, ebp
755 mov ebp, DWORD PTR 16[esp] 756 mov ebp, DWORD PTR 16[esp]
756 xor ecx, ebp 757 xor ebx, ebp
757 mov ebp, edi 758 mov ebp, edi
758 rol ecx, 1 759 rol ebx, 1
759 xor ebp, esi 760 xor ebp, esi
760 mov DWORD PTR 28[esp],ecx 761 mov DWORD PTR 28[esp],ebx
761 xor ebp, eax 762 xor ebp, eax
762 lea ecx, DWORD PTR 1859775393[ebx*1+ecx] 763 lea ebx, DWORD PTR 1859775393[ecx*1+ebx]
763 mov ebx, edx 764 mov ecx, edx
764 rol ebx, 5 765 rol ecx, 5
765 ror edi, 1 766 ror edi, 1
766 add ebx, ebp 767 add ecx, ebp
767 ror edi, 1 768 ror edi, 1
768 add ecx, ebx 769 add ebx, ecx
769 ; 40_59 40 770 ; 40_59 40
770 mov ebx, DWORD PTR 32[esp] 771 mov ecx, DWORD PTR 32[esp]
771 mov ebp, DWORD PTR 40[esp] 772 mov ebp, DWORD PTR 40[esp]
772 xor ebx, ebp 773 xor ecx, ebp
773 mov ebp, DWORD PTR [esp] 774 mov ebp, DWORD PTR [esp]
774 xor ebx, ebp 775 xor ecx, ebp
775 mov ebp, DWORD PTR 20[esp] 776 mov ebp, DWORD PTR 20[esp]
776 xor ebx, ebp 777 xor ecx, ebp
777 mov ebp, edx 778 mov ebp, edx
778 rol ebx, 1 779 rol ecx, 1
779 or ebp, edi 780 or ebp, edi
780 mov DWORD PTR 32[esp],ebx 781 mov DWORD PTR 32[esp],ecx
781 and ebp, esi 782 and ebp, esi
782 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 783 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
783 mov eax, edx 784 mov eax, edx
784 ror edx, 1 785 ror edx, 1
785 and eax, edi 786 and eax, edi
786 or ebp, eax 787 or ebp, eax
787 mov eax, ecx 788 mov eax, ebx
788 rol eax, 5 789 rol eax, 5
789 add ebp, eax 790 add ebp, eax
790 mov eax, DWORD PTR 36[esp] 791 mov eax, DWORD PTR 36[esp]
791 add ebx, ebp 792 add ecx, ebp
792 mov ebp, DWORD PTR 44[esp] 793 mov ebp, DWORD PTR 44[esp]
793 xor eax, ebp 794 xor eax, ebp
794 mov ebp, DWORD PTR 4[esp] 795 mov ebp, DWORD PTR 4[esp]
@@ -797,19 +798,19 @@ L000start:
797 ror edx, 1 798 ror edx, 1
798 xor eax, ebp 799 xor eax, ebp
799 rol eax, 1 800 rol eax, 1
800 mov ebp, ecx 801 mov ebp, ebx
801 mov DWORD PTR 36[esp],eax 802 mov DWORD PTR 36[esp],eax
802 or ebp, edx 803 or ebp, edx
803 lea eax, DWORD PTR 2400959708[esi*1+eax] 804 lea eax, DWORD PTR 2400959708[esi*1+eax]
804 mov esi, ecx 805 mov esi, ebx
805 and ebp, edi 806 and ebp, edi
806 and esi, edx 807 and esi, edx
807 or ebp, esi 808 or ebp, esi
808 mov esi, ebx 809 mov esi, ecx
809 rol esi, 5 810 rol esi, 5
810 ror ecx, 1 811 ror ebx, 1
811 add ebp, esi 812 add ebp, esi
812 ror ecx, 1 813 ror ebx, 1
813 add eax, ebp 814 add eax, ebp
814 ; 40_59 41 815 ; 40_59 41
815 ; 40_59 42 816 ; 40_59 42
@@ -820,15 +821,15 @@ L000start:
820 xor esi, ebp 821 xor esi, ebp
821 mov ebp, DWORD PTR 28[esp] 822 mov ebp, DWORD PTR 28[esp]
822 xor esi, ebp 823 xor esi, ebp
823 mov ebp, ebx 824 mov ebp, ecx
824 rol esi, 1 825 rol esi, 1
825 or ebp, ecx 826 or ebp, ebx
826 mov DWORD PTR 40[esp],esi 827 mov DWORD PTR 40[esp],esi
827 and ebp, edx 828 and ebp, edx
828 lea esi, DWORD PTR 2400959708[edi*1+esi] 829 lea esi, DWORD PTR 2400959708[edi*1+esi]
829 mov edi, ebx 830 mov edi, ecx
830 ror ebx, 1 831 ror ecx, 1
831 and edi, ecx 832 and edi, ebx
832 or ebp, edi 833 or ebp, edi
833 mov edi, eax 834 mov edi, eax
834 rol edi, 5 835 rol edi, 5
@@ -840,16 +841,16 @@ L000start:
840 mov ebp, DWORD PTR 12[esp] 841 mov ebp, DWORD PTR 12[esp]
841 xor edi, ebp 842 xor edi, ebp
842 mov ebp, DWORD PTR 32[esp] 843 mov ebp, DWORD PTR 32[esp]
843 ror ebx, 1 844 ror ecx, 1
844 xor edi, ebp 845 xor edi, ebp
845 rol edi, 1 846 rol edi, 1
846 mov ebp, eax 847 mov ebp, eax
847 mov DWORD PTR 44[esp],edi 848 mov DWORD PTR 44[esp],edi
848 or ebp, ebx 849 or ebp, ecx
849 lea edi, DWORD PTR 2400959708[edx*1+edi] 850 lea edi, DWORD PTR 2400959708[edx*1+edi]
850 mov edx, eax 851 mov edx, eax
851 and ebp, ecx 852 and ebp, ebx
852 and edx, ebx 853 and edx, ecx
853 or ebp, edx 854 or ebp, edx
854 mov edx, esi 855 mov edx, esi
855 rol edx, 5 856 rol edx, 5
@@ -870,63 +871,63 @@ L000start:
870 rol edx, 1 871 rol edx, 1
871 or ebp, eax 872 or ebp, eax
872 mov DWORD PTR 48[esp],edx 873 mov DWORD PTR 48[esp],edx
873 and ebp, ebx 874 and ebp, ecx
874 lea edx, DWORD PTR 2400959708[ecx*1+edx] 875 lea edx, DWORD PTR 2400959708[ebx*1+edx]
875 mov ecx, esi 876 mov ebx, esi
876 ror esi, 1 877 ror esi, 1
877 and ecx, eax 878 and ebx, eax
878 or ebp, ecx 879 or ebp, ebx
879 mov ecx, edi 880 mov ebx, edi
880 rol ecx, 5 881 rol ebx, 5
881 add ebp, ecx 882 add ebp, ebx
882 mov ecx, DWORD PTR 52[esp] 883 mov ebx, DWORD PTR 52[esp]
883 add edx, ebp 884 add edx, ebp
884 mov ebp, DWORD PTR 60[esp] 885 mov ebp, DWORD PTR 60[esp]
885 xor ecx, ebp 886 xor ebx, ebp
886 mov ebp, DWORD PTR 20[esp] 887 mov ebp, DWORD PTR 20[esp]
887 xor ecx, ebp 888 xor ebx, ebp
888 mov ebp, DWORD PTR 40[esp] 889 mov ebp, DWORD PTR 40[esp]
889 ror esi, 1 890 ror esi, 1
890 xor ecx, ebp 891 xor ebx, ebp
891 rol ecx, 1 892 rol ebx, 1
892 mov ebp, edi 893 mov ebp, edi
893 mov DWORD PTR 52[esp],ecx 894 mov DWORD PTR 52[esp],ebx
894 or ebp, esi 895 or ebp, esi
895 lea ecx, DWORD PTR 2400959708[ebx*1+ecx] 896 lea ebx, DWORD PTR 2400959708[ecx*1+ebx]
896 mov ebx, edi 897 mov ecx, edi
897 and ebp, eax 898 and ebp, eax
898 and ebx, esi 899 and ecx, esi
899 or ebp, ebx 900 or ebp, ecx
900 mov ebx, edx 901 mov ecx, edx
901 rol ebx, 5 902 rol ecx, 5
902 ror edi, 1 903 ror edi, 1
903 add ebp, ebx 904 add ebp, ecx
904 ror edi, 1 905 ror edi, 1
905 add ecx, ebp 906 add ebx, ebp
906 ; 40_59 45 907 ; 40_59 45
907 ; 40_59 46 908 ; 40_59 46
908 mov ebx, DWORD PTR 56[esp] 909 mov ecx, DWORD PTR 56[esp]
909 mov ebp, DWORD PTR [esp] 910 mov ebp, DWORD PTR [esp]
910 xor ebx, ebp 911 xor ecx, ebp
911 mov ebp, DWORD PTR 24[esp] 912 mov ebp, DWORD PTR 24[esp]
912 xor ebx, ebp 913 xor ecx, ebp
913 mov ebp, DWORD PTR 44[esp] 914 mov ebp, DWORD PTR 44[esp]
914 xor ebx, ebp 915 xor ecx, ebp
915 mov ebp, edx 916 mov ebp, edx
916 rol ebx, 1 917 rol ecx, 1
917 or ebp, edi 918 or ebp, edi
918 mov DWORD PTR 56[esp],ebx 919 mov DWORD PTR 56[esp],ecx
919 and ebp, esi 920 and ebp, esi
920 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 921 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
921 mov eax, edx 922 mov eax, edx
922 ror edx, 1 923 ror edx, 1
923 and eax, edi 924 and eax, edi
924 or ebp, eax 925 or ebp, eax
925 mov eax, ecx 926 mov eax, ebx
926 rol eax, 5 927 rol eax, 5
927 add ebp, eax 928 add ebp, eax
928 mov eax, DWORD PTR 60[esp] 929 mov eax, DWORD PTR 60[esp]
929 add ebx, ebp 930 add ecx, ebp
930 mov ebp, DWORD PTR 4[esp] 931 mov ebp, DWORD PTR 4[esp]
931 xor eax, ebp 932 xor eax, ebp
932 mov ebp, DWORD PTR 28[esp] 933 mov ebp, DWORD PTR 28[esp]
@@ -935,19 +936,19 @@ L000start:
935 ror edx, 1 936 ror edx, 1
936 xor eax, ebp 937 xor eax, ebp
937 rol eax, 1 938 rol eax, 1
938 mov ebp, ecx 939 mov ebp, ebx
939 mov DWORD PTR 60[esp],eax 940 mov DWORD PTR 60[esp],eax
940 or ebp, edx 941 or ebp, edx
941 lea eax, DWORD PTR 2400959708[esi*1+eax] 942 lea eax, DWORD PTR 2400959708[esi*1+eax]
942 mov esi, ecx 943 mov esi, ebx
943 and ebp, edi 944 and ebp, edi
944 and esi, edx 945 and esi, edx
945 or ebp, esi 946 or ebp, esi
946 mov esi, ebx 947 mov esi, ecx
947 rol esi, 5 948 rol esi, 5
948 ror ecx, 1 949 ror ebx, 1
949 add ebp, esi 950 add ebp, esi
950 ror ecx, 1 951 ror ebx, 1
951 add eax, ebp 952 add eax, ebp
952 ; 40_59 47 953 ; 40_59 47
953 ; 40_59 48 954 ; 40_59 48
@@ -958,15 +959,15 @@ L000start:
958 xor esi, ebp 959 xor esi, ebp
959 mov ebp, DWORD PTR 52[esp] 960 mov ebp, DWORD PTR 52[esp]
960 xor esi, ebp 961 xor esi, ebp
961 mov ebp, ebx 962 mov ebp, ecx
962 rol esi, 1 963 rol esi, 1
963 or ebp, ecx 964 or ebp, ebx
964 mov DWORD PTR [esp],esi 965 mov DWORD PTR [esp],esi
965 and ebp, edx 966 and ebp, edx
966 lea esi, DWORD PTR 2400959708[edi*1+esi] 967 lea esi, DWORD PTR 2400959708[edi*1+esi]
967 mov edi, ebx 968 mov edi, ecx
968 ror ebx, 1 969 ror ecx, 1
969 and edi, ecx 970 and edi, ebx
970 or ebp, edi 971 or ebp, edi
971 mov edi, eax 972 mov edi, eax
972 rol edi, 5 973 rol edi, 5
@@ -978,16 +979,16 @@ L000start:
978 mov ebp, DWORD PTR 36[esp] 979 mov ebp, DWORD PTR 36[esp]
979 xor edi, ebp 980 xor edi, ebp
980 mov ebp, DWORD PTR 56[esp] 981 mov ebp, DWORD PTR 56[esp]
981 ror ebx, 1 982 ror ecx, 1
982 xor edi, ebp 983 xor edi, ebp
983 rol edi, 1 984 rol edi, 1
984 mov ebp, eax 985 mov ebp, eax
985 mov DWORD PTR 4[esp],edi 986 mov DWORD PTR 4[esp],edi
986 or ebp, ebx 987 or ebp, ecx
987 lea edi, DWORD PTR 2400959708[edx*1+edi] 988 lea edi, DWORD PTR 2400959708[edx*1+edi]
988 mov edx, eax 989 mov edx, eax
989 and ebp, ecx 990 and ebp, ebx
990 and edx, ebx 991 and edx, ecx
991 or ebp, edx 992 or ebp, edx
992 mov edx, esi 993 mov edx, esi
993 rol edx, 5 994 rol edx, 5
@@ -1008,63 +1009,63 @@ L000start:
1008 rol edx, 1 1009 rol edx, 1
1009 or ebp, eax 1010 or ebp, eax
1010 mov DWORD PTR 8[esp],edx 1011 mov DWORD PTR 8[esp],edx
1011 and ebp, ebx 1012 and ebp, ecx
1012 lea edx, DWORD PTR 2400959708[ecx*1+edx] 1013 lea edx, DWORD PTR 2400959708[ebx*1+edx]
1013 mov ecx, esi 1014 mov ebx, esi
1014 ror esi, 1 1015 ror esi, 1
1015 and ecx, eax 1016 and ebx, eax
1016 or ebp, ecx 1017 or ebp, ebx
1017 mov ecx, edi 1018 mov ebx, edi
1018 rol ecx, 5 1019 rol ebx, 5
1019 add ebp, ecx 1020 add ebp, ebx
1020 mov ecx, DWORD PTR 12[esp] 1021 mov ebx, DWORD PTR 12[esp]
1021 add edx, ebp 1022 add edx, ebp
1022 mov ebp, DWORD PTR 20[esp] 1023 mov ebp, DWORD PTR 20[esp]
1023 xor ecx, ebp 1024 xor ebx, ebp
1024 mov ebp, DWORD PTR 44[esp] 1025 mov ebp, DWORD PTR 44[esp]
1025 xor ecx, ebp 1026 xor ebx, ebp
1026 mov ebp, DWORD PTR [esp] 1027 mov ebp, DWORD PTR [esp]
1027 ror esi, 1 1028 ror esi, 1
1028 xor ecx, ebp 1029 xor ebx, ebp
1029 rol ecx, 1 1030 rol ebx, 1
1030 mov ebp, edi 1031 mov ebp, edi
1031 mov DWORD PTR 12[esp],ecx 1032 mov DWORD PTR 12[esp],ebx
1032 or ebp, esi 1033 or ebp, esi
1033 lea ecx, DWORD PTR 2400959708[ebx*1+ecx] 1034 lea ebx, DWORD PTR 2400959708[ecx*1+ebx]
1034 mov ebx, edi 1035 mov ecx, edi
1035 and ebp, eax 1036 and ebp, eax
1036 and ebx, esi 1037 and ecx, esi
1037 or ebp, ebx 1038 or ebp, ecx
1038 mov ebx, edx 1039 mov ecx, edx
1039 rol ebx, 5 1040 rol ecx, 5
1040 ror edi, 1 1041 ror edi, 1
1041 add ebp, ebx 1042 add ebp, ecx
1042 ror edi, 1 1043 ror edi, 1
1043 add ecx, ebp 1044 add ebx, ebp
1044 ; 40_59 51 1045 ; 40_59 51
1045 ; 40_59 52 1046 ; 40_59 52
1046 mov ebx, DWORD PTR 16[esp] 1047 mov ecx, DWORD PTR 16[esp]
1047 mov ebp, DWORD PTR 24[esp] 1048 mov ebp, DWORD PTR 24[esp]
1048 xor ebx, ebp 1049 xor ecx, ebp
1049 mov ebp, DWORD PTR 48[esp] 1050 mov ebp, DWORD PTR 48[esp]
1050 xor ebx, ebp 1051 xor ecx, ebp
1051 mov ebp, DWORD PTR 4[esp] 1052 mov ebp, DWORD PTR 4[esp]
1052 xor ebx, ebp 1053 xor ecx, ebp
1053 mov ebp, edx 1054 mov ebp, edx
1054 rol ebx, 1 1055 rol ecx, 1
1055 or ebp, edi 1056 or ebp, edi
1056 mov DWORD PTR 16[esp],ebx 1057 mov DWORD PTR 16[esp],ecx
1057 and ebp, esi 1058 and ebp, esi
1058 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 1059 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
1059 mov eax, edx 1060 mov eax, edx
1060 ror edx, 1 1061 ror edx, 1
1061 and eax, edi 1062 and eax, edi
1062 or ebp, eax 1063 or ebp, eax
1063 mov eax, ecx 1064 mov eax, ebx
1064 rol eax, 5 1065 rol eax, 5
1065 add ebp, eax 1066 add ebp, eax
1066 mov eax, DWORD PTR 20[esp] 1067 mov eax, DWORD PTR 20[esp]
1067 add ebx, ebp 1068 add ecx, ebp
1068 mov ebp, DWORD PTR 28[esp] 1069 mov ebp, DWORD PTR 28[esp]
1069 xor eax, ebp 1070 xor eax, ebp
1070 mov ebp, DWORD PTR 52[esp] 1071 mov ebp, DWORD PTR 52[esp]
@@ -1073,19 +1074,19 @@ L000start:
1073 ror edx, 1 1074 ror edx, 1
1074 xor eax, ebp 1075 xor eax, ebp
1075 rol eax, 1 1076 rol eax, 1
1076 mov ebp, ecx 1077 mov ebp, ebx
1077 mov DWORD PTR 20[esp],eax 1078 mov DWORD PTR 20[esp],eax
1078 or ebp, edx 1079 or ebp, edx
1079 lea eax, DWORD PTR 2400959708[esi*1+eax] 1080 lea eax, DWORD PTR 2400959708[esi*1+eax]
1080 mov esi, ecx 1081 mov esi, ebx
1081 and ebp, edi 1082 and ebp, edi
1082 and esi, edx 1083 and esi, edx
1083 or ebp, esi 1084 or ebp, esi
1084 mov esi, ebx 1085 mov esi, ecx
1085 rol esi, 5 1086 rol esi, 5
1086 ror ecx, 1 1087 ror ebx, 1
1087 add ebp, esi 1088 add ebp, esi
1088 ror ecx, 1 1089 ror ebx, 1
1089 add eax, ebp 1090 add eax, ebp
1090 ; 40_59 53 1091 ; 40_59 53
1091 ; 40_59 54 1092 ; 40_59 54
@@ -1096,15 +1097,15 @@ L000start:
1096 xor esi, ebp 1097 xor esi, ebp
1097 mov ebp, DWORD PTR 12[esp] 1098 mov ebp, DWORD PTR 12[esp]
1098 xor esi, ebp 1099 xor esi, ebp
1099 mov ebp, ebx 1100 mov ebp, ecx
1100 rol esi, 1 1101 rol esi, 1
1101 or ebp, ecx 1102 or ebp, ebx
1102 mov DWORD PTR 24[esp],esi 1103 mov DWORD PTR 24[esp],esi
1103 and ebp, edx 1104 and ebp, edx
1104 lea esi, DWORD PTR 2400959708[edi*1+esi] 1105 lea esi, DWORD PTR 2400959708[edi*1+esi]
1105 mov edi, ebx 1106 mov edi, ecx
1106 ror ebx, 1 1107 ror ecx, 1
1107 and edi, ecx 1108 and edi, ebx
1108 or ebp, edi 1109 or ebp, edi
1109 mov edi, eax 1110 mov edi, eax
1110 rol edi, 5 1111 rol edi, 5
@@ -1116,16 +1117,16 @@ L000start:
1116 mov ebp, DWORD PTR 60[esp] 1117 mov ebp, DWORD PTR 60[esp]
1117 xor edi, ebp 1118 xor edi, ebp
1118 mov ebp, DWORD PTR 16[esp] 1119 mov ebp, DWORD PTR 16[esp]
1119 ror ebx, 1 1120 ror ecx, 1
1120 xor edi, ebp 1121 xor edi, ebp
1121 rol edi, 1 1122 rol edi, 1
1122 mov ebp, eax 1123 mov ebp, eax
1123 mov DWORD PTR 28[esp],edi 1124 mov DWORD PTR 28[esp],edi
1124 or ebp, ebx 1125 or ebp, ecx
1125 lea edi, DWORD PTR 2400959708[edx*1+edi] 1126 lea edi, DWORD PTR 2400959708[edx*1+edi]
1126 mov edx, eax 1127 mov edx, eax
1127 and ebp, ecx 1128 and ebp, ebx
1128 and edx, ebx 1129 and edx, ecx
1129 or ebp, edx 1130 or ebp, edx
1130 mov edx, esi 1131 mov edx, esi
1131 rol edx, 5 1132 rol edx, 5
@@ -1146,63 +1147,63 @@ L000start:
1146 rol edx, 1 1147 rol edx, 1
1147 or ebp, eax 1148 or ebp, eax
1148 mov DWORD PTR 32[esp],edx 1149 mov DWORD PTR 32[esp],edx
1149 and ebp, ebx 1150 and ebp, ecx
1150 lea edx, DWORD PTR 2400959708[ecx*1+edx] 1151 lea edx, DWORD PTR 2400959708[ebx*1+edx]
1151 mov ecx, esi 1152 mov ebx, esi
1152 ror esi, 1 1153 ror esi, 1
1153 and ecx, eax 1154 and ebx, eax
1154 or ebp, ecx 1155 or ebp, ebx
1155 mov ecx, edi 1156 mov ebx, edi
1156 rol ecx, 5 1157 rol ebx, 5
1157 add ebp, ecx 1158 add ebp, ebx
1158 mov ecx, DWORD PTR 36[esp] 1159 mov ebx, DWORD PTR 36[esp]
1159 add edx, ebp 1160 add edx, ebp
1160 mov ebp, DWORD PTR 44[esp] 1161 mov ebp, DWORD PTR 44[esp]
1161 xor ecx, ebp 1162 xor ebx, ebp
1162 mov ebp, DWORD PTR 4[esp] 1163 mov ebp, DWORD PTR 4[esp]
1163 xor ecx, ebp 1164 xor ebx, ebp
1164 mov ebp, DWORD PTR 24[esp] 1165 mov ebp, DWORD PTR 24[esp]
1165 ror esi, 1 1166 ror esi, 1
1166 xor ecx, ebp 1167 xor ebx, ebp
1167 rol ecx, 1 1168 rol ebx, 1
1168 mov ebp, edi 1169 mov ebp, edi
1169 mov DWORD PTR 36[esp],ecx 1170 mov DWORD PTR 36[esp],ebx
1170 or ebp, esi 1171 or ebp, esi
1171 lea ecx, DWORD PTR 2400959708[ebx*1+ecx] 1172 lea ebx, DWORD PTR 2400959708[ecx*1+ebx]
1172 mov ebx, edi 1173 mov ecx, edi
1173 and ebp, eax 1174 and ebp, eax
1174 and ebx, esi 1175 and ecx, esi
1175 or ebp, ebx 1176 or ebp, ecx
1176 mov ebx, edx 1177 mov ecx, edx
1177 rol ebx, 5 1178 rol ecx, 5
1178 ror edi, 1 1179 ror edi, 1
1179 add ebp, ebx 1180 add ebp, ecx
1180 ror edi, 1 1181 ror edi, 1
1181 add ecx, ebp 1182 add ebx, ebp
1182 ; 40_59 57 1183 ; 40_59 57
1183 ; 40_59 58 1184 ; 40_59 58
1184 mov ebx, DWORD PTR 40[esp] 1185 mov ecx, DWORD PTR 40[esp]
1185 mov ebp, DWORD PTR 48[esp] 1186 mov ebp, DWORD PTR 48[esp]
1186 xor ebx, ebp 1187 xor ecx, ebp
1187 mov ebp, DWORD PTR 8[esp] 1188 mov ebp, DWORD PTR 8[esp]
1188 xor ebx, ebp 1189 xor ecx, ebp
1189 mov ebp, DWORD PTR 28[esp] 1190 mov ebp, DWORD PTR 28[esp]
1190 xor ebx, ebp 1191 xor ecx, ebp
1191 mov ebp, edx 1192 mov ebp, edx
1192 rol ebx, 1 1193 rol ecx, 1
1193 or ebp, edi 1194 or ebp, edi
1194 mov DWORD PTR 40[esp],ebx 1195 mov DWORD PTR 40[esp],ecx
1195 and ebp, esi 1196 and ebp, esi
1196 lea ebx, DWORD PTR 2400959708[eax*1+ebx] 1197 lea ecx, DWORD PTR 2400959708[eax*1+ecx]
1197 mov eax, edx 1198 mov eax, edx
1198 ror edx, 1 1199 ror edx, 1
1199 and eax, edi 1200 and eax, edi
1200 or ebp, eax 1201 or ebp, eax
1201 mov eax, ecx 1202 mov eax, ebx
1202 rol eax, 5 1203 rol eax, 5
1203 add ebp, eax 1204 add ebp, eax
1204 mov eax, DWORD PTR 44[esp] 1205 mov eax, DWORD PTR 44[esp]
1205 add ebx, ebp 1206 add ecx, ebp
1206 mov ebp, DWORD PTR 52[esp] 1207 mov ebp, DWORD PTR 52[esp]
1207 xor eax, ebp 1208 xor eax, ebp
1208 mov ebp, DWORD PTR 12[esp] 1209 mov ebp, DWORD PTR 12[esp]
@@ -1211,19 +1212,19 @@ L000start:
1211 ror edx, 1 1212 ror edx, 1
1212 xor eax, ebp 1213 xor eax, ebp
1213 rol eax, 1 1214 rol eax, 1
1214 mov ebp, ecx 1215 mov ebp, ebx
1215 mov DWORD PTR 44[esp],eax 1216 mov DWORD PTR 44[esp],eax
1216 or ebp, edx 1217 or ebp, edx
1217 lea eax, DWORD PTR 2400959708[esi*1+eax] 1218 lea eax, DWORD PTR 2400959708[esi*1+eax]
1218 mov esi, ecx 1219 mov esi, ebx
1219 and ebp, edi 1220 and ebp, edi
1220 and esi, edx 1221 and esi, edx
1221 or ebp, esi 1222 or ebp, esi
1222 mov esi, ebx 1223 mov esi, ecx
1223 rol esi, 5 1224 rol esi, 5
1224 ror ecx, 1 1225 ror ebx, 1
1225 add ebp, esi 1226 add ebp, esi
1226 ror ecx, 1 1227 ror ebx, 1
1227 add eax, ebp 1228 add eax, ebp
1228 ; 40_59 59 1229 ; 40_59 59
1229 ; 20_39 60 1230 ; 20_39 60
@@ -1234,17 +1235,17 @@ L000start:
1234 xor esi, ebp 1235 xor esi, ebp
1235 mov ebp, DWORD PTR 36[esp] 1236 mov ebp, DWORD PTR 36[esp]
1236 xor esi, ebp 1237 xor esi, ebp
1237 mov ebp, ebx 1238 mov ebp, ecx
1238 rol esi, 1 1239 rol esi, 1
1239 xor ebp, ecx 1240 xor ebp, ebx
1240 mov DWORD PTR 48[esp],esi 1241 mov DWORD PTR 48[esp],esi
1241 xor ebp, edx 1242 xor ebp, edx
1242 lea esi, DWORD PTR 3395469782[edi*1+esi] 1243 lea esi, DWORD PTR 3395469782[edi*1+esi]
1243 mov edi, eax 1244 mov edi, eax
1244 rol edi, 5 1245 rol edi, 5
1245 ror ebx, 1 1246 ror ecx, 1
1246 add edi, ebp 1247 add edi, ebp
1247 ror ebx, 1 1248 ror ecx, 1
1248 add esi, edi 1249 add esi, edi
1249 ; 20_39 61 1250 ; 20_39 61
1250 mov edi, DWORD PTR 52[esp] 1251 mov edi, DWORD PTR 52[esp]
@@ -1256,9 +1257,9 @@ L000start:
1256 xor edi, ebp 1257 xor edi, ebp
1257 mov ebp, eax 1258 mov ebp, eax
1258 rol edi, 1 1259 rol edi, 1
1259 xor ebp, ebx
1260 mov DWORD PTR 52[esp],edi
1261 xor ebp, ecx 1260 xor ebp, ecx
1261 mov DWORD PTR 52[esp],edi
1262 xor ebp, ebx
1262 lea edi, DWORD PTR 3395469782[edx*1+edi] 1263 lea edi, DWORD PTR 3395469782[edx*1+edi]
1263 mov edx, esi 1264 mov edx, esi
1264 rol edx, 5 1265 rol edx, 5
@@ -1278,54 +1279,54 @@ L000start:
1278 rol edx, 1 1279 rol edx, 1
1279 xor ebp, eax 1280 xor ebp, eax
1280 mov DWORD PTR 56[esp],edx 1281 mov DWORD PTR 56[esp],edx
1281 xor ebp, ebx 1282 xor ebp, ecx
1282 lea edx, DWORD PTR 3395469782[ecx*1+edx] 1283 lea edx, DWORD PTR 3395469782[ebx*1+edx]
1283 mov ecx, edi 1284 mov ebx, edi
1284 rol ecx, 5 1285 rol ebx, 5
1285 ror esi, 1 1286 ror esi, 1
1286 add ecx, ebp 1287 add ebx, ebp
1287 ror esi, 1 1288 ror esi, 1
1288 add edx, ecx 1289 add edx, ebx
1289 ; 20_39 63 1290 ; 20_39 63
1290 mov ecx, DWORD PTR 60[esp] 1291 mov ebx, DWORD PTR 60[esp]
1291 mov ebp, DWORD PTR 4[esp] 1292 mov ebp, DWORD PTR 4[esp]
1292 xor ecx, ebp 1293 xor ebx, ebp
1293 mov ebp, DWORD PTR 28[esp] 1294 mov ebp, DWORD PTR 28[esp]
1294 xor ecx, ebp 1295 xor ebx, ebp
1295 mov ebp, DWORD PTR 48[esp] 1296 mov ebp, DWORD PTR 48[esp]
1296 xor ecx, ebp 1297 xor ebx, ebp
1297 mov ebp, edi 1298 mov ebp, edi
1298 rol ecx, 1 1299 rol ebx, 1
1299 xor ebp, esi 1300 xor ebp, esi
1300 mov DWORD PTR 60[esp],ecx 1301 mov DWORD PTR 60[esp],ebx
1301 xor ebp, eax 1302 xor ebp, eax
1302 lea ecx, DWORD PTR 3395469782[ebx*1+ecx] 1303 lea ebx, DWORD PTR 3395469782[ecx*1+ebx]
1303 mov ebx, edx 1304 mov ecx, edx
1304 rol ebx, 5 1305 rol ecx, 5
1305 ror edi, 1 1306 ror edi, 1
1306 add ebx, ebp 1307 add ecx, ebp
1307 ror edi, 1 1308 ror edi, 1
1308 add ecx, ebx 1309 add ebx, ecx
1309 ; 20_39 64 1310 ; 20_39 64
1310 mov ebx, DWORD PTR [esp] 1311 mov ecx, DWORD PTR [esp]
1311 mov ebp, DWORD PTR 8[esp] 1312 mov ebp, DWORD PTR 8[esp]
1312 xor ebx, ebp 1313 xor ecx, ebp
1313 mov ebp, DWORD PTR 32[esp] 1314 mov ebp, DWORD PTR 32[esp]
1314 xor ebx, ebp 1315 xor ecx, ebp
1315 mov ebp, DWORD PTR 52[esp] 1316 mov ebp, DWORD PTR 52[esp]
1316 xor ebx, ebp 1317 xor ecx, ebp
1317 mov ebp, edx 1318 mov ebp, edx
1318 rol ebx, 1 1319 rol ecx, 1
1319 xor ebp, edi 1320 xor ebp, edi
1320 mov DWORD PTR [esp],ebx 1321 mov DWORD PTR [esp],ecx
1321 xor ebp, esi 1322 xor ebp, esi
1322 lea ebx, DWORD PTR 3395469782[eax*1+ebx] 1323 lea ecx, DWORD PTR 3395469782[eax*1+ecx]
1323 mov eax, ecx 1324 mov eax, ebx
1324 rol eax, 5 1325 rol eax, 5
1325 ror edx, 1 1326 ror edx, 1
1326 add eax, ebp 1327 add eax, ebp
1327 ror edx, 1 1328 ror edx, 1
1328 add ebx, eax 1329 add ecx, eax
1329 ; 20_39 65 1330 ; 20_39 65
1330 mov eax, DWORD PTR 4[esp] 1331 mov eax, DWORD PTR 4[esp]
1331 mov ebp, DWORD PTR 12[esp] 1332 mov ebp, DWORD PTR 12[esp]
@@ -1334,17 +1335,17 @@ L000start:
1334 xor eax, ebp 1335 xor eax, ebp
1335 mov ebp, DWORD PTR 56[esp] 1336 mov ebp, DWORD PTR 56[esp]
1336 xor eax, ebp 1337 xor eax, ebp
1337 mov ebp, ecx 1338 mov ebp, ebx
1338 rol eax, 1 1339 rol eax, 1
1339 xor ebp, edx 1340 xor ebp, edx
1340 mov DWORD PTR 4[esp],eax 1341 mov DWORD PTR 4[esp],eax
1341 xor ebp, edi 1342 xor ebp, edi
1342 lea eax, DWORD PTR 3395469782[esi*1+eax] 1343 lea eax, DWORD PTR 3395469782[esi*1+eax]
1343 mov esi, ebx 1344 mov esi, ecx
1344 rol esi, 5 1345 rol esi, 5
1345 ror ecx, 1 1346 ror ebx, 1
1346 add esi, ebp 1347 add esi, ebp
1347 ror ecx, 1 1348 ror ebx, 1
1348 add eax, esi 1349 add eax, esi
1349 ; 20_39 66 1350 ; 20_39 66
1350 mov esi, DWORD PTR 8[esp] 1351 mov esi, DWORD PTR 8[esp]
@@ -1354,17 +1355,17 @@ L000start:
1354 xor esi, ebp 1355 xor esi, ebp
1355 mov ebp, DWORD PTR 60[esp] 1356 mov ebp, DWORD PTR 60[esp]
1356 xor esi, ebp 1357 xor esi, ebp
1357 mov ebp, ebx 1358 mov ebp, ecx
1358 rol esi, 1 1359 rol esi, 1
1359 xor ebp, ecx 1360 xor ebp, ebx
1360 mov DWORD PTR 8[esp],esi 1361 mov DWORD PTR 8[esp],esi
1361 xor ebp, edx 1362 xor ebp, edx
1362 lea esi, DWORD PTR 3395469782[edi*1+esi] 1363 lea esi, DWORD PTR 3395469782[edi*1+esi]
1363 mov edi, eax 1364 mov edi, eax
1364 rol edi, 5 1365 rol edi, 5
1365 ror ebx, 1 1366 ror ecx, 1
1366 add edi, ebp 1367 add edi, ebp
1367 ror ebx, 1 1368 ror ecx, 1
1368 add esi, edi 1369 add esi, edi
1369 ; 20_39 67 1370 ; 20_39 67
1370 mov edi, DWORD PTR 12[esp] 1371 mov edi, DWORD PTR 12[esp]
@@ -1376,9 +1377,9 @@ L000start:
1376 xor edi, ebp 1377 xor edi, ebp
1377 mov ebp, eax 1378 mov ebp, eax
1378 rol edi, 1 1379 rol edi, 1
1379 xor ebp, ebx
1380 mov DWORD PTR 12[esp],edi
1381 xor ebp, ecx 1380 xor ebp, ecx
1381 mov DWORD PTR 12[esp],edi
1382 xor ebp, ebx
1382 lea edi, DWORD PTR 3395469782[edx*1+edi] 1383 lea edi, DWORD PTR 3395469782[edx*1+edi]
1383 mov edx, esi 1384 mov edx, esi
1384 rol edx, 5 1385 rol edx, 5
@@ -1398,54 +1399,54 @@ L000start:
1398 rol edx, 1 1399 rol edx, 1
1399 xor ebp, eax 1400 xor ebp, eax
1400 mov DWORD PTR 16[esp],edx 1401 mov DWORD PTR 16[esp],edx
1401 xor ebp, ebx 1402 xor ebp, ecx
1402 lea edx, DWORD PTR 3395469782[ecx*1+edx] 1403 lea edx, DWORD PTR 3395469782[ebx*1+edx]
1403 mov ecx, edi 1404 mov ebx, edi
1404 rol ecx, 5 1405 rol ebx, 5
1405 ror esi, 1 1406 ror esi, 1
1406 add ecx, ebp 1407 add ebx, ebp
1407 ror esi, 1 1408 ror esi, 1
1408 add edx, ecx 1409 add edx, ebx
1409 ; 20_39 69 1410 ; 20_39 69
1410 mov ecx, DWORD PTR 20[esp] 1411 mov ebx, DWORD PTR 20[esp]
1411 mov ebp, DWORD PTR 28[esp] 1412 mov ebp, DWORD PTR 28[esp]
1412 xor ecx, ebp 1413 xor ebx, ebp
1413 mov ebp, DWORD PTR 52[esp] 1414 mov ebp, DWORD PTR 52[esp]
1414 xor ecx, ebp 1415 xor ebx, ebp
1415 mov ebp, DWORD PTR 8[esp] 1416 mov ebp, DWORD PTR 8[esp]
1416 xor ecx, ebp 1417 xor ebx, ebp
1417 mov ebp, edi 1418 mov ebp, edi
1418 rol ecx, 1 1419 rol ebx, 1
1419 xor ebp, esi 1420 xor ebp, esi
1420 mov DWORD PTR 20[esp],ecx 1421 mov DWORD PTR 20[esp],ebx
1421 xor ebp, eax 1422 xor ebp, eax
1422 lea ecx, DWORD PTR 3395469782[ebx*1+ecx] 1423 lea ebx, DWORD PTR 3395469782[ecx*1+ebx]
1423 mov ebx, edx 1424 mov ecx, edx
1424 rol ebx, 5 1425 rol ecx, 5
1425 ror edi, 1 1426 ror edi, 1
1426 add ebx, ebp 1427 add ecx, ebp
1427 ror edi, 1 1428 ror edi, 1
1428 add ecx, ebx 1429 add ebx, ecx
1429 ; 20_39 70 1430 ; 20_39 70
1430 mov ebx, DWORD PTR 24[esp] 1431 mov ecx, DWORD PTR 24[esp]
1431 mov ebp, DWORD PTR 32[esp] 1432 mov ebp, DWORD PTR 32[esp]
1432 xor ebx, ebp 1433 xor ecx, ebp
1433 mov ebp, DWORD PTR 56[esp] 1434 mov ebp, DWORD PTR 56[esp]
1434 xor ebx, ebp 1435 xor ecx, ebp
1435 mov ebp, DWORD PTR 12[esp] 1436 mov ebp, DWORD PTR 12[esp]
1436 xor ebx, ebp 1437 xor ecx, ebp
1437 mov ebp, edx 1438 mov ebp, edx
1438 rol ebx, 1 1439 rol ecx, 1
1439 xor ebp, edi 1440 xor ebp, edi
1440 mov DWORD PTR 24[esp],ebx 1441 mov DWORD PTR 24[esp],ecx
1441 xor ebp, esi 1442 xor ebp, esi
1442 lea ebx, DWORD PTR 3395469782[eax*1+ebx] 1443 lea ecx, DWORD PTR 3395469782[eax*1+ecx]
1443 mov eax, ecx 1444 mov eax, ebx
1444 rol eax, 5 1445 rol eax, 5
1445 ror edx, 1 1446 ror edx, 1
1446 add eax, ebp 1447 add eax, ebp
1447 ror edx, 1 1448 ror edx, 1
1448 add ebx, eax 1449 add ecx, eax
1449 ; 20_39 71 1450 ; 20_39 71
1450 mov eax, DWORD PTR 28[esp] 1451 mov eax, DWORD PTR 28[esp]
1451 mov ebp, DWORD PTR 36[esp] 1452 mov ebp, DWORD PTR 36[esp]
@@ -1454,17 +1455,17 @@ L000start:
1454 xor eax, ebp 1455 xor eax, ebp
1455 mov ebp, DWORD PTR 16[esp] 1456 mov ebp, DWORD PTR 16[esp]
1456 xor eax, ebp 1457 xor eax, ebp
1457 mov ebp, ecx 1458 mov ebp, ebx
1458 rol eax, 1 1459 rol eax, 1
1459 xor ebp, edx 1460 xor ebp, edx
1460 mov DWORD PTR 28[esp],eax 1461 mov DWORD PTR 28[esp],eax
1461 xor ebp, edi 1462 xor ebp, edi
1462 lea eax, DWORD PTR 3395469782[esi*1+eax] 1463 lea eax, DWORD PTR 3395469782[esi*1+eax]
1463 mov esi, ebx 1464 mov esi, ecx
1464 rol esi, 5 1465 rol esi, 5
1465 ror ecx, 1 1466 ror ebx, 1
1466 add esi, ebp 1467 add esi, ebp
1467 ror ecx, 1 1468 ror ebx, 1
1468 add eax, esi 1469 add eax, esi
1469 ; 20_39 72 1470 ; 20_39 72
1470 mov esi, DWORD PTR 32[esp] 1471 mov esi, DWORD PTR 32[esp]
@@ -1474,17 +1475,17 @@ L000start:
1474 xor esi, ebp 1475 xor esi, ebp
1475 mov ebp, DWORD PTR 20[esp] 1476 mov ebp, DWORD PTR 20[esp]
1476 xor esi, ebp 1477 xor esi, ebp
1477 mov ebp, ebx 1478 mov ebp, ecx
1478 rol esi, 1 1479 rol esi, 1
1479 xor ebp, ecx 1480 xor ebp, ebx
1480 mov DWORD PTR 32[esp],esi 1481 mov DWORD PTR 32[esp],esi
1481 xor ebp, edx 1482 xor ebp, edx
1482 lea esi, DWORD PTR 3395469782[edi*1+esi] 1483 lea esi, DWORD PTR 3395469782[edi*1+esi]
1483 mov edi, eax 1484 mov edi, eax
1484 rol edi, 5 1485 rol edi, 5
1485 ror ebx, 1 1486 ror ecx, 1
1486 add edi, ebp 1487 add edi, ebp
1487 ror ebx, 1 1488 ror ecx, 1
1488 add esi, edi 1489 add esi, edi
1489 ; 20_39 73 1490 ; 20_39 73
1490 mov edi, DWORD PTR 36[esp] 1491 mov edi, DWORD PTR 36[esp]
@@ -1496,9 +1497,9 @@ L000start:
1496 xor edi, ebp 1497 xor edi, ebp
1497 mov ebp, eax 1498 mov ebp, eax
1498 rol edi, 1 1499 rol edi, 1
1499 xor ebp, ebx
1500 mov DWORD PTR 36[esp],edi
1501 xor ebp, ecx 1500 xor ebp, ecx
1501 mov DWORD PTR 36[esp],edi
1502 xor ebp, ebx
1502 lea edi, DWORD PTR 3395469782[edx*1+edi] 1503 lea edi, DWORD PTR 3395469782[edx*1+edi]
1503 mov edx, esi 1504 mov edx, esi
1504 rol edx, 5 1505 rol edx, 5
@@ -1518,54 +1519,54 @@ L000start:
1518 rol edx, 1 1519 rol edx, 1
1519 xor ebp, eax 1520 xor ebp, eax
1520 mov DWORD PTR 40[esp],edx 1521 mov DWORD PTR 40[esp],edx
1521 xor ebp, ebx 1522 xor ebp, ecx
1522 lea edx, DWORD PTR 3395469782[ecx*1+edx] 1523 lea edx, DWORD PTR 3395469782[ebx*1+edx]
1523 mov ecx, edi 1524 mov ebx, edi
1524 rol ecx, 5 1525 rol ebx, 5
1525 ror esi, 1 1526 ror esi, 1
1526 add ecx, ebp 1527 add ebx, ebp
1527 ror esi, 1 1528 ror esi, 1
1528 add edx, ecx 1529 add edx, ebx
1529 ; 20_39 75 1530 ; 20_39 75
1530 mov ecx, DWORD PTR 44[esp] 1531 mov ebx, DWORD PTR 44[esp]
1531 mov ebp, DWORD PTR 52[esp] 1532 mov ebp, DWORD PTR 52[esp]
1532 xor ecx, ebp 1533 xor ebx, ebp
1533 mov ebp, DWORD PTR 12[esp] 1534 mov ebp, DWORD PTR 12[esp]
1534 xor ecx, ebp 1535 xor ebx, ebp
1535 mov ebp, DWORD PTR 32[esp] 1536 mov ebp, DWORD PTR 32[esp]
1536 xor ecx, ebp 1537 xor ebx, ebp
1537 mov ebp, edi 1538 mov ebp, edi
1538 rol ecx, 1 1539 rol ebx, 1
1539 xor ebp, esi 1540 xor ebp, esi
1540 mov DWORD PTR 44[esp],ecx 1541 mov DWORD PTR 44[esp],ebx
1541 xor ebp, eax 1542 xor ebp, eax
1542 lea ecx, DWORD PTR 3395469782[ebx*1+ecx] 1543 lea ebx, DWORD PTR 3395469782[ecx*1+ebx]
1543 mov ebx, edx 1544 mov ecx, edx
1544 rol ebx, 5 1545 rol ecx, 5
1545 ror edi, 1 1546 ror edi, 1
1546 add ebx, ebp 1547 add ecx, ebp
1547 ror edi, 1 1548 ror edi, 1
1548 add ecx, ebx 1549 add ebx, ecx
1549 ; 20_39 76 1550 ; 20_39 76
1550 mov ebx, DWORD PTR 48[esp] 1551 mov ecx, DWORD PTR 48[esp]
1551 mov ebp, DWORD PTR 56[esp] 1552 mov ebp, DWORD PTR 56[esp]
1552 xor ebx, ebp 1553 xor ecx, ebp
1553 mov ebp, DWORD PTR 16[esp] 1554 mov ebp, DWORD PTR 16[esp]
1554 xor ebx, ebp 1555 xor ecx, ebp
1555 mov ebp, DWORD PTR 36[esp] 1556 mov ebp, DWORD PTR 36[esp]
1556 xor ebx, ebp 1557 xor ecx, ebp
1557 mov ebp, edx 1558 mov ebp, edx
1558 rol ebx, 1 1559 rol ecx, 1
1559 xor ebp, edi 1560 xor ebp, edi
1560 mov DWORD PTR 48[esp],ebx 1561 mov DWORD PTR 48[esp],ecx
1561 xor ebp, esi 1562 xor ebp, esi
1562 lea ebx, DWORD PTR 3395469782[eax*1+ebx] 1563 lea ecx, DWORD PTR 3395469782[eax*1+ecx]
1563 mov eax, ecx 1564 mov eax, ebx
1564 rol eax, 5 1565 rol eax, 5
1565 ror edx, 1 1566 ror edx, 1
1566 add eax, ebp 1567 add eax, ebp
1567 ror edx, 1 1568 ror edx, 1
1568 add ebx, eax 1569 add ecx, eax
1569 ; 20_39 77 1570 ; 20_39 77
1570 mov eax, DWORD PTR 52[esp] 1571 mov eax, DWORD PTR 52[esp]
1571 mov ebp, DWORD PTR 60[esp] 1572 mov ebp, DWORD PTR 60[esp]
@@ -1574,17 +1575,17 @@ L000start:
1574 xor eax, ebp 1575 xor eax, ebp
1575 mov ebp, DWORD PTR 40[esp] 1576 mov ebp, DWORD PTR 40[esp]
1576 xor eax, ebp 1577 xor eax, ebp
1577 mov ebp, ecx 1578 mov ebp, ebx
1578 rol eax, 1 1579 rol eax, 1
1579 xor ebp, edx 1580 xor ebp, edx
1580 mov DWORD PTR 52[esp],eax 1581 mov DWORD PTR 52[esp],eax
1581 xor ebp, edi 1582 xor ebp, edi
1582 lea eax, DWORD PTR 3395469782[esi*1+eax] 1583 lea eax, DWORD PTR 3395469782[esi*1+eax]
1583 mov esi, ebx 1584 mov esi, ecx
1584 rol esi, 5 1585 rol esi, 5
1585 ror ecx, 1 1586 ror ebx, 1
1586 add esi, ebp 1587 add esi, ebp
1587 ror ecx, 1 1588 ror ebx, 1
1588 add eax, esi 1589 add eax, esi
1589 ; 20_39 78 1590 ; 20_39 78
1590 mov esi, DWORD PTR 56[esp] 1591 mov esi, DWORD PTR 56[esp]
@@ -1594,17 +1595,17 @@ L000start:
1594 xor esi, ebp 1595 xor esi, ebp
1595 mov ebp, DWORD PTR 44[esp] 1596 mov ebp, DWORD PTR 44[esp]
1596 xor esi, ebp 1597 xor esi, ebp
1597 mov ebp, ebx 1598 mov ebp, ecx
1598 rol esi, 1 1599 rol esi, 1
1599 xor ebp, ecx 1600 xor ebp, ebx
1600 mov DWORD PTR 56[esp],esi 1601 mov DWORD PTR 56[esp],esi
1601 xor ebp, edx 1602 xor ebp, edx
1602 lea esi, DWORD PTR 3395469782[edi*1+esi] 1603 lea esi, DWORD PTR 3395469782[edi*1+esi]
1603 mov edi, eax 1604 mov edi, eax
1604 rol edi, 5 1605 rol edi, 5
1605 ror ebx, 1 1606 ror ecx, 1
1606 add edi, ebp 1607 add edi, ebp
1607 ror ebx, 1 1608 ror ecx, 1
1608 add esi, edi 1609 add esi, edi
1609 ; 20_39 79 1610 ; 20_39 79
1610 mov edi, DWORD PTR 60[esp] 1611 mov edi, DWORD PTR 60[esp]
@@ -1616,49 +1617,100 @@ L000start:
1616 xor edi, ebp 1617 xor edi, ebp
1617 mov ebp, eax 1618 mov ebp, eax
1618 rol edi, 1 1619 rol edi, 1
1619 xor ebp, ebx
1620 mov DWORD PTR 60[esp],edi
1621 xor ebp, ecx 1620 xor ebp, ecx
1621 mov DWORD PTR 60[esp],edi
1622 xor ebp, ebx
1622 lea edi, DWORD PTR 3395469782[edx*1+edi] 1623 lea edi, DWORD PTR 3395469782[edx*1+edi]
1623 mov edx, esi 1624 mov edx, esi
1624 rol edx, 5 1625 rol edx, 5
1625 add edx, ebp 1626 add edx, ebp
1626 mov ebp, DWORD PTR 92[esp] 1627 mov ebp, DWORD PTR 128[esp]
1627 ror eax, 1 1628 ror eax, 1
1628 add edi, edx 1629 add edi, edx
1629 ror eax, 1 1630 ror eax, 1
1630 ; End processing 1631 ; End processing
1631 ; 1632 ;
1632 mov edx, DWORD PTR 12[ebp] 1633 mov edx, DWORD PTR 12[ebp]
1633 add edx, ebx 1634 add edx, ecx
1634 mov ebx, DWORD PTR 4[ebp] 1635 mov ecx, DWORD PTR 4[ebp]
1635 add ebx, esi 1636 add ecx, esi
1636 mov esi, eax 1637 mov esi, eax
1637 mov eax, DWORD PTR [ebp] 1638 mov eax, DWORD PTR [ebp]
1638 mov DWORD PTR 12[ebp],edx 1639 mov DWORD PTR 12[ebp],edx
1639 add eax, edi 1640 add eax, edi
1640 mov edi, DWORD PTR 16[ebp] 1641 mov edi, DWORD PTR 16[ebp]
1641 add edi, ecx 1642 add edi, ebx
1642 mov ecx, DWORD PTR 8[ebp] 1643 mov ebx, DWORD PTR 8[ebp]
1643 add ecx, esi 1644 add ebx, esi
1644 mov DWORD PTR [ebp],eax 1645 mov DWORD PTR [ebp],eax
1645 mov esi, DWORD PTR 64[esp] 1646 mov esi, DWORD PTR 132[esp]
1646 mov DWORD PTR 8[ebp],ecx 1647 mov DWORD PTR 8[ebp],ebx
1647 add esi, 64 1648 add esi, 64
1648 mov eax, DWORD PTR 68[esp] 1649 mov eax, DWORD PTR 68[esp]
1649 mov DWORD PTR 16[ebp],edi 1650 mov DWORD PTR 16[ebp],edi
1650 cmp eax, esi 1651 cmp esi, eax
1651 mov DWORD PTR 4[ebp],ebx 1652 mov DWORD PTR 4[ebp],ecx
1652 jl $L001end 1653 jl L000start
1653 mov eax, DWORD PTR [esi] 1654 add esp, 108
1654 jmp L000start
1655$L001end:
1656 add esp, 72
1657 pop edi 1655 pop edi
1658 pop ebx 1656 pop ebx
1659 pop ebp 1657 pop ebp
1660 pop esi 1658 pop esi
1661 ret 1659 ret
1662_sha1_block_x86 ENDP 1660_TEXT SEGMENT
1661PUBLIC _sha1_block_asm_host_order
1662
1663_sha1_block_asm_host_order PROC NEAR
1664 mov ecx, DWORD PTR 12[esp]
1665 push esi
1666 shl ecx, 6
1667 mov esi, DWORD PTR 12[esp]
1668 push ebp
1669 add ecx, esi
1670 push ebx
1671 mov ebp, DWORD PTR 16[esp]
1672 push edi
1673 mov edx, DWORD PTR 12[ebp]
1674 sub esp, 108
1675 mov edi, DWORD PTR 16[ebp]
1676 mov ebx, DWORD PTR 8[ebp]
1677 mov DWORD PTR 68[esp],ecx
1678 ; First we need to setup the X array
1679 mov eax, DWORD PTR [esi]
1680 mov ecx, DWORD PTR 4[esi]
1681 mov DWORD PTR [esp],eax
1682 mov DWORD PTR 4[esp],ecx
1683 mov eax, DWORD PTR 8[esi]
1684 mov ecx, DWORD PTR 12[esi]
1685 mov DWORD PTR 8[esp],eax
1686 mov DWORD PTR 12[esp],ecx
1687 mov eax, DWORD PTR 16[esi]
1688 mov ecx, DWORD PTR 20[esi]
1689 mov DWORD PTR 16[esp],eax
1690 mov DWORD PTR 20[esp],ecx
1691 mov eax, DWORD PTR 24[esi]
1692 mov ecx, DWORD PTR 28[esi]
1693 mov DWORD PTR 24[esp],eax
1694 mov DWORD PTR 28[esp],ecx
1695 mov eax, DWORD PTR 32[esi]
1696 mov ecx, DWORD PTR 36[esi]
1697 mov DWORD PTR 32[esp],eax
1698 mov DWORD PTR 36[esp],ecx
1699 mov eax, DWORD PTR 40[esi]
1700 mov ecx, DWORD PTR 44[esi]
1701 mov DWORD PTR 40[esp],eax
1702 mov DWORD PTR 44[esp],ecx
1703 mov eax, DWORD PTR 48[esi]
1704 mov ecx, DWORD PTR 52[esi]
1705 mov DWORD PTR 48[esp],eax
1706 mov DWORD PTR 52[esp],ecx
1707 mov eax, DWORD PTR 56[esi]
1708 mov ecx, DWORD PTR 60[esi]
1709 mov DWORD PTR 56[esp],eax
1710 mov DWORD PTR 60[esp],ecx
1711 jmp L001shortcut
1712_sha1_block_asm_host_order ENDP
1713_TEXT ENDS
1714_sha1_block_asm_data_order ENDP
1663_TEXT ENDS 1715_TEXT ENDS
1664END 1716END
diff --git a/src/lib/libssl/src/crypto/sha/asm/sha1-586.pl b/src/lib/libssl/src/crypto/sha/asm/sha1-586.pl
index 04e42ab09f..48d9192a4e 100644
--- a/src/lib/libssl/src/crypto/sha/asm/sha1-586.pl
+++ b/src/lib/libssl/src/crypto/sha/asm/sha1-586.pl
@@ -8,8 +8,8 @@ require "x86asm.pl";
8&asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386"); 8&asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386");
9 9
10$A="eax"; 10$A="eax";
11$B="ebx"; 11$B="ecx";
12$C="ecx"; 12$C="ebx";
13$D="edx"; 13$D="edx";
14$E="edi"; 14$E="edi";
15$T="esi"; 15$T="esi";
@@ -19,7 +19,7 @@ $off=9*4;
19 19
20@K=(0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6); 20@K=(0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6);
21 21
22&sha1_block("sha1_block_x86"); 22&sha1_block_data("sha1_block_asm_data_order");
23 23
24&asm_finish(); 24&asm_finish();
25 25
@@ -53,11 +53,14 @@ sub X_expand
53 local($in)=@_; 53 local($in)=@_;
54 54
55 &comment("First, load the words onto the stack in network byte order"); 55 &comment("First, load the words onto the stack in network byte order");
56 for ($i=0; $i<16; $i++) 56 for ($i=0; $i<16; $i+=2)
57 { 57 {
58 &mov("eax",&DWP(($i+0)*4,$in,"",0)) unless $i == 0; 58 &mov($A,&DWP(($i+0)*4,$in,"",0));# unless $i == 0;
59 &bswap("eax"); 59 &mov($B,&DWP(($i+1)*4,$in,"",0));
60 &mov(&swtmp($i+0),"eax"); 60 &bswap($A);
61 &bswap($B);
62 &mov(&swtmp($i+0),$A);
63 &mov(&swtmp($i+1),$B);
61 } 64 }
62 65
63 &comment("We now have the X array on the stack"); 66 &comment("We now have the X array on the stack");
@@ -312,7 +315,7 @@ sub BODY_60_79
312 &BODY_20_39(@_); 315 &BODY_20_39(@_);
313 } 316 }
314 317
315sub sha1_block 318sub sha1_block_host
316 { 319 {
317 local($name)=@_; 320 local($name)=@_;
318 321
@@ -325,35 +328,77 @@ sub sha1_block
325 # D 12 328 # D 12
326 # E 16 329 # E 16
327 330
328 &push("esi"); 331 &mov("ecx", &wparam(2));
329 &push("ebp"); 332 &push("esi");
330 &mov("eax", &wparam(2)); 333 &shl("ecx",6);
331 &mov("esi", &wparam(1)); 334 &mov("esi", &wparam(1));
332 &add("eax", "esi"); # offset to leave on 335 &push("ebp");
336 &add("ecx","esi"); # offset to leave on
337 &push("ebx");
333 &mov("ebp", &wparam(0)); 338 &mov("ebp", &wparam(0));
339 &push("edi");
340 &mov($D, &DWP(12,"ebp","",0));
341 &stack_push(18+9);
342 &mov($E, &DWP(16,"ebp","",0));
343 &mov($C, &DWP( 8,"ebp","",0));
344 &mov(&swtmp(17),"ecx");
345
346 &comment("First we need to setup the X array");
347
348 for ($i=0; $i<16; $i+=2)
349 {
350 &mov($A,&DWP(($i+0)*4,"esi","",0));# unless $i == 0;
351 &mov($B,&DWP(($i+1)*4,"esi","",0));
352 &mov(&swtmp($i+0),$A);
353 &mov(&swtmp($i+1),$B);
354 }
355 &jmp(&label("shortcut"));
356 &function_end_B($name);
357 }
358
359
360sub sha1_block_data
361 {
362 local($name)=@_;
363
364 &function_begin_B($name,"");
365
366 # parameter 1 is the MD5_CTX structure.
367 # A 0
368 # B 4
369 # C 8
370 # D 12
371 # E 16
372
373 &mov("ecx", &wparam(2));
374 &push("esi");
375 &shl("ecx",6);
376 &mov("esi", &wparam(1));
377 &push("ebp");
378 &add("ecx","esi"); # offset to leave on
334 &push("ebx"); 379 &push("ebx");
335 &sub("eax", 64); 380 &mov("ebp", &wparam(0));
336 &push("edi"); 381 &push("edi");
337 &mov($B, &DWP( 4,"ebp","",0));
338 &stack_push(18);
339 &mov($D, &DWP(12,"ebp","",0)); 382 &mov($D, &DWP(12,"ebp","",0));
340 &mov($E, &DWP(16,"ebp","",0)); 383 &stack_push(18+9);
341 &mov($C, &DWP( 8,"ebp","",0)); 384 &mov($E, &DWP(16,"ebp","",0));
342 &mov(&swtmp(17),"eax"); 385 &mov($C, &DWP( 8,"ebp","",0));
386 &mov(&swtmp(17),"ecx");
343 387
344 &comment("First we need to setup the X array"); 388 &comment("First we need to setup the X array");
345 &mov("eax",&DWP(0,"esi","",0)); # pulled out of X_expand
346 389
347 &set_label("start") unless $normal; 390 &set_label("start") unless $normal;
348 391
349 &X_expand("esi"); 392 &X_expand("esi");
350 &mov(&swtmp(16),"esi"); 393 &mov(&wparam(1),"esi");
351 394
395 &set_label("shortcut", 1);
352 &comment(""); 396 &comment("");
353 &comment("Start processing"); 397 &comment("Start processing");
354 398
355 # odd start 399 # odd start
356 &mov($A, &DWP( 0,"ebp","",0)); 400 &mov($A, &DWP( 0,"ebp","",0));
401 &mov($B, &DWP( 4,"ebp","",0));
357 $X="esp"; 402 $X="esp";
358 &BODY_00_15(-2,$K[0],$X, 0,$A,$B,$C,$D,$E,$T); 403 &BODY_00_15(-2,$K[0],$X, 0,$A,$B,$C,$D,$E,$T);
359 &BODY_00_15( 0,$K[0],$X, 1,$T,$A,$B,$C,$D,$E); 404 &BODY_00_15( 0,$K[0],$X, 1,$T,$A,$B,$C,$D,$E);
@@ -468,24 +513,26 @@ sub sha1_block
468 &add($C,$T); 513 &add($C,$T);
469 514
470 &mov(&DWP( 0,$tmp1,"",0),$A); 515 &mov(&DWP( 0,$tmp1,"",0),$A);
471 &mov("esi",&swtmp(16)); 516 &mov("esi",&wparam(1));
472 &mov(&DWP( 8,$tmp1,"",0),$C); # This is for looping 517 &mov(&DWP( 8,$tmp1,"",0),$C);
473 &add("esi",64); 518 &add("esi",64);
474 &mov("eax",&swtmp(17)); 519 &mov("eax",&swtmp(17));
475 &mov(&DWP(16,$tmp1,"",0),$E); 520 &mov(&DWP(16,$tmp1,"",0),$E);
476 &cmp("eax","esi"); 521 &cmp("esi","eax");
477 &mov(&DWP( 4,$tmp1,"",0),$B); # This is for looping 522 &mov(&DWP( 4,$tmp1,"",0),$B);
478 &jl(&label("end")); 523 &jl(&label("start"));
479 &mov("eax",&DWP(0,"esi","",0)); # Pulled down from 524
480 &jmp(&label("start")); 525 &stack_pop(18+9);
481
482 &set_label("end");
483 &stack_pop(18);
484 &pop("edi"); 526 &pop("edi");
485 &pop("ebx"); 527 &pop("ebx");
486 &pop("ebp"); 528 &pop("ebp");
487 &pop("esi"); 529 &pop("esi");
488 &ret(); 530 &ret();
531
532 # it has to reside within sha1_block_asm_host_order body
533 # because it calls &jmp(&label("shortcut"));
534 &sha1_block_host("sha1_block_asm_host_order");
535
489 &function_end_B($name); 536 &function_end_B($name);
490 } 537 }
491 538
diff --git a/src/lib/libssl/src/crypto/sha/sha.h b/src/lib/libssl/src/crypto/sha/sha.h
index cd6960ee1a..77f6d9695e 100644
--- a/src/lib/libssl/src/crypto/sha/sha.h
+++ b/src/lib/libssl/src/crypto/sha/sha.h
@@ -63,7 +63,7 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_SHA 66#if defined(NO_SHA) || (defined(NO_SHA0) && defined(NO_SHA1))
67#error SHA is disabled. 67#error SHA is disabled.
68#endif 68#endif
69 69
@@ -100,17 +100,17 @@ typedef struct SHAstate_st
100 100
101#ifndef NO_SHA0 101#ifndef NO_SHA0
102void SHA_Init(SHA_CTX *c); 102void SHA_Init(SHA_CTX *c);
103void SHA_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); 103void SHA_Update(SHA_CTX *c, const void *data, unsigned long len);
104void SHA_Final(unsigned char *md, SHA_CTX *c); 104void SHA_Final(unsigned char *md, SHA_CTX *c);
105unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); 105unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md);
106void SHA_Transform(SHA_CTX *c, unsigned char *data); 106void SHA_Transform(SHA_CTX *c, const unsigned char *data);
107#endif 107#endif
108#ifndef NO_SHA1 108#ifndef NO_SHA1
109void SHA1_Init(SHA_CTX *c); 109void SHA1_Init(SHA_CTX *c);
110void SHA1_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); 110void SHA1_Update(SHA_CTX *c, const void *data, unsigned long len);
111void SHA1_Final(unsigned char *md, SHA_CTX *c); 111void SHA1_Final(unsigned char *md, SHA_CTX *c);
112unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); 112unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md);
113void SHA1_Transform(SHA_CTX *c, unsigned char *data); 113void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
114#endif 114#endif
115#ifdef __cplusplus 115#ifdef __cplusplus
116} 116}
diff --git a/src/lib/libssl/src/crypto/sha/sha1dgst.c b/src/lib/libssl/src/crypto/sha/sha1dgst.c
index 66e885dd76..c09edb4cd7 100644
--- a/src/lib/libssl/src/crypto/sha/sha1dgst.c
+++ b/src/lib/libssl/src/crypto/sha/sha1dgst.c
@@ -56,443 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h> 59#if !defined(NO_SHA1) && !defined(NO_SHA)
60#include <string.h> 60
61#undef SHA_0 61#undef SHA_0
62#define SHA_1 62#define SHA_1
63#include <openssl/sha.h>
64#include "sha_locl.h"
65#include <openssl/opensslv.h>
66
67#ifndef NO_SHA1
68char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT;
69
70/* Implemented from SHA-1 document - The Secure Hash Algorithm
71 */
72
73#define INIT_DATA_h0 0x67452301UL
74#define INIT_DATA_h1 0xefcdab89UL
75#define INIT_DATA_h2 0x98badcfeUL
76#define INIT_DATA_h3 0x10325476UL
77#define INIT_DATA_h4 0xc3d2e1f0UL
78
79#define K_00_19 0x5a827999UL
80#define K_20_39 0x6ed9eba1UL
81#define K_40_59 0x8f1bbcdcUL
82#define K_60_79 0xca62c1d6UL
83
84#ifdef SHA1_ASM
85 void sha1_block_x86(SHA_CTX *c, register SHA_LONG *p, int num);
86# define sha1_block(c,p,n) sha1_block_x86((c),(p),(n)*SHA_CBLOCK)
87#else
88 static void sha1_block(SHA_CTX *c, register SHA_LONG *p, int num);
89#endif
90
91#if !defined(B_ENDIAN) && defined(SHA1_ASM)
92# define M_c2nl c2l
93# define M_p_c2nl p_c2l
94# define M_c2nl_p c2l_p
95# define M_p_c2nl_p p_c2l_p
96# define M_nl2c l2c
97#else
98# define M_c2nl c2nl
99# define M_p_c2nl p_c2nl
100# define M_c2nl_p c2nl_p
101# define M_p_c2nl_p p_c2nl_p
102# define M_nl2c nl2c
103#endif
104
105void SHA1_Init(SHA_CTX *c)
106 {
107 c->h0=INIT_DATA_h0;
108 c->h1=INIT_DATA_h1;
109 c->h2=INIT_DATA_h2;
110 c->h3=INIT_DATA_h3;
111 c->h4=INIT_DATA_h4;
112 c->Nl=0;
113 c->Nh=0;
114 c->num=0;
115 }
116
117void SHA1_Update(SHA_CTX *c, register const unsigned char *data,
118 unsigned long len)
119 {
120 register SHA_LONG *p;
121 int ew,ec,sw,sc;
122 SHA_LONG l;
123
124 if (len == 0) return;
125
126 l=(c->Nl+(len<<3))&0xffffffffL;
127 if (l < c->Nl) /* overflow */
128 c->Nh++;
129 c->Nh+=(len>>29);
130 c->Nl=l;
131
132 if (c->num != 0)
133 {
134 p=c->data;
135 sw=c->num>>2;
136 sc=c->num&0x03;
137
138 if ((c->num+len) >= SHA_CBLOCK)
139 {
140 l= p[sw];
141 M_p_c2nl(data,l,sc);
142 p[sw++]=l;
143 for (; sw<SHA_LBLOCK; sw++)
144 {
145 M_c2nl(data,l);
146 p[sw]=l;
147 }
148 len-=(SHA_CBLOCK-c->num);
149
150 sha1_block(c,p,1);
151 c->num=0;
152 /* drop through and do the rest */
153 }
154 else
155 {
156 c->num+=(int)len;
157 if ((sc+len) < 4) /* ugly, add char's to a word */
158 {
159 l= p[sw];
160 M_p_c2nl_p(data,l,sc,len);
161 p[sw]=l;
162 }
163 else
164 {
165 ew=(c->num>>2);
166 ec=(c->num&0x03);
167 l= p[sw];
168 M_p_c2nl(data,l,sc);
169 p[sw++]=l;
170 for (; sw < ew; sw++)
171 { M_c2nl(data,l); p[sw]=l; }
172 if (ec)
173 {
174 M_c2nl_p(data,l,ec);
175 p[sw]=l;
176 }
177 }
178 return;
179 }
180 }
181 /* We can only do the following code for assember, the reason
182 * being that the sha1_block 'C' version changes the values
183 * in the 'data' array. The assember code avoids this and
184 * copies it to a local array. I should be able to do this for
185 * the C version as well....
186 */
187#if SHA_LONG_LOG2==2
188#if defined(B_ENDIAN) || defined(SHA1_ASM)
189 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
190 {
191 sw=len/SHA_CBLOCK;
192 if (sw)
193 {
194 sha1_block(c,(SHA_LONG *)data,sw);
195 sw*=SHA_CBLOCK;
196 data+=sw;
197 len-=sw;
198 }
199 }
200#endif
201#endif
202 /* we now can process the input data in blocks of SHA_CBLOCK
203 * chars and save the leftovers to c->data. */
204 p=c->data;
205 while (len >= SHA_CBLOCK)
206 {
207#if SHA_LONG_LOG2==2
208#if defined(B_ENDIAN) || defined(SHA1_ASM)
209#define SHA_NO_TAIL_CODE
210 /*
211 * Basically we get here only when data happens
212 * to be unaligned.
213 */
214 if (p != (SHA_LONG *)data)
215 memcpy(p,data,SHA_CBLOCK);
216 data+=SHA_CBLOCK;
217 sha1_block(c,p=c->data,1);
218 len-=SHA_CBLOCK;
219#elif defined(L_ENDIAN)
220#define BE_COPY(dst,src,i) { \
221 l = ((SHA_LONG *)src)[i]; \
222 Endian_Reverse32(l); \
223 dst[i] = l; \
224 }
225 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
226 {
227 for (sw=(SHA_LBLOCK/4); sw; sw--)
228 {
229 BE_COPY(p,data,0);
230 BE_COPY(p,data,1);
231 BE_COPY(p,data,2);
232 BE_COPY(p,data,3);
233 p+=4;
234 data += 4*sizeof(SHA_LONG);
235 }
236 sha1_block(c,p=c->data,1);
237 len-=SHA_CBLOCK;
238 continue;
239 }
240#endif
241#endif
242#ifndef SHA_NO_TAIL_CODE
243 /*
244 * In addition to "sizeof(SHA_LONG)!= 4" case the
245 * following code covers unaligned access cases on
246 * little-endian machines.
247 * <appro@fy.chalmers.se>
248 */
249 p=c->data;
250 for (sw=(SHA_LBLOCK/4); sw; sw--)
251 {
252 M_c2nl(data,l); p[0]=l;
253 M_c2nl(data,l); p[1]=l;
254 M_c2nl(data,l); p[2]=l;
255 M_c2nl(data,l); p[3]=l;
256 p+=4;
257 }
258 p=c->data;
259 sha1_block(c,p,1);
260 len-=SHA_CBLOCK;
261#endif
262 }
263 ec=(int)len;
264 c->num=ec;
265 ew=(ec>>2);
266 ec&=0x03;
267
268 for (sw=0; sw < ew; sw++)
269 { M_c2nl(data,l); p[sw]=l; }
270 M_c2nl_p(data,l,ec);
271 p[sw]=l;
272 }
273
274void SHA1_Transform(SHA_CTX *c, unsigned char *b)
275 {
276 SHA_LONG p[SHA_LBLOCK];
277
278#if SHA_LONG_LOG2==2
279#if defined(B_ENDIAN) || defined(SHA1_ASM)
280 memcpy(p,b,SHA_CBLOCK);
281 sha1_block(c,p,1);
282 return;
283#elif defined(L_ENDIAN)
284 if (((unsigned long)b%sizeof(SHA_LONG)) == 0)
285 {
286 SHA_LONG *q;
287 int i;
288
289 q=p;
290 for (i=(SHA_LBLOCK/4); i; i--)
291 {
292 unsigned long l;
293 BE_COPY(q,b,0); /* BE_COPY was defined above */
294 BE_COPY(q,b,1);
295 BE_COPY(q,b,2);
296 BE_COPY(q,b,3);
297 q+=4;
298 b+=4*sizeof(SHA_LONG);
299 }
300 sha1_block(c,p,1);
301 return;
302 }
303#endif
304#endif
305#ifndef SHA_NO_TAIL_CODE /* defined above, see comment */
306 {
307 SHA_LONG *q;
308 int i;
309
310 q=p;
311 for (i=(SHA_LBLOCK/4); i; i--)
312 {
313 SHA_LONG l;
314 c2nl(b,l); *(q++)=l;
315 c2nl(b,l); *(q++)=l;
316 c2nl(b,l); *(q++)=l;
317 c2nl(b,l); *(q++)=l;
318 }
319 sha1_block(c,p,1);
320 }
321#endif
322 }
323
324#ifndef SHA1_ASM
325static void sha1_block(SHA_CTX *c, register SHA_LONG *W, int num)
326 {
327 register SHA_LONG A,B,C,D,E,T;
328 SHA_LONG X[SHA_LBLOCK];
329
330 A=c->h0;
331 B=c->h1;
332 C=c->h2;
333 D=c->h3;
334 E=c->h4;
335 63
336 for (;;) 64#include <openssl/opensslv.h>
337 {
338 BODY_00_15( 0,A,B,C,D,E,T,W);
339 BODY_00_15( 1,T,A,B,C,D,E,W);
340 BODY_00_15( 2,E,T,A,B,C,D,W);
341 BODY_00_15( 3,D,E,T,A,B,C,W);
342 BODY_00_15( 4,C,D,E,T,A,B,W);
343 BODY_00_15( 5,B,C,D,E,T,A,W);
344 BODY_00_15( 6,A,B,C,D,E,T,W);
345 BODY_00_15( 7,T,A,B,C,D,E,W);
346 BODY_00_15( 8,E,T,A,B,C,D,W);
347 BODY_00_15( 9,D,E,T,A,B,C,W);
348 BODY_00_15(10,C,D,E,T,A,B,W);
349 BODY_00_15(11,B,C,D,E,T,A,W);
350 BODY_00_15(12,A,B,C,D,E,T,W);
351 BODY_00_15(13,T,A,B,C,D,E,W);
352 BODY_00_15(14,E,T,A,B,C,D,W);
353 BODY_00_15(15,D,E,T,A,B,C,W);
354 BODY_16_19(16,C,D,E,T,A,B,W,W,W,W);
355 BODY_16_19(17,B,C,D,E,T,A,W,W,W,W);
356 BODY_16_19(18,A,B,C,D,E,T,W,W,W,W);
357 BODY_16_19(19,T,A,B,C,D,E,W,W,W,X);
358
359 BODY_20_31(20,E,T,A,B,C,D,W,W,W,X);
360 BODY_20_31(21,D,E,T,A,B,C,W,W,W,X);
361 BODY_20_31(22,C,D,E,T,A,B,W,W,W,X);
362 BODY_20_31(23,B,C,D,E,T,A,W,W,W,X);
363 BODY_20_31(24,A,B,C,D,E,T,W,W,X,X);
364 BODY_20_31(25,T,A,B,C,D,E,W,W,X,X);
365 BODY_20_31(26,E,T,A,B,C,D,W,W,X,X);
366 BODY_20_31(27,D,E,T,A,B,C,W,W,X,X);
367 BODY_20_31(28,C,D,E,T,A,B,W,W,X,X);
368 BODY_20_31(29,B,C,D,E,T,A,W,W,X,X);
369 BODY_20_31(30,A,B,C,D,E,T,W,X,X,X);
370 BODY_20_31(31,T,A,B,C,D,E,W,X,X,X);
371 BODY_32_39(32,E,T,A,B,C,D,X);
372 BODY_32_39(33,D,E,T,A,B,C,X);
373 BODY_32_39(34,C,D,E,T,A,B,X);
374 BODY_32_39(35,B,C,D,E,T,A,X);
375 BODY_32_39(36,A,B,C,D,E,T,X);
376 BODY_32_39(37,T,A,B,C,D,E,X);
377 BODY_32_39(38,E,T,A,B,C,D,X);
378 BODY_32_39(39,D,E,T,A,B,C,X);
379
380 BODY_40_59(40,C,D,E,T,A,B,X);
381 BODY_40_59(41,B,C,D,E,T,A,X);
382 BODY_40_59(42,A,B,C,D,E,T,X);
383 BODY_40_59(43,T,A,B,C,D,E,X);
384 BODY_40_59(44,E,T,A,B,C,D,X);
385 BODY_40_59(45,D,E,T,A,B,C,X);
386 BODY_40_59(46,C,D,E,T,A,B,X);
387 BODY_40_59(47,B,C,D,E,T,A,X);
388 BODY_40_59(48,A,B,C,D,E,T,X);
389 BODY_40_59(49,T,A,B,C,D,E,X);
390 BODY_40_59(50,E,T,A,B,C,D,X);
391 BODY_40_59(51,D,E,T,A,B,C,X);
392 BODY_40_59(52,C,D,E,T,A,B,X);
393 BODY_40_59(53,B,C,D,E,T,A,X);
394 BODY_40_59(54,A,B,C,D,E,T,X);
395 BODY_40_59(55,T,A,B,C,D,E,X);
396 BODY_40_59(56,E,T,A,B,C,D,X);
397 BODY_40_59(57,D,E,T,A,B,C,X);
398 BODY_40_59(58,C,D,E,T,A,B,X);
399 BODY_40_59(59,B,C,D,E,T,A,X);
400
401 BODY_60_79(60,A,B,C,D,E,T,X);
402 BODY_60_79(61,T,A,B,C,D,E,X);
403 BODY_60_79(62,E,T,A,B,C,D,X);
404 BODY_60_79(63,D,E,T,A,B,C,X);
405 BODY_60_79(64,C,D,E,T,A,B,X);
406 BODY_60_79(65,B,C,D,E,T,A,X);
407 BODY_60_79(66,A,B,C,D,E,T,X);
408 BODY_60_79(67,T,A,B,C,D,E,X);
409 BODY_60_79(68,E,T,A,B,C,D,X);
410 BODY_60_79(69,D,E,T,A,B,C,X);
411 BODY_60_79(70,C,D,E,T,A,B,X);
412 BODY_60_79(71,B,C,D,E,T,A,X);
413 BODY_60_79(72,A,B,C,D,E,T,X);
414 BODY_60_79(73,T,A,B,C,D,E,X);
415 BODY_60_79(74,E,T,A,B,C,D,X);
416 BODY_60_79(75,D,E,T,A,B,C,X);
417 BODY_60_79(76,C,D,E,T,A,B,X);
418 BODY_60_79(77,B,C,D,E,T,A,X);
419 BODY_60_79(78,A,B,C,D,E,T,X);
420 BODY_60_79(79,T,A,B,C,D,E,X);
421
422 c->h0=(c->h0+E)&0xffffffffL;
423 c->h1=(c->h1+T)&0xffffffffL;
424 c->h2=(c->h2+A)&0xffffffffL;
425 c->h3=(c->h3+B)&0xffffffffL;
426 c->h4=(c->h4+C)&0xffffffffL;
427
428 if (--num <= 0) break;
429 65
430 A=c->h0; 66const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT;
431 B=c->h1;
432 C=c->h2;
433 D=c->h3;
434 E=c->h4;
435 67
436 W+=SHA_LBLOCK; /* Note! This can happen only when sizeof(SHA_LONG) 68/* The implementation is in ../md32_common.h */
437 * is 4. Whenever it's not the actual case this
438 * function is never called with num larger than 1
439 * and we never advance down here.
440 * <appro@fy.chalmers.se>
441 */
442 }
443 }
444#endif
445 69
446void SHA1_Final(unsigned char *md, SHA_CTX *c) 70#include "sha_locl.h"
447 {
448 register int i,j;
449 register SHA_LONG l;
450 register SHA_LONG *p;
451 static unsigned char end[4]={0x80,0x00,0x00,0x00};
452 unsigned char *cp=end;
453
454 /* c->num should definitly have room for at least one more byte. */
455 p=c->data;
456 j=c->num;
457 i=j>>2;
458#ifdef PURIFY
459 if ((j&0x03) == 0) p[i]=0;
460#endif
461 l=p[i];
462 M_p_c2nl(cp,l,j&0x03);
463 p[i]=l;
464 i++;
465 /* i is the next 'undefined word' */
466 if (c->num >= SHA_LAST_BLOCK)
467 {
468 for (; i<SHA_LBLOCK; i++)
469 p[i]=0;
470 sha1_block(c,p,1);
471 i=0;
472 }
473 for (; i<(SHA_LBLOCK-2); i++)
474 p[i]=0;
475 p[SHA_LBLOCK-2]=c->Nh;
476 p[SHA_LBLOCK-1]=c->Nl;
477#if SHA_LONG_LOG2==2
478#if !defined(B_ENDIAN) && defined(SHA1_ASM)
479 Endian_Reverse32(p[SHA_LBLOCK-2]);
480 Endian_Reverse32(p[SHA_LBLOCK-1]);
481#endif
482#endif
483 sha1_block(c,p,1);
484 cp=md;
485 l=c->h0; nl2c(l,cp);
486 l=c->h1; nl2c(l,cp);
487 l=c->h2; nl2c(l,cp);
488 l=c->h3; nl2c(l,cp);
489 l=c->h4; nl2c(l,cp);
490 71
491 c->num=0;
492 /* sha_block may be leaving some stuff on the stack
493 * but I'm not worried :-)
494 memset((void *)c,0,sizeof(SHA_CTX));
495 */
496 }
497#endif 72#endif
498 73
diff --git a/src/lib/libssl/src/crypto/sha/sha1s.cpp b/src/lib/libssl/src/crypto/sha/sha1s.cpp
index 3103e1871b..af23d1e0f2 100644
--- a/src/lib/libssl/src/crypto/sha/sha1s.cpp
+++ b/src/lib/libssl/src/crypto/sha/sha1s.cpp
@@ -34,6 +34,7 @@ void GetTSC(unsigned long& tsc)
34#include <stdlib.h> 34#include <stdlib.h>
35#include <openssl/sha.h> 35#include <openssl/sha.h>
36 36
37#define sha1_block_x86 sha1_block_asm_data_order
37extern "C" { 38extern "C" {
38void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num); 39void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num);
39} 40}
@@ -55,8 +56,10 @@ void main(int argc,char *argv[])
55 if (num == 0) num=16; 56 if (num == 0) num=16;
56 if (num > 250) num=16; 57 if (num > 250) num=16;
57 numm=num+2; 58 numm=num+2;
59#if 0
58 num*=64; 60 num*=64;
59 numm*=64; 61 numm*=64;
62#endif
60 63
61 for (j=0; j<6; j++) 64 for (j=0; j<6; j++)
62 { 65 {
@@ -72,7 +75,7 @@ void main(int argc,char *argv[])
72 sha1_block_x86(&ctx,buffer,num); 75 sha1_block_x86(&ctx,buffer,num);
73 } 76 }
74 77
75 printf("sha1 (%d bytes) %d %d (%.2f)\n",num, 78 printf("sha1 (%d bytes) %d %d (%.2f)\n",num*64,
76 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
77 } 80 }
78 } 81 }
diff --git a/src/lib/libssl/src/crypto/sha/sha1test.c b/src/lib/libssl/src/crypto/sha/sha1test.c
index 9400ad2a61..688d06c637 100644
--- a/src/lib/libssl/src/crypto/sha/sha1test.c
+++ b/src/lib/libssl/src/crypto/sha/sha1test.c
@@ -76,26 +76,26 @@ int main(int argc, char *argv[])
76#undef SHA_0 /* FIPS 180 */ 76#undef SHA_0 /* FIPS 180 */
77#define SHA_1 /* FIPS 180-1 */ 77#define SHA_1 /* FIPS 180-1 */
78 78
79char *test[]={ 79static char *test[]={
80 "abc", 80 "abc",
81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
82 NULL, 82 NULL,
83 }; 83 };
84 84
85#ifdef SHA_0 85#ifdef SHA_0
86char *ret[]={ 86static char *ret[]={
87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", 87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8", 88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
89 }; 89 };
90char *bigret= 90static char *bigret=
91 "3232affa48628a26653b5aaa44541fd90d690603"; 91 "3232affa48628a26653b5aaa44541fd90d690603";
92#endif 92#endif
93#ifdef SHA_1 93#ifdef SHA_1
94char *ret[]={ 94static char *ret[]={
95 "a9993e364706816aba3e25717850c26c9cd0d89d", 95 "a9993e364706816aba3e25717850c26c9cd0d89d",
96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1", 96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
97 }; 97 };
98char *bigret= 98static char *bigret=
99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; 99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
100#endif 100#endif
101 101
diff --git a/src/lib/libssl/src/crypto/sha/sha_dgst.c b/src/lib/libssl/src/crypto/sha/sha_dgst.c
index 4df535360f..894a96274a 100644
--- a/src/lib/libssl/src/crypto/sha/sha_dgst.c
+++ b/src/lib/libssl/src/crypto/sha/sha_dgst.c
@@ -1,4 +1,4 @@
1/* crypto/sha/sha_dgst.c */ 1/* crypto/sha/sha1dgst.c */
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 *
@@ -56,437 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h> 59#if !defined(NO_SHA0) && !defined(NO_SHA)
60#include <string.h>
61#define SHA_0
62#undef SHA_1
63#include <openssl/sha.h>
64#include "sha_locl.h"
65#include <openssl/opensslv.h>
66
67#ifndef NO_SHA0
68char *SHA_version="SHA" OPENSSL_VERSION_PTEXT;
69
70/* Implemented from SHA-0 document - The Secure Hash Algorithm
71 */
72
73#define INIT_DATA_h0 0x67452301UL
74#define INIT_DATA_h1 0xefcdab89UL
75#define INIT_DATA_h2 0x98badcfeUL
76#define INIT_DATA_h3 0x10325476UL
77#define INIT_DATA_h4 0xc3d2e1f0UL
78
79#define K_00_19 0x5a827999UL
80#define K_20_39 0x6ed9eba1UL
81#define K_40_59 0x8f1bbcdcUL
82#define K_60_79 0xca62c1d6UL
83
84static void sha_block(SHA_CTX *c, register SHA_LONG *p, int num);
85
86#if !defined(B_ENDIAN) && defined(SHA_ASM)
87# define M_c2nl c2l
88# define M_p_c2nl p_c2l
89# define M_c2nl_p c2l_p
90# define M_p_c2nl_p p_c2l_p
91# define M_nl2c l2c
92#else
93# define M_c2nl c2nl
94# define M_p_c2nl p_c2nl
95# define M_c2nl_p c2nl_p
96# define M_p_c2nl_p p_c2nl_p
97# define M_nl2c nl2c
98#endif
99
100void SHA_Init(SHA_CTX *c)
101 {
102 c->h0=INIT_DATA_h0;
103 c->h1=INIT_DATA_h1;
104 c->h2=INIT_DATA_h2;
105 c->h3=INIT_DATA_h3;
106 c->h4=INIT_DATA_h4;
107 c->Nl=0;
108 c->Nh=0;
109 c->num=0;
110 }
111 60
112void SHA_Update(SHA_CTX *c, register const unsigned char *data, 61#undef SHA_1
113 unsigned long len) 62#define SHA_0
114 {
115 register SHA_LONG *p;
116 int ew,ec,sw,sc;
117 SHA_LONG l;
118
119 if (len == 0) return;
120
121 l=(c->Nl+(len<<3))&0xffffffffL;
122 if (l < c->Nl) /* overflow */
123 c->Nh++;
124 c->Nh+=(len>>29);
125 c->Nl=l;
126
127 if (c->num != 0)
128 {
129 p=c->data;
130 sw=c->num>>2;
131 sc=c->num&0x03;
132
133 if ((c->num+len) >= SHA_CBLOCK)
134 {
135 l= p[sw];
136 M_p_c2nl(data,l,sc);
137 p[sw++]=l;
138 for (; sw<SHA_LBLOCK; sw++)
139 {
140 M_c2nl(data,l);
141 p[sw]=l;
142 }
143 len-=(SHA_CBLOCK-c->num);
144
145 sha_block(c,p,1);
146 c->num=0;
147 /* drop through and do the rest */
148 }
149 else
150 {
151 c->num+=(int)len;
152 if ((sc+len) < 4) /* ugly, add char's to a word */
153 {
154 l= p[sw];
155 M_p_c2nl_p(data,l,sc,len);
156 p[sw]=l;
157 }
158 else
159 {
160 ew=(c->num>>2);
161 ec=(c->num&0x03);
162 l= p[sw];
163 M_p_c2nl(data,l,sc);
164 p[sw++]=l;
165 for (; sw < ew; sw++)
166 { M_c2nl(data,l); p[sw]=l; }
167 if (ec)
168 {
169 M_c2nl_p(data,l,ec);
170 p[sw]=l;
171 }
172 }
173 return;
174 }
175 }
176 /* We can only do the following code for assember, the reason
177 * being that the sha_block 'C' version changes the values
178 * in the 'data' array. The assember code avoids this and
179 * copies it to a local array. I should be able to do this for
180 * the C version as well....
181 */
182#if SHA_LONG_LOG2==2
183#if defined(B_ENDIAN) || defined(SHA_ASM)
184 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
185 {
186 sw=len/SHA_CBLOCK;
187 if (sw)
188 {
189 sha_block(c,(SHA_LONG *)data,sw);
190 sw*=SHA_CBLOCK;
191 data+=sw;
192 len-=sw;
193 }
194 }
195#endif
196#endif
197 /* we now can process the input data in blocks of SHA_CBLOCK
198 * chars and save the leftovers to c->data. */
199 p=c->data;
200 while (len >= SHA_CBLOCK)
201 {
202#if SHA_LONG_LOG2==2
203#if defined(B_ENDIAN) || defined(SHA_ASM)
204#define SHA_NO_TAIL_CODE
205 /*
206 * Basically we get here only when data happens
207 * to be unaligned.
208 */
209 if (p != (SHA_LONG *)data)
210 memcpy(p,data,SHA_CBLOCK);
211 data+=SHA_CBLOCK;
212 sha_block(c,p=c->data,1);
213 len-=SHA_CBLOCK;
214#elif defined(L_ENDIAN)
215#define BE_COPY(dst,src,i) { \
216 l = ((SHA_LONG *)src)[i]; \
217 Endian_Reverse32(l); \
218 dst[i] = l; \
219 }
220 if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
221 {
222 for (sw=(SHA_LBLOCK/4); sw; sw--)
223 {
224 BE_COPY(p,data,0);
225 BE_COPY(p,data,1);
226 BE_COPY(p,data,2);
227 BE_COPY(p,data,3);
228 p+=4;
229 data += 4*sizeof(SHA_LONG);
230 }
231 sha_block(c,p=c->data,1);
232 len-=SHA_CBLOCK;
233 continue;
234 }
235#endif
236#endif
237#ifndef SHA_NO_TAIL_CODE
238 /*
239 * In addition to "sizeof(SHA_LONG)!= 4" case the
240 * following code covers unaligned access cases on
241 * little-endian machines.
242 * <appro@fy.chalmers.se>
243 */
244 p=c->data;
245 for (sw=(SHA_LBLOCK/4); sw; sw--)
246 {
247 M_c2nl(data,l); p[0]=l;
248 M_c2nl(data,l); p[1]=l;
249 M_c2nl(data,l); p[2]=l;
250 M_c2nl(data,l); p[3]=l;
251 p+=4;
252 }
253 p=c->data;
254 sha_block(c,p,1);
255 len-=SHA_CBLOCK;
256#endif
257 }
258 ec=(int)len;
259 c->num=ec;
260 ew=(ec>>2);
261 ec&=0x03;
262 63
263 for (sw=0; sw < ew; sw++) 64#include <openssl/opensslv.h>
264 { M_c2nl(data,l); p[sw]=l; }
265 M_c2nl_p(data,l,ec);
266 p[sw]=l;
267 }
268
269void SHA_Transform(SHA_CTX *c, unsigned char *b)
270 {
271 SHA_LONG p[SHA_LBLOCK];
272
273#if SHA_LONG_LOG2==2
274#if defined(B_ENDIAN) || defined(SHA_ASM)
275 memcpy(p,b,SHA_CBLOCK);
276 sha_block(c,p,1);
277 return;
278#elif defined(L_ENDIAN)
279 if (((unsigned long)b%sizeof(SHA_LONG)) == 0)
280 {
281 SHA_LONG *q;
282 int i;
283
284 q=p;
285 for (i=(SHA_LBLOCK/4); i; i--)
286 {
287 unsigned long l;
288 BE_COPY(q,b,0); /* BE_COPY was defined above */
289 BE_COPY(q,b,1);
290 BE_COPY(q,b,2);
291 BE_COPY(q,b,3);
292 q+=4;
293 b+=4*sizeof(SHA_LONG);
294 }
295 sha_block(c,p,1);
296 return;
297 }
298#endif
299#endif
300#ifndef SHA_NO_TAIL_CODE /* defined above, see comment */
301 {
302 SHA_LONG *q;
303 int i;
304
305 q=p;
306 for (i=(SHA_LBLOCK/4); i; i--)
307 {
308 SHA_LONG l;
309 c2nl(b,l); *(q++)=l;
310 c2nl(b,l); *(q++)=l;
311 c2nl(b,l); *(q++)=l;
312 c2nl(b,l); *(q++)=l;
313 }
314 sha_block(c,p,1);
315 }
316#endif
317 }
318
319#ifndef SHA_ASM
320static void sha_block(SHA_CTX *c, register SHA_LONG *W, int num)
321 {
322 register SHA_LONG A,B,C,D,E,T;
323 SHA_LONG X[SHA_LBLOCK];
324
325 A=c->h0;
326 B=c->h1;
327 C=c->h2;
328 D=c->h3;
329 E=c->h4;
330
331 for (;;)
332 {
333 BODY_00_15( 0,A,B,C,D,E,T,W);
334 BODY_00_15( 1,T,A,B,C,D,E,W);
335 BODY_00_15( 2,E,T,A,B,C,D,W);
336 BODY_00_15( 3,D,E,T,A,B,C,W);
337 BODY_00_15( 4,C,D,E,T,A,B,W);
338 BODY_00_15( 5,B,C,D,E,T,A,W);
339 BODY_00_15( 6,A,B,C,D,E,T,W);
340 BODY_00_15( 7,T,A,B,C,D,E,W);
341 BODY_00_15( 8,E,T,A,B,C,D,W);
342 BODY_00_15( 9,D,E,T,A,B,C,W);
343 BODY_00_15(10,C,D,E,T,A,B,W);
344 BODY_00_15(11,B,C,D,E,T,A,W);
345 BODY_00_15(12,A,B,C,D,E,T,W);
346 BODY_00_15(13,T,A,B,C,D,E,W);
347 BODY_00_15(14,E,T,A,B,C,D,W);
348 BODY_00_15(15,D,E,T,A,B,C,W);
349 BODY_16_19(16,C,D,E,T,A,B,W,W,W,W);
350 BODY_16_19(17,B,C,D,E,T,A,W,W,W,W);
351 BODY_16_19(18,A,B,C,D,E,T,W,W,W,W);
352 BODY_16_19(19,T,A,B,C,D,E,W,W,W,X);
353
354 BODY_20_31(20,E,T,A,B,C,D,W,W,W,X);
355 BODY_20_31(21,D,E,T,A,B,C,W,W,W,X);
356 BODY_20_31(22,C,D,E,T,A,B,W,W,W,X);
357 BODY_20_31(23,B,C,D,E,T,A,W,W,W,X);
358 BODY_20_31(24,A,B,C,D,E,T,W,W,X,X);
359 BODY_20_31(25,T,A,B,C,D,E,W,W,X,X);
360 BODY_20_31(26,E,T,A,B,C,D,W,W,X,X);
361 BODY_20_31(27,D,E,T,A,B,C,W,W,X,X);
362 BODY_20_31(28,C,D,E,T,A,B,W,W,X,X);
363 BODY_20_31(29,B,C,D,E,T,A,W,W,X,X);
364 BODY_20_31(30,A,B,C,D,E,T,W,X,X,X);
365 BODY_20_31(31,T,A,B,C,D,E,W,X,X,X);
366 BODY_32_39(32,E,T,A,B,C,D,X);
367 BODY_32_39(33,D,E,T,A,B,C,X);
368 BODY_32_39(34,C,D,E,T,A,B,X);
369 BODY_32_39(35,B,C,D,E,T,A,X);
370 BODY_32_39(36,A,B,C,D,E,T,X);
371 BODY_32_39(37,T,A,B,C,D,E,X);
372 BODY_32_39(38,E,T,A,B,C,D,X);
373 BODY_32_39(39,D,E,T,A,B,C,X);
374
375 BODY_40_59(40,C,D,E,T,A,B,X);
376 BODY_40_59(41,B,C,D,E,T,A,X);
377 BODY_40_59(42,A,B,C,D,E,T,X);
378 BODY_40_59(43,T,A,B,C,D,E,X);
379 BODY_40_59(44,E,T,A,B,C,D,X);
380 BODY_40_59(45,D,E,T,A,B,C,X);
381 BODY_40_59(46,C,D,E,T,A,B,X);
382 BODY_40_59(47,B,C,D,E,T,A,X);
383 BODY_40_59(48,A,B,C,D,E,T,X);
384 BODY_40_59(49,T,A,B,C,D,E,X);
385 BODY_40_59(50,E,T,A,B,C,D,X);
386 BODY_40_59(51,D,E,T,A,B,C,X);
387 BODY_40_59(52,C,D,E,T,A,B,X);
388 BODY_40_59(53,B,C,D,E,T,A,X);
389 BODY_40_59(54,A,B,C,D,E,T,X);
390 BODY_40_59(55,T,A,B,C,D,E,X);
391 BODY_40_59(56,E,T,A,B,C,D,X);
392 BODY_40_59(57,D,E,T,A,B,C,X);
393 BODY_40_59(58,C,D,E,T,A,B,X);
394 BODY_40_59(59,B,C,D,E,T,A,X);
395
396 BODY_60_79(60,A,B,C,D,E,T,X);
397 BODY_60_79(61,T,A,B,C,D,E,X);
398 BODY_60_79(62,E,T,A,B,C,D,X);
399 BODY_60_79(63,D,E,T,A,B,C,X);
400 BODY_60_79(64,C,D,E,T,A,B,X);
401 BODY_60_79(65,B,C,D,E,T,A,X);
402 BODY_60_79(66,A,B,C,D,E,T,X);
403 BODY_60_79(67,T,A,B,C,D,E,X);
404 BODY_60_79(68,E,T,A,B,C,D,X);
405 BODY_60_79(69,D,E,T,A,B,C,X);
406 BODY_60_79(70,C,D,E,T,A,B,X);
407 BODY_60_79(71,B,C,D,E,T,A,X);
408 BODY_60_79(72,A,B,C,D,E,T,X);
409 BODY_60_79(73,T,A,B,C,D,E,X);
410 BODY_60_79(74,E,T,A,B,C,D,X);
411 BODY_60_79(75,D,E,T,A,B,C,X);
412 BODY_60_79(76,C,D,E,T,A,B,X);
413 BODY_60_79(77,B,C,D,E,T,A,X);
414 BODY_60_79(78,A,B,C,D,E,T,X);
415 BODY_60_79(79,T,A,B,C,D,E,X);
416
417 c->h0=(c->h0+E)&0xffffffffL;
418 c->h1=(c->h1+T)&0xffffffffL;
419 c->h2=(c->h2+A)&0xffffffffL;
420 c->h3=(c->h3+B)&0xffffffffL;
421 c->h4=(c->h4+C)&0xffffffffL;
422
423 if (--num <= 0) break;
424 65
425 A=c->h0; 66const char *SHA_version="SHA" OPENSSL_VERSION_PTEXT;
426 B=c->h1;
427 C=c->h2;
428 D=c->h3;
429 E=c->h4;
430 67
431 W+=SHA_LBLOCK; /* Note! This can happen only when sizeof(SHA_LONG) 68/* The implementation is in ../md32_common.h */
432 * is 4. Whenever it's not the actual case this
433 * function is never called with num larger than 1
434 * and we never advance down here.
435 * <appro@fy.chalmers.se>
436 */
437 }
438 }
439#endif
440 69
441void SHA_Final(unsigned char *md, SHA_CTX *c) 70#include "sha_locl.h"
442 {
443 register int i,j;
444 register SHA_LONG l;
445 register SHA_LONG *p;
446 static unsigned char end[4]={0x80,0x00,0x00,0x00};
447 unsigned char *cp=end;
448 71
449 /* c->num should definitly have room for at least one more byte. */
450 p=c->data;
451 j=c->num;
452 i=j>>2;
453#ifdef PURIFY
454 if ((j&0x03) == 0) p[i]=0;
455#endif
456 l=p[i];
457 M_p_c2nl(cp,l,j&0x03);
458 p[i]=l;
459 i++;
460 /* i is the next 'undefined word' */
461 if (c->num >= SHA_LAST_BLOCK)
462 {
463 for (; i<SHA_LBLOCK; i++)
464 p[i]=0;
465 sha_block(c,p,1);
466 i=0;
467 }
468 for (; i<(SHA_LBLOCK-2); i++)
469 p[i]=0;
470 p[SHA_LBLOCK-2]=c->Nh;
471 p[SHA_LBLOCK-1]=c->Nl;
472#if SHA_LONG_LOG2==2
473#if !defined(B_ENDIAN) && defined(SHA_ASM)
474 Endian_Reverse32(p[SHA_LBLOCK-2]);
475 Endian_Reverse32(p[SHA_LBLOCK-1]);
476#endif 72#endif
477#endif
478 sha_block(c,p,1);
479 cp=md;
480 l=c->h0; nl2c(l,cp);
481 l=c->h1; nl2c(l,cp);
482 l=c->h2; nl2c(l,cp);
483 l=c->h3; nl2c(l,cp);
484 l=c->h4; nl2c(l,cp);
485 73
486 c->num=0;
487 /* sha_block may be leaving some stuff on the stack
488 * but I'm not worried :-)
489 memset((void *)c,0,sizeof(SHA_CTX));
490 */
491 }
492#endif
diff --git a/src/lib/libssl/src/crypto/sha/sha_locl.h b/src/lib/libssl/src/crypto/sha/sha_locl.h
index 6646a8915b..3e6f489b87 100644
--- a/src/lib/libssl/src/crypto/sha/sha_locl.h
+++ b/src/lib/libssl/src/crypto/sha/sha_locl.h
@@ -60,180 +60,105 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63#include <openssl/sha.h>
64#ifdef undef
65/* one or the other needs to be defined */
66#ifndef SHA_1 /* FIPE 180-1 */
67#define SHA_0 /* FIPS 180 */
68#endif
69#endif
70
71#undef c2nl
72#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
73 l|=(((unsigned long)(*((c)++)))<<16), \
74 l|=(((unsigned long)(*((c)++)))<< 8), \
75 l|=(((unsigned long)(*((c)++))) ))
76
77#undef p_c2nl
78#define p_c2nl(c,l,n) { \
79 switch (n) { \
80 case 0: l =((unsigned long)(*((c)++)))<<24; \
81 case 1: l|=((unsigned long)(*((c)++)))<<16; \
82 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
83 case 3: l|=((unsigned long)(*((c)++))); \
84 } \
85 }
86
87#undef c2nl_p
88/* NOTE the pointer is not incremented at the end of this */
89#define c2nl_p(c,l,n) { \
90 l=0; \
91 (c)+=n; \
92 switch (n) { \
93 case 3: l =((unsigned long)(*(--(c))))<< 8; \
94 case 2: l|=((unsigned long)(*(--(c))))<<16; \
95 case 1: l|=((unsigned long)(*(--(c))))<<24; \
96 } \
97 }
98
99#undef p_c2nl_p
100#define p_c2nl_p(c,l,sc,len) { \
101 switch (sc) \
102 { \
103 case 0: l =((unsigned long)(*((c)++)))<<24; \
104 if (--len == 0) break; \
105 case 1: l|=((unsigned long)(*((c)++)))<<16; \
106 if (--len == 0) break; \
107 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
108 } \
109 }
110
111#undef nl2c
112#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
113 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
114 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
115 *((c)++)=(unsigned char)(((l) )&0xff))
116
117#undef c2l
118#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
119 l|=(((unsigned long)(*((c)++)))<< 8), \
120 l|=(((unsigned long)(*((c)++)))<<16), \
121 l|=(((unsigned long)(*((c)++)))<<24))
122
123#undef p_c2l
124#define p_c2l(c,l,n) { \
125 switch (n) { \
126 case 0: l =((unsigned long)(*((c)++))); \
127 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
128 case 2: l|=((unsigned long)(*((c)++)))<<16; \
129 case 3: l|=((unsigned long)(*((c)++)))<<24; \
130 } \
131 }
132
133#undef c2l_p
134/* NOTE the pointer is not incremented at the end of this */
135#define c2l_p(c,l,n) { \
136 l=0; \
137 (c)+=n; \
138 switch (n) { \
139 case 3: l =((unsigned long)(*(--(c))))<<16; \
140 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
141 case 1: l|=((unsigned long)(*(--(c)))); \
142 } \
143 }
144
145#undef p_c2l_p
146#define p_c2l_p(c,l,sc,len) { \
147 switch (sc) \
148 { \
149 case 0: l =((unsigned long)(*((c)++))); \
150 if (--len == 0) break; \
151 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
152 if (--len == 0) break; \
153 case 2: l|=((unsigned long)(*((c)++)))<<16; \
154 } \
155 }
156
157#undef l2c
158#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
159 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
160 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
161 *((c)++)=(unsigned char)(((l)>>24)&0xff))
162 64
163#ifndef SHA_LONG_LOG2 65#ifndef SHA_LONG_LOG2
164#define SHA_LONG_LOG2 2 /* default to 32 bits */ 66#define SHA_LONG_LOG2 2 /* default to 32 bits */
165#endif 67#endif
166 68
167#undef ROTATE 69#define DATA_ORDER_IS_BIG_ENDIAN
168#undef Endian_Reverse32 70
169#if defined(WIN32) 71#define HASH_LONG SHA_LONG
170#define ROTATE(a,n) _lrotl(a,n) 72#define HASH_LONG_LOG2 SHA_LONG_LOG2
171#elif defined(__GNUC__) && !defined(PEDANTIC) 73#define HASH_CTX SHA_CTX
172/* some inline assembler templates by <appro@fy.chalmers.se> */ 74#define HASH_CBLOCK SHA_CBLOCK
173#if defined(__i386) && !defined(NO_ASM) 75#define HASH_LBLOCK SHA_LBLOCK
174#define ROTATE(a,n) ({ register unsigned int ret; \ 76#define HASH_MAKE_STRING(c,s) do { \
175 asm ("roll %1,%0" \ 77 unsigned long ll; \
176 : "=r"(ret) \ 78 ll=(c)->h0; HOST_l2c(ll,(s)); \
177 : "I"(n), "0"(a) \ 79 ll=(c)->h1; HOST_l2c(ll,(s)); \
178 : "cc"); \ 80 ll=(c)->h2; HOST_l2c(ll,(s)); \
179 ret; \ 81 ll=(c)->h3; HOST_l2c(ll,(s)); \
180 }) 82 ll=(c)->h4; HOST_l2c(ll,(s)); \
181#ifndef I386_ONLY 83 } while (0)
182#define Endian_Reverse32(a) \ 84
183 { register unsigned int ltmp=(a); \ 85#if defined(SHA_0)
184 asm ("bswapl %0" \ 86
185 : "=r"(ltmp) : "0"(ltmp)); \ 87# define HASH_UPDATE SHA_Update
186 (a)=ltmp; \ 88# define HASH_TRANSFORM SHA_Transform
187 } 89# define HASH_FINAL SHA_Final
188#endif 90# define HASH_INIT SHA_Init
189#elif defined(__powerpc) 91# define HASH_BLOCK_HOST_ORDER sha_block_host_order
190#define ROTATE(a,n) ({ register unsigned int ret; \ 92# define HASH_BLOCK_DATA_ORDER sha_block_data_order
191 asm ("rlwinm %0,%1,%2,0,31" \ 93# define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id))
192 : "=r"(ret) \ 94
193 : "r"(a), "I"(n)); \ 95 void sha_block_host_order (SHA_CTX *c, const void *p,int num);
194 ret; \ 96 void sha_block_data_order (SHA_CTX *c, const void *p,int num);
195 }) 97
196/* Endian_Reverse32 is not needed for PowerPC */ 98#elif defined(SHA_1)
197#endif 99
198#endif 100# define HASH_UPDATE SHA1_Update
101# define HASH_TRANSFORM SHA1_Transform
102# define HASH_FINAL SHA1_Final
103# define HASH_INIT SHA1_Init
104# define HASH_BLOCK_HOST_ORDER sha1_block_host_order
105# define HASH_BLOCK_DATA_ORDER sha1_block_data_order
106# if defined(__MWERKS__) && defined(__MC68K__)
107 /* Metrowerks for Motorola fails otherwise:-( <appro@fy.chalmers.se> */
108# define Xupdate(a,ix,ia,ib,ic,id) do { (a)=(ia^ib^ic^id); \
109 ix=(a)=ROTATE((a),1); \
110 } while (0)
111# else
112# define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \
113 ix=(a)=ROTATE((a),1) \
114 )
115# endif
116
117# ifdef SHA1_ASM
118# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
119# define sha1_block_host_order sha1_block_asm_host_order
120# define DONT_IMPLEMENT_BLOCK_HOST_ORDER
121# define sha1_block_data_order sha1_block_asm_data_order
122# define DONT_IMPLEMENT_BLOCK_DATA_ORDER
123# define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order
124# endif
125# endif
126 void sha1_block_host_order (SHA_CTX *c, const void *p,int num);
127 void sha1_block_data_order (SHA_CTX *c, const void *p,int num);
199 128
200/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
201#ifdef ROTATE
202#ifndef Endian_Reverse32
203/* 5 instructions with rotate instruction, else 9 */
204#define Endian_Reverse32(a) \
205 { \
206 unsigned long t=(a); \
207 (a)=((ROTATE(t,8)&0x00FF00FF)|(ROTATE((t&0x00FF00FF),24))); \
208 }
209#endif
210#else 129#else
211#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) 130# error "Either SHA_0 or SHA_1 must be defined."
212#ifndef Endian_Reverse32
213/* 6 instructions with rotate instruction, else 8 */
214#define Endian_Reverse32(a) \
215 { \
216 unsigned long t=(a); \
217 t=(((t>>8)&0x00FF00FF)|((t&0x00FF00FF)<<8)); \
218 (a)=ROTATE(t,16); \
219 }
220#endif 131#endif
221/* 132
222 * Originally the middle line started with l=(((l&0xFF00FF00)>>8)|... 133#ifndef FLAT_INC
223 * It's rewritten as above for two reasons: 134#include "../md32_common.h"
224 * - RISCs aren't good at long constants and have to explicitely 135#else
225 * compose 'em with several (well, usually 2) instructions in a 136#include "md32_common.h"
226 * register before performing the actual operation and (as you
227 * already realized:-) having same constant should inspire the
228 * compiler to permanently allocate the only register for it;
229 * - most modern CPUs have two ALUs, but usually only one has
230 * circuitry for shifts:-( this minor tweak inspires compiler
231 * to schedule shift instructions in a better way...
232 *
233 * <appro@fy.chalmers.se>
234 */
235#endif 137#endif
236 138
139#define INIT_DATA_h0 0x67452301UL
140#define INIT_DATA_h1 0xefcdab89UL
141#define INIT_DATA_h2 0x98badcfeUL
142#define INIT_DATA_h3 0x10325476UL
143#define INIT_DATA_h4 0xc3d2e1f0UL
144
145void HASH_INIT (SHA_CTX *c)
146 {
147 c->h0=INIT_DATA_h0;
148 c->h1=INIT_DATA_h1;
149 c->h2=INIT_DATA_h2;
150 c->h3=INIT_DATA_h3;
151 c->h4=INIT_DATA_h4;
152 c->Nl=0;
153 c->Nh=0;
154 c->num=0;
155 }
156
157#define K_00_19 0x5a827999UL
158#define K_20_39 0x6ed9eba1UL
159#define K_40_59 0x8f1bbcdcUL
160#define K_60_79 0xca62c1d6UL
161
237/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be 162/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be
238 * simplified to the code in F_00_19. Wei attributes these optimisations 163 * simplified to the code in F_00_19. Wei attributes these optimisations
239 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. 164 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
@@ -246,43 +171,305 @@
246#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) 171#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
247#define F_60_79(b,c,d) F_20_39(b,c,d) 172#define F_60_79(b,c,d) F_20_39(b,c,d)
248 173
249#undef Xupdate 174#define BODY_00_15(i,a,b,c,d,e,f,xi) \
250#ifdef SHA_0 175 (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
251#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\
252 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);
253#endif
254#ifdef SHA_1
255#define Xupdate(a,i,ia,ib,ic,id) (a)=\
256 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\
257 X[(i)&0x0f]=(a)=ROTATE((a),1);
258#endif
259
260#define BODY_00_15(i,a,b,c,d,e,f,xa) \
261 (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
262 (b)=ROTATE((b),30); 176 (b)=ROTATE((b),30);
263 177
264#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \ 178#define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
265 Xupdate(f,i,xa,xb,xc,xd); \ 179 Xupdate(f,xi,xa,xb,xc,xd); \
266 (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ 180 (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
267 (b)=ROTATE((b),30); 181 (b)=ROTATE((b),30);
268 182
269#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \ 183#define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
270 Xupdate(f,i,xa,xb,xc,xd); \ 184 Xupdate(f,xi,xa,xb,xc,xd); \
271 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ 185 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
272 (b)=ROTATE((b),30); 186 (b)=ROTATE((b),30);
273 187
274#define BODY_32_39(i,a,b,c,d,e,f,xa) \ 188#define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \
275 Xupdate(f,i,xa,xa,xa,xa); \ 189 Xupdate(f,xa,xa,xb,xc,xd); \
276 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ 190 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
277 (b)=ROTATE((b),30); 191 (b)=ROTATE((b),30);
278 192
279#define BODY_40_59(i,a,b,c,d,e,f,xa) \ 193#define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \
280 Xupdate(f,i,xa,xa,xa,xa); \ 194 Xupdate(f,xa,xa,xb,xc,xd); \
281 (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ 195 (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
282 (b)=ROTATE((b),30); 196 (b)=ROTATE((b),30);
283 197
284#define BODY_60_79(i,a,b,c,d,e,f,xa) \ 198#define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \
285 Xupdate(f,i,xa,xa,xa,xa); \ 199 Xupdate(f,xa,xa,xb,xc,xd); \
286 (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ 200 (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
287 (b)=ROTATE((b),30); 201 (b)=ROTATE((b),30);
288 202
203#ifdef X
204#undef X
205#endif
206#ifndef MD32_XARRAY
207 /*
208 * Originally X was an array. As it's automatic it's natural
209 * to expect RISC compiler to accomodate at least part of it in
210 * the register bank, isn't it? Unfortunately not all compilers
211 * "find" this expectation reasonable:-( On order to make such
212 * compilers generate better code I replace X[] with a bunch of
213 * X0, X1, etc. See the function body below...
214 * <appro@fy.chalmers.se>
215 */
216# define X(i) XX##i
217#else
218 /*
219 * However! Some compilers (most notably HP C) get overwhelmed by
220 * that many local variables so that we have to have the way to
221 * fall down to the original behavior.
222 */
223# define X(i) XX[i]
224#endif
225
226#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
227void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
228 {
229 const SHA_LONG *W=d;
230 register unsigned long A,B,C,D,E,T;
231#ifndef MD32_XARRAY
232 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
233 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
234#else
235 SHA_LONG XX[16];
236#endif
237
238 A=c->h0;
239 B=c->h1;
240 C=c->h2;
241 D=c->h3;
242 E=c->h4;
243
244 for (;;)
245 {
246 BODY_00_15( 0,A,B,C,D,E,T,W[ 0]);
247 BODY_00_15( 1,T,A,B,C,D,E,W[ 1]);
248 BODY_00_15( 2,E,T,A,B,C,D,W[ 2]);
249 BODY_00_15( 3,D,E,T,A,B,C,W[ 3]);
250 BODY_00_15( 4,C,D,E,T,A,B,W[ 4]);
251 BODY_00_15( 5,B,C,D,E,T,A,W[ 5]);
252 BODY_00_15( 6,A,B,C,D,E,T,W[ 6]);
253 BODY_00_15( 7,T,A,B,C,D,E,W[ 7]);
254 BODY_00_15( 8,E,T,A,B,C,D,W[ 8]);
255 BODY_00_15( 9,D,E,T,A,B,C,W[ 9]);
256 BODY_00_15(10,C,D,E,T,A,B,W[10]);
257 BODY_00_15(11,B,C,D,E,T,A,W[11]);
258 BODY_00_15(12,A,B,C,D,E,T,W[12]);
259 BODY_00_15(13,T,A,B,C,D,E,W[13]);
260 BODY_00_15(14,E,T,A,B,C,D,W[14]);
261 BODY_00_15(15,D,E,T,A,B,C,W[15]);
262
263 BODY_16_19(16,C,D,E,T,A,B,X( 0),W[ 0],W[ 2],W[ 8],W[13]);
264 BODY_16_19(17,B,C,D,E,T,A,X( 1),W[ 1],W[ 3],W[ 9],W[14]);
265 BODY_16_19(18,A,B,C,D,E,T,X( 2),W[ 2],W[ 4],W[10],W[15]);
266 BODY_16_19(19,T,A,B,C,D,E,X( 3),W[ 3],W[ 5],W[11],X( 0));
267
268 BODY_20_31(20,E,T,A,B,C,D,X( 4),W[ 4],W[ 6],W[12],X( 1));
269 BODY_20_31(21,D,E,T,A,B,C,X( 5),W[ 5],W[ 7],W[13],X( 2));
270 BODY_20_31(22,C,D,E,T,A,B,X( 6),W[ 6],W[ 8],W[14],X( 3));
271 BODY_20_31(23,B,C,D,E,T,A,X( 7),W[ 7],W[ 9],W[15],X( 4));
272 BODY_20_31(24,A,B,C,D,E,T,X( 8),W[ 8],W[10],X( 0),X( 5));
273 BODY_20_31(25,T,A,B,C,D,E,X( 9),W[ 9],W[11],X( 1),X( 6));
274 BODY_20_31(26,E,T,A,B,C,D,X(10),W[10],W[12],X( 2),X( 7));
275 BODY_20_31(27,D,E,T,A,B,C,X(11),W[11],W[13],X( 3),X( 8));
276 BODY_20_31(28,C,D,E,T,A,B,X(12),W[12],W[14],X( 4),X( 9));
277 BODY_20_31(29,B,C,D,E,T,A,X(13),W[13],W[15],X( 5),X(10));
278 BODY_20_31(30,A,B,C,D,E,T,X(14),W[14],X( 0),X( 6),X(11));
279 BODY_20_31(31,T,A,B,C,D,E,X(15),W[15],X( 1),X( 7),X(12));
280
281 BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
282 BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
283 BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
284 BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
285 BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
286 BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
287 BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
288 BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
289
290 BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
291 BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
292 BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
293 BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
294 BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
295 BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
296 BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
297 BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
298 BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
299 BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
300 BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
301 BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
302 BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
303 BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
304 BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
305 BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
306 BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
307 BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
308 BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
309 BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
310
311 BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
312 BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
313 BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
314 BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
315 BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
316 BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
317 BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
318 BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
319 BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
320 BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
321 BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
322 BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
323 BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
324 BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
325 BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
326 BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
327 BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
328 BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
329 BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
330 BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
331
332 c->h0=(c->h0+E)&0xffffffffL;
333 c->h1=(c->h1+T)&0xffffffffL;
334 c->h2=(c->h2+A)&0xffffffffL;
335 c->h3=(c->h3+B)&0xffffffffL;
336 c->h4=(c->h4+C)&0xffffffffL;
337
338 if (--num <= 0) break;
339
340 A=c->h0;
341 B=c->h1;
342 C=c->h2;
343 D=c->h3;
344 E=c->h4;
345
346 W+=SHA_LBLOCK;
347 }
348 }
349#endif
350
351#ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
352void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num)
353 {
354 const unsigned char *data=p;
355 register unsigned long A,B,C,D,E,T,l;
356#ifndef MD32_XARRAY
357 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
358 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
359#else
360 SHA_LONG XX[16];
361#endif
362
363 A=c->h0;
364 B=c->h1;
365 C=c->h2;
366 D=c->h3;
367 E=c->h4;
368
369 for (;;)
370 {
371
372 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
373 BODY_00_15( 0,A,B,C,D,E,T,X( 0)); HOST_c2l(data,l); X( 2)=l;
374 BODY_00_15( 1,T,A,B,C,D,E,X( 1)); HOST_c2l(data,l); X( 3)=l;
375 BODY_00_15( 2,E,T,A,B,C,D,X( 2)); HOST_c2l(data,l); X( 4)=l;
376 BODY_00_15( 3,D,E,T,A,B,C,X( 3)); HOST_c2l(data,l); X( 5)=l;
377 BODY_00_15( 4,C,D,E,T,A,B,X( 4)); HOST_c2l(data,l); X( 6)=l;
378 BODY_00_15( 5,B,C,D,E,T,A,X( 5)); HOST_c2l(data,l); X( 7)=l;
379 BODY_00_15( 6,A,B,C,D,E,T,X( 6)); HOST_c2l(data,l); X( 8)=l;
380 BODY_00_15( 7,T,A,B,C,D,E,X( 7)); HOST_c2l(data,l); X( 9)=l;
381 BODY_00_15( 8,E,T,A,B,C,D,X( 8)); HOST_c2l(data,l); X(10)=l;
382 BODY_00_15( 9,D,E,T,A,B,C,X( 9)); HOST_c2l(data,l); X(11)=l;
383 BODY_00_15(10,C,D,E,T,A,B,X(10)); HOST_c2l(data,l); X(12)=l;
384 BODY_00_15(11,B,C,D,E,T,A,X(11)); HOST_c2l(data,l); X(13)=l;
385 BODY_00_15(12,A,B,C,D,E,T,X(12)); HOST_c2l(data,l); X(14)=l;
386 BODY_00_15(13,T,A,B,C,D,E,X(13)); HOST_c2l(data,l); X(15)=l;
387 BODY_00_15(14,E,T,A,B,C,D,X(14));
388 BODY_00_15(15,D,E,T,A,B,C,X(15));
389
390 BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13));
391 BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14));
392 BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15));
393 BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0));
394
395 BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1));
396 BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2));
397 BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3));
398 BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4));
399 BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5));
400 BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6));
401 BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7));
402 BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8));
403 BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9));
404 BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10));
405 BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11));
406 BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12));
407
408 BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
409 BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
410 BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
411 BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
412 BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
413 BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
414 BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
415 BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
416
417 BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
418 BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
419 BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
420 BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
421 BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
422 BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
423 BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
424 BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
425 BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
426 BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
427 BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
428 BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
429 BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
430 BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
431 BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
432 BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
433 BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
434 BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
435 BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
436 BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
437
438 BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
439 BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
440 BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
441 BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
442 BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
443 BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
444 BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
445 BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
446 BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
447 BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
448 BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
449 BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
450 BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
451 BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
452 BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
453 BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
454 BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
455 BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
456 BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
457 BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
458
459 c->h0=(c->h0+E)&0xffffffffL;
460 c->h1=(c->h1+T)&0xffffffffL;
461 c->h2=(c->h2+A)&0xffffffffL;
462 c->h3=(c->h3+B)&0xffffffffL;
463 c->h4=(c->h4+C)&0xffffffffL;
464
465 if (--num <= 0) break;
466
467 A=c->h0;
468 B=c->h1;
469 C=c->h2;
470 D=c->h3;
471 E=c->h4;
472
473 }
474 }
475#endif
diff --git a/src/lib/libssl/src/crypto/sha/shatest.c b/src/lib/libssl/src/crypto/sha/shatest.c
index 2b0744d937..a5786bbf76 100644
--- a/src/lib/libssl/src/crypto/sha/shatest.c
+++ b/src/lib/libssl/src/crypto/sha/shatest.c
@@ -76,26 +76,26 @@ int main(int argc, char *argv[])
76#define SHA_0 /* FIPS 180 */ 76#define SHA_0 /* FIPS 180 */
77#undef SHA_1 /* FIPS 180-1 */ 77#undef SHA_1 /* FIPS 180-1 */
78 78
79char *test[]={ 79static char *test[]={
80 "abc", 80 "abc",
81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 81 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
82 NULL, 82 NULL,
83 }; 83 };
84 84
85#ifdef SHA_0 85#ifdef SHA_0
86char *ret[]={ 86static char *ret[]={
87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", 87 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8", 88 "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
89 }; 89 };
90char *bigret= 90static char *bigret=
91 "3232affa48628a26653b5aaa44541fd90d690603"; 91 "3232affa48628a26653b5aaa44541fd90d690603";
92#endif 92#endif
93#ifdef SHA_1 93#ifdef SHA_1
94char *ret[]={ 94static char *ret[]={
95 "a9993e364706816aba3e25717850c26c9cd0d89d", 95 "a9993e364706816aba3e25717850c26c9cd0d89d",
96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1", 96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
97 }; 97 };
98char *bigret= 98static char *bigret=
99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; 99 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
100#endif 100#endif
101 101
diff --git a/src/lib/libssl/src/crypto/stack/Makefile.ssl b/src/lib/libssl/src/crypto/stack/Makefile.ssl
index faed4d0364..64a93b33ac 100644
--- a/src/lib/libssl/src/crypto/stack/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/stack/Makefile.ssl
@@ -82,4 +82,5 @@ stack.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82stack.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82stack.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84stack.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 84stack.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85stack.o: ../../include/openssl/stack.h ../cryptlib.h 85stack.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
86stack.o: ../cryptlib.h
diff --git a/src/lib/libssl/src/crypto/stack/stack.c b/src/lib/libssl/src/crypto/stack/stack.c
index 8b96713884..58e9126339 100644
--- a/src/lib/libssl/src/crypto/stack/stack.c
+++ b/src/lib/libssl/src/crypto/stack/stack.c
@@ -59,7 +59,7 @@
59/* Code for stacks 59/* Code for stacks
60 * Author - Eric Young v 1.0 60 * Author - Eric Young v 1.0
61 * 1.2 eay 12-Mar-97 - Modified sk_find so that it _DOES_ return the 61 * 1.2 eay 12-Mar-97 - Modified sk_find so that it _DOES_ return the
62 * lowest index for the seached item. 62 * lowest index for the searched item.
63 * 63 *
64 * 1.1 eay - Take from netdb and added to SSLeay 64 * 1.1 eay - Take from netdb and added to SSLeay
65 * 65 *
@@ -126,7 +126,7 @@ STACK *sk_new(int (*c)())
126 ret->sorted=0; 126 ret->sorted=0;
127 return(ret); 127 return(ret);
128err1: 128err1:
129 Free((char *)ret); 129 Free(ret);
130err0: 130err0:
131 return(NULL); 131 return(NULL);
132 } 132 }
@@ -276,8 +276,8 @@ void sk_pop_free(STACK *st, void (*func)())
276void sk_free(STACK *st) 276void sk_free(STACK *st)
277 { 277 {
278 if (st == NULL) return; 278 if (st == NULL) return;
279 if (st->data != NULL) Free((char *)st->data); 279 if (st->data != NULL) Free(st->data);
280 Free((char *)st); 280 Free(st);
281 } 281 }
282 282
283int sk_num(STACK *st) 283int sk_num(STACK *st)
diff --git a/src/lib/libssl/src/crypto/stack/stack.h b/src/lib/libssl/src/crypto/stack/stack.h
index 0f825cc0c4..a615d9b4c9 100644
--- a/src/lib/libssl/src/crypto/stack/stack.h
+++ b/src/lib/libssl/src/crypto/stack/stack.h
@@ -76,8 +76,8 @@ typedef struct stack_st
76 76
77#define sk_new_null() sk_new(NULL) 77#define sk_new_null() sk_new(NULL)
78 78
79#define M_sk_num(sk) ((sk)->num) 79#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
80#define M_sk_value(sk,n) ((sk)->data[n]) 80#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
81 81
82int sk_num(STACK *); 82int sk_num(STACK *);
83char *sk_value(STACK *, int); 83char *sk_value(STACK *, int);
diff --git a/src/lib/libssl/src/crypto/threads/README b/src/lib/libssl/src/crypto/threads/README
new file mode 100644
index 0000000000..df6b26e146
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/README
@@ -0,0 +1,14 @@
1Mutithreading testing area.
2
3Since this stuff is very very platorm specific, this is not part of the
4normal build. Have a read of doc/threads.doc.
5
6mttest will do some testing and will currently build under Windows NT/95,
7Solaris and Linux. The IRIX stuff is not finished.
8
9I have tested this program on a 12 CPU ultra sparc box (solaris 2.5.1)
10and things seem to work ok.
11
12The Linux pthreads package can be retrieved from
13http://www.mit.edu:8001/people/proven/pthreads.html
14
diff --git a/src/lib/libssl/src/crypto/threads/mttest.c b/src/lib/libssl/src/crypto/threads/mttest.c
index 142623edda..24713a3157 100644
--- a/src/lib/libssl/src/crypto/threads/mttest.c
+++ b/src/lib/libssl/src/crypto/threads/mttest.c
@@ -74,26 +74,29 @@
74#include <ulocks.h> 74#include <ulocks.h>
75#include <sys/prctl.h> 75#include <sys/prctl.h>
76#endif 76#endif
77#ifdef PTHREADS
78#include <pthread.h>
79#endif
77#include <openssl/lhash.h> 80#include <openssl/lhash.h>
78#include <openssl/crypto.h> 81#include <openssl/crypto.h>
79#include <openssl/buffer.h> 82#include <openssl/buffer.h>
80#include "../e_os.h" 83#include "../../e_os.h"
81#include <openssl/x509.h> 84#include <openssl/x509.h>
82#include <openssl/ssl.h> 85#include <openssl/ssl.h>
83#include <openssl/err.h> 86#include <openssl/err.h>
87#include <openssl/rand.h>
84 88
85#ifdef NO_FP_API 89#ifdef NO_FP_API
86#define APPS_WIN16 90#define APPS_WIN16
87#include "../crypto/buffer/bss_file.c" 91#include "../buffer/bss_file.c"
88#endif 92#endif
89 93
90#define TEST_SERVER_CERT "../apps/server.pem" 94#define TEST_SERVER_CERT "../../apps/server.pem"
91#define TEST_CLIENT_CERT "../apps/client.pem" 95#define TEST_CLIENT_CERT "../../apps/client.pem"
92 96
93#define MAX_THREAD_NUMBER 100 97#define MAX_THREAD_NUMBER 100
94 98
95int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, 99int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs);
96 int error,char *arg);
97void thread_setup(void); 100void thread_setup(void);
98void thread_cleanup(void); 101void thread_cleanup(void);
99void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); 102void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx);
@@ -121,6 +124,8 @@ int number_of_loops=10;
121int reconnect=0; 124int reconnect=0;
122int cache_stats=0; 125int cache_stats=0;
123 126
127static const char rnd_seed[] = "string to make the random number generator think it has entropy";
128
124int doit(char *ctx[4]); 129int doit(char *ctx[4]);
125static void print_stats(FILE *fp, SSL_CTX *ctx) 130static void print_stats(FILE *fp, SSL_CTX *ctx)
126{ 131{
@@ -170,6 +175,8 @@ int main(int argc, char *argv[])
170 char *ccert=TEST_CLIENT_CERT; 175 char *ccert=TEST_CLIENT_CERT;
171 SSL_METHOD *ssl_method=SSLv23_method(); 176 SSL_METHOD *ssl_method=SSLv23_method();
172 177
178 RAND_seed(rnd_seed, sizeof rnd_seed);
179
173 if (bio_err == NULL) 180 if (bio_err == NULL)
174 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 181 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
175 if (bio_stdout == NULL) 182 if (bio_stdout == NULL)
@@ -244,7 +251,7 @@ bad:
244 if (cipher == NULL) cipher=getenv("SSL_CIPHER"); 251 if (cipher == NULL) cipher=getenv("SSL_CIPHER");
245 252
246 SSL_load_error_strings(); 253 SSL_load_error_strings();
247 SSLeay_add_ssl_algorithms(); 254 OpenSSL_add_ssl_algorithms();
248 255
249 c_ctx=SSL_CTX_new(ssl_method); 256 c_ctx=SSL_CTX_new(ssl_method);
250 s_ctx=SSL_CTX_new(ssl_method); 257 s_ctx=SSL_CTX_new(ssl_method);
@@ -259,8 +266,15 @@ bad:
259 SSL_CTX_set_session_cache_mode(c_ctx, 266 SSL_CTX_set_session_cache_mode(c_ctx,
260 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER); 267 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
261 268
262 SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM); 269 if (!SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM))
263 SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM); 270 {
271 ERR_print_errors(bio_err);
272 }
273 else if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM))
274 {
275 ERR_print_errors(bio_err);
276 goto end;
277 }
264 278
265 if (client_auth) 279 if (client_auth)
266 { 280 {
@@ -489,6 +503,7 @@ int doit(char *ctx[4])
489 else 503 else
490 { 504 {
491 fprintf(stderr,"ERROR in CLIENT\n"); 505 fprintf(stderr,"ERROR in CLIENT\n");
506 ERR_print_errors_fp(stderr);
492 return(1); 507 return(1);
493 } 508 }
494 } 509 }
@@ -520,6 +535,7 @@ int doit(char *ctx[4])
520 else 535 else
521 { 536 {
522 fprintf(stderr,"ERROR in CLIENT\n"); 537 fprintf(stderr,"ERROR in CLIENT\n");
538 ERR_print_errors_fp(stderr);
523 return(1); 539 return(1);
524 } 540 }
525 } 541 }
@@ -652,18 +668,23 @@ err:
652 return(0); 668 return(0);
653 } 669 }
654 670
655int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, 671int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
656 int error, char *arg)
657 { 672 {
658 char buf[256]; 673 char *s, buf[256];
659 674
660 if (verbose) 675 if (verbose)
661 { 676 {
662 X509_NAME_oneline(X509_get_subject_name(xs),buf,256); 677 s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),
663 if (ok) 678 buf,256);
664 fprintf(stderr,"depth=%d %s\n",depth,buf); 679 if (s != NULL)
665 else 680 {
666 fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf); 681 if (ok)
682 fprintf(stderr,"depth=%d %s\n",
683 ctx->error_depth,buf);
684 else
685 fprintf(stderr,"depth=%d error=%d %s\n",
686 ctx->error_depth,ctx->error,buf);
687 }
667 } 688 }
668 return(ok); 689 return(ok);
669 } 690 }
@@ -672,13 +693,14 @@ int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth,
672 693
673#ifdef WIN32 694#ifdef WIN32
674 695
675static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; 696static HANDLE *lock_cs;
676 697
677void thread_setup(void) 698void thread_setup(void)
678 { 699 {
679 int i; 700 int i;
680 701
681 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 702 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(HANDLE));
703 for (i=0; i<CRYPTO_num_locks(); i++)
682 { 704 {
683 lock_cs[i]=CreateMutex(NULL,FALSE,NULL); 705 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
684 } 706 }
@@ -692,8 +714,9 @@ void thread_cleanup(void)
692 int i; 714 int i;
693 715
694 CRYPTO_set_locking_callback(NULL); 716 CRYPTO_set_locking_callback(NULL);
695 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 717 for (i=0; i<CRYPTO_num_locks(); i++)
696 CloseHandle(lock_cs[i]); 718 CloseHandle(lock_cs[i]);
719 Free(lock_cs);
697 } 720 }
698 721
699void win32_locking_callback(int mode, int type, char *file, int line) 722void win32_locking_callback(int mode, int type, char *file, int line)
@@ -763,15 +786,17 @@ void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
763 786
764#ifdef SOLARIS 787#ifdef SOLARIS
765 788
766static mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 789static mutex_t *lock_cs;
767/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */ 790/*static rwlock_t *lock_cs; */
768static long lock_count[CRYPTO_NUM_LOCKS]; 791static long *lock_count;
769 792
770void thread_setup(void) 793void thread_setup(void)
771 { 794 {
772 int i; 795 int i;
773 796
774 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 797 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(mutex_t));
798 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
799 for (i=0; i<CRYPTO_num_locks(); i++)
775 { 800 {
776 lock_count[i]=0; 801 lock_count[i]=0;
777 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */ 802 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
@@ -787,31 +812,37 @@ void thread_cleanup(void)
787 int i; 812 int i;
788 813
789 CRYPTO_set_locking_callback(NULL); 814 CRYPTO_set_locking_callback(NULL);
790fprintf(stderr,"cleanup\n"); 815
791 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 816 fprintf(stderr,"cleanup\n");
817
818 for (i=0; i<CRYPTO_num_locks(); i++)
792 { 819 {
793 /* rwlock_destroy(&(lock_cs[i])); */ 820 /* rwlock_destroy(&(lock_cs[i])); */
794 mutex_destroy(&(lock_cs[i])); 821 mutex_destroy(&(lock_cs[i]));
795 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i)); 822 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
796 } 823 }
797fprintf(stderr,"done cleanup\n"); 824 Free(lock_cs);
825 Free(lock_count);
826
827 fprintf(stderr,"done cleanup\n");
828
798 } 829 }
799 830
800void solaris_locking_callback(int mode, int type, char *file, int line) 831void solaris_locking_callback(int mode, int type, char *file, int line)
801 { 832 {
802#ifdef undef 833#ifdef undef
803fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", 834 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
804 CRYPTO_thread_id(), 835 CRYPTO_thread_id(),
805 (mode&CRYPTO_LOCK)?"l":"u", 836 (mode&CRYPTO_LOCK)?"l":"u",
806 (type&CRYPTO_READ)?"r":"w",file,line); 837 (type&CRYPTO_READ)?"r":"w",file,line);
807#endif 838#endif
808 839
809/* 840 /*
810if (CRYPTO_LOCK_SSL_CERT == type) 841 if (CRYPTO_LOCK_SSL_CERT == type)
811 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n", 842 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
812 CRYPTO_thread_id(), 843 CRYPTO_thread_id(),
813 mode,file,line); 844 mode,file,line);
814*/ 845 */
815 if (mode & CRYPTO_LOCK) 846 if (mode & CRYPTO_LOCK)
816 { 847 {
817 /* if (mode & CRYPTO_READ) 848 /* if (mode & CRYPTO_READ)
@@ -871,7 +902,7 @@ unsigned long solaris_thread_id(void)
871 902
872 903
873static usptr_t *arena; 904static usptr_t *arena;
874static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; 905static usema_t **lock_cs;
875 906
876void thread_setup(void) 907void thread_setup(void)
877 { 908 {
@@ -888,7 +919,8 @@ void thread_setup(void)
888 arena=usinit(filename); 919 arena=usinit(filename);
889 unlink(filename); 920 unlink(filename);
890 921
891 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 922 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(usema_t *));
923 for (i=0; i<CRYPTO_num_locks(); i++)
892 { 924 {
893 lock_cs[i]=usnewsema(arena,1); 925 lock_cs[i]=usnewsema(arena,1);
894 } 926 }
@@ -902,7 +934,7 @@ void thread_cleanup(void)
902 int i; 934 int i;
903 935
904 CRYPTO_set_locking_callback(NULL); 936 CRYPTO_set_locking_callback(NULL);
905 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 937 for (i=0; i<CRYPTO_num_locks(); i++)
906 { 938 {
907 char buf[10]; 939 char buf[10];
908 940
@@ -910,6 +942,7 @@ void thread_cleanup(void)
910 usdumpsema(lock_cs[i],stdout,buf); 942 usdumpsema(lock_cs[i],stdout,buf);
911 usfreesema(lock_cs[i],arena); 943 usfreesema(lock_cs[i],arena);
912 } 944 }
945 Free(lock_cs);
913 } 946 }
914 947
915void irix_locking_callback(int mode, int type, char *file, int line) 948void irix_locking_callback(int mode, int type, char *file, int line)
@@ -962,14 +995,16 @@ unsigned long irix_thread_id(void)
962 995
963#ifdef PTHREADS 996#ifdef PTHREADS
964 997
965static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 998static pthread_mutex_t *lock_cs;
966static long lock_count[CRYPTO_NUM_LOCKS]; 999static long *lock_count;
967 1000
968void thread_setup(void) 1001void thread_setup(void)
969 { 1002 {
970 int i; 1003 int i;
971 1004
972 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 1005 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
1006 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
1007 for (i=0; i<CRYPTO_num_locks(); i++)
973 { 1008 {
974 lock_count[i]=0; 1009 lock_count[i]=0;
975 pthread_mutex_init(&(lock_cs[i]),NULL); 1010 pthread_mutex_init(&(lock_cs[i]),NULL);
@@ -985,12 +1020,15 @@ void thread_cleanup(void)
985 1020
986 CRYPTO_set_locking_callback(NULL); 1021 CRYPTO_set_locking_callback(NULL);
987 fprintf(stderr,"cleanup\n"); 1022 fprintf(stderr,"cleanup\n");
988 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 1023 for (i=0; i<CRYPTO_num_locks(); i++)
989 { 1024 {
990 pthread_mutex_destroy(&(lock_cs[i])); 1025 pthread_mutex_destroy(&(lock_cs[i]));
991 fprintf(stderr,"%8ld:%s\n",lock_count[i], 1026 fprintf(stderr,"%8ld:%s\n",lock_count[i],
992 CRYPTO_get_lock_name(i)); 1027 CRYPTO_get_lock_name(i));
993 } 1028 }
1029 Free(lock_cs);
1030 Free(lock_count);
1031
994 fprintf(stderr,"done cleanup\n"); 1032 fprintf(stderr,"done cleanup\n");
995 } 1033 }
996 1034
@@ -1045,7 +1083,7 @@ void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
1045 } 1083 }
1046 1084
1047 printf("pthreads threads done (%d,%d)\n", 1085 printf("pthreads threads done (%d,%d)\n",
1048 s_ctx->references,c_ctx->references); 1086 s_ctx->references,c_ctx->references);
1049 } 1087 }
1050 1088
1051unsigned long pthreads_thread_id(void) 1089unsigned long pthreads_thread_id(void)
diff --git a/src/lib/libssl/src/crypto/threads/profile.sh b/src/lib/libssl/src/crypto/threads/profile.sh
new file mode 100644
index 0000000000..6e3e342fc0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/profile.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -p -DSOLARIS -I../../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/crypto/threads/ptest.bat b/src/lib/libssl/src/crypto/threads/ptest.bat
new file mode 100644
index 0000000000..4071b5ffea
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/ptest.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3purify cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssl32.lib ..\..\out\crypt32.lib
4
diff --git a/src/lib/libssl/src/crypto/threads/pthread.sh b/src/lib/libssl/src/crypto/threads/pthread.sh
new file mode 100644
index 0000000000..f1c49821d2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/pthread.sh
@@ -0,0 +1,9 @@
1#!/bin/sh
2#
3# build using pthreads
4#
5# http://www.mit.edu:8001/people/proven/pthreads.html
6#
7/bin/rm -f mttest
8pgcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto
9
diff --git a/src/lib/libssl/src/crypto/threads/pthread2.sh b/src/lib/libssl/src/crypto/threads/pthread2.sh
new file mode 100644
index 0000000000..41264c6a50
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/pthread2.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2#
3# build using pthreads where it's already built into the system
4#
5/bin/rm -f mttest
6gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread
7
diff --git a/src/lib/libssl/src/crypto/threads/pthreads-vms.com b/src/lib/libssl/src/crypto/threads/pthreads-vms.com
new file mode 100644
index 0000000000..63f5b8cc2e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/pthreads-vms.com
@@ -0,0 +1,9 @@
1$! To compile mttest on VMS.
2$!
3$! WARNING: only tested with DEC C so far.
4$
5$ arch := vax
6$ if f$getsyi("CPU") .ge. 128 then arch := axp
7$ define/user openssl [--.include.openssl]
8$ cc/def=PTHREADS mttest.c
9$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib
diff --git a/src/lib/libssl/src/crypto/threads/purify.sh b/src/lib/libssl/src/crypto/threads/purify.sh
new file mode 100644
index 0000000000..6d44fe26b7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/purify.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3purify cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/crypto/threads/solaris.sh b/src/lib/libssl/src/crypto/threads/solaris.sh
new file mode 100644
index 0000000000..bc93094a27
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/solaris.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/crypto/threads/th-lock.c b/src/lib/libssl/src/crypto/threads/th-lock.c
index afb4f4caf2..3ee978060c 100644
--- a/src/lib/libssl/src/crypto/threads/th-lock.c
+++ b/src/lib/libssl/src/crypto/threads/th-lock.c
@@ -74,6 +74,9 @@
74#include <ulocks.h> 74#include <ulocks.h>
75#include <sys/prctl.h> 75#include <sys/prctl.h>
76#endif 76#endif
77#ifdef PTHREADS
78#include <pthread.h>
79#endif
77#include <openssl/lhash.h> 80#include <openssl/lhash.h>
78#include <openssl/crypto.h> 81#include <openssl/crypto.h>
79#include <openssl/buffer.h> 82#include <openssl/buffer.h>
@@ -82,7 +85,7 @@
82#include <openssl/ssl.h> 85#include <openssl/ssl.h>
83#include <openssl/err.h> 86#include <openssl/err.h>
84 87
85int CRYPTO_thread_setup(void); 88void CRYPTO_thread_setup(void);
86void CRYPTO_thread_cleanup(void); 89void CRYPTO_thread_cleanup(void);
87 90
88static void irix_locking_callback(int mode,int type,char *file,int line); 91static void irix_locking_callback(int mode,int type,char *file,int line);
@@ -96,7 +99,7 @@ static unsigned long pthreads_thread_id(void );
96 99
97/* usage: 100/* usage:
98 * CRYPTO_thread_setup(); 101 * CRYPTO_thread_setup();
99 * applicaion code 102 * application code
100 * CRYPTO_thread_cleanup(); 103 * CRYPTO_thread_cleanup();
101 */ 104 */
102 105
@@ -104,13 +107,14 @@ static unsigned long pthreads_thread_id(void );
104 107
105#ifdef WIN32 108#ifdef WIN32
106 109
107static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; 110static HANDLE *lock_cs;
108 111
109int CRYPTO_thread_setup(void) 112void CRYPTO_thread_setup(void)
110 { 113 {
111 int i; 114 int i;
112 115
113 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 116 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(HANDLE));
117 for (i=0; i<CRYPTO_num_locks(); i++)
114 { 118 {
115 lock_cs[i]=CreateMutex(NULL,FALSE,NULL); 119 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
116 } 120 }
@@ -125,8 +129,9 @@ static void CRYPTO_thread_cleanup(void)
125 int i; 129 int i;
126 130
127 CRYPTO_set_locking_callback(NULL); 131 CRYPTO_set_locking_callback(NULL);
128 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 132 for (i=0; i<CRYPTO_num_locks(); i++)
129 CloseHandle(lock_cs[i]); 133 CloseHandle(lock_cs[i]);
134 Free(lock_cs);
130 } 135 }
131 136
132void win32_locking_callback(int mode, int type, char *file, int line) 137void win32_locking_callback(int mode, int type, char *file, int line)
@@ -147,18 +152,24 @@ void win32_locking_callback(int mode, int type, char *file, int line)
147 152
148#define USE_MUTEX 153#define USE_MUTEX
149 154
150static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
151#ifdef USE_MUTEX 155#ifdef USE_MUTEX
152static long lock_count[CRYPTO_NUM_LOCKS]; 156static mutex_t *lock_cs;
153#else 157#else
154static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; 158static rwlock_t *lock_cs;
155#endif 159#endif
160static long *lock_count;
156 161
157void CRYPTO_thread_setup(void) 162void CRYPTO_thread_setup(void)
158 { 163 {
159 int i; 164 int i;
160 165
161 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 166#ifdef USE_MUTEX
167 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(mutex_t));
168#else
169 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(rwlock_t));
170#endif
171 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
172 for (i=0; i<CRYPTO_num_locks(); i++)
162 { 173 {
163 lock_count[i]=0; 174 lock_count[i]=0;
164#ifdef USE_MUTEX 175#ifdef USE_MUTEX
@@ -177,7 +188,7 @@ void CRYPTO_thread_cleanup(void)
177 int i; 188 int i;
178 189
179 CRYPTO_set_locking_callback(NULL); 190 CRYPTO_set_locking_callback(NULL);
180 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 191 for (i=0; i<CRYPTO_num_locks(); i++)
181 { 192 {
182#ifdef USE_MUTEX 193#ifdef USE_MUTEX
183 mutex_destroy(&(lock_cs[i])); 194 mutex_destroy(&(lock_cs[i]));
@@ -185,6 +196,8 @@ void CRYPTO_thread_cleanup(void)
185 rwlock_destroy(&(lock_cs[i])); 196 rwlock_destroy(&(lock_cs[i]));
186#endif 197#endif
187 } 198 }
199 Free(lock_cs);
200 Free(lock_count);
188 } 201 }
189 202
190void solaris_locking_callback(int mode, int type, char *file, int line) 203void solaris_locking_callback(int mode, int type, char *file, int line)
@@ -237,7 +250,7 @@ unsigned long solaris_thread_id(void)
237/* I don't think this works..... */ 250/* I don't think this works..... */
238 251
239static usptr_t *arena; 252static usptr_t *arena;
240static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; 253static usema_t **lock_cs;
241 254
242void CRYPTO_thread_setup(void) 255void CRYPTO_thread_setup(void)
243 { 256 {
@@ -254,7 +267,8 @@ void CRYPTO_thread_setup(void)
254 arena=usinit(filename); 267 arena=usinit(filename);
255 unlink(filename); 268 unlink(filename);
256 269
257 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 270 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(usema_t *));
271 for (i=0; i<CRYPTO_num_locks(); i++)
258 { 272 {
259 lock_cs[i]=usnewsema(arena,1); 273 lock_cs[i]=usnewsema(arena,1);
260 } 274 }
@@ -268,7 +282,7 @@ void CRYPTO_thread_cleanup(void)
268 int i; 282 int i;
269 283
270 CRYPTO_set_locking_callback(NULL); 284 CRYPTO_set_locking_callback(NULL);
271 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 285 for (i=0; i<CRYPTO_num_locks(); i++)
272 { 286 {
273 char buf[10]; 287 char buf[10];
274 288
@@ -276,6 +290,7 @@ void CRYPTO_thread_cleanup(void)
276 usdumpsema(lock_cs[i],stdout,buf); 290 usdumpsema(lock_cs[i],stdout,buf);
277 usfreesema(lock_cs[i],arena); 291 usfreesema(lock_cs[i],arena);
278 } 292 }
293 Free(lock_cs);
279 } 294 }
280 295
281void irix_locking_callback(int mode, int type, char *file, int line) 296void irix_locking_callback(int mode, int type, char *file, int line)
@@ -302,14 +317,16 @@ unsigned long irix_thread_id(void)
302/* Linux and a few others */ 317/* Linux and a few others */
303#ifdef PTHREADS 318#ifdef PTHREADS
304 319
305static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 320static pthread_mutex_t *lock_cs;
306static long lock_count[CRYPTO_NUM_LOCKS]; 321static long *lock_count;
307 322
308void CRYPTO_thread_setup(void) 323void CRYPTO_thread_setup(void)
309 { 324 {
310 int i; 325 int i;
311 326
312 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 327 lock_cs=Malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
328 lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
329 for (i=0; i<CRYPTO_num_locks(); i++)
313 { 330 {
314 lock_count[i]=0; 331 lock_count[i]=0;
315 pthread_mutex_init(&(lock_cs[i]),NULL); 332 pthread_mutex_init(&(lock_cs[i]),NULL);
@@ -324,10 +341,12 @@ void thread_cleanup(void)
324 int i; 341 int i;
325 342
326 CRYPTO_set_locking_callback(NULL); 343 CRYPTO_set_locking_callback(NULL);
327 for (i=0; i<CRYPTO_NUM_LOCKS; i++) 344 for (i=0; i<CRYPTO_num_locks(); i++)
328 { 345 {
329 pthread_mutex_destroy(&(lock_cs[i])); 346 pthread_mutex_destroy(&(lock_cs[i]));
330 } 347 }
348 Free(lock_cs);
349 Free(lock_count);
331 } 350 }
332 351
333void pthreads_locking_callback(int mode, int type, char *file, 352void pthreads_locking_callback(int mode, int type, char *file,
diff --git a/src/lib/libssl/src/crypto/threads/win32.bat b/src/lib/libssl/src/crypto/threads/win32.bat
new file mode 100644
index 0000000000..ee6da80a07
--- /dev/null
+++ b/src/lib/libssl/src/crypto/threads/win32.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssleay32.lib ..\..\out\libeay32.lib
4
diff --git a/src/lib/libssl/src/crypto/txt_db/Makefile.ssl b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
index 02b863bf89..a631dce6f2 100644
--- a/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
@@ -82,5 +82,6 @@ txt_db.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
82txt_db.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 82txt_db.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
83txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 83txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
84txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 84txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
85txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h 85txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
86txt_db.o: ../../include/openssl/txt_db.h ../cryptlib.h 86txt_db.o: ../../include/openssl/stack.h ../../include/openssl/txt_db.h
87txt_db.o: ../cryptlib.h
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 9a9fa5ce55..33acc81f3f 100644
--- a/src/lib/libssl/src/crypto/txt_db/txt_db.c
+++ b/src/lib/libssl/src/crypto/txt_db/txt_db.c
@@ -181,7 +181,7 @@ err:
181#endif 181#endif
182 if (ret->data != NULL) sk_free(ret->data); 182 if (ret->data != NULL) sk_free(ret->data);
183 if (ret->index != NULL) Free(ret->index); 183 if (ret->index != NULL) Free(ret->index);
184 if (ret->qual != NULL) Free((char *)ret->qual); 184 if (ret->qual != NULL) Free(ret->qual);
185 if (ret != NULL) Free(ret); 185 if (ret != NULL) Free(ret);
186 return(NULL); 186 return(NULL);
187 } 187 }
@@ -205,7 +205,7 @@ char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
205 db->error=DB_ERROR_NO_INDEX; 205 db->error=DB_ERROR_NO_INDEX;
206 return(NULL); 206 return(NULL);
207 } 207 }
208 ret=(char **)lh_retrieve(lh,(char *)value); 208 ret=(char **)lh_retrieve(lh,value);
209 db->error=DB_ERROR_OK; 209 db->error=DB_ERROR_OK;
210 return(ret); 210 return(ret);
211 } 211 }
@@ -306,7 +306,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
306 { 306 {
307 if ((db->qual[i] != NULL) && 307 if ((db->qual[i] != NULL) &&
308 (db->qual[i](row) == 0)) continue; 308 (db->qual[i](row) == 0)) continue;
309 r=(char **)lh_retrieve(db->index[i],(char *)row); 309 r=(char **)lh_retrieve(db->index[i],row);
310 if (r != NULL) 310 if (r != NULL)
311 { 311 {
312 db->error=DB_ERROR_INDEX_CLASH; 312 db->error=DB_ERROR_INDEX_CLASH;
@@ -329,7 +329,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
329 { 329 {
330 if ((db->qual[i] != NULL) && 330 if ((db->qual[i] != NULL) &&
331 (db->qual[i](row) == 0)) continue; 331 (db->qual[i](row) == 0)) continue;
332 lh_insert(db->index[i],(char *)row); 332 lh_insert(db->index[i],row);
333 } 333 }
334 } 334 }
335 return(1); 335 return(1);
diff --git a/src/lib/libssl/src/crypto/x509/Makefile.ssl b/src/lib/libssl/src/crypto/x509/Makefile.ssl
index c7ac35f6cc..48937b43af 100644
--- a/src/lib/libssl/src/crypto/x509/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/x509/Makefile.ssl
@@ -23,17 +23,17 @@ APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \ 25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
26 x509_obj.c x509_req.c x509_vfy.c \ 26 x509_obj.c x509_req.c x509spki.c x509_vfy.c \
27 x509_set.c x509rset.c x509_err.c \ 27 x509_set.c x509rset.c x509_err.c \
28 x509name.c x509_v3.c x509_ext.c \ 28 x509name.c x509_v3.c x509_ext.c x509_att.c \
29 x509type.c x509_lu.c x_all.c x509_txt.c \ 29 x509type.c x509_lu.c x_all.c x509_txt.c \
30 by_file.c by_dir.c 30 x509_trs.c by_file.c by_dir.c
31LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \ 31LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
32 x509_obj.o x509_req.o x509_vfy.o \ 32 x509_obj.o x509_req.o x509spki.o x509_vfy.o \
33 x509_set.o x509rset.o x509_err.o \ 33 x509_set.o x509rset.o x509_err.o \
34 x509name.o x509_v3.o x509_ext.o \ 34 x509name.o x509_v3.o x509_ext.o x509_att.o \
35 x509type.o x509_lu.o x_all.o x509_txt.o \ 35 x509type.o x509_lu.o x_all.o x509_txt.o \
36 by_file.o by_dir.o 36 x509_trs.o by_file.o by_dir.o
37 37
38SRC= $(LIBSRC) 38SRC= $(LIBSRC)
39 39
@@ -123,14 +123,33 @@ by_file.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
123by_file.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 123by_file.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
124by_file.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 124by_file.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
125by_file.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 125by_file.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
126x509_att.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
127x509_att.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
128x509_att.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
129x509_att.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
130x509_att.o: ../../include/openssl/des.h ../../include/openssl/dh.h
131x509_att.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
132x509_att.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
133x509_att.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
134x509_att.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
135x509_att.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
136x509_att.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
137x509_att.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
138x509_att.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
139x509_att.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
140x509_att.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
141x509_att.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
142x509_att.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
143x509_att.o: ../../include/openssl/x509v3.h ../cryptlib.h
126x509_cmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 144x509_cmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
127x509_cmp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 145x509_cmp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
128x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 146x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
129x509_cmp.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 147x509_cmp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
130x509_cmp.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 148x509_cmp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
131x509_cmp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 149x509_cmp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
132x509_cmp.o: ../../include/openssl/err.h ../../include/openssl/evp.h 150x509_cmp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
133x509_cmp.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 151x509_cmp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
152x509_cmp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
134x509_cmp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 153x509_cmp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
135x509_cmp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 154x509_cmp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
136x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 155x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -139,7 +158,7 @@ x509_cmp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
139x509_cmp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 158x509_cmp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
140x509_cmp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 159x509_cmp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
141x509_cmp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 160x509_cmp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
142x509_cmp.o: ../cryptlib.h 161x509_cmp.o: ../../include/openssl/x509v3.h ../cryptlib.h
143x509_d2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 162x509_d2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
144x509_d2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 163x509_d2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
145x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 164x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -192,11 +211,12 @@ x509_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
192x509_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 211x509_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
193x509_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 212x509_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
194x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 213x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
195x509_ext.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 214x509_ext.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
196x509_ext.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 215x509_ext.o: ../../include/openssl/des.h ../../include/openssl/dh.h
197x509_ext.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 216x509_ext.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
198x509_ext.o: ../../include/openssl/err.h ../../include/openssl/evp.h 217x509_ext.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199x509_ext.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 218x509_ext.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
219x509_ext.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
200x509_ext.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 220x509_ext.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
201x509_ext.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 221x509_ext.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
202x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 222x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -205,7 +225,7 @@ x509_ext.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
205x509_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 225x509_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
206x509_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 226x509_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
207x509_ext.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 227x509_ext.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
208x509_ext.o: ../cryptlib.h 228x509_ext.o: ../../include/openssl/x509v3.h ../cryptlib.h
209x509_lu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 229x509_lu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
210x509_lu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 230x509_lu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
211x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 231x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -293,6 +313,24 @@ x509_set.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
293x509_set.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 313x509_set.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
294x509_set.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 314x509_set.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
295x509_set.o: ../cryptlib.h 315x509_set.o: ../cryptlib.h
316x509_trs.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
317x509_trs.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
318x509_trs.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
319x509_trs.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
320x509_trs.o: ../../include/openssl/des.h ../../include/openssl/dh.h
321x509_trs.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
322x509_trs.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
323x509_trs.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
324x509_trs.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
325x509_trs.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
326x509_trs.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
327x509_trs.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
328x509_trs.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
329x509_trs.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
330x509_trs.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
331x509_trs.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
332x509_trs.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
333x509_trs.o: ../../include/openssl/x509v3.h ../cryptlib.h
296x509_txt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 334x509_txt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
297x509_txt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 335x509_txt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
298x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 336x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -314,11 +352,12 @@ x509_txt.o: ../cryptlib.h
314x509_v3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 352x509_v3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
315x509_v3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 353x509_v3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
316x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 354x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
317x509_v3.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 355x509_v3.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
318x509_v3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 356x509_v3.o: ../../include/openssl/des.h ../../include/openssl/dh.h
319x509_v3.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 357x509_v3.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
320x509_v3.o: ../../include/openssl/err.h ../../include/openssl/evp.h 358x509_v3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
321x509_v3.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 359x509_v3.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
360x509_v3.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
322x509_v3.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 361x509_v3.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
323x509_v3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 362x509_v3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
324x509_v3.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 363x509_v3.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -327,25 +366,25 @@ x509_v3.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
327x509_v3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 366x509_v3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
328x509_v3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 367x509_v3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
329x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 368x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
330x509_v3.o: ../cryptlib.h 369x509_v3.o: ../../include/openssl/x509v3.h ../cryptlib.h
331x509_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 370x509_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
332x509_vfy.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 371x509_vfy.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
333x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 372x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
334x509_vfy.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 373x509_vfy.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
335x509_vfy.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 374x509_vfy.o: ../../include/openssl/des.h ../../include/openssl/dh.h
336x509_vfy.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 375x509_vfy.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
337x509_vfy.o: ../../include/openssl/err.h ../../include/openssl/evp.h 376x509_vfy.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
338x509_vfy.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 377x509_vfy.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
339x509_vfy.o: ../../include/openssl/md2.h ../../include/openssl/md5.h 378x509_vfy.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
340x509_vfy.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h 379x509_vfy.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
341x509_vfy.o: ../../include/openssl/opensslconf.h 380x509_vfy.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
342x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 381x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
343x509_vfy.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 382x509_vfy.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
344x509_vfy.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 383x509_vfy.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
345x509_vfy.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 384x509_vfy.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
346x509_vfy.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 385x509_vfy.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
347x509_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 386x509_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
348x509_vfy.o: ../cryptlib.h 387x509_vfy.o: ../../include/openssl/x509v3.h ../cryptlib.h
349x509name.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 388x509name.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
350x509name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 389x509name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
351x509name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 390x509name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -380,6 +419,24 @@ x509rset.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
380x509rset.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 419x509rset.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
381x509rset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 420x509rset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
382x509rset.o: ../cryptlib.h 421x509rset.o: ../cryptlib.h
422x509spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
423x509spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
424x509spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
425x509spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
426x509spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h
427x509spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
428x509spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
429x509spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
430x509spki.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
431x509spki.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
432x509spki.o: ../../include/openssl/opensslconf.h
433x509spki.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
434x509spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
435x509spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
436x509spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
437x509spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
438x509spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
439x509spki.o: ../cryptlib.h
383x509type.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 440x509type.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
384x509type.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 441x509type.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
385x509type.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 442x509type.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
diff --git a/src/lib/libssl/src/crypto/x509/by_dir.c b/src/lib/libssl/src/crypto/x509/by_dir.c
index 734e39ac77..14d12c56bd 100644
--- a/src/lib/libssl/src/crypto/x509/by_dir.c
+++ b/src/lib/libssl/src/crypto/x509/by_dir.c
@@ -59,10 +59,18 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64 62
65#include "cryptlib.h" 63#include "cryptlib.h"
64
65#ifndef NO_SYS_TYPES_H
66# include <sys/types.h>
67#endif
68#ifdef MAC_OS_pre_X
69# include <stat.h>
70#else
71# include <sys/stat.h>
72#endif
73
66#include <openssl/lhash.h> 74#include <openssl/lhash.h>
67#include <openssl/x509.h> 75#include <openssl/x509.h>
68 76
@@ -210,9 +218,9 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
210 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)* 218 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)*
211 sizeof(int)); 219 sizeof(int));
212 if (ctx->dirs != NULL) 220 if (ctx->dirs != NULL)
213 Free((char *)ctx->dirs); 221 Free(ctx->dirs);
214 if (ctx->dirs_type != NULL) 222 if (ctx->dirs_type != NULL)
215 Free((char *)ctx->dirs_type); 223 Free(ctx->dirs_type);
216 ctx->dirs=pp; 224 ctx->dirs=pp;
217 ctx->dirs_type=ip; 225 ctx->dirs_type=ip;
218 } 226 }
@@ -318,8 +326,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
318 /* we have added it to the cache so now pull 326 /* we have added it to the cache so now pull
319 * it out again */ 327 * it out again */
320 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); 328 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
321 tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs, 329 tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs,&stmp);
322 (char *)&stmp);
323 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); 330 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
324 331
325 if (tmp != NULL) 332 if (tmp != NULL)
diff --git a/src/lib/libssl/src/crypto/x509/by_file.c b/src/lib/libssl/src/crypto/x509/by_file.c
index 00ee5e8bbc..78e9240a8d 100644
--- a/src/lib/libssl/src/crypto/x509/by_file.c
+++ b/src/lib/libssl/src/crypto/x509/by_file.c
@@ -59,8 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64 62
65#include "cryptlib.h" 63#include "cryptlib.h"
66#include <openssl/lhash.h> 64#include <openssl/lhash.h>
@@ -94,7 +92,7 @@ X509_LOOKUP_METHOD *X509_LOOKUP_file(void)
94static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, 92static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
95 char **ret) 93 char **ret)
96 { 94 {
97 int ok=0,ok2=0; 95 int ok=0;
98 char *file; 96 char *file;
99 97
100 switch (cmd) 98 switch (cmd)
@@ -102,31 +100,30 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
102 case X509_L_FILE_LOAD: 100 case X509_L_FILE_LOAD:
103 if (argl == X509_FILETYPE_DEFAULT) 101 if (argl == X509_FILETYPE_DEFAULT)
104 { 102 {
105 ok=X509_load_cert_file(ctx,X509_get_default_cert_file(), 103 ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
106 X509_FILETYPE_PEM); 104 X509_FILETYPE_PEM) != 0);
107 ok2=X509_load_crl_file(ctx,X509_get_default_cert_file(), 105 if (!ok)
108 X509_FILETYPE_PEM);
109 if (!ok || !ok2)
110 { 106 {
111 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS); 107 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS);
112 } 108 }
113 else 109 else
114 { 110 {
115 file=(char *)Getenv(X509_get_default_cert_file_env()); 111 file=(char *)Getenv(X509_get_default_cert_file_env());
116 ok=X509_load_cert_file(ctx,file, 112 ok = (X509_load_cert_crl_file(ctx,file,
117 X509_FILETYPE_PEM); 113 X509_FILETYPE_PEM) != 0);
118 ok2=X509_load_crl_file(ctx,file,
119 X509_FILETYPE_PEM);
120 } 114 }
121 } 115 }
122 else 116 else
123 { 117 {
124 ok=X509_load_cert_file(ctx,argp,(int)argl); 118 if(argl == X509_FILETYPE_PEM)
125 ok2=X509_load_crl_file(ctx,argp,(int)argl); 119 ok = (X509_load_cert_crl_file(ctx,argp,
120 X509_FILETYPE_PEM) != 0);
121 else
122 ok = (X509_load_cert_file(ctx,argp,(int)argl) != 0);
126 } 123 }
127 break; 124 break;
128 } 125 }
129 return((ok && ok2)?ok:0); 126 return(ok);
130 } 127 }
131 128
132int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) 129int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
@@ -149,7 +146,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
149 { 146 {
150 for (;;) 147 for (;;)
151 { 148 {
152 x=PEM_read_bio_X509(in,NULL,NULL,NULL); 149 x=PEM_read_bio_X509_AUX(in,NULL,NULL,NULL);
153 if (x == NULL) 150 if (x == NULL)
154 { 151 {
155 if ((ERR_GET_REASON(ERR_peek_error()) == 152 if ((ERR_GET_REASON(ERR_peek_error()) ==
@@ -263,5 +260,39 @@ err:
263 return(ret); 260 return(ret);
264 } 261 }
265 262
263int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
264{
265 STACK_OF(X509_INFO) *inf;
266 X509_INFO *itmp;
267 BIO *in;
268 int i, count = 0;
269 if(type != X509_FILETYPE_PEM)
270 return X509_load_cert_file(ctx, file, type);
271 in = BIO_new_file(file, "r");
272 if(!in) {
273 X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_SYS_LIB);
274 return 0;
275 }
276 inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
277 BIO_free(in);
278 if(!inf) {
279 X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_PEM_LIB);
280 return 0;
281 }
282 for(i = 0; i < sk_X509_INFO_num(inf); i++) {
283 itmp = sk_X509_INFO_value(inf, i);
284 if(itmp->x509) {
285 X509_STORE_add_cert(ctx->store_ctx, itmp->x509);
286 count++;
287 } else if(itmp->crl) {
288 X509_STORE_add_crl(ctx->store_ctx, itmp->crl);
289 count++;
290 }
291 }
292 sk_X509_INFO_pop_free(inf, X509_INFO_free);
293 return count;
294}
295
296
266#endif /* NO_STDIO */ 297#endif /* NO_STDIO */
267 298
diff --git a/src/lib/libssl/src/crypto/x509/x509.h b/src/lib/libssl/src/crypto/x509/x509.h
index 35f9484f8b..d3336d9ceb 100644
--- a/src/lib/libssl/src/crypto/x509/x509.h
+++ b/src/lib/libssl/src/crypto/x509/x509.h
@@ -176,9 +176,8 @@ typedef struct X509_extension_st
176 short critical; 176 short critical;
177 short netscape_hack; 177 short netscape_hack;
178 ASN1_OCTET_STRING *value; 178 ASN1_OCTET_STRING *value;
179 long argl; /* used when decoding */ 179 struct v3_ext_method *method; /* V3 method to use */
180 char *argp; /* used when decoding */ 180 void *ext_val; /* extension value */
181 void (*ex_free)(); /* clear argp stuff */
182 } X509_EXTENSION; 181 } X509_EXTENSION;
183 182
184DECLARE_STACK_OF(X509_EXTENSION) 183DECLARE_STACK_OF(X509_EXTENSION)
@@ -231,6 +230,21 @@ typedef struct x509_cinf_st
231 STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ 230 STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */
232 } X509_CINF; 231 } X509_CINF;
233 232
233/* This stuff is certificate "auxiliary info"
234 * it contains details which are useful in certificate
235 * stores and databases. When used this is tagged onto
236 * the end of the certificate itself
237 */
238
239typedef struct x509_cert_aux_st
240 {
241 STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */
242 STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */
243 ASN1_UTF8STRING *alias; /* "friendly name" */
244 ASN1_OCTET_STRING *keyid; /* key id of private key */
245 STACK_OF(X509_ALGOR) *other; /* other unspecified info */
246 } X509_CERT_AUX;
247
234typedef struct x509_st 248typedef struct x509_st
235 { 249 {
236 X509_CINF *cert_info; 250 X509_CINF *cert_info;
@@ -239,11 +253,58 @@ typedef struct x509_st
239 int valid; 253 int valid;
240 int references; 254 int references;
241 char *name; 255 char *name;
256 CRYPTO_EX_DATA ex_data;
257 /* These contain copies of various extension values */
258 long ex_pathlen;
259 unsigned long ex_flags;
260 unsigned long ex_kusage;
261 unsigned long ex_xkusage;
262 unsigned long ex_nscert;
263#ifndef NO_SHA
264 unsigned char sha1_hash[SHA_DIGEST_LENGTH];
265#endif
266 X509_CERT_AUX *aux;
242 } X509; 267 } X509;
243 268
244DECLARE_STACK_OF(X509) 269DECLARE_STACK_OF(X509)
245DECLARE_ASN1_SET_OF(X509) 270DECLARE_ASN1_SET_OF(X509)
246 271
272/* This is used for a table of trust checking functions */
273
274typedef struct x509_trust_st {
275 int trust;
276 int flags;
277 int (*check_trust)(struct x509_trust_st *, X509 *, int);
278 char *name;
279 int arg1;
280 void *arg2;
281} X509_TRUST;
282
283DECLARE_STACK_OF(X509_TRUST)
284
285/* standard trust ids */
286
287#define X509_TRUST_ANY 1
288#define X509_TRUST_SSL_CLIENT 2
289#define X509_TRUST_SSL_SERVER 3
290#define X509_TRUST_EMAIL 4
291#define X509_TRUST_OBJECT_SIGN 5
292
293/* Keep these up to date! */
294#define X509_TRUST_MIN 1
295#define X509_TRUST_MAX 5
296
297
298/* trust_flags values */
299#define X509_TRUST_DYNAMIC 1
300#define X509_TRUST_DYNAMIC_NAME 2
301
302/* check_trust return codes */
303
304#define X509_TRUST_TRUSTED 1
305#define X509_TRUST_REJECTED 2
306#define X509_TRUST_UNTRUSTED 3
307
247typedef struct X509_revoked_st 308typedef struct X509_revoked_st
248 { 309 {
249 ASN1_INTEGER *serialNumber; 310 ASN1_INTEGER *serialNumber;
@@ -318,7 +379,7 @@ DECLARE_STACK_OF(X509_INFO)
318 379
319/* The next 2 structures and their 8 routines were sent to me by 380/* The next 2 structures and their 8 routines were sent to me by
320 * Pat Richard <patr@x509.com> and are used to manipulate 381 * Pat Richard <patr@x509.com> and are used to manipulate
321 * Netscapes spki strucutres - usefull if you are writing a CA web page 382 * Netscapes spki structures - useful if you are writing a CA web page
322 */ 383 */
323typedef struct Netscape_spkac_st 384typedef struct Netscape_spkac_st
324 { 385 {
@@ -372,8 +433,10 @@ X509_ALGOR *prf;
372typedef struct pkcs8_priv_key_info_st 433typedef struct pkcs8_priv_key_info_st
373 { 434 {
374 int broken; /* Flag for various broken formats */ 435 int broken; /* Flag for various broken formats */
375#define PKCS8_OK 0 436#define PKCS8_OK 0
376#define PKCS8_NO_OCTET 1 437#define PKCS8_NO_OCTET 1
438#define PKCS8_EMBEDDED_PARAM 2
439#define PKCS8_NS_DB 3
377 ASN1_INTEGER *version; 440 ASN1_INTEGER *version;
378 X509_ALGOR *pkeyalg; 441 X509_ALGOR *pkeyalg;
379 ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ 442 ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
@@ -552,13 +615,20 @@ int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
552int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); 615int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
553int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); 616int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
554 617
618NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
619char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
620EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
621int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
622
623int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
624
555int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); 625int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
556int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); 626int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
557int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); 627int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
558int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); 628int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
559 629
560int X509_digest(X509 *data,EVP_MD *type,unsigned char *md,unsigned int *len); 630int X509_digest(X509 *data,const EVP_MD *type,unsigned char *md,unsigned int *len);
561int X509_NAME_digest(X509_NAME *data,EVP_MD *type, 631int X509_NAME_digest(X509_NAME *data,const EVP_MD *type,
562 unsigned char *md,unsigned int *len); 632 unsigned char *md,unsigned int *len);
563#endif 633#endif
564 634
@@ -574,16 +644,23 @@ RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
574int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); 644int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
575RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); 645RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
576int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); 646int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
647RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
648int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
577#endif 649#endif
578#ifndef NO_DSA 650#ifndef NO_DSA
651DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
652int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
579DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); 653DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
580int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); 654int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
655#endif
581X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); 656X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
582int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); 657int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
583PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, 658PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
584 PKCS8_PRIV_KEY_INFO **p8inf); 659 PKCS8_PRIV_KEY_INFO **p8inf);
585int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); 660int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
586#endif 661int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
662int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
663EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
587#endif 664#endif
588 665
589#ifdef HEADER_BIO_H 666#ifdef HEADER_BIO_H
@@ -598,8 +675,12 @@ RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
598int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); 675int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
599RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); 676RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
600int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); 677int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
678RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
679int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
601#endif 680#endif
602#ifndef NO_DSA 681#ifndef NO_DSA
682DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
683int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
603DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); 684DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
604int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); 685int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
605#endif 686#endif
@@ -608,6 +689,9 @@ int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
608PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, 689PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
609 PKCS8_PRIV_KEY_INFO **p8inf); 690 PKCS8_PRIV_KEY_INFO **p8inf);
610int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); 691int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
692int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
693int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
694EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
611#endif 695#endif
612 696
613X509 *X509_dup(X509 *x509); 697X509 *X509_dup(X509 *x509);
@@ -635,7 +719,7 @@ const char * X509_get_default_cert_dir_env(void );
635const char * X509_get_default_cert_file_env(void ); 719const char * X509_get_default_cert_file_env(void );
636const char * X509_get_default_private_dir(void ); 720const char * X509_get_default_private_dir(void );
637 721
638X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, EVP_MD *md); 722X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
639X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); 723X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
640void ERR_load_X509_strings(void ); 724void ERR_load_X509_strings(void );
641 725
@@ -660,7 +744,19 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
660EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); 744EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
661int X509_get_pubkey_parameters(EVP_PKEY *pkey, 745int X509_get_pubkey_parameters(EVP_PKEY *pkey,
662 STACK_OF(X509) *chain); 746 STACK_OF(X509) *chain);
663 747int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
748EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,unsigned char **pp,
749 long length);
750#ifndef NO_RSA
751int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
752RSA * d2i_RSA_PUBKEY(RSA **a,unsigned char **pp,
753 long length);
754#endif
755#ifndef NO_DSA
756int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
757DSA * d2i_DSA_PUBKEY(DSA **a,unsigned char **pp,
758 long length);
759#endif
664 760
665X509_SIG * X509_SIG_new(void ); 761X509_SIG * X509_SIG_new(void );
666void X509_SIG_free(X509_SIG *a); 762void X509_SIG_free(X509_SIG *a);
@@ -714,6 +810,25 @@ X509 * X509_new(void);
714void X509_free(X509 *a); 810void X509_free(X509 *a);
715int i2d_X509(X509 *a,unsigned char **pp); 811int i2d_X509(X509 *a,unsigned char **pp);
716X509 * d2i_X509(X509 **a,unsigned char **pp,long length); 812X509 * d2i_X509(X509 **a,unsigned char **pp,long length);
813int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
814 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
815int X509_set_ex_data(X509 *r, int idx, void *arg);
816void *X509_get_ex_data(X509 *r, int idx);
817int i2d_X509_AUX(X509 *a,unsigned char **pp);
818X509 * d2i_X509_AUX(X509 **a,unsigned char **pp,long length);
819
820X509_CERT_AUX * X509_CERT_AUX_new(void);
821void X509_CERT_AUX_free(X509_CERT_AUX *a);
822int i2d_X509_CERT_AUX(X509_CERT_AUX *a,unsigned char **pp);
823X509_CERT_AUX * d2i_X509_CERT_AUX(X509_CERT_AUX **a,unsigned char **pp,
824 long length);
825int X509_alias_set1(X509 *x, unsigned char *name, int len);
826unsigned char * X509_alias_get0(X509 *x, int *len);
827int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
828int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
829int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
830void X509_trust_clear(X509 *x);
831void X509_reject_clear(X509 *x);
717 832
718X509_REVOKED * X509_REVOKED_new(void); 833X509_REVOKED * X509_REVOKED_new(void);
719void X509_REVOKED_free(X509_REVOKED *a); 834void X509_REVOKED_free(X509_REVOKED *a);
@@ -762,7 +877,7 @@ char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
762int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1, 877int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1,
763 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); 878 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
764 879
765int ASN1_digest(int (*i2d)(),EVP_MD *type,char *data, 880int ASN1_digest(int (*i2d)(),const EVP_MD *type,char *data,
766 unsigned char *md,unsigned int *len); 881 unsigned char *md,unsigned int *len);
767 882
768int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2, 883int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
@@ -787,6 +902,30 @@ int X509_REQ_set_version(X509_REQ *x,long version);
787int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); 902int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
788int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); 903int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
789EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); 904EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
905int X509_REQ_extension_nid(int nid);
906int * X509_REQ_get_extension_nids(void);
907void X509_REQ_set_extension_nids(int *nids);
908STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
909int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
910 int nid);
911int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
912int X509_REQ_get_attr_count(const X509_REQ *req);
913int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
914 int lastpos);
915int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
916 int lastpos);
917X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
918X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
919int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
920int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
921 ASN1_OBJECT *obj, int type,
922 unsigned char *bytes, int len);
923int X509_REQ_add1_attr_by_NID(X509_REQ *req,
924 int nid, int type,
925 unsigned char *bytes, int len);
926int X509_REQ_add1_attr_by_txt(X509_REQ *req,
927 char *attrname, int type,
928 unsigned char *bytes, int len);
790 929
791int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); 930int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
792 931
@@ -799,6 +938,7 @@ unsigned long X509_issuer_name_hash(X509 *a);
799int X509_subject_name_cmp(X509 *a,X509 *b); 938int X509_subject_name_cmp(X509 *a,X509 *b);
800unsigned long X509_subject_name_hash(X509 *x); 939unsigned long X509_subject_name_hash(X509 *x);
801 940
941int X509_cmp (X509 *a, X509 *b);
802int X509_NAME_cmp (X509_NAME *a, X509_NAME *b); 942int X509_NAME_cmp (X509_NAME *a, X509_NAME *b);
803unsigned long X509_NAME_hash(X509_NAME *x); 943unsigned long X509_NAME_hash(X509_NAME *x);
804 944
@@ -812,6 +952,7 @@ int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
812#ifdef HEADER_BIO_H 952#ifdef HEADER_BIO_H
813int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); 953int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
814int X509_print(BIO *bp,X509 *x); 954int X509_print(BIO *bp,X509 *x);
955int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
815int X509_CRL_print(BIO *bp,X509_CRL *x); 956int X509_CRL_print(BIO *bp,X509_CRL *x);
816int X509_REQ_print(BIO *bp,X509_REQ *req); 957int X509_REQ_print(BIO *bp,X509_REQ *req);
817#endif 958#endif
@@ -823,7 +964,7 @@ int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
823 char *buf,int len); 964 char *buf,int len);
824 965
825/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use 966/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use
826 * lastpos, seach after that position on. */ 967 * lastpos, search after that position on. */
827int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); 968int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
828int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, 969int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
829 int lastpos); 970 int lastpos);
@@ -831,8 +972,16 @@ X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
831X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); 972X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
832int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, 973int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
833 int loc, int set); 974 int loc, int set);
975int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
976 unsigned char *bytes, int len, int loc, int set);
977int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
978 unsigned char *bytes, int len, int loc, int set);
979X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
980 char *field, int type, unsigned char *bytes, int len);
834X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, 981X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
835 int type,unsigned char *bytes, int len); 982 int type,unsigned char *bytes, int len);
983int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type,
984 unsigned char *bytes, int len, int loc, int set);
836X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, 985X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
837 ASN1_OBJECT *obj, int type,unsigned char *bytes, 986 ASN1_OBJECT *obj, int type,unsigned char *bytes,
838 int len); 987 int len);
@@ -862,6 +1011,7 @@ int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
862X509_EXTENSION *X509_get_ext(X509 *x, int loc); 1011X509_EXTENSION *X509_get_ext(X509 *x, int loc);
863X509_EXTENSION *X509_delete_ext(X509 *x, int loc); 1012X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
864int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); 1013int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
1014void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
865 1015
866int X509_CRL_get_ext_count(X509_CRL *x); 1016int X509_CRL_get_ext_count(X509_CRL *x);
867int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); 1017int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
@@ -870,6 +1020,7 @@ int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
870X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); 1020X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
871X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); 1021X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
872int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); 1022int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
1023void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
873 1024
874int X509_REVOKED_get_ext_count(X509_REVOKED *x); 1025int X509_REVOKED_get_ext_count(X509_REVOKED *x);
875int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); 1026int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
@@ -878,6 +1029,7 @@ int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
878X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); 1029X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
879X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); 1030X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
880int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); 1031int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
1032void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
881 1033
882X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, 1034X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
883 int nid, int crit, ASN1_OCTET_STRING *data); 1035 int nid, int crit, ASN1_OCTET_STRING *data);
@@ -891,6 +1043,38 @@ ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
891ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); 1043ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
892int X509_EXTENSION_get_critical(X509_EXTENSION *ex); 1044int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
893 1045
1046int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
1047int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
1048 int lastpos);
1049int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
1050 int lastpos);
1051X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
1052X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
1053STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
1054 X509_ATTRIBUTE *attr);
1055STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
1056 ASN1_OBJECT *obj, int type,
1057 unsigned char *bytes, int len);
1058STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
1059 int nid, int type,
1060 unsigned char *bytes, int len);
1061STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
1062 char *attrname, int type,
1063 unsigned char *bytes, int len);
1064X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
1065 int atrtype, void *data, int len);
1066X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
1067 ASN1_OBJECT *obj, int atrtype, void *data, int len);
1068X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
1069 char *atrname, int type, unsigned char *bytes, int len);
1070int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj);
1071int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int len);
1072void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
1073 int atrtype, void *data);
1074int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
1075ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
1076ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
1077
894int X509_verify_cert(X509_STORE_CTX *ctx); 1078int X509_verify_cert(X509_STORE_CTX *ctx);
895 1079
896/* lookup a cert from a X509 STACK */ 1080/* lookup a cert from a X509 STACK */
@@ -926,8 +1110,20 @@ void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a);
926 1110
927EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); 1111EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
928PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); 1112PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
1113PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
929PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); 1114PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
930 1115
1116int X509_check_trust(X509 *x, int id, int flags);
1117int X509_TRUST_get_count(void);
1118X509_TRUST * X509_TRUST_get0(int idx);
1119int X509_TRUST_get_by_id(int id);
1120int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
1121 char *name, int arg1, void *arg2);
1122void X509_TRUST_cleanup(void);
1123int X509_TRUST_get_flags(X509_TRUST *xp);
1124char *X509_TRUST_get0_name(X509_TRUST *xp);
1125int X509_TRUST_get_trust(X509_TRUST *xp);
1126
931/* BEGIN ERROR CODES */ 1127/* BEGIN ERROR CODES */
932/* The following lines are auto generated by the script mkerr.pl. Any changes 1128/* The following lines are auto generated by the script mkerr.pl. Any changes
933 * made after this point may be overwritten when the script is next run. 1129 * made after this point may be overwritten when the script is next run.
@@ -940,15 +1136,25 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
940#define X509_F_BY_FILE_CTRL 101 1136#define X509_F_BY_FILE_CTRL 101
941#define X509_F_DIR_CTRL 102 1137#define X509_F_DIR_CTRL 102
942#define X509_F_GET_CERT_BY_SUBJECT 103 1138#define X509_F_GET_CERT_BY_SUBJECT 103
1139#define X509_F_NETSCAPE_SPKI_B64_DECODE 129
1140#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130
943#define X509_F_X509V3_ADD_EXT 104 1141#define X509_F_X509V3_ADD_EXT 104
1142#define X509_F_X509_ADD_ATTR 135
1143#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136
1144#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137
1145#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140
1146#define X509_F_X509_ATTRIBUTE_GET0_DATA 139
1147#define X509_F_X509_ATTRIBUTE_SET1_DATA 138
944#define X509_F_X509_CHECK_PRIVATE_KEY 128 1148#define X509_F_X509_CHECK_PRIVATE_KEY 128
945#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 1149#define X509_F_X509_EXTENSION_CREATE_BY_NID 108
946#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 1150#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
947#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 1151#define X509_F_X509_GET_PUBKEY_PARAMETERS 110
1152#define X509_F_X509_LOAD_CERT_CRL_FILE 132
948#define X509_F_X509_LOAD_CERT_FILE 111 1153#define X509_F_X509_LOAD_CERT_FILE 111
949#define X509_F_X509_LOAD_CRL_FILE 112 1154#define X509_F_X509_LOAD_CRL_FILE 112
950#define X509_F_X509_NAME_ADD_ENTRY 113 1155#define X509_F_X509_NAME_ADD_ENTRY 113
951#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 1156#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
1157#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131
952#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 1158#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
953#define X509_F_X509_NAME_ONELINE 116 1159#define X509_F_X509_NAME_ONELINE 116
954#define X509_F_X509_NAME_PRINT 117 1160#define X509_F_X509_NAME_PRINT 117
@@ -960,15 +1166,19 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
960#define X509_F_X509_REQ_TO_X509 123 1166#define X509_F_X509_REQ_TO_X509 123
961#define X509_F_X509_STORE_ADD_CERT 124 1167#define X509_F_X509_STORE_ADD_CERT 124
962#define X509_F_X509_STORE_ADD_CRL 125 1168#define X509_F_X509_STORE_ADD_CRL 125
1169#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
963#define X509_F_X509_TO_X509_REQ 126 1170#define X509_F_X509_TO_X509_REQ 126
1171#define X509_F_X509_TRUST_ADD 133
964#define X509_F_X509_VERIFY_CERT 127 1172#define X509_F_X509_VERIFY_CERT 127
965 1173
966/* Reason codes. */ 1174/* Reason codes. */
967#define X509_R_BAD_X509_FILETYPE 100 1175#define X509_R_BAD_X509_FILETYPE 100
1176#define X509_R_BASE64_DECODE_ERROR 118
968#define X509_R_CANT_CHECK_DH_KEY 114 1177#define X509_R_CANT_CHECK_DH_KEY 114
969#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 1178#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
970#define X509_R_ERR_ASN1_LIB 102 1179#define X509_R_ERR_ASN1_LIB 102
971#define X509_R_INVALID_DIRECTORY 113 1180#define X509_R_INVALID_DIRECTORY 113
1181#define X509_R_INVALID_FIELD_NAME 119
972#define X509_R_KEY_TYPE_MISMATCH 115 1182#define X509_R_KEY_TYPE_MISMATCH 115
973#define X509_R_KEY_VALUES_MISMATCH 116 1183#define X509_R_KEY_VALUES_MISMATCH 116
974#define X509_R_LOADING_CERT_DIR 103 1184#define X509_R_LOADING_CERT_DIR 103
@@ -979,8 +1189,11 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
979#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 1189#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
980#define X509_R_UNKNOWN_KEY_TYPE 117 1190#define X509_R_UNKNOWN_KEY_TYPE 117
981#define X509_R_UNKNOWN_NID 109 1191#define X509_R_UNKNOWN_NID 109
1192#define X509_R_UNKNOWN_PURPOSE_ID 121
1193#define X509_R_UNKNOWN_TRUST_ID 120
982#define X509_R_UNSUPPORTED_ALGORITHM 111 1194#define X509_R_UNSUPPORTED_ALGORITHM 111
983#define X509_R_WRONG_LOOKUP_TYPE 112 1195#define X509_R_WRONG_LOOKUP_TYPE 112
1196#define X509_R_WRONG_TYPE 122
984 1197
985#ifdef __cplusplus 1198#ifdef __cplusplus
986} 1199}
diff --git a/src/lib/libssl/src/crypto/x509/x509_att.c b/src/lib/libssl/src/crypto/x509/x509_att.c
new file mode 100644
index 0000000000..caafde658f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509_att.c
@@ -0,0 +1,326 @@
1/* crypto/x509/x509_att.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <openssl/stack.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63#include <openssl/objects.h>
64#include <openssl/evp.h>
65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
67
68int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
69{
70 if (!x) return 0;
71 return(sk_X509_ATTRIBUTE_num(x));
72}
73
74int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
75 int lastpos)
76{
77 ASN1_OBJECT *obj;
78
79 obj=OBJ_nid2obj(nid);
80 if (obj == NULL) return(-2);
81 return(X509at_get_attr_by_OBJ(x,obj,lastpos));
82}
83
84int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
85 int lastpos)
86{
87 int n;
88 X509_ATTRIBUTE *ex;
89
90 if (sk == NULL) return(-1);
91 lastpos++;
92 if (lastpos < 0)
93 lastpos=0;
94 n=sk_X509_ATTRIBUTE_num(sk);
95 for ( ; lastpos < n; lastpos++)
96 {
97 ex=sk_X509_ATTRIBUTE_value(sk,lastpos);
98 if (OBJ_cmp(ex->object,obj) == 0)
99 return(lastpos);
100 }
101 return(-1);
102}
103
104X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
105{
106 if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
107 return NULL;
108 else
109 return sk_X509_ATTRIBUTE_value(x,loc);
110}
111
112X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc)
113{
114 X509_ATTRIBUTE *ret;
115
116 if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
117 return(NULL);
118 ret=sk_X509_ATTRIBUTE_delete(x,loc);
119 return(ret);
120}
121
122STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
123 X509_ATTRIBUTE *attr)
124{
125 X509_ATTRIBUTE *new_attr=NULL;
126 STACK_OF(X509_ATTRIBUTE) *sk=NULL;
127
128 if ((x != NULL) && (*x == NULL))
129 {
130 if ((sk=sk_X509_ATTRIBUTE_new_null()) == NULL)
131 goto err;
132 }
133 else
134 sk= *x;
135
136 if ((new_attr=X509_ATTRIBUTE_dup(attr)) == NULL)
137 goto err2;
138 if (!sk_X509_ATTRIBUTE_push(sk,new_attr))
139 goto err;
140 if ((x != NULL) && (*x == NULL))
141 *x=sk;
142 return(sk);
143err:
144 X509err(X509_F_X509_ADD_ATTR,ERR_R_MALLOC_FAILURE);
145err2:
146 if (new_attr != NULL) X509_ATTRIBUTE_free(new_attr);
147 if (sk != NULL) sk_X509_ATTRIBUTE_free(sk);
148 return(NULL);
149}
150
151STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
152 ASN1_OBJECT *obj, int type,
153 unsigned char *bytes, int len)
154{
155 X509_ATTRIBUTE *attr;
156 STACK_OF(X509_ATTRIBUTE) *ret;
157 attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len);
158 if(!attr) return 0;
159 ret = X509at_add1_attr(x, attr);
160 X509_ATTRIBUTE_free(attr);
161 return ret;
162}
163
164STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
165 int nid, int type,
166 unsigned char *bytes, int len)
167{
168 X509_ATTRIBUTE *attr;
169 STACK_OF(X509_ATTRIBUTE) *ret;
170 attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len);
171 if(!attr) return 0;
172 ret = X509at_add1_attr(x, attr);
173 X509_ATTRIBUTE_free(attr);
174 return ret;
175}
176
177STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
178 char *attrname, int type,
179 unsigned char *bytes, int len)
180{
181 X509_ATTRIBUTE *attr;
182 STACK_OF(X509_ATTRIBUTE) *ret;
183 attr = X509_ATTRIBUTE_create_by_txt(NULL, attrname, type, bytes, len);
184 if(!attr) return 0;
185 ret = X509at_add1_attr(x, attr);
186 X509_ATTRIBUTE_free(attr);
187 return ret;
188}
189
190X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
191 int atrtype, void *data, int len)
192{
193 ASN1_OBJECT *obj;
194 X509_ATTRIBUTE *ret;
195
196 obj=OBJ_nid2obj(nid);
197 if (obj == NULL)
198 {
199 X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_NID,X509_R_UNKNOWN_NID);
200 return(NULL);
201 }
202 ret=X509_ATTRIBUTE_create_by_OBJ(attr,obj,atrtype,data,len);
203 if (ret == NULL) ASN1_OBJECT_free(obj);
204 return(ret);
205}
206
207X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
208 ASN1_OBJECT *obj, int atrtype, void *data, int len)
209{
210 X509_ATTRIBUTE *ret;
211
212 if ((attr == NULL) || (*attr == NULL))
213 {
214 if ((ret=X509_ATTRIBUTE_new()) == NULL)
215 {
216 X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ,ERR_R_MALLOC_FAILURE);
217 return(NULL);
218 }
219 }
220 else
221 ret= *attr;
222
223 if (!X509_ATTRIBUTE_set1_object(ret,obj))
224 goto err;
225 if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len))
226 goto err;
227
228 if ((attr != NULL) && (*attr == NULL)) *attr=ret;
229 return(ret);
230err:
231 if ((attr == NULL) || (ret != *attr))
232 X509_ATTRIBUTE_free(ret);
233 return(NULL);
234}
235
236X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
237 char *atrname, int type, unsigned char *bytes, int len)
238 {
239 ASN1_OBJECT *obj;
240 X509_ATTRIBUTE *nattr;
241
242 obj=OBJ_txt2obj(atrname, 0);
243 if (obj == NULL)
244 {
245 X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_TXT,
246 X509_R_INVALID_FIELD_NAME);
247 ERR_add_error_data(2, "name=", atrname);
248 return(NULL);
249 }
250 nattr = X509_ATTRIBUTE_create_by_OBJ(attr,obj,type,bytes,len);
251 ASN1_OBJECT_free(obj);
252 return nattr;
253 }
254
255int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj)
256{
257 if ((attr == NULL) || (obj == NULL))
258 return(0);
259 ASN1_OBJECT_free(attr->object);
260 attr->object=OBJ_dup(obj);
261 return(1);
262}
263
264int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int len)
265{
266 ASN1_TYPE *ttmp;
267 ASN1_STRING *stmp;
268 int atype;
269 if (!attr) return 0;
270 if(attrtype & MBSTRING_FLAG) {
271 stmp = ASN1_STRING_set_by_NID(NULL, data, len, attrtype,
272 OBJ_obj2nid(attr->object));
273 if(!stmp) {
274 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_ASN1_LIB);
275 return 0;
276 }
277 atype = stmp->type;
278 } else {
279 if(!(stmp = ASN1_STRING_type_new(attrtype))) goto err;
280 if(!ASN1_STRING_set(stmp, data, len)) goto err;
281 atype = attrtype;
282 }
283 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
284 if(!(ttmp = ASN1_TYPE_new())) goto err;
285 if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err;
286 attr->set = 1;
287 ASN1_TYPE_set(ttmp, atype, stmp);
288 return 1;
289 err:
290 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
291 return 0;
292}
293
294int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr)
295{
296 if(attr->set) return sk_ASN1_TYPE_num(attr->value.set);
297 if(attr->value.single) return 1;
298 return 0;
299}
300
301ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr)
302{
303 if (attr == NULL) return(NULL);
304 return(attr->object);
305}
306
307void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
308 int atrtype, void *data)
309{
310 ASN1_TYPE *ttmp;
311 ttmp = X509_ATTRIBUTE_get0_type(attr, idx);
312 if(!ttmp) return NULL;
313 if(atrtype != ASN1_TYPE_get(ttmp)){
314 X509err(X509_F_X509_ATTRIBUTE_GET0_DATA, X509_R_WRONG_TYPE);
315 return NULL;
316 }
317 return ttmp->value.ptr;
318}
319
320ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx)
321{
322 if (attr == NULL) return(NULL);
323 if(idx >= X509_ATTRIBUTE_count(attr)) return NULL;
324 if(attr->set) return sk_ASN1_TYPE_value(attr->value.set, idx);
325 else return attr->value.single;
326}
diff --git a/src/lib/libssl/src/crypto/x509/x509_cmp.c b/src/lib/libssl/src/crypto/x509/x509_cmp.c
index 9a93bae3ff..a8a5ca8b03 100644
--- a/src/lib/libssl/src/crypto/x509/x509_cmp.c
+++ b/src/lib/libssl/src/crypto/x509/x509_cmp.c
@@ -57,12 +57,11 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <sys/stat.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/asn1.h> 61#include <openssl/asn1.h>
64#include <openssl/objects.h> 62#include <openssl/objects.h>
65#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h>
66 65
67int X509_issuer_and_serial_cmp(X509 *a, X509 *b) 66int X509_issuer_and_serial_cmp(X509 *a, X509 *b)
68 { 67 {
@@ -71,7 +70,7 @@ int X509_issuer_and_serial_cmp(X509 *a, X509 *b)
71 70
72 ai=a->cert_info; 71 ai=a->cert_info;
73 bi=b->cert_info; 72 bi=b->cert_info;
74 i=ASN1_INTEGER_cmp(ai->serialNumber,bi->serialNumber); 73 i=M_ASN1_INTEGER_cmp(ai->serialNumber,bi->serialNumber);
75 if (i) return(i); 74 if (i) return(i);
76 return(X509_NAME_cmp(ai->issuer,bi->issuer)); 75 return(X509_NAME_cmp(ai->issuer,bi->issuer));
77 } 76 }
@@ -138,6 +137,20 @@ unsigned long X509_subject_name_hash(X509 *x)
138 return(X509_NAME_hash(x->cert_info->subject)); 137 return(X509_NAME_hash(x->cert_info->subject));
139 } 138 }
140 139
140#ifndef NO_SHA
141/* Compare two certificates: they must be identical for
142 * this to work.
143 */
144int X509_cmp(X509 *a, X509 *b)
145{
146 /* ensure hash is valid */
147 X509_check_purpose(a, -1, 0);
148 X509_check_purpose(b, -1, 0);
149
150 return memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
151}
152#endif
153
141int X509_NAME_cmp(X509_NAME *a, X509_NAME *b) 154int X509_NAME_cmp(X509_NAME *a, X509_NAME *b)
142 { 155 {
143 int i,j; 156 int i,j;
@@ -175,7 +188,7 @@ int X509_NAME_cmp(X509_NAME *a, X509_NAME *b)
175 188
176#ifndef NO_MD5 189#ifndef NO_MD5
177/* I now DER encode the name and hash it. Since I cache the DER encoding, 190/* I now DER encode the name and hash it. Since I cache the DER encoding,
178 * this is reasonably effiecent. */ 191 * this is reasonably efficient. */
179unsigned long X509_NAME_hash(X509_NAME *x) 192unsigned long X509_NAME_hash(X509_NAME *x)
180 { 193 {
181 unsigned long ret=0; 194 unsigned long ret=0;
@@ -209,6 +222,8 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
209 X509_CINF cinf; 222 X509_CINF cinf;
210 X509 x,*x509=NULL; 223 X509 x,*x509=NULL;
211 224
225 if(!sk) return NULL;
226
212 x.cert_info= &cinf; 227 x.cert_info= &cinf;
213 cinf.serialNumber=serial; 228 cinf.serialNumber=serial;
214 cinf.issuer=name; 229 cinf.issuer=name;
diff --git a/src/lib/libssl/src/crypto/x509/x509_d2.c b/src/lib/libssl/src/crypto/x509/x509_d2.c
index 3e7ec5b432..753d53eb43 100644
--- a/src/lib/libssl/src/crypto/x509/x509_d2.c
+++ b/src/lib/libssl/src/crypto/x509/x509_d2.c
@@ -57,8 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <sys/stat.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/crypto.h> 61#include <openssl/crypto.h>
64#include <openssl/x509.h> 62#include <openssl/x509.h>
@@ -91,13 +89,15 @@ int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
91 { 89 {
92 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_file()); 90 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_file());
93 if (lookup == NULL) return(0); 91 if (lookup == NULL) return(0);
94 X509_LOOKUP_load_file(lookup,file,X509_FILETYPE_PEM); 92 if (X509_LOOKUP_load_file(lookup,file,X509_FILETYPE_PEM) != 1)
93 return(0);
95 } 94 }
96 if (path != NULL) 95 if (path != NULL)
97 { 96 {
98 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_hash_dir()); 97 lookup=X509_STORE_add_lookup(ctx,X509_LOOKUP_hash_dir());
99 if (lookup == NULL) return(0); 98 if (lookup == NULL) return(0);
100 X509_LOOKUP_add_dir(lookup,path,X509_FILETYPE_PEM); 99 if (X509_LOOKUP_add_dir(lookup,path,X509_FILETYPE_PEM) != 1)
100 return(0);
101 } 101 }
102 if ((path == NULL) && (file == NULL)) 102 if ((path == NULL) && (file == NULL))
103 return(0); 103 return(0);
diff --git a/src/lib/libssl/src/crypto/x509/x509_def.c b/src/lib/libssl/src/crypto/x509/x509_def.c
index c4bee71569..e0ac151a76 100644
--- a/src/lib/libssl/src/crypto/x509/x509_def.c
+++ b/src/lib/libssl/src/crypto/x509/x509_def.c
@@ -57,8 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <sys/types.h>
61#include <sys/stat.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/crypto.h> 61#include <openssl/crypto.h>
64#include <openssl/x509.h> 62#include <openssl/x509.h>
diff --git a/src/lib/libssl/src/crypto/x509/x509_err.c b/src/lib/libssl/src/crypto/x509/x509_err.c
index 9afd4ccde5..fdedbdac34 100644
--- a/src/lib/libssl/src/crypto/x509/x509_err.c
+++ b/src/lib/libssl/src/crypto/x509/x509_err.c
@@ -69,15 +69,25 @@ static ERR_STRING_DATA X509_str_functs[]=
69{ERR_PACK(0,X509_F_BY_FILE_CTRL,0), "BY_FILE_CTRL"}, 69{ERR_PACK(0,X509_F_BY_FILE_CTRL,0), "BY_FILE_CTRL"},
70{ERR_PACK(0,X509_F_DIR_CTRL,0), "DIR_CTRL"}, 70{ERR_PACK(0,X509_F_DIR_CTRL,0), "DIR_CTRL"},
71{ERR_PACK(0,X509_F_GET_CERT_BY_SUBJECT,0), "GET_CERT_BY_SUBJECT"}, 71{ERR_PACK(0,X509_F_GET_CERT_BY_SUBJECT,0), "GET_CERT_BY_SUBJECT"},
72{ERR_PACK(0,X509_F_NETSCAPE_SPKI_B64_DECODE,0), "NETSCAPE_SPKI_b64_decode"},
73{ERR_PACK(0,X509_F_NETSCAPE_SPKI_B64_ENCODE,0), "NETSCAPE_SPKI_b64_encode"},
72{ERR_PACK(0,X509_F_X509V3_ADD_EXT,0), "X509v3_add_ext"}, 74{ERR_PACK(0,X509_F_X509V3_ADD_EXT,0), "X509v3_add_ext"},
75{ERR_PACK(0,X509_F_X509_ADD_ATTR,0), "X509_ADD_ATTR"},
76{ERR_PACK(0,X509_F_X509_ATTRIBUTE_CREATE_BY_NID,0), "X509_ATTRIBUTE_create_by_NID"},
77{ERR_PACK(0,X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ,0), "X509_ATTRIBUTE_create_by_OBJ"},
78{ERR_PACK(0,X509_F_X509_ATTRIBUTE_CREATE_BY_TXT,0), "X509_ATTRIBUTE_create_by_txt"},
79{ERR_PACK(0,X509_F_X509_ATTRIBUTE_GET0_DATA,0), "X509_ATTRIBUTE_get0_data"},
80{ERR_PACK(0,X509_F_X509_ATTRIBUTE_SET1_DATA,0), "X509_ATTRIBUTE_set1_data"},
73{ERR_PACK(0,X509_F_X509_CHECK_PRIVATE_KEY,0), "X509_check_private_key"}, 81{ERR_PACK(0,X509_F_X509_CHECK_PRIVATE_KEY,0), "X509_check_private_key"},
74{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_NID,0), "X509_EXTENSION_create_by_NID"}, 82{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_NID,0), "X509_EXTENSION_create_by_NID"},
75{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_OBJ,0), "X509_EXTENSION_create_by_OBJ"}, 83{ERR_PACK(0,X509_F_X509_EXTENSION_CREATE_BY_OBJ,0), "X509_EXTENSION_create_by_OBJ"},
76{ERR_PACK(0,X509_F_X509_GET_PUBKEY_PARAMETERS,0), "X509_get_pubkey_parameters"}, 84{ERR_PACK(0,X509_F_X509_GET_PUBKEY_PARAMETERS,0), "X509_get_pubkey_parameters"},
85{ERR_PACK(0,X509_F_X509_LOAD_CERT_CRL_FILE,0), "X509_load_cert_crl_file"},
77{ERR_PACK(0,X509_F_X509_LOAD_CERT_FILE,0), "X509_load_cert_file"}, 86{ERR_PACK(0,X509_F_X509_LOAD_CERT_FILE,0), "X509_load_cert_file"},
78{ERR_PACK(0,X509_F_X509_LOAD_CRL_FILE,0), "X509_load_crl_file"}, 87{ERR_PACK(0,X509_F_X509_LOAD_CRL_FILE,0), "X509_load_crl_file"},
79{ERR_PACK(0,X509_F_X509_NAME_ADD_ENTRY,0), "X509_NAME_add_entry"}, 88{ERR_PACK(0,X509_F_X509_NAME_ADD_ENTRY,0), "X509_NAME_add_entry"},
80{ERR_PACK(0,X509_F_X509_NAME_ENTRY_CREATE_BY_NID,0), "X509_NAME_ENTRY_create_by_NID"}, 89{ERR_PACK(0,X509_F_X509_NAME_ENTRY_CREATE_BY_NID,0), "X509_NAME_ENTRY_create_by_NID"},
90{ERR_PACK(0,X509_F_X509_NAME_ENTRY_CREATE_BY_TXT,0), "X509_NAME_ENTRY_create_by_txt"},
81{ERR_PACK(0,X509_F_X509_NAME_ENTRY_SET_OBJECT,0), "X509_NAME_ENTRY_set_object"}, 91{ERR_PACK(0,X509_F_X509_NAME_ENTRY_SET_OBJECT,0), "X509_NAME_ENTRY_set_object"},
82{ERR_PACK(0,X509_F_X509_NAME_ONELINE,0), "X509_NAME_oneline"}, 92{ERR_PACK(0,X509_F_X509_NAME_ONELINE,0), "X509_NAME_oneline"},
83{ERR_PACK(0,X509_F_X509_NAME_PRINT,0), "X509_NAME_print"}, 93{ERR_PACK(0,X509_F_X509_NAME_PRINT,0), "X509_NAME_print"},
@@ -89,7 +99,9 @@ static ERR_STRING_DATA X509_str_functs[]=
89{ERR_PACK(0,X509_F_X509_REQ_TO_X509,0), "X509_REQ_to_X509"}, 99{ERR_PACK(0,X509_F_X509_REQ_TO_X509,0), "X509_REQ_to_X509"},
90{ERR_PACK(0,X509_F_X509_STORE_ADD_CERT,0), "X509_STORE_add_cert"}, 100{ERR_PACK(0,X509_F_X509_STORE_ADD_CERT,0), "X509_STORE_add_cert"},
91{ERR_PACK(0,X509_F_X509_STORE_ADD_CRL,0), "X509_STORE_add_crl"}, 101{ERR_PACK(0,X509_F_X509_STORE_ADD_CRL,0), "X509_STORE_add_crl"},
102{ERR_PACK(0,X509_F_X509_STORE_CTX_PURPOSE_INHERIT,0), "X509_STORE_CTX_purpose_inherit"},
92{ERR_PACK(0,X509_F_X509_TO_X509_REQ,0), "X509_to_X509_REQ"}, 103{ERR_PACK(0,X509_F_X509_TO_X509_REQ,0), "X509_to_X509_REQ"},
104{ERR_PACK(0,X509_F_X509_TRUST_ADD,0), "X509_TRUST_add"},
93{ERR_PACK(0,X509_F_X509_VERIFY_CERT,0), "X509_verify_cert"}, 105{ERR_PACK(0,X509_F_X509_VERIFY_CERT,0), "X509_verify_cert"},
94{0,NULL} 106{0,NULL}
95 }; 107 };
@@ -97,10 +109,12 @@ static ERR_STRING_DATA X509_str_functs[]=
97static ERR_STRING_DATA X509_str_reasons[]= 109static ERR_STRING_DATA X509_str_reasons[]=
98 { 110 {
99{X509_R_BAD_X509_FILETYPE ,"bad x509 filetype"}, 111{X509_R_BAD_X509_FILETYPE ,"bad x509 filetype"},
112{X509_R_BASE64_DECODE_ERROR ,"base64 decode error"},
100{X509_R_CANT_CHECK_DH_KEY ,"cant check dh key"}, 113{X509_R_CANT_CHECK_DH_KEY ,"cant check dh key"},
101{X509_R_CERT_ALREADY_IN_HASH_TABLE ,"cert already in hash table"}, 114{X509_R_CERT_ALREADY_IN_HASH_TABLE ,"cert already in hash table"},
102{X509_R_ERR_ASN1_LIB ,"err asn1 lib"}, 115{X509_R_ERR_ASN1_LIB ,"err asn1 lib"},
103{X509_R_INVALID_DIRECTORY ,"invalid directory"}, 116{X509_R_INVALID_DIRECTORY ,"invalid directory"},
117{X509_R_INVALID_FIELD_NAME ,"invalid field name"},
104{X509_R_KEY_TYPE_MISMATCH ,"key type mismatch"}, 118{X509_R_KEY_TYPE_MISMATCH ,"key type mismatch"},
105{X509_R_KEY_VALUES_MISMATCH ,"key values mismatch"}, 119{X509_R_KEY_VALUES_MISMATCH ,"key values mismatch"},
106{X509_R_LOADING_CERT_DIR ,"loading cert dir"}, 120{X509_R_LOADING_CERT_DIR ,"loading cert dir"},
@@ -111,8 +125,11 @@ static ERR_STRING_DATA X509_str_reasons[]=
111{X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY ,"unable to get certs public key"}, 125{X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY ,"unable to get certs public key"},
112{X509_R_UNKNOWN_KEY_TYPE ,"unknown key type"}, 126{X509_R_UNKNOWN_KEY_TYPE ,"unknown key type"},
113{X509_R_UNKNOWN_NID ,"unknown nid"}, 127{X509_R_UNKNOWN_NID ,"unknown nid"},
128{X509_R_UNKNOWN_PURPOSE_ID ,"unknown purpose id"},
129{X509_R_UNKNOWN_TRUST_ID ,"unknown trust id"},
114{X509_R_UNSUPPORTED_ALGORITHM ,"unsupported algorithm"}, 130{X509_R_UNSUPPORTED_ALGORITHM ,"unsupported algorithm"},
115{X509_R_WRONG_LOOKUP_TYPE ,"wrong lookup type"}, 131{X509_R_WRONG_LOOKUP_TYPE ,"wrong lookup type"},
132{X509_R_WRONG_TYPE ,"wrong type"},
116{0,NULL} 133{0,NULL}
117 }; 134 };
118 135
diff --git a/src/lib/libssl/src/crypto/x509/x509_ext.c b/src/lib/libssl/src/crypto/x509/x509_ext.c
index f8565a60b2..2955989807 100644
--- a/src/lib/libssl/src/crypto/x509/x509_ext.c
+++ b/src/lib/libssl/src/crypto/x509/x509_ext.c
@@ -63,6 +63,8 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
67
66 68
67int X509_CRL_get_ext_count(X509_CRL *x) 69int X509_CRL_get_ext_count(X509_CRL *x)
68 { 70 {
@@ -94,6 +96,11 @@ X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc)
94 return(X509v3_delete_ext(x->crl->extensions,loc)); 96 return(X509v3_delete_ext(x->crl->extensions,loc));
95 } 97 }
96 98
99void *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx)
100{
101 return X509V3_get_d2i(x->crl->extensions, nid, crit, idx);
102}
103
97int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) 104int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc)
98 { 105 {
99 return(X509v3_add_ext(&(x->crl->extensions),ex,loc) != NULL); 106 return(X509v3_add_ext(&(x->crl->extensions),ex,loc) != NULL);
@@ -134,6 +141,11 @@ int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc)
134 return(X509v3_add_ext(&(x->cert_info->extensions),ex,loc) != NULL); 141 return(X509v3_add_ext(&(x->cert_info->extensions),ex,loc) != NULL);
135 } 142 }
136 143
144void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
145{
146 return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx);
147}
148
137int X509_REVOKED_get_ext_count(X509_REVOKED *x) 149int X509_REVOKED_get_ext_count(X509_REVOKED *x)
138 { 150 {
139 return(X509v3_get_ext_count(x->extensions)); 151 return(X509v3_get_ext_count(x->extensions));
@@ -170,5 +182,10 @@ int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc)
170 return(X509v3_add_ext(&(x->extensions),ex,loc) != NULL); 182 return(X509v3_add_ext(&(x->extensions),ex,loc) != NULL);
171 } 183 }
172 184
185void *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx)
186{
187 return X509V3_get_d2i(x->extensions, nid, crit, idx);
188}
189
173IMPLEMENT_STACK_OF(X509_EXTENSION) 190IMPLEMENT_STACK_OF(X509_EXTENSION)
174IMPLEMENT_ASN1_SET_OF(X509_EXTENSION) 191IMPLEMENT_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 18bfecb11e..a20006d67e 100644
--- a/src/lib/libssl/src/crypto/x509/x509_lu.c
+++ b/src/lib/libssl/src/crypto/x509/x509_lu.c
@@ -61,8 +61,8 @@
61#include <openssl/lhash.h> 61#include <openssl/lhash.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64static STACK *x509_store_meth=NULL; 64static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_meth=NULL;
65static STACK *x509_store_ctx_meth=NULL; 65static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_ctx_meth=NULL;
66 66
67X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) 67X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
68 { 68 {
@@ -244,7 +244,7 @@ void X509_STORE_free(X509_STORE *vfy)
244 } 244 }
245 sk_X509_LOOKUP_free(sk); 245 sk_X509_LOOKUP_free(sk);
246 246
247 CRYPTO_free_ex_data(x509_store_meth,(char *)vfy,&vfy->ex_data); 247 CRYPTO_free_ex_data(x509_store_meth,vfy,&vfy->ex_data);
248 lh_doall(vfy->certs,cleanup); 248 lh_doall(vfy->certs,cleanup);
249 lh_free(vfy->certs); 249 lh_free(vfy->certs);
250 Free(vfy); 250 Free(vfy);
@@ -377,10 +377,24 @@ X509_OBJECT *X509_OBJECT_retrieve_by_subject(LHASH *h, int type,
377 abort(); 377 abort();
378 } 378 }
379 379
380 tmp=(X509_OBJECT *)lh_retrieve(h,(char *)&stmp); 380 tmp=(X509_OBJECT *)lh_retrieve(h,&stmp);
381 return(tmp); 381 return(tmp);
382 } 382 }
383 383
384X509_STORE_CTX *X509_STORE_CTX_new(void)
385{
386 X509_STORE_CTX *ctx;
387 ctx = (X509_STORE_CTX *)Malloc(sizeof(X509_STORE_CTX));
388 if(ctx) memset(ctx, 0, sizeof(X509_STORE_CTX));
389 return ctx;
390}
391
392void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
393{
394 X509_STORE_CTX_cleanup(ctx);
395 Free(ctx);
396}
397
384void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, 398void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
385 STACK_OF(X509) *chain) 399 STACK_OF(X509) *chain)
386 { 400 {
@@ -389,6 +403,8 @@ void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
389 ctx->cert=x509; 403 ctx->cert=x509;
390 ctx->untrusted=chain; 404 ctx->untrusted=chain;
391 ctx->last_untrusted=0; 405 ctx->last_untrusted=0;
406 ctx->purpose=0;
407 ctx->trust=0;
392 ctx->valid=0; 408 ctx->valid=0;
393 ctx->chain=NULL; 409 ctx->chain=NULL;
394 ctx->depth=9; 410 ctx->depth=9;
@@ -404,7 +420,7 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
404 sk_X509_pop_free(ctx->chain,X509_free); 420 sk_X509_pop_free(ctx->chain,X509_free);
405 ctx->chain=NULL; 421 ctx->chain=NULL;
406 } 422 }
407 CRYPTO_free_ex_data(x509_store_ctx_meth,(char *)ctx,&(ctx->ex_data)); 423 CRYPTO_free_ex_data(x509_store_ctx_meth,ctx,&(ctx->ex_data));
408 memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA)); 424 memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA));
409 } 425 }
410 426
diff --git a/src/lib/libssl/src/crypto/x509/x509_r2x.c b/src/lib/libssl/src/crypto/x509/x509_r2x.c
index bb4697ae60..db051033d9 100644
--- a/src/lib/libssl/src/crypto/x509/x509_r2x.c
+++ b/src/lib/libssl/src/crypto/x509/x509_r2x.c
@@ -82,7 +82,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
82 82
83 if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) 83 if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0)
84 { 84 {
85 if ((xi->version=ASN1_INTEGER_new()) == NULL) goto err; 85 if ((xi->version=M_ASN1_INTEGER_new()) == NULL) goto err;
86 if (!ASN1_INTEGER_set(xi->version,2)) goto err; 86 if (!ASN1_INTEGER_set(xi->version,2)) goto err;
87/* xi->extensions=ri->attributes; <- bad, should not ever be done 87/* xi->extensions=ri->attributes; <- bad, should not ever be done
88 ri->attributes=NULL; */ 88 ri->attributes=NULL; */
diff --git a/src/lib/libssl/src/crypto/x509/x509_req.c b/src/lib/libssl/src/crypto/x509/x509_req.c
index 2ef94decd1..baef8790eb 100644
--- a/src/lib/libssl/src/crypto/x509/x509_req.c
+++ b/src/lib/libssl/src/crypto/x509/x509_req.c
@@ -66,7 +66,7 @@
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#include <openssl/pem.h> 67#include <openssl/pem.h>
68 68
69X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, EVP_MD *md) 69X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
70 { 70 {
71 X509_REQ *ret; 71 X509_REQ *ret;
72 X509_REQ_INFO *ri; 72 X509_REQ_INFO *ri;
@@ -113,3 +113,166 @@ EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
113 return(X509_PUBKEY_get(req->req_info->pubkey)); 113 return(X509_PUBKEY_get(req->req_info->pubkey));
114 } 114 }
115 115
116/* It seems several organisations had the same idea of including a list of
117 * extensions in a certificate request. There are at least two OIDs that are
118 * used and there may be more: so the list is configurable.
119 */
120
121static int ext_nid_list[] = { NID_ms_ext_req, NID_ext_req, NID_undef};
122
123static int *ext_nids = ext_nid_list;
124
125int X509_REQ_extension_nid(int req_nid)
126{
127 int i, nid;
128 for(i = 0; ; i++) {
129 nid = ext_nids[i];
130 if(nid == NID_undef) return 0;
131 else if (req_nid == nid) return 1;
132 }
133}
134
135int *X509_REQ_get_extension_nids(void)
136{
137 return ext_nids;
138}
139
140void X509_REQ_set_extension_nids(int *nids)
141{
142 ext_nids = nids;
143}
144
145STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
146{
147 X509_ATTRIBUTE *attr;
148 STACK_OF(X509_ATTRIBUTE) *sk;
149 ASN1_TYPE *ext = NULL;
150 int i;
151 unsigned char *p;
152 if ((req == NULL) || (req->req_info == NULL))
153 return(NULL);
154 sk=req->req_info->attributes;
155 if (!sk) return NULL;
156 for(i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) {
157 attr = sk_X509_ATTRIBUTE_value(sk, i);
158 if(X509_REQ_extension_nid(OBJ_obj2nid(attr->object))) {
159 if(attr->set && sk_ASN1_TYPE_num(attr->value.set))
160 ext = sk_ASN1_TYPE_value(attr->value.set, 0);
161 else ext = attr->value.single;
162 break;
163 }
164 }
165 if(!ext || (ext->type != V_ASN1_SEQUENCE)) return NULL;
166 p = ext->value.sequence->data;
167 return d2i_ASN1_SET_OF_X509_EXTENSION(NULL, &p,
168 ext->value.sequence->length,
169 d2i_X509_EXTENSION, X509_EXTENSION_free,
170 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
171}
172
173/* Add a STACK_OF extensions to a certificate request: allow alternative OIDs
174 * in case we want to create a non standard one.
175 */
176
177int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
178 int nid)
179{
180 unsigned char *p = NULL, *q;
181 long len;
182 ASN1_TYPE *at = NULL;
183 X509_ATTRIBUTE *attr = NULL;
184 if(!(at = ASN1_TYPE_new()) ||
185 !(at->value.sequence = ASN1_STRING_new())) goto err;
186
187 at->type = V_ASN1_SEQUENCE;
188 /* Generate encoding of extensions */
189 len = i2d_ASN1_SET_OF_X509_EXTENSION(exts, NULL, i2d_X509_EXTENSION,
190 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE);
191 if(!(p = Malloc(len))) goto err;
192 q = p;
193 i2d_ASN1_SET_OF_X509_EXTENSION(exts, &q, i2d_X509_EXTENSION,
194 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE);
195 at->value.sequence->data = p;
196 p = NULL;
197 at->value.sequence->length = len;
198 if(!(attr = X509_ATTRIBUTE_new())) 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;
201 at = NULL;
202 attr->set = 1;
203 attr->object = OBJ_nid2obj(nid);
204 if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err;
205 return 1;
206 err:
207 if(p) Free(p);
208 X509_ATTRIBUTE_free(attr);
209 ASN1_TYPE_free(at);
210 return 0;
211}
212/* This is the normal usage: use the "official" OID */
213int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts)
214{
215 return X509_REQ_add_extensions_nid(req, exts, NID_ext_req);
216}
217
218/* Request attribute functions */
219
220int X509_REQ_get_attr_count(const X509_REQ *req)
221{
222 return X509at_get_attr_count(req->req_info->attributes);
223}
224
225int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
226 int lastpos)
227{
228 return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos);
229}
230
231int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
232 int lastpos)
233{
234 return X509at_get_attr_by_OBJ(req->req_info->attributes, obj, lastpos);
235}
236
237X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc)
238{
239 return X509at_get_attr(req->req_info->attributes, loc);
240}
241
242X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc)
243{
244 return X509at_delete_attr(req->req_info->attributes, loc);
245}
246
247int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr)
248{
249 if(X509at_add1_attr(&req->req_info->attributes, attr)) return 1;
250 return 0;
251}
252
253int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
254 ASN1_OBJECT *obj, int type,
255 unsigned char *bytes, int len)
256{
257 if(X509at_add1_attr_by_OBJ(&req->req_info->attributes, obj,
258 type, bytes, len)) return 1;
259 return 0;
260}
261
262int X509_REQ_add1_attr_by_NID(X509_REQ *req,
263 int nid, int type,
264 unsigned char *bytes, int len)
265{
266 if(X509at_add1_attr_by_NID(&req->req_info->attributes, nid,
267 type, bytes, len)) return 1;
268 return 0;
269}
270
271int X509_REQ_add1_attr_by_txt(X509_REQ *req,
272 char *attrname, int type,
273 unsigned char *bytes, int len)
274{
275 if(X509at_add1_attr_by_txt(&req->req_info->attributes, attrname,
276 type, bytes, len)) return 1;
277 return 0;
278}
diff --git a/src/lib/libssl/src/crypto/x509/x509_set.c b/src/lib/libssl/src/crypto/x509/x509_set.c
index 5a6f7b414f..add842d17a 100644
--- a/src/lib/libssl/src/crypto/x509/x509_set.c
+++ b/src/lib/libssl/src/crypto/x509/x509_set.c
@@ -68,7 +68,7 @@ int X509_set_version(X509 *x, long version)
68 if (x == NULL) return(0); 68 if (x == NULL) return(0);
69 if (x->cert_info->version == NULL) 69 if (x->cert_info->version == NULL)
70 { 70 {
71 if ((x->cert_info->version=ASN1_INTEGER_new()) == NULL) 71 if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL)
72 return(0); 72 return(0);
73 } 73 }
74 return(ASN1_INTEGER_set(x->cert_info->version,version)); 74 return(ASN1_INTEGER_set(x->cert_info->version,version));
@@ -82,10 +82,10 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
82 in=x->cert_info->serialNumber; 82 in=x->cert_info->serialNumber;
83 if (in != serial) 83 if (in != serial)
84 { 84 {
85 in=ASN1_INTEGER_dup(serial); 85 in=M_ASN1_INTEGER_dup(serial);
86 if (in != NULL) 86 if (in != NULL)
87 { 87 {
88 ASN1_INTEGER_free(x->cert_info->serialNumber); 88 M_ASN1_INTEGER_free(x->cert_info->serialNumber);
89 x->cert_info->serialNumber=in; 89 x->cert_info->serialNumber=in;
90 } 90 }
91 } 91 }
@@ -112,10 +112,10 @@ int X509_set_notBefore(X509 *x, ASN1_UTCTIME *tm)
112 in=x->cert_info->validity->notBefore; 112 in=x->cert_info->validity->notBefore;
113 if (in != tm) 113 if (in != tm)
114 { 114 {
115 in=ASN1_UTCTIME_dup(tm); 115 in=M_ASN1_UTCTIME_dup(tm);
116 if (in != NULL) 116 if (in != NULL)
117 { 117 {
118 ASN1_UTCTIME_free(x->cert_info->validity->notBefore); 118 M_ASN1_UTCTIME_free(x->cert_info->validity->notBefore);
119 x->cert_info->validity->notBefore=in; 119 x->cert_info->validity->notBefore=in;
120 } 120 }
121 } 121 }
@@ -130,10 +130,10 @@ int X509_set_notAfter(X509 *x, ASN1_UTCTIME *tm)
130 in=x->cert_info->validity->notAfter; 130 in=x->cert_info->validity->notAfter;
131 if (in != tm) 131 if (in != tm)
132 { 132 {
133 in=ASN1_UTCTIME_dup(tm); 133 in=M_ASN1_UTCTIME_dup(tm);
134 if (in != NULL) 134 if (in != NULL)
135 { 135 {
136 ASN1_UTCTIME_free(x->cert_info->validity->notAfter); 136 M_ASN1_UTCTIME_free(x->cert_info->validity->notAfter);
137 x->cert_info->validity->notAfter=in; 137 x->cert_info->validity->notAfter=in;
138 } 138 }
139 } 139 }
diff --git a/src/lib/libssl/src/crypto/x509/x509_trs.c b/src/lib/libssl/src/crypto/x509/x509_trs.c
new file mode 100644
index 0000000000..9f7d67952d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509_trs.c
@@ -0,0 +1,263 @@
1/* x509_trs.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/x509v3.h>
62
63
64static int tr_cmp(X509_TRUST **a, X509_TRUST **b);
65static void trtable_free(X509_TRUST *p);
66
67static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags);
68static int trust_any(X509_TRUST *trust, X509 *x, int flags);
69
70static int obj_trust(int id, X509 *x, int flags);
71static int (*default_trust)(int id, X509 *x, int flags) = obj_trust;
72
73/* WARNING: the following table should be kept in order of trust
74 * and without any gaps so we can just subtract the minimum trust
75 * value to get an index into the table
76 */
77
78static X509_TRUST trstandard[] = {
79{X509_TRUST_ANY, 0, trust_any, "Any", 0, NULL},
80{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL},
81{X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Client", NID_server_auth, NULL},
82{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL},
83};
84
85#define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST))
86
87IMPLEMENT_STACK_OF(X509_TRUST)
88
89static STACK_OF(X509_TRUST) *trtable = NULL;
90
91static int tr_cmp(X509_TRUST **a, X509_TRUST **b)
92{
93 return (*a)->trust - (*b)->trust;
94}
95
96int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int)
97{
98int (*oldtrust)(int , X509 *, int);
99oldtrust = default_trust;
100default_trust = trust;
101return oldtrust;
102}
103
104
105int X509_check_trust(X509 *x, int id, int flags)
106{
107 X509_TRUST *pt;
108 int idx;
109 if(id == -1) return 1;
110 if(!(idx = X509_TRUST_get_by_id(id)))
111 return default_trust(id, x, flags);
112 pt = X509_TRUST_get0(idx);
113 return pt->check_trust(pt, x, flags);
114}
115
116int X509_TRUST_get_count(void)
117{
118 if(!trtable) return X509_TRUST_COUNT;
119 return sk_X509_TRUST_num(trtable) + X509_TRUST_COUNT;
120}
121
122X509_TRUST * X509_TRUST_get0(int idx)
123{
124 if(idx < 0) return NULL;
125 if(idx < X509_TRUST_COUNT) return trstandard + idx;
126 return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT);
127}
128
129int X509_TRUST_get_by_id(int id)
130{
131 X509_TRUST tmp;
132 int idx;
133 if((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))
134 return id - X509_TRUST_MIN;
135 tmp.trust = id;
136 if(!trtable) return -1;
137 idx = sk_X509_TRUST_find(trtable, &tmp);
138 if(idx == -1) return -1;
139 return idx + X509_TRUST_COUNT;
140}
141
142int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
143 char *name, int arg1, void *arg2)
144{
145 int idx;
146 X509_TRUST *trtmp;
147 /* This is set according to what we change: application can't set it */
148 flags &= ~X509_TRUST_DYNAMIC;
149 /* This will always be set for application modified trust entries */
150 flags |= X509_TRUST_DYNAMIC_NAME;
151 /* Get existing entry if any */
152 idx = X509_TRUST_get_by_id(id);
153 /* Need a new entry */
154 if(idx == -1) {
155 if(!(trtmp = Malloc(sizeof(X509_TRUST)))) {
156 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
157 return 0;
158 }
159 trtmp->flags = X509_TRUST_DYNAMIC;
160 } else trtmp = X509_TRUST_get0(idx);
161
162 /* Free existing name if dynamic */
163 if(trtmp->flags & X509_TRUST_DYNAMIC_NAME) Free(trtmp->name);
164 /* dup supplied name */
165 if(!(trtmp->name = BUF_strdup(name))) {
166 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
167 return 0;
168 }
169 /* Keep the dynamic flag of existing entry */
170 trtmp->flags &= X509_TRUST_DYNAMIC;
171 /* Set all other flags */
172 trtmp->flags |= flags;
173
174 trtmp->trust = id;
175 trtmp->check_trust = ck;
176 trtmp->arg1 = arg1;
177 trtmp->arg2 = arg2;
178
179 /* If its a new entry manage the dynamic table */
180 if(idx == -1) {
181 if(!trtable && !(trtable = sk_X509_TRUST_new(tr_cmp))) {
182 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
183 return 0;
184 }
185 if (!sk_X509_TRUST_push(trtable, trtmp)) {
186 X509err(X509_F_X509_TRUST_ADD,ERR_R_MALLOC_FAILURE);
187 return 0;
188 }
189 }
190 return 1;
191}
192
193static void trtable_free(X509_TRUST *p)
194 {
195 if(!p) return;
196 if (p->flags & X509_TRUST_DYNAMIC)
197 {
198 if (p->flags & X509_TRUST_DYNAMIC_NAME)
199 Free(p->name);
200 Free(p);
201 }
202 }
203
204void X509_TRUST_cleanup(void)
205{
206 int i;
207 for(i = 0; i < X509_TRUST_COUNT; i++) trtable_free(trstandard + i);
208 sk_X509_TRUST_pop_free(trtable, trtable_free);
209 trtable = NULL;
210}
211
212int X509_TRUST_get_flags(X509_TRUST *xp)
213{
214 return xp->flags;
215}
216
217char *X509_TRUST_get0_name(X509_TRUST *xp)
218{
219 return xp->name;
220}
221
222int X509_TRUST_get_trust(X509_TRUST *xp)
223{
224 return xp->trust;
225}
226
227static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags)
228{
229 if(x->aux) return obj_trust(trust->arg1, x, flags);
230 /* we don't have any trust settings: for compatibility
231 * we return trusted if it is self signed
232 */
233 X509_check_purpose(x, -1, 0);
234 if(x->ex_flags & EXFLAG_SS) return X509_TRUST_TRUSTED;
235 else return X509_TRUST_UNTRUSTED;
236}
237
238static int obj_trust(int id, X509 *x, int flags)
239{
240 ASN1_OBJECT *obj;
241 int i;
242 X509_CERT_AUX *ax;
243 ax = x->aux;
244 if(!ax) return X509_TRUST_UNTRUSTED;
245 if(ax->reject) {
246 for(i = 0; i < sk_ASN1_OBJECT_num(ax->reject); i++) {
247 obj = sk_ASN1_OBJECT_value(ax->reject, i);
248 if(OBJ_obj2nid(obj) == id) return X509_TRUST_REJECTED;
249 }
250 }
251 if(ax->trust) {
252 for(i = 0; i < sk_ASN1_OBJECT_num(ax->trust); i++) {
253 obj = sk_ASN1_OBJECT_value(ax->trust, i);
254 if(OBJ_obj2nid(obj) == id) return X509_TRUST_TRUSTED;
255 }
256 }
257 return X509_TRUST_UNTRUSTED;
258}
259
260static int trust_any(X509_TRUST *trust, X509 *x, int flags)
261{
262 return X509_TRUST_TRUSTED;
263}
diff --git a/src/lib/libssl/src/crypto/x509/x509_txt.c b/src/lib/libssl/src/crypto/x509/x509_txt.c
index 11a3d2012f..209cf53191 100644
--- a/src/lib/libssl/src/crypto/x509/x509_txt.c
+++ b/src/lib/libssl/src/crypto/x509/x509_txt.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63 62
64#include "cryptlib.h" 63#include "cryptlib.h"
65#include <openssl/lhash.h> 64#include <openssl/lhash.h>
@@ -121,6 +120,16 @@ const char *X509_verify_cert_error_string(long n)
121 return("certificate chain too long"); 120 return("certificate chain too long");
122 case X509_V_ERR_CERT_REVOKED: 121 case X509_V_ERR_CERT_REVOKED:
123 return("certificate revoked"); 122 return("certificate revoked");
123 case X509_V_ERR_INVALID_CA:
124 return ("invalid CA certificate");
125 case X509_V_ERR_PATH_LENGTH_EXCEEDED:
126 return ("path length constraint exceeded");
127 case X509_V_ERR_INVALID_PURPOSE:
128 return ("unsupported certificate purpose");
129 case X509_V_ERR_CERT_UNTRUSTED:
130 return ("certificate not trusted");
131 case X509_V_ERR_CERT_REJECTED:
132 return ("certificate rejected");
124 case X509_V_ERR_APPLICATION_VERIFICATION: 133 case X509_V_ERR_APPLICATION_VERIFICATION:
125 return("application verification failure"); 134 return("application verification failure");
126 default: 135 default:
diff --git a/src/lib/libssl/src/crypto/x509/x509_v3.c b/src/lib/libssl/src/crypto/x509/x509_v3.c
index dd2f9f1b17..52887986fe 100644
--- a/src/lib/libssl/src/crypto/x509/x509_v3.c
+++ b/src/lib/libssl/src/crypto/x509/x509_v3.c
@@ -63,6 +63,7 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
66 67
67int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) 68int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x)
68 { 69 {
@@ -242,7 +243,7 @@ int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data)
242 int i; 243 int i;
243 244
244 if (ex == NULL) return(0); 245 if (ex == NULL) return(0);
245 i=ASN1_OCTET_STRING_set(ex->value,data->data,data->length); 246 i=M_ASN1_OCTET_STRING_set(ex->value,data->data,data->length);
246 if (!i) return(0); 247 if (!i) return(0);
247 return(1); 248 return(1);
248 } 249 }
diff --git a/src/lib/libssl/src/crypto/x509/x509_vfy.c b/src/lib/libssl/src/crypto/x509/x509_vfy.c
index c72ee4a385..4fdff54124 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.c
+++ b/src/lib/libssl/src/crypto/x509/x509_vfy.c
@@ -59,23 +59,24 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64 62
65#include <openssl/crypto.h>
66#include "cryptlib.h" 63#include "cryptlib.h"
64#include <openssl/crypto.h>
67#include <openssl/lhash.h> 65#include <openssl/lhash.h>
68#include <openssl/buffer.h> 66#include <openssl/buffer.h>
69#include <openssl/evp.h> 67#include <openssl/evp.h>
70#include <openssl/asn1.h> 68#include <openssl/asn1.h>
71#include <openssl/x509.h> 69#include <openssl/x509.h>
70#include <openssl/x509v3.h>
72#include <openssl/objects.h> 71#include <openssl/objects.h>
73 72
74static int null_callback(int ok,X509_STORE_CTX *e); 73static int null_callback(int ok,X509_STORE_CTX *e);
74static int check_chain_purpose(X509_STORE_CTX *ctx);
75static int check_trust(X509_STORE_CTX *ctx);
75static int internal_verify(X509_STORE_CTX *ctx); 76static int internal_verify(X509_STORE_CTX *ctx);
76const char *X509_version="X.509" OPENSSL_VERSION_PTEXT; 77const char *X509_version="X.509" OPENSSL_VERSION_PTEXT;
77 78
78static STACK *x509_store_ctx_method=NULL; 79static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_ctx_method=NULL;
79static int x509_store_ctx_num=0; 80static int x509_store_ctx_num=0;
80#if 0 81#if 0
81static int x509_store_num=1; 82static int x509_store_num=1;
@@ -127,7 +128,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
127 ctx->last_untrusted=1; 128 ctx->last_untrusted=1;
128 } 129 }
129 130
130 /* We use a temporary so we can chop and hack at it */ 131 /* We use a temporary STACK so we can chop and hack at it */
131 if (ctx->untrusted != NULL 132 if (ctx->untrusted != NULL
132 && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL) 133 && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL)
133 { 134 {
@@ -184,17 +185,37 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
184 185
185 i=sk_X509_num(ctx->chain); 186 i=sk_X509_num(ctx->chain);
186 x=sk_X509_value(ctx->chain,i-1); 187 x=sk_X509_value(ctx->chain,i-1);
187 if (X509_NAME_cmp(X509_get_subject_name(x),X509_get_issuer_name(x)) 188 xn = X509_get_subject_name(x);
189 if (X509_NAME_cmp(xn,X509_get_issuer_name(x))
188 == 0) 190 == 0)
189 { 191 {
190 /* we have a self signed certificate */ 192 /* we have a self signed certificate */
191 if (sk_X509_num(ctx->chain) == 1) 193 if (sk_X509_num(ctx->chain) == 1)
192 { 194 {
193 ctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT; 195 /* We have a single self signed certificate: see if
194 ctx->current_cert=x; 196 * we can find it in the store. We must have an exact
195 ctx->error_depth=i-1; 197 * match to avoid possible impersonation.
196 ok=cb(0,ctx); 198 */
197 if (!ok) goto end; 199 ok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj);
200 if ((ok != X509_LU_X509) || X509_cmp(x, obj.data.x509))
201 {
202 ctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;
203 ctx->current_cert=x;
204 ctx->error_depth=i-1;
205 if(ok == X509_LU_X509) X509_OBJECT_free_contents(&obj);
206 ok=cb(0,ctx);
207 if (!ok) goto end;
208 }
209 else
210 {
211 /* We have a match: replace certificate with store version
212 * so we get any trust settings.
213 */
214 X509_free(x);
215 x = obj.data.x509;
216 sk_X509_set(ctx->chain, i - 1, x);
217 ctx->last_untrusted=0;
218 }
198 } 219 }
199 else 220 else
200 { 221 {
@@ -272,6 +293,17 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
272 if (!ok) goto end; 293 if (!ok) goto end;
273 } 294 }
274 295
296 /* We have the chain complete: now we need to check its purpose */
297 if(ctx->purpose > 0) ok = check_chain_purpose(ctx);
298
299 if(!ok) goto end;
300
301 /* The chain extensions are OK: check trust */
302
303 if(ctx->trust > 0) ok = check_trust(ctx);
304
305 if(!ok) goto end;
306
275 /* We may as well copy down any DSA parameters that are required */ 307 /* We may as well copy down any DSA parameters that are required */
276 X509_get_pubkey_parameters(NULL,ctx->chain); 308 X509_get_pubkey_parameters(NULL,ctx->chain);
277 309
@@ -290,6 +322,71 @@ end:
290 return(ok); 322 return(ok);
291 } 323 }
292 324
325/* Check a certificate chains extensions for consistency
326 * with the supplied purpose
327 */
328
329static int check_chain_purpose(X509_STORE_CTX *ctx)
330{
331#ifdef NO_CHAIN_VERIFY
332 return 1;
333#else
334 int i, ok=0;
335 X509 *x;
336 int (*cb)();
337 cb=ctx->ctx->verify_cb;
338 if (cb == NULL) cb=null_callback;
339 /* Check all untrusted certificates */
340 for(i = 0; i < ctx->last_untrusted; i++) {
341 x = sk_X509_value(ctx->chain, i);
342 if(!X509_check_purpose(x, ctx->purpose, i)) {
343 if(i) ctx->error = X509_V_ERR_INVALID_CA;
344 else ctx->error = X509_V_ERR_INVALID_PURPOSE;
345 ctx->error_depth = i;
346 ctx->current_cert = x;
347 ok=cb(0,ctx);
348 if(!ok) goto end;
349 }
350 /* Check pathlen */
351 if((i > 1) && (x->ex_pathlen != -1)
352 && (i > (x->ex_pathlen + 1))) {
353 ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED;
354 ctx->error_depth = i;
355 ctx->current_cert = x;
356 ok=cb(0,ctx);
357 if(!ok) goto end;
358 }
359 }
360 ok = 1;
361 end:
362 return(ok);
363#endif
364}
365
366static int check_trust(X509_STORE_CTX *ctx)
367{
368#ifdef NO_CHAIN_VERIFY
369 return 1;
370#else
371 int i, ok;
372 X509 *x;
373 int (*cb)();
374 cb=ctx->ctx->verify_cb;
375 if (cb == NULL) cb=null_callback;
376/* For now just check the last certificate in the chain */
377 i = sk_X509_num(ctx->chain) - 1;
378 x = sk_X509_value(ctx->chain, i);
379 ok = X509_check_trust(x, ctx->trust, 0);
380 if(ok == X509_TRUST_TRUSTED) return 1;
381 ctx->error_depth = sk_X509_num(ctx->chain) - 1;
382 ctx->current_cert = x;
383 if(ok == X509_TRUST_REJECTED) ctx->error = X509_V_ERR_CERT_REJECTED;
384 else ctx->error = X509_V_ERR_CERT_UNTRUSTED;
385 ok = cb(0, ctx);
386 return(ok);
387#endif
388}
389
293static int internal_verify(X509_STORE_CTX *ctx) 390static int internal_verify(X509_STORE_CTX *ctx)
294 { 391 {
295 int i,ok=0,n; 392 int i,ok=0,n;
@@ -439,7 +536,7 @@ int X509_cmp_current_time(ASN1_UTCTIME *ctm)
439 atm.length=sizeof(buff2); 536 atm.length=sizeof(buff2);
440 atm.data=(unsigned char *)buff2; 537 atm.data=(unsigned char *)buff2;
441 538
442 X509_gmtime_adj(&atm,-offset); 539 X509_gmtime_adj(&atm,-offset*60);
443 540
444 i=(buff1[0]-'0')*10+(buff1[1]-'0'); 541 i=(buff1[0]-'0')*10+(buff1[1]-'0');
445 if (i < 50) i+=100; /* cf. RFC 2459 */ 542 if (i < 50) i+=100; /* cf. RFC 2459 */
@@ -525,13 +622,13 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
525 622
526 X509_OBJECT_up_ref_count(obj); 623 X509_OBJECT_up_ref_count(obj);
527 624
528 r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj); 625 r=(X509_OBJECT *)lh_insert(ctx->certs,obj);
529 if (r != NULL) 626 if (r != NULL)
530 { /* oops, put it back */ 627 { /* oops, put it back */
531 lh_delete(ctx->certs,(char *)obj); 628 lh_delete(ctx->certs,obj);
532 X509_OBJECT_free_contents(obj); 629 X509_OBJECT_free_contents(obj);
533 Free(obj); 630 Free(obj);
534 lh_insert(ctx->certs,(char *)r); 631 lh_insert(ctx->certs,r);
535 X509err(X509_F_X509_STORE_ADD_CERT,X509_R_CERT_ALREADY_IN_HASH_TABLE); 632 X509err(X509_F_X509_STORE_ADD_CERT,X509_R_CERT_ALREADY_IN_HASH_TABLE);
536 ret=0; 633 ret=0;
537 } 634 }
@@ -560,13 +657,13 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
560 657
561 X509_OBJECT_up_ref_count(obj); 658 X509_OBJECT_up_ref_count(obj);
562 659
563 r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj); 660 r=(X509_OBJECT *)lh_insert(ctx->certs,obj);
564 if (r != NULL) 661 if (r != NULL)
565 { /* oops, put it back */ 662 { /* oops, put it back */
566 lh_delete(ctx->certs,(char *)obj); 663 lh_delete(ctx->certs,obj);
567 X509_OBJECT_free_contents(obj); 664 X509_OBJECT_free_contents(obj);
568 Free(obj); 665 Free(obj);
569 lh_insert(ctx->certs,(char *)r); 666 lh_insert(ctx->certs,r);
570 X509err(X509_F_X509_STORE_ADD_CRL,X509_R_CERT_ALREADY_IN_HASH_TABLE); 667 X509err(X509_F_X509_STORE_ADD_CRL,X509_R_CERT_ALREADY_IN_HASH_TABLE);
571 ret=0; 668 ret=0;
572 } 669 }
@@ -576,8 +673,8 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
576 return(ret); 673 return(ret);
577 } 674 }
578 675
579int X509_STORE_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), 676int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
580 int (*dup_func)(), void (*free_func)()) 677 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
581 { 678 {
582 x509_store_ctx_num++; 679 x509_store_ctx_num++;
583 return(CRYPTO_get_ex_new_index(x509_store_ctx_num-1, 680 return(CRYPTO_get_ex_new_index(x509_store_ctx_num-1,
@@ -620,6 +717,19 @@ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
620 return(ctx->chain); 717 return(ctx->chain);
621 } 718 }
622 719
720STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
721 {
722 int i;
723 X509 *x;
724 STACK_OF(X509) *chain;
725 if(!ctx->chain || !(chain = sk_X509_dup(ctx->chain))) return NULL;
726 for(i = 0; i < sk_X509_num(chain); i++) {
727 x = sk_X509_value(chain, i);
728 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
729 }
730 return(chain);
731 }
732
623void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x) 733void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
624 { 734 {
625 ctx->cert=x; 735 ctx->cert=x;
@@ -630,6 +740,62 @@ void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
630 ctx->untrusted=sk; 740 ctx->untrusted=sk;
631 } 741 }
632 742
743int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose)
744 {
745 return X509_STORE_CTX_purpose_inherit(ctx, 0, purpose, 0);
746 }
747
748int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust)
749 {
750 return X509_STORE_CTX_purpose_inherit(ctx, 0, 0, trust);
751 }
752
753/* This function is used to set the X509_STORE_CTX purpose and trust
754 * values. This is intended to be used when another structure has its
755 * own trust and purpose values which (if set) will be inherited by
756 * the ctx. If they aren't set then we will usually have a default
757 * purpose in mind which should then be used to set the trust value.
758 * An example of this is SSL use: an SSL structure will have its own
759 * purpose and trust settings which the application can set: if they
760 * aren't set then we use the default of SSL client/server.
761 */
762
763int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
764 int purpose, int trust)
765{
766 int idx;
767 /* If purpose not set use default */
768 if(!purpose) purpose = def_purpose;
769 /* If we have a purpose then check it is valid */
770 if(purpose) {
771 idx = X509_PURPOSE_get_by_id(purpose);
772 if(idx == -1) {
773 X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
774 X509_R_UNKNOWN_PURPOSE_ID);
775 return 0;
776 }
777 /* If trust not set then get from purpose default */
778 if(!trust) {
779 X509_PURPOSE *ptmp;
780 ptmp = X509_PURPOSE_get0(idx);
781 trust = ptmp->trust;
782 }
783 }
784 if(trust) {
785 idx = X509_TRUST_get_by_id(trust);
786 if(idx == -1) {
787 X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
788 X509_R_UNKNOWN_TRUST_ID);
789 return 0;
790 }
791 }
792
793 if(purpose) ctx->purpose = purpose;
794 if(trust) ctx->trust = trust;
795 return 1;
796}
797
798
633IMPLEMENT_STACK_OF(X509) 799IMPLEMENT_STACK_OF(X509)
634IMPLEMENT_ASN1_SET_OF(X509) 800IMPLEMENT_ASN1_SET_OF(X509)
635 801
diff --git a/src/lib/libssl/src/crypto/x509/x509_vfy.h b/src/lib/libssl/src/crypto/x509/x509_vfy.h
index ecfd4cf9ed..4637aecedf 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.h
+++ b/src/lib/libssl/src/crypto/x509/x509_vfy.h
@@ -202,6 +202,8 @@ struct x509_store_state_st /* X509_STORE_CTX */
202 /* The following are set by the caller */ 202 /* The following are set by the caller */
203 X509 *cert; /* The cert to check */ 203 X509 *cert; /* The cert to check */
204 STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ 204 STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */
205 int purpose; /* purpose to check untrusted certificates */
206 int trust; /* trust setting to check */
205 207
206 /* The following is built up */ 208 /* The following is built up */
207 int depth; /* how far to go looking up certs */ 209 int depth; /* how far to go looking up certs */
@@ -234,6 +236,7 @@ struct x509_store_state_st /* X509_STORE_CTX */
234 X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) 236 X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)
235 237
236#define X509_V_OK 0 238#define X509_V_OK 0
239/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */
237 240
238#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 241#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2
239#define X509_V_ERR_UNABLE_TO_GET_CRL 3 242#define X509_V_ERR_UNABLE_TO_GET_CRL 3
@@ -257,6 +260,11 @@ struct x509_store_state_st /* X509_STORE_CTX */
257#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 260#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21
258#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 261#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22
259#define X509_V_ERR_CERT_REVOKED 23 262#define X509_V_ERR_CERT_REVOKED 23
263#define X509_V_ERR_INVALID_CA 24
264#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25
265#define X509_V_ERR_INVALID_PURPOSE 26
266#define X509_V_ERR_CERT_UNTRUSTED 27
267#define X509_V_ERR_CERT_REJECTED 28
260 268
261/* The application is not happy */ 269/* The application is not happy */
262#define X509_V_ERR_APPLICATION_VERIFICATION 50 270#define X509_V_ERR_APPLICATION_VERIFICATION 50
@@ -284,6 +292,8 @@ void X509_OBJECT_free_contents(X509_OBJECT *a);
284X509_STORE *X509_STORE_new(void ); 292X509_STORE *X509_STORE_new(void );
285void X509_STORE_free(X509_STORE *v); 293void X509_STORE_free(X509_STORE *v);
286 294
295X509_STORE_CTX *X509_STORE_CTX_new(void);
296void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
287void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, 297void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
288 X509 *x509, STACK_OF(X509) *chain); 298 X509 *x509, STACK_OF(X509) *chain);
289void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); 299void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
@@ -305,6 +315,7 @@ int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
305#ifndef NO_STDIO 315#ifndef NO_STDIO
306int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); 316int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
307int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); 317int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
318int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
308#endif 319#endif
309 320
310 321
@@ -327,8 +338,8 @@ int X509_STORE_load_locations (X509_STORE *ctx,
327int X509_STORE_set_default_paths(X509_STORE *ctx); 338int X509_STORE_set_default_paths(X509_STORE *ctx);
328#endif 339#endif
329 340
330int X509_STORE_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), 341int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
331 int (*dup_func)(), void (*free_func)()); 342 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
332int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); 343int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
333void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); 344void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
334int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); 345int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
@@ -336,8 +347,13 @@ void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
336int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); 347int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
337X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); 348X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
338STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); 349STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
350STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
339void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); 351void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
340void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); 352void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk);
353int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
354int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
355int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
356 int purpose, int trust);
341 357
342#ifdef __cplusplus 358#ifdef __cplusplus
343} 359}
diff --git a/src/lib/libssl/src/crypto/x509/x509name.c b/src/lib/libssl/src/crypto/x509/x509name.c
index 2a422be350..cf2382d42c 100644
--- a/src/lib/libssl/src/crypto/x509/x509name.c
+++ b/src/lib/libssl/src/crypto/x509/x509name.c
@@ -171,6 +171,42 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)
171 return(ret); 171 return(ret);
172 } 172 }
173 173
174int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
175 unsigned char *bytes, int len, int loc, int set)
176{
177 X509_NAME_ENTRY *ne;
178 int ret;
179 ne = X509_NAME_ENTRY_create_by_OBJ(NULL, obj, type, bytes, len);
180 if(!ne) return 0;
181 ret = X509_NAME_add_entry(name, ne, loc, set);
182 X509_NAME_ENTRY_free(ne);
183 return ret;
184}
185
186int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
187 unsigned char *bytes, int len, int loc, int set)
188{
189 X509_NAME_ENTRY *ne;
190 int ret;
191 ne = X509_NAME_ENTRY_create_by_NID(NULL, nid, type, bytes, len);
192 if(!ne) return 0;
193 ret = X509_NAME_add_entry(name, ne, loc, set);
194 X509_NAME_ENTRY_free(ne);
195 return ret;
196}
197
198int X509_NAME_add_entry_by_txt(X509_NAME *name, char *field, int type,
199 unsigned char *bytes, int len, int loc, int set)
200{
201 X509_NAME_ENTRY *ne;
202 int ret;
203 ne = X509_NAME_ENTRY_create_by_txt(NULL, field, type, bytes, len);
204 if(!ne) return 0;
205 ret = X509_NAME_add_entry(name, ne, loc, set);
206 X509_NAME_ENTRY_free(ne);
207 return ret;
208}
209
174/* if set is -1, append to previous set, 0 'a new one', and 1, 210/* if set is -1, append to previous set, 0 'a new one', and 1,
175 * prepend to the guy we are about to stomp on. */ 211 * prepend to the guy we are about to stomp on. */
176int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, 212int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc,
@@ -236,10 +272,30 @@ err:
236 return(0); 272 return(0);
237 } 273 }
238 274
275X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
276 char *field, int type, unsigned char *bytes, int len)
277 {
278 ASN1_OBJECT *obj;
279 X509_NAME_ENTRY *nentry;
280
281 obj=OBJ_txt2obj(field, 0);
282 if (obj == NULL)
283 {
284 X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_TXT,
285 X509_R_INVALID_FIELD_NAME);
286 ERR_add_error_data(2, "name=", field);
287 return(NULL);
288 }
289 nentry = X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len);
290 ASN1_OBJECT_free(obj);
291 return nentry;
292 }
293
239X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, 294X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
240 int type, unsigned char *bytes, int len) 295 int type, unsigned char *bytes, int len)
241 { 296 {
242 ASN1_OBJECT *obj; 297 ASN1_OBJECT *obj;
298 X509_NAME_ENTRY *nentry;
243 299
244 obj=OBJ_nid2obj(nid); 300 obj=OBJ_nid2obj(nid);
245 if (obj == NULL) 301 if (obj == NULL)
@@ -247,7 +303,9 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
247 X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID,X509_R_UNKNOWN_NID); 303 X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID,X509_R_UNKNOWN_NID);
248 return(NULL); 304 return(NULL);
249 } 305 }
250 return(X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len)); 306 nentry = X509_NAME_ENTRY_create_by_OBJ(ne,obj,type,bytes,len);
307 ASN1_OBJECT_free(obj);
308 return nentry;
251 } 309 }
252 310
253X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, 311X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
@@ -267,7 +325,7 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
267 goto err; 325 goto err;
268 if (!X509_NAME_ENTRY_set_data(ret,type,bytes,len)) 326 if (!X509_NAME_ENTRY_set_data(ret,type,bytes,len))
269 goto err; 327 goto err;
270 328
271 if ((ne != NULL) && (*ne == NULL)) *ne=ret; 329 if ((ne != NULL) && (*ne == NULL)) *ne=ret;
272 return(ret); 330 return(ret);
273err: 331err:
@@ -294,6 +352,10 @@ int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
294 int i; 352 int i;
295 353
296 if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return(0); 354 if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return(0);
355 if(type & MBSTRING_FLAG)
356 return ASN1_STRING_set_by_NID(&ne->value, bytes,
357 len, type,
358 OBJ_obj2nid(ne->object)) ? 1 : 0;
297 if (len < 0) len=strlen((char *)bytes); 359 if (len < 0) len=strlen((char *)bytes);
298 i=ASN1_STRING_set(ne->value,bytes,len); 360 i=ASN1_STRING_set(ne->value,bytes,len);
299 if (!i) return(0); 361 if (!i) return(0);
diff --git a/src/lib/libssl/src/crypto/x509/x509spki.c b/src/lib/libssl/src/crypto/x509/x509spki.c
new file mode 100644
index 0000000000..b35c3f92e7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509spki.c
@@ -0,0 +1,121 @@
1/* x509spki.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/x509.h>
62#include <openssl/asn1_mac.h>
63
64int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey)
65{
66 if ((x == NULL) || (x->spkac == NULL)) return(0);
67 return(X509_PUBKEY_set(&(x->spkac->pubkey),pkey));
68}
69
70EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x)
71{
72 if ((x == NULL) || (x->spkac == NULL))
73 return(NULL);
74 return(X509_PUBKEY_get(x->spkac->pubkey));
75}
76
77/* Load a Netscape SPKI from a base64 encoded string */
78
79NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len)
80{
81 unsigned char *spki_der, *p;
82 int spki_len;
83 NETSCAPE_SPKI *spki;
84 if(len <= 0) len = strlen(str);
85 if (!(spki_der = Malloc(len + 1))) {
86 X509err(X509_F_NETSCAPE_SPKI_B64_DECODE, ERR_R_MALLOC_FAILURE);
87 return NULL;
88 }
89 spki_len = EVP_DecodeBlock(spki_der, (const unsigned char *)str, len);
90 if(spki_len < 0) {
91 X509err(X509_F_NETSCAPE_SPKI_B64_DECODE,
92 X509_R_BASE64_DECODE_ERROR);
93 Free(spki_der);
94 return NULL;
95 }
96 p = spki_der;
97 spki = d2i_NETSCAPE_SPKI(NULL, &p, spki_len);
98 Free(spki_der);
99 return spki;
100}
101
102/* Generate a base64 encoded string from an SPKI */
103
104char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki)
105{
106 unsigned char *der_spki, *p;
107 char *b64_str;
108 int der_len;
109 der_len = i2d_NETSCAPE_SPKI(spki, NULL);
110 der_spki = Malloc(der_len);
111 b64_str = Malloc(der_len * 2);
112 if(!der_spki || !b64_str) {
113 X509err(X509_F_NETSCAPE_SPKI_B64_ENCODE, ERR_R_MALLOC_FAILURE);
114 return NULL;
115 }
116 p = der_spki;
117 i2d_NETSCAPE_SPKI(spki, &p);
118 EVP_EncodeBlock((unsigned char *)b64_str, der_spki, der_len);
119 Free(der_spki);
120 return b64_str;
121}
diff --git a/src/lib/libssl/src/crypto/x509/x_all.c b/src/lib/libssl/src/crypto/x509/x_all.c
index f2af895df0..d2bf3c8e1c 100644
--- a/src/lib/libssl/src/crypto/x509/x_all.c
+++ b/src/lib/libssl/src/crypto/x509/x_all.c
@@ -285,10 +285,22 @@ RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa)
285 (unsigned char **)(rsa))); 285 (unsigned char **)(rsa)));
286 } 286 }
287 287
288RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
289 {
290 return((RSA *)ASN1_d2i_fp((char *(*)())
291 RSA_new,(char *(*)())d2i_RSA_PUBKEY, (fp),
292 (unsigned char **)(rsa)));
293 }
294
288int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa) 295int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa)
289 { 296 {
290 return(ASN1_i2d_fp(i2d_RSAPublicKey,fp,(unsigned char *)rsa)); 297 return(ASN1_i2d_fp(i2d_RSAPublicKey,fp,(unsigned char *)rsa));
291 } 298 }
299
300int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
301 {
302 return(ASN1_i2d_fp(i2d_RSA_PUBKEY,fp,(unsigned char *)rsa));
303 }
292#endif 304#endif
293 305
294RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa) 306RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
@@ -310,10 +322,22 @@ RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa)
310 (unsigned char **)(rsa))); 322 (unsigned char **)(rsa)));
311 } 323 }
312 324
325RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
326 {
327 return((RSA *)ASN1_d2i_bio((char *(*)())
328 RSA_new,(char *(*)())d2i_RSA_PUBKEY, (bp),
329 (unsigned char **)(rsa)));
330 }
331
313int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa) 332int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa)
314 { 333 {
315 return(ASN1_i2d_bio(i2d_RSAPublicKey,bp,(unsigned char *)rsa)); 334 return(ASN1_i2d_bio(i2d_RSAPublicKey,bp,(unsigned char *)rsa));
316 } 335 }
336
337int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
338 {
339 return(ASN1_i2d_bio(i2d_RSA_PUBKEY,bp,(unsigned char *)rsa));
340 }
317#endif 341#endif
318 342
319#ifndef NO_DSA 343#ifndef NO_DSA
@@ -329,6 +353,18 @@ int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa)
329 { 353 {
330 return(ASN1_i2d_fp(i2d_DSAPrivateKey,fp,(unsigned char *)dsa)); 354 return(ASN1_i2d_fp(i2d_DSAPrivateKey,fp,(unsigned char *)dsa));
331 } 355 }
356
357DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa)
358 {
359 return((DSA *)ASN1_d2i_fp((char *(*)())
360 DSA_new,(char *(*)())d2i_DSA_PUBKEY, (fp),
361 (unsigned char **)(dsa)));
362 }
363
364int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa)
365 {
366 return(ASN1_i2d_fp(i2d_DSA_PUBKEY,fp,(unsigned char *)dsa));
367 }
332#endif 368#endif
333 369
334DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa) 370DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa)
@@ -342,6 +378,19 @@ int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa)
342 { 378 {
343 return(ASN1_i2d_bio(i2d_DSAPrivateKey,bp,(unsigned char *)dsa)); 379 return(ASN1_i2d_bio(i2d_DSAPrivateKey,bp,(unsigned char *)dsa));
344 } 380 }
381
382DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa)
383 {
384 return((DSA *)ASN1_d2i_bio((char *(*)())
385 DSA_new,(char *(*)())d2i_DSA_PUBKEY, (bp),
386 (unsigned char **)(dsa)));
387 }
388
389int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
390 {
391 return(ASN1_i2d_bio(i2d_DSA_PUBKEY,bp,(unsigned char *)dsa));
392 }
393
345#endif 394#endif
346 395
347X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn) 396X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn)
@@ -362,19 +411,19 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne)
362 (char *(*)())d2i_X509_NAME_ENTRY,(char *)ne)); 411 (char *(*)())d2i_X509_NAME_ENTRY,(char *)ne));
363 } 412 }
364 413
365int X509_digest(X509 *data, EVP_MD *type, unsigned char *md, 414int X509_digest(X509 *data, const EVP_MD *type, unsigned char *md,
366 unsigned int *len) 415 unsigned int *len)
367 { 416 {
368 return(ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)); 417 return(ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len));
369 } 418 }
370 419
371int X509_NAME_digest(X509_NAME *data, EVP_MD *type, unsigned char *md, 420int X509_NAME_digest(X509_NAME *data, const EVP_MD *type, unsigned char *md,
372 unsigned int *len) 421 unsigned int *len)
373 { 422 {
374 return(ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)); 423 return(ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len));
375 } 424 }
376 425
377int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, EVP_MD *type, 426int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type,
378 unsigned char *md, unsigned int *len) 427 unsigned char *md, unsigned int *len)
379 { 428 {
380 return(ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type, 429 return(ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,
@@ -420,6 +469,29 @@ int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf)
420 { 469 {
421 return(ASN1_i2d_fp(i2d_PKCS8_PRIV_KEY_INFO,fp,(unsigned char *)p8inf)); 470 return(ASN1_i2d_fp(i2d_PKCS8_PRIV_KEY_INFO,fp,(unsigned char *)p8inf));
422 } 471 }
472
473int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
474 {
475 PKCS8_PRIV_KEY_INFO *p8inf;
476 int ret;
477 p8inf = EVP_PKEY2PKCS8(key);
478 if(!p8inf) return 0;
479 ret = i2d_PKCS8_PRIV_KEY_INFO_fp(fp, p8inf);
480 PKCS8_PRIV_KEY_INFO_free(p8inf);
481 return ret;
482 }
483
484int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey)
485 {
486 return(ASN1_i2d_fp(i2d_PrivateKey,fp,(unsigned char *)pkey));
487 }
488
489EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a)
490{
491 return((EVP_PKEY *)ASN1_d2i_fp((char *(*)())EVP_PKEY_new,
492 (char *(*)())d2i_AutoPrivateKey, (fp),(unsigned char **)(a)));
493}
494
423#endif 495#endif
424 496
425PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, 497PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
@@ -435,3 +507,25 @@ int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf)
435 { 507 {
436 return(ASN1_i2d_bio(i2d_PKCS8_PRIV_KEY_INFO,bp,(unsigned char *)p8inf)); 508 return(ASN1_i2d_bio(i2d_PKCS8_PRIV_KEY_INFO,bp,(unsigned char *)p8inf));
437 } 509 }
510
511int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
512 {
513 PKCS8_PRIV_KEY_INFO *p8inf;
514 int ret;
515 p8inf = EVP_PKEY2PKCS8(key);
516 if(!p8inf) return 0;
517 ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
518 PKCS8_PRIV_KEY_INFO_free(p8inf);
519 return ret;
520 }
521
522int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey)
523 {
524 return(ASN1_i2d_bio(i2d_PrivateKey,bp,(unsigned char *)pkey));
525 }
526
527EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a)
528 {
529 return((EVP_PKEY *)ASN1_d2i_bio((char *(*)())EVP_PKEY_new,
530 (char *(*)())d2i_AutoPrivateKey, (bp),(unsigned char **)(a)));
531 }
diff --git a/src/lib/libssl/src/crypto/x509v3/Makefile.ssl b/src/lib/libssl/src/crypto/x509v3/Makefile.ssl
index 72871edbc1..1bb746d52d 100644
--- a/src/lib/libssl/src/crypto/x509v3/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/x509v3/Makefile.ssl
@@ -24,10 +24,10 @@ APPS=
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c \ 25LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c \
26v3_lib.c v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.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_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.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
28LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \ 28LIBOBJ= 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 \ 29v3_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 30v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o
31 31
32SRC= $(LIBSRC) 32SRC= $(LIBSRC)
33 33
@@ -285,6 +285,25 @@ v3_ia5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
285v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 285v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
286v3_ia5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 286v3_ia5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
287v3_ia5.o: ../../include/openssl/x509v3.h ../cryptlib.h 287v3_ia5.o: ../../include/openssl/x509v3.h ../cryptlib.h
288v3_info.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
289v3_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
290v3_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
291v3_info.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
292v3_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
293v3_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
294v3_info.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
295v3_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h
296v3_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
297v3_info.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
298v3_info.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
299v3_info.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
300v3_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
301v3_info.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
302v3_info.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
303v3_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
304v3_info.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
305v3_info.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
306v3_info.o: ../cryptlib.h
288v3_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 307v3_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
289v3_int.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 308v3_int.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
290v3_int.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 309v3_int.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -320,7 +339,7 @@ v3_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
320v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 339v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
321v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 340v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
322v3_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 341v3_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
323v3_lib.o: ../../include/openssl/x509v3.h ../cryptlib.h 342v3_lib.o: ../../include/openssl/x509v3.h ../cryptlib.h ext_dat.h
324v3_pku.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 343v3_pku.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
325v3_pku.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 344v3_pku.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
326v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 345v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -358,6 +377,24 @@ v3_prn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
358v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 377v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
359v3_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 378v3_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
360v3_prn.o: ../../include/openssl/x509v3.h ../cryptlib.h 379v3_prn.o: ../../include/openssl/x509v3.h ../cryptlib.h
380v3_purp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
381v3_purp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
382v3_purp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
383v3_purp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
384v3_purp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
385v3_purp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
386v3_purp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
387v3_purp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
388v3_purp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
389v3_purp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
390v3_purp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
391v3_purp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
392v3_purp.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
393v3_purp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
394v3_purp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
395v3_purp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
396v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
397v3_purp.o: ../../include/openssl/x509v3.h ../cryptlib.h
361v3_skey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 398v3_skey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
362v3_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 399v3_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
363v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 400v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
diff --git a/src/lib/libssl/src/crypto/x509v3/README b/src/lib/libssl/src/crypto/x509v3/README
index 3b2cc047be..e69de29bb2 100644
--- a/src/lib/libssl/src/crypto/x509v3/README
+++ b/src/lib/libssl/src/crypto/x509v3/README
@@ -1,4 +0,0 @@
1WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
2
3This is ***VERY*** new experimental code and is likely to change
4considerably or vanish altogether.
diff --git a/src/lib/libssl/src/crypto/x509v3/ext_dat.h b/src/lib/libssl/src/crypto/x509v3/ext_dat.h
new file mode 100644
index 0000000000..801a585a52
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/ext_dat.h
@@ -0,0 +1,97 @@
1/* ext_dat.h */
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/* This file contains a table of "standard" extensions */
59
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;
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;
64
65/* This table will be searched using OBJ_bsearch so it *must* kept in
66 * order of the ext_nid values.
67 */
68
69static X509V3_EXT_METHOD *standard_exts[] = {
70&v3_nscert,
71&v3_ns_ia5_list[0],
72&v3_ns_ia5_list[1],
73&v3_ns_ia5_list[2],
74&v3_ns_ia5_list[3],
75&v3_ns_ia5_list[4],
76&v3_ns_ia5_list[5],
77&v3_ns_ia5_list[6],
78&v3_skey_id,
79&v3_key_usage,
80&v3_pkey_usage_period,
81&v3_alt[0],
82&v3_alt[1],
83&v3_bcons,
84&v3_crl_num,
85&v3_cpols,
86&v3_akey_id,
87&v3_crld,
88&v3_ext_ku,
89&v3_crl_reason,
90&v3_sxnet,
91&v3_info,
92};
93
94/* Number of standard extensions */
95
96#define STANDARD_EXTENSION_COUNT (sizeof(standard_exts)/sizeof(X509V3_EXT_METHOD *))
97
diff --git a/src/lib/libssl/src/crypto/x509v3/tabtest.c b/src/lib/libssl/src/crypto/x509v3/tabtest.c
new file mode 100644
index 0000000000..dad0d38dd5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/tabtest.c
@@ -0,0 +1,88 @@
1/* tabtest.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59/* Simple program to check the ext_dat.h is correct and print out
60 * problems if it is not.
61 */
62
63#include <stdio.h>
64
65#include <openssl/x509v3.h>
66
67#include "ext_dat.h"
68
69main()
70{
71 int i, prev = -1, bad = 0;
72 X509V3_EXT_METHOD **tmp;
73 i = sizeof(standard_exts) / sizeof(X509V3_EXT_METHOD *);
74 if(i != STANDARD_EXTENSION_COUNT)
75 fprintf(stderr, "Extension number invalid expecting %d\n", i);
76 tmp = standard_exts;
77 for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) {
78 if((*tmp)->ext_nid < prev) bad = 1;
79 prev = (*tmp)->ext_nid;
80
81 }
82 if(bad) {
83 tmp = standard_exts;
84 fprintf(stderr, "Extensions out of order!\n");
85 for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
86 printf("%d : %s\n", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid));
87 } else fprintf(stderr, "Order OK\n");
88}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_akey.c b/src/lib/libssl/src/crypto/x509v3/v3_akey.c
index 4099e6019e..96c04fe4f5 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_akey.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_akey.c
@@ -129,10 +129,10 @@ AUTHORITY_KEYID *d2i_AUTHORITY_KEYID(AUTHORITY_KEYID **a, unsigned char **pp,
129void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a) 129void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a)
130{ 130{
131 if (a == NULL) return; 131 if (a == NULL) return;
132 ASN1_OCTET_STRING_free(a->keyid); 132 M_ASN1_OCTET_STRING_free(a->keyid);
133 sk_GENERAL_NAME_pop_free(a->issuer, GENERAL_NAME_free); 133 sk_GENERAL_NAME_pop_free(a->issuer, GENERAL_NAME_free);
134 ASN1_INTEGER_free (a->serial); 134 M_ASN1_INTEGER_free (a->serial);
135 Free ((char *)a); 135 Free (a);
136} 136}
137 137
138static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, 138static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
@@ -214,7 +214,7 @@ if(keyid) {
214 214
215if((issuer && !ikeyid) || (issuer == 2)) { 215if((issuer && !ikeyid) || (issuer == 2)) {
216 isname = X509_NAME_dup(X509_get_issuer_name(cert)); 216 isname = X509_NAME_dup(X509_get_issuer_name(cert));
217 serial = ASN1_INTEGER_dup(X509_get_serialNumber(cert)); 217 serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(cert));
218 if(!isname || !serial) { 218 if(!isname || !serial) {
219 X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS); 219 X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS);
220 goto err; 220 goto err;
@@ -241,8 +241,8 @@ return akeyid;
241 241
242err: 242err:
243X509_NAME_free(isname); 243X509_NAME_free(isname);
244ASN1_INTEGER_free(serial); 244M_ASN1_INTEGER_free(serial);
245ASN1_OCTET_STRING_free(ikeyid); 245M_ASN1_OCTET_STRING_free(ikeyid);
246return NULL; 246return NULL;
247 247
248} 248}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_alt.c b/src/lib/libssl/src/crypto/x509v3/v3_alt.c
index b5e1f8af96..5ccd1e0e3d 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_alt.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_alt.c
@@ -84,7 +84,6 @@ NULL, NULL,
84(X509V3_EXT_I2V)i2v_GENERAL_NAMES, 84(X509V3_EXT_I2V)i2v_GENERAL_NAMES,
85(X509V3_EXT_V2I)v2i_issuer_alt, 85(X509V3_EXT_V2I)v2i_issuer_alt,
86NULL, NULL, NULL}, 86NULL, NULL, NULL},
87EXT_END
88}; 87};
89 88
90STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 89STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
@@ -273,7 +272,7 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
273 while((i = X509_NAME_get_index_by_NID(nm, 272 while((i = X509_NAME_get_index_by_NID(nm,
274 NID_pkcs9_emailAddress, i)) > 0) { 273 NID_pkcs9_emailAddress, i)) > 0) {
275 ne = X509_NAME_get_entry(nm, i); 274 ne = X509_NAME_get_entry(nm, i);
276 email = ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne)); 275 email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne));
277 if(!email || !(gen = GENERAL_NAME_new())) { 276 if(!email || !(gen = GENERAL_NAME_new())) {
278 X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE); 277 X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE);
279 goto err; 278 goto err;
@@ -293,7 +292,7 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
293 292
294 err: 293 err:
295 GENERAL_NAME_free(gen); 294 GENERAL_NAME_free(gen);
296 ASN1_IA5STRING_free(email); 295 M_ASN1_IA5STRING_free(email);
297 return 0; 296 return 0;
298 297
299} 298}
@@ -371,7 +370,7 @@ if(!name_cmp(name, "email")) {
371 goto err; 370 goto err;
372 } 371 }
373 ip[0] = i1; ip[1] = i2 ; ip[2] = i3 ; ip[3] = i4; 372 ip[0] = i1; ip[1] = i2 ; ip[2] = i3 ; ip[3] = i4;
374 if(!(gen->d.ip = ASN1_OCTET_STRING_new()) || 373 if(!(gen->d.ip = M_ASN1_OCTET_STRING_new()) ||
375 !ASN1_STRING_set(gen->d.ip, ip, 4)) { 374 !ASN1_STRING_set(gen->d.ip, ip, 4)) {
376 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); 375 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE);
377 goto err; 376 goto err;
@@ -384,7 +383,7 @@ if(!name_cmp(name, "email")) {
384} 383}
385 384
386if(is_string) { 385if(is_string) {
387 if(!(gen->d.ia5 = ASN1_IA5STRING_new()) || 386 if(!(gen->d.ia5 = M_ASN1_IA5STRING_new()) ||
388 !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, 387 !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value,
389 strlen(value))) { 388 strlen(value))) {
390 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); 389 X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_bcons.c b/src/lib/libssl/src/crypto/x509v3/v3_bcons.c
index de2f855c35..1e3edc205f 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_bcons.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_bcons.c
@@ -122,8 +122,8 @@ BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a,
122void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a) 122void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a)
123{ 123{
124 if (a == NULL) return; 124 if (a == NULL) return;
125 ASN1_INTEGER_free (a->pathlen); 125 M_ASN1_INTEGER_free (a->pathlen);
126 Free ((char *)a); 126 Free (a);
127} 127}
128 128
129static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 129static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_bitst.c b/src/lib/libssl/src/crypto/x509v3/v3_bitst.c
index 9828ba15b3..0e1167d05c 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_bitst.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_bitst.c
@@ -61,7 +61,6 @@
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
63 63
64static ASN1_BIT_STRING *asn1_bit_string_new(void);
65static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 64static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
66 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 65 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
67static 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,
@@ -97,11 +96,6 @@ static BIT_STRING_BITNAME key_usage_type_table[] = {
97X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table); 96X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table);
98X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table); 97X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table);
99 98
100static ASN1_BIT_STRING *asn1_bit_string_new(void)
101{
102 return ASN1_BIT_STRING_new();
103}
104
105static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 99static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
106 ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret) 100 ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret)
107{ 101{
@@ -120,7 +114,7 @@ static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
120 ASN1_BIT_STRING *bs; 114 ASN1_BIT_STRING *bs;
121 int i; 115 int i;
122 BIT_STRING_BITNAME *bnam; 116 BIT_STRING_BITNAME *bnam;
123 if(!(bs = ASN1_BIT_STRING_new())) { 117 if(!(bs = M_ASN1_BIT_STRING_new())) {
124 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,ERR_R_MALLOC_FAILURE); 118 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,ERR_R_MALLOC_FAILURE);
125 return NULL; 119 return NULL;
126 } 120 }
@@ -137,7 +131,7 @@ static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
137 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, 131 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,
138 X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); 132 X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT);
139 X509V3_conf_err(val); 133 X509V3_conf_err(val);
140 ASN1_BIT_STRING_free(bs); 134 M_ASN1_BIT_STRING_free(bs);
141 return NULL; 135 return NULL;
142 } 136 }
143 } 137 }
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_conf.c b/src/lib/libssl/src/crypto/x509v3/v3_conf.c
index f19bb3ad84..b2f03010cc 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_conf.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_conf.c
@@ -170,13 +170,13 @@ static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
170 if(!(ext_der = Malloc(ext_len))) goto merr; 170 if(!(ext_der = Malloc(ext_len))) goto merr;
171 p = ext_der; 171 p = ext_der;
172 method->i2d(ext_struc, &p); 172 method->i2d(ext_struc, &p);
173 if(!(ext_oct = ASN1_OCTET_STRING_new())) goto merr; 173 if(!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr;
174 ext_oct->data = ext_der; 174 ext_oct->data = ext_der;
175 ext_oct->length = ext_len; 175 ext_oct->length = ext_len;
176 176
177 ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct); 177 ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct);
178 if(!ext) goto merr; 178 if(!ext) goto merr;
179 ASN1_OCTET_STRING_free(ext_oct); 179 M_ASN1_OCTET_STRING_free(ext_oct);
180 180
181 return ext; 181 return ext;
182 182
@@ -220,7 +220,7 @@ static int v3_check_generic(char **value)
220 return 1; 220 return 1;
221} 221}
222 222
223/* Create a generic extension: for now just handle RAW type */ 223/* Create a generic extension: for now just handle DER type */
224static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, 224static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
225 int crit, int type) 225 int crit, int type)
226{ 226{
@@ -241,7 +241,7 @@ if(!(ext_der = string_to_hex(value, &ext_len))) {
241 goto err; 241 goto err;
242} 242}
243 243
244if(!(oct = ASN1_OCTET_STRING_new())) { 244if(!(oct = M_ASN1_OCTET_STRING_new())) {
245 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE); 245 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE);
246 goto err; 246 goto err;
247} 247}
@@ -254,7 +254,7 @@ extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct);
254 254
255err: 255err:
256ASN1_OBJECT_free(obj); 256ASN1_OBJECT_free(obj);
257ASN1_OCTET_STRING_free(oct); 257M_ASN1_OCTET_STRING_free(oct);
258if(ext_der) Free(ext_der); 258if(ext_der) Free(ext_der);
259return extension; 259return extension;
260} 260}
@@ -302,6 +302,30 @@ int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
302 return 1; 302 return 1;
303} 303}
304 304
305/* Add extensions to certificate request */
306
307int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
308 X509_REQ *req)
309{
310 X509_EXTENSION *ext;
311 STACK_OF(X509_EXTENSION) *extlist = NULL;
312 STACK_OF(CONF_VALUE) *nval;
313 CONF_VALUE *val;
314 int i;
315 if(!(nval = CONF_get_section(conf, section))) return 0;
316 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
317 val = sk_CONF_VALUE_value(nval, i);
318 if(!(ext = X509V3_EXT_conf(conf, ctx, val->name, val->value)))
319 return 0;
320 if(!extlist) extlist = sk_X509_EXTENSION_new_null();
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);
326 return i;
327}
328
305/* Config database functions */ 329/* Config database functions */
306 330
307char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section) 331char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section)
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_cpols.c b/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
index b4d4883545..466713b50d 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
@@ -169,7 +169,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
169 if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) 169 if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual))
170 goto merr; 170 goto merr;
171 qual->pqualid = OBJ_nid2obj(NID_id_qt_cps); 171 qual->pqualid = OBJ_nid2obj(NID_id_qt_cps);
172 qual->d.cpsuri = ASN1_IA5STRING_new(); 172 qual->d.cpsuri = M_ASN1_IA5STRING_new();
173 if(!ASN1_STRING_set(qual->d.cpsuri, cnf->value, 173 if(!ASN1_STRING_set(qual->d.cpsuri, cnf->value,
174 strlen(cnf->value))) goto merr; 174 strlen(cnf->value))) goto merr;
175 } else if(!name_cmp(cnf->name, "userNotice")) { 175 } else if(!name_cmp(cnf->name, "userNotice")) {
@@ -229,7 +229,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
229 for(i = 0; i < sk_CONF_VALUE_num(unot); i++) { 229 for(i = 0; i < sk_CONF_VALUE_num(unot); i++) {
230 cnf = sk_CONF_VALUE_value(unot, i); 230 cnf = sk_CONF_VALUE_value(unot, i);
231 if(!strcmp(cnf->name, "explicitText")) { 231 if(!strcmp(cnf->name, "explicitText")) {
232 not->exptext = ASN1_VISIBLESTRING_new(); 232 not->exptext = M_ASN1_VISIBLESTRING_new();
233 if(!ASN1_STRING_set(not->exptext, cnf->value, 233 if(!ASN1_STRING_set(not->exptext, cnf->value,
234 strlen(cnf->value))) goto merr; 234 strlen(cnf->value))) goto merr;
235 } else if(!strcmp(cnf->name, "organization")) { 235 } else if(!strcmp(cnf->name, "organization")) {
@@ -238,8 +238,8 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
238 if(!(nref = NOTICEREF_new())) goto merr; 238 if(!(nref = NOTICEREF_new())) goto merr;
239 not->noticeref = nref; 239 not->noticeref = nref;
240 } else nref = not->noticeref; 240 } else nref = not->noticeref;
241 if(ia5org) nref->organization = ASN1_IA5STRING_new(); 241 if(ia5org) nref->organization = M_ASN1_IA5STRING_new();
242 else nref->organization = ASN1_VISIBLESTRING_new(); 242 else nref->organization = M_ASN1_VISIBLESTRING_new();
243 if(!ASN1_STRING_set(nref->organization, cnf->value, 243 if(!ASN1_STRING_set(nref->organization, cnf->value,
244 strlen(cnf->value))) goto merr; 244 strlen(cnf->value))) goto merr;
245 } else if(!strcmp(cnf->name, "noticeNumbers")) { 245 } else if(!strcmp(cnf->name, "noticeNumbers")) {
@@ -538,7 +538,7 @@ void POLICYQUALINFO_free(POLICYQUALINFO *a)
538 if (a == NULL) return; 538 if (a == NULL) return;
539 switch(OBJ_obj2nid(a->pqualid)) { 539 switch(OBJ_obj2nid(a->pqualid)) {
540 case NID_id_qt_cps: 540 case NID_id_qt_cps:
541 ASN1_IA5STRING_free(a->d.cpsuri); 541 M_ASN1_IA5STRING_free(a->d.cpsuri);
542 break; 542 break;
543 543
544 case NID_id_qt_unotice: 544 case NID_id_qt_unotice:
@@ -596,7 +596,7 @@ void USERNOTICE_free(USERNOTICE *a)
596{ 596{
597 if (a == NULL) return; 597 if (a == NULL) return;
598 NOTICEREF_free(a->noticeref); 598 NOTICEREF_free(a->noticeref);
599 DISPLAYTEXT_free(a->exptext); 599 M_DISPLAYTEXT_free(a->exptext);
600 Free (a); 600 Free (a);
601} 601}
602 602
@@ -646,7 +646,7 @@ NOTICEREF *d2i_NOTICEREF(NOTICEREF **a, unsigned char **pp,long length)
646void NOTICEREF_free(NOTICEREF *a) 646void NOTICEREF_free(NOTICEREF *a)
647{ 647{
648 if (a == NULL) return; 648 if (a == NULL) return;
649 DISPLAYTEXT_free(a->organization); 649 M_DISPLAYTEXT_free(a->organization);
650 sk_pop_free(a->noticenos, ASN1_STRING_free); 650 sk_pop_free(a->noticenos, ASN1_STRING_free);
651 Free (a); 651 Free (a);
652} 652}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_crld.c b/src/lib/libssl/src/crypto/x509v3/v3_crld.c
index 897ffb63e4..e459d2595a 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_crld.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_crld.c
@@ -211,20 +211,20 @@ void DIST_POINT_free(DIST_POINT *a)
211{ 211{
212 if (a == NULL) return; 212 if (a == NULL) return;
213 DIST_POINT_NAME_free(a->distpoint); 213 DIST_POINT_NAME_free(a->distpoint);
214 ASN1_BIT_STRING_free(a->reasons); 214 M_ASN1_BIT_STRING_free(a->reasons);
215 sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free); 215 sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free);
216 Free ((char *)a); 216 Free (a);
217} 217}
218 218
219int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) 219int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp)
220{ 220{
221 int v = 0;
222 M_ASN1_I2D_vars(a); 221 M_ASN1_I2D_vars(a);
223 222
224 if(a->fullname) { 223 if(a->fullname) {
225 M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES); 224 M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES);
226 } else { 225 } else {
227 M_ASN1_I2D_len_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); 226 M_ASN1_I2D_len_IMP_SET_opt_type(X509_NAME_ENTRY,
227 a->relativename, i2d_X509_NAME_ENTRY, 1);
228 } 228 }
229 229
230 /* Don't want a SEQUENCE so... */ 230 /* Don't want a SEQUENCE so... */
@@ -234,7 +234,8 @@ int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp)
234 if(a->fullname) { 234 if(a->fullname) {
235 M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0); 235 M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0);
236 } else { 236 } else {
237 M_ASN1_I2D_put_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); 237 M_ASN1_I2D_put_IMP_SET_opt_type(X509_NAME_ENTRY,
238 a->relativename, i2d_X509_NAME_ENTRY, 1);
238 } 239 }
239 M_ASN1_I2D_finish(); 240 M_ASN1_I2D_finish();
240} 241}
@@ -253,9 +254,9 @@ DIST_POINT_NAME *DIST_POINT_NAME_new(void)
253void DIST_POINT_NAME_free(DIST_POINT_NAME *a) 254void DIST_POINT_NAME_free(DIST_POINT_NAME *a)
254{ 255{
255 if (a == NULL) return; 256 if (a == NULL) return;
256 X509_NAME_free(a->relativename); 257 sk_X509_NAME_ENTRY_pop_free(a->relativename, X509_NAME_ENTRY_free);
257 sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free); 258 sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free);
258 Free ((char *)a); 259 Free (a);
259} 260}
260 261
261DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, 262DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
@@ -273,7 +274,8 @@ DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
273 M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES, 274 M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES,
274 V_ASN1_SEQUENCE); 275 V_ASN1_SEQUENCE);
275 } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) { 276 } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) {
276 M_ASN1_D2I_get_EXP_opt (ret->relativename, d2i_X509_NAME, 1); 277 M_ASN1_D2I_get_IMP_set_opt_type (X509_NAME_ENTRY,
278 ret->relativename, d2i_X509_NAME_ENTRY, X509_NAME_ENTRY_free, 1);
277 } else { 279 } else {
278 c.error = ASN1_R_BAD_TAG; 280 c.error = ASN1_R_BAD_TAG;
279 goto err; 281 goto err;
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_enum.c b/src/lib/libssl/src/crypto/x509v3/v3_enum.c
index db423548ff..aecfdc87f8 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_enum.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_enum.c
@@ -60,8 +60,6 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ASN1_ENUMERATED *asn1_enumerated_new(void);
64
65static ENUMERATED_NAMES crl_reasons[] = { 63static ENUMERATED_NAMES crl_reasons[] = {
66{0, "Unspecified", "unspecified"}, 64{0, "Unspecified", "unspecified"},
67{1, "Key Compromise", "keyCompromise"}, 65{1, "Key Compromise", "keyCompromise"},
@@ -76,20 +74,15 @@ static ENUMERATED_NAMES crl_reasons[] = {
76 74
77X509V3_EXT_METHOD v3_crl_reason = { 75X509V3_EXT_METHOD v3_crl_reason = {
78NID_crl_reason, 0, 76NID_crl_reason, 0,
79(X509V3_EXT_NEW)asn1_enumerated_new, 77(X509V3_EXT_NEW)ASN1_ENUMERATED_new,
80(X509V3_EXT_FREE)ASN1_STRING_free, 78(X509V3_EXT_FREE)ASN1_ENUMERATED_free,
81(X509V3_EXT_D2I)d2i_ASN1_ENUMERATED, 79(X509V3_EXT_D2I)d2i_ASN1_ENUMERATED,
82(X509V3_EXT_I2D)i2d_ASN1_ENUMERATED, 80(X509V3_EXT_I2D)i2d_ASN1_ENUMERATED,
83(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, 81(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE,
84(X509V3_EXT_S2I)NULL, 82(X509V3_EXT_S2I)0,
85NULL, NULL, NULL, NULL, crl_reasons}; 83NULL, NULL, NULL, NULL, crl_reasons};
86 84
87 85
88static ASN1_ENUMERATED *asn1_enumerated_new(void)
89{
90 return ASN1_ENUMERATED_new();
91}
92
93char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, 86char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method,
94 ASN1_ENUMERATED *e) 87 ASN1_ENUMERATED *e)
95{ 88{
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_genn.c b/src/lib/libssl/src/crypto/x509v3/v3_genn.c
index af716232f8..894afa7e03 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_genn.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_genn.c
@@ -88,12 +88,15 @@ int i2d_GENERAL_NAME(GENERAL_NAME *a, unsigned char **pp)
88 88
89 switch(a->type) { 89 switch(a->type) {
90 90
91 case GEN_OTHERNAME:
92 case GEN_X400: 91 case GEN_X400:
93 case GEN_EDIPARTY: 92 case GEN_EDIPARTY:
94 ret = i2d_ASN1_TYPE(a->d.other, pp); 93 ret = i2d_ASN1_TYPE(a->d.other, pp);
95 break; 94 break;
96 95
96 case GEN_OTHERNAME:
97 ret = i2d_OTHERNAME(a->d.otherName, pp);
98 break;
99
97 case GEN_EMAIL: 100 case GEN_EMAIL:
98 case GEN_DNS: 101 case GEN_DNS:
99 case GEN_URI: 102 case GEN_URI:
@@ -137,12 +140,15 @@ GENERAL_NAME *d2i_GENERAL_NAME(GENERAL_NAME **a, unsigned char **pp,
137 140
138 switch(ret->type) { 141 switch(ret->type) {
139 /* Just put these in a "blob" for now */ 142 /* Just put these in a "blob" for now */
140 case GEN_OTHERNAME:
141 case GEN_X400: 143 case GEN_X400:
142 case GEN_EDIPARTY: 144 case GEN_EDIPARTY:
143 M_ASN1_D2I_get_imp(ret->d.other, d2i_ASN1_TYPE,V_ASN1_SEQUENCE); 145 M_ASN1_D2I_get_imp(ret->d.other, d2i_ASN1_TYPE,V_ASN1_SEQUENCE);
144 break; 146 break;
145 147
148 case GEN_OTHERNAME:
149 M_ASN1_D2I_get_imp(ret->d.otherName, d2i_OTHERNAME,V_ASN1_SEQUENCE);
150 break;
151
146 case GEN_EMAIL: 152 case GEN_EMAIL:
147 case GEN_DNS: 153 case GEN_DNS:
148 case GEN_URI: 154 case GEN_URI:
@@ -176,17 +182,20 @@ void GENERAL_NAME_free(GENERAL_NAME *a)
176{ 182{
177 if (a == NULL) return; 183 if (a == NULL) return;
178 switch(a->type) { 184 switch(a->type) {
179 case GEN_OTHERNAME:
180 case GEN_X400: 185 case GEN_X400:
181 case GEN_EDIPARTY: 186 case GEN_EDIPARTY:
182 ASN1_TYPE_free(a->d.other); 187 ASN1_TYPE_free(a->d.other);
183 break; 188 break;
184 189
190 case GEN_OTHERNAME:
191 OTHERNAME_free(a->d.otherName);
192 break;
193
185 case GEN_EMAIL: 194 case GEN_EMAIL:
186 case GEN_DNS: 195 case GEN_DNS:
187 case GEN_URI: 196 case GEN_URI:
188 197
189 ASN1_IA5STRING_free(a->d.ia5); 198 M_ASN1_IA5STRING_free(a->d.ia5);
190 break; 199 break;
191 200
192 case GEN_DIRNAME: 201 case GEN_DIRNAME:
@@ -194,7 +203,7 @@ void GENERAL_NAME_free(GENERAL_NAME *a)
194 break; 203 break;
195 204
196 case GEN_IPADD: 205 case GEN_IPADD:
197 ASN1_OCTET_STRING_free(a->d.ip); 206 M_ASN1_OCTET_STRING_free(a->d.ip);
198 break; 207 break;
199 208
200 case GEN_RID: 209 case GEN_RID:
@@ -202,11 +211,11 @@ void GENERAL_NAME_free(GENERAL_NAME *a)
202 break; 211 break;
203 212
204 } 213 }
205 Free ((char *)a); 214 Free (a);
206} 215}
207 216
208/* Now the GeneralNames versions: a SEQUENCE OF GeneralName These are needed as 217/* Now the GeneralNames versions: a SEQUENCE OF GeneralName. These are needed as
209 * an explicit functions. 218 * explicit functions.
210 */ 219 */
211 220
212STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new() 221STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new()
@@ -235,3 +244,48 @@ return i2d_ASN1_SET_OF_GENERAL_NAME(a, pp, i2d_GENERAL_NAME, V_ASN1_SEQUENCE,
235IMPLEMENT_STACK_OF(GENERAL_NAME) 244IMPLEMENT_STACK_OF(GENERAL_NAME)
236IMPLEMENT_ASN1_SET_OF(GENERAL_NAME) 245IMPLEMENT_ASN1_SET_OF(GENERAL_NAME)
237 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 Free (a);
290}
291
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ia5.c b/src/lib/libssl/src/crypto/x509v3/v3_ia5.c
index 3446c5cd6a..af3525f33e 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_ia5.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_ia5.c
@@ -63,7 +63,6 @@
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static ASN1_IA5STRING *ia5string_new(void);
67static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); 66static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
68static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 67static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
69X509V3_EXT_METHOD v3_ns_ia5_list[] = { 68X509V3_EXT_METHOD v3_ns_ia5_list[] = {
@@ -78,11 +77,6 @@ EXT_END
78}; 77};
79 78
80 79
81static ASN1_IA5STRING *ia5string_new(void)
82{
83 return ASN1_IA5STRING_new();
84}
85
86static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, 80static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
87 ASN1_IA5STRING *ia5) 81 ASN1_IA5STRING *ia5)
88{ 82{
@@ -102,12 +96,15 @@ static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
102 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,X509V3_R_INVALID_NULL_ARGUMENT); 96 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,X509V3_R_INVALID_NULL_ARGUMENT);
103 return NULL; 97 return NULL;
104 } 98 }
105 if(!(ia5 = ASN1_IA5STRING_new())) goto err; 99 if(!(ia5 = M_ASN1_IA5STRING_new())) goto err;
106 if(!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str, 100 if(!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str,
107 strlen(str))) { 101 strlen(str))) {
108 ASN1_IA5STRING_free(ia5); 102 M_ASN1_IA5STRING_free(ia5);
109 goto err; 103 goto err;
110 } 104 }
105#ifdef CHARSET_EBCDIC
106 ebcdic2ascii(ia5->data, ia5->data, ia5->length);
107#endif /*CHARSET_EBCDIC*/
111 return ia5; 108 return ia5;
112 err: 109 err:
113 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE); 110 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_info.c b/src/lib/libssl/src/crypto/x509v3/v3_info.c
new file mode 100644
index 0000000000..78d2135046
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/v3_info.c
@@ -0,0 +1,236 @@
1/* v3_info.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/asn1_mac.h>
64#include <openssl/x509v3.h>
65
66static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
67 STACK_OF(ACCESS_DESCRIPTION) *ainfo,
68 STACK_OF(CONF_VALUE) *ret);
69static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
70 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
71
72X509V3_EXT_METHOD v3_info =
73{ NID_info_access, X509V3_EXT_MULTILINE,
74(X509V3_EXT_NEW)AUTHORITY_INFO_ACCESS_new,
75(X509V3_EXT_FREE)AUTHORITY_INFO_ACCESS_free,
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,
80(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
81NULL, NULL, NULL};
82
83static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
84 STACK_OF(ACCESS_DESCRIPTION) *ainfo,
85 STACK_OF(CONF_VALUE) *ret)
86{
87 ACCESS_DESCRIPTION *desc;
88 int i;
89 char objtmp[80], *ntmp;
90 CONF_VALUE *vtmp;
91 for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
92 desc = sk_ACCESS_DESCRIPTION_value(ainfo, i);
93 ret = i2v_GENERAL_NAME(method, desc->location, ret);
94 if(!ret) break;
95 vtmp = sk_CONF_VALUE_value(ret, i);
96 i2t_ASN1_OBJECT(objtmp, 80, desc->method);
97 ntmp = Malloc(strlen(objtmp) + strlen(vtmp->name) + 5);
98 if(!ntmp) {
99 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
100 ERR_R_MALLOC_FAILURE);
101 return NULL;
102 }
103 strcpy(ntmp, objtmp);
104 strcat(ntmp, " - ");
105 strcat(ntmp, vtmp->name);
106 Free(vtmp->name);
107 vtmp->name = ntmp;
108
109 }
110 if(!ret) return sk_CONF_VALUE_new_null();
111 return ret;
112}
113
114static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
115 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
116{
117 STACK_OF(ACCESS_DESCRIPTION) *ainfo = NULL;
118 CONF_VALUE *cnf, ctmp;
119 ACCESS_DESCRIPTION *acc;
120 int i, objlen;
121 char *objtmp, *ptmp;
122 if(!(ainfo = sk_ACCESS_DESCRIPTION_new(NULL))) {
123 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE);
124 return NULL;
125 }
126 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
127 cnf = sk_CONF_VALUE_value(nval, i);
128 if(!(acc = ACCESS_DESCRIPTION_new())
129 || !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) {
130 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE);
131 goto err;
132 }
133 ptmp = strchr(cnf->name, ';');
134 if(!ptmp) {
135 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,X509V3_R_INVALID_SYNTAX);
136 goto err;
137 }
138 objlen = ptmp - cnf->name;
139 ctmp.name = ptmp + 1;
140 ctmp.value = cnf->value;
141 if(!(acc->location = v2i_GENERAL_NAME(method, ctx, &ctmp)))
142 goto err;
143 if(!(objtmp = Malloc(objlen + 1))) {
144 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE);
145 goto err;
146 }
147 strncpy(objtmp, cnf->name, objlen);
148 objtmp[objlen] = 0;
149 acc->method = OBJ_txt2obj(objtmp, 0);
150 if(!acc->method) {
151 X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,X509V3_R_BAD_OBJECT);
152 ERR_add_error_data(2, "value=", objtmp);
153 Free(objtmp);
154 goto err;
155 }
156 Free(objtmp);
157
158 }
159 return ainfo;
160 err:
161 sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free);
162 return NULL;
163}
164
165int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **pp)
166{
167 M_ASN1_I2D_vars(a);
168
169 M_ASN1_I2D_len(a->method, i2d_ASN1_OBJECT);
170 M_ASN1_I2D_len(a->location, i2d_GENERAL_NAME);
171
172 M_ASN1_I2D_seq_total();
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 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 637dd5e128..63c201e5f4 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_int.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_int.c
@@ -60,20 +60,13 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63static ASN1_INTEGER *asn1_integer_new(void);
64
65X509V3_EXT_METHOD v3_crl_num = { 63X509V3_EXT_METHOD v3_crl_num = {
66NID_crl_number, 0, 64NID_crl_number, 0,
67(X509V3_EXT_NEW)asn1_integer_new, 65(X509V3_EXT_NEW)ASN1_INTEGER_new,
68(X509V3_EXT_FREE)ASN1_STRING_free, 66(X509V3_EXT_FREE)ASN1_INTEGER_free,
69(X509V3_EXT_D2I)d2i_ASN1_INTEGER, 67(X509V3_EXT_D2I)d2i_ASN1_INTEGER,
70(X509V3_EXT_I2D)i2d_ASN1_INTEGER, 68(X509V3_EXT_I2D)i2d_ASN1_INTEGER,
71(X509V3_EXT_I2S)i2s_ASN1_INTEGER, 69(X509V3_EXT_I2S)i2s_ASN1_INTEGER,
72(X509V3_EXT_S2I)NULL, 70(X509V3_EXT_S2I)0,
73NULL, NULL, NULL, NULL, NULL}; 71NULL, NULL, NULL, NULL, NULL};
74 72
75
76static ASN1_INTEGER *asn1_integer_new(void)
77{
78 return ASN1_INTEGER_new();
79}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_lib.c b/src/lib/libssl/src/crypto/x509v3/v3_lib.c
index a0aa5de794..4242d130a2 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_lib.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_lib.c
@@ -62,6 +62,8 @@
62#include <openssl/conf.h> 62#include <openssl/conf.h>
63#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
64 64
65#include "ext_dat.h"
66
65static STACK *ext_list = NULL; 67static STACK *ext_list = NULL;
66 68
67static int ext_cmp(X509V3_EXT_METHOD **a, X509V3_EXT_METHOD **b); 69static int ext_cmp(X509V3_EXT_METHOD **a, X509V3_EXT_METHOD **b);
@@ -87,10 +89,15 @@ static int ext_cmp(X509V3_EXT_METHOD **a, X509V3_EXT_METHOD **b)
87 89
88X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) 90X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid)
89{ 91{
90 X509V3_EXT_METHOD tmp; 92 X509V3_EXT_METHOD tmp, *t = &tmp, **ret;
91 int idx; 93 int idx;
94 if(nid < 0) return NULL;
92 tmp.ext_nid = nid; 95 tmp.ext_nid = nid;
93 if(!ext_list || (tmp.ext_nid < 0) ) return NULL; 96 ret = (X509V3_EXT_METHOD **) OBJ_bsearch((char *)&t,
97 (char *)standard_exts, STANDARD_EXTENSION_COUNT,
98 sizeof(X509V3_EXT_METHOD *), (int (*)())ext_cmp);
99 if(ret) return *ret;
100 if(!ext_list) return NULL;
94 idx = sk_find(ext_list, (char *)&tmp); 101 idx = sk_find(ext_list, (char *)&tmp);
95 if(idx == -1) return NULL; 102 if(idx == -1) return NULL;
96 return (X509V3_EXT_METHOD *)sk_value(ext_list, idx); 103 return (X509V3_EXT_METHOD *)sk_value(ext_list, idx);
@@ -125,7 +132,7 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from)
125 *tmpext = *ext; 132 *tmpext = *ext;
126 tmpext->ext_nid = nid_to; 133 tmpext->ext_nid = nid_to;
127 tmpext->ext_flags |= X509V3_EXT_DYNAMIC; 134 tmpext->ext_flags |= X509V3_EXT_DYNAMIC;
128 return 1; 135 return X509V3_EXT_add(tmpext);
129} 136}
130 137
131void X509V3_EXT_cleanup(void) 138void X509V3_EXT_cleanup(void)
@@ -139,28 +146,12 @@ static void ext_list_free(X509V3_EXT_METHOD *ext)
139 if(ext->ext_flags & X509V3_EXT_DYNAMIC) Free(ext); 146 if(ext->ext_flags & X509V3_EXT_DYNAMIC) Free(ext);
140} 147}
141 148
142extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku; 149/* Legacy function: we don't need to add standard extensions
143extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet; 150 * any more because they are now kept in ext_dat.h.
144extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; 151 */
145
146extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_cpols, v3_crld;
147 152
148int X509V3_add_standard_extensions(void) 153int X509V3_add_standard_extensions(void)
149{ 154{
150 X509V3_EXT_add_list(v3_ns_ia5_list);
151 X509V3_EXT_add_list(v3_alt);
152 X509V3_EXT_add(&v3_bcons);
153 X509V3_EXT_add(&v3_nscert);
154 X509V3_EXT_add(&v3_key_usage);
155 X509V3_EXT_add(&v3_ext_ku);
156 X509V3_EXT_add(&v3_skey_id);
157 X509V3_EXT_add(&v3_akey_id);
158 X509V3_EXT_add(&v3_pkey_usage_period);
159 X509V3_EXT_add(&v3_crl_num);
160 X509V3_EXT_add(&v3_sxnet);
161 X509V3_EXT_add(&v3_crl_reason);
162 X509V3_EXT_add(&v3_cpols);
163 X509V3_EXT_add(&v3_crld);
164 return 1; 155 return 1;
165} 156}
166 157
@@ -175,3 +166,56 @@ void *X509V3_EXT_d2i(X509_EXTENSION *ext)
175 return method->d2i(NULL, &p, ext->value->length); 166 return method->d2i(NULL, &p, ext->value->length);
176} 167}
177 168
169/* Get critical flag and decoded version of extension from a NID.
170 * The "idx" variable returns the last found extension and can
171 * be used to retrieve multiple extensions of the same NID.
172 * However multiple extensions with the same NID is usually
173 * due to a badly encoded certificate so if idx is NULL we
174 * choke if multiple extensions exist.
175 * The "crit" variable is set to the critical value.
176 * The return value is the decoded extension or NULL on
177 * error. The actual error can have several different causes,
178 * the value of *crit reflects the cause:
179 * >= 0, extension found but not decoded (reflects critical value).
180 * -1 extension not found.
181 * -2 extension occurs more than once.
182 */
183
184void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx)
185{
186 int lastpos, i;
187 X509_EXTENSION *ex, *found_ex = NULL;
188 if(!x) {
189 if(idx) *idx = -1;
190 if(crit) *crit = -1;
191 return NULL;
192 }
193 if(idx) lastpos = *idx + 1;
194 else lastpos = 0;
195 if(lastpos < 0) lastpos = 0;
196 for(i = lastpos; i < sk_X509_EXTENSION_num(x); i++)
197 {
198 ex = sk_X509_EXTENSION_value(x, i);
199 if(OBJ_obj2nid(ex->object) == nid) {
200 if(idx) {
201 *idx = i;
202 break;
203 } else if(found_ex) {
204 /* Found more than one */
205 if(crit) *crit = -2;
206 return NULL;
207 }
208 found_ex = ex;
209 }
210 }
211 if(found_ex) {
212 /* Found it */
213 if(crit) *crit = found_ex->critical;
214 return X509V3_EXT_d2i(found_ex);
215 }
216
217 /* Extension not found */
218 if(idx) *idx = -1;
219 if(crit) *crit = -1;
220 return NULL;
221}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_pku.c b/src/lib/libssl/src/crypto/x509v3/v3_pku.c
index c13e7d8f45..30a62c6090 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_pku.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_pku.c
@@ -119,9 +119,9 @@ PKEY_USAGE_PERIOD *d2i_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD **a,
119void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a) 119void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a)
120{ 120{
121 if (a == NULL) return; 121 if (a == NULL) return;
122 ASN1_GENERALIZEDTIME_free(a->notBefore); 122 M_ASN1_GENERALIZEDTIME_free(a->notBefore);
123 ASN1_GENERALIZEDTIME_free(a->notAfter); 123 M_ASN1_GENERALIZEDTIME_free(a->notAfter);
124 Free ((char *)a); 124 Free (a);
125} 125}
126 126
127static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, 127static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_prn.c b/src/lib/libssl/src/crypto/x509v3/v3_prn.c
index dc20c6bdba..bee624c6be 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_prn.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_prn.c
@@ -81,7 +81,15 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml)
81 nval = sk_CONF_VALUE_value(val, i); 81 nval = sk_CONF_VALUE_value(val, i);
82 if(!nval->name) BIO_puts(out, nval->value); 82 if(!nval->name) BIO_puts(out, nval->value);
83 else if(!nval->value) BIO_puts(out, nval->name); 83 else if(!nval->value) BIO_puts(out, nval->name);
84#ifndef CHARSET_EBCDIC
84 else BIO_printf(out, "%s:%s", nval->name, nval->value); 85 else BIO_printf(out, "%s:%s", nval->name, nval->value);
86#else
87 else {
88 char tmp[10240]; /* 10k is BIO_printf's limit anyway */
89 ascii2ebcdic(tmp, nval->value, strlen(nval->value)+1);
90 BIO_printf(out, "%s:%s", nval->name, tmp);
91 }
92#endif
85 if(ml) BIO_puts(out, "\n"); 93 if(ml) BIO_puts(out, "\n");
86 } 94 }
87} 95}
@@ -103,7 +111,15 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent)
103 ok = 0; 111 ok = 0;
104 goto err; 112 goto err;
105 } 113 }
114#ifndef CHARSET_EBCDIC
106 BIO_printf(out, "%*s%s", indent, "", value); 115 BIO_printf(out, "%*s%s", indent, "", value);
116#else
117 {
118 char tmp[10240]; /* 10k is BIO_printf's limit anyway */
119 ascii2ebcdic(tmp, value, strlen(value)+1);
120 BIO_printf(out, "%*s%s", indent, "", tmp);
121 }
122#endif
107 } else if(method->i2v) { 123 } else if(method->i2v) {
108 if(!(nval = method->i2v(method, ext_str, NULL))) { 124 if(!(nval = method->i2v(method, ext_str, NULL))) {
109 ok = 0; 125 ok = 0;
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_purp.c b/src/lib/libssl/src/crypto/x509v3/v3_purp.c
new file mode 100644
index 0000000000..b7494ebcd5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/v3_purp.c
@@ -0,0 +1,456 @@
1/* v3_purp.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/x509v3.h>
62
63
64static void x509v3_cache_extensions(X509 *x);
65
66static int ca_check(X509 *x);
67static int check_purpose_ssl_client(X509_PURPOSE *xp, X509 *x, int ca);
68static int check_purpose_ssl_server(X509_PURPOSE *xp, X509 *x, int ca);
69static int check_purpose_ns_ssl_server(X509_PURPOSE *xp, X509 *x, int ca);
70static int purpose_smime(X509 *x, int ca);
71static int check_purpose_smime_sign(X509_PURPOSE *xp, X509 *x, int ca);
72static int check_purpose_smime_encrypt(X509_PURPOSE *xp, X509 *x, int ca);
73static int check_purpose_crl_sign(X509_PURPOSE *xp, X509 *x, int ca);
74
75static int xp_cmp(X509_PURPOSE **a, X509_PURPOSE **b);
76static void xptable_free(X509_PURPOSE *p);
77
78static X509_PURPOSE xstandard[] = {
79 {X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_client, "SSL client", "sslclient", NULL},
80 {X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_server, "SSL server", "sslserver", NULL},
81 {X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ssl_server, "Netscape SSL server", "nssslserver", NULL},
82 {X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, "S/MIME signing", "smimesign", NULL},
83 {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, "S/MIME encryption", "smimeencrypt", NULL},
84 {X509_PURPOSE_CRL_SIGN, X509_TRUST_ANY, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL},
85};
86
87#define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE))
88
89IMPLEMENT_STACK_OF(X509_PURPOSE)
90
91static STACK_OF(X509_PURPOSE) *xptable = NULL;
92
93static int xp_cmp(X509_PURPOSE **a, X509_PURPOSE **b)
94{
95 return (*a)->purpose - (*b)->purpose;
96}
97
98int X509_check_purpose(X509 *x, int id, int ca)
99{
100 int idx;
101 X509_PURPOSE *pt;
102 if(!(x->ex_flags & EXFLAG_SET)) {
103 CRYPTO_w_lock(CRYPTO_LOCK_X509);
104 x509v3_cache_extensions(x);
105 CRYPTO_w_unlock(CRYPTO_LOCK_X509);
106 }
107 if(id == -1) return 1;
108 idx = X509_PURPOSE_get_by_id(id);
109 if(idx == -1) return -1;
110 pt = X509_PURPOSE_get0(idx);
111 return pt->check_purpose(pt, x, ca);
112}
113
114int X509_PURPOSE_get_count(void)
115{
116 if(!xptable) return X509_PURPOSE_COUNT;
117 return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT;
118}
119
120X509_PURPOSE * X509_PURPOSE_get0(int idx)
121{
122 if(idx < 0) return NULL;
123 if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
124 return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
125}
126
127int X509_PURPOSE_get_by_sname(char *sname)
128{
129 int i;
130 X509_PURPOSE *xptmp;
131 for(i = 0; i < X509_PURPOSE_get_count(); i++) {
132 xptmp = X509_PURPOSE_get0(i);
133 if(!strcmp(xptmp->sname, sname)) return i;
134 }
135 return -1;
136}
137
138
139int X509_PURPOSE_get_by_id(int purpose)
140{
141 X509_PURPOSE tmp;
142 int idx;
143 if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
144 return purpose - X509_PURPOSE_MIN;
145 tmp.purpose = purpose;
146 if(!xptable) return -1;
147 idx = sk_X509_PURPOSE_find(xptable, &tmp);
148 if(idx == -1) return -1;
149 return idx + X509_PURPOSE_COUNT;
150}
151
152int X509_PURPOSE_add(int id, int trust, int flags,
153 int (*ck)(X509_PURPOSE *, X509 *, int),
154 char *name, char *sname, void *arg)
155{
156 int idx;
157 X509_PURPOSE *ptmp;
158 /* This is set according to what we change: application can't set it */
159 flags &= ~X509_PURPOSE_DYNAMIC;
160 /* This will always be set for application modified trust entries */
161 flags |= X509_PURPOSE_DYNAMIC_NAME;
162 /* Get existing entry if any */
163 idx = X509_PURPOSE_get_by_id(id);
164 /* Need a new entry */
165 if(idx == -1) {
166 if(!(ptmp = Malloc(sizeof(X509_PURPOSE)))) {
167 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
168 return 0;
169 }
170 ptmp->flags = X509_PURPOSE_DYNAMIC;
171 } else ptmp = X509_PURPOSE_get0(idx);
172
173 /* Free existing name if dynamic */
174 if(ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) {
175 Free(ptmp->name);
176 Free(ptmp->sname);
177 }
178 /* dup supplied name */
179 ptmp->name = BUF_strdup(name);
180 ptmp->sname = BUF_strdup(sname);
181 if(!ptmp->name || !ptmp->sname) {
182 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
183 return 0;
184 }
185 /* Keep the dynamic flag of existing entry */
186 ptmp->flags &= X509_PURPOSE_DYNAMIC;
187 /* Set all other flags */
188 ptmp->flags |= flags;
189
190 ptmp->purpose = id;
191 ptmp->trust = trust;
192 ptmp->check_purpose = ck;
193 ptmp->usr_data = arg;
194
195 /* If its a new entry manage the dynamic table */
196 if(idx == -1) {
197 if(!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) {
198 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
199 return 0;
200 }
201 if (!sk_X509_PURPOSE_push(xptable, ptmp)) {
202 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
203 return 0;
204 }
205 }
206 return 1;
207}
208
209static void xptable_free(X509_PURPOSE *p)
210 {
211 if(!p) return;
212 if (p->flags & X509_PURPOSE_DYNAMIC)
213 {
214 if (p->flags & X509_PURPOSE_DYNAMIC_NAME) {
215 Free(p->name);
216 Free(p->sname);
217 }
218 Free(p);
219 }
220 }
221
222void X509_PURPOSE_cleanup(void)
223{
224 int i;
225 sk_X509_PURPOSE_pop_free(xptable, xptable_free);
226 for(i = 0; i < X509_PURPOSE_COUNT; i++) xptable_free(xstandard + i);
227 xptable = NULL;
228}
229
230int X509_PURPOSE_get_id(X509_PURPOSE *xp)
231{
232 return xp->purpose;
233}
234
235char *X509_PURPOSE_get0_name(X509_PURPOSE *xp)
236{
237 return xp->name;
238}
239
240char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp)
241{
242 return xp->sname;
243}
244
245int X509_PURPOSE_get_trust(X509_PURPOSE *xp)
246{
247 return xp->trust;
248}
249
250#ifndef NO_SHA
251static void x509v3_cache_extensions(X509 *x)
252{
253 BASIC_CONSTRAINTS *bs;
254 ASN1_BIT_STRING *usage;
255 ASN1_BIT_STRING *ns;
256 STACK_OF(ASN1_OBJECT) *extusage;
257 int i;
258 if(x->ex_flags & EXFLAG_SET) return;
259 X509_digest(x, EVP_sha1(), x->sha1_hash, NULL);
260 /* Does subject name match issuer ? */
261 if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x)))
262 x->ex_flags |= EXFLAG_SS;
263 /* V1 should mean no extensions ... */
264 if(!X509_get_version(x)) x->ex_flags |= EXFLAG_V1;
265 /* Handle basic constraints */
266 if((bs=X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) {
267 if(bs->ca) x->ex_flags |= EXFLAG_CA;
268 if(bs->pathlen) {
269 if((bs->pathlen->type == V_ASN1_NEG_INTEGER)
270 || !bs->ca) {
271 x->ex_flags |= EXFLAG_INVALID;
272 x->ex_pathlen = 0;
273 } else x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen);
274 } else x->ex_pathlen = -1;
275 BASIC_CONSTRAINTS_free(bs);
276 x->ex_flags |= EXFLAG_BCONS;
277 }
278 /* Handle key usage */
279 if((usage=X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) {
280 if(usage->length > 0) {
281 x->ex_kusage = usage->data[0];
282 if(usage->length > 1)
283 x->ex_kusage |= usage->data[1] << 8;
284 } else x->ex_kusage = 0;
285 x->ex_flags |= EXFLAG_KUSAGE;
286 ASN1_BIT_STRING_free(usage);
287 }
288 x->ex_xkusage = 0;
289 if((extusage=X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) {
290 x->ex_flags |= EXFLAG_XKUSAGE;
291 for(i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) {
292 switch(OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage,i))) {
293 case NID_server_auth:
294 x->ex_xkusage |= XKU_SSL_SERVER;
295 break;
296
297 case NID_client_auth:
298 x->ex_xkusage |= XKU_SSL_CLIENT;
299 break;
300
301 case NID_email_protect:
302 x->ex_xkusage |= XKU_SMIME;
303 break;
304
305 case NID_code_sign:
306 x->ex_xkusage |= XKU_CODE_SIGN;
307 break;
308
309 case NID_ms_sgc:
310 case NID_ns_sgc:
311 x->ex_xkusage |= XKU_SGC;
312 }
313 }
314 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
315 }
316
317 if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) {
318 if(ns->length > 0) x->ex_nscert = ns->data[0];
319 else x->ex_nscert = 0;
320 x->ex_flags |= EXFLAG_NSCERT;
321 ASN1_BIT_STRING_free(ns);
322 }
323 x->ex_flags |= EXFLAG_SET;
324}
325#endif
326
327/* CA checks common to all purposes
328 * return codes:
329 * 0 not a CA
330 * 1 is a CA
331 * 2 basicConstraints absent so "maybe" a CA
332 * 3 basicConstraints absent but self signed V1.
333 */
334
335#define V1_ROOT (EXFLAG_V1|EXFLAG_SS)
336#define ku_reject(x, usage) \
337 (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage)))
338#define xku_reject(x, usage) \
339 (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage)))
340#define ns_reject(x, usage) \
341 (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage)))
342
343static int ca_check(X509 *x)
344{
345 /* keyUsage if present should allow cert signing */
346 if(ku_reject(x, KU_KEY_CERT_SIGN)) return 0;
347 if(x->ex_flags & EXFLAG_BCONS) {
348 if(x->ex_flags & EXFLAG_CA) return 1;
349 /* If basicConstraints says not a CA then say so */
350 else return 0;
351 } else {
352 if((x->ex_flags & V1_ROOT) == V1_ROOT) return 3;
353 else return 2;
354 }
355}
356
357
358static int check_purpose_ssl_client(X509_PURPOSE *xp, X509 *x, int ca)
359{
360 if(xku_reject(x,XKU_SSL_CLIENT)) return 0;
361 if(ca) {
362 int ca_ret;
363 ca_ret = ca_check(x);
364 if(!ca_ret) return 0;
365 /* check nsCertType if present */
366 if(x->ex_flags & EXFLAG_NSCERT) {
367 if(x->ex_nscert & NS_SSL_CA) return ca_ret;
368 return 0;
369 }
370 if(ca_ret != 2) return ca_ret;
371 else return 0;
372 }
373 /* We need to do digital signatures with it */
374 if(ku_reject(x,KU_DIGITAL_SIGNATURE)) return 0;
375 /* nsCertType if present should allow SSL client use */
376 if(ns_reject(x, NS_SSL_CLIENT)) return 0;
377 return 1;
378}
379
380static int check_purpose_ssl_server(X509_PURPOSE *xp, X509 *x, int ca)
381{
382 if(xku_reject(x,XKU_SSL_SERVER|XKU_SGC)) return 0;
383 /* Otherwise same as SSL client for a CA */
384 if(ca) return check_purpose_ssl_client(xp, x, 1);
385
386 if(ns_reject(x, NS_SSL_SERVER)) return 0;
387 /* Now as for keyUsage: we'll at least need to sign OR encipher */
388 if(ku_reject(x, KU_DIGITAL_SIGNATURE|KU_KEY_ENCIPHERMENT)) return 0;
389
390 return 1;
391
392}
393
394static int check_purpose_ns_ssl_server(X509_PURPOSE *xp, X509 *x, int ca)
395{
396 int ret;
397 ret = check_purpose_ssl_server(xp, x, ca);
398 if(!ret || ca) return ret;
399 /* We need to encipher or Netscape complains */
400 if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0;
401 return ret;
402}
403
404/* common S/MIME checks */
405static int purpose_smime(X509 *x, int ca)
406{
407 if(xku_reject(x,XKU_SMIME)) return 0;
408 if(ca) {
409 int ca_ret;
410 ca_ret = ca_check(x);
411 if(!ca_ret) return 0;
412 /* check nsCertType if present */
413 if(x->ex_flags & EXFLAG_NSCERT) {
414 if(x->ex_nscert & NS_SMIME_CA) return ca_ret;
415 return 0;
416 }
417 if(ca_ret != 2) return ca_ret;
418 else return 0;
419 }
420 if(x->ex_flags & EXFLAG_NSCERT) {
421 if(x->ex_nscert & NS_SMIME) return 1;
422 /* Workaround for some buggy certificates */
423 if(x->ex_nscert & NS_SSL_CLIENT) return 2;
424 return 0;
425 }
426 return 1;
427}
428
429static int check_purpose_smime_sign(X509_PURPOSE *xp, X509 *x, int ca)
430{
431 int ret;
432 ret = purpose_smime(x, ca);
433 if(!ret || ca) return ret;
434 if(ku_reject(x, KU_DIGITAL_SIGNATURE)) return 0;
435 return ret;
436}
437
438static int check_purpose_smime_encrypt(X509_PURPOSE *xp, X509 *x, int ca)
439{
440 int ret;
441 ret = purpose_smime(x, ca);
442 if(!ret || ca) return ret;
443 if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0;
444 return ret;
445}
446
447static int check_purpose_crl_sign(X509_PURPOSE *xp, X509 *x, int ca)
448{
449 if(ca) {
450 int ca_ret;
451 if((ca_ret = ca_check(x)) != 2) return ca_ret;
452 else return 0;
453 }
454 if(ku_reject(x, KU_CRL_SIGN)) return 0;
455 return 1;
456}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_skey.c b/src/lib/libssl/src/crypto/x509v3/v3_skey.c
index fb3e36014d..939845fa8f 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_skey.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_skey.c
@@ -61,24 +61,17 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
63 63
64static ASN1_OCTET_STRING *octet_string_new(void);
65static 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);
66X509V3_EXT_METHOD v3_skey_id = { 65X509V3_EXT_METHOD v3_skey_id = {
67NID_subject_key_identifier, 0, 66NID_subject_key_identifier, 0,
68(X509V3_EXT_NEW)octet_string_new, 67(X509V3_EXT_NEW)ASN1_OCTET_STRING_new,
69(X509V3_EXT_FREE)ASN1_STRING_free, 68(X509V3_EXT_FREE)ASN1_OCTET_STRING_free,
70(X509V3_EXT_D2I)d2i_ASN1_OCTET_STRING, 69(X509V3_EXT_D2I)d2i_ASN1_OCTET_STRING,
71(X509V3_EXT_I2D)i2d_ASN1_OCTET_STRING, 70(X509V3_EXT_I2D)i2d_ASN1_OCTET_STRING,
72(X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING, 71(X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING,
73(X509V3_EXT_S2I)s2i_skey_id, 72(X509V3_EXT_S2I)s2i_skey_id,
74NULL, NULL, NULL, NULL, NULL}; 73NULL, NULL, NULL, NULL, NULL};
75 74
76
77static ASN1_OCTET_STRING *octet_string_new(void)
78{
79 return ASN1_OCTET_STRING_new();
80}
81
82char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, 75char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
83 ASN1_OCTET_STRING *oct) 76 ASN1_OCTET_STRING *oct)
84{ 77{
@@ -91,13 +84,13 @@ ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
91 ASN1_OCTET_STRING *oct; 84 ASN1_OCTET_STRING *oct;
92 long length; 85 long length;
93 86
94 if(!(oct = ASN1_OCTET_STRING_new())) { 87 if(!(oct = M_ASN1_OCTET_STRING_new())) {
95 X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE); 88 X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);
96 return NULL; 89 return NULL;
97 } 90 }
98 91
99 if(!(oct->data = string_to_hex(str, &length))) { 92 if(!(oct->data = string_to_hex(str, &length))) {
100 ASN1_OCTET_STRING_free(oct); 93 M_ASN1_OCTET_STRING_free(oct);
101 return NULL; 94 return NULL;
102 } 95 }
103 96
@@ -118,7 +111,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
118 111
119 if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str); 112 if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str);
120 113
121 if(!(oct = ASN1_OCTET_STRING_new())) { 114 if(!(oct = M_ASN1_OCTET_STRING_new())) {
122 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); 115 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE);
123 return NULL; 116 return NULL;
124 } 117 }
@@ -143,7 +136,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
143 EVP_DigestUpdate(&md, pk->data, pk->length); 136 EVP_DigestUpdate(&md, pk->data, pk->length);
144 EVP_DigestFinal(&md, pkey_dig, &diglen); 137 EVP_DigestFinal(&md, pkey_dig, &diglen);
145 138
146 if(!ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) { 139 if(!M_ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) {
147 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); 140 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE);
148 goto err; 141 goto err;
149 } 142 }
@@ -151,6 +144,6 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
151 return oct; 144 return oct;
152 145
153 err: 146 err:
154 ASN1_OCTET_STRING_free(oct); 147 M_ASN1_OCTET_STRING_free(oct);
155 return NULL; 148 return NULL;
156} 149}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_sxnet.c b/src/lib/libssl/src/crypto/x509v3/v3_sxnet.c
index 0687bb4e3d..20ba8ac8d6 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_sxnet.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_sxnet.c
@@ -111,7 +111,7 @@ SXNET *SXNET_new(void)
111 SXNET *ret=NULL; 111 SXNET *ret=NULL;
112 ASN1_CTX c; 112 ASN1_CTX c;
113 M_ASN1_New_Malloc(ret, SXNET); 113 M_ASN1_New_Malloc(ret, SXNET);
114 M_ASN1_New(ret->version,ASN1_INTEGER_new); 114 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
115 M_ASN1_New(ret->ids,sk_SXNETID_new_null); 115 M_ASN1_New(ret->ids,sk_SXNETID_new_null);
116 return (ret); 116 return (ret);
117 M_ASN1_New_Error(ASN1_F_SXNET_NEW); 117 M_ASN1_New_Error(ASN1_F_SXNET_NEW);
@@ -130,7 +130,7 @@ SXNET *d2i_SXNET(SXNET **a, unsigned char **pp, long length)
130void SXNET_free(SXNET *a) 130void SXNET_free(SXNET *a)
131{ 131{
132 if (a == NULL) return; 132 if (a == NULL) return;
133 ASN1_INTEGER_free(a->version); 133 M_ASN1_INTEGER_free(a->version);
134 sk_SXNETID_pop_free(a->ids, SXNETID_free); 134 sk_SXNETID_pop_free(a->ids, SXNETID_free);
135 Free (a); 135 Free (a);
136} 136}
@@ -156,7 +156,7 @@ SXNETID *SXNETID_new(void)
156 ASN1_CTX c; 156 ASN1_CTX c;
157 M_ASN1_New_Malloc(ret, SXNETID); 157 M_ASN1_New_Malloc(ret, SXNETID);
158 ret->zone = NULL; 158 ret->zone = NULL;
159 M_ASN1_New(ret->user,ASN1_OCTET_STRING_new); 159 M_ASN1_New(ret->user,M_ASN1_OCTET_STRING_new);
160 return (ret); 160 return (ret);
161 M_ASN1_New_Error(ASN1_F_SXNETID_NEW); 161 M_ASN1_New_Error(ASN1_F_SXNETID_NEW);
162} 162}
@@ -174,8 +174,8 @@ SXNETID *d2i_SXNETID(SXNETID **a, unsigned char **pp, long length)
174void SXNETID_free(SXNETID *a) 174void SXNETID_free(SXNETID *a)
175{ 175{
176 if (a == NULL) return; 176 if (a == NULL) return;
177 ASN1_INTEGER_free(a->zone); 177 M_ASN1_INTEGER_free(a->zone);
178 ASN1_OCTET_STRING_free(a->user); 178 M_ASN1_OCTET_STRING_free(a->user);
179 Free (a); 179 Free (a);
180} 180}
181 181
@@ -193,7 +193,7 @@ static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out,
193 tmp = i2s_ASN1_INTEGER(NULL, id->zone); 193 tmp = i2s_ASN1_INTEGER(NULL, id->zone);
194 BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp); 194 BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp);
195 Free(tmp); 195 Free(tmp);
196 ASN1_OCTET_STRING_print(out, id->user); 196 M_ASN1_OCTET_STRING_print(out, id->user);
197 } 197 }
198 return 1; 198 return 1;
199} 199}
@@ -244,9 +244,9 @@ int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,
244 int userlen) 244 int userlen)
245{ 245{
246 ASN1_INTEGER *izone = NULL; 246 ASN1_INTEGER *izone = NULL;
247 if(!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { 247 if(!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
248 X509V3err(X509V3_F_SXNET_ADD_ID_ULONG,ERR_R_MALLOC_FAILURE); 248 X509V3err(X509V3_F_SXNET_ADD_ID_ULONG,ERR_R_MALLOC_FAILURE);
249 ASN1_INTEGER_free(izone); 249 M_ASN1_INTEGER_free(izone);
250 return 0; 250 return 0;
251 } 251 }
252 return SXNET_add_id_INTEGER(psx, izone, user, userlen); 252 return SXNET_add_id_INTEGER(psx, izone, user, userlen);
@@ -285,7 +285,7 @@ int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, char *user,
285 if(!(id = SXNETID_new())) goto err; 285 if(!(id = SXNETID_new())) goto err;
286 if(userlen == -1) userlen = strlen(user); 286 if(userlen == -1) userlen = strlen(user);
287 287
288 if(!ASN1_OCTET_STRING_set(id->user, user, userlen)) goto err; 288 if(!M_ASN1_OCTET_STRING_set(id->user, user, userlen)) goto err;
289 if(!sk_SXNETID_push(sx->ids, id)) goto err; 289 if(!sk_SXNETID_push(sx->ids, id)) goto err;
290 id->zone = zone; 290 id->zone = zone;
291 return 1; 291 return 1;
@@ -307,7 +307,7 @@ ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone)
307 return NULL; 307 return NULL;
308 } 308 }
309 oct = SXNET_get_id_INTEGER(sx, izone); 309 oct = SXNET_get_id_INTEGER(sx, izone);
310 ASN1_INTEGER_free(izone); 310 M_ASN1_INTEGER_free(izone);
311 return oct; 311 return oct;
312} 312}
313 313
@@ -315,13 +315,13 @@ ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone)
315{ 315{
316 ASN1_INTEGER *izone = NULL; 316 ASN1_INTEGER *izone = NULL;
317 ASN1_OCTET_STRING *oct; 317 ASN1_OCTET_STRING *oct;
318 if(!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { 318 if(!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
319 X509V3err(X509V3_F_SXNET_GET_ID_ULONG,ERR_R_MALLOC_FAILURE); 319 X509V3err(X509V3_F_SXNET_GET_ID_ULONG,ERR_R_MALLOC_FAILURE);
320 ASN1_INTEGER_free(izone); 320 M_ASN1_INTEGER_free(izone);
321 return NULL; 321 return NULL;
322 } 322 }
323 oct = SXNET_get_id_INTEGER(sx, izone); 323 oct = SXNET_get_id_INTEGER(sx, izone);
324 ASN1_INTEGER_free(izone); 324 M_ASN1_INTEGER_free(izone);
325 return oct; 325 return oct;
326} 326}
327 327
@@ -331,7 +331,7 @@ ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone)
331 int i; 331 int i;
332 for(i = 0; i < sk_SXNETID_num(sx->ids); i++) { 332 for(i = 0; i < sk_SXNETID_num(sx->ids); i++) {
333 id = sk_SXNETID_value(sx->ids, i); 333 id = sk_SXNETID_value(sx->ids, i);
334 if(!ASN1_INTEGER_cmp(id->zone, zone)) return id->user; 334 if(!M_ASN1_INTEGER_cmp(id->zone, zone)) return id->user;
335 } 335 }
336 return NULL; 336 return NULL;
337} 337}
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_utl.c b/src/lib/libssl/src/crypto/x509v3/v3_utl.c
index 40f71c71b4..4c2c4a9483 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_utl.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3_utl.c
@@ -104,7 +104,7 @@ void X509V3_conf_free(CONF_VALUE *conf)
104 if(conf->name) Free(conf->name); 104 if(conf->name) Free(conf->name);
105 if(conf->value) Free(conf->value); 105 if(conf->value) Free(conf->value);
106 if(conf->section) Free(conf->section); 106 if(conf->section) Free(conf->section);
107 Free((char *)conf); 107 Free(conf);
108} 108}
109 109
110int X509V3_add_value_bool(const char *name, int asn1_bool, 110int X509V3_add_value_bool(const char *name, int asn1_bool,
diff --git a/src/lib/libssl/src/crypto/x509v3/v3err.c b/src/lib/libssl/src/crypto/x509v3/v3err.c
index 50efa8d99d..b7d4e350c4 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3err.c
+++ b/src/lib/libssl/src/crypto/x509v3/v3err.c
@@ -72,6 +72,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
72{ERR_PACK(0,X509V3_F_HEX_TO_STRING,0), "hex_to_string"}, 72{ERR_PACK(0,X509V3_F_HEX_TO_STRING,0), "hex_to_string"},
73{ERR_PACK(0,X509V3_F_I2S_ASN1_ENUMERATED,0), "i2s_ASN1_ENUMERATED"}, 73{ERR_PACK(0,X509V3_F_I2S_ASN1_ENUMERATED,0), "i2s_ASN1_ENUMERATED"},
74{ERR_PACK(0,X509V3_F_I2S_ASN1_INTEGER,0), "i2s_ASN1_INTEGER"}, 74{ERR_PACK(0,X509V3_F_I2S_ASN1_INTEGER,0), "i2s_ASN1_INTEGER"},
75{ERR_PACK(0,X509V3_F_I2V_AUTHORITY_INFO_ACCESS,0), "I2V_AUTHORITY_INFO_ACCESS"},
75{ERR_PACK(0,X509V3_F_NOTICE_SECTION,0), "NOTICE_SECTION"}, 76{ERR_PACK(0,X509V3_F_NOTICE_SECTION,0), "NOTICE_SECTION"},
76{ERR_PACK(0,X509V3_F_NREF_NOS,0), "NREF_NOS"}, 77{ERR_PACK(0,X509V3_F_NREF_NOS,0), "NREF_NOS"},
77{ERR_PACK(0,X509V3_F_POLICY_SECTION,0), "POLICY_SECTION"}, 78{ERR_PACK(0,X509V3_F_POLICY_SECTION,0), "POLICY_SECTION"},
@@ -87,6 +88,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
87{ERR_PACK(0,X509V3_F_SXNET_ADD_ID_ULONG,0), "SXNET_add_id_ulong"}, 88{ERR_PACK(0,X509V3_F_SXNET_ADD_ID_ULONG,0), "SXNET_add_id_ulong"},
88{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ASC,0), "SXNET_get_id_asc"}, 89{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ASC,0), "SXNET_get_id_asc"},
89{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ULONG,0), "SXNET_get_id_ulong"}, 90{ERR_PACK(0,X509V3_F_SXNET_GET_ID_ULONG,0), "SXNET_get_id_ulong"},
91{ERR_PACK(0,X509V3_F_V2I_ACCESS_DESCRIPTION,0), "V2I_ACCESS_DESCRIPTION"},
90{ERR_PACK(0,X509V3_F_V2I_ASN1_BIT_STRING,0), "V2I_ASN1_BIT_STRING"}, 92{ERR_PACK(0,X509V3_F_V2I_ASN1_BIT_STRING,0), "V2I_ASN1_BIT_STRING"},
91{ERR_PACK(0,X509V3_F_V2I_AUTHORITY_KEYID,0), "V2I_AUTHORITY_KEYID"}, 93{ERR_PACK(0,X509V3_F_V2I_AUTHORITY_KEYID,0), "V2I_AUTHORITY_KEYID"},
92{ERR_PACK(0,X509V3_F_V2I_BASIC_CONSTRAINTS,0), "V2I_BASIC_CONSTRAINTS"}, 94{ERR_PACK(0,X509V3_F_V2I_BASIC_CONSTRAINTS,0), "V2I_BASIC_CONSTRAINTS"},
@@ -102,6 +104,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
102{ERR_PACK(0,X509V3_F_X509V3_EXT_I2D,0), "X509V3_EXT_i2d"}, 104{ERR_PACK(0,X509V3_F_X509V3_EXT_I2D,0), "X509V3_EXT_i2d"},
103{ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"}, 105{ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"},
104{ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"}, 106{ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"},
107{ERR_PACK(0,X509V3_F_X509_PURPOSE_ADD,0), "X509_PURPOSE_add"},
105{0,NULL} 108{0,NULL}
106 }; 109 };
107 110
@@ -132,6 +135,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
132{X509V3_R_INVALID_OPTION ,"invalid option"}, 135{X509V3_R_INVALID_OPTION ,"invalid option"},
133{X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"}, 136{X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"},
134{X509V3_R_INVALID_SECTION ,"invalid section"}, 137{X509V3_R_INVALID_SECTION ,"invalid section"},
138{X509V3_R_INVALID_SYNTAX ,"invalid syntax"},
135{X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"}, 139{X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"},
136{X509V3_R_MISSING_VALUE ,"missing value"}, 140{X509V3_R_MISSING_VALUE ,"missing value"},
137{X509V3_R_NEED_ORGANIZATION_AND_NUMBERS ,"need organization and numbers"}, 141{X509V3_R_NEED_ORGANIZATION_AND_NUMBERS ,"need organization and numbers"},
diff --git a/src/lib/libssl/src/crypto/x509v3/x509v3.h b/src/lib/libssl/src/crypto/x509v3/x509v3.h
index 4eb04a5a89..fe01755797 100644
--- a/src/lib/libssl/src/crypto/x509v3/x509v3.h
+++ b/src/lib/libssl/src/crypto/x509v3/x509v3.h
@@ -136,12 +136,6 @@ typedef struct v3_ext_ctx X509V3_CTX;
136#define X509V3_EXT_CTX_DEP 0x2 136#define X509V3_EXT_CTX_DEP 0x2
137#define X509V3_EXT_MULTILINE 0x4 137#define X509V3_EXT_MULTILINE 0x4
138 138
139typedef struct BIT_STRING_BITNAME_st {
140int bitnum;
141const char *lname;
142const char *sname;
143} BIT_STRING_BITNAME;
144
145typedef BIT_STRING_BITNAME ENUMERATED_NAMES; 139typedef BIT_STRING_BITNAME ENUMERATED_NAMES;
146 140
147typedef struct BASIC_CONSTRAINTS_st { 141typedef struct BASIC_CONSTRAINTS_st {
@@ -155,6 +149,11 @@ ASN1_GENERALIZEDTIME *notBefore;
155ASN1_GENERALIZEDTIME *notAfter; 149ASN1_GENERALIZEDTIME *notAfter;
156} PKEY_USAGE_PERIOD; 150} PKEY_USAGE_PERIOD;
157 151
152typedef struct otherName_st {
153ASN1_OBJECT *type_id;
154ASN1_TYPE *value;
155} OTHERNAME;
156
158typedef struct GENERAL_NAME_st { 157typedef struct GENERAL_NAME_st {
159 158
160#define GEN_OTHERNAME (0|V_ASN1_CONTEXT_SPECIFIC) 159#define GEN_OTHERNAME (0|V_ASN1_CONTEXT_SPECIFIC)
@@ -174,17 +173,26 @@ union {
174 ASN1_OCTET_STRING *ip; /* iPAddress */ 173 ASN1_OCTET_STRING *ip; /* iPAddress */
175 X509_NAME *dirn; /* dirn */ 174 X509_NAME *dirn; /* dirn */
176 ASN1_OBJECT *rid; /* registeredID */ 175 ASN1_OBJECT *rid; /* registeredID */
177 ASN1_TYPE *other; /* otherName, ediPartyName, x400Address */ 176 OTHERNAME *otherName; /* otherName */
177 ASN1_TYPE *other; /* ediPartyName, x400Address */
178} d; 178} d;
179} GENERAL_NAME; 179} GENERAL_NAME;
180 180
181typedef struct ACCESS_DESCRIPTION_st {
182ASN1_OBJECT *method;
183GENERAL_NAME *location;
184} ACCESS_DESCRIPTION;
185
181DECLARE_STACK_OF(GENERAL_NAME) 186DECLARE_STACK_OF(GENERAL_NAME)
182DECLARE_ASN1_SET_OF(GENERAL_NAME) 187DECLARE_ASN1_SET_OF(GENERAL_NAME)
183 188
189DECLARE_STACK_OF(ACCESS_DESCRIPTION)
190DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)
191
184typedef struct DIST_POINT_NAME_st { 192typedef struct DIST_POINT_NAME_st {
185/* NB: this is a CHOICE type and only one of these should be set */ 193/* NB: this is a CHOICE type and only one of these should be set */
186STACK_OF(GENERAL_NAME) *fullname; 194STACK_OF(GENERAL_NAME) *fullname;
187X509_NAME *relativename; 195STACK_OF(X509_NAME_ENTRY) *relativename;
188} DIST_POINT_NAME; 196} DIST_POINT_NAME;
189 197
190typedef struct DIST_POINT_st { 198typedef struct DIST_POINT_st {
@@ -255,8 +263,8 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
255#define X509V3_set_ctx_nodb(ctx) ctx->db = NULL; 263#define X509V3_set_ctx_nodb(ctx) ctx->db = NULL;
256 264
257#define EXT_BITSTRING(nid, table) { nid, 0, \ 265#define EXT_BITSTRING(nid, table) { nid, 0, \
258 (X509V3_EXT_NEW)asn1_bit_string_new, \ 266 (X509V3_EXT_NEW)ASN1_BIT_STRING_new, \
259 (X509V3_EXT_FREE)ASN1_STRING_free, \ 267 (X509V3_EXT_FREE)ASN1_BIT_STRING_free, \
260 (X509V3_EXT_D2I)d2i_ASN1_BIT_STRING, \ 268 (X509V3_EXT_D2I)d2i_ASN1_BIT_STRING, \
261 (X509V3_EXT_I2D)i2d_ASN1_BIT_STRING, \ 269 (X509V3_EXT_I2D)i2d_ASN1_BIT_STRING, \
262 NULL, NULL, \ 270 NULL, NULL, \
@@ -266,8 +274,8 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
266 (char *)table} 274 (char *)table}
267 275
268#define EXT_IA5STRING(nid) { nid, 0, \ 276#define EXT_IA5STRING(nid) { nid, 0, \
269 (X509V3_EXT_NEW)ia5string_new, \ 277 (X509V3_EXT_NEW)ASN1_IA5STRING_new, \
270 (X509V3_EXT_FREE)ASN1_STRING_free, \ 278 (X509V3_EXT_FREE)ASN1_IA5STRING_free, \
271 (X509V3_EXT_D2I)d2i_ASN1_IA5STRING, \ 279 (X509V3_EXT_D2I)d2i_ASN1_IA5STRING, \
272 (X509V3_EXT_I2D)i2d_ASN1_IA5STRING, \ 280 (X509V3_EXT_I2D)i2d_ASN1_IA5STRING, \
273 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ 281 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
@@ -279,6 +287,69 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
279 NULL, NULL, NULL, NULL, \ 287 NULL, NULL, NULL, NULL, \
280 NULL} 288 NULL}
281 289
290
291/* X509_PURPOSE stuff */
292
293#define EXFLAG_BCONS 0x1
294#define EXFLAG_KUSAGE 0x2
295#define EXFLAG_XKUSAGE 0x4
296#define EXFLAG_NSCERT 0x8
297
298#define EXFLAG_CA 0x10
299#define EXFLAG_SS 0x20
300#define EXFLAG_V1 0x40
301#define EXFLAG_INVALID 0x80
302#define EXFLAG_SET 0x100
303
304#define KU_DIGITAL_SIGNATURE 0x0080
305#define KU_NON_REPUDIATION 0x0040
306#define KU_KEY_ENCIPHERMENT 0x0020
307#define KU_DATA_ENCIPHERMENT 0x0010
308#define KU_KEY_AGREEMENT 0x0008
309#define KU_KEY_CERT_SIGN 0x0004
310#define KU_CRL_SIGN 0x0002
311#define KU_ENCIPHER_ONLY 0x0001
312#define KU_DECIPHER_ONLY 0x8000
313
314#define NS_SSL_CLIENT 0x80
315#define NS_SSL_SERVER 0x40
316#define NS_SMIME 0x20
317#define NS_OBJSIGN 0x10
318#define NS_SSL_CA 0x04
319#define NS_SMIME_CA 0x02
320#define NS_OBJSIGN_CA 0x01
321
322#define XKU_SSL_SERVER 0x1
323#define XKU_SSL_CLIENT 0x2
324#define XKU_SMIME 0x4
325#define XKU_CODE_SIGN 0x8
326#define XKU_SGC 0x10
327
328#define X509_PURPOSE_DYNAMIC 0x1
329#define X509_PURPOSE_DYNAMIC_NAME 0x2
330
331typedef struct x509_purpose_st {
332 int purpose;
333 int trust; /* Default trust ID */
334 int flags;
335 int (*check_purpose)(struct x509_purpose_st *, X509 *, int);
336 char *name;
337 char *sname;
338 void *usr_data;
339} X509_PURPOSE;
340
341#define X509_PURPOSE_SSL_CLIENT 1
342#define X509_PURPOSE_SSL_SERVER 2
343#define X509_PURPOSE_NS_SSL_SERVER 3
344#define X509_PURPOSE_SMIME_SIGN 4
345#define X509_PURPOSE_SMIME_ENCRYPT 5
346#define X509_PURPOSE_CRL_SIGN 6
347
348#define X509_PURPOSE_MIN 1
349#define X509_PURPOSE_MAX 6
350
351DECLARE_STACK_OF(X509_PURPOSE)
352
282void ERR_load_X509V3_strings(void); 353void ERR_load_X509V3_strings(void);
283int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp); 354int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp);
284BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, unsigned char **pp, long length); 355BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, unsigned char **pp, long length);
@@ -328,6 +399,11 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
328STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, 399STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
329 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 400 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
330 401
402int i2d_OTHERNAME(OTHERNAME *a, unsigned char **pp);
403OTHERNAME *OTHERNAME_new(void);
404OTHERNAME *d2i_OTHERNAME(OTHERNAME **a, unsigned char **pp, long length);
405void OTHERNAME_free(OTHERNAME *a);
406
331char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); 407char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
332ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 408ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
333 409
@@ -380,12 +456,27 @@ void DIST_POINT_NAME_free(DIST_POINT_NAME *a);
380DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, 456DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
381 long length); 457 long length);
382 458
459int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **pp);
460ACCESS_DESCRIPTION *ACCESS_DESCRIPTION_new(void);
461void ACCESS_DESCRIPTION_free(ACCESS_DESCRIPTION *a);
462ACCESS_DESCRIPTION *d2i_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION **a, unsigned char **pp,
463 long length);
464
465STACK_OF(ACCESS_DESCRIPTION) *AUTHORITY_INFO_ACCESS_new(void);
466void AUTHORITY_INFO_ACCESS_free(STACK_OF(ACCESS_DESCRIPTION) *a);
467STACK_OF(ACCESS_DESCRIPTION) *d2i_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) **a,
468 unsigned char **pp, long length);
469int i2d_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) *a, unsigned char **pp);
470
471
472
383#ifdef HEADER_CONF_H 473#ifdef HEADER_CONF_H
384GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf); 474GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf);
385void X509V3_conf_free(CONF_VALUE *val); 475void X509V3_conf_free(CONF_VALUE *val);
386X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); 476X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value);
387X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); 477X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value);
388int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); 478int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert);
479int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
389int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); 480int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
390int X509V3_add_value_bool_nf(char *name, int asn1_bool, 481int X509V3_add_value_bool_nf(char *name, int asn1_bool,
391 STACK_OF(CONF_VALUE) **extlist); 482 STACK_OF(CONF_VALUE) **extlist);
@@ -423,6 +514,8 @@ X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
423int X509V3_add_standard_extensions(void); 514int X509V3_add_standard_extensions(void);
424STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line); 515STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line);
425void *X509V3_EXT_d2i(X509_EXTENSION *ext); 516void *X509V3_EXT_d2i(X509_EXTENSION *ext);
517void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
518
426X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 519X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
427 520
428char *hex_to_string(unsigned char *buffer, long len); 521char *hex_to_string(unsigned char *buffer, long len);
@@ -434,6 +527,20 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
434int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent); 527int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent);
435int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); 528int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
436 529
530int X509_check_purpose(X509 *x, int id, int ca);
531int X509_PURPOSE_get_count(void);
532X509_PURPOSE * X509_PURPOSE_get0(int idx);
533int X509_PURPOSE_get_by_sname(char *sname);
534int X509_PURPOSE_get_by_id(int id);
535int X509_PURPOSE_add(int id, int trust, int flags,
536 int (*ck)(X509_PURPOSE *, X509 *, int),
537 char *name, char *sname, void *arg);
538char *X509_PURPOSE_get0_name(X509_PURPOSE *xp);
539char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);
540int X509_PURPOSE_get_trust(X509_PURPOSE *xp);
541void X509_PURPOSE_cleanup(void);
542int X509_PURPOSE_get_id(X509_PURPOSE *);
543
437/* BEGIN ERROR CODES */ 544/* BEGIN ERROR CODES */
438/* The following lines are auto generated by the script mkerr.pl. Any changes 545/* The following lines are auto generated by the script mkerr.pl. Any changes
439 * made after this point may be overwritten when the script is next run. 546 * made after this point may be overwritten when the script is next run.
@@ -449,6 +556,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
449#define X509V3_F_HEX_TO_STRING 111 556#define X509V3_F_HEX_TO_STRING 111
450#define X509V3_F_I2S_ASN1_ENUMERATED 121 557#define X509V3_F_I2S_ASN1_ENUMERATED 121
451#define X509V3_F_I2S_ASN1_INTEGER 120 558#define X509V3_F_I2S_ASN1_INTEGER 120
559#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138
452#define X509V3_F_NOTICE_SECTION 132 560#define X509V3_F_NOTICE_SECTION 132
453#define X509V3_F_NREF_NOS 133 561#define X509V3_F_NREF_NOS 133
454#define X509V3_F_POLICY_SECTION 131 562#define X509V3_F_POLICY_SECTION 131
@@ -464,6 +572,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
464#define X509V3_F_SXNET_ADD_ID_ULONG 127 572#define X509V3_F_SXNET_ADD_ID_ULONG 127
465#define X509V3_F_SXNET_GET_ID_ASC 128 573#define X509V3_F_SXNET_GET_ID_ASC 128
466#define X509V3_F_SXNET_GET_ID_ULONG 129 574#define X509V3_F_SXNET_GET_ID_ULONG 129
575#define X509V3_F_V2I_ACCESS_DESCRIPTION 139
467#define X509V3_F_V2I_ASN1_BIT_STRING 101 576#define X509V3_F_V2I_ASN1_BIT_STRING 101
468#define X509V3_F_V2I_AUTHORITY_KEYID 119 577#define X509V3_F_V2I_AUTHORITY_KEYID 119
469#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 578#define X509V3_F_V2I_BASIC_CONSTRAINTS 102
@@ -479,6 +588,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
479#define X509V3_F_X509V3_EXT_I2D 136 588#define X509V3_F_X509V3_EXT_I2D 136
480#define X509V3_F_X509V3_GET_VALUE_BOOL 110 589#define X509V3_F_X509V3_GET_VALUE_BOOL 110
481#define X509V3_F_X509V3_PARSE_LIST 109 590#define X509V3_F_X509V3_PARSE_LIST 109
591#define X509V3_F_X509_PURPOSE_ADD 137
482 592
483/* Reason codes. */ 593/* Reason codes. */
484#define X509V3_R_BAD_IP_ADDRESS 118 594#define X509V3_R_BAD_IP_ADDRESS 118
@@ -506,6 +616,7 @@ int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
506#define X509V3_R_INVALID_OPTION 138 616#define X509V3_R_INVALID_OPTION 138
507#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 617#define X509V3_R_INVALID_POLICY_IDENTIFIER 134
508#define X509V3_R_INVALID_SECTION 135 618#define X509V3_R_INVALID_SECTION 135
619#define X509V3_R_INVALID_SYNTAX 143
509#define X509V3_R_ISSUER_DECODE_ERROR 126 620#define X509V3_R_ISSUER_DECODE_ERROR 126
510#define X509V3_R_MISSING_VALUE 124 621#define X509V3_R_MISSING_VALUE 124
511#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 622#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142
diff --git a/src/lib/libssl/src/demos/bio/saccept.c b/src/lib/libssl/src/demos/bio/saccept.c
index 2f2dc985fe..933d6699ee 100644
--- a/src/lib/libssl/src/demos/bio/saccept.c
+++ b/src/lib/libssl/src/demos/bio/saccept.c
@@ -46,7 +46,7 @@ char *argv[];
46 SSL_load_error_strings(); 46 SSL_load_error_strings();
47 47
48 /* Add ciphers and message digests */ 48 /* Add ciphers and message digests */
49 SSLeay_add_ssl_algorithms(); 49 OpenSSL_add_ssl_algorithms();
50 50
51 ctx=SSL_CTX_new(SSLv23_server_method()); 51 ctx=SSL_CTX_new(SSLv23_server_method());
52 if (!SSL_CTX_use_certificate_file(ctx,CERT_FILE,SSL_FILETYPE_PEM)) 52 if (!SSL_CTX_use_certificate_file(ctx,CERT_FILE,SSL_FILETYPE_PEM))
diff --git a/src/lib/libssl/src/demos/bio/sconnect.c b/src/lib/libssl/src/demos/bio/sconnect.c
index 59fab1985e..87b380b258 100644
--- a/src/lib/libssl/src/demos/bio/sconnect.c
+++ b/src/lib/libssl/src/demos/bio/sconnect.c
@@ -36,7 +36,7 @@ char *argv[];
36 SSL_load_error_strings(); 36 SSL_load_error_strings();
37 37
38 /* Setup all the global SSL stuff */ 38 /* Setup all the global SSL stuff */
39 SSLeay_add_ssl_algorithms(); 39 OpenSSL_add_ssl_algorithms();
40 ssl_ctx=SSL_CTX_new(SSLv23_client_method()); 40 ssl_ctx=SSL_CTX_new(SSLv23_client_method());
41 41
42 /* Lets make a SSL structure */ 42 /* Lets make a SSL structure */
diff --git a/src/lib/libssl/src/demos/selfsign.c b/src/lib/libssl/src/demos/selfsign.c
index f4a8369352..68904c611e 100644
--- a/src/lib/libssl/src/demos/selfsign.c
+++ b/src/lib/libssl/src/demos/selfsign.c
@@ -18,26 +18,27 @@ int main()
18 18
19 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 19 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
20 20
21 X509V3_add_standard_extensions(); 21 bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
22
23 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
24 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE);
25 22
26 mkit(&x509,&pkey,512,0,365); 23 mkit(&x509,&pkey,512,0,365);
27 24
28 RSA_print_fp(stdout,pkey->pkey.rsa,0); 25 RSA_print_fp(stdout,pkey->pkey.rsa,0);
29 X509_print_fp(stdout,x509); 26 X509_print_fp(stdout,x509);
30 27
31 PEM_write_RSAPrivateKey(stdout,pkey->pkey.rsa,NULL,NULL,0,NULL); 28 PEM_write_PrivateKey(stdout,pkey,NULL,NULL,0,NULL, NULL);
32 PEM_write_X509(stdout,x509); 29 PEM_write_X509(stdout,x509);
33 30
34 X509_free(x509); 31 X509_free(x509);
35 EVP_PKEY_free(pkey); 32 EVP_PKEY_free(pkey);
36 BIO_free(bio_err);
37 33
34#ifdef CUSTOM_EXT
35 /* Only needed if we add objects or custom extensions */
38 X509V3_EXT_cleanup(); 36 X509V3_EXT_cleanup();
37 OBJ_cleanup();
38#endif
39 39
40 CRYPTO_mem_leaks(bio_err); 40 CRYPTO_mem_leaks(bio_err);
41 BIO_free(bio_err);
41 return(0); 42 return(0);
42 } 43 }
43 44
@@ -111,25 +112,19 @@ int days;
111 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days); 112 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days);
112 X509_set_pubkey(x,pk); 113 X509_set_pubkey(x,pk);
113 114
114 name=X509_NAME_new(); 115 name=X509_get_subject_name(x);
115
116 ne=X509_NAME_ENTRY_create_by_NID(NULL,NID_countryName,
117 V_ASN1_APP_CHOOSE,"AU",-1);
118 X509_NAME_add_entry(name,ne,0,0);
119
120 X509_NAME_ENTRY_create_by_NID(&ne,NID_commonName,
121 V_ASN1_APP_CHOOSE,"Eric Young",-1);
122 X509_NAME_add_entry(name,ne,1,0);
123 116
124 /* finished with structure */ 117 /* This function creates and adds the entry, working out the
125 X509_NAME_ENTRY_free(ne); 118 * correct string type and performing checks on its length.
119 * Normally we'd check the return value for errors...
120 */
121 X509_NAME_add_entry_by_txt(name,"C",
122 MBSTRING_ASC, "UK", -1, -1, 0);
123 X509_NAME_add_entry_by_txt(name,"CN",
124 MBSTRING_ASC, "OpenSSL Group", -1, -1, 0);
126 125
127 X509_set_subject_name(x,name);
128 X509_set_issuer_name(x,name); 126 X509_set_issuer_name(x,name);
129 127
130 /* finished with structure */
131 X509_NAME_free(name);
132
133 /* Add extension using V3 code: we can set the config file as NULL 128 /* Add extension using V3 code: we can set the config file as NULL
134 * because we wont reference any other sections. We can also set 129 * because we wont reference any other sections. We can also set
135 * the context to NULL because none of these extensions below will need 130 * the context to NULL because none of these extensions below will need
@@ -138,15 +133,18 @@ int days;
138 133
139 ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_cert_type, "server"); 134 ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_cert_type, "server");
140 X509_add_ext(x,ex,-1); 135 X509_add_ext(x,ex,-1);
136 X509_EXTENSION_free(ex);
141 137
142 ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_comment, 138 ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_comment,
143 "example comment extension"); 139 "example comment extension");
144 X509_add_ext(x,ex,-1); 140 X509_add_ext(x,ex,-1);
141 X509_EXTENSION_free(ex);
145 142
146 ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_ssl_server_name, 143 ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_ssl_server_name,
147 "www.openssl.org"); 144 "www.openssl.org");
148 145
149 X509_add_ext(x,ex,-1); 146 X509_add_ext(x,ex,-1);
147 X509_EXTENSION_free(ex);
150 148
151#if 0 149#if 0
152 /* might want something like this too.... */ 150 /* might want something like this too.... */
@@ -155,6 +153,20 @@ int days;
155 153
156 154
157 X509_add_ext(x,ex,-1); 155 X509_add_ext(x,ex,-1);
156 X509_EXTENSION_free(ex);
157#endif
158
159#ifdef CUSTOM_EXT
160 /* Maybe even add our own extension based on existing */
161 {
162 int nid;
163 nid = OBJ_create("1.2.3.4", "MyAlias", "My Test Alias Extension");
164 X509V3_EXT_add_alias(nid, NID_netscape_comment);
165 ex = X509V3_EXT_conf_nid(NULL, NULL, nid,
166 "example comment alias");
167 X509_add_ext(x,ex,-1);
168 X509_EXTENSION_free(ex);
169 }
158#endif 170#endif
159 171
160 if (!X509_sign(x,pk,EVP_md5())) 172 if (!X509_sign(x,pk,EVP_md5()))
diff --git a/src/lib/libssl/src/demos/ssl/cli.cpp b/src/lib/libssl/src/demos/ssl/cli.cpp
index b3d726961f..daea2bd9c7 100644
--- a/src/lib/libssl/src/demos/ssl/cli.cpp
+++ b/src/lib/libssl/src/demos/ssl/cli.cpp
@@ -14,7 +14,6 @@
14#include <arpa/inet.h> 14#include <arpa/inet.h>
15#include <netdb.h> 15#include <netdb.h>
16 16
17#include "rsa.h" /* SSLeay stuff */
18#include <openssl/crypto.h> 17#include <openssl/crypto.h>
19#include <openssl/x509.h> 18#include <openssl/x509.h>
20#include <openssl/pem.h> 19#include <openssl/pem.h>
diff --git a/src/lib/libssl/src/dep/crypto.txt b/src/lib/libssl/src/dep/crypto.txt
index 9e5144fec6..e69de29bb2 100644
--- a/src/lib/libssl/src/dep/crypto.txt
+++ b/src/lib/libssl/src/dep/crypto.txt
@@ -1,1043 +0,0 @@
1ASN1_BIT_STRING_asn1_meth
2ASN1_BIT_STRING_get_bit
3ASN1_BIT_STRING_set_bit
4ASN1_HEADER_free
5ASN1_HEADER_new
6ASN1_IA5STRING_asn1_meth
7ASN1_INTEGER_get
8ASN1_INTEGER_set
9ASN1_INTEGER_to_BN
10ASN1_OBJECT_create
11ASN1_OBJECT_free
12ASN1_OBJECT_new
13ASN1_PRINTABLE_type
14ASN1_STRING_cmp
15ASN1_STRING_dup
16ASN1_STRING_free
17ASN1_STRING_new
18ASN1_STRING_print
19ASN1_STRING_set
20ASN1_STRING_type_new
21ASN1_TYPE_free
22ASN1_TYPE_get
23ASN1_TYPE_new
24ASN1_TYPE_set
25ASN1_UNIVERSALSTRING_to_string
26ASN1_UTCTIME_check
27ASN1_UTCTIME_print
28ASN1_UTCTIME_set
29ASN1_check_infinite_end
30ASN1_d2i_bio
31ASN1_d2i_fp
32ASN1_digest
33ASN1_dup
34ASN1_get_object
35ASN1_i2d_bio
36ASN1_i2d_fp
37ASN1_object_size
38ASN1_parse
39ASN1_put_object
40ASN1_sign
41ASN1_verify
42BF_cbc_encrypt
43BF_cfb64_encrypt
44BF_decrypt
45BF_ecb_encrypt
46BF_encrypt
47BF_ofb64_encrypt
48BF_options
49BF_set_key
50BIO_ACCEPT_free
51BIO_ACCEPT_new
52BIO_CONNECT_free
53BIO_CONNECT_new
54BIO_accept
55BIO_copy_next_retry
56BIO_ctrl
57BIO_ctrl_int
58BIO_debug_callback
59BIO_dump
60BIO_dup_chain
61BIO_f_base64
62BIO_f_buffer
63BIO_f_cipher
64BIO_f_md
65BIO_f_nbio_test
66BIO_f_null
67BIO_f_proxy_server
68BIO_fd_non_fatal_error
69BIO_fd_should_retry
70BIO_find_type
71BIO_free
72BIO_free_all
73BIO_get_accept_socket
74BIO_get_ex_data
75BIO_get_ex_new_index
76BIO_get_filter_bio
77BIO_get_host_ip
78BIO_get_port
79BIO_get_retry_BIO
80BIO_get_retry_reason
81BIO_gethostbyname
82BIO_gets
83BIO_ghbn_ctrl
84BIO_new
85BIO_new_accept
86BIO_new_connect
87BIO_new_fd
88BIO_new_file
89BIO_new_fp
90BIO_new_socket
91BIO_pop
92BIO_printf
93BIO_ptr_ctrl
94BIO_push
95BIO_puts
96BIO_read
97BIO_s_accept
98BIO_s_connect
99BIO_s_fd
100BIO_s_file
101BIO_s_mem
102BIO_s_null
103BIO_s_proxy_client
104BIO_s_socket
105BIO_set
106BIO_set_cipher
107BIO_set_ex_data
108BIO_set_tcp_ndelay
109BIO_sock_cleanup
110BIO_sock_error
111BIO_sock_init
112BIO_sock_non_fatal_error
113BIO_sock_should_retry
114BIO_socket_ioctl
115BIO_write
116BN_BLINDING_convert
117BN_BLINDING_free
118BN_BLINDING_invert
119BN_BLINDING_new
120BN_BLINDING_update
121BN_CTX_free
122BN_CTX_new
123BN_MONT_CTX_free
124BN_MONT_CTX_new
125BN_MONT_CTX_set
126BN_add
127BN_add_word
128BN_bin2bn
129BN_bn2bin
130BN_bn2dec
131BN_bn2hex
132BN_bn2mpi
133BN_clear
134BN_clear_bit
135BN_clear_free
136BN_cmp
137BN_copy
138BN_dec2bn
139BN_div
140BN_div_word
141BN_dup
142BN_exp
143BN_free
144BN_from_montgomery
145BN_gcd
146BN_generate_prime
147BN_get_word
148BN_hex2bn
149BN_is_bit_set
150BN_is_prime
151BN_lshift
152BN_lshift1
153BN_mask_bits
154BN_mod
155BN_mod_exp
156BN_mod_exp_mont
157BN_mod_exp_recp
158BN_mod_exp_simple
159BN_mod_inverse
160BN_mod_mul
161BN_mod_mul_montgomery
162BN_mod_mul_reciprocal
163BN_mod_word
164BN_mpi2bn
165BN_mul
166BN_mul_word
167BN_new
168BN_num_bits
169BN_num_bits_word
170BN_options
171BN_print
172BN_print_fp
173BN_rand
174BN_reciprocal
175BN_rshift
176BN_rshift1
177BN_set_bit
178BN_set_word
179BN_sqr
180BN_sub
181BN_sub_word
182BN_to_ASN1_INTEGER
183BN_ucmp
184BN_value_one
185BUF_MEM_free
186BUF_MEM_grow
187BUF_MEM_new
188BUF_strdup
189CAST_cbc_encrypt
190CAST_cfb64_encrypt
191CAST_decrypt
192CAST_ecb_encrypt
193CAST_encrypt
194CAST_ofb64_encrypt
195CAST_set_key
196CONF_free
197CONF_get_number
198CONF_get_section
199CONF_get_string
200CONF_load
201CRYPTO_add_lock
202CRYPTO_dbg_free
203CRYPTO_dbg_malloc
204CRYPTO_dbg_realloc
205CRYPTO_dbg_remalloc
206CRYPTO_dup_ex_data
207CRYPTO_free
208CRYPTO_free_ex_data
209CRYPTO_get_add_lock_callback
210CRYPTO_get_ex_data
211CRYPTO_get_ex_new_index
212CRYPTO_get_id_callback
213CRYPTO_get_lock_name
214CRYPTO_get_locking_callback
215CRYPTO_get_mem_functions
216CRYPTO_get_new_lockid
217CRYPTO_lock
218CRYPTO_malloc
219CRYPTO_mem_ctrl
220CRYPTO_mem_leaks
221CRYPTO_mem_leaks_cb
222CRYPTO_mem_leaks_fp
223CRYPTO_new_ex_data
224CRYPTO_realloc
225CRYPTO_remalloc
226CRYPTO_set_add_lock_callback
227CRYPTO_set_ex_data
228CRYPTO_set_id_callback
229CRYPTO_set_locking_callback
230CRYPTO_set_mem_functions
231CRYPTO_thread_id
232DH_check
233DH_compute_key
234DH_free
235DH_generate_key
236DH_generate_parameters
237DH_new
238DH_size
239DHparams_print
240DHparams_print_fp
241DSA_free
242DSA_generate_key
243DSA_generate_parameters
244DSA_is_prime
245DSA_new
246DSA_print
247DSA_print_fp
248DSA_sign
249DSA_sign_setup
250DSA_size
251DSA_verify
252DSAparams_print
253DSAparams_print_fp
254ERR_clear_error
255ERR_error_string
256ERR_free_strings
257ERR_func_error_string
258ERR_get_err_state_table
259ERR_get_error
260ERR_get_error_line
261ERR_get_next_error_library
262ERR_get_state
263ERR_get_string_table
264ERR_lib_error_string
265ERR_load_ASN1_strings
266ERR_load_BIO_strings
267ERR_load_BN_strings
268ERR_load_BUF_strings
269ERR_load_CONF_strings
270ERR_load_CRYPTO_strings
271ERR_load_DH_strings
272ERR_load_DSA_strings
273ERR_load_ERR_strings
274ERR_load_EVP_strings
275ERR_load_OBJ_strings
276ERR_load_PEM_strings
277ERR_load_PKCS7_strings
278ERR_load_PROXY_strings
279ERR_load_RSA_strings
280ERR_load_X509_strings
281ERR_load_crypto_strings
282ERR_load_strings
283ERR_peek_error
284ERR_peek_error_line
285ERR_print_errors
286ERR_print_errors_fp
287ERR_put_error
288ERR_reason_error_string
289ERR_remove_state
290EVP_BytesToKey
291EVP_CIPHER_CTX_cleanup
292EVP_CIPHER_CTX_init
293EVP_CipherFinal
294EVP_CipherInit
295EVP_CipherUpdate
296EVP_DecodeBlock
297EVP_DecodeFinal
298EVP_DecodeInit
299EVP_DecodeUpdate
300EVP_DecryptFinal
301EVP_DecryptInit
302EVP_DecryptUpdate
303EVP_DigestFinal
304EVP_DigestInit
305EVP_DigestUpdate
306EVP_EncodeBlock
307EVP_EncodeFinal
308EVP_EncodeInit
309EVP_EncodeUpdate
310EVP_EncryptFinal
311EVP_EncryptInit
312EVP_EncryptUpdate
313EVP_OpenFinal
314EVP_OpenInit
315EVP_PKEY_assign
316EVP_PKEY_bits
317EVP_PKEY_cmp_parameters
318EVP_PKEY_copy_parameters
319EVP_PKEY_free
320EVP_PKEY_missing_parameters
321EVP_PKEY_new
322EVP_PKEY_save_parameters
323EVP_PKEY_size
324EVP_PKEY_type
325EVP_SealFinal
326EVP_SealInit
327EVP_SignFinal
328EVP_VerifyFinal
329EVP_add_alias
330EVP_add_cipher
331EVP_add_digest
332EVP_bf_cbc
333EVP_bf_cfb
334EVP_bf_ecb
335EVP_bf_ofb
336EVP_cast5_cbc
337EVP_cast5_cfb
338EVP_cast5_ecb
339EVP_cast5_ofb
340EVP_cleanup
341EVP_delete_alias
342EVP_des_cbc
343EVP_des_cfb
344EVP_des_ecb
345EVP_des_ede
346EVP_des_ede3
347EVP_des_ede3_cbc
348EVP_des_ede3_cfb
349EVP_des_ede3_ofb
350EVP_des_ede_cbc
351EVP_des_ede_cfb
352EVP_des_ede_ofb
353EVP_des_ofb
354EVP_desx_cbc
355EVP_dss
356EVP_dss1
357EVP_enc_null
358EVP_get_cipherbyname
359EVP_get_digestbyname
360EVP_get_pw_prompt
361EVP_idea_cbc
362EVP_idea_cfb
363EVP_idea_ecb
364EVP_idea_ofb
365EVP_md2
366EVP_md5
367EVP_md_null
368EVP_mdc2
369EVP_rc2_40_cbc
370EVP_rc2_cbc
371EVP_rc2_cfb
372EVP_rc2_ecb
373EVP_rc2_ofb
374EVP_rc4
375EVP_rc4_40
376EVP_read_pw_string
377EVP_set_pw_prompt
378EVP_sha
379EVP_sha1
380HMAC
381HMAC_Final
382HMAC_Init
383HMAC_Update
384HMAC_cleanup
385MD2
386MD2_Final
387MD2_Init
388MD2_Update
389MD2_options
390MD5
391MD5_Final
392MD5_Init
393MD5_Transform
394MD5_Update
395MDC2
396MDC2_Final
397MDC2_Init
398MDC2_Update
399NETSCAPE_SPKAC_free
400NETSCAPE_SPKAC_new
401NETSCAPE_SPKI_free
402NETSCAPE_SPKI_new
403NETSCAPE_SPKI_sign
404NETSCAPE_SPKI_verify
405OBJ_add_object
406OBJ_bsearch
407OBJ_cleanup
408OBJ_cmp
409OBJ_create
410OBJ_create_objects
411OBJ_dup
412OBJ_ln2nid
413OBJ_new_nid
414OBJ_nid2ln
415OBJ_nid2obj
416OBJ_nid2sn
417OBJ_obj2nid
418OBJ_sn2nid
419OBJ_txt2nid
420PEM_ASN1_read
421PEM_ASN1_read_bio
422PEM_ASN1_write
423PEM_ASN1_write_bio
424PEM_SealFinal
425PEM_SealInit
426PEM_SealUpdate
427PEM_SignFinal
428PEM_SignInit
429PEM_SignUpdate
430PEM_X509_INFO_read
431PEM_X509_INFO_read_bio
432PEM_X509_INFO_write_bio
433PEM_dek_info
434PEM_do_header
435PEM_get_EVP_CIPHER_INFO
436PEM_proc_type
437PEM_read
438PEM_read_DHparams
439PEM_read_DSAPrivateKey
440PEM_read_DSAparams
441PEM_read_PKCS7
442PEM_read_PrivateKey
443PEM_read_RSAPrivateKey
444PEM_read_RSAPublicKey
445PEM_read_X509
446PEM_read_X509_CRL
447PEM_read_X509_REQ
448PEM_read_bio
449PEM_read_bio_DHparams
450PEM_read_bio_DSAPrivateKey
451PEM_read_bio_DSAparams
452PEM_read_bio_PKCS7
453PEM_read_bio_PrivateKey
454PEM_read_bio_RSAPrivateKey
455PEM_read_bio_RSAPublicKey
456PEM_read_bio_X509
457PEM_read_bio_X509_CRL
458PEM_read_bio_X509_REQ
459PEM_write
460PEM_write_DHparams
461PEM_write_DSAPrivateKey
462PEM_write_DSAparams
463PEM_write_PKCS7
464PEM_write_PrivateKey
465PEM_write_RSAPrivateKey
466PEM_write_RSAPublicKey
467PEM_write_X509
468PEM_write_X509_CRL
469PEM_write_X509_REQ
470PEM_write_bio
471PEM_write_bio_DHparams
472PEM_write_bio_DSAPrivateKey
473PEM_write_bio_DSAparams
474PEM_write_bio_PKCS7
475PEM_write_bio_PrivateKey
476PEM_write_bio_RSAPrivateKey
477PEM_write_bio_RSAPublicKey
478PEM_write_bio_X509
479PEM_write_bio_X509_CRL
480PEM_write_bio_X509_REQ
481PKCS7_DIGEST_free
482PKCS7_DIGEST_new
483PKCS7_ENCRYPT_free
484PKCS7_ENCRYPT_new
485PKCS7_ENC_CONTENT_free
486PKCS7_ENC_CONTENT_new
487PKCS7_ENVELOPE_free
488PKCS7_ENVELOPE_new
489PKCS7_ISSUER_AND_SERIAL_digest
490PKCS7_ISSUER_AND_SERIAL_free
491PKCS7_ISSUER_AND_SERIAL_new
492PKCS7_RECIP_INFO_free
493PKCS7_RECIP_INFO_new
494PKCS7_SIGNED_free
495PKCS7_SIGNED_new
496PKCS7_SIGNER_INFO_free
497PKCS7_SIGNER_INFO_new
498PKCS7_SIGNER_INFO_set
499PKCS7_SIGN_ENVELOPE_free
500PKCS7_SIGN_ENVELOPE_new
501PKCS7_add_certificate
502PKCS7_add_crl
503PKCS7_add_signature
504PKCS7_add_signer
505PKCS7_cert_from_signer_info
506PKCS7_content_free
507PKCS7_content_new
508PKCS7_ctrl
509PKCS7_dataInit
510PKCS7_dataSign
511PKCS7_dataVerify
512PKCS7_dup
513PKCS7_free
514PKCS7_get_signer_info
515PKCS7_new
516PKCS7_set_content
517PKCS7_set_type
518PROXY_ENTRY_add_noproxy
519PROXY_ENTRY_clear_noproxy
520PROXY_ENTRY_free
521PROXY_ENTRY_get_noproxy
522PROXY_ENTRY_new
523PROXY_ENTRY_set_server
524PROXY_add_noproxy
525PROXY_add_server
526PROXY_check_by_host
527PROXY_check_url
528PROXY_clear_noproxy
529PROXY_free
530PROXY_get_noproxy
531PROXY_get_proxies
532PROXY_get_proxy_entry
533PROXY_load_conf
534PROXY_new
535PROXY_print
536RAND_bytes
537RAND_cleanup
538RAND_file_name
539RAND_load_file
540RAND_seed
541RAND_write_file
542RC2_cbc_encrypt
543RC2_cfb64_encrypt
544RC2_decrypt
545RC2_ecb_encrypt
546RC2_encrypt
547RC2_ofb64_encrypt
548RC2_set_key
549RC4
550RC4_options
551RC4_set_key
552RC5_32_cbc_encrypt
553RC5_32_cfb64_encrypt
554RC5_32_decrypt
555RC5_32_ecb_encrypt
556RC5_32_encrypt
557RC5_32_ofb64_encrypt
558RC5_32_set_key
559RIPEMD160
560RIPEMD160_Final
561RIPEMD160_Init
562RIPEMD160_Transform
563RIPEMD160_Update
564RSAPrivateKey_asn1_meth
565RSAPrivateKey_dup
566RSAPublicKey_dup
567RSA_PKCS1_SSLeay
568RSA_blinding_off
569RSA_blinding_on
570RSA_flags
571RSA_free
572RSA_generate_key
573RSA_get_ex_data
574RSA_get_ex_new_index
575RSA_new
576RSA_new_method
577RSA_padding_add_PKCS1_type_1
578RSA_padding_add_PKCS1_type_2
579RSA_padding_add_SSLv23
580RSA_padding_add_none
581RSA_padding_check_PKCS1_type_1
582RSA_padding_check_PKCS1_type_2
583RSA_padding_check_SSLv23
584RSA_padding_check_none
585RSA_print
586RSA_print_fp
587RSA_private_decrypt
588RSA_private_encrypt
589RSA_public_decrypt
590RSA_public_encrypt
591RSA_set_default_method
592RSA_set_ex_data
593RSA_sign
594RSA_sign_ASN1_OCTET_STRING
595RSA_size
596RSA_verify
597RSA_verify_ASN1_OCTET_STRING
598SHA
599SHA1
600SHA1_Final
601SHA1_Init
602SHA1_Transform
603SHA1_Update
604SHA_Final
605SHA_Init
606SHA_Transform
607SHA_Update
608SSLeay
609SSLeay_add_all_algorithms
610SSLeay_add_all_ciphers
611SSLeay_add_all_digests
612SSLeay_version
613TXT_DB_create_index
614TXT_DB_free
615TXT_DB_get_by_index
616TXT_DB_insert
617TXT_DB_read
618TXT_DB_write
619X509_ALGOR_free
620X509_ALGOR_new
621X509_ATTRIBUTE_free
622X509_ATTRIBUTE_new
623X509_CINF_free
624X509_CINF_new
625X509_CRL_INFO_free
626X509_CRL_INFO_new
627X509_CRL_add_ext
628X509_CRL_cmp
629X509_CRL_delete_ext
630X509_CRL_dup
631X509_CRL_free
632X509_CRL_get_ext
633X509_CRL_get_ext_by_NID
634X509_CRL_get_ext_by_OBJ
635X509_CRL_get_ext_by_critical
636X509_CRL_get_ext_count
637X509_CRL_new
638X509_CRL_sign
639X509_CRL_verify
640X509_EXTENSION_create_by_NID
641X509_EXTENSION_create_by_OBJ
642X509_EXTENSION_dup
643X509_EXTENSION_free
644X509_EXTENSION_get_critical
645X509_EXTENSION_get_data
646X509_EXTENSION_get_object
647X509_EXTENSION_new
648X509_EXTENSION_set_critical
649X509_EXTENSION_set_data
650X509_EXTENSION_set_object
651X509_INFO_free
652X509_INFO_new
653X509_LOOKUP_by_alias
654X509_LOOKUP_by_fingerprint
655X509_LOOKUP_by_issuer_serial
656X509_LOOKUP_by_subject
657X509_LOOKUP_ctrl
658X509_LOOKUP_file
659X509_LOOKUP_free
660X509_LOOKUP_hash_dir
661X509_LOOKUP_init
662X509_LOOKUP_new
663X509_LOOKUP_shutdown
664X509_NAME_ENTRY_create_by_NID
665X509_NAME_ENTRY_create_by_OBJ
666X509_NAME_ENTRY_dup
667X509_NAME_ENTRY_free
668X509_NAME_ENTRY_get_data
669X509_NAME_ENTRY_get_object
670X509_NAME_ENTRY_new
671X509_NAME_ENTRY_set_data
672X509_NAME_ENTRY_set_object
673X509_NAME_add_entry
674X509_NAME_cmp
675X509_NAME_delete_entry
676X509_NAME_digest
677X509_NAME_dup
678X509_NAME_entry_count
679X509_NAME_free
680X509_NAME_get_entry
681X509_NAME_get_index_by_NID
682X509_NAME_get_index_by_OBJ
683X509_NAME_get_text_by_NID
684X509_NAME_get_text_by_OBJ
685X509_NAME_hash
686X509_NAME_new
687X509_NAME_oneline
688X509_NAME_print
689X509_NAME_set
690X509_OBJECT_free_contents
691X509_OBJECT_retrive_by_subject
692X509_OBJECT_up_ref_count
693X509_PKEY_free
694X509_PKEY_new
695X509_PUBKEY_free
696X509_PUBKEY_get
697X509_PUBKEY_new
698X509_PUBKEY_set
699X509_REQ_INFO_free
700X509_REQ_INFO_new
701X509_REQ_dup
702X509_REQ_free
703X509_REQ_get_pubkey
704X509_REQ_new
705X509_REQ_print
706X509_REQ_print_fp
707X509_REQ_set_pubkey
708X509_REQ_set_subject_name
709X509_REQ_set_version
710X509_REQ_sign
711X509_REQ_to_X509
712X509_REQ_verify
713X509_REVOKED_add_ext
714X509_REVOKED_delete_ext
715X509_REVOKED_free
716X509_REVOKED_get_ext
717X509_REVOKED_get_ext_by_NID
718X509_REVOKED_get_ext_by_OBJ
719X509_REVOKED_get_ext_by_critical
720X509_REVOKED_get_ext_count
721X509_REVOKED_new
722X509_SIG_free
723X509_SIG_new
724X509_STORE_CTX_cleanup
725X509_STORE_CTX_get_chain
726X509_STORE_CTX_get_current_cert
727X509_STORE_CTX_get_error
728X509_STORE_CTX_get_error_depth
729X509_STORE_CTX_get_ex_data
730X509_STORE_CTX_get_ex_new_index
731X509_STORE_CTX_init
732X509_STORE_CTX_set_cert
733X509_STORE_CTX_set_chain
734X509_STORE_CTX_set_error
735X509_STORE_CTX_set_ex_data
736X509_STORE_add_cert
737X509_STORE_add_crl
738X509_STORE_add_lookup
739X509_STORE_free
740X509_STORE_get_by_subject
741X509_STORE_load_locations
742X509_STORE_new
743X509_STORE_set_default_paths
744X509_VAL_free
745X509_VAL_new
746X509_add_ext
747X509_asn1_meth
748X509_certificate_type
749X509_check_private_key
750X509_cmp_current_time
751X509_delete_ext
752X509_digest
753X509_dup
754X509_find_by_issuer_and_serial
755X509_find_by_subject
756X509_free
757X509_get_default_cert_area
758X509_get_default_cert_dir
759X509_get_default_cert_dir_env
760X509_get_default_cert_file
761X509_get_default_cert_file_env
762X509_get_default_private_dir
763X509_get_ext
764X509_get_ext_by_NID
765X509_get_ext_by_OBJ
766X509_get_ext_by_critical
767X509_get_ext_count
768X509_get_issuer_name
769X509_get_pubkey
770X509_get_pubkey_parameters
771X509_get_serialNumber
772X509_get_subject_name
773X509_gmtime_adj
774X509_issuer_and_serial_cmp
775X509_issuer_and_serial_hash
776X509_issuer_name_cmp
777X509_issuer_name_hash
778X509_load_cert_file
779X509_load_crl_file
780X509_new
781X509_print
782X509_print_fp
783X509_set_issuer_name
784X509_set_notAfter
785X509_set_notBefore
786X509_set_pubkey
787X509_set_serialNumber
788X509_set_subject_name
789X509_set_version
790X509_sign
791X509_subject_name_cmp
792X509_subject_name_hash
793X509_to_X509_REQ
794X509_verify
795X509_verify_cert
796X509_verify_cert_error_string
797X509v3_add_ext
798X509v3_add_extension
799X509v3_add_netscape_extensions
800X509v3_add_standard_extensions
801X509v3_cleanup_extensions
802X509v3_data_type_by_NID
803X509v3_data_type_by_OBJ
804X509v3_delete_ext
805X509v3_get_ext
806X509v3_get_ext_by_NID
807X509v3_get_ext_by_OBJ
808X509v3_get_ext_by_critical
809X509v3_get_ext_count
810X509v3_get_key_usage
811X509v3_pack_string
812X509v3_pack_type_by_NID
813X509v3_pack_type_by_OBJ
814X509v3_set_key_usage
815X509v3_unpack_string
816_des_crypt
817a2d_ASN1_OBJECT
818a2i_ASN1_INTEGER
819a2i_ASN1_STRING
820a2i_X509v3_key_usage
821asn1_Finish
822asn1_GetSequence
823bn_add_words
824bn_div64
825bn_expand2
826bn_mul_add_words
827bn_mul_words
828bn_qadd
829bn_qsub
830bn_sqr_words
831crypt
832d2i_ASN1_BIT_STRING
833d2i_ASN1_BOOLEAN
834d2i_ASN1_HEADER
835d2i_ASN1_IA5STRING
836d2i_ASN1_INTEGER
837d2i_ASN1_OBJECT
838d2i_ASN1_OCTET_STRING
839d2i_ASN1_PRINTABLE
840d2i_ASN1_PRINTABLESTRING
841d2i_ASN1_SET
842d2i_ASN1_T61STRING
843d2i_ASN1_TYPE
844d2i_ASN1_UTCTIME
845d2i_ASN1_bytes
846d2i_ASN1_type_bytes
847d2i_DHparams
848d2i_DSAPrivateKey
849d2i_DSAPrivateKey_bio
850d2i_DSAPrivateKey_fp
851d2i_DSAPublicKey
852d2i_DSAparams
853d2i_NETSCAPE_SPKAC
854d2i_NETSCAPE_SPKI
855d2i_Netscape_RSA
856d2i_Netscape_RSA_2
857d2i_PKCS7
858d2i_PKCS7_DIGEST
859d2i_PKCS7_ENCRYPT
860d2i_PKCS7_ENC_CONTENT
861d2i_PKCS7_ENVELOPE
862d2i_PKCS7_ISSUER_AND_SERIAL
863d2i_PKCS7_RECIP_INFO
864d2i_PKCS7_SIGNED
865d2i_PKCS7_SIGNER_INFO
866d2i_PKCS7_SIGN_ENVELOPE
867d2i_PKCS7_bio
868d2i_PKCS7_fp
869d2i_PrivateKey
870d2i_PublicKey
871d2i_RSAPrivateKey
872d2i_RSAPrivateKey_bio
873d2i_RSAPrivateKey_fp
874d2i_RSAPublicKey
875d2i_RSAPublicKey_bio
876d2i_RSAPublicKey_fp
877d2i_X509
878d2i_X509_ALGOR
879d2i_X509_ATTRIBUTE
880d2i_X509_CINF
881d2i_X509_CRL
882d2i_X509_CRL_INFO
883d2i_X509_CRL_bio
884d2i_X509_CRL_fp
885d2i_X509_EXTENSION
886d2i_X509_NAME
887d2i_X509_NAME_ENTRY
888d2i_X509_PKEY
889d2i_X509_PUBKEY
890d2i_X509_REQ
891d2i_X509_REQ_INFO
892d2i_X509_REQ_bio
893d2i_X509_REQ_fp
894d2i_X509_REVOKED
895d2i_X509_SIG
896d2i_X509_VAL
897d2i_X509_bio
898d2i_X509_fp
899des_cbc_cksum
900des_cbc_encrypt
901des_cblock_print_file
902des_cfb64_encrypt
903des_cfb_encrypt
904des_decrypt3
905des_ecb3_encrypt
906des_ecb_encrypt
907des_ede3_cbc_encrypt
908des_ede3_cfb64_encrypt
909des_ede3_ofb64_encrypt
910des_enc_read
911des_enc_write
912des_encrypt
913des_encrypt2
914des_encrypt3
915des_fcrypt
916des_is_weak_key
917des_key_sched
918des_ncbc_encrypt
919des_ofb64_encrypt
920des_ofb_encrypt
921des_options
922des_pcbc_encrypt
923des_quad_cksum
924des_random_key
925des_random_seed
926des_read_2passwords
927des_read_password
928des_read_pw
929des_read_pw_string
930des_set_key
931des_set_odd_parity
932des_string_to_2keys
933des_string_to_key
934des_xcbc_encrypt
935des_xwhite_in2out
936fcrypt_body
937i2a_ASN1_INTEGER
938i2a_ASN1_OBJECT
939i2a_ASN1_STRING
940i2a_X509v3_key_usage
941i2d_ASN1_BIT_STRING
942i2d_ASN1_BOOLEAN
943i2d_ASN1_HEADER
944i2d_ASN1_IA5STRING
945i2d_ASN1_INTEGER
946i2d_ASN1_OBJECT
947i2d_ASN1_OCTET_STRING
948i2d_ASN1_PRINTABLE
949i2d_ASN1_SET
950i2d_ASN1_TYPE
951i2d_ASN1_UTCTIME
952i2d_ASN1_bytes
953i2d_DHparams
954i2d_DSAPrivateKey
955i2d_DSAPrivateKey_bio
956i2d_DSAPrivateKey_fp
957i2d_DSAPublicKey
958i2d_DSAparams
959i2d_NETSCAPE_SPKAC
960i2d_NETSCAPE_SPKI
961i2d_Netscape_RSA
962i2d_PKCS7
963i2d_PKCS7_DIGEST
964i2d_PKCS7_ENCRYPT
965i2d_PKCS7_ENC_CONTENT
966i2d_PKCS7_ENVELOPE
967i2d_PKCS7_ISSUER_AND_SERIAL
968i2d_PKCS7_RECIP_INFO
969i2d_PKCS7_SIGNED
970i2d_PKCS7_SIGNER_INFO
971i2d_PKCS7_SIGN_ENVELOPE
972i2d_PKCS7_bio
973i2d_PKCS7_fp
974i2d_PrivateKey
975i2d_PublicKey
976i2d_RSAPrivateKey
977i2d_RSAPrivateKey_bio
978i2d_RSAPrivateKey_fp
979i2d_RSAPublicKey
980i2d_RSAPublicKey_bio
981i2d_RSAPublicKey_fp
982i2d_X509
983i2d_X509_ALGOR
984i2d_X509_ATTRIBUTE
985i2d_X509_CINF
986i2d_X509_CRL
987i2d_X509_CRL_INFO
988i2d_X509_CRL_bio
989i2d_X509_CRL_fp
990i2d_X509_EXTENSION
991i2d_X509_NAME
992i2d_X509_NAME_ENTRY
993i2d_X509_PKEY
994i2d_X509_PUBKEY
995i2d_X509_REQ
996i2d_X509_REQ_INFO
997i2d_X509_REQ_bio
998i2d_X509_REQ_fp
999i2d_X509_REVOKED
1000i2d_X509_SIG
1001i2d_X509_VAL
1002i2d_X509_bio
1003i2d_X509_fp
1004i2t_ASN1_OBJECT
1005idea_cbc_encrypt
1006idea_cfb64_encrypt
1007idea_ecb_encrypt
1008idea_encrypt
1009idea_ofb64_encrypt
1010idea_options
1011idea_set_decrypt_key
1012idea_set_encrypt_key
1013lh_delete
1014lh_doall
1015lh_doall_arg
1016lh_free
1017lh_insert
1018lh_new
1019lh_node_stats
1020lh_node_stats_bio
1021lh_node_usage_stats
1022lh_node_usage_stats_bio
1023lh_retrieve
1024lh_stats
1025lh_stats_bio
1026lh_strhash
1027ripemd160_block
1028sha1_block
1029sha_block
1030sk_delete
1031sk_delete_ptr
1032sk_dup
1033sk_find
1034sk_free
1035sk_insert
1036sk_new
1037sk_pop
1038sk_pop_free
1039sk_push
1040sk_set_cmp_func
1041sk_shift
1042sk_unshift
1043sk_zero
diff --git a/src/lib/libssl/src/dep/files b/src/lib/libssl/src/dep/files
index 85cd7a3ff9..e69de29bb2 100644
--- a/src/lib/libssl/src/dep/files
+++ b/src/lib/libssl/src/dep/files
@@ -1,566 +0,0 @@
1./e_os.h
2
3./crypto/cryptall.h CRYPTO
4./crypto/cryptlib.h CRYPTO
5./crypto/crypto.c CRYPTO
6./crypto/cversion.c CRYPTO
7./crypto/date.h CRYPTO
8./crypto/mem.c CRYPTO
9./crypto/cpt_err.c CRYPTO
10./crypto/ex_data.c CRYPTO
11./crypto/crypto.h CRYPTO
12./crypto/cryptlib.c CRYPTO
13./crypto/tmdiff.c CRYPTO
14
15./crypto/asn1/asn1.h ASN1
16./crypto/asn1/asn1_mac.h ASN1
17./crypto/asn1/asn1_err.c ASN1
18./crypto/asn1/asn1_lib.c ASN1
19./crypto/asn1/asn1_par.c ASN1
20./crypto/asn1/a_bitstr.c ASN1
21./crypto/asn1/a_bmp.c ASN1
22./crypto/asn1/a_bool.c ASN1
23./crypto/asn1/a_bytes.c ASN1
24./crypto/asn1/a_d2i_fp.c ASN1
25./crypto/asn1/a_digest.c ASN1
26./crypto/asn1/a_dup.c ASN1
27./crypto/asn1/a_hdr.c ASN1
28./crypto/asn1/a_i2d_fp.c ASN1
29./crypto/asn1/a_int.c ASN1
30./crypto/asn1/a_meth.c ASN1
31./crypto/asn1/a_object.c ASN1
32./crypto/asn1/a_octet.c ASN1
33./crypto/asn1/a_print.c ASN1
34./crypto/asn1/a_set.c ASN1
35./crypto/asn1/a_sign.c ASN1
36./crypto/asn1/a_type.c ASN1
37./crypto/asn1/a_utctm.c ASN1
38./crypto/asn1/a_verify.c ASN1
39./crypto/asn1/d2i_dhp.c ASN1
40./crypto/asn1/d2i_dsap.c ASN1
41./crypto/asn1/d2i_pr.c ASN1
42./crypto/asn1/d2i_pu.c ASN1
43./crypto/asn1/d2i_r_pr.c ASN1
44./crypto/asn1/d2i_r_pu.c ASN1
45./crypto/asn1/d2i_s_pr.c ASN1
46./crypto/asn1/d2i_s_pu.c ASN1
47./crypto/asn1/f_int.c ASN1
48./crypto/asn1/f_string.c ASN1
49./crypto/asn1/i2d_dhp.c ASN1
50./crypto/asn1/i2d_dsap.c ASN1
51./crypto/asn1/i2d_pr.c ASN1
52./crypto/asn1/i2d_pu.c ASN1
53./crypto/asn1/i2d_r_pr.c ASN1
54./crypto/asn1/i2d_r_pu.c ASN1
55./crypto/asn1/i2d_s_pr.c ASN1
56./crypto/asn1/i2d_s_pu.c ASN1
57./crypto/asn1/n_pkey.c ASN1
58./crypto/asn1/p7_dgst.c ASN1
59./crypto/asn1/p7_enc.c ASN1
60./crypto/asn1/p7_enc_c.c ASN1
61./crypto/asn1/p7_evp.c ASN1
62./crypto/asn1/p7_i_s.c ASN1
63./crypto/asn1/p7_lib.c ASN1
64./crypto/asn1/p7_recip.c ASN1
65./crypto/asn1/p7_signd.c ASN1
66./crypto/asn1/p7_signi.c ASN1
67./crypto/asn1/p7_s_e.c ASN1
68./crypto/asn1/pk.c ASN1
69./crypto/asn1/pkcs8.c ASN1
70./crypto/asn1/t_pkey.c ASN1
71./crypto/asn1/t_req.c ASN1
72./crypto/asn1/t_x509.c ASN1
73./crypto/asn1/x_algor.c ASN1
74./crypto/asn1/x_attrib.c ASN1
75./crypto/asn1/x_cinf.c ASN1
76./crypto/asn1/x_crl.c ASN1
77./crypto/asn1/x_exten.c ASN1
78./crypto/asn1/x_info.c ASN1
79./crypto/asn1/x_name.c ASN1
80./crypto/asn1/x_pkey.c ASN1
81./crypto/asn1/x_pubkey.c ASN1
82./crypto/asn1/x_req.c ASN1
83./crypto/asn1/x_sig.c ASN1
84./crypto/asn1/x_spki.c ASN1
85./crypto/asn1/x_val.c ASN1
86./crypto/asn1/x_x509.c ASN1
87
88./crypto/bf/blowfish.h BF
89./crypto/bf/bf_pi.h BF
90./crypto/bf/bf_locl.h BF
91./crypto/bf/bfspeed.c BF
92./crypto/bf/bftest.c BF
93./crypto/bf/bf_cbc.c BF
94./crypto/bf/bf_cfb64.c BF
95./crypto/bf/bf_ecb.c BF
96./crypto/bf/bf_enc.c BF
97./crypto/bf/bf_ofb64.c BF
98./crypto/bf/bf_opts.c BF
99./crypto/bf/bf_skey.c BF
100
101./crypto/bio/bio.h BIO
102./crypto/bio/bf_buff.c BIO
103./crypto/bio/bf_nbio.c BIO
104./crypto/bio/bf_null.c BIO
105./crypto/bio/bio_cb.c BIO
106./crypto/bio/bio_err.c BIO
107./crypto/bio/bio_lib.c BIO
108./crypto/bio/bss_acpt.c BIO
109./crypto/bio/bss_conn.c BIO
110./crypto/bio/bss_fd.c BIO
111./crypto/bio/bss_file.c BIO
112./crypto/bio/bss_mem.c BIO
113./crypto/bio/bss_null.c BIO
114./crypto/bio/bss_rtcp.c BIO
115./crypto/bio/bss_sock.c BIO
116./crypto/bio/b_dump.c BIO
117./crypto/bio/b_print.c BIO
118./crypto/bio/b_sock.c BIO
119
120./crypto/bn/bn.h BN
121./crypto/bn/bn_lcl.h BN
122./crypto/bn/bn_prime.h BN
123./crypto/bn/bnspeed.c BN
124./crypto/bn/bntest.c BN
125./crypto/bn/bn_add.c BN
126./crypto/bn/bn_bld.c BN
127./crypto/bn/bn_blind.c BN
128./crypto/bn/bn_div.c BN
129./crypto/bn/bn_err.c BN
130./crypto/bn/bn_exp.c BN
131./crypto/bn/bn_gcd.c BN
132./crypto/bn/bn_lib.c BN
133./crypto/bn/bn_mod.c BN
134./crypto/bn/bn_mont.c BN
135./crypto/bn/bn_mul.c BN
136./crypto/bn/bn_mulw.c BN
137./crypto/bn/bn_prime.c BN
138./crypto/bn/bn_print.c BN
139./crypto/bn/bn_rand.c BN
140./crypto/bn/bn_recp.c BN
141./crypto/bn/bn_shift.c BN
142./crypto/bn/bn_sqr.c BN
143./crypto/bn/bn_sub.c BN
144./crypto/bn/bn_word.c BN
145./crypto/bn/bn_m.c BN
146./crypto/bn/m.c BN
147./crypto/bn/expspeed.c BN
148./crypto/bn/bn_mpi.c BN
149./crypto/bn/exptest.c BN
150
151./crypto/buffer/buffer.c BUFF
152./crypto/buffer/buffer.h BUFF
153./crypto/buffer/buf_err.c BUFF
154
155./crypto/cast/cast.h CAST
156./crypto/cast/castopts.c CAST
157./crypto/cast/casttest.c CAST
158./crypto/cast/cast_lcl.h CAST
159./crypto/cast/cast_s.h CAST
160./crypto/cast/cast_spd.c CAST
161./crypto/cast/c_cfb64.c CAST
162./crypto/cast/c_ecb.c CAST
163./crypto/cast/c_enc.c CAST
164./crypto/cast/c_ofb64.c CAST
165./crypto/cast/c_skey.c CAST
166
167./crypto/conf/conf_lcl.h CONF
168./crypto/conf/cnf_save.c CONF
169./crypto/conf/conf.c CONF
170./crypto/conf/conf.h CONF
171./crypto/conf/conf_err.c CONF
172
173./crypto/des/des.h DES
174./crypto/des/des_locl.h DES
175./crypto/des/spr.h DES
176./crypto/des/podd.h DES
177./crypto/des/sk.h DES
178./crypto/des/cbc3_enc.c DES
179./crypto/des/cbc_cksm.c DES
180./crypto/des/cbc_enc.c DES
181./crypto/des/cfb64ede.c DES
182./crypto/des/cfb64enc.c DES
183./crypto/des/cfb_enc.c DES
184./crypto/des/des.c DES
185./crypto/des/destest.c DES
186./crypto/des/des_enc.c DES
187./crypto/des/des_opts.c DES
188./crypto/des/des_ver.h DES
189./crypto/des/ecb3_enc.c DES
190./crypto/des/ecb_enc.c DES
191./crypto/des/ede_enc.c DES
192./crypto/des/enc_read.c DES
193./crypto/des/enc_writ.c DES
194./crypto/des/fcrypt.c DES
195./crypto/des/fcrypt_b.c DES
196./crypto/des/ncbc_enc.c DES
197./crypto/des/ofb64ede.c DES
198./crypto/des/ofb64enc.c DES
199./crypto/des/ofb_enc.c DES
200./crypto/des/pcbc_enc.c DES
201./crypto/des/qud_cksm.c DES
202./crypto/des/rand_key.c DES
203./crypto/des/read2pwd.c DES
204./crypto/des/read_pwd.c DES
205./crypto/des/rpc_des.h DES
206./crypto/des/rpc_enc.c DES
207./crypto/des/rpw.c DES
208./crypto/des/set_key.c DES
209./crypto/des/str2key.c DES
210./crypto/des/supp.c DES
211./crypto/des/xcbc_enc.c DES
212
213./crypto/dh/dh.h DH
214./crypto/dh/dh_check.c DH
215./crypto/dh/dh_err.c DH
216./crypto/dh/dh_gen.c DH
217./crypto/dh/dh_key.c DH
218./crypto/dh/dh_lib.c DH
219./crypto/dh/p1024.c DH
220./crypto/dh/p192.c DH
221./crypto/dh/p512.c DH
222./crypto/dh/dhtest.c DH
223
224./crypto/dsa/dsa.h DSA
225./crypto/dsa/dsagen.c DSA
226./crypto/dsa/dsa_err.c DSA
227./crypto/dsa/dsa_gen.c DSA
228./crypto/dsa/dsa_key.c DSA
229./crypto/dsa/dsa_lib.c DSA
230./crypto/dsa/dsa_sign.c DSA
231./crypto/dsa/dsa_vrf.c DSA
232./crypto/dsa/dsatest.c DSA
233
234./crypto/err/err.c ERR
235./crypto/err/err.h ERR
236./crypto/err/err_all.c ERR
237./crypto/err/err_prn.c ERR
238
239./crypto/evp/evp.h EVP
240./crypto/evp/bio_b64.c EVP
241./crypto/evp/bio_enc.c EVP
242./crypto/evp/bio_md.c EVP
243./crypto/evp/c_all.c EVP
244./crypto/evp/digest.c EVP
245./crypto/evp/encode.c EVP
246./crypto/evp/evp_enc.c EVP
247./crypto/evp/evp_err.c EVP
248./crypto/evp/evp_key.c EVP
249./crypto/evp/e_cbc_3d.c EVP
250./crypto/evp/e_cbc_bf.c EVP
251./crypto/evp/e_cbc_c.c EVP
252./crypto/evp/e_cbc_d.c EVP
253./crypto/evp/e_cbc_i.c EVP
254./crypto/evp/e_cbc_r2.c EVP
255./crypto/evp/e_cfb_3d.c EVP
256./crypto/evp/e_cfb_bf.c EVP
257./crypto/evp/e_cfb_c.c EVP
258./crypto/evp/e_cfb_d.c EVP
259./crypto/evp/e_cfb_i.c EVP
260./crypto/evp/e_cfb_r2.c EVP
261./crypto/evp/e_dsa.c EVP
262./crypto/evp/e_ecb_3d.c EVP
263./crypto/evp/e_ecb_bf.c EVP
264./crypto/evp/e_ecb_c.c EVP
265./crypto/evp/e_ecb_d.c EVP
266./crypto/evp/e_ecb_i.c EVP
267./crypto/evp/e_ecb_r2.c EVP
268./crypto/evp/e_null.c EVP
269./crypto/evp/e_ofb_3d.c EVP
270./crypto/evp/e_ofb_bf.c EVP
271./crypto/evp/e_ofb_c.c EVP
272./crypto/evp/e_ofb_d.c EVP
273./crypto/evp/e_ofb_i.c EVP
274./crypto/evp/e_ofb_r2.c EVP
275./crypto/evp/e_rc4.c EVP
276./crypto/evp/e_xcbc_d.c EVP
277./crypto/evp/m_dss.c EVP
278./crypto/evp/m_dss1.c EVP
279./crypto/evp/m_md2.c EVP
280./crypto/evp/m_md5.c EVP
281./crypto/evp/m_mdc2.c EVP
282./crypto/evp/m_null.c EVP
283./crypto/evp/m_sha.c EVP
284./crypto/evp/m_sha1.c EVP
285./crypto/evp/names.c EVP
286./crypto/evp/p_lib.c EVP
287./crypto/evp/p_open.c EVP
288./crypto/evp/p_seal.c EVP
289./crypto/evp/p_sign.c EVP
290./crypto/evp/p_verify.c EVP
291
292./crypto/hmac/hmac.c HMAC
293./crypto/hmac/hmac.h HMAC
294./crypto/hmac/hmactest.c HMAC
295
296./crypto/idea/ideatest.c IDEA
297./crypto/idea/idea_lcl.h IDEA
298./crypto/idea/idea_spd.c IDEA
299./crypto/idea/i_cbc.c IDEA
300./crypto/idea/i_cfb64.c IDEA
301./crypto/idea/i_ecb.c IDEA
302./crypto/idea/i_ofb64.c IDEA
303./crypto/idea/i_skey.c IDEA
304./crypto/idea/idea.h IDEA
305
306./crypto/lhash/lhash.c LHASH
307./crypto/lhash/lhash.h LHASH
308./crypto/lhash/lh_stats.c LHASH
309./crypto/lhash/lh_test.c LHASH
310
311./crypto/md2/md2.c MD2
312./crypto/md2/md2test.c MD2
313./crypto/md2/md2_dgst.c MD2
314./crypto/md2/md2_one.c MD2
315./crypto/md2/md2.h MD2
316
317./crypto/md5/md5.c MD5
318./crypto/md5/md5.h MD5
319./crypto/md5/md5test.c MD5
320./crypto/md5/md5_dgst.c MD5
321./crypto/md5/md5_locl.h MD5
322./crypto/md5/md5_one.c MD5
323
324./crypto/mdc2/mdc2.h MDC2
325./crypto/mdc2/mdc2dgst.c MDC2
326./crypto/mdc2/mdc2test.c MDC2
327./crypto/mdc2/mdc2_one.c MDC2
328
329./crypto/objects/objects.h OBJ
330./crypto/objects/obj_dat.c OBJ
331./crypto/objects/obj_dat.h OBJ
332./crypto/objects/obj_err.c OBJ
333./crypto/objects/obj_lib.c OBJ
334
335./crypto/pem/ctx_size.c PEM
336./crypto/pem/pem.h PEM
337./crypto/pem/pem_all.c PEM
338./crypto/pem/pem_err.c PEM
339./crypto/pem/pem_info.c PEM
340./crypto/pem/pem_lib.c PEM
341./crypto/pem/pem_seal.c PEM
342./crypto/pem/pem_sign.c PEM
343
344./crypto/pkcs7/pk7_dgst.c PKCS7
345./crypto/pkcs7/pk7_doit.c PKCS7
346./crypto/pkcs7/pk7_enc.c PKCS7
347./crypto/pkcs7/pk7_lib.c PKCS7
348./crypto/pkcs7/pkcs7.h PKCS7
349./crypto/pkcs7/pkcs7err.c PKCS7
350./crypto/pkcs7/sign.c PKCS7
351
352./crypto/proxy/bf_proxy.c PROXY
353./crypto/proxy/p2test.c PROXY
354./crypto/proxy/p3test.c PROXY
355./crypto/proxy/paccept.c PROXY
356./crypto/proxy/proxy.c PROXY
357./crypto/proxy/proxy.h PROXY
358./crypto/proxy/ptest.c PROXY
359./crypto/proxy/pxy_conf.c PROXY
360./crypto/proxy/pxy_err.c PROXY
361./crypto/proxy/pxy_txt.c PROXY
362
363./crypto/rand/md_rand.c RAND
364./crypto/rand/rand.h RAND
365./crypto/rand/randfile.c RAND
366./crypto/rand/randtest.c RAND
367
368./crypto/rc2/rc2cfb64.c RC2
369./crypto/rc2/rc2ofb64.c RC2
370./crypto/rc2/rc2speed.c RC2
371./crypto/rc2/rc2test.c RC2
372./crypto/rc2/rc2_cbc.c RC2
373./crypto/rc2/rc2_ecb.c RC2
374./crypto/rc2/rc2_locl.h RC2
375./crypto/rc2/rc2_skey.c RC2
376./crypto/rc2/rc2.h RC2
377
378./crypto/rc4/rc4.c RC4
379./crypto/rc4/rc4speed.c RC4
380./crypto/rc4/rc4test.c RC4
381./crypto/rc4/rc4_enc.c RC4
382./crypto/rc4/rc4_skey.c RC4
383./crypto/rc4/rc4.h RC4
384./crypto/rc4/rc4_locl.h RC4
385
386./crypto/rsa/rsa.h RSA
387./crypto/rsa/rsa_eay.c RSA
388./crypto/rsa/rsa_err.c RSA
389./crypto/rsa/rsa_gen.c RSA
390./crypto/rsa/rsa_lib.c RSA
391./crypto/rsa/rsa_saos.c RSA
392./crypto/rsa/rsa_sign.c RSA
393./crypto/rsa/rsa_ssl.c RSA
394./crypto/rsa/rsa_pk1.c RSA
395./crypto/rsa/rsa_none.c RSA
396
397./crypto/sha/sha.h SHA
398./crypto/sha/sha_locl.h SHA
399./crypto/sha/sha.c SHA0
400./crypto/sha/sha_dgst.c SHA0
401./crypto/sha/sha_one.c SHA0
402./crypto/sha/sha_sgst.c SHA0
403./crypto/sha/shatest.c SHA0
404./crypto/sha/sha1.c SHA1
405./crypto/sha/sha1dgst.c SHA1
406./crypto/sha/sha1_one.c SHA1
407./crypto/sha/sha1test.c SHA1
408
409./crypto/stack/stack.c STACK
410./crypto/stack/stack.h STACK
411
412./crypto/txt_db/txt_db.c TXTDB
413./crypto/txt_db/txt_db.h TXTDB
414
415./crypto/x509/by_dir.c X509
416./crypto/x509/by_file.c X509
417./crypto/x509/v3_net.c X509
418./crypto/x509/v3_x509.c X509
419./crypto/x509/x509.h X509
420./crypto/x509/x509name.c X509
421./crypto/x509/x509pack.c X509
422./crypto/x509/x509rset.c X509
423./crypto/x509/x509type.c X509
424./crypto/x509/x509_cmp.c X509
425./crypto/x509/x509_d2.c X509
426./crypto/x509/x509_def.c X509
427./crypto/x509/x509_err.c X509
428./crypto/x509/x509_ext.c X509
429./crypto/x509/x509_lu.c X509
430./crypto/x509/x509_obj.c X509
431./crypto/x509/x509_r2x.c X509
432./crypto/x509/x509_req.c X509
433./crypto/x509/x509_set.c X509
434./crypto/x509/x509_txt.c X509
435./crypto/x509/x509_v3.c X509
436./crypto/x509/x509_vfy.c X509
437./crypto/x509/x_all.c X509
438./crypto/x509/x509_vfy.h X509
439./crypto/x509v3/v3_ku.c X509
440./crypto/x509v3/x509v3.h X509
441
442./crypto/threads/mttest.c THREADS
443./crypto/threads/th-lock.c THREADS
444
445./crypto/ripemd/rmdtest.c RMD160
446./crypto/ripemd/ripemd.h RMD160
447./crypto/ripemd/rmdconst.h RMD160
448./crypto/ripemd/rmd_locl.h RMD160
449./crypto/ripemd/rmd_one.c RMD160
450./crypto/ripemd/rmd160.c RMD160
451./crypto/ripemd/rmd_dgst.c RMD160
452
453./crypto/rc5/rc5_ecb.c RC5
454./crypto/rc5/rc5cfb64.c RC5
455./crypto/rc5/rc5ofb64.c RC5
456./crypto/rc5/rc5speed.c RC5
457./crypto/rc5/rc5test.c RC5
458./crypto/rc5/rc5_enc.c RC5
459./crypto/rc5/rc5.h RC5
460./crypto/rc5/rc5_locl.h RC5
461./crypto/rc5/rc5_skey.c RC5
462
463./ssl/bio_ssl.c SSL
464./ssl/pxy_ssl.c SSL
465./ssl/s23_clnt.c SSL
466./ssl/s23_lib.c SSL
467./ssl/s23_meth.c SSL
468./ssl/s23_pkt.c SSL
469./ssl/s23_srvr.c SSL
470./ssl/s2_clnt.c SSL
471./ssl/s2_enc.c SSL
472./ssl/s2_lib.c SSL
473./ssl/s2_meth.c SSL
474./ssl/s2_pkt.c SSL
475./ssl/s2_srvr.c SSL
476./ssl/s3_both.c SSL
477./ssl/s3_clnt.c SSL
478./ssl/s3_enc.c SSL
479./ssl/s3_lib.c SSL
480./ssl/s3_meth.c SSL
481./ssl/s3_pkt.c SSL
482./ssl/s3_srvr.c SSL
483./ssl/ssl.c SSL
484./ssl/ssl2.h SSL
485./ssl/ssl23.h SSL
486./ssl/ssl3.h SSL
487./ssl/ssl_algs.c SSL
488./ssl/ssl_asn1.c SSL
489./ssl/ssl_cert.c SSL
490./ssl/ssl_ciph.c SSL
491./ssl/ssl_err.c SSL
492./ssl/ssl_err2.c SSL
493./ssl/ssl_lib.c SSL
494./ssl/ssl_locl.h SSL
495./ssl/ssl_rsa.c SSL
496./ssl/ssl_sess.c SSL
497./ssl/ssl_stat.c SSL
498./ssl/ssl_task.c SSL
499./ssl/ssl_txt.c SSL
500./ssl/tls1.h SSL
501./ssl/t1_lib.c SSL
502./ssl/t1_enc.c SSL
503./ssl/t1_meth.c SSL
504./ssl/t1_srvr.c SSL
505./ssl/t1_clnt.c SSL
506./ssl/ssl.h SSL
507./ssl/ssltest.c SSL
508
509./rsaref/rsaref.c RSAREF
510./rsaref/rsaref.h RSAREF
511./rsaref/rsar_err.c RSAREF
512
513./apps/apps.c APPS
514./apps/apps.h APPS
515./apps/asn1pars.c APPS
516./apps/bf_perm.c APPS
517./apps/bf_perm.h APPS
518./apps/ca.c APPS
519./apps/ciphers.c APPS
520./apps/crl.c APPS
521./apps/crl2p7.c APPS
522./apps/dgst.c APPS
523./apps/dh.c APPS
524./apps/dsa.c APPS
525./apps/dsaparam.c APPS
526./apps/eay.c APPS
527./apps/enc.c APPS
528./apps/errstr.c APPS
529./apps/speed.c APPS
530./apps/gendh.c APPS
531./apps/gendsa.c APPS
532./apps/genrsa.c APPS
533./apps/mybio_cb.c APPS
534./apps/pem_mail.c APPS
535./apps/pkcs7.c APPS
536./apps/progs.h APPS
537./apps/req.c APPS
538./apps/rsa.c APPS
539./apps/sess_id.c APPS
540./apps/s_apps.h APPS
541./apps/s_cb.c APPS
542./apps/s_client.c APPS
543./apps/s_server.c APPS
544./apps/s_socket.c APPS
545./apps/s_time.c APPS
546./apps/testdsa.h APPS
547./apps/testrsa.h APPS
548./apps/verify.c APPS
549./apps/version.c APPS
550./apps/x509.c APPS
551./apps/ssleay.c APPS
552./apps/sp.c APPS
553
554./demos/b64.c DEMO
555./demos/bio/saccept.c DEMO
556./demos/bio/sconnect.c DEMO
557./demos/maurice/example1.c DEMO
558./demos/maurice/example2.c DEMO
559./demos/maurice/example3.c DEMO
560./demos/maurice/example4.c DEMO
561./demos/maurice/loadkeys.c DEMO
562./demos/maurice/loadkeys.h DEMO
563./demos/prime/prime.c DEMO
564./demos/selfsign.c DEMO
565./demos/spkigen.c DEMO
566
diff --git a/src/lib/libssl/src/dep/gen.pl b/src/lib/libssl/src/dep/gen.pl
index 8ab6db5c53..e69de29bb2 100644
--- a/src/lib/libssl/src/dep/gen.pl
+++ b/src/lib/libssl/src/dep/gen.pl
@@ -1,113 +0,0 @@
1#!/usr/local/bin/perl
2
3require 'getopts.pl';
4
5$files="files";
6%have=();
7%missing=();
8%name=();
9%func=();
10
11&Getopts('Ff:');
12
13&load_file("files");
14foreach $file (@ARGV)
15 { &do_nm($file); }
16
17if (defined($opt_f))
18 {
19 %a=();
20 $r=&list_files($opt_f,"",*a);
21 if ($opt_F)
22 {
23 foreach (sort split(/\n/,$r))
24 { print "$_\n"; }
25 }
26 else
27 { print $r; }
28 }
29else
30 {
31 for (sort keys %have)
32 {
33 print "$_:$have{$_}\n";
34 }
35 }
36
37sub list_files
38 {
39 local($f,$o,*done)=@_;
40 local($a,$_,$ff,$ret);
41
42 return if $f =~ /^\s*$/;
43
44 $done{$f}=1;
45 $ret.=$f."\n" if $opt_F;
46 foreach (split(/ /,$have{$f}))
47 {
48 $ret.="$o$f:$_\n" unless $opt_F;
49 }
50
51 foreach (split(/ /,$missing{$f}))
52 {
53 $ff=$func{$_};
54 next if defined($done{$ff});
55 $ret.=&list_files($ff,$o." ");
56 }
57 $ret;
58 }
59
60sub do_nm
61 {
62 local($file)=@_;
63 local($fname)="";
64
65 open(IN,"nm $file|") || die "unable to run 'nm $file|':$!\n";
66 while (<IN>)
67 {
68 chop;
69 next if /^\s*$/;
70 if (/^(.*)\.o:\s*$/)
71 {
72 $fname="$1.c";
73 next;
74 }
75 ($type,$name)=/^.{8} (.) (.+)/;
76# print "$fname $type $name\n";
77
78 if ($type eq "T")
79 {
80 $have{$fname}.="$name ";
81 $func{$name}=$fname;
82 }
83 elsif ($type eq "U")
84 {
85 $missing{$fname}.="$name ";
86 }
87 }
88 close(IN);
89 }
90
91sub load_file
92 {
93 local($file)=@_;
94
95 open(IN,"<$files") || die "unable to open $files:$!\n";
96
97 while (<IN>)
98 {
99 chop;
100 next if /^\s*$/;
101 ($n)=/\/([^\/\s]+)\s+/;
102 ($fn)=/^(\S+)\s/;
103# print "$n - $fn\n";
104 if (defined($name{$n}))
105 { print "$n already exists\n"; }
106 else
107 { $name{$n}=$fn; }
108 }
109 close(IN);
110 @name=%name;
111 }
112
113
diff --git a/src/lib/libssl/src/dep/ssl.txt b/src/lib/libssl/src/dep/ssl.txt
index 7cd125a0d1..e69de29bb2 100644
--- a/src/lib/libssl/src/dep/ssl.txt
+++ b/src/lib/libssl/src/dep/ssl.txt
@@ -1,156 +0,0 @@
1BIO_f_ssl
2BIO_new_buffer_ssl_connect
3BIO_new_ssl
4BIO_new_ssl_connect
5BIO_proxy_ssl_copy_session_id
6BIO_ssl_copy_session_id
7BIO_ssl_shutdown
8ERR_load_SSL_strings
9SSL_CIPHER_description
10SSL_CIPHER_get_bits
11SSL_CIPHER_get_name
12SSL_CIPHER_get_version
13SSL_CTX_add_client_CA
14SSL_CTX_add_session
15SSL_CTX_check_private_key
16SSL_CTX_ctrl
17SSL_CTX_flush_sessions
18SSL_CTX_free
19SSL_CTX_get_client_CA_list
20SSL_CTX_get_ex_data
21SSL_CTX_get_ex_new_index
22SSL_CTX_get_quiet_shutdown
23SSL_CTX_get_verify_callback
24SSL_CTX_get_verify_mode
25SSL_CTX_load_verify_locations
26SSL_CTX_new
27SSL_CTX_remove_session
28SSL_CTX_set_cert_verify_cb
29SSL_CTX_set_cipher_list
30SSL_CTX_set_client_CA_list
31SSL_CTX_set_default_passwd_cb
32SSL_CTX_set_default_verify_paths
33SSL_CTX_set_ex_data
34SSL_CTX_set_quiet_shutdown
35SSL_CTX_set_ssl_version
36SSL_CTX_set_verify
37SSL_CTX_use_PrivateKey
38SSL_CTX_use_PrivateKey_ASN1
39SSL_CTX_use_PrivateKey_file
40SSL_CTX_use_RSAPrivateKey
41SSL_CTX_use_RSAPrivateKey_ASN1
42SSL_CTX_use_RSAPrivateKey_file
43SSL_CTX_use_certificate
44SSL_CTX_use_certificate_ASN1
45SSL_CTX_use_certificate_file
46SSL_SESSION_cmp
47SSL_SESSION_free
48SSL_SESSION_get_ex_data
49SSL_SESSION_get_ex_new_index
50SSL_SESSION_get_time
51SSL_SESSION_get_timeout
52SSL_SESSION_hash
53SSL_SESSION_new
54SSL_SESSION_print
55SSL_SESSION_print_fp
56SSL_SESSION_set_ex_data
57SSL_SESSION_set_time
58SSL_SESSION_set_timeout
59SSL_accept
60SSL_add_client_CA
61SSL_alert_desc_string
62SSL_alert_desc_string_long
63SSL_alert_type_string
64SSL_alert_type_string_long
65SSL_check_private_key
66SSL_clear
67SSL_connect
68SSL_copy_session_id
69SSL_ctrl
70SSL_do_handshake
71SSL_dup
72SSL_dup_CA_list
73SSL_free
74SSL_get_SSL_CTX
75SSL_get_certificate
76SSL_get_cipher_list
77SSL_get_ciphers
78SSL_get_client_CA_list
79SSL_get_current_cipher
80SSL_get_default_timeout
81SSL_get_error
82SSL_get_ex_data
83SSL_get_ex_new_index
84SSL_get_fd
85SSL_get_info_callback
86SSL_get_peer_cert_chain
87SSL_get_peer_certificate
88SSL_get_privatekey
89SSL_get_quiet_shutdown
90SSL_get_rbio
91SSL_get_read_ahead
92SSL_get_session
93SSL_get_shared_ciphers
94SSL_get_shutdown
95SSL_get_ssl_method
96SSL_get_verify_callback
97SSL_get_verify_mode
98SSL_get_verify_result
99SSL_get_version
100SSL_get_wbio
101SSL_load_client_CA_file
102SSL_load_error_strings
103SSL_new
104SSL_peek
105SSL_pending
106SSL_read
107SSL_renegotiate
108SSL_rstate_string
109SSL_rstate_string_long
110SSL_set_accept_state
111SSL_set_bio
112SSL_set_cipher_list
113SSL_set_client_CA_list
114SSL_set_connect_state
115SSL_set_ex_data
116SSL_set_fd
117SSL_set_info_callback
118SSL_set_quiet_shutdown
119SSL_set_read_ahead
120SSL_set_rfd
121SSL_set_session
122SSL_set_shutdown
123SSL_set_ssl_method
124SSL_set_verify
125SSL_set_verify_result
126SSL_set_wfd
127SSL_shutdown
128SSL_state
129SSL_state_string
130SSL_state_string_long
131SSL_use_PrivateKey
132SSL_use_PrivateKey_ASN1
133SSL_use_PrivateKey_file
134SSL_use_RSAPrivateKey
135SSL_use_RSAPrivateKey_ASN1
136SSL_use_RSAPrivateKey_file
137SSL_use_certificate
138SSL_use_certificate_ASN1
139SSL_use_certificate_file
140SSL_version
141SSL_write
142SSLeay_add_ssl_algorithms
143SSLv23_client_method
144SSLv23_method
145SSLv23_server_method
146SSLv2_client_method
147SSLv2_method
148SSLv2_server_method
149SSLv3_client_method
150SSLv3_method
151SSLv3_server_method
152TLSv1_client_method
153TLSv1_method
154TLSv1_server_method
155d2i_SSL_SESSION
156i2d_SSL_SESSION
diff --git a/src/lib/libssl/src/doc/README b/src/lib/libssl/src/doc/README
index a9a588262a..14469a82e3 100644
--- a/src/lib/libssl/src/doc/README
+++ b/src/lib/libssl/src/doc/README
@@ -1,9 +1,9 @@
1 1
2 openssl.pod ..... Documentation of OpenSSL `openssl' command 2 apps/openssl.pod .... Documentation of OpenSSL `openssl' command
3 crypto.pod ...... Documentation of OpenSSL crypto.h+libcrypto.a 3 crypto/crypto.pod ... Documentation of OpenSSL crypto.h+libcrypto.a
4 ssl.pod ......... Documentation of OpenSSL ssl.h+libssl.a 4 ssl/ssl.pod ......... Documentation of OpenSSL ssl.h+libssl.a
5 ssleay.txt ...... Assembled documentation files of ancestor SSLeay [obsolete] 5 openssl.txt ......... Assembled documentation files for OpenSSL [not final]
6 openssl.txt ..... Assembled documentation files for OpenSSL [not final] 6 ssleay.txt .......... Assembled documentation of ancestor SSLeay [obsolete]
7 7
8 An archive of HTML documents for the SSLeay library is available from 8 An archive of HTML documents for the SSLeay library is available from
9 http://www.columbia.edu/~ariel/ssleay/ 9 http://www.columbia.edu/~ariel/ssleay/
diff --git a/src/lib/libssl/src/doc/apps/CA.pl.pod b/src/lib/libssl/src/doc/apps/CA.pl.pod
new file mode 100644
index 0000000000..83e4c0af81
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/CA.pl.pod
@@ -0,0 +1,138 @@
1
2=pod
3
4=head1 NAME
5
6CA.pl - friendlier interface for OpenSSL certificate programs
7
8=head1 SYNOPSIS
9
10B<CA.pl>
11[B<-?>]
12[B<-h>]
13[B<-help>]
14[B<-newcert>]
15[B<-newreq>]
16[B<-newca>]
17[B<-xsign>]
18[B<-sign>]
19[B<-signreq>]
20[B<-signcert>]
21[B<-verify>]
22[B<files>]
23
24=head1 DESCRIPTION
25
26The B<CA.pl> script is a perl script that supplies the relevant command line
27arguments to the B<openssl> command for some common certificate operations.
28It is intended to simplify the process of certificate creation and management
29by the use of some simple options.
30
31=head1 COMMAND OPTIONS
32
33=over 4
34
35=item B<?>, B<-h>, B<-help>
36
37prints a usage message.
38
39=item B<-newcert>
40
41creates a new self signed certificate. The private key and certificate are
42written to the file "newreq.pem".
43
44=item B<-newreq>
45
46creates a new certificate request. The private key and request are
47written to the file "newreq.pem".
48
49=item B<-newca>
50
51creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert>
52and B<-xsign> options). The user is prompted to enter the filename of the CA
53certificates (which should also contain the private key) or by hitting ENTER
54details of the CA will be prompted for. The relevant files and directories
55are created in a directory called "demoCA" in the current directory.
56
57=item B<-pkcs12>
58
59create a PKCS#12 file containing the user certificate, private key and CA
60certificate. It expects the user certificate and private key to be in the
61file "newcert.pem" and the CA certificate to be in the file demoCA/cacert.pem,
62it creates a file "newcert.p12". This command can thus be called after the
63B<-sign> option. The PKCS#12 file can be imported directly into a browser.
64If there is an additional argument on the command line it will be used as the
65"friendly name" for the certificate (which is typically displayed in the browser
66list box), otherwise the name "My Certificate" is used.
67
68=item B<-sign>, B<-signreq>, B<-xsign>
69
70calls the B<ca> program to sign a certificate request. It expects the request
71to be in the file "newreq.pem". The new certificate is written to the file
72"newcert.pem" except in the case of the B<-xcert> option when it is written
73to standard output.
74
75=item B<-signcert>
76
77this option is the same as B<-sign> except it expects a self signed certificate
78to be present in the file "newreq.pem".
79
80=item B<-verify>
81
82verifies certificates against the CA certificate for "demoCA". If no certificates
83are specified on the command line it tries to verify the file "newcert.pem".
84
85=item B<files>
86
87one or more optional certificate file names for use with the B<-verify> command.
88
89=back
90
91=head1 EXAMPLES
92
93Create a CA hierarchy:
94
95 CA.pl -newca
96
97Complete certificate creation example: create a CA, create a request, sign
98the request and finally create a PKCS#12 file containing it.
99
100 CA.pl -newca
101 CA.pl -newreq
102 CA.pl -signreq
103 CA.pl -pkcs12 "My Test Certificate"
104
105=head1 NOTES
106
107Most of the filenames mentioned can be modified by editing the B<CA.pl> script.
108
109If the demoCA directory already exists then the B<-newca> command will not
110overwrite it and will do nothing. This can happen if a previous call using
111the B<-newca> option terminated abnormally. To get the correct behaviour
112delete the demoCA directory if it already exists.
113
114Under some environments it may not be possible to run the B<CA.pl> script
115directly (for example Win32) and the default configuration file location may
116be wrong. In this case the command:
117
118 perl -S CA.pl
119
120can be used and the B<OPENSSL_CONF> environment variable changed to point to
121the correct path of the configuration file "openssl.cnf".
122
123The script is intended as a simple front end for the B<openssl> program for use
124by a beginner. Its behaviour isn't always what is wanted. For more control over the
125behaviour of the certificate commands call the B<openssl> command directly.
126
127=head1 ENVIRONMENT VARIABLES
128
129The variable B<OPENSSL_CONF> if defined allows an alternative configuration
130file location to be specified, it should contain the full path to the
131configuration file, not just its directory.
132
133=head1 SEE ALSO
134
135L<x509(1)|x509(1)>, L<ca(1)|ca(1)>, L<req(1)|req(1)>, L<pkcs12(1)|pkcs12(1)>,
136L<config(5)|config(5)>
137
138=cut
diff --git a/src/lib/libssl/src/doc/apps/asn1parse.pod b/src/lib/libssl/src/doc/apps/asn1parse.pod
new file mode 100644
index 0000000000..e76e9813ab
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/asn1parse.pod
@@ -0,0 +1,129 @@
1=pod
2
3=head1 NAME
4
5asn1parse - ASN.1 parsing tool
6
7=head1 SYNOPSIS
8
9B<openssl> B<asn1parse>
10[B<-inform PEM|DER>]
11[B<-in filename>]
12[B<-out filename>]
13[B<-noout>]
14[B<-offset number>]
15[B<-length number>]
16[B<-i>]
17[B<-oid filename>]
18[B<-strparse offset>]
19
20=head1 DESCRIPTION
21
22The B<asn1parse> command is a diagnostic utility that can parse ASN.1
23structures. It can also be used to extract data from ASN.1 formatted data.
24
25=head1 OPTIONS
26
27=over 4
28
29=item B<-inform> B<DER|PEM>
30
31the input format. B<DER> is binary format and B<PEM> (the default) is base64
32encoded.
33
34=item B<-in filename>
35
36the input file, default is standard input
37
38=item B<-out filename>
39
40output file to place the DER encoded data into. If this
41option is not present then no data will be output. This is most useful when
42combined with the B<-strparse> option.
43
44=item B<-noout>
45
46don't output the parsed version of the input file.
47
48=item B<-offset number>
49
50starting offset to begin parsing, default is start of file.
51
52=item B<-length number>
53
54number of bytes to parse, default is until end of file.
55
56=item B<-i>
57
58indents the output according to the "depth" of the structures.
59
60=item B<-oid filename>
61
62a file containing additional OBJECT IDENTIFIERs (OIDs). The format of this
63file is described in the NOTES section below.
64
65=item B<-strparse offset>
66
67parse the contents octets of the ASN.1 object starting at B<offset>. This
68option can be used multiple times to "drill down" into a nested structure.
69
70
71=back
72
73=head2 OUTPUT
74
75The output will typically contain lines like this:
76
77 0:d=0 hl=4 l= 681 cons: SEQUENCE
78
79.....
80
81 229:d=3 hl=3 l= 141 prim: BIT STRING
82 373:d=2 hl=3 l= 162 cons: cont [ 3 ]
83 376:d=3 hl=3 l= 159 cons: SEQUENCE
84 379:d=4 hl=2 l= 29 cons: SEQUENCE
85 381:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier
86 386:d=5 hl=2 l= 22 prim: OCTET STRING
87 410:d=4 hl=2 l= 112 cons: SEQUENCE
88 412:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier
89 417:d=5 hl=2 l= 105 prim: OCTET STRING
90 524:d=4 hl=2 l= 12 cons: SEQUENCE
91
92.....
93
94This example is part of a self signed certificate. Each line starts with the
95offset in decimal. B<d=XX> specifies the current depth. The depth is increased
96within the scope of any SET or SEQUENCE. B<hl=XX> gives the header length
97(tag and length octets) of the current type. B<l=XX> gives the length of
98the contents octets.
99
100The B<-i> option can be used to make the output more readable.
101
102Some knowledge of the ASN.1 structure is needed to interpret the output.
103
104In this example the BIT STRING at offset 229 is the certificate public key.
105The contents octets of this will contain the public key information. This can
106be examined using the option B<-strparse 229> to yield:
107
108 0:d=0 hl=3 l= 137 cons: SEQUENCE
109 3:d=1 hl=3 l= 129 prim: INTEGER :E5D21E1F5C8D208EA7A2166C7FAF9F6BDF2059669C60876DDB70840F1A5AAFA59699FE471F379F1DD6A487E7D5409AB6A88D4A9746E24B91D8CF55DB3521015460C8EDE44EE8A4189F7A7BE77D6CD3A9AF2696F486855CF58BF0EDF2B4068058C7A947F52548DDF7E15E96B385F86422BEA9064A3EE9E1158A56E4A6F47E5897
110 135:d=1 hl=2 l= 3 prim: INTEGER :010001
111
112=head1 NOTES
113
114If an OID is not part of OpenSSL's internal table it will be represented in
115numerical form (for example 1.2.3.4). The file passed to the B<-oid> option
116allows additional OIDs to be included. Each line consists of three columns,
117the first column is the OID in numerical format and should be followed by white
118space. The second column is the "short name" which is a single word followed
119by white space. The final column is the rest of the line and is the
120"long name". B<asn1parse> displays the long name. Example:
121
122C<1.2.3.4 shortName A long name>
123
124=head1 BUGS
125
126There should be options to change the format of input lines. The output of some
127ASN.1 types is not well handled (if at all).
128
129=cut
diff --git a/src/lib/libssl/src/doc/apps/ca.pod b/src/lib/libssl/src/doc/apps/ca.pod
new file mode 100644
index 0000000000..03209aa6b1
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/ca.pod
@@ -0,0 +1,479 @@
1
2=pod
3
4=head1 NAME
5
6ca - sample minimal CA application
7
8=head1 SYNOPSIS
9
10B<openssl> B<ca>
11[B<-verbose>]
12[B<-config filename>]
13[B<-name section>]
14[B<-gencrl>]
15[B<-revoke file>]
16[B<-crldays days>]
17[B<-crlhours hours>]
18[B<-crlexts section>]
19[B<-startdate date>]
20[B<-enddate date>]
21[B<-days arg>]
22[B<-md arg>]
23[B<-policy arg>]
24[B<-keyfile arg>]
25[B<-key arg>]
26[B<-cert file>]
27[B<-in file>]
28[B<-out file>]
29[B<-notext>]
30[B<-outdir dir>]
31[B<-infiles>]
32[B<-spkac file>]
33[B<-ss_cert file>]
34[B<-preserveDN>]
35[B<-batch>]
36[B<-msie_hack>]
37[B<-extensions section>]
38
39=head1 DESCRIPTION
40
41The B<ca> command is a minimal CA application. It can be used
42to sign certificate requests in a variety of forms and generate
43CRLs it also maintains a text database of issued certificates
44and their status.
45
46The options descriptions will be divided into each purpose.
47
48=head1 CA OPTIONS
49
50=over 4
51
52=item B<-config filename>
53
54specifies the configuration file to use.
55
56=item B<-in filename>
57
58an input filename containing a single certificate request to be
59signed by the CA.
60
61=item B<-ss_cert filename>
62
63a single self signed certificate to be signed by the CA.
64
65=item B<-spkac filename>
66
67a file containing a single Netscape signed public key and challenge
68and additional field values to be signed by the CA. See the B<NOTES>
69section for information on the required format.
70
71=item B<-infiles>
72
73if present this should be the last option, all subsequent arguments
74are assumed to the the names of files containing certificate requests.
75
76=item B<-out filename>
77
78the output file to output certificates to. The default is standard
79output. The certificate details will also be printed out to this
80file.
81
82=item B<-outdir directory>
83
84the directory to output certificates to. The certificate will be
85written to a filename consisting of the serial number in hex with
86".pem" appended.
87
88=item B<-cert>
89
90the CA certificate file.
91
92=item B<-keyfile filename>
93
94the private key to sign requests with.
95
96=item B<-key password>
97
98the password used to encrypt the private key. Since on some
99systems the command line arguments are visible (e.g. Unix with
100the 'ps' utility) this option should be used with caution.
101
102=item B<-verbose>
103
104this prints extra details about the operations being performed.
105
106=item B<-notext>
107
108don't output the text form of a certificate to the output file.
109
110=item B<-startdate date>
111
112this allows the start date to be explicitly set. The format of the
113date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure).
114
115=item B<-enddate date>
116
117this allows the expiry date to be explicitly set. The format of the
118date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure).
119
120=item B<-days arg>
121
122the number of days to certify the certificate for.
123
124=item B<-md alg>
125
126the message digest to use. Possible values include md5, sha1 and mdc2.
127This option also applies to CRLs.
128
129=item B<-policy arg>
130
131this option defines the CA "policy" to use. This is a section in
132the configuration file which decides which fields should be mandatory
133or match the CA certificate. Check out the B<POLICY FORMAT> section
134for more information.
135
136=item B<-msie_hack>
137
138this is a legacy option to make B<ca> work with very old versions of
139the IE certificate enrollment control "certenr3". It used UniversalStrings
140for almost everything. Since the old control has various security bugs
141its use is strongly discouraged. The newer control "Xenroll" does not
142need this option.
143
144=item B<-preserveDN>
145
146Normally the DN order of a certificate is the same as the order of the
147fields in the relevant policy section. When this option is set the order
148is the same as the request. This is largely for compatibility with the
149older IE enrollment control which would only accept certificates if their
150DNs match the order of the request. This is not needed for Xenroll.
151
152=item B<-batch>
153
154this sets the batch mode. In this mode no questions will be asked
155and all certificates will be certified automatically.
156
157=item B<-extensions section>
158
159the section of the configuration file containing certificate extensions
160to be added when a certificate is issued. If no extension section is
161present then a V1 certificate is created. If the extension section
162is present (even if it is empty) then a V3 certificate is created.
163
164=back
165
166=head1 CRL OPTIONS
167
168=over 4
169
170=item B<-gencrl>
171
172this option generates a CRL based on information in the index file.
173
174=item B<-crldays num>
175
176the number of days before the next CRL is due. That is the days from
177now to place in the CRL nextUpdate field.
178
179=item B<-crlhours num>
180
181the number of hours before the next CRL is due.
182
183=item B<-revoke filename>
184
185a filename containing a certificate to revoke.
186
187=item B<-crlexts section>
188
189the section of the configuration file containing CRL extensions to
190include. If no CRL extension section is present then a V1 CRL is
191created, if the CRL extension section is present (even if it is
192empty) then a V2 CRL is created. The CRL extensions specified are
193CRL extensions and B<not> CRL entry extensions. It should be noted
194that some software (for example Netscape) can't handle V2 CRLs.
195
196=back
197
198=head1 CONFIGURATION FILE OPTIONS
199
200The options for B<ca> are contained in the B<ca> section of the
201configuration file. Many of these are identical to command line
202options. Where the option is present in the configuration file
203and the command line the command line value is used. Where an
204option is described as mandatory then it must be present in
205the configuration file or the command line equivalent (if
206any) used.
207
208=over 4
209
210=item B<oid_file>
211
212This specifies a file containing additional B<OBJECT IDENTIFIERS>.
213Each line of the file should consist of the numerical form of the
214object identifier followed by white space then the short name followed
215by white space and finally the long name.
216
217=item B<oid_section>
218
219This specifies a section in the configuration file containing extra
220object identifiers. Each line should consist of the short name of the
221object identifier followed by B<=> and the numerical form. The short
222and long names are the same when this option is used.
223
224=item B<new_certs_dir>
225
226the same as the B<-outdir> command line option. It specifies
227the directory where new certificates will be placed. Mandatory.
228
229=item B<certificate>
230
231the same as B<-cert>. It gives the file containing the CA
232certificate. Mandatory.
233
234=item B<private_key>
235
236same as the B<-keyfile> option. The file containing the
237CA private key. Mandatory.
238
239=item B<RANDFILE>
240
241a file used to read and write random number seed information, or
242an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
243
244=item B<default_days>
245
246the same as the B<-days> option. The number of days to certify
247a certificate for.
248
249=item B<default_startdate>
250
251the same as the B<-startdate> option. The start date to certify
252a certificate for. If not set the current time is used.
253
254=item B<default_enddate>
255
256the same as the B<-enddate> option. Either this option or
257B<default_days> (or the command line equivalents) must be
258present.
259
260=item B<default_crl_hours default_crl_days>
261
262the same as the B<-crlhours> and the B<-crldays> options. These
263will only be used if neither command line option is present. At
264least one of these must be present to generate a CRL.
265
266=item B<default_md>
267
268the same as the B<-md> option. The message digest to use. Mandatory.
269
270=item B<database>
271
272the text database file to use. Mandatory. This file must be present
273though initially it will be empty.
274
275=item B<serialfile>
276
277a text file containing the next serial number to use in hex. Mandatory.
278This file must be present and contain a valid serial number.
279
280=item B<x509_extensions>
281
282the same as B<-extensions>.
283
284=item B<crl_extensions>
285
286the same as B<-crlexts>.
287
288=item B<preserve>
289
290the same as B<-preserveDN>
291
292=item B<msie_hack>
293
294the same as B<-msie_hack>
295
296=item B<policy>
297
298the same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section
299for more information.
300
301=back
302
303=head1 POLICY FORMAT
304
305The policy section consists of a set of variables corresponding to
306certificate DN fields. If the value is "match" then the field value
307must match the same field in the CA certificate. If the value is
308"supplied" then it must be present. If the value is "optional" then
309it may be present. Any fields not mentioned in the policy section
310are silently deleted, unless the B<-preserveDN> option is set but
311this can be regarded more of a quirk than intended behaviour.
312
313=head1 SPKAC FORMAT
314
315The input to the B<-spkac> command line option is a Netscape
316signed public key and challenge. This will usually come from
317the B<KEYGEN> tag in an HTML form to create a new private key.
318It is however possible to create SPKACs using the B<spkac> utility.
319
320The file should contain the variable SPKAC set to the value of
321the SPKAC and also the required DN components as name value pairs.
322If you need to include the same component twice then it can be
323preceded by a number and a '.'.
324
325=head1 EXAMPLES
326
327Note: these examples assume that the B<ca> directory structure is
328already set up and the relevant files already exist. This usually
329involves creating a CA certificate and private key with B<req>, a
330serial number file and an empty index file and placing them in
331the relevant directories.
332
333To use the sample configuration file below the directories demoCA,
334demoCA/private and demoCA/newcerts would be created. The CA
335certificate would be copied to demoCA/cacert.pem and its private
336key to demoCA/private/cakey.pem. A file demoCA/serial would be
337created containing for example "01" and the empty index file
338demoCA/index.txt.
339
340
341Sign a certificate request:
342
343 openssl ca -in req.pem -out newcert.pem
344
345Generate a CRL
346
347 openssl ca -gencrl -out crl.pem
348
349Sign several requests:
350
351 openssl ca -infiles req1.pem req2.pem req3.pem
352
353Certify a Netscape SPKAC:
354
355 openssl ca -spkac spkac.txt
356
357A sample SPKAC file (the SPKAC line has been truncated for clarity):
358
359 SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5
360 CN=Steve Test
361 emailAddress=steve@openssl.org
362 0.OU=OpenSSL Group
363 1.OU=Another Group
364
365A sample configuration file with the relevant sections for B<ca>:
366
367 [ ca ]
368 default_ca = CA_default # The default ca section
369
370 [ CA_default ]
371
372 dir = ./demoCA # top dir
373 database = $dir/index.txt # index file.
374 new_certs_dir = $dir/newcerts # new certs dir
375
376 certificate = $dir/cacert.pem # The CA cert
377 serial = $dir/serial # serial no file
378 private_key = $dir/private/cakey.pem# CA private key
379 RANDFILE = $dir/private/.rand # random number file
380
381 default_days = 365 # how long to certify for
382 default_crl_days= 30 # how long before next CRL
383 default_md = md5 # md to use
384
385 policy = policy_any # default policy
386
387 [ policy_any ]
388 countryName = supplied
389 stateOrProvinceName = optional
390 organizationName = optional
391 organizationalUnitName = optional
392 commonName = supplied
393 emailAddress = optional
394
395=head1 WARNINGS
396
397The B<ca> command is quirky and at times downright unfriendly.
398
399The B<ca> utility was originally meant as an example of how to do things
400in a CA. It was not supposed be be used as a full blown CA itself:
401nevertheless some people are using it for this purpose.
402
403The B<ca> command is effectively a single user command: no locking is
404done on the various files and attempts to run more than one B<ca> command
405on the same database can have unpredictable results.
406
407=head1 FILES
408
409Note: the location of all files can change either by compile time options,
410configuration file entries, environment variables or command line options.
411The values below reflect the default values.
412
413 /usr/local/ssl/lib/openssl.cnf - master configuration file
414 ./demoCA - main CA directory
415 ./demoCA/cacert.pem - CA certificate
416 ./demoCA/private/cakey.pem - CA private key
417 ./demoCA/serial - CA serial number file
418 ./demoCA/serial.old - CA serial number backup file
419 ./demoCA/index.txt - CA text database file
420 ./demoCA/index.txt.old - CA text database backup file
421 ./demoCA/certs - certificate output file
422 ./demoCA/.rnd - CA random seed information
423
424=head1 ENVIRONMENT VARIABLES
425
426B<OPENSSL_CONF> reflects the location of master configuration file it can
427be overridden by the B<-config> command line option.
428
429=head1 RESTRICTIONS
430
431The text database index file is a critical part of the process and
432if corrupted it can be difficult to fix. It is theoretically possible
433to rebuild the index file from all the issued certificates and a current
434CRL: however there is no option to do this.
435
436CRL entry extensions cannot currently be created: only CRL extensions
437can be added.
438
439V2 CRL features like delta CRL support and CRL numbers are not currently
440supported.
441
442Although several requests can be input and handled at once it is only
443possible to include one SPKAC or self signed certificate.
444
445=head1 BUGS
446
447The use of an in memory text database can cause problems when large
448numbers of certificates are present because, as the name implies
449the database has to be kept in memory.
450
451Certificate request extensions are ignored: some kind of "policy" should
452be included to use certain static extensions and certain extensions
453from the request.
454
455It is not possible to certify two certificates with the same DN: this
456is a side effect of how the text database is indexed and it cannot easily
457be fixed without introducing other problems. Some S/MIME clients can use
458two certificates with the same DN for separate signing and encryption
459keys.
460
461The B<ca> command really needs rewriting or the required functionality
462exposed at either a command or interface level so a more friendly utility
463(perl script or GUI) can handle things properly. The scripts B<CA.sh> and
464B<CA.pl> help a little but not very much.
465
466Any fields in a request that are not present in a policy are silently
467deleted. This does not happen if the B<-preserveDN> option is used but
468the extra fields are not displayed when the user is asked to certify
469a request. The behaviour should be more friendly and configurable.
470
471Cancelling some commands by refusing to certify a certificate can
472create an empty file.
473
474=head1 SEE ALSO
475
476L<req(1)|req(1)>, L<spkac(1)|spkac(1)>, L<x509(1)|x509(1)>, L<CA.pl(1)|CA.pl(1)>,
477L<config(5)|config(5)>
478
479=cut
diff --git a/src/lib/libssl/src/doc/apps/ciphers.pod b/src/lib/libssl/src/doc/apps/ciphers.pod
new file mode 100644
index 0000000000..2301e28251
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/ciphers.pod
@@ -0,0 +1,342 @@
1=pod
2
3=head1 NAME
4
5ciphers - SSL cipher display and cipher list tool.
6
7=head1 SYNOPSIS
8
9B<openssl> B<ciphers>
10[B<-v>]
11[B<-ssl2>]
12[B<-ssl3>]
13[B<-tls1>]
14[B<cipherlist>]
15
16=head1 DESCRIPTION
17
18The B<cipherlist> command converts OpenSSL cipher lists into ordered
19SSL cipher preference lists. It can be used as a test tool to determine
20the appropriate cipherlist.
21
22=head1 COMMAND OPTIONS
23
24=over 4
25
26=item B<-v>
27
28verbose option. List ciphers with a complete description of the authentication,
29key exchange, encryption and mac algorithms used along with any key size
30restrictions and whether the algorithm is classed as an "export" cipher.
31
32=item B<-ssl3>
33
34only include SSL v3 ciphers.
35
36=item B<-ssl2>
37
38only include SSL v2 ciphers.
39
40=item B<-tls1>
41
42only include TLS v1 ciphers.
43
44=item B<-h>, B<-?>
45
46print a brief usage message.
47
48=item B<cipherlist>
49
50a cipher list to convert to a cipher preference list. If it is not included
51then the default cipher list will be used. The format is described below.
52
53=back
54
55=head1 CIPHER LIST FORMAT
56
57The cipher list consists of one or more I<cipher strings> separated by colons.
58Commas or spaces are also acceptable separators but colons are normally used.
59
60The actual cipher string can take several different forms.
61
62It can consist of a single cipher suite such as B<RC4-SHA>.
63
64It can represent a list of cipher suites containing a certain algorithm, or
65cipher suites of a certain type. For example B<SHA1> represents all ciphers
66suites using the digest algorithm SHA1 and B<SSLv3> represents all SSL v3
67algorithms.
68
69Lists of cipher suites can be combined in a single cipher string using the
70B<+> character. This is used as a logical B<and> operation. For example
71B<SHA1+DES> represents all cipher suites containing the SHA1 B<and> the DES
72algorithms.
73
74Each cipher string can be optionally preceded by the characters B<!>,
75B<-> or B<+>.
76
77If B<!> is used then the ciphers are permanently deleted from the list.
78The ciphers deleted can never reappear in the list even if they are
79explicitly stated.
80
81If B<-> is used then the ciphers are deleted from the list, but some or
82all of the ciphers can be added again by later options.
83
84If B<+> is used then the ciphers are moved to the end of the list. This
85option doesn't add any new ciphers it just moves matching existing ones.
86
87If none of these characters is present then the string is just interpreted
88as a list of ciphers to be appended to the current preference list. If the
89list includes any ciphers already present they will be ignored: that is they
90will not moved to the end of the list.
91
92Additionally the cipher string B<@STRENGTH> can be used at any point to sort
93the current cipher list in order of encryption algorithm key length.
94
95=head1 CIPHER STRINGS
96
97The following is a list of all permitted cipher strings and their meanings.
98
99=over 4
100
101=item B<DEFAULT>
102
103the default cipher list. This is determined at compile time and is normally
104B<ALL:!ADH:RC4+RSA:+SSLv2:@STRENGTH>. This must be the first cipher string
105specified.
106
107=item B<ALL>
108
109all ciphers suites except the B<eNULL> ciphers which must be explicitly enabled.
110
111=item B<HIGH>
112
113"high" encryption cipher suites. This currently means those with key lengths larger
114than 128 bits.
115
116=item B<MEDIUM>
117
118"medium" encryption cipher suites, currently those using 128 bit encryption.
119
120=item B<LOW>
121
122"low" encryption cipher suites, currently those using 64 or 56 bit encryption algorithms
123but excluding export cipher suites.
124
125=item B<EXP>, B<EXPORT>
126
127export encryption algorithms. Including 40 and 56 bits algorithms.
128
129=item B<EXPORT40>
130
13140 bit export encryption algorithms
132
133=item B<EXPORT56>
134
13556 bit export encryption algorithms.
136
137=item B<eNULL>, B<NULL>
138
139the "NULL" ciphers that is those offering no encryption. Because these offer no
140encryption at all and are a security risk they are disabled unless explicitly
141included.
142
143=item B<aNULL>
144
145the cipher suites offering no authentication. This is currently the anonymous
146DH algorithms. These cipher suites are vulnerable to a "man in the middle"
147attack and so their use is normally discouraged.
148
149=item B<kRSA>, B<RSA>
150
151cipher suites using RSA key exchange.
152
153=item B<kEDH>
154
155cipher suites using ephemeral DH key agreement.
156
157=item B<kDHr>, B<kDHd>
158
159cipher suites using DH key agreement and DH certificates signed by CAs with RSA
160and DSS keys respectively. Not implemented.
161
162=item B<aRSA>
163
164cipher suites using RSA authentication, i.e. the certificates carry RSA keys.
165
166=item B<aDSS>, B<DSS>
167
168cipher suites using DSS authentication, i.e. the certificates carry DSS keys.
169
170=item B<aDH>
171
172cipher suites effectively using DH authentication, i.e. the certificates carry
173DH keys. Not implemented.
174
175=item B<kFZA>, B<aFZA>, B<eFZA>, B<FZA>
176
177ciphers suites using FORTEZZA key exchange, authentication, encryption or all
178FORTEZZA algorithms. Not implemented.
179
180=item B<TLSv1>, B<SSLv3>, B<SSLv2>
181
182TLS v1.0, SSL v3.0 or SSL v2.0 cipher suites respectively.
183
184=item B<DH>
185
186cipher suites using DH, including anonymous DH.
187
188=item B<ADH>
189
190anonymous DH cipher suites.
191
192=item B<3DES>
193
194cipher suites using triple DES.
195
196=item B<DES>
197
198cipher suites using DES (not triple DES).
199
200=item B<RC4>
201
202cipher suites using RC4.
203
204=item B<RC2>
205
206cipher suites using RC2.
207
208=item B<IDEA>
209
210cipher suites using IDEA.
211
212=item B<MD5>
213
214cipher suites using MD5.
215
216=item B<SHA1>, B<SHA>
217
218cipher suites using SHA1.
219
220=back
221
222=head1 CIPHER SUITE NAMES
223
224The following lists give the SSL or TLS cipher suites names from the
225relevant specification and their OpenSSL equivalents.
226
227=head2 SSL v3.0 cipher suites.
228
229 SSL_RSA_WITH_NULL_MD5 NULL-MD5
230 SSL_RSA_WITH_NULL_SHA NULL-SHA
231 SSL_RSA_EXPORT_WITH_RC4_40_MD5 EXP-RC4-MD5
232 SSL_RSA_WITH_RC4_128_MD5 RC4-MD5
233 SSL_RSA_WITH_RC4_128_SHA RC4-SHA
234 SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 EXP-RC2-CBC-MD5
235 SSL_RSA_WITH_IDEA_CBC_SHA IDEA-CBC-SHA
236 SSL_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-DES-CBC-SHA
237 SSL_RSA_WITH_DES_CBC_SHA DES-CBC-SHA
238 SSL_RSA_WITH_3DES_EDE_CBC_SHA DES-CBC3-SHA
239
240 SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA Not implemented.
241 SSL_DH_DSS_WITH_DES_CBC_SHA Not implemented.
242 SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA Not implemented.
243 SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA Not implemented.
244 SSL_DH_RSA_WITH_DES_CBC_SHA Not implemented.
245 SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA Not implemented.
246 SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-DSS-DES-CBC-SHA
247 SSL_DHE_DSS_WITH_DES_CBC_SHA EDH-DSS-CBC-SHA
248 SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA EDH-DSS-DES-CBC3-SHA
249 SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-RSA-DES-CBC-SHA
250 SSL_DHE_RSA_WITH_DES_CBC_SHA EDH-RSA-DES-CBC-SHA
251 SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA EDH-RSA-DES-CBC3-SHA
252
253 SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 EXP-ADH-RC4-MD5
254 SSL_DH_anon_WITH_RC4_128_MD5 ADH-RC4-MD5
255 SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA EXP-ADH-DES-CBC-SHA
256 SSL_DH_anon_WITH_DES_CBC_SHA ADH-DES-CBC-SHA
257 SSL_DH_anon_WITH_3DES_EDE_CBC_SHA ADH-DES-CBC3-SHA
258
259 SSL_FORTEZZA_KEA_WITH_NULL_SHA Not implemented.
260 SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA Not implemented.
261 SSL_FORTEZZA_KEA_WITH_RC4_128_SHA Not implemented.
262
263=head2 TLS v1.0 cipher suites.
264
265 TLS_RSA_WITH_NULL_MD5 NULL-MD5
266 TLS_RSA_WITH_NULL_SHA NULL-SHA
267 TLS_RSA_EXPORT_WITH_RC4_40_MD5 EXP-RC4-MD5
268 TLS_RSA_WITH_RC4_128_MD5 RC4-MD5
269 TLS_RSA_WITH_RC4_128_SHA RC4-SHA
270 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 EXP-RC2-CBC-MD5
271 TLS_RSA_WITH_IDEA_CBC_SHA IDEA-CBC-SHA
272 TLS_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-DES-CBC-SHA
273 TLS_RSA_WITH_DES_CBC_SHA DES-CBC-SHA
274 TLS_RSA_WITH_3DES_EDE_CBC_SHA DES-CBC3-SHA
275
276 TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA Not implemented.
277 TLS_DH_DSS_WITH_DES_CBC_SHA Not implemented.
278 TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA Not implemented.
279 TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA Not implemented.
280 TLS_DH_RSA_WITH_DES_CBC_SHA Not implemented.
281 TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA Not implemented.
282 TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-DSS-DES-CBC-SHA
283 TLS_DHE_DSS_WITH_DES_CBC_SHA EDH-DSS-CBC-SHA
284 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA EDH-DSS-DES-CBC3-SHA
285 TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-RSA-DES-CBC-SHA
286 TLS_DHE_RSA_WITH_DES_CBC_SHA EDH-RSA-DES-CBC-SHA
287 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA EDH-RSA-DES-CBC3-SHA
288
289 TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 EXP-ADH-RC4-MD5
290 TLS_DH_anon_WITH_RC4_128_MD5 ADH-RC4-MD5
291 TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA EXP-ADH-DES-CBC-SHA
292 TLS_DH_anon_WITH_DES_CBC_SHA ADH-DES-CBC-SHA
293 TLS_DH_anon_WITH_3DES_EDE_CBC_SHA ADH-DES-CBC3-SHA
294
295=head2 Additional Export 1024 and other cipher suites
296
297Note: these ciphers can also be used in SSL v3.
298
299 TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA EXP1024-DES-CBC-SHA
300 TLS_RSA_EXPORT1024_WITH_RC4_56_SHA EXP1024-RC4-SHA
301 TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA EXP1024-DHE-DSS-DES-CBC-SHA
302 TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA EXP1024-DHE-DSS-RC4-SHA
303 TLS_DHE_DSS_WITH_RC4_128_SHA DHE-DSS-RC4-SHA
304
305=head2 SSL v2.0 cipher suites.
306
307 SSL_CK_RC4_128_WITH_MD5 RC4-MD5
308 SSL_CK_RC4_128_EXPORT40_WITH_MD5 EXP-RC4-MD5
309 SSL_CK_RC2_128_CBC_WITH_MD5 RC2-MD5
310 SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 EXP-RC2-MD5
311 SSL_CK_IDEA_128_CBC_WITH_MD5 IDEA-CBC-MD5
312 SSL_CK_DES_64_CBC_WITH_MD5 DES-CBC-MD5
313 SSL_CK_DES_192_EDE3_CBC_WITH_MD5 DES-CBC3-MD5
314
315=head1 NOTES
316
317The non-ephemeral DH modes are currently unimplemented in OpenSSL
318because there is no support for DH certificates.
319
320Some compiled versions of OpenSSL may not include all the ciphers
321listed here because some ciphers were excluded at compile time.
322
323=head1 EXAMPLES
324
325Verbose listing of all OpenSSL ciphers including NULL ciphers:
326
327 openssl ciphers -v 'ALL:eNULL'
328
329Include all ciphers except NULL and anonymous DH then sort by
330strength:
331
332 openssl ciphers -v 'ALL:!ADH:@STRENGTH'
333
334Include only 3DES ciphers and then place RSA ciphers last:
335
336 openssl ciphers -v '3DES:+RSA'
337
338=head1 SEE ALSO
339
340L<s_client(1)|s_client(1)>, L<s_server(1)|s_server(1)>, L<ssl(3)|ssl(3)>
341
342=cut
diff --git a/src/lib/libssl/src/doc/apps/config.pod b/src/lib/libssl/src/doc/apps/config.pod
new file mode 100644
index 0000000000..ce874a42ce
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/config.pod
@@ -0,0 +1,138 @@
1
2=pod
3
4=head1 NAME
5
6config - OpenSSL CONF library configuration files
7
8=head1 DESCRIPTION
9
10The OpenSSL CONF library can be used to read configuration files.
11It is used for the OpenSSL master configuration file B<openssl.cnf>
12and in a few other places like B<SPKAC> files and certificate extension
13files for the B<x509> utility.
14
15A configuration file is divided into a number of sections. Each section
16starts with a line B<[ section_name ]> and ends when a new section is
17started or end of file is reached. A section name can consist of
18alphanumeric characters and underscores.
19
20The first section of a configuration file is special and is referred
21to as the B<default> section this is usually unnamed and is from the
22start of file until the first named section. When a name is being looked up
23it is first looked up in a named section (if any) and then the
24default section.
25
26The environment is mapped onto a section called B<ENV>.
27
28Comments can be included by preceding them with the B<#> character
29
30Each section in a configuration file consists of a number of name and
31value pairs of the form B<name=value>
32
33The B<name> string can contain any alphanumeric characters as well as
34a few punctuation symbols such as B<.> B<,> B<;> and B<_>.
35
36The B<value> string consists of the string following the B<=> character
37until end of line with any leading and trailing white space removed.
38
39The value string undergoes variable expansion. This can be done by
40including the form B<$var> or B<${var}>: this will substitute the value
41of the named variable in the current section. It is also possible to
42substitute a value from another section using the syntax B<$section::name>
43or B<${section::name}>. By using the form B<$ENV::name> environment
44variables can be substituted. It is also possible to assign values to
45environment variables by using the name B<ENV::name>, this will work
46if the program looks up environment variables using the B<CONF> library
47instead of calling B<getenv()> directly.
48
49It is possible to escape certain characters by using any kind of quote
50or the B<\> character. By making the last character of a line a B<\>
51a B<value> string can be spread across multiple lines. In addition
52the sequences B<\n>, B<\r>, B<\b> and B<\t> are recognized.
53
54=head1 NOTES
55
56If a configuration file attempts to expand a variable that doesn't exist
57then an error is flagged and the file will not load. This can happen
58if an attempt is made to expand an environment variable that doesn't
59exist. For example the default OpenSSL master configuration file used
60the value of B<HOME> which may not be defined on non Unix systems.
61
62This can be worked around by including a B<default> section to provide
63a default value: then if the environment lookup fails the default value
64will be used instead. For this to work properly the default value must
65be defined earlier in the configuration file than the expansion. See
66the B<EXAMPLES> section for an example of how to do this.
67
68If the same variable exists in the same section then all but the last
69value will be silently ignored. In certain circumstances such as with
70DNs the same field may occur multiple times. This is usually worked
71around by ignoring any characters before an initial B<.> e.g.
72
73 1.OU="My first OU"
74 2.OU="My Second OU"
75
76=head1 EXAMPLES
77
78Here is a sample configuration file using some of the features
79mentioned above.
80
81 # This is the default section.
82
83 HOME=/temp
84 RANDFILE= ${ENV::HOME}/.rnd
85 configdir=$ENV::HOME/config
86
87 [ section_one ]
88
89 # We are now in section one.
90
91 # Quotes permit leading and trailing whitespace
92 any = " any variable name "
93
94 other = A string that can \
95 cover several lines \
96 by including \\ characters
97
98 message = Hello World\n
99
100 [ section_two ]
101
102 greeting = $section_one::message
103
104This next example shows how to expand environment variables safely.
105
106Suppose you want a variable called B<tmpfile> to refer to a
107temporary filename. The directory it is placed in can determined by
108the the B<TEMP> or B<TMP> environment variables but they may not be
109set to any value at all. If you just include the environment variable
110names and the variable doesn't exist then this will cause an error when
111an attempt is made to load the configuration file. By making use of the
112default section both values can be looked up with B<TEMP> taking
113priority and B</tmp> used if neither is defined:
114
115 TMP=/tmp
116 # The above value is used if TMP isn't in the environment
117 TEMP=$ENV::TMP
118 # The above value is used if TEMP isn't in the environment
119 tmpfile=${ENV::TEMP}/tmp.filename
120
121=head1 BUGS
122
123Currently there is no way to include characters using the octal B<\nnn>
124form. Strings are all null terminated so nulls cannot form part of
125the value.
126
127The escaping isn't quite right: if you want to use sequences like B<\n>
128you can't use any quote escaping on the same line.
129
130Files are loaded in a single pass. This means that an variable expansion
131will only work if the variables referenced are defined earlier in the
132file.
133
134=head1 SEE ALSO
135
136L<x509(1)|x509(1)>, L<req(1)|req(1)>, L<ca(1)|ca(1)>
137
138=cut
diff --git a/src/lib/libssl/src/doc/apps/crl.pod b/src/lib/libssl/src/doc/apps/crl.pod
new file mode 100644
index 0000000000..a40c873b95
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/crl.pod
@@ -0,0 +1,117 @@
1=pod
2
3=head1 NAME
4
5crl - CRL utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<crl>
10[B<-inform PEM|DER>]
11[B<-outform PEM|DER>]
12[B<-text>]
13[B<-in filename>]
14[B<-out filename>]
15[B<-noout>]
16[B<-hash>]
17[B<-issuer>]
18[B<-lastupdate>]
19[B<-nextupdate>]
20[B<-CAfile file>]
21[B<-CApath dir>]
22
23=head1 DESCRIPTION
24
25The B<crl> command processes CRL files in DER or PEM format.
26
27=head1 COMMAND OPTIONS
28
29=over 4
30
31=item B<-inform DER|PEM>
32
33This specifies the input format. B<DER> format is DER encoded CRL
34structure. B<PEM> (the default) is a base64 encoded version of
35the DER form with header and footer lines.
36
37=item B<-outform DER|PEM>
38
39This specifies the output format, the options have the same meaning as the
40B<-inform> option.
41
42=item B<-in filename>
43
44This specifies the input filename to read from or standard input if this
45option is not specified.
46
47=item B<-out filename>
48
49specifies the output filename to write to or standard output by
50default.
51
52=item B<-text>
53
54print out the CRL in text form.
55
56=item B<-noout>
57
58don't output the encoded version of the CRL.
59
60=item B<-hash>
61
62output a hash of the issuer name. This can be use to lookup CRLs in
63a directory by issuer name.
64
65=item B<-issuer>
66
67output the issuer name.
68
69=item B<-lastupdate>
70
71output the lastUpdate field.
72
73=item B<-nextupdate>
74
75output the nextUpdate field.
76
77=item B<-CAfile file>
78
79verify the signature on a CRL by looking up the issuing certificate in
80B<file>
81
82=item B<-CApath dir>
83
84verify the signature on a CRL by looking up the issuing certificate in
85B<dir>. This directory must be a standard certificate directory: that
86is a hash of each subject name (using B<x509 -hash>) should be linked
87to each certificate.
88
89=back
90
91=head1 NOTES
92
93The PEM CRL format uses the header and footer lines:
94
95 -----BEGIN X509 CRL-----
96 -----END X509 CRL-----
97
98=head1 EXAMPLES
99
100Convert a CRL file from PEM to DER:
101
102 openssl crl -in crl.pem -outform DER -out crl.der
103
104Output the text form of a DER encoded certificate:
105
106 openssl crl -in crl.der -text -noout
107
108=head1 BUGS
109
110Ideally it should be possible to create a CRL using appropriate options
111and files too.
112
113=head1 SEE ALSO
114
115L<crl2pkcs7(1)|crl2pkcs7(1)>, L<ca(1)|ca(1)>, L<x509(1)|x509(1)>
116
117=cut
diff --git a/src/lib/libssl/src/doc/apps/crl2pkcs7.pod b/src/lib/libssl/src/doc/apps/crl2pkcs7.pod
new file mode 100644
index 0000000000..da199b044a
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/crl2pkcs7.pod
@@ -0,0 +1,90 @@
1=pod
2
3=head1 NAME
4
5crl2pkcs7 - Create a PKCS#7 structure from a CRL and certificates.
6
7=head1 SYNOPSIS
8
9B<openssl> B<pkcs7>
10[B<-inform PEM|DER>]
11[B<-outform PEM|DER>]
12[B<-in filename>]
13[B<-out filename>]
14[B<-print_certs>]
15
16=head1 DESCRIPTION
17
18The B<crl2pkcs7> command takes an optional CRL and one or more
19certificates and converts them into a PKCS#7 degenerate "certificates
20only" structure.
21
22=head1 COMMAND OPTIONS
23
24=over 4
25
26=item B<-inform DER|PEM>
27
28This specifies the CRL input format. B<DER> format is DER encoded CRL
29structure.B<PEM> (the default) is a base64 encoded version of
30the DER form with header and footer lines.
31
32=item B<-outform DER|PEM>
33
34This specifies the PKCS#7 structure output format. B<DER> format is DER
35encoded PKCS#7 structure.B<PEM> (the default) is a base64 encoded version of
36the DER form with header and footer lines.
37
38=item B<-in filename>
39
40This specifies the input filename to read a CRL from or standard input if this
41option is not specified.
42
43=item B<-out filename>
44
45specifies the output filename to write the PKCS#7 structure to or standard
46output by default.
47
48=item B<-certfile filename>
49
50specifies a filename containing one or more certificates in B<PEM> format.
51All certificates in the file will be added to the PKCS#7 structure. This
52option can be used more than once to read certificates form multiple
53files.
54
55=item B<-nocrl>
56
57normally a CRL is included in the output file. With this option no CRL is
58included in the output file and a CRL is not read from the input file.
59
60=back
61
62=head1 EXAMPLES
63
64Create a PKCS#7 structure from a certificate and CRL:
65
66 openssl crl2pkcs7 -in crl.pem -certfile cert.pem -out p7.pem
67
68Creates a PKCS#7 structure in DER format with no CRL from several
69different certificates:
70
71 openssl crl2pkcs7 -nocrl -certfile newcert.pem
72 -certfile demoCA/cacert.pem -outform DER -out p7.der
73
74=head1 NOTES
75
76The output file is a PKCS#7 signed data structure containing no signers and
77just certificates and an optional CRL.
78
79This utility can be used to send certificates and CAs to Netscape as part of
80the certificate enrollment process. This involves sending the DER encoded output
81as MIME type application/x-x509-user-cert.
82
83The B<PEM> encoded form with the header and footer lines removed can be used to
84install user certificates and CAs in MSIE using the Xenroll control.
85
86=head1 SEE ALSO
87
88L<pkcs7(1)|pkcs7(1)>
89
90=cut
diff --git a/src/lib/libssl/src/doc/apps/dgst.pod b/src/lib/libssl/src/doc/apps/dgst.pod
new file mode 100644
index 0000000000..cbf2cc529a
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/dgst.pod
@@ -0,0 +1,49 @@
1=pod
2
3=head1 NAME
4
5dgst, md5, md2, sha1, sha, mdc2, ripemd160 - message digests
6
7=head1 SYNOPSIS
8
9[B<dgst>]
10[B<-md5|-md2|-sha1|-sha|mdc2|-ripemd160>]
11[B<-c>]
12[B<-d>]
13[B<file...>]
14
15[B<md5|md2|sha1|sha|mdc2|ripemd160>]
16[B<-c>]
17[B<-d>]
18[B<file...>]
19
20=head1 DESCRIPTION
21
22The digest functions print out the message digest of a supplied file or files
23in hexadecimal form.
24
25=head1 OPTIONS
26
27=over 4
28
29=item B<-c>
30
31print out the digest in two digit groups separated by colons.
32
33=item B<-d>
34
35print out BIO debugging information.
36
37=item B<file...>
38
39file or files to digest. If no files are specified then standard input is
40used.
41
42=back
43
44=head1 NOTES
45
46The digest of choice for all new applications is SHA1. Other digests are
47however still widely used.
48
49=cut
diff --git a/src/lib/libssl/src/doc/apps/dhparam.pod b/src/lib/libssl/src/doc/apps/dhparam.pod
new file mode 100644
index 0000000000..6b237ec05a
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/dhparam.pod
@@ -0,0 +1,115 @@
1=pod
2
3=head1 NAME
4
5dhparam - DH parameter manipulation and generation
6
7=head1 SYNOPSIS
8
9B<openssl dh>
10[B<-inform DER|PEM>]
11[B<-outform DER|PEM>]
12[B<-in filename>]
13[B<-out filename>]
14[B<-noout>]
15[B<-text>]
16[B<-C>]
17[B<-2>]
18[B<-5>]
19[B<-rand file(s)>]
20[numbits]
21
22=head1 DESCRIPTION
23
24This command is used to manipulate DH parameter files.
25
26=head1 OPTIONS
27
28=over 4
29
30=item B<-inform DER|PEM>
31
32This specifies the input format. The B<DER> option uses an ASN1 DER encoded
33form compatible with the PKCS#3 DHparameter structure. The PEM form is the
34default format: it consists of the B<DER> format base64 encoded with
35additional header and footer lines.
36
37=item B<-outform DER|PEM>
38
39This specifies the output format, the options have the same meaning as the
40B<-inform> option.
41
42=item B<-in filename>
43
44This specifies the input filename to read parameters from or standard input if
45this option is not specified.
46
47=item B<-out filename>
48
49This specifies the output filename parameters to. Standard output is used
50if this option is not present. The output filename should B<not> be the same
51as the input filename.
52
53=item B<-2>, B<-5>
54
55The generator to use, either 2 or 5. 2 is the default. If present then the
56input file is ignored and parameters are generated instead.
57
58=item B<-rand file(s)>
59
60a file or files containing random data used to seed the random number
61generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
62Multiple files can be specified separated by a OS-dependent character.
63The separator is B<;> for MS-Windows, B<,> for OpenVSM, and B<:> for
64all others.
65
66=item B<numbits>
67
68this option specifies that a parameter set should be generated of size
69B<numbits>. It must be the last option. If not present then a value of 512
70is used. If this option is present then the input file is ignored and
71parameters are generated instead.
72
73=item B<-noout>
74
75this option inhibits the output of the encoded version of the parameters.
76
77=item B<-text>
78
79this option prints out the DH parameters in human readable form.
80
81=item B<-C>
82
83this option converts the parameters into C code. The parameters can then
84be loaded by calling the B<get_dhXXX()> function.
85
86=back
87
88=head1 WARNINGS
89
90The program B<dhparam> combines the functionality of the programs B<dh> and
91B<gendh> in previous versions of OpenSSL and SSLeay. The B<dh> and B<gendh>
92programs are retained for now but may have different purposes in future
93versions of OpenSSL.
94
95=head1 NOTES
96
97PEM format DH parameters use the header and footer lines:
98
99 -----BEGIN DH PARAMETERS-----
100 -----END DH PARAMETERS-----
101
102OpenSSL currently only supports the older PKCS#3 DH, not the newer X9.42
103DH.
104
105This program manipulates DH parameters not keys.
106
107=head1 BUGS
108
109There should be a way to generate and manipulate DH keys.
110
111=head1 SEE ALSO
112
113L<dsaparam(1)|dsaparam(1)>
114
115=cut
diff --git a/src/lib/libssl/src/doc/apps/dsa.pod b/src/lib/libssl/src/doc/apps/dsa.pod
new file mode 100644
index 0000000000..28e534bb95
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/dsa.pod
@@ -0,0 +1,150 @@
1=pod
2
3=head1 NAME
4
5dsa - DSA key processing
6
7=head1 SYNOPSIS
8
9B<openssl> B<dsa>
10[B<-inform PEM|DER>]
11[B<-outform PEM|DER>]
12[B<-in filename>]
13[B<-passin arg>]
14[B<-out filename>]
15[B<-passout arg>]
16[B<-des>]
17[B<-des3>]
18[B<-idea>]
19[B<-text>]
20[B<-noout>]
21[B<-modulus>]
22[B<-pubin>]
23[B<-pubout>]
24
25=head1 DESCRIPTION
26
27The B<dsa> command processes DSA keys. They can be converted between various
28forms and their components printed out. B<Note> This command uses the
29traditional SSLeay compatible format for private key encryption: newer
30applications should use the more secure PKCS#8 format using the B<pkcs8>
31
32=head1 COMMAND OPTIONS
33
34=over 4
35
36=item B<-inform DER|PEM>
37
38This specifies the input format. The B<DER> option with a private key uses
39an ASN1 DER encoded form of an ASN.1 SEQUENCE consisting of the values of
40version (currently zero), p, q, g, the public and private key components
41respectively as ASN.1 INTEGERs. When used with a public key it uses a
42SubjectPublicKeyInfo structure: it is an error if the key is not DSA.
43
44The B<PEM> form is the default format: it consists of the B<DER> format base64
45encoded with additional header and footer lines. In the case of a private key
46PKCS#8 format is also accepted.
47
48=item B<-outform DER|PEM>
49
50This specifies the output format, the options have the same meaning as the
51B<-inform> option.
52
53=item B<-in filename>
54
55This specifies the input filename to read a key from or standard input if this
56option is not specified. If the key is encrypted a pass phrase will be
57prompted for.
58
59=item B<-passin arg>
60
61the input file password source. For more information about the format of B<arg>
62see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
63
64=item B<-out filename>
65
66This specifies the output filename to write a key to or standard output by
67is not specified. If any encryption options are set then a pass phrase will be
68prompted for. The output filename should B<not> be the same as the input
69filename.
70
71=item B<-passout arg>
72
73the output file password source. For more information about the format of B<arg>
74see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
75
76=item B<-des|-des3|-idea>
77
78These options encrypt the private key with the DES, triple DES, or the
79IDEA ciphers respectively before outputting it. A pass phrase is prompted for.
80If none of these options is specified the key is written in plain text. This
81means that using the B<dsa> utility to read in an encrypted key with no
82encryption option can be used to remove the pass phrase from a key, or by
83setting the encryption options it can be use to add or change the pass phrase.
84These options can only be used with PEM format output files.
85
86=item B<-text>
87
88prints out the public, private key components and parameters.
89
90=item B<-noout>
91
92this option prevents output of the encoded version of the key.
93
94=item B<-modulus>
95
96this option prints out the value of the public key component of the key.
97
98=item B<-pubin>
99
100by default a private key is read from the input file: with this option a
101public key is read instead.
102
103=item B<-pubout>
104
105by default a private key is output. With this option a public
106key will be output instead. This option is automatically set if the input is
107a public key.
108
109=back
110
111=head1 NOTES
112
113The PEM private key format uses the header and footer lines:
114
115 -----BEGIN DSA PRIVATE KEY-----
116 -----END DSA PRIVATE KEY-----
117
118The PEM public key format uses the header and footer lines:
119
120 -----BEGIN PUBLIC KEY-----
121 -----END PUBLIC KEY-----
122
123=head1 EXAMPLES
124
125To remove the pass phrase on a DSA private key:
126
127 openssl dsa -in key.pem -out keyout.pem
128
129To encrypt a private key using triple DES:
130
131 openssl dsa -in key.pem -des3 -out keyout.pem
132
133To convert a private key from PEM to DER format:
134
135 openssl dsa -in key.pem -outform DER -out keyout.der
136
137To print out the components of a private key to standard output:
138
139 openssl dsa -in key.pem -text -noout
140
141To just output the public part of a private key:
142
143 openssl dsa -in key.pem -pubout -out pubkey.pem
144
145=head1 SEE ALSO
146
147L<dsaparam(1)|dsaparam(1)>, L<gendsa(1)|gendsa(1)>, L<rsa(1)|rsa(1)>,
148L<genrsa(1)|genrsa(1)>
149
150=cut
diff --git a/src/lib/libssl/src/doc/apps/dsaparam.pod b/src/lib/libssl/src/doc/apps/dsaparam.pod
new file mode 100644
index 0000000000..8647f34698
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/dsaparam.pod
@@ -0,0 +1,102 @@
1=pod
2
3=head1 NAME
4
5dsaparam - DSA parameter manipulation and generation
6
7=head1 SYNOPSIS
8
9B<openssl dsaparam>
10[B<-inform DER|PEM>]
11[B<-outform DER|PEM>]
12[B<-in filename>]
13[B<-out filename>]
14[B<-noout>]
15[B<-text>]
16[B<-C>]
17[B<-rand file(s)>]
18[B<-genkey>]
19[B<numbits>]
20
21=head1 DESCRIPTION
22
23This command is used to manipulate or generate DSA parameter files.
24
25=head1 OPTIONS
26
27=over 4
28
29=item B<-inform DER|PEM>
30
31This specifies the input format. The B<DER> option uses an ASN1 DER encoded
32form compatible with RFC2459 (PKIX) DSS-Parms that is a SEQUENCE consisting
33of p, q and g respectively. The PEM form is the default format: it consists
34of the B<DER> format base64 encoded with additional header and footer lines.
35
36=item B<-outform DER|PEM>
37
38This specifies the output format, the options have the same meaning as the
39B<-inform> option.
40
41=item B<-in filename>
42
43This specifies the input filename to read parameters from or standard input if
44this option is not specified. If the B<numbits> parameter is included then
45this option will be ignored.
46
47=item B<-out filename>
48
49This specifies the output filename parameters to. Standard output is used
50if this option is not present. The output filename should B<not> be the same
51as the input filename.
52
53=item B<-noout>
54
55this option inhibits the output of the encoded version of the parameters.
56
57=item B<-text>
58
59this option prints out the DSA parameters in human readable form.
60
61=item B<-C>
62
63this option converts the parameters into C code. The parameters can then
64be loaded by calling the B<get_dsaXXX()> function.
65
66=item B<-genkey>
67
68this option will generate a DSA either using the specified or generated
69parameters.
70
71=item B<-rand file(s)>
72
73a file or files containing random data used to seed the random number
74generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
75Multiple files can be specified separated by a OS-dependent character.
76The separator is B<;> for MS-Windows, B<,> for OpenVSM, and B<:> for
77all others.
78
79=item B<numbits>
80
81this option specifies that a parameter set should be generated of size
82B<numbits>. It must be the last option. If this option is included then
83the input file (if any) is ignored.
84
85=back
86
87=head1 NOTES
88
89PEM format DSA parameters use the header and footer lines:
90
91 -----BEGIN DSA PARAMETERS-----
92 -----END DSA PARAMETERS-----
93
94DSA parameter generation is a slow process and as a result the same set of
95DSA parameters is often used to generate several distinct keys.
96
97=head1 SEE ALSO
98
99L<gendsa(1)|gendsa(1)>, L<dsa(1)|dsa(1)>, L<genrsa(1)|genrsa(1)>,
100L<rsa(1)|rsa(1)>
101
102=cut
diff --git a/src/lib/libssl/src/doc/apps/enc.pod b/src/lib/libssl/src/doc/apps/enc.pod
new file mode 100644
index 0000000000..e436ccc37e
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/enc.pod
@@ -0,0 +1,257 @@
1=pod
2
3=head1 NAME
4
5enc - symmetric cipher routines
6
7=head1 SYNOPSIS
8
9B<openssl enc -ciphername>
10[B<-in filename>]
11[B<-out filename>]
12[B<-pass arg>]
13[B<-e>]
14[B<-d>]
15[B<-a>]
16[B<-A>]
17[B<-k password>]
18[B<-kfile filename>]
19[B<-K key>]
20[B<-iv IV>]
21[B<-p>]
22[B<-P>]
23[B<-bufsize number>]
24[B<-debug>]
25
26=head1 DESCRIPTION
27
28The symmetric cipher commands allow data to be encrypted or decrypted
29using various block and stream ciphers using keys based on passwords
30or explicitly provided. Base64 encoding or decoding can also be performed
31either by itself or in addition to the encryption or decryption.
32
33=head1 OPTIONS
34
35=over 4
36
37=item B<-in filename>
38
39the input filename, standard input by default.
40
41=item B<-out filename>
42
43the output filename, standard output by default.
44
45=item B<-pass arg>
46
47the password source. For more information about the format of B<arg>
48see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
49
50=item B<-salt>
51
52use a salt in the key derivation routines. This option should B<ALWAYS>
53be used unless compatibility with previous versions of OpenSSL or SSLeay
54is required. This option is only present on OpenSSL versions 0.9.5 or
55above.
56
57=item B<-nosalt>
58
59don't use a salt in the key derivation routines. This is the default for
60compatibility with previous versions of OpenSSL and SSLeay.
61
62=item B<-e>
63
64encrypt the input data: this is the default.
65
66=item B<-d>
67
68decrypt the input data.
69
70=item B<-a>
71
72base64 process the data. This means that if encryption is taking place
73the data is base64 encoded after encryption. If decryption is set then
74the input data is base64 decoded before being decrypted.
75
76=item B<-A>
77
78if the B<-a> option is set then base64 process the data on one line.
79
80=item B<-k password>
81
82the password to derive the key from. This is for compatibility with previous
83versions of OpenSSL. Superseded by the B<-pass> argument.
84
85=item B<-kfile filename>
86
87read the password to derive the key from the first line of B<filename>.
88This is for computability with previous versions of OpenSSL. Superseded by
89the B<-pass> argument.
90
91=item B<-S salt>
92
93the actual salt to use: this must be represented as a string comprised only
94of hex digits.
95
96=item B<-K key>
97
98the actual key to use: this must be represented as a string comprised only
99of hex digits.
100
101=item B<-iv IV>
102
103the actual IV to use: this must be represented as a string comprised only
104of hex digits.
105
106=item B<-p>
107
108print out the key and IV used.
109
110=item B<-P>
111
112print out the key and IV used then immediately exit: don't do any encryption
113or decryption.
114
115=item B<-bufsize number>
116
117set the buffer size for I/O
118
119=item B<-debug>
120
121debug the BIOs used for I/O.
122
123=back
124
125=head1 NOTES
126
127The program can be called either as B<openssl ciphername> or
128B<openssl enc -ciphername>.
129
130A password will be prompted for to derive the key and IV if necessary.
131
132The B<-salt> option should B<ALWAYS> be used if the key is being derived
133from a password unless you want compatibility with previous versions of
134OpenSSL and SSLeay.
135
136Without the B<-salt> option it is possible to perform efficient dictionary
137attacks on the password and to attack stream cipher encrypted data. The reason
138for this is that without the salt the same password always generates the same
139encryption key. When the salt is being used the first eight bytes of the
140encrypted data are reserved for the salt: it is generated at random when
141encrypting a file and read from the encrypted file when it is decrypted.
142
143Some of the ciphers do not have large keys and others have security
144implications if not used correctly. A beginner is advised to just use
145a strong block cipher in CBC mode such as bf or des3.
146
147All the block ciphers use PKCS#5 padding also known as standard block
148padding: this allows a rudimentary integrity or password check to be
149performed. However since the chance of random data passing the test is
150better than 1 in 256 it isn't a very good test.
151
152All RC2 ciphers have the same key and effective key length.
153
154Blowfish and RC5 algorithms use a 128 bit key.
155
156=head1 SUPPORTED CIPHERS
157
158 base64 Base 64
159
160 bf-cbc Blowfish in CBC mode
161 bf Alias for bf-cbc
162 bf-cfb Blowfish in CFB mode
163 bf-ecb Blowfish in ECB mode
164 bf-ofb Blowfish in OFB mode
165
166 cast-cbc CAST in CBC mode
167 cast Alias for cast-cbc
168 cast5-cbc CAST5 in CBC mode
169 cast5-cfb CAST5 in CFB mode
170 cast5-ecb CAST5 in ECB mode
171 cast5-ofb CAST5 in OFB mode
172
173 des-cbc DES in CBC mode
174 des Alias for des-cbc
175 des-cfb DES in CBC mode
176 des-ofb DES in OFB mode
177 des-ecb DES in ECB mode
178
179 des-ede-cbc Two key triple DES EDE in CBC mode
180 des-ede Alias for des-ede
181 des-ede-cfb Two key triple DES EDE in CFB mode
182 des-ede-ofb Two key triple DES EDE in OFB mode
183
184 des-ede3-cbc Three key triple DES EDE in CBC mode
185 des-ede3 Alias for des-ede3-cbc
186 des3 Alias for des-ede3-cbc
187 des-ede3-cfb Three key triple DES EDE CFB mode
188 des-ede3-ofb Three key triple DES EDE in OFB mode
189
190 desx DESX algorithm.
191
192 idea-cbc IDEA algorithm in CBC mode
193 idea same as idea-cbc
194 idea-cfb IDEA in CFB mode
195 idea-ecb IDEA in ECB mode
196 idea-ofb IDEA in OFB mode
197
198 rc2-cbc 128 bit RC2 in CBC mode
199 rc2 Alias for rc2-cbc
200 rc2-cfb 128 bit RC2 in CBC mode
201 rc2-ecb 128 bit RC2 in CBC mode
202 rc2-ofb 128 bit RC2 in CBC mode
203 rc2-64-cbc 64 bit RC2 in CBC mode
204 rc2-40-cbc 40 bit RC2 in CBC mode
205
206 rc4 128 bit RC4
207 rc4-64 64 bit RC4
208 rc4-40 40 bit RC4
209
210 rc5-cbc RC5 cipher in CBC mode
211 rc5 Alias for rc5-cbc
212 rc5-cfb RC5 cipher in CBC mode
213 rc5-ecb RC5 cipher in CBC mode
214 rc5-ofb RC5 cipher in CBC mode
215
216=head1 EXAMPLES
217
218Just base64 encode a binary file:
219
220 openssl base64 -in file.bin -out file.b64
221
222Decode the same file
223
224 openssl base64 -d -in file.b64 -out file.bin
225
226Encrypt a file using triple DES in CBC mode using a prompted password:
227
228 openssl des3 -salt -in file.txt -out file.des3
229
230Decrypt a file using a supplied password:
231
232 openssl des3 -d -salt -in file.des3 -out file.txt -k mypassword
233
234Encrypt a file then base64 encode it (so it can be sent via mail for example)
235using Blowfish in CBC mode:
236
237 openssl bf -a -salt -in file.txt -out file.bf
238
239Base64 decode a file then decrypt it:
240
241 openssl bf -d -salt -a -in file.bf -out file.txt
242
243Decrypt some data using a supplied 40 bit RC4 key:
244
245 openssl rc4-40 -in file.rc4 -out file.txt -K 0102030405
246
247=head1 BUGS
248
249The B<-A> option when used with large files doesn't work properly.
250
251There should be an option to allow an iteration count to be included.
252
253Like the EVP library the B<enc> program only supports a fixed number of
254algorithms with certain parameters. So if, for example, you want to use RC2
255with a 76 bit key or RC4 with an 84 bit key you can't use this program.
256
257=cut
diff --git a/src/lib/libssl/src/doc/apps/gendsa.pod b/src/lib/libssl/src/doc/apps/gendsa.pod
new file mode 100644
index 0000000000..3314ace517
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/gendsa.pod
@@ -0,0 +1,58 @@
1=pod
2
3=head1 NAME
4
5gendsa - generate a DSA private key from a set of parameters
6
7=head1 SYNOPSIS
8
9B<openssl> B<gendsa>
10[B<-out filename>]
11[B<-des>]
12[B<-des3>]
13[B<-idea>]
14[B<-rand file(s)>]
15[B<paramfile>]
16
17=head1 DESCRIPTION
18
19The B<gendsa> command generates a DSA private key from a DSA parameter file
20(which will be typically generated by the B<openssl dsaparam> command).
21
22=head1 OPTIONS
23
24=over 4
25
26=item B<-des|-des3|-idea>
27
28These options encrypt the private key with the DES, triple DES, or the
29IDEA ciphers respectively before outputting it. A pass phrase is prompted for.
30If none of these options is specified no encryption is used.
31
32=item B<-rand file(s)>
33
34a file or files containing random data used to seed the random number
35generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
36Multiple files can be specified separated by a OS-dependent character.
37The separator is B<;> for MS-Windows, B<,> for OpenVSM, and B<:> for
38all others.
39
40=item B<paramfile>
41
42This option specifies the DSA parameter file to use. The parameters in this
43file determine the size of the private key. DSA parameters can be generated
44and examined using the B<openssl dsaparam> command.
45
46=back
47
48=head1 NOTES
49
50DSA key generation is little more than random number generation so it is
51much quicker that RSA key generation for example.
52
53=head1 SEE ALSO
54
55L<dsaparam(1)|dsaparam(1)>, L<dsa(1)|dsa(1)>, L<genrsa(1)|genrsa(1)>,
56L<rsa(1)|rsa(1)>
57
58=cut
diff --git a/src/lib/libssl/src/doc/apps/genrsa.pod b/src/lib/libssl/src/doc/apps/genrsa.pod
new file mode 100644
index 0000000000..a2d878410b
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/genrsa.pod
@@ -0,0 +1,85 @@
1=pod
2
3=head1 NAME
4
5genrsa - generate an RSA private key
6
7=head1 SYNOPSIS
8
9B<openssl> B<genrsa>
10[B<-out filename>]
11[B<-passout arg>]
12[B<-des>]
13[B<-des3>]
14[B<-idea>]
15[B<-f4>]
16[B<-3>]
17[B<-rand file(s)>]
18[B<numbits>]
19
20=head1 DESCRIPTION
21
22The B<genrsa> command generates an RSA private key.
23
24=head1 OPTIONS
25
26=over 4
27
28=item B<-out filename>
29
30the output filename. If this argument is not specified then standard output is
31used.
32
33=item B<-passout arg>
34
35the output file password source. For more information about the format of B<arg>
36see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
37
38=item B<-des|-des3|-idea>
39
40These options encrypt the private key with the DES, triple DES, or the
41IDEA ciphers respectively before outputting it. If none of these options is
42specified no encryption is used. If encryption is used a pass phrase is prompted
43for if it is not supplied via the B<-passout> argument.
44
45=item B<-F4|-3>
46
47the public exponent to use, either 65537 or 3. The default is 65537.
48
49=item B<-rand file(s)>
50
51a file or files containing random data used to seed the random number
52generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
53Multiple files can be specified separated by a OS-dependent character.
54The separator is B<;> for MS-Windows, B<,> for OpenVSM, and B<:> for
55all others.
56
57=item B<numbits>
58
59the size of the private key to generate in bits. This must be the last option
60specified. The default is 512.
61
62=back
63
64=head1 NOTES
65
66RSA private key generation essentially involves the generation of two prime
67numbers. When generating a private key various symbols will be output to
68indicate the progress of the generation. A B<.> represents each number which
69has passed an initial sieve test, B<+> means a number has passed a single
70round of the Miller-Rabin primality test. A newline means that the number has
71passed all the prime tests (the actual number depends on the key size).
72
73Because key generation is a random process the time taken to generate a key
74may vary somewhat.
75
76=head1 BUGS
77
78A quirk of the prime generation algorithm is that it cannot generate small
79primes. Therefore the number of bits should not be less that 64. For typical
80private keys this will not matter because for security reasons they will
81be much larger (typically 1024 bits).
82
83=head1 SEE ALSO
84
85L<gendsa(1)|gendsa(1)>
diff --git a/src/lib/libssl/src/doc/apps/nseq.pod b/src/lib/libssl/src/doc/apps/nseq.pod
new file mode 100644
index 0000000000..989c3108fb
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/nseq.pod
@@ -0,0 +1,70 @@
1=pod
2
3=head1 NAME
4
5nseq - create or examine a netscape certificate sequence
6
7=head1 SYNOPSIS
8
9B<openssl> B<nseq>
10[B<-in filename>]
11[B<-out filename>]
12[B<-toseq>]
13
14=head1 DESCRIPTION
15
16The B<nseq> command takes a file containing a Netscape certificate
17sequence and prints out the certificates contained in it or takes a
18file of certificates and converts it into a Netscape certificate
19sequence.
20
21=head1 COMMAND OPTIONS
22
23=over 4
24
25=item B<-in filename>
26
27This specifies the input filename to read or standard input if this
28option is not specified.
29
30=item B<-out filename>
31
32specifies the output filename or standard output by default.
33
34=item B<-toseq>
35
36normally a Netscape certificate sequence will be input and the output
37is the certificates contained in it. With the B<-toseq> option the
38situation is reversed: a Netscape certificate sequence is created from
39a file of certificates.
40
41=back
42
43=head1 EXAMPLES
44
45Output the certificates in a Netscape certificate sequence
46
47 openssl nseq -in nseq.pem -out certs.pem
48
49Create a Netscape certificate sequence
50
51 openssl nseq -in certs.pem -toseq -out nseq.pem
52
53=head1 NOTES
54
55The B<PEM> encoded form uses the same headers and footers as a certificate:
56
57 -----BEGIN CERTIFICATE-----
58 -----END CERTIFICATE-----
59
60A Netscape certificate sequence is a Netscape specific form that can be sent
61to browsers as an alternative to the standard PKCS#7 format when several
62certificates are sent to the browser: for example during certificate enrollment.
63It is used by Netscape certificate server for example.
64
65=head1 BUGS
66
67This program needs a few more options: like allowing DER or PEM input and
68output files and allowing multiple certificate files to be used.
69
70=cut
diff --git a/src/lib/libssl/src/doc/apps/openssl.pod b/src/lib/libssl/src/doc/apps/openssl.pod
new file mode 100644
index 0000000000..9b1320606b
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/openssl.pod
@@ -0,0 +1,298 @@
1
2=pod
3
4=head1 NAME
5
6openssl - OpenSSL command line tool
7
8=head1 SYNOPSIS
9
10B<openssl>
11I<command>
12[ I<command_opts> ]
13[ I<command_args> ]
14
15=head1 DESCRIPTION
16
17OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer (SSL
18v2/v3) and Transport Layer Security (TLS v1) network protocols and related
19cryptography standards required by them.
20
21The B<openssl> program is a command line tool for using the various
22cryptography functions of OpenSSL's B<crypto> library from the shell.
23It can be used for
24
25 o Creation of RSA, DH and DSA key parameters
26 o Creation of X.509 certificates, CSRs and CRLs
27 o Calculation of Message Digests
28 o Encryption and Decryption with Ciphers
29 o SSL/TLS Client and Server Tests
30 o Handling of S/MIME signed or encrypted mail
31
32=head1 COMMAND SUMMARY
33
34The B<openssl> program provides a rich variety of commands (I<command> in the
35SYNOPSIS above), each of which often has a wealth of options and arguments
36(I<command_opts> and I<command_args> in the SYNOPSIS).
37
38=head2 STANDARD COMMANDS
39
40=over 10
41
42=item L<B<asn1parse>|asn1parse(1)>
43
44Parse an ASN.1 sequence.
45
46=item L<B<ca>|ca(1)>
47
48Certificate Authority (CA) Management.
49
50=item L<B<ciphers>|ciphers(1)>
51
52Cipher Suite Description Determination.
53
54=item L<B<crl>|crl(1)>
55
56Certificate Revocation List (CRL) Management.
57
58=item L<B<crl2pkcs7>|crl2pkcs7(1)>
59
60CRL to PKCS#7 Conversion.
61
62=item L<B<dgst>|dgst(1)>
63
64Message Digest Calculation.
65
66=item L<B<dh>|dh(1)>
67
68Diffie-Hellman Data Management.
69
70=item L<B<dsa>|dsa(1)>
71
72DSA Data Management.
73
74=item L<B<dsaparam>|dsaparam(1)>
75
76DSA Parameter Generation.
77
78=item L<B<enc>|enc(1)>
79
80Encoding with Ciphers.
81
82=item L<B<errstr>|errstr(1)>
83
84Error Number to Error String Conversion.
85
86=item L<B<gendh>|gendh(1)>
87
88Generation of Diffie-Hellman Parameters.
89
90=item L<B<gendsa>|gendsa(1)>
91
92Generation of DSA Parameters.
93
94=item L<B<genrsa>|genrsa(1)>
95
96Generation of RSA Parameters.
97
98=item L<B<passwd>|passwd(1)>
99
100Generation of hashed passwords.
101
102=item L<B<pkcs7>|pkcs7(1)>
103
104PKCS#7 Data Management.
105
106=item L<B<req>|req(1)>
107
108X.509 Certificate Signing Request (CSR) Management.
109
110=item L<B<rsa>|rsa(1)>
111
112RSA Data Management.
113
114=item L<B<s_client>|s_client(1)>
115
116This implements a generic SSL/TLS client which can establish a transparent
117connection to a remote server speaking SSL/TLS. It's intended for testing
118purposes only and provides only rudimentary interface functionality but
119internally uses mostly all functionality of the OpenSSL B<ssl> library.
120
121=item L<B<s_server>|s_server(1)>
122
123This implements a generic SSL/TLS server which accepts connections from remote
124clients speaking SSL/TLS. It's intended for testing purposes only and provides
125only rudimentary interface functionality but internally uses mostly all
126functionality of the OpenSSL B<ssl> library. It provides both an own command
127line oriented protocol for testing SSL functions and a simple HTTP response
128facility to emulate an SSL/TLS-aware webserver.
129
130=item L<B<s_time>|s_time(1)>
131
132SSL Connection Timer.
133
134=item L<B<sess_id>|sess_id(1)>
135
136SSL Session Data Management.
137
138=item L<B<smime>|smime(1)>
139
140S/MIME mail processing.
141
142=item L<B<speed>|speed(1)>
143
144Algorithm Speed Measurement.
145
146=item L<B<verify>|verify(1)>
147
148X.509 Certificate Verification.
149
150=item L<B<version>|version(1)>
151
152OpenSSL Version Information.
153
154=item L<B<x509>|x509(1)>
155
156X.509 Certificate Data Management.
157
158=back
159
160=head2 MESSAGE DIGEST COMMANDS
161
162=over 10
163
164=item B<md2>
165
166MD2 Digest
167
168=item B<md5>
169
170MD5 Digest
171
172=item B<mdc2>
173
174MDC2 Digest
175
176=item B<rmd160>
177
178RMD-160 Digest
179
180=item B<sha>
181
182SHA Digest
183
184=item B<sha1>
185
186SHA-1 Digest
187
188=back
189
190=head2 ENCODING AND CIPHER COMMANDS
191
192=over 10
193
194=item B<base64>
195
196Base64 Encoding
197
198=item B<bf bf-cbc bf-cfb bf-ecb bf-ofb>
199
200Blowfish Cipher
201
202=item B<cast cast-cbc>
203
204CAST Cipher
205
206=item B<cast5-cbc cast5-cfb cast5-ecb cast5-ofb>
207
208CAST5 Cipher
209
210=item B<des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ofb>
211
212DES Cipher
213
214=item B<des3 desx des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb>
215
216Triple-DES Cipher
217
218=item B<idea idea-cbc idea-cfb idea-ecb idea-ofb>
219
220IDEA Cipher
221
222=item B<rc2 rc2-cbc rc2-cfb rc2-ecb rc2-ofb>
223
224RC2 Cipher
225
226=item B<rc4>
227
228RC4 Cipher
229
230=item B<rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb>
231
232RC5 Cipher
233
234=back
235
236=head1 PASS PHRASE ARGUMENTS
237
238Several commands accept password arguments, typically using B<-passin>
239and B<-passout> for input and output passwords respectively. These allow
240the password to be obtained from a variety of sources. Both of these
241options take a single argument whose format is described below. If no
242password argument is given and a password is required then the user is
243prompted to enter one: this will typically be read from the current
244terminal with echoing turned off.
245
246=over 10
247
248=item B<pass:password>
249
250the actual password is B<password>. Since the password is visible
251to utilities (like 'ps' under Unix) this form should only be used
252where security is not important.
253
254=item B<env:var>
255
256obtain the password from the environment variable B<var>. Since
257the environment of other processes is visible on certain platforms
258(e.g. ps under certain Unix OSes) this option should be used with caution.
259
260=item B<file:pathname>
261
262the first line of B<pathname> is the password. If the same B<pathname>
263argument is supplied to B<-passin> and B<-passout> arguments then the first
264line will be used for the input password and the next line for the output
265password. B<pathname> need not refer to a regular file: it could for example
266refer to a device or named pipe.
267
268=item B<fd:number>
269
270read the password from the file descriptor B<number>. This can be used to
271send the data via a pipe for example.
272
273=item B<stdin>
274
275read the password from standard input.
276
277=back
278
279=head1 SEE ALSO
280
281L<asn1parse(1)|asn1parse(1)>, L<ca(1)|ca(1)>, L<config(5)|config(5)>,
282L<crl(1)|crl(1)>, L<crl2pkcs7(1)|crl2pkcs7(1)>, L<dgst(1)|dgst(1)>,
283L<dhparam(1)|dhparam(1)>, L<dsa(1)|dsa(1)>, L<dsaparam(1)|dsaparam(1)>,
284L<enc(1)|enc(1)>, L<gendsa(1)|gendsa(1)>,
285L<genrsa(1)|genrsa(1)>, L<nseq(1)|nseq(1)>, L<openssl(1)|openssl(1)>,
286L<passwd(1)|passwd(1)>,
287L<pkcs12(1)|pkcs12(1)>, L<pkcs7(1)|pkcs7(1)>, L<pkcs8(1)|pkcs8(1)>,
288L<req(1)|req(1)>, L<rsa(1)|rsa(1)>, L<s_client(1)|s_client(1)>,
289L<s_server(1)|s_server(1)>, L<smime(1)|smime(1)>, L<spkac(1)|spkac(1)>,
290L<verify(1)|verify(1)>, L<version(1)|version(1)>, L<x509(1)|x509(1)>,
291L<crypto(3)|crypto(3)>, L<ssl(3)|ssl(3)>
292
293=head1 HISTORY
294
295The openssl(1) document appeared in OpenSSL 0.9.2
296
297=cut
298
diff --git a/src/lib/libssl/src/doc/apps/passwd.pod b/src/lib/libssl/src/doc/apps/passwd.pod
new file mode 100644
index 0000000000..cee6a2f172
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/passwd.pod
@@ -0,0 +1,69 @@
1=pod
2
3=head1 NAME
4
5passwd - compute password hashes
6
7=head1 SYNOPSIS
8
9B<openssl passwd>
10[B<-crypt>]
11[B<-apr1>]
12[B<-salt> I<string>]
13[B<-in> I<file>]
14[B<-stdin>]
15[B<-quiet>]
16[B<-table>]
17{I<password>}
18
19=head1 DESCRIPTION
20
21The B<passwd> command computes the hash of a password typed at
22run-time or the hash of each password in a list. The password list is
23taken from the named file for option B<-in file>, from stdin for
24option B<-stdin>, and from the command line otherwise.
25The Unix standard algorithm B<crypt> and the MD5-based B<apr1> algorithm
26are available.
27
28=head1 OPTIONS
29
30=over 4
31
32=item B<-crypt>
33
34Use the B<crypt> algorithm (default).
35
36=item B<-apr1>
37
38Use the B<apr1> algorithm.
39
40=item B<-salt> I<string>
41
42Use the specified salt.
43
44=item B<-in> I<file>
45
46Read passwords from I<file>.
47
48=item B<-stdin>
49
50Read passwords from B<stdin>.
51
52=item B<-quiet>
53
54Don't output warnings when passwords given at the command line are truncated.
55
56=item B<-table>
57
58In the output list, prepend the cleartext password and a TAB character
59to each password hash.
60
61=back
62
63=head1 EXAMPLES
64
65B<openssl passwd -crypt -salt xx password> prints B<xxj31ZMTZzkVA>.
66
67B<openssl passwd -apr1 -salt xxxxxxxx password> prints B<$apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0>.
68
69=cut
diff --git a/src/lib/libssl/src/doc/apps/pkcs12.pod b/src/lib/libssl/src/doc/apps/pkcs12.pod
new file mode 100644
index 0000000000..241f9c4a8b
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/pkcs12.pod
@@ -0,0 +1,310 @@
1
2=pod
3
4=head1 NAME
5
6pkcs12 - PKCS#12 file utility
7
8=head1 SYNOPSIS
9
10B<openssl> B<pkcs12>
11[B<-export>]
12[B<-chain>]
13[B<-inkey filename>]
14[B<-certfile filename>]
15[B<-name name>]
16[B<-caname name>]
17[B<-in filename>]
18[B<-out filename>]
19[B<-noout>]
20[B<-nomacver>]
21[B<-nocerts>]
22[B<-clcerts>]
23[B<-cacerts>]
24[B<-nokeys>]
25[B<-info>]
26[B<-des>]
27[B<-des3>]
28[B<-idea>]
29[B<-nodes>]
30[B<-noiter>]
31[B<-maciter>]
32[B<-twopass>]
33[B<-descert>]
34[B<-certpbe>]
35[B<-keypbe>]
36[B<-keyex>]
37[B<-keysig>]
38[B<-password arg>]
39[B<-passin arg>]
40[B<-passout arg>]
41[B<-rand file(s)>]
42
43=head1 DESCRIPTION
44
45The B<pkcs12> command allows PKCS#12 files (sometimes referred to as
46PFX files) to be created and parsed. PKCS#12 files are used by several
47programs including Netscape, MSIE and MS Outlook.
48
49=head1 COMMAND OPTIONS
50
51There are a lot of options the meaning of some depends of whether a PKCS#12 file
52is being created or parsed. By default a PKCS#12 file is parsed a PKCS#12
53file can be created by using the B<-export> option (see below).
54
55=head1 PARSING OPTIONS
56
57=over 4
58
59=item B<-in filename>
60
61This specifies filename of the PKCS#12 file to be parsed. Standard input is used
62by default.
63
64=item B<-out filename>
65
66The filename to write certificates and private keys to, standard output by default.
67They are all written in PEM format.
68
69=item B<-pass arg>, B<-passin arg>
70
71the PKCS#12 file (i.e. input file) password source. For more information about the
72format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
73L<openssl(1)|openssl(1)>.
74
75=item B<-passout arg>
76
77pass phrase source to encrypt any outputed private keys with. For more information
78about the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
79L<openssl(1)|openssl(1)>.
80
81=item B<-noout>
82
83this option inhibits output of the keys and certificates to the output file version
84of the PKCS#12 file.
85
86=item B<-clcerts>
87
88only output client certificates (not CA certificates).
89
90=item B<-cacerts>
91
92only output CA certificates (not client certificates).
93
94=item B<-nocerts>
95
96no certificates at all will be output.
97
98=item B<-nokeys>
99
100no private keys will be output.
101
102=item B<-info>
103
104output additional information about the PKCS#12 file structure, algorithms used and
105iteration counts.
106
107=item B<-des>
108
109use DES to encrypt private keys before outputting.
110
111=item B<-des3>
112
113use triple DES to encrypt private keys before outputting, this is the default.
114
115=item B<-idea>
116
117use IDEA to encrypt private keys before outputting.
118
119=item B<-nodes>
120
121don't encrypt the private keys at all.
122
123=item B<-nomacver>
124
125don't attempt to verify the integrity MAC before reading the file.
126
127=item B<-twopass>
128
129prompt for separate integrity and encryption passwords: most software
130always assumes these are the same so this option will render such
131PKCS#12 files unreadable.
132
133=back
134
135=head1 FILE CREATION OPTIONS
136
137=over 4
138
139=item B<-export>
140
141This option specifies that a PKCS#12 file will be created rather than
142parsed.
143
144=item B<-out filename>
145
146This specifies filename to write the PKCS#12 file to. Standard output is used
147by default.
148
149=item B<-in filename>
150
151The filename to read certificates and private keys from, standard input by default.
152They must all be in PEM format. The order doesn't matter but one private key and
153its corresponding certificate should be present. If additional certificates are
154present they will also be included in the PKCS#12 file.
155
156=item B<-inkey filename>
157
158file to read private key from. If not present then a private key must be present
159in the input file.
160
161=item B<-name friendlyname>
162
163This specifies the "friendly name" for the certificate and private key. This name
164is typically displayed in list boxes by software importing the file.
165
166=item B<-certfile filename>
167
168A filename to read additional certificates from.
169
170=item B<-caname friendlyname>
171
172This specifies the "friendly name" for other certificates. This option may be
173used multiple times to specify names for all certificates in the order they
174appear. Netscape ignores friendly names on other certificates whereas MSIE
175displays them.
176
177=item B<-pass arg>, B<-passout arg>
178
179the PKCS#12 file (i.e. output file) password source. For more information about
180the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
181L<openssl(1)|openssl(1)>.
182
183=item B<-passin password>
184
185pass phrase source to decrypt any input private keys with. For more information
186about the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in
187L<openssl(1)|openssl(1)>.
188
189=item B<-chain>
190
191if this option is present then an attempt is made to include the entire
192certificate chain of the user certificate. The standard CA store is used
193for this search. If the search fails it is considered a fatal error.
194
195=item B<-descert>
196
197encrypt the certificate using triple DES, this may render the PKCS#12
198file unreadable by some "export grade" software. By default the private
199key is encrypted using triple DES and the certificate using 40 bit RC2.
200
201=item B<-keypbe alg>, B<-certpbe alg>
202
203these options allow the algorithm used to encrypt the private key and
204certificates to be selected. Although any PKCS#5 v1.5 or PKCS#12 algorithms
205can be selected it is advisable only to use PKCS#12 algorithms. See the list
206in the B<NOTES> section for more information.
207
208=item B<-keyex|-keysig>
209
210specifies that the private key is to be used for key exchange or just signing.
211This option is only interpreted by MSIE and similar MS software. Normally
212"export grade" software will only allow 512 bit RSA keys to be used for
213encryption purposes but arbitrary length keys for signing. The B<-keysig>
214option marks the key for signing only. Signing only keys can be used for
215S/MIME signing, authenticode (ActiveX control signing) and SSL client
216authentication, however due to a bug only MSIE 5.0 and later support
217the use of signing only keys for SSL client authentication.
218
219=item B<-nomaciter>, B<-noiter>
220
221these options affect the iteration counts on the MAC and key algorithms.
222Unless you wish to produce files compatible with MSIE 4.0 you should leave
223these options alone.
224
225To discourage attacks by using large dictionaries of common passwords the
226algorithm that derives keys from passwords can have an iteration count applied
227to it: this causes a certain part of the algorithm to be repeated and slows it
228down. The MAC is used to check the file integrity but since it will normally
229have the same password as the keys and certificates it could also be attacked.
230By default both MAC and encryption iteration counts are set to 2048, using
231these options the MAC and encryption iteration counts can be set to 1, since
232this reduces the file security you should not use these options unless you
233really have to. Most software supports both MAC and key iteration counts.
234MSIE 4.0 doesn't support MAC iteration counts so it needs the B<-nomaciter>
235option.
236
237=item B<-maciter>
238
239This option is included for compatibility with previous versions, it used
240to be needed to use MAC iterations counts but they are now used by default.
241
242=item B<-rand file(s)>
243
244a file or files containing random data used to seed the random number
245generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
246Multiple files can be specified separated by a OS-dependent character.
247The separator is B<;> for MS-Windows, B<,> for OpenVSM, and B<:> for
248all others.
249
250=back
251
252=head1 NOTES
253
254Although there are a large number of options most of them are very rarely
255used. For PKCS#12 file parsing only B<-in> and B<-out> need to be used
256for PKCS#12 file creation B<-export> and B<-name> are also used.
257
258If none of the B<-clcerts>, B<-cacerts> or B<-nocerts> options are present
259then all certificates will be output in the order they appear in the input
260PKCS#12 files. There is no guarantee that the first certificate present is
261the one corresponding to the private key. Certain software which requires
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
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
266certificates are required then they can be output to a separate file using
267the B<-nokeys -cacerts> options to just output CA certificates.
268
269The B<-keypbe> and B<-certpbe> algorithms allow the precise encryption
270algorithms for private keys and certificates to be specified. Normally
271the defaults are fine but occasionally software can't handle triple DES
272encrypted private keys, then the option B<-keypbe PBE-SHA1-RC2-40> can
273be used to reduce the private key encryption to 40 bit RC2. A complete
274description of all algorithms is contained in the B<pkcs8> manual page.
275
276=head1 EXAMPLES
277
278Parse a PKCS#12 file and output it to a file:
279
280 openssl pkcs12 -in file.p12 -out file.pem
281
282Output only client certificates to a file:
283
284 openssl pkcs12 -in file.p12 -clcerts -out file.pem
285
286Don't encrypt the private key:
287
288 openssl pkcs12 -in file.p12 -out file.pem -nodes
289
290Print some info about a PKCS#12 file:
291
292 openssl pkcs12 -in file.p12 -info -noout
293
294Create a PKCS#12 file:
295
296 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
297
298Include some extra certificates:
299
300 openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \
301 -certfile othercerts.pem
302
303=head1 BUGS
304
305Some would argue that the PKCS#12 standard is one big bug :-)
306
307=head1 SEE ALSO
308
309L<pkcs8(1)|pkcs8(1)>
310
diff --git a/src/lib/libssl/src/doc/apps/pkcs7.pod b/src/lib/libssl/src/doc/apps/pkcs7.pod
new file mode 100644
index 0000000000..4e9bd6e46b
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/pkcs7.pod
@@ -0,0 +1,97 @@
1=pod
2
3=head1 NAME
4
5pkcs7 - PKCS#7 utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<pkcs7>
10[B<-inform PEM|DER>]
11[B<-outform PEM|DER>]
12[B<-in filename>]
13[B<-out filename>]
14[B<-print_certs>]
15[B<-text>]
16[B<-noout>]
17
18=head1 DESCRIPTION
19
20The B<pkcs7> command processes PKCS#7 files in DER or PEM format.
21
22=head1 COMMAND OPTIONS
23
24=over 4
25
26=item B<-inform DER|PEM>
27
28This specifies the input format. B<DER> format is DER encoded PKCS#7
29v1.5 structure.B<PEM> (the default) is a base64 encoded version of
30the DER form with header and footer lines.
31
32=item B<-outform DER|PEM>
33
34This specifies the output format, the options have the same meaning as the
35B<-inform> option.
36
37=item B<-in filename>
38
39This specifies the input filename to read from or standard input if this
40option is not specified.
41
42=item B<-out filename>
43
44specifies the output filename to write to or standard output by
45default.
46
47=item B<-print_certs>
48
49prints out any certificates or CRLs contained in the file. They are
50preceded by their subject and issuer names in one line format.
51
52=item B<-text>
53
54prints out certificates details in full rather than just subject and
55issuer names.
56
57=item B<-noout>
58
59don't output the encoded version of the PKCS#7 structure (or certificates
60is B<-print_certs> is set).
61
62=back
63
64=head1 EXAMPLES
65
66Convert a PKCS#7 file from PEM to DER:
67
68 openssl pkcs7 -in file.pem -outform DER -out file.der
69
70Output all certificates in a file:
71
72 openssl pkcs7 -in file.pem -print_certs -out certs.pem
73
74=head1 NOTES
75
76The PEM PKCS#7 format uses the header and footer lines:
77
78 -----BEGIN PKCS7-----
79 -----END PKCS7-----
80
81For compatability with some CAs it will also accept:
82
83 -----BEGIN CERTIFICATE-----
84 -----END CERTIFICATE-----
85
86=head1 RESTRICTIONS
87
88There is no option to print out all the fields of a PKCS#7 file.
89
90This PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC2315 they
91cannot currently parse, for example, the new CMS as described in RFC2630.
92
93=head1 SEE ALSO
94
95L<crl2pkcs7(1)|crl2pkcs7(1)>
96
97=cut
diff --git a/src/lib/libssl/src/doc/apps/pkcs8.pod b/src/lib/libssl/src/doc/apps/pkcs8.pod
new file mode 100644
index 0000000000..a56b2dd002
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/pkcs8.pod
@@ -0,0 +1,235 @@
1=pod
2
3=head1 NAME
4
5pkcs8 - PKCS#8 format private key conversion tool
6
7=head1 SYNOPSIS
8
9B<openssl> B<pkcs8>
10[B<-topk8>]
11[B<-inform PEM|DER>]
12[B<-outform PEM|DER>]
13[B<-in filename>]
14[B<-passin arg>]
15[B<-out filename>]
16[B<-passout arg>]
17[B<-noiter>]
18[B<-nocrypt>]
19[B<-nooct>]
20[B<-embed>]
21[B<-nsdb>]
22[B<-v2 alg>]
23[B<-v1 alg>]
24
25=head1 DESCRIPTION
26
27The B<pkcs8> command processes private keys in PKCS#8 format. It can handle
28both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo
29format with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms.
30
31=head1 COMMAND OPTIONS
32
33=over 4
34
35=item B<-topk8>
36
37Normally a PKCS#8 private key is expected on input and a traditional format
38private key will be written. With the B<-topk8> option the situation is
39reversed: it reads a traditional format private key and writes a PKCS#8
40format key.
41
42=item B<-inform DER|PEM>
43
44This specifies the input format. If a PKCS#8 format key is expected on input
45then either a B<DER> or B<PEM> encoded version of a PKCS#8 key will be
46expected. Otherwise the B<DER> or B<PEM> format of the traditional format
47private key is used.
48
49=item B<-outform DER|PEM>
50
51This specifies the output format, the options have the same meaning as the
52B<-inform> option.
53
54=item B<-in filename>
55
56This specifies the input filename to read a key from or standard input if this
57option is not specified. If the key is encrypted a pass phrase will be
58prompted for.
59
60=item B<-passin arg>
61
62the input file password source. For more information about the format of B<arg>
63see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
64
65=item B<-out filename>
66
67This specifies the output filename to write a key to or standard output by
68default. If any encryption options are set then a pass phrase will be
69prompted for. The output filename should B<not> be the same as the input
70filename.
71
72=item B<-passout arg>
73
74the output file password source. For more information about the format of B<arg>
75see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
76
77=item B<-nocrypt>
78
79PKCS#8 keys generated or input are normally PKCS#8 EncryptedPrivateKeyInfo
80structures using an appropriate password based encryption algorithm. With
81this option an unencrypted PrivateKeyInfo structure is expected or output.
82This option does not encrypt private keys at all and should only be used
83when absolutely necessary. Certain software such as some versions of Java
84code signing software used unencrypted private keys.
85
86=item B<-nooct>
87
88This option generates RSA private keys in a broken format that some software
89uses. Specifically the private key should be enclosed in a OCTET STRING
90but some software just includes the structure itself without the
91surrounding OCTET STRING.
92
93=item B<-embed>
94
95This option generates DSA keys in a broken format. The DSA parameters are
96embedded inside the PrivateKey structure. In this form the OCTET STRING
97contains an ASN1 SEQUENCE consisting of two structures: a SEQUENCE containing
98the parameters and an ASN1 INTEGER containing the private key.
99
100=item B<-nsdb>
101
102This option generates DSA keys in a broken format compatible with Netscape
103private key databases. The PrivateKey contains a SEQUENCE consisting of
104the public and private keys respectively.
105
106=item B<-v2 alg>
107
108This option enables the use of PKCS#5 v2.0 algorithms. Normally PKCS#8
109private keys are encrypted with the password based encryption algorithm
110called B<pbeWithMD5AndDES-CBC> this uses 56 bit DES encryption but it
111was the strongest encryption algorithm supported in PKCS#5 v1.5. Using
112the B<-v2> option PKCS#5 v2.0 algorithms are used which can use any
113encryption algorithm such as 168 bit triple DES or 128 bit RC2 however
114not many implementations support PKCS#5 v2.0 yet. If you are just using
115private keys with OpenSSL then this doesn't matter.
116
117The B<alg> argument is the encryption algorithm to use, valid values include
118B<des>, B<des3> and B<rc2>. It is recommended that B<des3> is used.
119
120=item B<-v1 alg>
121
122This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete
123list of possible algorithms is included below.
124
125=back
126
127=head1 NOTES
128
129The encrypted form of a PEM encode PKCS#8 files uses the following
130headers and footers:
131
132 -----BEGIN ENCRYPTED PRIVATE KEY-----
133 -----END ENCRYPTED PRIVATE KEY-----
134
135The unencrypted form uses:
136
137 -----BEGIN PRIVATE KEY-----
138 -----END PRIVATE KEY-----
139
140Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration
141counts are more secure that those encrypted using the traditional
142SSLeay compatible formats. So if additional security is considered
143important the keys should be converted.
144
145The default encryption is only 56 bits because this is the encryption
146that most current implementations of PKCS#8 will support.
147
148Some software may use PKCS#12 password based encryption algorithms
149with PKCS#8 format private keys: these are handled automatically
150but there is no option to produce them.
151
152It is possible to write out DER encoded encrypted private keys in
153PKCS#8 format because the encryption details are included at an ASN1
154level whereas the traditional format includes them at a PEM level.
155
156=head1 PKCS#5 v1.5 and PKCS#12 algorithms.
157
158Various algorithms can be used with the B<-v1> command line option,
159including PKCS#5 v1.5 and PKCS#12. These are described in more detail
160below.
161
162=over 4
163
164=item B<PBE-MD2-DES PBE-MD5-DES>
165
166These algorithms were included in the original PKCS#5 v1.5 specification.
167They only offer 56 bits of protection since they both use DES.
168
169=item B<PBE-SHA1-RC2-64 PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES>
170
171These algorithms are not mentioned in the original PKCS#5 v1.5 specification
172but they use the same key derivation algorithm and are supported by some
173software. They are mentioned in PKCS#5 v2.0. They use either 64 bit RC2 or
17456 bit DES.
175
176=item B<PBE-SHA1-RC4-128 PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 PBE-SHA1-RC2-40>
177
178These algorithms use the PKCS#12 password based encryption algorithm and
179allow strong encryption algorithms like triple DES or 128 bit RC2 to be used.
180
181=back
182
183=head1 EXAMPLES
184
185Convert a private from traditional to PKCS#5 v2.0 format using triple
186DES:
187
188 openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem
189
190Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm
191(DES):
192
193 openssl pkcs8 -in key.pem -topk8 -out enckey.pem
194
195Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm
196(3DES):
197
198 openssl pkcs8 -in key.pem -topk8 -out enckey.pem -v1 PBE-SHA1-3DES
199
200Read a DER unencrypted PKCS#8 format private key:
201
202 openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem
203
204Convert a private key from any PKCS#8 format to traditional format:
205
206 openssl pkcs8 -in pk8.pem -out key.pem
207
208=head1 STANDARDS
209
210Test vectors from this PKCS#5 v2.0 implementation were posted to the
211pkcs-tng mailing list using triple DES, DES and RC2 with high iteration
212counts, several people confirmed that they could decrypt the private
213keys produced and Therefore it can be assumed that the PKCS#5 v2.0
214implementation is reasonably accurate at least as far as these
215algorithms are concerned.
216
217The format of PKCS#8 DSA (and other) private keys is not well documented:
218it is hidden away in PKCS#11 v2.01, section 11.9. OpenSSL's default DSA
219PKCS#8 private key format complies with this standard.
220
221=head1 BUGS
222
223There should be an option that prints out the encryption algorithm
224in use and other details such as the iteration count.
225
226PKCS#8 using triple DES and PKCS#5 v2.0 should be the default private
227key format for OpenSSL: for compatibility several of the utilities use
228the old format at present.
229
230=head1 SEE ALSO
231
232L<dsa(1)|dsa(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)>,
233L<gendsa(1)|gendsa(1)>
234
235=cut
diff --git a/src/lib/libssl/src/doc/apps/req.pod b/src/lib/libssl/src/doc/apps/req.pod
new file mode 100644
index 0000000000..fde6ff2e9f
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/req.pod
@@ -0,0 +1,528 @@
1
2=pod
3
4=head1 NAME
5
6req - PKCS#10 certificate and certificate generating utility.
7
8=head1 SYNOPSIS
9
10B<openssl> B<req>
11[B<-inform PEM|DER>]
12[B<-outform PEM|DER>]
13[B<-in filename>]
14[B<-passin arg>]
15[B<-out filename>]
16[B<-passout arg>]
17[B<-text>]
18[B<-noout>]
19[B<-verify>]
20[B<-modulus>]
21[B<-new>]
22[B<-newkey rsa:bits>]
23[B<-newkey dsa:file>]
24[B<-nodes>]
25[B<-key filename>]
26[B<-keyform PEM|DER>]
27[B<-keyout filename>]
28[B<-[md5|sha1|md2|mdc2]>]
29[B<-config filename>]
30[B<-x509>]
31[B<-days n>]
32[B<-asn1-kludge>]
33[B<-newhdr>]
34[B<-extensions section>]
35[B<-reqexts section>]
36
37=head1 DESCRIPTION
38
39The B<req> command primarily creates and processes certificate requests
40in PKCS#10 format. It can additionally create self signed certificates
41for use as root CAs for example.
42
43=head1 COMMAND OPTIONS
44
45=over 4
46
47=item B<-inform DER|PEM>
48
49This specifies the input format. The B<DER> option uses an ASN1 DER encoded
50form compatible with the PKCS#10. The B<PEM> form is the default format: it
51consists of the B<DER> format base64 encoded with additional header and
52footer lines.
53
54=item B<-outform DER|PEM>
55
56This specifies the output format, the options have the same meaning as the
57B<-inform> option.
58
59=item B<-in filename>
60
61This specifies the input filename to read a request from or standard input
62if this option is not specified. A request is only read if the creation
63options (B<-new> and B<-newkey>) are not specified.
64
65=item B<-passin arg>
66
67the input file password source. For more information about the format of B<arg>
68see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
69
70=item B<-out filename>
71
72This specifies the output filename to write to or standard output by
73default.
74
75=item B<-passout arg>
76
77the output file password source. For more information about the format of B<arg>
78see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
79
80=item B<-text>
81
82prints out the certificate request in text form.
83
84=item B<-noout>
85
86this option prevents output of the encoded version of the request.
87
88=item B<-modulus>
89
90this option prints out the value of the modulus of the public key
91contained in the request.
92
93=item B<-verify>
94
95verifies the signature on the request.
96
97=item B<-new>
98
99this option generates a new certificate request. It will prompt
100the user for the relevant field values. The actual fields
101prompted for and their maximum and minimum sizes are specified
102in the configuration file and any requested extensions.
103
104If the B<-key> option is not used it will generate a new RSA private
105key using information specified in the configuration file.
106
107=item B<-newkey arg>
108
109this option creates a new certificate request and a new private
110key. The argument takes one of two forms. B<rsa:nbits>, where
111B<nbits> is the number of bits, generates an RSA key B<nbits>
112in size. B<dsa:filename> generates a DSA key using the parameters
113in the file B<filename>.
114
115=item B<-key filename>
116
117This specifies the file to read the private key from. It also
118accepts PKCS#8 format private keys for PEM format files.
119
120=item B<-keyform PEM|DER>
121
122the format of the private key file specified in the B<-key>
123argument. PEM is the default.
124
125=item B<-keyout filename>
126
127this gives the filename to write the newly created private key to.
128If this option is not specified then the filename present in the
129configuration file is used.
130
131=item B<-nodes>
132
133if this option is specified then if a private key is created it
134will not be encrypted.
135
136=item B<-[md5|sha1|md2|mdc2]>
137
138this specifies the message digest to sign the request with. This
139overrides the digest algorithm specified in the configuration file.
140This option is ignored for DSA requests: they always use SHA1.
141
142=item B<-config filename>
143
144this allows an alternative configuration file to be specified,
145this overrides the compile time filename or any specified in
146the B<OPENSSL_CONF> environment variable.
147
148=item B<-x509>
149
150this option outputs a self signed certificate instead of a certificate
151request. This is typically used to generate a test certificate or
152a self signed root CA. The extensions added to the certificate
153(if any) are specified in the configuration file.
154
155=item B<-days n>
156
157when the B<-x509> option is being used this specifies the number of
158days to certify the certificate for. The default is 30 days.
159
160=item B<-extensions section>
161=item B<-reqexts section>
162
163these options specify alternative sections to include certificate
164extensions (if the B<-x509> option is present) or certificate
165request extensions. This allows several different sections to
166be used in the same configuration file to specify requests for
167a variety of purposes.
168
169=item B<-asn1-kludge>
170
171by default the B<req> command outputs certificate requests containing
172no attributes in the correct PKCS#10 format. However certain CAs will only
173accept requests containing no attributes in an invalid form: this
174option produces this invalid format.
175
176More precisely the B<Attributes> in a PKCS#10 certificate request
177are defined as a B<SET OF Attribute>. They are B<not OPTIONAL> so
178if no attributes are present then they should be encoded as an
179empty B<SET OF>. The invalid form does not include the empty
180B<SET OF> whereas the correct form does.
181
182It should be noted that very few CAs still require the use of this option.
183
184=item B<-newhdr>
185
186Adds the word B<NEW> to the PEM file header and footer lines on the outputed
187request. Some software (Netscape certificate server) and some CAs need this.
188
189=back
190
191=head1 CONFIGURATION FILE FORMAT
192
193The configuration options are specified in the B<req> section of
194the configuration file. As with all configuration files if no
195value is specified in the specific section (i.e. B<req>) then
196the initial unnamed or B<default> section is searched too.
197
198The options available are described in detail below.
199
200=over 4
201
202=item B<input_password output_password>
203
204The passwords for the input private key file (if present) and
205the output private key file (if one will be created). The
206command line options B<passin> and B<passout> override the
207configuration file values.
208
209=item B<default_bits>
210
211This specifies the default key size in bits. If not specified then
212512 is used. It is used if the B<-new> option is used. It can be
213overridden by using the B<-newkey> option.
214
215=item B<default_keyfile>
216
217This is the default filename to write a private key to. If not
218specified the key is written to standard output. This can be
219overridden by the B<-keyout> option.
220
221=item B<oid_file>
222
223This specifies a file containing additional B<OBJECT IDENTIFIERS>.
224Each line of the file should consist of the numerical form of the
225object identifier followed by white space then the short name followed
226by white space and finally the long name.
227
228=item B<oid_section>
229
230This specifies a section in the configuration file containing extra
231object identifiers. Each line should consist of the short name of the
232object identifier followed by B<=> and the numerical form. The short
233and long names are the same when this option is used.
234
235=item B<RANDFILE>
236
237This specifies a filename in which random number seed information is
238placed and read from, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
239It is used for private key generation.
240
241=item B<encrypt_key>
242
243If this is set to B<no> then if a private key is generated it is
244B<not> encrypted. This is equivalent to the B<-nodes> command line
245option. For compatibility B<encrypt_rsa_key> is an equivalent option.
246
247=item B<default_md>
248
249This option specifies the digest algorithm to use. Possible values
250include B<md5 sha1 mdc2>. If not present then MD5 is used. This
251option can be overridden on the command line.
252
253=item B<string_mask>
254
255This option masks out the use of certain string types in certain
256fields. Most users will not need to change this option.
257
258It can be set to several values B<default> which is also the default
259option uses PrintableStrings, T61Strings and BMPStrings if the
260B<pkix> value is used then only PrintableStrings and BMPStrings will
261be used. This follows the PKIX recommendation in RFC2459. If the
262B<utf8only> option is used then only UTF8Strings will be used: this
263is the PKIX recommendation in RFC2459 after 2003. Finally the B<nombstr>
264option just uses PrintableStrings and T61Strings: certain software has
265problems with BMPStrings and UTF8Strings: in particular Netscape.
266
267=item B<req_extensions>
268
269this specifies the configuration file section containing a list of
270extensions to add to the certificate request. It can be overridden
271by the B<-reqexts> command line switch.
272
273=item B<x509_extensions>
274
275this specifies the configuration file section containing a list of
276extensions to add to certificate generated when the B<-x509> switch
277is used. It can be overridden by the B<-extensions> command line switch.
278
279=item B<prompt>
280
281if set to the value B<no> this disables prompting of certificate fields
282and just takes values from the config file directly. It also changes the
283expected format of the B<distinguished_name> and B<attributes> sections.
284
285=item B<attributes>
286
287this specifies the section containing any request attributes: its format
288is the same as B<distinguished_name>. Typically these may contain the
289challengePassword or unstructuredName types. They are currently ignored
290by OpenSSL's request signing utilities but some CAs might want them.
291
292=item B<distinguished_name>
293
294This specifies the section containing the distinguished name fields to
295prompt for when generating a certificate or certificate request. The format
296is described in the next section.
297
298=back
299
300=head1 DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT
301
302There are two separate formats for the distinguished name and attribute
303sections. If the B<prompt> option is set to B<no> then these sections
304just consist of field names and values: for example,
305
306 CN=My Name
307 OU=My Organization
308 emailAddress=someone@somewhere.org
309
310This allows external programs (e.g. GUI based) to generate a template file
311with all the field names and values and just pass it to B<req>. An example
312of this kind of configuration file is contained in the B<EXAMPLES> section.
313
314Alternatively if the B<prompt> option is absent or not set to B<no> then the
315file contains field prompting information. It consists of lines of the form:
316
317 fieldName="prompt"
318 fieldName_default="default field value"
319 fieldName_min= 2
320 fieldName_max= 4
321
322"fieldName" is the field name being used, for example commonName (or CN).
323The "prompt" string is used to ask the user to enter the relevant
324details. If the user enters nothing then the default value is used if no
325default value is present then the field is omitted. A field can
326still be omitted if a default value is present if the user just
327enters the '.' character.
328
329The number of characters entered must be between the fieldName_min and
330fieldName_max limits: there may be additional restrictions based
331on the field being used (for example countryName can only ever be
332two characters long and must fit in a PrintableString).
333
334Some fields (such as organizationName) can be used more than once
335in a DN. This presents a problem because configuration files will
336not recognize the same name occurring twice. To avoid this problem
337if the fieldName contains some characters followed by a full stop
338they will be ignored. So for example a second organizationName can
339be input by calling it "1.organizationName".
340
341The actual permitted field names are any object identifier short or
342long names. These are compiled into OpenSSL and include the usual
343values such as commonName, countryName, localityName, organizationName,
344organizationUnitName, stateOrPrivinceName. Additionally emailAddress
345is include as well as name, surname, givenName initials and dnQualifier.
346
347Additional object identifiers can be defined with the B<oid_file> or
348B<oid_section> options in the configuration file. Any additional fields
349will be treated as though they were a DirectoryString.
350
351
352=head1 EXAMPLES
353
354Examine and verify certificate request:
355
356 openssl req -in req.pem -text -verify -noout
357
358Create a private key and then generate a certificate request from it:
359
360 openssl genrsa -out key.pem 1024
361 openssl req -new -key key.pem -out req.pem
362
363The same but just using req:
364
365 openssl req -newkey rsa:1024 -keyout key.pem -out req.pem
366
367Generate a self signed root certificate:
368
369 openssl req -x509 -newkey rsa:1024 -keyout key.pem -out req.pem
370
371Example of a file pointed to by the B<oid_file> option:
372
373 1.2.3.4 shortName A longer Name
374 1.2.3.6 otherName Other longer Name
375
376Example of a section pointed to by B<oid_section> making use of variable
377expansion:
378
379 testoid1=1.2.3.5
380 testoid2=${testoid1}.6
381
382Sample configuration file prompting for field values:
383
384 [ req ]
385 default_bits = 1024
386 default_keyfile = privkey.pem
387 distinguished_name = req_distinguished_name
388 attributes = req_attributes
389 x509_extensions = v3_ca
390
391 dirstring_type = nobmp
392
393 [ req_distinguished_name ]
394 countryName = Country Name (2 letter code)
395 countryName_default = AU
396 countryName_min = 2
397 countryName_max = 2
398
399 localityName = Locality Name (eg, city)
400
401 organizationalUnitName = Organizational Unit Name (eg, section)
402
403 commonName = Common Name (eg, YOUR name)
404 commonName_max = 64
405
406 emailAddress = Email Address
407 emailAddress_max = 40
408
409 [ req_attributes ]
410 challengePassword = A challenge password
411 challengePassword_min = 4
412 challengePassword_max = 20
413
414 [ v3_ca ]
415
416 subjectKeyIdentifier=hash
417 authorityKeyIdentifier=keyid:always,issuer:always
418 basicConstraints = CA:true
419
420Sample configuration containing all field values:
421
422
423 RANDFILE = $ENV::HOME/.rnd
424
425 [ req ]
426 default_bits = 1024
427 default_keyfile = keyfile.pem
428 distinguished_name = req_distinguished_name
429 attributes = req_attributes
430 prompt = no
431 output_password = mypass
432
433 [ req_distinguished_name ]
434 C = GB
435 ST = Test State or Province
436 L = Test Locality
437 O = Organization Name
438 OU = Organizational Unit Name
439 CN = Common Name
440 emailAddress = test@email.address
441
442 [ req_attributes ]
443 challengePassword = A challenge password
444
445
446=head1 NOTES
447
448The header and footer lines in the B<PEM> format are normally:
449
450 -----BEGIN CERTIFICATE REQUEST----
451 -----END CERTIFICATE REQUEST----
452
453some software (some versions of Netscape certificate server) instead needs:
454
455 -----BEGIN NEW CERTIFICATE REQUEST----
456 -----END NEW CERTIFICATE REQUEST----
457
458which is produced with the B<-newhdr> option but is otherwise compatible.
459Either form is accepted transparently on input.
460
461The certificate requests generated by B<Xenroll> with MSIE have extensions
462added. It includes the B<keyUsage> extension which determines the type of
463key (signature only or general purpose) and any additional OIDs entered
464by the script in an extendedKeyUsage extension.
465
466=head1 DIAGNOSTICS
467
468The following messages are frequently asked about:
469
470 Using configuration from /some/path/openssl.cnf
471 Unable to load config info
472
473This is followed some time later by...
474
475 unable to find 'distinguished_name' in config
476 problems making Certificate Request
477
478The first error message is the clue: it can't find the configuration
479file! Certain operations (like examining a certificate request) don't
480need a configuration file so its use isn't enforced. Generation of
481certificates or requests however does need a configuration file. This
482could be regarded as a bug.
483
484Another puzzling message is this:
485
486 Attributes:
487 a0:00
488
489this is displayed when no attributes are present and the request includes
490the correct empty B<SET OF> structure (the DER encoding of which is 0xa0
4910x00). If you just see:
492
493 Attributes:
494
495then the B<SET OF> is missing and the encoding is technically invalid (but
496it is tolerated). See the description of the command line option B<-asn1-kludge>
497for more information.
498
499=head1 ENVIRONMENT VARIABLES
500
501The variable B<OPENSSL_CONF> if defined allows an alternative configuration
502file location to be specified, it will be overridden by the B<-config> command
503line switch if it is present. For compatibility reasons the B<SSLEAY_CONF>
504environment variable serves the same purpose but its use is discouraged.
505
506=head1 BUGS
507
508OpenSSL's handling of T61Strings (aka TeletexStrings) is broken: it effectively
509treats them as ISO-8859-1 (Latin 1), Netscape and MSIE have similar behaviour.
510This can cause problems if you need characters that aren't available in
511PrintableStrings and you don't want to or can't use BMPStrings.
512
513As a consequence of the T61String handling the only correct way to represent
514accented characters in OpenSSL is to use a BMPString: unfortunately Netscape
515currently chokes on these. If you have to use accented characters with Netscape
516and MSIE then you currently need to use the invalid T61String form.
517
518The current prompting is not very friendly. It doesn't allow you to confirm what
519you've just entered. Other things like extensions in certificate requests are
520statically defined in the configuration file. Some of these: like an email
521address in subjectAltName should be input by the user.
522
523=head1 SEE ALSO
524
525L<x509(1)|x509(1)>, L<ca(1)|ca(1)>, L<genrsa(1)|genrsa(1)>,
526L<gendsa(1)|gendsa(1)>, L<config(5)|config(5)>
527
528=cut
diff --git a/src/lib/libssl/src/doc/apps/rsa.pod b/src/lib/libssl/src/doc/apps/rsa.pod
new file mode 100644
index 0000000000..62ad62e23d
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/rsa.pod
@@ -0,0 +1,156 @@
1
2=pod
3
4=head1 NAME
5
6rsa - RSA key processing tool
7
8=head1 SYNOPSIS
9
10B<openssl> B<rsa>
11[B<-inform PEM|NET|DER>]
12[B<-outform PEM|NET|DER>]
13[B<-in filename>]
14[B<-passin arg>]
15[B<-out filename>]
16[B<-passout arg>]
17[B<-des>]
18[B<-des3>]
19[B<-idea>]
20[B<-text>]
21[B<-noout>]
22[B<-modulus>]
23[B<-check>]
24[B<-pubin>]
25[B<-pubout>]
26
27=head1 DESCRIPTION
28
29The B<rsa> command processes RSA keys. They can be converted between various
30forms and their components printed out. B<Note> this command uses the
31traditional SSLeay compatible format for private key encryption: newer
32applications should use the more secure PKCS#8 format using the B<pkcs8>
33utility.
34
35=head1 COMMAND OPTIONS
36
37=over 4
38
39=item B<-inform DER|NET|PEM>
40
41This specifies the input format. The B<DER> option uses an ASN1 DER encoded
42form compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format.
43The B<PEM> form is the default format: it consists of the B<DER> format base64
44encoded with additional header and footer lines. On input PKCS#8 format private
45keys are also accepted. The B<NET> form is a format compatible with older Netscape
46servers and MS IIS, this uses unsalted RC4 for its encryption. It is not very
47secure and so should only be used when necessary.
48
49=item B<-outform DER|NET|PEM>
50
51This specifies the output format, the options have the same meaning as the
52B<-inform> option.
53
54=item B<-in filename>
55
56This specifies the input filename to read a key from or standard input if this
57option is not specified. If the key is encrypted a pass phrase will be
58prompted for.
59
60=item B<-passin arg>
61
62the input file password source. For more information about the format of B<arg>
63see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
64
65=item B<-out filename>
66
67This specifies the output filename to write a key to or standard output if this
68option is not specified. If any encryption options are set then a pass phrase
69will be prompted for. The output filename should B<not> be the same as the input
70filename.
71
72=item B<-passout password>
73
74the output file password source. For more information about the format of B<arg>
75see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
76
77=item B<-des|-des3|-idea>
78
79These options encrypt the private key with the DES, triple DES, or the
80IDEA ciphers respectively before outputting it. A pass phrase is prompted for.
81If none of these options is specified the key is written in plain text. This
82means that using the B<rsa> utility to read in an encrypted key with no
83encryption option can be used to remove the pass phrase from a key, or by
84setting the encryption options it can be use to add or change the pass phrase.
85These options can only be used with PEM format output files.
86
87=item B<-text>
88
89prints out the various public or private key components in
90plain text in addition to the encoded version.
91
92=item B<-noout>
93
94this option prevents output of the encoded version of the key.
95
96=item B<-modulus>
97
98this option prints out the value of the modulus of the key.
99
100=item B<-check>
101
102this option checks the consistency of an RSA private key.
103
104=item B<-pubin>
105
106by default a private key is read from the input file: with this
107option a public key is read instead.
108
109=item B<-pubout>
110
111by default a private key is output: with this option a public
112key will be output instead. This option is automatically set if
113the input is a public key.
114
115=back
116
117=head1 NOTES
118
119The PEM private key format uses the header and footer lines:
120
121 -----BEGIN RSA PRIVATE KEY-----
122 -----END RSA PRIVATE KEY-----
123
124The PEM public key format uses the header and footer lines:
125
126 -----BEGIN PUBLIC KEY-----
127 -----END PUBLIC KEY-----
128
129=head1 EXAMPLES
130
131To remove the pass phrase on an RSA private key:
132
133 openssl rsa -in key.pem -out keyout.pem
134
135To encrypt a private key using triple DES:
136
137 openssl rsa -in key.pem -des3 -out keyout.pem
138
139To convert a private key from PEM to DER format:
140
141 openssl rsa -in key.pem -outform DER -out keyout.der
142
143To print out the components of a private key to standard output:
144
145 openssl rsa -in key.pem -text -noout
146
147To just output the public part of a private key:
148
149 openssl rsa -in key.pem -pubout -out pubkey.pem
150
151=head1 SEE ALSO
152
153L<pkcs8(1)|pkcs8(1)>, L<dsa(1)|dsa(1)>, L<genrsa(1)|genrsa(1)>,
154L<gendsa(1)|gendsa(1)>
155
156=cut
diff --git a/src/lib/libssl/src/doc/apps/s_client.pod b/src/lib/libssl/src/doc/apps/s_client.pod
new file mode 100644
index 0000000000..3ede134164
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/s_client.pod
@@ -0,0 +1,213 @@
1
2=pod
3
4=head1 NAME
5
6s_client - SSL/TLS client program
7
8=head1 SYNOPSIS
9
10B<openssl> B<s_client>
11[B<-connect> host:port>]
12[B<-verify depth>]
13[B<-cert filename>]
14[B<-key filename>]
15[B<-CApath directory>]
16[B<-CAfile filename>]
17[B<-reconnect>]
18[B<-pause>]
19[B<-showcerts>]
20[B<-debug>]
21[B<-nbio_test>]
22[B<-state>]
23[B<-nbio>]
24[B<-crlf>]
25[B<-quiet>]
26[B<-ssl2>]
27[B<-ssl3>]
28[B<-tls1>]
29[B<-no_ssl2>]
30[B<-no_ssl3>]
31[B<-no_tls1>]
32[B<-bugs>]
33[B<-cipher cipherlist>]
34
35=head1 DESCRIPTION
36
37The B<s_client> command implements a generic SSL/TLS client which connects
38to a remote host using SSL/TLS. It is a I<very> useful diagnostic tool for
39SSL servers.
40
41=head1 OPTIONS
42
43=over 4
44
45=item B<-connect host:port>
46
47This specifies the host and optional port to connect to. If not specified
48then an attempt is made to connect to the local host on port 4433.
49
50=item B<-cert certname>
51
52The certificate to use, if one is requested by the server. The default is
53not to use a certificate.
54
55=item B<-key keyfile>
56
57The private key to use. If not specified then the certificate file will
58be used.
59
60=item B<-verify depth>
61
62The verify depth to use. This specifies the maximum length of the
63server certificate chain and turns on server certificate verification.
64Currently the verify operation continues after errors so all the problems
65with a certificate chain can be seen. As a side effect the connection
66will never fail due to a server certificate verify failure.
67
68=item B<-CApath directory>
69
70The directory to use for server certificate verification. This directory
71must be in "hash format", see B<verify> for more information. These are
72also used when building the client certificate chain.
73
74=item B<-CAfile file>
75
76A file containing trusted certificates to use during server authentication
77and to use when attempting to build the client certificate chain.
78
79=item B<-reconnect>
80
81reconnects to the same server 5 times using the same session ID, this can
82be used as a test that session caching is working.
83
84=item B<-pause>
85
86pauses 1 second between each read and write call.
87
88=item B<-showcerts>
89
90display the whole server certificate chain: normally only the server
91certificate itself is displayed.
92
93=item B<-prexit>
94
95print session information when the program exits. This will always attempt
96to print out information even if the connection fails. Normally information
97will only be printed out once if the connection succeeds. This option is useful
98because the cipher in use may be renegotiated or the connection may fail
99because a client certificate is required or is requested only after an
100attempt is made to access a certain URL. Note: the output produced by this
101option is not always accurate because a connection might never have been
102established.
103
104=item B<-state>
105
106prints out the SSL session states.
107
108=item B<-debug>
109
110print extensive debugging information including a hex dump of all traffic.
111
112=item B<-nbio_test>
113
114tests non-blocking I/O
115
116=item B<-nbio>
117
118turns on non-blocking I/O
119
120=item B<-crlf>
121
122this option translated a line feed from the terminal into CR+LF as required
123by some servers.
124
125=item B<-quiet>
126
127inhibit printing of session and certificate information.
128
129=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
130
131these options disable the use of certain SSL or TLS protocols. By default
132the initial handshake uses a method which should be compatible with all
133servers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
134
135Unfortunately there are a lot of ancient and broken servers in use which
136cannot handle this technique and will fail to connect. Some servers only
137work if TLS is turned off with the B<-no_tls> option others will only
138support SSL v2 and may need the B<-ssl2> option.
139
140=item B<-bugs>
141
142there are several known bug in SSL and TLS implementations. Adding this
143option enables various workarounds.
144
145=item B<-cipher cipherlist>
146
147this allows the cipher list sent by the client to be modified. Although
148the server determines which cipher suite is used it should take the first
149supported cipher in the list sent by the client. See the B<ciphers>
150command for more information.
151
152=back
153
154=head1 CONNECTED COMMANDS
155
156If a connection is established with an SSL server then any data received
157from the server is displayed and any key presses will be sent to the
158server. If the line begins with an B<R> then the session will be
159renegotiated. If the line begins with a B<Q> the connection will be closed
160down.
161
162=head1 NOTES
163
164B<s_client> can be used to debug SSL servers. To connect to an SSL HTTP
165server the command:
166
167 openssl s_client -connect servername:443
168
169would typically be used (https uses port 443). If the connection succeeds
170then an HTTP command can be given such as "GET /" to retrieve a web page.
171
172If the handshake fails then there are several possible causes, if it is
173nothing obvious like no client certificate then the B<-bugs>, B<-ssl2>,
174B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> can be tried
175in case it is a buggy server. In particular you should play with these
176options B<before> submitting a bug report to an OpenSSL mailing list.
177
178A frequent problem when attempting to get client certificates working
179is that a web client complains it has no certificates or gives an empty
180list to choose from. This is normally because the server is not sending
181the clients certificate authority in its "acceptable CA list" when it
182requests a certificate. By using B<s_client> the CA list can be viewed
183and checked. However some servers only request client authentication
184after a specific URL is requested. To obtain the list in this case it
185is necessary to use the B<-prexit> command and send an HTTP request
186for an appropriate page.
187
188If a certificate is specified on the command line using the B<-cert>
189option it will not be used unless the server specifically requests
190a client certificate. Therefor merely including a client certificate
191on the command line is no guarantee that the certificate works.
192
193If there are problems verifying a server certificate then the
194B<-showcerts> option can be used to show the whole chain.
195
196=head1 BUGS
197
198Because this program has a lot of options and also because some of
199the techniques used are rather old, the C source of s_client is rather
200hard to read and not a model of how things should be done. A typical
201SSL client program would be much simpler.
202
203The B<-verify> option should really exit if the server verification
204fails.
205
206The B<-prexit> option is a bit of a hack. We should really report
207information whenever a session is renegotiated.
208
209=head1 SEE ALSO
210
211L<sess_id(1)|sess_id(1)>, L<s_server(1)|s_server(1)>, L<ciphers(1)|ciphers(1)>
212
213=cut
diff --git a/src/lib/libssl/src/doc/apps/s_server.pod b/src/lib/libssl/src/doc/apps/s_server.pod
new file mode 100644
index 0000000000..0f29c361d9
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/s_server.pod
@@ -0,0 +1,265 @@
1
2=pod
3
4=head1 NAME
5
6s_server - SSL/TLS server program
7
8=head1 SYNOPSIS
9
10B<openssl> B<s_client>
11[B<-accept port>]
12[B<-context id>]
13[B<-verify depth>]
14[B<-Verify depth>]
15[B<-cert filename>]
16[B<-key keyfile>]
17[B<-dcert filename>]
18[B<-dkey keyfile>]
19[B<-dhparam filename>]
20[B<-nbio>]
21[B<-nbio_test>]
22[B<-crlf>]
23[B<-debug>]
24[B<-state>]
25[B<-CApath directory>]
26[B<-CAfile filename>]
27[B<-nocert>]
28[B<-cipher cipherlist>]
29[B<-quiet>]
30[B<-no_tmp_rsa>]
31[B<-ssl2>]
32[B<-ssl3>]
33[B<-tls1>]
34[B<-no_ssl2>]
35[B<-no_ssl3>]
36[B<-no_tls1>]
37[B<-no_dhe>]
38[B<-bugs>]
39[B<-hack>]
40[B<-www>]
41[B<-WWW>]
42
43=head1 DESCRIPTION
44
45The B<s_server> command implements a generic SSL/TLS server which listens
46for connections on a given port using SSL/TLS.
47
48=head1 OPTIONS
49
50=over 4
51
52=item B<-accept port>
53
54the TCP port to listen on for connections. If not specified 4433 is used.
55
56=item B<-context id>
57
58sets the SSL context id. It can be given any string value. If this option
59is not present a default value will be used.
60
61=item B<-cert certname>
62
63The certificate to use, most servers cipher suites require the use of a
64certificate and some require a certificate with a certain public key type:
65for example the DSS cipher suites require a certificate containing a DSS
66(DSA) key. If not specified then the filename "server.pem" will be used.
67
68=item B<-key keyfile>
69
70The private key to use. If not specified then the certificate file will
71be used.
72
73=item B<-dcert filename>, B<-dkey keyname>
74
75specify an additional certificate and private key, these behave in the
76same manner as the B<-cert> and B<-key> options except there is no default
77if they are not specified (no additional certificate and key is used). As
78noted above some cipher suites require a certificate containing a key of
79a certain type. Some cipher suites need a certificate carrying an RSA key
80and some a DSS (DSA) key. By using RSA and DSS certificates and keys
81a server can support clients which only support RSA or DSS cipher suites
82by using an appropriate certificate.
83
84=item B<-nocert>
85
86if this option is set then no certificate is used. This restricts the
87cipher suites available to the anonymous ones (currently just anonymous
88DH).
89
90=item B<-dhparam filename>
91
92the DH parameter file to use. The ephemeral DH cipher suites generate keys
93using a set of DH parameters. If not specified then an attempt is made to
94load the parameters from the server certificate file. If this fails then
95a static set of parameters hard coded into the s_server program will be used.
96
97=item B<-nodhe>
98
99if this option is set then no DH parameters will be loaded effectively
100disabling the ephemeral DH cipher suites.
101
102=item B<-no_tmp_rsa>
103
104certain export cipher suites sometimes use a temporary RSA key, this option
105disables temporary RSA key generation.
106
107=item B<-verify depth>, B<-Verify depth>
108
109The verify depth to use. This specifies the maximum length of the
110client certificate chain and makes the server request a certificate from
111the client. With the B<-verify> option a certificate is requested but the
112client does not have to send one, with the B<-Verify> option the client
113must supply a certificate or an error occurs.
114
115=item B<-CApath directory>
116
117The directory to use for client certificate verification. This directory
118must be in "hash format", see B<verify> for more information. These are
119also used when building the server certificate chain.
120
121=item B<-CAfile file>
122
123A file containing trusted certificates to use during client authentication
124and to use when attempting to build the server certificate chain. The list
125is also used in the list of acceptable client CAs passed to the client when
126a certificate is requested.
127
128=item B<-state>
129
130prints out the SSL session states.
131
132=item B<-debug>
133
134print extensive debugging information including a hex dump of all traffic.
135
136=item B<-nbio_test>
137
138tests non blocking I/O
139
140=item B<-nbio>
141
142turns on non blocking I/O
143
144=item B<-crlf>
145
146this option translated a line feed from the terminal into CR+LF.
147
148=item B<-quiet>
149
150inhibit printing of session and certificate information.
151
152=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
153
154these options disable the use of certain SSL or TLS protocols. By default
155the initial handshake uses a method which should be compatible with all
156servers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
157
158=item B<-bugs>
159
160there are several known bug in SSL and TLS implementations. Adding this
161option enables various workarounds.
162
163=item B<-hack>
164
165this option enables a further workaround for some some early Netscape
166SSL code (?).
167
168=item B<-cipher cipherlist>
169
170this allows the cipher list used by the server to be modified. When
171the client sends a list of supported ciphers the first client cipher
172also included in the server list is used. Because the client specifies
173the preference order, the order of the server cipherlist irrelevant. See
174the B<ciphers> command for more information.
175
176=item B<-www>
177
178sends a status message back to the client when it connects. This includes
179lots of information about the ciphers used and various session parameters.
180The output is in HTML format so this option will normally be used with a
181web browser.
182
183=item B<-WWW>
184
185emulates a simple web server. Pages will be resolved relative to the
186current directory, for example if the URL https://myhost/page.html is
187requested the file ./page.html will be loaded.
188
189=back
190
191=head1 CONNECTED COMMANDS
192
193If a connection request is established with an SSL client and neither the
194B<-www> nor the B<-WWW> option has been used then normally any data received
195from the client is displayed and any key presses will be sent to the client.
196
197Certain single letter commands are also recognized which perform special
198operations: these are listed below.
199
200=over 4
201
202=item B<q>
203
204end the current SSL connection but still accept new connections.
205
206=item B<Q>
207
208end the current SSL connection and exit.
209
210=item B<r>
211
212renegotiate the SSL session.
213
214=item B<R>
215
216renegotiate the SSL session and request a client certificate.
217
218=item B<P>
219
220send some plain text down the underlying TCP connection: this should
221cause the client to disconnect due to a protocol violation.
222
223=item B<S>
224
225print out some session cache status information.
226
227=back
228
229=head1 NOTES
230
231B<s_server> can be used to debug SSL clients. To accept connections from
232a web browser the command:
233
234 openssl s_server -accept 443 -www
235
236can be used for example.
237
238Most web browsers (in particular Netscape and MSIE) only support RSA cipher
239suites, so they cannot connect to servers which don't use a certificate
240carrying an RSA key or a version of OpenSSL with RSA disabled.
241
242Although specifying an empty list of CAs when requesting a client certificate
243is strictly speaking a protocol violation, some SSL clients interpret this to
244mean any CA is acceptable. This is useful for debugging purposes.
245
246The session parameters can printed out using the B<sess_id> program.
247
248=head1 BUGS
249
250Because this program has a lot of options and also because some of
251the techniques used are rather old, the C source of s_server is rather
252hard to read and not a model of how things should be done. A typical
253SSL server program would be much simpler.
254
255The output of common ciphers is wrong: it just gives the list of ciphers that
256OpenSSL recognizes and the client supports.
257
258There should be a way for the B<s_server> program to print out details of any
259unknown cipher suites a client says it supports.
260
261=head1 SEE ALSO
262
263L<sess_id(1)|sess_id(1)>, L<s_client(1)|s_client(1)>, L<ciphers(1)|ciphers(1)>
264
265=cut
diff --git a/src/lib/libssl/src/doc/apps/sess_id.pod b/src/lib/libssl/src/doc/apps/sess_id.pod
new file mode 100644
index 0000000000..9988d2cd3d
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/sess_id.pod
@@ -0,0 +1,151 @@
1
2=pod
3
4=head1 NAME
5
6sess_id - SSL/TLS session handling utility
7
8=head1 SYNOPSIS
9
10B<openssl> B<sess_id>
11[B<-inform PEM|DER>]
12[B<-outform PEM|DER>]
13[B<-in filename>]
14[B<-out filename>]
15[B<-text>]
16[B<-noout>]
17[B<-context ID>]
18
19=head1 DESCRIPTION
20
21The B<sess_id> process the encoded version of the SSL session structure
22and optionally prints out SSL session details (for example the SSL session
23master key) in human readable format. Since this is a diagnostic tool that
24needs some knowledge of the SSL protocol to use properly, most users will
25not need to use it.
26
27=over 4
28
29=item B<-inform DER|PEM>
30
31This specifies the input format. The B<DER> option uses an ASN1 DER encoded
32format containing session details. The precise format can vary from one version
33to the next. The B<PEM> form is the default format: it consists of the B<DER>
34format base64 encoded with additional header and footer lines.
35
36=item B<-outform DER|PEM>
37
38This specifies the output format, the options have the same meaning as the
39B<-inform> option.
40
41=item B<-in filename>
42
43This specifies the input filename to read session information from or standard
44input by default.
45
46=item B<-out filename>
47
48This specifies the output filename to write session information to or standard
49output if this option is not specified.
50
51=item B<-text>
52
53prints out the various public or private key components in
54plain text in addition to the encoded version.
55
56=item B<-cert>
57
58if a certificate is present in the session it will be output using this option,
59if the B<-text> option is also present then it will be printed out in text form.
60
61=item B<-noout>
62
63this option prevents output of the encoded version of the session.
64
65=item B<-context ID>
66
67this option can set the session id so the output session information uses the
68supplied ID. The ID can be any string of characters. This option wont normally
69be used.
70
71=back
72
73=head1 OUTPUT
74
75Typical output:
76
77 SSL-Session:
78 Protocol : TLSv1
79 Cipher : 0016
80 Session-ID: 871E62626C554CE95488823752CBD5F3673A3EF3DCE9C67BD916C809914B40ED
81 Session-ID-ctx: 01000000
82 Master-Key: A7CEFC571974BE02CAC305269DC59F76EA9F0B180CB6642697A68251F2D2BB57E51DBBB4C7885573192AE9AEE220FACD
83 Key-Arg : None
84 Start Time: 948459261
85 Timeout : 300 (sec)
86 Verify return code 0 (ok)
87
88Theses are described below in more detail.
89
90=over 4
91
92=item B<Protocol>
93
94this is the protocol in use TLSv1, SSLv3 or SSLv2.
95
96=item B<Cipher>
97
98the cipher used this is the actual raw SSL or TLS cipher code, see the SSL
99or TLS specifications for more information.
100
101=item B<Session-ID>
102
103the SSL session ID in hex format.
104
105=item B<Session-ID-ctx>
106
107the session ID context in hex format.
108
109=item B<Master-Key>
110
111this is the SSL session master key.
112
113=item B<Key-Arg>
114
115the key argument, this is only used in SSL v2.
116
117=item B<Start Time>
118
119this is the session start time represented as an integer in standard Unix format.
120
121=item B<Timeout>
122
123the timeout in seconds.
124
125=item B<Verify return code>
126
127this is the return code when an SSL client certificate is verified.
128
129=back
130
131=head1 NOTES
132
133The PEM encoded session format uses the header and footer lines:
134
135 -----BEGIN SSL SESSION PARAMETERS-----
136 -----END SSL SESSION PARAMETERS-----
137
138Since the SSL session output contains the master key it is possible to read the contents
139of an encrypted session using this information. Therefore appropriate security precautions
140should be taken if the information is being output by a "real" application. This is
141however strongly discouraged and should only be used for debugging purposes.
142
143=head1 BUGS
144
145The cipher and start time should be printed out in human readable form.
146
147=head1 SEE ALSO
148
149L<ciphers(1)|ciphers(1)>, L<s_server(1)|s_server(1)>
150
151=cut
diff --git a/src/lib/libssl/src/doc/apps/smime.pod b/src/lib/libssl/src/doc/apps/smime.pod
new file mode 100644
index 0000000000..631ecdc241
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/smime.pod
@@ -0,0 +1,325 @@
1=pod
2
3=head1 NAME
4
5smime - S/MIME utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<smime>
10[B<-encrypt>]
11[B<-decrypt>]
12[B<-sign>]
13[B<-verify>]
14[B<-pk7out>]
15[B<-des>]
16[B<-des3>]
17[B<-rc2-40>]
18[B<-rc2-64>]
19[B<-rc2-128>]
20[B<-in file>]
21[B<-certfile file>]
22[B<-signer file>]
23[B<-recip file>]
24[B<-in file>]
25[B<-inkey file>]
26[B<-out file>]
27[B<-to addr>]
28[B<-from ad>]
29[B<-subject s>]
30[B<-text>]
31[B<-rand file(s)>]
32[cert.pem]...
33
34=head1 DESCRIPTION
35
36The B<smime> command handles S/MIME mail. It can encrypt, decrypt, sign and
37verify S/MIME messages.
38
39=head1 COMMAND OPTIONS
40
41There are five operation options that set the type of operation to be performed.
42The meaning of the other options varies according to the operation type.
43
44=over 4
45
46=item B<-encrypt>
47
48encrypt mail for the given recipient certificates. Input file is the message
49to be encrypted. The output file is the encrypted mail in MIME format.
50
51=item B<-decrypt>
52
53decrypt mail using the supplied certificate and private key. Expects an
54encrypted mail message in MIME format for the input file. The decrypted mail
55is written to the output file.
56
57=item B<-sign>
58
59sign mail using the supplied certificate and private key. Input file is
60the message to be signed. The signed message in MIME format is written
61to the output file.
62
63=item B<-verify>
64
65verify signed mail. Expects a signed mail message on input and outputs
66the signed data. Both clear text and opaque signing is supported.
67
68=item B<-pk7out>
69
70takes an input message and writes out a PEM encoded PKCS#7 structure.
71
72=item B<-in filename>
73
74the input message to be encrypted or signed or the MIME message to
75be decrypted or verified.
76
77=item B<-out filename>
78
79the message text that has been decrypted or verified or the output MIME
80format message that has been signed or verified.
81
82=item B<-text>
83
84this option adds plain text (text/plain) MIME headers to the supplied
85message if encrypting or signing. If decrypting or verifying it strips
86off text headers: if the decrypted or verified message is not of MIME
87type text/plain then an error occurs.
88
89=item B<-CAfile file>
90
91a file containing trusted CA certificates, only used with B<-verify>.
92
93=item B<-CApath dir>
94
95a directory containing trusted CA certificates, only used with
96B<-verify>. This directory must be a standard certificate directory: that
97is a hash of each subject name (using B<x509 -hash>) should be linked
98to each certificate.
99
100=item B<-des -des3 -rc2-40 -rc2-64 -rc2-128>
101
102the encryption algorithm to use. DES (56 bits), triple DES (168 bits)
103or 40, 64 or 128 bit RC2 respectively if not specified 40 bit RC2 is
104used. Only used with B<-encrypt>.
105
106=item B<-nointern>
107
108when verifying a message normally certificates (if any) included in
109the message are searched for the signing certificate. With this option
110only the certificates specified in the B<-certfile> option are used.
111The supplied certificates can still be used as untrusted CAs however.
112
113=item B<-noverify>
114
115do not verify the signers certificate of a signed message.
116
117=item B<-nochain>
118
119do not do chain verification of signers certificates: that is don't
120use the certificates in the signed message as untrusted CAs.
121
122=item B<-nosigs>
123
124don't try to verify the signatures on the message.
125
126=item B<-nocerts>
127
128when signing a message the signer's certificate is normally included
129with this option it is excluded. This will reduce the size of the
130signed message but the verifier must have a copy of the signers certificate
131available locally (passed using the B<-certfile> option for example).
132
133=item B<-noattr>
134
135normally when a message is signed a set of attributes are included which
136include the signing time and supported symmetric algorithms. With this
137option they are not included.
138
139=item B<-binary>
140
141normally the input message is converted to "canonical" format which is
142effectively using CR and LF as end of line: as required by the S/MIME
143specification. When this option is present no translation occurs. This
144is useful when handling binary data which may not be in MIME format.
145
146=item B<-nodetach>
147
148when signing a message use opaque signing: this form is more resistant
149to translation by mail relays but it cannot be read by mail agents that
150do not support S/MIME. Without this option cleartext signing with
151the MIME type multipart/signed is used.
152
153=item B<-certfile file>
154
155allows additional certificates to be specified. When signing these will
156be included with the message. When verifying these will be searched for
157the signers certificates. The certificates should be in PEM format.
158
159=item B<-signer file>
160
161the signers certificate when signing a message. If a message is
162being verified then the signers certificates will be written to this
163file if the verification was successful.
164
165=item B<-recip file>
166
167the recipients certificate when decrypting a message. This certificate
168must match one of the recipients of the message or an error occurs.
169
170=item B<-inkey file>
171
172the private key to use when signing or decrypting. This must match the
173corresponding certificate. If this option is not specified then the
174private key must be included in the certificate file specified with
175the B<-recip> or B<-signer> file.
176
177=item B<-rand file(s)>
178
179a file or files containing random data used to seed the random number
180generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
181Multiple files can be specified separated by a OS-dependent character.
182The separator is B<;> for MS-Windows, B<,> for OpenVSM, and B<:> for
183all others.
184
185=item B<cert.pem...>
186
187one or more certificates of message recipients: used when encrypting
188a message.
189
190=item B<-to, -from, -subject>
191
192the relevant mail headers. These are included outside the signed
193portion of a message so they may be included manually. If signing
194then many S/MIME mail clients check the signers certificate's email
195address matches that specified in the From: address.
196
197=back
198
199=head1 NOTES
200
201The MIME message must be sent without any blank lines between the
202headers and the output. Some mail programs will automatically add
203a blank line. Piping the mail directly to sendmail is one way to
204achieve the correct format.
205
206The supplied message to be signed or encrypted must include the
207necessary MIME headers: or many S/MIME clients wont display it
208properly (if at all). You can use the B<-text> option to automatically
209add plain text headers.
210
211A "signed and encrypted" message is one where a signed message is
212then encrypted. This can be produced by encrypting an already signed
213message: see the examples section.
214
215This version of the program only allows one signer per message but it
216will verify multiple signers on received messages. Some S/MIME clients
217choke if a message contains multiple signers. It is possible to sign
218messages "in parallel" by signing an already signed message.
219
220The options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME
221clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7
222encrypted data is used for other purposes.
223
224=head1 EXIT CODES
225
226=over 4
227
228=item 0
229
230the operation was completely successfully.
231
232=item 1
233
234an error occurred parsing the command options.
235
236=item 2
237
238one of the input files could not be read.
239
240=item 3
241
242an error occurred creating the PKCS#7 file or when reading the MIME
243message.
244
245=item 4
246
247an error occurred decrypting or verifying the message.
248
249=item 5
250
251the message was verified correctly but an error occurred writing out
252the signers certificates.
253
254=back
255
256=head1 EXAMPLES
257
258Create a cleartext signed message:
259
260 openssl smime -sign -in message.txt -text -out mail.msg \
261 -signer mycert.pem
262
263Create and opaque signed message
264
265 openssl smime -sign -in message.txt -text -out mail.msg -nodetach \
266 -signer mycert.pem
267
268Create a signed message, include some additional certificates and
269read the private key from another file:
270
271 openssl smime -sign -in in.txt -text -out mail.msg \
272 -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
273
274Send a signed message under Unix directly to sendmail, including headers:
275
276 openssl smime -sign -in in.txt -text -signer mycert.pem \
277 -from steve@openssl.org -to someone@somewhere \
278 -subject "Signed message" | sendmail someone@somewhere
279
280Verify a message and extract the signer's certificate if successful:
281
282 openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
283
284Send encrypted mail using triple DES:
285
286 openssl smime -encrypt -in in.txt -from steve@openssl.org \
287 -to someone@somewhere -subject "Encrypted message" \
288 -des3 user.pem -out mail.msg
289
290Sign and encrypt mail:
291
292 openssl smime -sign -in ml.txt -signer my.pem -text \
293 | openssl -encrypt -out mail.msg \
294 -from steve@openssl.org -to someone@somewhere \
295 -subject "Signed and Encrypted message" -des3 user.pem
296
297Note: the encryption command does not include the B<-text> option because the message
298being encrypted already has MIME headers.
299
300Decrypt mail:
301
302 openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
303
304=head1 BUGS
305
306The MIME parser isn't very clever: it seems to handle most messages that I've thrown
307at it but it may choke on others.
308
309The code currently will only write out the signer's certificate to a file: if the
310signer has a separate encryption certificate this must be manually extracted. There
311should be some heuristic that determines the correct encryption certificate.
312
313Ideally a database should be maintained of a certificates for each email address.
314
315The code doesn't currently take note of the permitted symmetric encryption
316algorithms as supplied in the SMIMECapabilities signed attribute. this means the
317user has to manually include the correct encryption algorithm. It should store
318the list of permitted ciphers in a database and only use those.
319
320No revocation checking is done on the signer's certificate.
321
322The current code can only handle S/MIME v2 messages, the more complex S/MIME v3
323structures may cause parsing errors.
324
325=cut
diff --git a/src/lib/libssl/src/doc/apps/speed.pod b/src/lib/libssl/src/doc/apps/speed.pod
new file mode 100644
index 0000000000..fecd9a994d
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/speed.pod
@@ -0,0 +1,45 @@
1=pod
2
3=head1 NAME
4
5speed - test library performance
6
7=head1 SYNOPSIS
8
9B<openssl speed>
10[B<md2>]
11[B<mdc2>]
12[B<md5>]
13[B<hmac>]
14[B<sha1>]
15[B<rmd160>]
16[B<idea-cbc>]
17[B<rc2-cbc>]
18[B<rc5-cbc>]
19[B<bf-cbc>]
20[B<des-cbc>]
21[B<des-ede3>]
22[B<rc4>]
23[B<rsa512>]
24[B<rsa1024>]
25[B<rsa2048>]
26[B<rsa4096>]
27[B<dsa512>]
28[B<dsa1024>]
29[B<dsa2048>]
30[B<idea>]
31[B<rc2>]
32[B<des>]
33[B<rsa>]
34[B<blowfish>]
35
36=head1 DESCRIPTION
37
38This command is used to test the performance of cryptographic algorithms.
39
40=head1 OPTIONS
41
42If an option is given, B<speed> test that algorithm, otherwise all of
43the above are tested.
44
45=cut
diff --git a/src/lib/libssl/src/doc/apps/spkac.pod b/src/lib/libssl/src/doc/apps/spkac.pod
new file mode 100644
index 0000000000..bb84dfbe33
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/spkac.pod
@@ -0,0 +1,127 @@
1=pod
2
3=head1 NAME
4
5spkac - SPKAC printing and generating utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<spkac>
10[B<-in filename>]
11[B<-out filename>]
12[B<-key keyfile>]
13[B<-passin arg>]
14[B<-challenge string>]
15[B<-pubkey>]
16[B<-spkac spkacname>]
17[B<-spksect section>]
18[B<-noout>]
19[B<-verify>]
20
21
22=head1 DESCRIPTION
23
24The B<spkac> command processes Netscape signed public key and challenge
25(SPKAC) files. It can print out their contents, verify the signature and
26produce its own SPKACs from a supplied private key.
27
28=head1 COMMAND OPTIONS
29
30=over 4
31
32=item B<-in filename>
33
34This specifies the input filename to read from or standard input if this
35option is not specified. Ignored if the B<-key> option is used.
36
37=item B<-out filename>
38
39specifies the output filename to write to or standard output by
40default.
41
42=item B<-key keyfile>
43
44create an SPKAC file using the private key in B<keyfile>. The
45B<-in>, B<-noout>, B<-spksect> and B<-verify> options are ignored if
46present.
47
48=item B<-passin password>
49
50the input file password source. For more information about the format of B<arg>
51see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
52
53=item B<-challenge string>
54
55specifies the challenge string if an SPKAC is being created.
56
57=item B<-spkac spkacname>
58
59allows an alternative name form the variable containing the
60SPKAC. The default is "SPKAC". This option affects both
61generated and input SPKAC files.
62
63=item B<-spksect section>
64
65allows an alternative name form the section containing the
66SPKAC. The default is the default section.
67
68=item B<-noout>
69
70don't output the text version of the SPKAC (not used if an
71SPKAC is being created).
72
73=item B<-pubkey>
74
75output the public key of an SPKAC (not used if an SPKAC is
76being created).
77
78=item B<-verify>
79
80verifies the digital signature on the supplied SPKAC.
81
82
83=back
84
85=head1 EXAMPLES
86
87Print out the contents of an SPKAC:
88
89 openssl spkac -in spkac.cnf
90
91Verify the signature of an SPKAC:
92
93 openssl spkac -in spkac.cnf -noout -verify
94
95Create an SPKAC using the challenge string "hello":
96
97 openssl spkac -key key.pem -challenge hello -out spkac.cnf
98
99Example of an SPKAC, (long lines split up for clarity):
100
101 SPKAC=MIG5MGUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA1cCoq2Wa3Ixs47uI7F\
102 PVwHVIPDx5yso105Y6zpozam135a8R0CpoRvkkigIyXfcCjiVi5oWk+6FfPaD03u\
103 PFoQIDAQABFgVoZWxsbzANBgkqhkiG9w0BAQQFAANBAFpQtY/FojdwkJh1bEIYuc\
104 2EeM2KHTWPEepWYeawvHD0gQ3DngSC75YCWnnDdq+NQ3F+X4deMx9AaEglZtULwV\
105 4=
106
107=head1 NOTES
108
109A created SPKAC with suitable DN components appended can be fed into
110the B<ca> utility.
111
112SPKACs are typically generated by Netscape when a form is submitted
113containing the B<KEYGEN> tag as part of the certificate enrollment
114process.
115
116The challenge string permits a primitive form of proof of possession
117of private key. By checking the SPKAC signature and a random challenge
118string some guarantee is given that the user knows the private key
119corresponding to the public key being certified. This is important in
120some applications. Without this it is possible for a previous SPKAC
121to be used in a "replay attack".
122
123=head1 SEE ALSO
124
125L<ca(1)|ca(1)>
126
127=cut
diff --git a/src/lib/libssl/src/doc/apps/verify.pod b/src/lib/libssl/src/doc/apps/verify.pod
new file mode 100644
index 0000000000..4a6572d3b8
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/verify.pod
@@ -0,0 +1,273 @@
1=pod
2
3=head1 NAME
4
5pkcs7 - PKCS#7 utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<verify>
10[B<-CApath directory>]
11[B<-CAfile file>]
12[B<-purpose purpose>]
13[B<-untrusted file>]
14[B<-help>]
15[B<-verbose>]
16[B<->]
17[certificates]
18
19
20=head1 DESCRIPTION
21
22The B<verify> command verifies certificate chains.
23
24=head1 COMMAND OPTIONS
25
26=over 4
27
28=item B<-CApath directory>
29
30A directory of trusted certificates. The certificates should have names
31of the form: hash.0 or have symbolic links to them of this
32form ("hash" is the hashed certificate subject name: see the B<-hash> option
33of the B<x509> utility). Under Unix the B<c_rehash> script will automatically
34create symbolic links to a directory of certificates.
35
36=item B<-CAfile file>
37
38A file of trusted certificates. The file should contain multiple certificates
39in PEM format concatenated together.
40
41=item B<-untrusted file>
42
43A file of untrusted certificates. The file should contain multiple certificates
44
45=item B<-purpose purpose>
46
47the intended use for the certificate. Without this option no chain verification
48will be done. Currently accepted uses are B<sslclient>, B<sslserver>,
49B<nssslserver>, B<smimesign>, B<smimeencrypt>. See the B<VERIFY OPERATION>
50section for more information.
51
52=item B<-help>
53
54prints out a usage message.
55
56=item B<-verbose>
57
58print extra information about the operations being performed.
59
60=item B<->
61
62marks the last option. All arguments following this are assumed to be
63certificate files. This is useful if the first certificate filename begins
64with a B<->.
65
66=item B<certificates>
67
68one or more certificates to verify. If no certificate filenames are included
69then an attempt is made to read a certificate from standard input. They should
70all be in PEM format.
71
72
73=back
74
75=head1 VERIFY OPERATION
76
77The B<verify> program uses the same functions as the internal SSL and S/MIME
78verification, therefore this description applies to these verify operations
79too.
80
81There is one crucial difference between the verify operations performed
82by the B<verify> program: wherever possible an attempt is made to continue
83after an error whereas normally the verify operation would halt on the
84first error. This allows all the problems with a certificate chain to be
85determined.
86
87The verify operation consists of a number of separate steps.
88
89Firstly a certificate chain is built up starting from the supplied certificate
90and ending in the root CA. It is an error if the whole chain cannot be built
91up. The chain is built up by looking up a certificate whose subject name
92matches the issuer name of the current certificate. If a certificate is found
93whose subject and issuer names are identical it is assumed to be the root CA.
94The lookup first looks in the list of untrusted certificates and if no match
95is found the remaining lookups are from the trusted certificates. The root CA
96is always looked up in the trusted certificate list: if the certificate to
97verify is a root certificate then an exact match must be found in the trusted
98list.
99
100The second operation is to check every untrusted certificate's extensions for
101consistency with the supplied purpose. If the B<-purpose> option is not included
102then no checks are done. The supplied or "leaf" certificate must have extensions
103compatible with the supplied purpose and all other certificates must also be valid
104CA certificates. The precise extensions required are described in more detail in
105the B<CERTIFICATE EXTENSIONS> section of the B<x509> utility.
106
107The third operation is to check the trust settings on the root CA. The root
108CA should be trusted for the supplied purpose. For compatibility with previous
109versions of SSLeay and OpenSSL a certificate with no trust settings is considered
110to be valid for all purposes.
111
112The final operation is to check the validity of the certificate chain. The validity
113period is checked against the current system time and the notBefore and notAfter
114dates in the certificate. The certificate signatures are also checked at this
115point.
116
117If all operations complete successfully then certificate is considered valid. If
118any operation fails then the certificate is not valid.
119
120=head1 DIAGNOSTICS
121
122When a verify operation fails the output messages can be somewhat cryptic. The
123general form of the error message is:
124
125 server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
126 error 24 at 1 depth lookup:invalid CA certificate
127
128The first line contains the name of the certificate being verified followed by
129the subject name of the certificate. The second line contains the error number
130and the depth. The depth is number of the certificate being verified when a
131problem was detected starting with zero for the certificate being verified itself
132then 1 for the CA that signed the certificate and so on. Finally a text version
133of the error number is presented.
134
135An exhaustive list of the error codes and messages is shown below, this also
136includes the name of the error code as defined in the header file x509_vfy.h
137Some of the error codes are defined but never returned: these are described
138as "unused".
139
140=over 4
141
142=item B<0 X509_V_OK: ok>
143
144the operation was successful.
145
146=item B<2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate>
147
148the issuer certificate could not be found: this occurs if the issuer certificate
149of an untrusted certificate cannot be found.
150
151=item B<3 X509_V_ERR_UNABLE_TO_GET_CRL unable to get certificate CRL>
152
153the CRL of a certificate could not be found. Unused.
154
155=item B<4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature>
156
157the certificate signature could not be decrypted. This means that the actual signature value
158could not be determined rather than it not matching the expected value, this is only
159meaningful for RSA keys.
160
161=item B<5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature>
162
163the CRL signature could not be decrypted: this means that the actual signature value
164could not be determined rather than it not matching the expected value. Unused.
165
166=item B<6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key>
167
168the public key in the certificate SubjectPublicKeyInfo could not be read.
169
170=item B<7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure>
171
172the signature of the certificate is invalid.
173
174=item B<8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure>
175
176the signature of the certificate is invalid. Unused.
177
178=item B<9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid>
179
180the certificate is not yet valid: the notBefore date is after the current time.
181
182=item B<10 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
183
184the CRL is not yet valid. Unused.
185
186=item B<11 X509_V_ERR_CERT_HAS_EXPIRED: Certificate has expired>
187
188the certificate has expired: that is the notAfter date is before the current time.
189
190=item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
191
192the CRL has expired. Unused.
193
194=item B<13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field>
195
196the certificate notBefore field contains an invalid time.
197
198=item B<14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field>
199
200the certificate notAfter field contains an invalid time.
201
202=item B<15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field>
203
204the CRL lastUpdate field contains an invalid time. Unused.
205
206=item B<16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field>
207
208the CRL nextUpdate field contains an invalid time. Unused.
209
210=item B<17 X509_V_ERR_OUT_OF_MEM: out of memory>
211
212an error occurred trying to allocate memory. This should never happen.
213
214=item B<18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate>
215
216the passed certificate is self signed and the same certificate cannot be found in the list of
217trusted certificates.
218
219=item B<19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain>
220
221the certificate chain could be built up using the untrusted certificates but the root could not
222be found locally.
223
224=item B<20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate>
225
226the issuer certificate of a locally looked up certificate could not be found. This normally means
227the list of trusted certificates is not complete.
228
229=item B<21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate>
230
231no signatures could be verified because the chain contains only one certificate and it is not
232self signed.
233
234=item B<22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long>
235
236the certificate chain length is greater than the supplied maximum depth. Unused.
237
238=item B<23 X509_V_ERR_CERT_REVOKED: certificate revoked>
239
240the certificate has been revoked. Unused.
241
242=item B<24 X509_V_ERR_INVALID_CA: invalid CA certificate>
243
244a CA certificate is invalid. Either it is not a CA or its extensions are not consistent
245with the supplied purpose.
246
247=item B<25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded>
248
249the basicConstraints pathlength parameter has been exceeded.
250
251=item B<26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose>
252
253the supplied certificate cannot be used for the specified purpose.
254
255=item B<27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted>
256
257the root CA is not marked as trusted for the specified purpose.
258
259=item B<28 X509_V_ERR_CERT_REJECTED: certificate rejected>
260
261the root CA is marked to reject the specified purpose.
262
263=item B<50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure>
264
265an application specific error. Unused.
266
267=back
268
269=head1 SEE ALSO
270
271L<x509(1)|x509(1)>
272
273=cut
diff --git a/src/lib/libssl/src/doc/apps/version.pod b/src/lib/libssl/src/doc/apps/version.pod
new file mode 100644
index 0000000000..5d261a6405
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/version.pod
@@ -0,0 +1,56 @@
1=pod
2
3=head1 NAME
4
5version - print OpenSSL version information
6
7=head1 SYNOPSIS
8
9B<openssl version>
10[B<-a>]
11[B<-v>]
12[B<-b>]
13[B<-o>]
14[B<-f>]
15[B<-p>]
16
17=head1 DESCRIPTION
18
19This command is used to print out version information about OpenSSL.
20
21=head1 OPTIONS
22
23=over 4
24
25=item B<-a>
26
27all information, this is the same as setting all the other flags.
28
29=item B<-v>
30
31the current OpenSSL version.
32
33=item B<-b>
34
35the date the current version of OpenSSL was built.
36
37=item B<-o>
38
39option information: various options set when the library was built.
40
41=item B<-c>
42
43compilation flags.
44
45=item B<-p>
46
47platform setting.
48
49=back
50
51=head1 NOTES
52
53The output of B<openssl version -a> would typically be used when sending
54in a bug report.
55
56=cut
diff --git a/src/lib/libssl/src/doc/apps/x509.pod b/src/lib/libssl/src/doc/apps/x509.pod
new file mode 100644
index 0000000000..b127182bbb
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/x509.pod
@@ -0,0 +1,543 @@
1
2=pod
3
4=head1 NAME
5
6x509 - Certificate display and signing utility
7
8=head1 SYNOPSIS
9
10B<openssl> B<x509>
11[B<-inform DER|PEM|NET>]
12[B<-outform DER|PEM|NET>]
13[B<-keyform DER|PEM>]
14[B<-CAform DER|PEM>]
15[B<-CAkeyform DER|PEM>]
16[B<-in filename>]
17[B<-out filename>]
18[B<-serial>]
19[B<-hash>]
20[B<-subject>]
21[B<-issuer>]
22[B<-startdate>]
23[B<-enddate>]
24[B<-purpose>]
25[B<-dates>]
26[B<-modulus>]
27[B<-fingerprint>]
28[B<-alias>]
29[B<-noout>]
30[B<-trustout>]
31[B<-clrtrust>]
32[B<-clrreject>]
33[B<-addtrust arg>]
34[B<-addreject arg>]
35[B<-setalias arg>]
36[B<-days arg>]
37[B<-signkey filename>]
38[B<-x509toreq>]
39[B<-req>]
40[B<-CA filename>]
41[B<-CAkey filename>]
42[B<-CAcreateserial>]
43[B<-CAserial filename>]
44[B<-text>]
45[B<-C>]
46[B<-md2|-md5|-sha1|-mdc2>]
47[B<-clrext>]
48[B<-extfile filename>]
49[B<-extensions section>]
50
51=head1 DESCRIPTION
52
53The B<x509> command is a multi purpose certificate utility. It can be
54used to display certificate information, convert certificates to
55various forms, sign certificate requests like a "mini CA" or edit
56certificate trust settings.
57
58Since there are a large number of options they will split up into
59various sections.
60
61
62=head1 INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS
63
64=over 4
65
66=item B<-inform DER|PEM|NET>
67
68This specifies the input format normally the command will expect an X509
69certificate but this can change if other options such as B<-req> are
70present. The DER format is the DER encoding of the certificate and PEM
71is the base64 encoding of the DER encoding with header and footer lines
72added. The NET option is an obscure Netscape server format that is now
73obsolete.
74
75=item B<-outform DER|PEM|NET>
76
77This specifies the output format, the options have the same meaning as the
78B<-inform> option.
79
80=item B<-in filename>
81
82This specifies the input filename to read a certificate from or standard input
83if this option is not specified.
84
85=item B<-out filename>
86
87This specifies the output filename to write to or standard output by
88default.
89
90=item B<-md2|-md5|-sha1|-mdc2>
91
92the digest to use. This affects any signing or display option that uses a message
93digest, such as the B<-fingerprint>, B<-signkey> and B<-CA> options. If not
94specified then MD5 is used. If the key being used to sign with is a DSA key then
95this option has no effect: SHA1 is always used with DSA keys.
96
97
98=back
99
100=head1 DISPLAY OPTIONS
101
102Note: the B<-alias> and B<-purpose> options are also display options
103but are described in the B<TRUST OPTIONS> section.
104
105=over 4
106
107=item B<-text>
108
109prints out the certificate in text form. Full details are output including the
110public key, signature algorithms, issuer and subject names, serial number
111any extensions present and any trust settings.
112
113=item B<-noout>
114
115this option prevents output of the encoded version of the request.
116
117=item B<-modulus>
118
119this option prints out the value of the modulus of the public key
120contained in the certificate.
121
122=item B<-serial>
123
124outputs the certificate serial number.
125
126=item B<-hash>
127
128outputs the "hash" of the certificate subject name. This is used in OpenSSL to
129form an index to allow certificates in a directory to be looked up by subject
130name.
131
132=item B<-subject>
133
134outputs the subject name.
135
136=item B<-issuer>
137
138outputs the issuer name.
139
140=item B<-startdate>
141
142prints out the start date of the certificate, that is the notBefore date.
143
144=item B<-enddate>
145
146prints out the expiry date of the certificate, that is the notAfter date.
147
148=item B<-dates>
149
150prints out the start and expiry dates of a certificate.
151
152=item B<-fingerprint>
153
154prints out the digest of the DER encoded version of the whole certificate.
155
156=item B<-C>
157
158this outputs the certificate in the form of a C source file.
159
160=back
161
162=head1 TRUST SETTINGS
163
164Please note these options are currently experimental and may well change.
165
166A B<trusted certificate> is an ordinary certificate which has several
167additional pieces of information attached to it such as the permitted
168and prohibited uses of the certificate and an "alias".
169
170Normally when a certificate is being verified at least one certificate
171must be "trusted". By default a trusted certificate must be stored
172locally and must be a root CA: any certificate chain ending in this CA
173is then usable for any purpose.
174
175Trust settings currently are only used with a root CA. They allow a finer
176control over the purposes the root CA can be used for. For example a CA
177may be trusted for SSL client but not SSL server use.
178
179See the description of the B<verify> utility for more information on the
180meaning of trust settings.
181
182Future versions of OpenSSL will recognize trust settings on any
183certificate: not just root CAs.
184
185
186=over 4
187
188=item B<-trustout>
189
190this causes B<x509> to output a B<trusted> certificate. An ordinary
191or trusted certificate can be input but by default an ordinary
192certificate is output and any trust settings are discarded. With the
193B<-trustout> option a trusted certificate is output. A trusted
194certificate is automatically output if any trust settings are modified.
195
196=item B<-setalias arg>
197
198sets the alias of the certificate. This will allow the certificate
199to be referred to using a nickname for example "Steve's Certificate".
200
201=item B<-alias>
202
203outputs the certificate alias, if any.
204
205=item B<-clrtrust>
206
207clears all the permitted or trusted uses of the certificate.
208
209=item B<-clrreject>
210
211clears all the prohibited or rejected uses of the certificate.
212
213=item B<-addtrust arg>
214
215adds a trusted certificate use. Currently acceptable values
216are B<all> (any purpose), B<sslclient> (SSL client use), B<sslserver>
217(SSL server use) B<email> (S/MIME email) and B<objsign> (Object signing).
218
219=item B<-addreject arg>
220
221adds a prohibited use. It accepts the same values as the B<-addtrust>
222option.
223
224=item B<-purpose>
225
226this option performs tests on the certificate extensions and outputs
227the results. For a more complete description see the B<CERTIFICATE
228EXTENSIONS> section.
229
230=back
231
232=head1 SIGNING OPTIONS
233
234The B<x509> utility can be used to sign certificates and requests: it
235can thus behave like a "mini CA".
236
237=over 4
238
239=item B<-signkey filename>
240
241this option causes the input file to be self signed using the supplied
242private key.
243
244If the input file is a certificate it sets the issuer name to the
245subject name (i.e. makes it self signed) changes the public key to the
246supplied value and changes the start and end dates. The start date is
247set to the current time and the end date is set to a value determined
248by the B<-days> option. Any certificate extensions are retained unless
249the B<-clrext> option is supplied.
250
251If the input is a certificate request then a self signed certificate
252is created using the supplied private key using the subject name in
253the request.
254
255=item B<-clrext>
256
257delete any extensions from a certificate. This option is used when a
258certificate is being created from another certificate (for example with
259the B<-signkey> or the B<-CA> options). Normally all extensions are
260retained.
261
262=item B<-keyform PEM|DER>
263
264specifies the format (DER or PEM) of the private key file used in the
265B<-signkey> option.
266
267=item B<-days arg>
268
269specifies the number of days to make a certificate valid for. The default
270is 30 days.
271
272=item B<-x509toreq>
273
274converts a certificate into a certificate request. The B<-signkey> option
275is used to pass the required private key.
276
277=item B<-req>
278
279by default a certificate is expected on input. With this option a
280certificate request is expected instead.
281
282=item B<-CA filename>
283
284specifies the CA certificate to be used for signing. When this option is
285present B<x509> behaves like a "mini CA". The input file is signed by this
286CA using this option: that is its issuer name is set to the subject name
287of the CA and it is digitally signed using the CAs private key.
288
289This option is normally combined with the B<-req> option. Without the
290B<-req> option the input is a certificate which must be self signed.
291
292=item B<-CAkey filename>
293
294sets the CA private key to sign a certificate with. If this option is
295not specified then it is assumed that the CA private key is present in
296the CA certificate file.
297
298=item B<-CAserial filename>
299
300sets the CA serial number file to use.
301
302When the B<-CA> option is used to sign a certificate it uses a serial
303number specified in a file. This file consist of one line containing
304an even number of hex digits with the serial number to use. After each
305use the serial number is incremented and written out to the file again.
306
307The default filename consists of the CA certificate file base name with
308".srl" appended. For example if the CA certificate file is called
309"mycacert.pem" it expects to find a serial number file called "mycacert.srl".
310
311=item B<-CAcreateserial filename>
312
313with this option the CA serial number file is created if it does not exist:
314it will contain the serial number "02" and the certificate being signed will
315have the 1 as its serial number. Normally if the B<-CA> option is specified
316and the serial number file does not exist it is an error.
317
318=item B<-extfile filename>
319
320file containing certificate extensions to use. If not specified then
321no extensions are added to the certificate.
322
323=item B<-extensions section>
324
325the section to add certificate extensions from. If this option is not
326specified then the extensions should either be contained in the unnamed
327(default) section or the default section should contain a variable called
328"extensions" which contains the section to use.
329
330=back
331
332=head1 EXAMPLES
333
334Note: in these examples the '\' means the example should be all on one
335line.
336
337Display the contents of a certificate:
338
339 openssl x509 -in cert.pem -noout -text
340
341Display the certificate serial number:
342
343 openssl x509 -in cert.pem -noout -serial
344
345Display the certificate MD5 fingerprint:
346
347 openssl x509 -in cert.pem -noout -fingerprint
348
349Display the certificate SHA1 fingerprint:
350
351 openssl x509 -sha1 -in cert.pem -noout -fingerprint
352
353Convert a certificate from PEM to DER format:
354
355 openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER
356
357Convert a certificate to a certificate request:
358
359 openssl x509 -x509toreq -in cert.pem -out req.pem -signkey key.pem
360
361Convert a certificate request into a self signed certificate using
362extensions for a CA:
363
364 openssl x509 -req -in careq.pem -config openssl.cnf -extensions v3_ca \
365 -signkey key.pem -out cacert.pem
366
367Sign a certificate request using the CA certificate above and add user
368certificate extensions:
369
370 openssl x509 -req -in req.pem -config openssl.cnf -extensions v3_usr \
371 -CA cacert.pem -CAkey key.pem -CAcreateserial
372
373
374Set a certificate to be trusted for SSL client use and change set its alias to
375"Steve's Class 1 CA"
376
377 openssl x509 -in cert.pem -addtrust sslclient \
378 -alias "Steve's Class 1 CA" -out trust.pem
379
380=head1 NOTES
381
382The PEM format uses the header and footer lines:
383
384 -----BEGIN CERTIFICATE----
385 -----END CERTIFICATE----
386
387it will also handle files containing:
388
389 -----BEGIN X509 CERTIFICATE----
390 -----END X509 CERTIFICATE----
391
392Trusted certificates have the lines
393
394 -----BEGIN TRUSTED CERTIFICATE----
395 -----END TRUSTED CERTIFICATE----
396
397The B<-fingerprint> option takes the digest of the DER encoded certificate.
398This is commonly called a "fingerprint". Because of the nature of message
399digests the fingerprint of a certificate is unique to that certificate and
400two certificates with the same fingerprint can be considered to be the same.
401
402The Netscape fingerprint uses MD5 whereas MSIE uses SHA1.
403
404=head1 CERTIFICATE EXTENSIONS
405
406The B<-purpose> option checks the certificate extensions and determines
407what the certificate can be used for. The actual checks done are rather
408complex and include various hacks and workarounds to handle broken
409certificates and software.
410
411The same code is used when verifying untrusted certificates in chains
412so this section is useful if a chain is rejected by the verify code.
413
414The basicConstraints extension CA flag is used to determine whether the
415certificate can be used as a CA. If the CA flag is true then it is a CA,
416if the CA flag is false then it is not a CA. B<All> CAs should have the
417CA flag set to true.
418
419If the basicConstraints extension is absent then the certificate is
420considered to be a "possible CA" other extensions are checked according
421to the intended use of the certificate. A warning is given in this case
422because the certificate should really not be regarded as a CA: however
423it is allowed to be a CA to work around some broken software.
424
425If the certificate is a V1 certificate (and thus has no extensions) and
426it is self signed it is also assumed to be a CA but a warning is again
427given: this is to work around the problem of Verisign roots which are V1
428self signed certificates.
429
430If the keyUsage extension is present then additional restraints are
431made on the uses of the certificate. A CA certificate B<must> have the
432keyCertSign bit set if the keyUsage extension is present.
433
434The extended key usage extension places additional restrictions on the
435certificate uses. If this extension is present (whether critical or not)
436the key can only be used for the purposes specified.
437
438A complete description of each test is given below. The comments about
439basicConstraints and keyUsage and V1 certificates above apply to B<all>
440CA certificates.
441
442
443=over 4
444
445=item B<SSL Client>
446
447The extended key usage extension must be absent or include the "web client
448authentication" OID. keyUsage must be absent or it must have the
449digitalSignature bit set. Netscape certificate type must be absent or it must
450have the SSL client bit set.
451
452=item B<SSL Client CA>
453
454The extended key usage extension must be absent or include the "web client
455authentication" OID. Netscape certificate type must be absent or it must have
456the SSL CA bit set: this is used as a work around if the basicConstraints
457extension is absent.
458
459=item B<SSL Server>
460
461The extended key usage extension must be absent or include the "web server
462authentication" and/or one of the SGC OIDs. keyUsage must be absent or it
463must have the digitalSignature, the keyEncipherment set or both bits set.
464Netscape certificate type must be absent or have the SSL server bit set.
465
466=item B<SSL Server CA>
467
468The extended key usage extension must be absent or include the "web server
469authentication" and/or one of the SGC OIDs. Netscape certificate type must
470be absent or the SSL CA bit must be set: this is used as a work around if the
471basicConstraints extension is absent.
472
473=item B<Netscape SSL Server>
474
475For Netscape SSL clients to connect to an SSL server it must have the
476keyEncipherment bit set if the keyUsage extension is present. This isn't
477always valid because some cipher suites use the key for digital signing.
478Otherwise it is the same as a normal SSL server.
479
480=item B<Common S/MIME Client Tests>
481
482The extended key usage extension must be absent or include the "email
483protection" OID. Netscape certificate type must be absent or should have the
484S/MIME bit set. If the S/MIME bit is not set in netscape certificate type
485then the SSL client bit is tolerated as an alternative but a warning is shown:
486this is because some Verisign certificates don't set the S/MIME bit.
487
488=item B<S/MIME Signing>
489
490In addition to the common S/MIME client tests the digitalSignature bit must
491be set if the keyUsage extension is present.
492
493=item B<S/MIME Encryption>
494
495In addition to the common S/MIME tests the keyEncipherment bit must be set
496if the keyUsage extension is present.
497
498=item B<S/MIME CA>
499
500The extended key usage extension must be absent or include the "email
501protection" OID. Netscape certificate type must be absent or must have the
502S/MIME CA bit set: this is used as a work around if the basicConstraints
503extension is absent.
504
505=item B<CRL Signing>
506
507The keyUsage extension must be absent or it must have the CRL signing bit
508set.
509
510=item B<CRL Signing CA>
511
512The normal CA tests apply. Except in this case the basicConstraints extension
513must be present.
514
515=back
516
517=head1 BUGS
518
519The way DNs are printed is in a "historical SSLeay" format which doesn't
520follow any published standard. It should follow some standard like RFC2253
521or RFC1779 with options to make the stuff more readable.
522
523Extensions in certificates are not transferred to certificate requests and
524vice versa.
525
526It is possible to produce invalid certificates or requests by specifying the
527wrong private key or using inconsistent options in some cases: these should
528be checked.
529
530There should be options to explicitly set such things as start and end
531dates rather than an offset from the current time.
532
533The code to implement the verify behaviour described in the B<TRUST SETTINGS>
534is currently being developed. It thus describes the intended behavior rather
535than the current behaviour. It is hoped that it will represent reality in
536OpenSSL 0.9.5 and later.
537
538=head1 SEE ALSO
539
540L<req(1)|req(1)>, L<ca(1)|ca(1)>, L<genrsa(1)|genrsa(1)>,
541L<gendsa(1)|gendsa(1)>, L<verify(1)|verify(1)>
542
543=cut
diff --git a/src/lib/libssl/src/doc/c-indentation.el b/src/lib/libssl/src/doc/c-indentation.el
index 9a4a0be598..9111450915 100644
--- a/src/lib/libssl/src/doc/c-indentation.el
+++ b/src/lib/libssl/src/doc/c-indentation.el
@@ -26,11 +26,20 @@
26 (c-hanging-braces-alist) 26 (c-hanging-braces-alist)
27 (c-offsets-alist . ((defun-open . +) 27 (c-offsets-alist . ((defun-open . +)
28 (defun-block-intro . 0) 28 (defun-block-intro . 0)
29 (class-open . +)
30 (class-close . +)
29 (block-open . 0) 31 (block-open . 0)
32 (block-close . 0)
30 (substatement-open . +) 33 (substatement-open . +)
34 (statement . 0)
31 (statement-block-intro . 0) 35 (statement-block-intro . 0)
32 (statement-case-open . +) 36 (statement-case-open . +)
33 (statement-case-intro . +) 37 (statement-case-intro . +)
34 (case-label . -) 38 (case-label . -)
35 (label . -) 39 (label . -)
36 (arglist-cont-nonempty . +))))) 40 (arglist-cont-nonempty . +)
41 (topmost-intro . -)
42 (brace-list-close . +)
43 (brace-list-intro . +)
44 ))))
45
diff --git a/src/lib/libssl/src/doc/crypto.pod b/src/lib/libssl/src/doc/crypto.pod
index 9c8a143b09..e69de29bb2 100644
--- a/src/lib/libssl/src/doc/crypto.pod
+++ b/src/lib/libssl/src/doc/crypto.pod
@@ -1,27 +0,0 @@
1
2=pod
3
4=head1 NAME
5
6Crypto - OpenSSL Cryptography library
7
8=head1 SYNOPSIS
9
10=head1 DESCRIPTION
11
12The OpenSSL B<crypto> library implements various cryptography standards
13related to the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security
14(TLS v1) protocols. It provides a rich API which is documented here.
15
16...
17
18=head1 SEE ALSO
19
20openssl(1), ssl(3)
21
22=head1 HISTORY
23
24The crypto(3) document appeared in OpenSSL 0.9.2
25
26=cut
27
diff --git a/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod b/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod
new file mode 100644
index 0000000000..c94d8c610d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_CTX_new.pod
@@ -0,0 +1,53 @@
1=pod
2
3=head1 NAME
4
5BN_CTX_new, BN_CTX_init, BN_CTX_free - allocate and free BN_CTX structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BN_CTX *BN_CTX_new(void);
12
13 void BN_CTX_init(BN_CTX *c);
14
15 void BN_CTX_free(BN_CTX *c);
16
17=head1 DESCRIPTION
18
19A B<BN_CTX> is a structure that holds B<BIGNUM> temporary variables used by
20library functions. Since dynamic memory allocation to create B<BIGNUM>s
21is rather expensive when used in conjunction with repeated subroutine
22calls, the B<BN_CTX> structure is used.
23
24BN_CTX_new() allocates and initializes a B<BN_CTX>
25structure. BN_CTX_init() initializes an existing uninitialized
26B<BN_CTX>.
27
28BN_CTX_free() frees the components of the B<BN_CTX>, and if it was
29created by BN_CTX_new(), also the structure itself.
30If L<BN_CTX_start(3)|BN_CTX_start(3)> has been used on the B<BN_CTX>,
31L<BN_CTX_end(3)|BN_CTX_end(3)> must be called before the B<BN_CTX>
32may be freed by BN_CTX_free().
33
34
35=head1 RETURN VALUES
36
37BN_CTX_new() returns a pointer to the B<BN_CTX>. If the allocation fails,
38it returns B<NULL> and sets an error code that can be obtained by
39L<ERR_get_error(3)|ERR_get_error(3)>.
40
41BN_CTX_init() and BN_CTX_free() have no return values.
42
43=head1 SEE ALSO
44
45L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>,
46L<BN_CTX_start(3)|BN_CTX_start(3)>
47
48=head1 HISTORY
49
50BN_CTX_new() and BN_CTX_free() are available in all versions on SSLeay
51and OpenSSL. BN_CTX_init() was added in SSLeay 0.9.1b.
52
53=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_CTX_start.pod b/src/lib/libssl/src/doc/crypto/BN_CTX_start.pod
new file mode 100644
index 0000000000..c30552b122
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_CTX_start.pod
@@ -0,0 +1,51 @@
1=pod
2
3=head1 NAME
4
5BN_CTX_start, BN_CTX_get, BN_CTX_end - use temporary BIGNUM variables
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 void BN_CTX_start(BN_CTX *ctx);
12
13 BIGNUM *BN_CTX_get(BN_CTX *ctx);
14
15 void BN_CTX_end(BN_CTX *ctx);
16
17=head1 DESCRIPTION
18
19These functions are used to obtain temporary B<BIGNUM> variables from
20a B<BN_CTX> in order to save the overhead of repeatedly creating and
21freeing B<BIGNUM>s in functions that are called from inside a loop.
22
23A function must call BN_CTX_start() first. Then, BN_CTX_get() may be
24called repeatedly to obtain temporary B<BIGNUM>s. All BN_CTX_get()
25calls must be made before calling any other functions that use the
26B<ctx> as an argument.
27
28Finally, BN_CTX_end() must be called before returning from the function.
29When BN_CTX_end() is called, the B<BIGNUM> pointers obtained from
30BN_CTX_get() become invalid.
31
32=head1 RETURN VALUES
33
34BN_CTX_start() and BN_CTX_end() return no values.
35
36BN_CTX_get() returns a pointer to the B<BIGNUM>, or B<NULL> on error.
37Once BN_CTX_get() has failed, the subsequent calls will return B<NULL>
38as well, so it is sufficient to check the return value of the last
39BN_CTX_get() call. In case of an error, an error code is set, which
40can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
41
42
43=head1 SEE ALSO
44
45L<BN_CTX_new(3)|BN_CTX_new(3)>
46
47=head1 HISTORY
48
49BN_CTX_start(), BN_CTX_get() and BN_CTX_end() were added in OpenSSL 0.9.5.
50
51=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_add.pod b/src/lib/libssl/src/doc/crypto/BN_add.pod
new file mode 100644
index 0000000000..0541d45643
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_add.pod
@@ -0,0 +1,99 @@
1=pod
2
3=head1 NAME
4
5BN_add, BN_sub, BN_mul, BN_div, BN_sqr, BN_mod, BN_mod_mul, BN_exp,
6BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs
7
8=head1 SYNOPSIS
9
10 #include <openssl/bn.h>
11
12 int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
13
14 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
15
16 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
17
18 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
19 BN_CTX *ctx);
20
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
25 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
26 BN_CTX *ctx);
27
28 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
29
30 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
31 const BIGNUM *m, BN_CTX *ctx);
32
33 int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
34
35=head1 DESCRIPTION
36
37BN_add() adds B<a> and B<b> and places the result in B<r> (C<r=a+b>).
38B<r> may be the same B<BIGNUM> as B<a> or B<b>.
39
40BN_sub() subtracts B<b> from B<a> and places the result in B<r> (C<r=a-b>).
41
42BN_mul() multiplies B<a> and B<b> and places the result in B<r> (C<r=a*b>).
43B<r> may be the same B<BIGNUM> as B<a> or B<b>.
44For multiplication by powers of 2, use L<BN_lshift(3)|BN_lshift(3)>.
45
46BN_div() divides B<a> by B<d> and places the result in B<dv> and the
47remainder in B<rem> (C<dv=a/d, rem=a%d>). Either of B<dv> and B<rem> may
48be NULL, in which case the respective value is not returned.
49For division by powers of 2, use BN_rshift(3).
50
51BN_sqr() takes the square of B<a> and places the result in B<r>
52(C<r=a^2>). B<r> and B<a> may be the same B<BIGNUM>.
53This function is faster than BN_mul(r,a,a).
54
55BN_mod() find the remainder of B<a> divided by B<m> and places it in
56B<rem> (C<rem=a%m>).
57
58BN_mod_mul() multiplies B<a> by B<b> and finds the remainder when
59divided by B<m> (C<r=(a*b)%m>). B<r> may be the same B<BIGNUM> as B<a>
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
64BN_exp() raises B<a> to the B<p>-th power and places the result in B<r>
65(C<r=a^p>). This function is faster than repeated applications of
66BN_mul().
67
68BN_mod_exp() computes B<a> to the B<p>-th power modulo B<m> (C<r=a^p %
69m>). This function uses less time and space than BN_exp().
70
71BN_gcd() computes the greatest common divisor of B<a> and B<b> and
72places the result in B<r>. B<r> may be the same B<BIGNUM> as B<a> or
73B<b>.
74
75For all functions, B<ctx> is a previously allocated B<BN_CTX> used for
76temporary variables; see L<BN_CTX_new(3)|BN_CTX_new(3)>.
77
78Unless noted otherwise, the result B<BIGNUM> must be different from
79the arguments.
80
81=head1 RETURN VALUES
82
83For all functions, 1 is returned for success, 0 on error. The return
84value should always be checked (e.g., C<if (!BN_add(r,a,b)) goto err;>).
85The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
86
87=head1 SEE ALSO
88
89L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>,
90L<BN_add_word(3)|BN_add_word(3)>, L<BN_set_bit(3)|BN_set_bit(3)>
91
92=head1 HISTORY
93
94BN_add(), BN_sub(), BN_div(), BN_sqr(), BN_mod(), BN_mod_mul(),
95BN_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
970.9.1b. BN_exp() appeared in SSLeay 0.9.0.
98
99=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_add_word.pod b/src/lib/libssl/src/doc/crypto/BN_add_word.pod
new file mode 100644
index 0000000000..66bedfb924
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_add_word.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5BN_add_word, BN_sub_word, BN_mul_word, BN_div_word, BN_mod_word - arithmetic
6functions on BIGNUMs with integers
7
8=head1 SYNOPSIS
9
10 #include <openssl/bn.h>
11
12 int BN_add_word(BIGNUM *a, BN_ULONG w);
13
14 int BN_sub_word(BIGNUM *a, BN_ULONG w);
15
16 int BN_mul_word(BIGNUM *a, BN_ULONG w);
17
18 BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
19
20 BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
21
22=head1 DESCRIPTION
23
24These functions perform arithmetic operations on BIGNUMs with unsigned
25integers. They are much more efficient than the normal BIGNUM
26arithmetic operations.
27
28BN_add_word() adds B<w> to B<a> (C<a+=w>).
29
30BN_sub_word() subtracts B<w> from B<a> (C<a-=w>).
31
32BN_mul_word() multiplies B<a> and B<w> (C<a*=b>).
33
34BN_div_word() divides B<a> by B<w> (C<a/=w>) and returns the remainder.
35
36BN_mod_word() returns the remainder of B<a> divided by B<w> (C<a%m>).
37
38For BN_div_word() and BN_mod_word(), B<w> must not be 0.
39
40=head1 RETURN VALUES
41
42BN_add_word(), BN_sub_word() and BN_mul_word() return 1 for success, 0
43on error. The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
44
45BN_mod_word() and BN_div_word() return B<a>%B<w>.
46
47=head1 SEE ALSO
48
49L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>
50
51=head1 HISTORY
52
53BN_add_word() and BN_mod_word() are available in all versions of
54SSLeay and OpenSSL. BN_div_word() was added in SSLeay 0.8, and
55BN_sub_word() and BN_mul_word() in SSLeay 0.9.0.
56
57=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
new file mode 100644
index 0000000000..05f9e628cc
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
@@ -0,0 +1,95 @@
1=pod
2
3=head1 NAME
4
5BN_bn2bin, BN_bin2bn, BN_bn2hex, BN_bn2dec, BN_hex2bn, BN_dec2bn,
6BN_print, BN_print_fp, BN_bn2mpi, BN_mpi2bn - format conversions
7
8=head1 SYNOPSIS
9
10 #include <openssl/bn.h>
11
12 int BN_bn2bin(const BIGNUM *a, unsigned char *to);
13 BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
14
15 char *BN_bn2hex(const BIGNUM *a);
16 char *BN_bn2dec(const BIGNUM *a);
17 int BN_hex2bn(BIGNUM **a, const char *str);
18 int BN_dec2bn(BIGNUM **a, const char *str);
19
20 int BN_print(BIO *fp, const BIGNUM *a);
21 int BN_print_fp(FILE *fp, const BIGNUM *a);
22
23 int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
24 BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret);
25
26=head1 DESCRIPTION
27
28BN_bn2bin() converts the absolute value of B<a> into big-endian form
29and stores it at B<to>. B<to> must point to BN_num_bytes(B<a>) bytes of
30memory.
31
32BN_bin2bn() converts the positive integer in big-endian form of length
33B<len> at B<s> into a B<BIGNUM> and places it in B<ret>. If B<ret> is
34NULL, a new B<BIGNUM> is created.
35
36BN_bn2hex() and BN_bn2dec() return printable strings containing the
37hexadecimal and decimal encoding of B<a> respectively. For negative
38numbers, the string is prefaced with a leading '-'. The string must be
39Free()d later.
40
41BN_hex2bn() converts the string B<str> containing a hexadecimal number
42to a B<BIGNUM> and stores it in **B<bn>. If *B<bn> is NULL, a new
43B<BIGNUM> is created. If B<bn> is NULL, it only computes the number's
44length in hexadecimal digits. If the string starts with '-', the
45number is negative. BN_dec2bn() is the same using the decimal system.
46
47BN_print() and BN_print_fp() write the hexadecimal encoding of B<a>,
48with a leading '-' for negative numbers, to the B<BIO> or B<FILE>
49B<fp>.
50
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
53big-endian number, and the number itself in big-endian format, where
54the most significant bit signals a negative number (the representation
55of numbers with the MSB set is prefixed with null byte).
56
57BN_bn2mpi() stores the representation of B<a> at B<to>, where B<to>
58must be large enough to hold the result. The size can be determined by
59calling BN_bn2mpi(B<a>, NULL).
60
61BN_mpi2bn() converts the B<len> bytes long representation at B<s> to
62a B<BIGNUM> and stores it at B<ret>, or in a newly allocated B<BIGNUM>
63if B<ret> is NULL.
64
65=head1 RETURN VALUES
66
67BN_bn2bin() returns the length of the big-endian number placed at B<to>.
68BN_bin2bn() returns the B<BIGNUM>, NULL on error.
69
70BN_bn2hex() and BN_bn2dec() return a null-terminated string, or NULL
71on error. BN_hex2bn() and BN_dec2bn() return the number's length in
72hexadecimal or decimal digits, and 0 on error.
73
74BN_print_fp() and BN_print() return 1 on success, 0 on write errors.
75
76BN_bn2mpi() returns the length of the representation. BN_mpi2bn()
77returns the B<BIGNUM>, and NULL on error.
78
79The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
80
81=head1 SEE ALSO
82
83L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_zero(3)|BN_zero(3)>,
84L<ASN1_INTEGER_to_BN(3)|ASN1_INTEGER_to_BN(3)>,
85L<BN_num_bytes(3)|BN_num_bytes(3)>
86
87=head1 HISTORY
88
89BN_bn2bin(), BN_bin2bn(), BN_print_fp() and BN_print() are available
90in all versions of SSLeay and OpenSSL.
91
92BN_bn2hex(), BN_bn2dec(), BN_hex2bn(), BN_dec2bn(), BN_bn2mpi() and
93BN_mpi2bn() were added in SSLeay 0.9.0.
94
95=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_cmp.pod b/src/lib/libssl/src/doc/crypto/BN_cmp.pod
new file mode 100644
index 0000000000..23e9ed0b4f
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_cmp.pod
@@ -0,0 +1,48 @@
1=pod
2
3=head1 NAME
4
5BN_cmp, BN_ucmp, BN_is_zero, BN_is_one, BN_is_word, BN_is_odd - BIGNUM comparison and test functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 int BN_cmp(BIGNUM *a, BIGNUM *b);
12 int BN_ucmp(BIGNUM *a, BIGNUM *b);
13
14 int BN_is_zero(BIGNUM *a);
15 int BN_is_one(BIGNUM *a);
16 int BN_is_word(BIGNUM *a, BN_ULONG w);
17 int BN_is_odd(BIGNUM *a);
18
19=head1 DESCRIPTION
20
21BN_cmp() compares the numbers B<a> and B<b>. BN_ucmp() compares their
22absolute values.
23
24BN_is_zero(), BN_is_one() and BN_is_word() test if B<a> equals 0, 1,
25or B<w> respectively. BN_is_odd() tests if a is odd.
26
27BN_is_zero(), BN_is_one(), BN_is_word() and BN_is_odd() are macros.
28
29=head1 RETURN VALUES
30
31BN_cmp() returns -1 if B<a> E<lt> B<b>, 0 if B<a> == B<b> and 1 if
32B<a> E<gt> B<b>. BN_ucmp() is the same using the absolute values
33of B<a> and B<b>.
34
35BN_is_zero(), BN_is_one() BN_is_word() and BN_is_odd() return 1 if
36the condition is true, 0 otherwise.
37
38=head1 SEE ALSO
39
40L<bn(3)|bn(3)>
41
42=head1 HISTORY
43
44BN_cmp(), BN_ucmp(), BN_is_zero(), BN_is_one() and BN_is_word() are
45available in all versions of SSLeay and OpenSSL.
46BN_is_odd() was added in SSLeay 0.8.
47
48=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_copy.pod b/src/lib/libssl/src/doc/crypto/BN_copy.pod
new file mode 100644
index 0000000000..8ad25e7834
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_copy.pod
@@ -0,0 +1,34 @@
1=pod
2
3=head1 NAME
4
5BN_copy, BN_dup - copy BIGNUMs
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_copy(BIGNUM *to, const BIGNUM *from);
12
13 BIGNUM *BN_dup(const BIGNUM *from);
14
15=head1 DESCRIPTION
16
17BN_copy() copies B<from> to B<to>. BN_dup() creates a new B<BIGNUM>
18containing the value B<from>.
19
20=head1 RETURN VALUES
21
22BN_copy() returns B<to> on success, NULL on error. BN_dup() returns
23the new B<BIGNUM>, and NULL on error. The error codes can be obtained
24by L<ERR_get_error(3)|ERR_get_error(3)>.
25
26=head1 SEE ALSO
27
28L<bn(3)|bn(3)>, L<err(3)|err(3)>
29
30=head1 HISTORY
31
32BN_copy() and BN_dup() are available in all versions of SSLeay and OpenSSL.
33
34=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod b/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod
new file mode 100644
index 0000000000..638f6514ee
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_generate_prime.pod
@@ -0,0 +1,102 @@
1=pod
2
3=head1 NAME
4
5BN_generate_prime, BN_is_prime, BN_is_prime_fasttest - generate primes and test for primality
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_generate_prime(BIGNUM *ret, int num, int safe, BIGNUM *add,
12 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
13
14 int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int,
15 void *), BN_CTX *ctx, void *cb_arg);
16
17 int BN_is_prime_fasttest(const BIGNUM *a, int checks,
18 void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg,
19 int do_trial_division);
20
21=head1 DESCRIPTION
22
23BN_generate_prime() generates a pseudo-random prime number of B<num>
24bits.
25If B<ret> is not B<NULL>, it will be used to store the number.
26
27If B<callback> is not B<NULL>, it is called as follows:
28
29=over 4
30
31=item *
32
33B<callback(0, i, cb_arg)> is called after generating the i-th
34potential prime number.
35
36=item *
37
38While the number is being tested for primality, B<callback(1, j,
39cb_arg)> is called as described below.
40
41=item *
42
43When a prime has been found, B<callback(2, i, cb_arg)> is called.
44
45=back
46
47The prime may have to fulfill additional requirements for use in
48Diffie-Hellman key exchange:
49
50If B<add> is not B<NULL>, the prime will fulfill the condition p % B<add>
51== B<rem> (p % B<add> == 1 if B<rem> == B<NULL>) in order to suit a given
52generator.
53
54If B<safe> is true, it will be a safe prime (i.e. a prime p so
55that (p-1)/2 is also prime).
56
57The PRNG must be seeded prior to calling BN_generate_prime().
58The prime number generation has a negligible error probability.
59
60BN_is_prime() and BN_is_prime_fasttest() test if the number B<a> is
61prime. The following tests are performed until one of them shows that
62B<a> is composite; if B<a> passes all these tests, it is considered
63prime.
64
65BN_is_prime_fasttest(), when called with B<do_trial_division == 1>,
66first attempts trial division by a number of small primes;
67if no divisors are found by this test and B<callback> is not B<NULL>,
68B<callback(1, -1, cb_arg)> is called.
69If B<do_trial_division == 0>, this test is skipped.
70
71Both BN_is_prime() and BN_is_prime_fasttest() perform a Miller-Rabin
72probabilistic primality test with B<checks> iterations. If
73B<checks == BN_prime_check>, a number of iterations is used that
74yields a false positive rate of at most 2^-80 for random input.
75
76If B<callback> is not B<NULL>, B<callback(1, j, cb_arg)> is called
77after the j-th iteration (j = 0, 1, ...). B<ctx> is a
78pre-allocated B<BN_CTX> (to save the overhead of allocating and
79freeing the structure in a loop), or B<NULL>.
80
81=head1 RETURN VALUES
82
83BN_generate_prime() returns the prime number on success, B<NULL> otherwise.
84
85BN_is_prime() returns 0 if the number is composite, 1 if it is
86prime with an error probability of less than 0.25^B<checks>, and
87-1 on error.
88
89The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
90
91=head1 SEE ALSO
92
93L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>
94
95=head1 HISTORY
96
97The B<cb_arg> arguments to BN_generate_prime() and to BN_is_prime()
98were added in SSLeay 0.9.0. The B<ret> argument to BN_generate_prime()
99was added in SSLeay 0.9.1.
100BN_is_prime_fasttest() was added in OpenSSL 0.9.5.
101
102=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod b/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod
new file mode 100644
index 0000000000..49e62daf9f
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_inverse.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5BN_mod_inverse - compute inverse modulo n
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n,
12 BN_CTX *ctx);
13
14=head1 DESCRIPTION
15
16BN_mod_inverse() computes the inverse of B<a> modulo B<n>
17places the result in B<r> (C<(a*r)%n==1>). If B<r> is NULL,
18a new B<BIGNUM> is created.
19
20B<ctx> is a previously allocated B<BN_CTX> used for temporary
21variables. B<r> may be the same B<BIGNUM> as B<a> or B<n>.
22
23=head1 RETURN VALUES
24
25BN_mod_inverse() returns the B<BIGNUM> containing the inverse, and
26NULL on error. The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
27
28=head1 SEE ALSO
29
30L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>
31
32=head1 HISTORY
33
34BN_mod_inverse() is available in all versions of SSLeay and OpenSSL.
35
36=cut
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
new file mode 100644
index 0000000000..0f0c1375af
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
@@ -0,0 +1,95 @@
1=pod
2
3=head1 NAME
4
5BN_mod_mul_montgomery, BN_MONT_CTX_new, BN_MONT_CTX_init,
6BN_MONT_CTX_free, BN_MONT_CTX_set, BN_MONT_CTX_copy,
7BN_from_montgomery, BN_to_montgomery - Montgomery multiplication
8
9=head1 SYNOPSIS
10
11 #include <openssl/bn.h>
12
13 BN_MONT_CTX *BN_MONT_CTX_new(void);
14 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
15 void BN_MONT_CTX_free(BN_MONT_CTX *mont);
16
17 int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
18 BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
19
20 int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
21 BN_MONT_CTX *mont, BN_CTX *ctx);
22
23 int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
24 BN_CTX *ctx);
25
26 int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
27 BN_CTX *ctx);
28
29=head1 DESCRIPTION
30
31These functions implement Montgomery multiplication. They are used
32automatically when L<BN_mod_exp(3)|BN_mod_exp(3)> is called with suitable input,
33but they may be useful when several operations are to be performed
34using the same modulus.
35
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>.
38
39BN_MONT_CTX_set() sets up the B<mont> structure from the modulus B<m>
40by precomputing its inverse and a value R.
41
42BN_MONT_CTX_copy() copies the B<N_MONT_CTX> B<from> to B<to>.
43
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.
46
47BN_mod_mul_montgomery() computes Mont(B<a>,B<b>):=B<a>*B<b>*R^-1 and places
48the result in B<r>.
49
50BN_from_montgomery() performs the Montgomery reduction B<r> = B<a>*R^-1.
51
52BN_to_montgomery() computes Mont(B<a>,R^2).
53
54For all functions, B<ctx> is a previously allocated B<BN_CTX> used for
55temporary variables.
56
57The B<BN_MONT_CTX> structure is defined as follows:
58
59 typedef struct bn_mont_ctx_st
60 {
61 int ri; /* number of bits in R */
62 BIGNUM RR; /* R^2 (used to convert to Montgomery form) */
63 BIGNUM N; /* The modulus */
64 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
65 * (Ni is only stored for bignum algorithm) */
66 BN_ULONG n0; /* least significant word of Ni */
67 int flags;
68 } BN_MONT_CTX;
69
70BN_to_montgomery() is a macro.
71
72=head1 RETURN VALUES
73
74BN_MONT_CTX_new() returns the newly allocated B<BN_MONT_CTX>, and NULL
75on error.
76
77BN_MONT_CTX_init() and BN_MONT_CTX_free() have no return values.
78
79For 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)>.
81
82=head1 SEE ALSO
83
84L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>,
85L<BN_CTX_new(3)|BN_CTX_new(3)>
86
87=head1 HISTORY
88
89BN_MONT_CTX_new(), BN_MONT_CTX_free(), BN_MONT_CTX_set(),
90BN_mod_mul_montgomery(), BN_from_montgomery() and BN_to_montgomery()
91are available in all versions of SSLeay and OpenSSL.
92
93BN_MONT_CTX_init() and BN_MONT_CTX_copy() were added in SSLeay 0.9.1b.
94
95=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod b/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod
new file mode 100644
index 0000000000..32432ce4e6
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_mul_reciprocal.pod
@@ -0,0 +1,81 @@
1=pod
2
3=head1 NAME
4
5BN_mod_mul_reciprocal, BN_RECP_CTX_new, BN_RECP_CTX_init,
6BN_RECP_CTX_free, BN_RECP_CTX_set - modular multiplication using
7reciprocal
8
9=head1 SYNOPSIS
10
11 #include <openssl/bn.h>
12
13 BN_RECP_CTX *BN_RECP_CTX_new(void);
14 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
15 void BN_RECP_CTX_free(BN_RECP_CTX *recp);
16
17 int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
18
19 int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *a, BN_RECP_CTX *recp,
20 BN_CTX *ctx);
21
22 int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
23 BN_RECP_CTX *recp, BN_CTX *ctx);
24
25=head1 DESCRIPTION
26
27BN_mod_mul_reciprocal() can be used to perform an efficient
28L<BN_mod_mul(3)|BN_mod_mul(3)> operation when the operation will be performed
29repeatedly with the same modulus. It computes B<r>=(B<a>*B<b>)%B<m>
30using B<recp>=1/B<m>, which is set as described below. B<ctx> is a
31previously allocated B<BN_CTX> used for temporary variables.
32
33BN_RECP_CTX_new() allocates and initializes a B<BN_RECP> structure.
34BN_RECP_CTX_init() initializes an existing uninitialized B<BN_RECP>.
35
36BN_RECP_CTX_free() frees the components of the B<BN_RECP>, and, if it
37was created by BN_RECP_CTX_new(), also the structure itself.
38
39BN_RECP_CTX_set() stores B<m> in B<recp> and sets it up for computing
401/B<m> and shifting it left by BN_num_bits(B<m>)+1 to make it an
41integer. The result and the number of bits it was shifted left will
42later be stored in B<recp>.
43
44BN_div_recp() divides B<a> by B<m> using B<recp>. It places the quotient
45in B<dv> and the remainder in B<rem>.
46
47The B<BN_RECP_CTX> structure is defined as follows:
48
49 typedef struct bn_recp_ctx_st
50 {
51 BIGNUM N; /* the divisor */
52 BIGNUM Nr; /* the reciprocal */
53 int num_bits;
54 int shift;
55 int flags;
56 } BN_RECP_CTX;
57
58It cannot be shared between threads.
59
60=head1 RETURN VALUES
61
62BN_RECP_CTX_new() returns the newly allocated B<BN_RECP_CTX>, and NULL
63on error.
64
65BN_RECP_CTX_init() and BN_RECP_CTX_free() have no return values.
66
67For the other functions, 1 is returned for success, 0 on error.
68The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
69
70=head1 SEE ALSO
71
72L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<BN_add(3)|BN_add(3)>,
73L<BN_CTX_new(3)|BN_CTX_new(3)>
74
75=head1 HISTORY
76
77B<BN_RECP_CTX> was added in SSLeay 0.9.0. Before that, the function
78BN_reciprocal() was used instead, and the BN_mod_mul_reciprocal()
79arguments were different.
80
81=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_new.pod b/src/lib/libssl/src/doc/crypto/BN_new.pod
new file mode 100644
index 0000000000..c1394ff2a3
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_new.pod
@@ -0,0 +1,53 @@
1=pod
2
3=head1 NAME
4
5BN_new, BN_init, BN_clear, BN_free, BN_clear_free - allocate and free BIGNUMs
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_new(void);
12
13 void BN_init(BIGNUM *);
14
15 void BN_clear(BIGNUM *a);
16
17 void BN_free(BIGNUM *a);
18
19 void BN_clear_free(BIGNUM *a);
20
21=head1 DESCRIPTION
22
23BN_new() allocated and initializes a B<BIGNUM> structure. BN_init()
24initializes an existing uninitialized B<BIGNUM>.
25
26BN_clear() is used to destroy sensitive data such as keys when they
27are no longer needed. It erases the memory used by B<a> and sets it
28to the value 0.
29
30BN_free() frees the components of the B<BIGNUM>, and if it was created
31by BN_new(), also the structure itself. BN_clear_free() additionally
32overwrites the data before the memory is returned to the system.
33
34=head1 RETURN VALUES
35
36BN_new() returns a pointer to the B<BIGNUM>. If the allocation fails,
37it returns B<NULL> and sets an error code that can be obtained
38by L<ERR_get_error(3)|ERR_get_error(3)>.
39
40BN_init(), BN_clear(), BN_free() and BN_clear_free() have no return
41values.
42
43=head1 SEE ALSO
44
45L<bn(3)|bn(3)>, L<err(3)|err(3)>
46
47=head1 HISTORY
48
49BN_new(), BN_clear(), BN_free() and BN_clear_free() are available in
50all versions on SSLeay and OpenSSL. BN_init() was added in SSLeay
510.9.1b.
52
53=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_num_bytes.pod b/src/lib/libssl/src/doc/crypto/BN_num_bytes.pod
new file mode 100644
index 0000000000..61589fb9ac
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_num_bytes.pod
@@ -0,0 +1,37 @@
1=pod
2
3=head1 NAME
4
5BN_num_bits, BN_num_bytes, BN_num_bits_word - get BIGNUM size
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 int BN_num_bytes(const BIGNUM *a);
12
13 int BN_num_bits(const BIGNUM *a);
14
15 int BN_num_bits_word(BN_ULONG w);
16
17=head1 DESCRIPTION
18
19These functions return the size of a B<BIGNUM> in bytes or bits,
20and the size of an unsigned integer in bits.
21
22BN_num_bytes() is a macro.
23
24=head1 RETURN VALUES
25
26The size.
27
28=head1 SEE ALSO
29
30L<bn(3)|bn(3)>
31
32=head1 HISTORY
33
34BN_num_bytes(), BN_num_bits() and BN_num_bits_word() are available in
35all versions of SSLeay and OpenSSL.
36
37=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_rand.pod b/src/lib/libssl/src/doc/crypto/BN_rand.pod
new file mode 100644
index 0000000000..33363c981f
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_rand.pod
@@ -0,0 +1,45 @@
1=pod
2
3=head1 NAME
4
5BN_rand, BN_pseudo_rand - generate pseudo-random number
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
12
13 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
14
15=head1 DESCRIPTION
16
17BN_rand() generates a cryptographically strong pseudo-random number of
18B<bits> bits in length and stores it in B<rnd>. If B<top> is true, the
19two most significant bits of the number will be set to 1, so that the
20product of two such random numbers will always have 2*B<bits> length.
21If B<bottom> is true, the number will be odd.
22
23BN_pseudo_rand() does the same, but pseudo-random numbers generated by
24this function are not necessarily unpredictable. They can be used for
25non-cryptographic purposes and for certain purposes in cryptographic
26protocols, but usually not for key generation etc.
27
28The PRNG must be seeded prior to calling BN_rand().
29
30=head1 RETURN VALUES
31
32BN_rand() and BN_pseudo_rand() return 1 on success, 0 on error.
33The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
34
35=head1 SEE ALSO
36
37L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
38L<RAND_add(3)|RAND_add(3)>, L<RAND_bytes(3)|RAND_bytes(3)>
39
40=head1 HISTORY
41
42BN_rand() is available in all versions of SSLeay and OpenSSL.
43BN_pseudo_rand() was added in OpenSSL 0.9.5.
44
45=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_set_bit.pod b/src/lib/libssl/src/doc/crypto/BN_set_bit.pod
new file mode 100644
index 0000000000..b7c47b9b01
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_set_bit.pod
@@ -0,0 +1,66 @@
1=pod
2
3=head1 NAME
4
5BN_set_bit, BN_clear_bit, BN_is_bit_set, BN_mask_bits, BN_lshift,
6BN_lshift1, BN_rshift, BN_rshift1 - bit operations on BIGNUMs
7
8=head1 SYNOPSIS
9
10 #include <openssl/bn.h>
11
12 int BN_set_bit(BIGNUM *a, int n);
13 int BN_clear_bit(BIGNUM *a, int n);
14
15 int BN_is_bit_set(const BIGNUM *a, int n);
16
17 int BN_mask_bits(BIGNUM *a, int n);
18
19 int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
20 int BN_lshift1(BIGNUM *r, BIGNUM *a);
21
22 int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
23 int BN_rshift1(BIGNUM *r, BIGNUM *a);
24
25=head1 DESCRIPTION
26
27BN_set_bit() sets bit B<n> in B<a> to 1 (C<a|=(1E<lt>E<lt>n)>). The
28number is expanded if necessary.
29
30BN_clear_bit() sets bit B<n> in B<a> to 0 (C<a&=~(1E<lt>E<lt>n)>). An
31error occurs if B<a> is shorter than B<n> bits.
32
33BN_is_bit_set() tests if bit B<n> in B<a> is set.
34
35BN_mask_bits() truncates B<a> to an B<n> bit number
36(C<a&=~((~0)E<gt>E<gt>n)>). An error occurs if B<a> already is
37shorter than B<n> bits.
38
39BN_lshift() shifts B<a> left by B<n> bits and places the result in
40B<r> (C<r=a*2^n>). BN_lshift1() shifts B<a> left by one and places
41the result in B<r> (C<r=2*a>).
42
43BN_rshift() shifts B<a> right by B<n> bits and places the result in
44B<r> (C<r=a/2^n>). BN_rshift1() shifts B<a> right by one and places
45the result in B<r> (C<r=a/2>).
46
47For the shift functions, B<r> and B<a> may be the same variable.
48
49=head1 RETURN VALUES
50
51BN_is_bit_set() returns 1 if the bit is set, 0 otherwise.
52
53All other functions return 1 for success, 0 on error. The error codes
54can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
55
56=head1 SEE ALSO
57
58L<bn(3)|bn(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>, L<BN_add(3)|BN_add(3)>
59
60=head1 HISTORY
61
62BN_set_bit(), BN_clear_bit(), BN_is_bit_set(), BN_mask_bits(),
63BN_lshift(), BN_lshift1(), BN_rshift(), and BN_rshift1() are available
64in all versions of SSLeay and OpenSSL.
65
66=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_zero.pod b/src/lib/libssl/src/doc/crypto/BN_zero.pod
new file mode 100644
index 0000000000..165fd9a228
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_zero.pod
@@ -0,0 +1,55 @@
1=pod
2
3=head1 NAME
4
5BN_zero, BN_one, BN_set_word, BN_get_word - BIGNUM assignment operations
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 int BN_zero(BIGNUM *a);
12 int BN_one(BIGNUM *a);
13
14 BIGNUM *BN_value_one(void);
15
16 int BN_set_word(BIGNUM *a, unsigned long w);
17 unsigned long BN_get_word(BIGNUM *a);
18
19=head1 DESCRIPTION
20
21BN_zero(), BN_one() and BN_set_word() set B<a> to the values 0, 1 and
22B<w> respectively. BN_zero() and BN_one() are macros.
23
24BN_value_one() returns a B<BIGNUM> constant of value 1. This constant
25is useful for use in comparisons and assignment.
26
27BN_get_word() returns B<a>, if it can be represented as an unsigned
28long.
29
30=head1 RETURN VALUES
31
32BN_get_word() returns the value B<a>, and 0xffffffffL if B<a> cannot
33be represented as an unsigned long.
34
35BN_zero(), BN_one() and BN_set_word() return 1 on success, 0 otherwise.
36BN_value_one() returns the constant.
37
38=head1 BUGS
39
40Someone might change the constant.
41
42If a B<BIGNUM> is equal to 0xffffffffL it can be represented as an
43unsigned long but this value is also returned on error.
44
45=head1 SEE ALSO
46
47L<bn(3)|bn(3)>, L<BN_bn2bin(3)|BN_bn2bin(3)>
48
49=head1 HISTORY
50
51BN_zero(), BN_one() and BN_set_word() are available in all versions of
52SSLeay and OpenSSL. BN_value_one() and BN_get_word() were added in
53SSLeay 0.8.
54
55=cut
diff --git a/src/lib/libssl/src/doc/crypto/CRYPTO_set_ex_data.pod b/src/lib/libssl/src/doc/crypto/CRYPTO_set_ex_data.pod
new file mode 100644
index 0000000000..1bd5bed67d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/CRYPTO_set_ex_data.pod
@@ -0,0 +1,51 @@
1=pod
2
3=head1 NAME
4
5CRYPTO_set_ex_data, CRYPTO_get_ex_data - internal application specific data functions
6
7=head1 SYNOPSIS
8
9 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *r, int idx, void *arg);
10
11 void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *r, int idx);
12
13=head1 DESCRIPTION
14
15Several OpenSSL structures can have application specific data attached to them.
16These functions are used internally by OpenSSL to manipulate application
17specific data attached to a specific structure.
18
19These functions should only be used by applications to manipulate
20B<CRYPTO_EX_DATA> structures passed to the B<new_func()>, B<free_func()> and
21B<dup_func()> callbacks: as passed to B<RSA_get_ex_new_index()> for example.
22
23B<CRYPTO_set_ex_data()> is used to set application specific data, the data is
24supplied in the B<arg> parameter and its precise meaning is up to the
25application.
26
27B<CRYPTO_get_ex_data()> is used to retrieve application specific data. The data
28is returned to the application, this will be the same value as supplied to
29a previous B<CRYPTO_set_ex_data()> call.
30
31=head1 RETURN VALUES
32
33B<CRYPTO_set_ex_data()> returns 1 on success or 0 on failure.
34
35B<CRYPTO_get_ex_data()> returns the application data or 0 on failure. 0 may also
36be valid application data but currently it can only fail if given an invalid B<idx>
37parameter.
38
39On failure an error code can be obtained from L<ERR_get_error(3)|ERR_get_error(3)>.
40
41=head1 SEE ALSO
42
43L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>,
44L<DSA_get_ex_new_index(3)|DSA_get_ex_new_index(3)>,
45L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>
46
47=head1 HISTORY
48
49CRYPTO_set_ex_data() and CRYPTO_get_ex_data() have been available since SSLeay 0.9.0.
50
51=cut
diff --git a/src/lib/libssl/src/doc/crypto/DH_generate_key.pod b/src/lib/libssl/src/doc/crypto/DH_generate_key.pod
new file mode 100644
index 0000000000..920995b2e5
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DH_generate_key.pod
@@ -0,0 +1,50 @@
1=pod
2
3=head1 NAME
4
5DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 int DH_generate_key(DH *dh);
12
13 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
14
15=head1 DESCRIPTION
16
17DH_generate_key() performs the first step of a Diffie-Hellman key
18exchange by generating private and public DH values. By calling
19DH_compute_key(), these are combined with the other party's public
20value to compute the shared key.
21
22DH_generate_key() expects B<dh> to contain the shared parameters
23B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value
24unless B<dh-E<gt>priv_key> is already set, and computes the
25corresponding public value B<dh-E<gt>pub_key>, which can then be
26published.
27
28DH_compute_key() computes the shared secret from the private DH value
29in B<dh> and the other party's public value in B<pub_key> and stores
30it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory.
31
32=head1 RETURN VALUES
33
34DH_generate_key() returns 1 on success, 0 otherwise.
35
36DH_compute_key() returns the size of the shared secret on success, -1
37on error.
38
39The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
40
41=head1 SEE ALSO
42
43L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DH_size(3)|DH_size(3)>
44
45=head1 HISTORY
46
47DH_generate_key() and DH_compute_key() are available in all versions
48of SSLeay and OpenSSL.
49
50=cut
diff --git a/src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod b/src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod
new file mode 100644
index 0000000000..a7d0c75f0c
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DH_generate_parameters.pod
@@ -0,0 +1,72 @@
1=pod
2
3=head1 NAME
4
5DH_generate_parameters, DH_check - generate and check Diffie-Hellman parameters
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH *DH_generate_parameters(int prime_len, int generator,
12 void (*callback)(int, int, void *), void *cb_arg);
13
14 int DH_check(DH *dh, int *codes);
15
16=head1 DESCRIPTION
17
18DH_generate_parameters() generates Diffie-Hellman parameters that can
19be shared among a group of users, and returns them in a newly
20allocated B<DH> structure. The pseudo-random number generator must be
21seeded prior to calling DH_generate_parameters().
22
23B<prime_len> is the length in bits of the safe prime to be generated.
24B<generator> is a small number E<gt> 1, typically 2 or 5.
25
26A callback function may be used to provide feedback about the progress
27of the key generation. If B<callback> is not B<NULL>, it will be
28called as described in L<BN_generate_prime(3)|BN_generate_prime(3)> while a random prime
29number is generated, and when a prime has been found, B<callback(3,
300, cb_arg)> is called.
31
32DH_check() validates Diffie-Hellman parameters. It checks that B<p> is
33a safe prime, and that B<g> is a suitable generator. In the case of an
34error, the bit flags DH_CHECK_P_NOT_SAFE_PRIME or
35DH_NOT_SUITABLE_GENERATOR are set in B<*codes>.
36DH_UNABLE_TO_CHECK_GENERATOR is set if the generator cannot be
37checked, i.e. it does not equal 2 or 5.
38
39=head1 RETURN VALUES
40
41DH_generate_parameters() returns a pointer to the DH structure, or
42NULL if the parameter generation fails. The error codes can be
43obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
44
45DH_check() returns 1 if the check could be performed, 0 otherwise.
46
47=head1 NOTES
48
49DH_generate_parameters() may run for several hours before finding a
50suitable prime.
51
52The parameters generated by DH_generate_parameters() are not to be
53used in signature schemes.
54
55=head1 BUGS
56
57If B<generator> is not 2 or 5, B<dh-E<gt>g>=B<generator> is not
58a usable generator.
59
60=head1 SEE ALSO
61
62L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DH_free(3)|DH_free(3)>
63
64=head1 HISTORY
65
66DH_check() is available in all versions of SSLeay and OpenSSL.
67The B<cb_arg> argument to DH_generate_parameters() was added in SSLeay 0.9.0.
68
69In versions before OpenSSL 0.9.5, DH_CHECK_P_NOT_STRONG_PRIME is used
70instead of DH_CHECK_P_NOT_SAFE_PRIME.
71
72=cut
diff --git a/src/lib/libssl/src/doc/crypto/DH_get_ex_new_index.pod b/src/lib/libssl/src/doc/crypto/DH_get_ex_new_index.pod
new file mode 100644
index 0000000000..82e2548bcd
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DH_get_ex_new_index.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5DH_get_ex_new_index, DH_set_ex_data, DH_get_ex_data - add application specific data to DH structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 int DH_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func,
13 CRYPTO_EX_dup *dup_func,
14 CRYPTO_EX_free *free_func);
15
16 int DH_set_ex_data(DH *d, int idx, void *arg);
17
18 char *DH_get_ex_data(DH *d, int idx);
19
20=head1 DESCRIPTION
21
22These functions handle application specific data in DH
23structures. Their usage is identical to that of
24RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data()
25as described in L<RSA_get_ex_new_index(3)>.
26
27=head1 SEE ALSO
28
29L<RSA_get_ex_new_index()|RSA_get_ex_new_index()>, L<dh(3)|dh(3)>
30
31=head1 HISTORY
32
33DH_get_ex_new_index(), DH_set_ex_data() and DH_get_ex_data() are
34available since OpenSSL 0.9.5.
35
36=cut
diff --git a/src/lib/libssl/src/doc/crypto/DH_new.pod b/src/lib/libssl/src/doc/crypto/DH_new.pod
new file mode 100644
index 0000000000..64624b9d15
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DH_new.pod
@@ -0,0 +1,40 @@
1=pod
2
3=head1 NAME
4
5DH_new, DH_free - allocate and free DH objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH* DH_new(void);
12
13 void DH_free(DH *dh);
14
15=head1 DESCRIPTION
16
17DH_new() allocates and initializes a B<DH> structure.
18
19DH_free() frees the B<DH> structure and its components. The values are
20erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, DH_new() returns B<NULL> and sets an error
25code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns
26a pointer to the newly allocated structure.
27
28DH_free() returns no value.
29
30=head1 SEE ALSO
31
32L<dh(3)|dh(3)>, L<err(3)|err(3)>,
33L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
34L<DH_generate_key(3)|DH_generate_key(3)>
35
36=head1 HISTORY
37
38DH_new() and DH_free() are available in all versions of SSLeay and OpenSSL.
39
40=cut
diff --git a/src/lib/libssl/src/doc/crypto/DH_set_method.pod b/src/lib/libssl/src/doc/crypto/DH_set_method.pod
new file mode 100644
index 0000000000..dca41d8dbc
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DH_set_method.pod
@@ -0,0 +1,99 @@
1=pod
2
3=head1 NAME
4
5DH_set_default_method, DH_get_default_method, DH_set_method,
6DH_new_method, DH_OpenSSL - select DH method
7
8=head1 SYNOPSIS
9
10 #include <openssl/dh.h>
11
12 void DH_set_default_method(DH_METHOD *meth);
13
14 DH_METHOD *DH_get_default_method(void);
15
16 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
17
18 DH *DH_new_method(DH_METHOD *meth);
19
20 DH_METHOD *DH_OpenSSL(void);
21
22=head1 DESCRIPTION
23
24A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman
25operations. By modifying the method, alternative implementations
26such as hardware accelerators may be used.
27
28Initially, the default is to use the OpenSSL internal implementation.
29DH_OpenSSL() returns a pointer to that method.
30
31DH_set_default_method() makes B<meth> the default method for all B<DH>
32structures created later.
33
34DH_get_default_method() returns a pointer to the current default
35method.
36
37DH_set_method() selects B<meth> for all operations using the structure B<dh>.
38
39DH_get_method() returns a pointer to the method currently selected
40for B<dh>.
41
42DH_new_method() allocates and initializes a B<DH> structure so that
43B<method> will be used for the DH operations. If B<method> is B<NULL>,
44the default method is used.
45
46=head1 THE DH_METHOD STRUCTURE
47
48 typedef struct dh_meth_st
49 {
50 /* name of the implementation */
51 const char *name;
52
53 /* generate private and public DH values for key agreement */
54 int (*generate_key)(DH *dh);
55
56 /* compute shared secret */
57 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
58
59 /* compute r = a ^ p mod m. May be NULL */
60 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
61 const BIGNUM *m, BN_CTX *ctx,
62 BN_MONT_CTX *m_ctx);
63
64 /* called at DH_new */
65 int (*init)(DH *dh);
66
67 /* called at DH_free */
68 int (*finish)(DH *dh);
69
70 int flags;
71
72 char *app_data; /* ?? */
73
74 } DH_METHOD;
75
76=head1 RETURN VALUES
77
78DH_OpenSSL(), DH_get_default_method() and DH_get_method() return
79pointers to the respective B<DH_METHOD>s.
80
81DH_set_default_method() returns no value.
82
83DH_set_method() returns a pointer to the B<DH_METHOD> previously
84associated with B<dh>.
85
86DH_new_method() returns B<NULL> and sets an error code that can be
87obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
88returns a pointer to the newly allocated structure.
89
90=head1 SEE ALSO
91
92L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
93
94=head1 HISTORY
95
96DH_set_default_method(), DH_get_default_method(), DH_set_method(),
97DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.
98
99=cut
diff --git a/src/lib/libssl/src/doc/crypto/DH_size.pod b/src/lib/libssl/src/doc/crypto/DH_size.pod
new file mode 100644
index 0000000000..97f26fda78
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DH_size.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5DH_size - get Diffie-Hellman prime size
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 int DH_size(DH *dh);
12
13=head1 DESCRIPTION
14
15This function returns the Diffie-Hellman size in bytes. It can be used
16to determine how much memory must be allocated for the shared secret
17computed by DH_compute_key().
18
19B<dh-E<gt>p> must not be B<NULL>.
20
21=head1 RETURN VALUE
22
23The size in bytes.
24
25=head1 SEE ALSO
26
27L<dh(3)|dh(3)>, L<DH_generate_key(3)|DH_generate_key(3)>
28
29=head1 HISTORY
30
31DH_size() is available in all versions of SSLeay and OpenSSL.
32
33=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod b/src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod
new file mode 100644
index 0000000000..671655554a
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_SIG_new.pod
@@ -0,0 +1,39 @@
1=pod
2
3=head1 NAME
4
5DSA_SIG_new, DSA_SIG_free - allocate and free DSA signature objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA_SIG *DSA_SIG_new(void);
12
13 void DSA_SIG_free(DSA_SIG *a);
14
15=head1 DESCRIPTION
16
17DSA_SIG_new() allocates and initializes a B<DSA_SIG> structure.
18
19DSA_SIG_free() frees the B<DSA_SIG> structure and its components. The
20values are erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, DSA_SIG_new() returns B<NULL> and sets an
25error code that can be obtained by
26L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns a pointer
27to the newly allocated structure.
28
29DSA_SIG_free() returns no value.
30
31=head1 SEE ALSO
32
33L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<DSA_do_sign(3)|DSA_do_sign(3)>
34
35=head1 HISTORY
36
37DSA_SIG_new() and DSA_SIG_free() were added in OpenSSL 0.9.3.
38
39=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_do_sign.pod b/src/lib/libssl/src/doc/crypto/DSA_do_sign.pod
new file mode 100644
index 0000000000..a24fd5714e
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_do_sign.pod
@@ -0,0 +1,47 @@
1=pod
2
3=head1 NAME
4
5DSA_do_sign, DSA_do_verify - raw DSA signature operations
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
12
13 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
14 DSA_SIG *sig, DSA *dsa);
15
16=head1 DESCRIPTION
17
18DSA_do_sign() computes a digital signature on the B<len> byte message
19digest B<dgst> using the private key B<dsa> and returns it in a
20newly allocated B<DSA_SIG> structure.
21
22L<DSA_sign_setup(3)|DSA_sign_setup(3)> may be used to precompute part
23of the signing operation in case signature generation is
24time-critical.
25
26DSA_do_verify() verifies that the signature B<sig> matches a given
27message digest B<dgst> of size B<len>. B<dsa> is the signer's public
28key.
29
30=head1 RETURN VALUES
31
32DSA_do_sign() returns the signature, NULL on error. DSA_do_verify()
33returns 1 for a valid signature, 0 for an incorrect signature and -1
34on error. The error codes can be obtained by
35L<ERR_get_error(3)|ERR_get_error(3)>.
36
37=head1 SEE ALSO
38
39L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
40L<DSA_SIG_new(3)|DSA_SIG_new(3)>,
41L<DSA_sign(3)|DSA_sign(3)>
42
43=head1 HISTORY
44
45DSA_do_sign() and DSA_do_verify() were added in OpenSSL 0.9.3.
46
47=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod b/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod
new file mode 100644
index 0000000000..29cb1075d1
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_dup_DH.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5DSA_dup_DH - create a DH structure out of DSA structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DH * DSA_dup_DH(DSA *r);
12
13=head1 DESCRIPTION
14
15DSA_dup_DH() duplicates DSA parameters/keys as DH parameters/keys. q
16is lost during that conversion, but the resulting DH parameters
17contain its length.
18
19=head1 RETURN VALUE
20
21DSA_dup_DH() returns the new B<DH> structure, and NULL on error. The
22error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
23
24=head1 NOTE
25
26Be careful to avoid small subgroup attacks when using this.
27
28=head1 SEE ALSO
29
30L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>
31
32=head1 HISTORY
33
34DSA_dup_DH() was added in OpenSSL 0.9.4.
35
36=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_generate_key.pod b/src/lib/libssl/src/doc/crypto/DSA_generate_key.pod
new file mode 100644
index 0000000000..52890db5be
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_generate_key.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5DSA_generate_key - generate DSA key pair
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 int DSA_generate_key(DSA *a);
12
13=head1 DESCRIPTION
14
15DSA_generate_key() expects B<a> to contain DSA parameters. It generates
16a new key pair and stores it in B<a-E<gt>pub_key> and B<a-E<gt>priv_key>.
17
18The PRNG must be seeded prior to calling DSA_generate_key().
19
20=head1 RETURN VALUE
21
22DSA_generate_key() returns 1 on success, 0 otherwise.
23The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
24
25=head1 SEE ALSO
26
27L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>
28
29=head1 HISTORY
30
31DSA_generate_key() is available since SSLeay 0.8.
32
33=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod b/src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod
new file mode 100644
index 0000000000..43f60b0eb9
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_generate_parameters.pod
@@ -0,0 +1,105 @@
1=pod
2
3=head1 NAME
4
5DSA_generate_parameters - generate DSA parameters
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA *DSA_generate_parameters(int bits, unsigned char *seed,
12 int seed_len, int *counter_ret, unsigned long *h_ret,
13 void (*callback)(int, int, void *), void *cb_arg);
14
15=head1 DESCRIPTION
16
17DSA_generate_parameters() generates primes p and q and a generator g
18for use in the DSA.
19
20B<bits> is the length of the prime to be generated; the DSS allows a
21maximum of 1024 bits.
22
23If B<seed> is B<NULL> or B<seed_len> E<lt> 20, the primes will be
24generated at random. Otherwise, the seed is used to generate
25them. If the given seed does not yield a prime q, a new random
26seed is chosen and placed at B<seed>.
27
28DSA_generate_parameters() places the iteration count in
29*B<counter_ret> and a counter used for finding a generator in
30*B<h_ret>, unless these are B<NULL>.
31
32A callback function may be used to provide feedback about the progress
33of the key generation. If B<callback> is not B<NULL>, it will be
34called as follows:
35
36=over 4
37
38=item *
39
40When a candidate for q is generated, B<callback(0, m++, cb_arg)> is called
41(m is 0 for the first candidate).
42
43=item *
44
45When a candidate for q has passed a test by trial division,
46B<callback(1, -1, cb_arg)> is called.
47While a candidate for q is tested by Miller-Rabin primality tests,
48B<callback(1, i, cb_arg)> is called in the outer loop
49(once for each witness that confirms that the candidate may be prime);
50i is the loop counter (starting at 0).
51
52=item *
53
54When a prime q has been found, B<callback(2, 0, cb_arg)> and
55B<callback(3, 0, cb_arg)> are called.
56
57=item *
58
59Before a candidate for p (other than the first) is generated and tested,
60B<callback(0, counter, cb_arg)> is called.
61
62=item *
63
64When a candidate for p has passed the test by trial division,
65B<callback(1, -1, cb_arg)> is called.
66While it is tested by the Miller-Rabin primality test,
67B<callback(1, i, cb_arg)> is called in the outer loop
68(once for each witness that confirms that the candidate may be prime).
69i is the loop counter (starting at 0).
70
71=item *
72
73When p has been found, B<callback(2, 1, cb_arg)> is called.
74
75=item *
76
77When the generator has been found, B<callback(3, 1, cb_arg)> is called.
78
79=back
80
81=head1 RETURN VALUE
82
83DSA_generate_parameters() returns a pointer to the DSA structure, or
84B<NULL> if the parameter generation fails. The error codes can be
85obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
86
87=head1 BUGS
88
89Seed lengths E<gt> 20 are not supported.
90
91=head1 SEE ALSO
92
93L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
94L<DSA_free(3)|DSA_free(3)>
95
96=head1 HISTORY
97
98DSA_generate_parameters() appeared in SSLeay 0.8. The B<cb_arg>
99argument was added in SSLeay 0.9.0.
100In versions up to OpenSSL 0.9.4, B<callback(1, ...)> was called
101in the inner loop of the Miller-Rabin test whenever it reached the
102squaring step (the parameters to B<callback> did not reveal how many
103witnesses had been tested); since OpenSSL 0.9.5, B<callback(1, ...)>
104is called as in BN_is_prime(3), i.e. once for each witness.
105=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_get_ex_new_index.pod b/src/lib/libssl/src/doc/crypto/DSA_get_ex_new_index.pod
new file mode 100644
index 0000000000..4612e708ec
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_get_ex_new_index.pod
@@ -0,0 +1,36 @@
1=pod
2
3=head1 NAME
4
5DSA_get_ex_new_index, DSA_set_ex_data, DSA_get_ex_data - add application specific data to DSA structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/DSA.h>
10
11 int DSA_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func,
13 CRYPTO_EX_dup *dup_func,
14 CRYPTO_EX_free *free_func);
15
16 int DSA_set_ex_data(DSA *d, int idx, void *arg);
17
18 char *DSA_get_ex_data(DSA *d, int idx);
19
20=head1 DESCRIPTION
21
22These functions handle application specific data in DSA
23structures. Their usage is identical to that of
24RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data()
25as described in L<RSA_get_ex_new_index(3)>.
26
27=head1 SEE ALSO
28
29L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>, L<dsa(3)|dsa(3)>
30
31=head1 HISTORY
32
33DSA_get_ex_new_index(), DSA_set_ex_data() and DSA_get_ex_data() are
34available since OpenSSL 0.9.5.
35
36=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_new.pod b/src/lib/libssl/src/doc/crypto/DSA_new.pod
new file mode 100644
index 0000000000..7dde54445b
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_new.pod
@@ -0,0 +1,41 @@
1=pod
2
3=head1 NAME
4
5DSA_new, DSA_free - allocate and free DSA objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA* DSA_new(void);
12
13 void DSA_free(DSA *dsa);
14
15=head1 DESCRIPTION
16
17DSA_new() allocates and initializes a B<DSA> structure.
18
19DSA_free() frees the B<DSA> structure and its components. The values are
20erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, DSA_new() returns B<NULL> and sets an error
25code that can be obtained by
26L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns a pointer
27to the newly allocated structure.
28
29DSA_free() returns no value.
30
31=head1 SEE ALSO
32
33L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
34L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
35L<DSA_generate_key(3)|DSA_generate_key(3)>
36
37=head1 HISTORY
38
39DSA_new() and DSA_free() are available in all versions of SSLeay and OpenSSL.
40
41=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_set_method.pod b/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
new file mode 100644
index 0000000000..0b13ec9237
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
@@ -0,0 +1,111 @@
1=pod
2
3=head1 NAME
4
5DSA_set_default_method, DSA_get_default_method, DSA_set_method,
6DSA_new_method, DSA_OpenSSL - select RSA method
7
8=head1 SYNOPSIS
9
10 #include <openssl/DSA.h>
11
12 void DSA_set_default_method(DSA_METHOD *meth);
13
14 DSA_METHOD *DSA_get_default_method(void);
15
16 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth);
17
18 DSA *DSA_new_method(DSA_METHOD *meth);
19
20 DSA_METHOD *DSA_OpenSSL(void);
21
22=head1 DESCRIPTION
23
24A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA
25operations. By modifying the method, alternative implementations
26such as hardware accelerators may be used.
27
28Initially, the default is to use the OpenSSL internal implementation.
29DSA_OpenSSL() returns a pointer to that method.
30
31DSA_set_default_method() makes B<meth> the default method for all B<DSA>
32structures created later.
33
34DSA_get_default_method() returns a pointer to the current default
35method.
36
37DSA_set_method() selects B<meth> for all operations using the structure B<DSA>.
38
39DSA_get_method() returns a pointer to the method currently selected
40for B<DSA>.
41
42DSA_new_method() allocates and initializes a B<DSA> structure so that
43B<method> will be used for the DSA operations. If B<method> is B<NULL>,
44the default method is used.
45
46=head1 THE DSA_METHOD STRUCTURE
47
48struct
49 {
50 /* name of the implementation */
51 const char *name;
52
53 /* sign */
54 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
55 DSA *dsa);
56
57 /* pre-compute k^-1 and r */
58 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
59 BIGNUM **rp);
60
61 /* verify */
62 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
63 DSA_SIG *sig, DSA *dsa);
64
65 /* compute rr = a1^p1 * a2^p2 mod m. May be NULL */
66 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
67 BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
68 BN_CTX *ctx, BN_MONT_CTX *in_mont);
69
70 /* compute r = a ^ p mod m. May be NULL */
71 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
72 const BIGNUM *p, const BIGNUM *m,
73 BN_CTX *ctx, BN_MONT_CTX *m_ctx);
74
75 /* called at DSA_new */
76 int (*init)(DSA *DSA);
77
78 /* called at DSA_free */
79 int (*finish)(DSA *DSA);
80
81 int flags;
82
83 char *app_data; /* ?? */
84
85 } DSA_METHOD;
86
87=head1 RETURN VALUES
88
89DSA_OpenSSL(), DSA_get_default_method() and DSA_get_method() return
90pointers to the respective B<DSA_METHOD>s.
91
92DSA_set_default_method() returns no value.
93
94DSA_set_method() returns a pointer to the B<DSA_METHOD> previously
95associated with B<dsa>.
96
97DSA_new_method() returns B<NULL> and sets an error code that can be
98obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
99fails. Otherwise it returns a pointer to the newly allocated
100structure.
101
102=head1 SEE ALSO
103
104L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
105
106=head1 HISTORY
107
108DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
109DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
110
111=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_sign.pod b/src/lib/libssl/src/doc/crypto/DSA_sign.pod
new file mode 100644
index 0000000000..f6e60a8ca3
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_sign.pod
@@ -0,0 +1,66 @@
1=pod
2
3=head1 NAME
4
5DSA_sign, DSA_sign_setup, DSA_verify - DSA signatures
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 int DSA_sign(int type, const unsigned char *dgst, int len,
12 unsigned char *sigret, unsigned int *siglen, DSA *dsa);
13
14 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
15 BIGNUM **rp);
16
17 int DSA_verify(int type, const unsigned char *dgst, int len,
18 unsigned char *sigbuf, int siglen, DSA *dsa);
19
20=head1 DESCRIPTION
21
22DSA_sign() computes a digital signature on the B<len> byte message
23digest B<dgst> using the private key B<dsa> and places its ASN.1 DER
24encoding at B<sigret>. The length of the signature is places in
25*B<siglen>. B<sigret> must point to DSA_size(B<dsa>) bytes of memory.
26
27DSA_sign_setup() may be used to precompute part of the signing
28operation in case signature generation is time-critical. It expects
29B<dsa> to contain DSA parameters. It places the precomputed values
30in newly allocated B<BIGNUM>s at *B<kinvp> and *B<rp>, after freeing
31the old ones unless *B<kinvp> and *B<rp> are NULL. These values may
32be passed to DSA_sign() in B<dsa-E<gt>kinv> and B<dsa-E<gt>r>.
33B<ctx> is a pre-allocated B<BN_CTX> or NULL.
34
35DSA_verify() verifies that the signature B<sigbuf> of size B<siglen>
36matches a given message digest B<dgst> of size B<len>.
37B<dsa> is the signer's public key.
38
39The B<type> parameter is ignored.
40
41The PRNG must be seeded before DSA_sign() (or DSA_sign_setup())
42is called.
43
44=head1 RETURN VALUES
45
46DSA_sign() and DSA_sign_setup() return 1 on success, 0 on error.
47DSA_verify() returns 1 for a valid signature, 0 for an incorrect
48signature and -1 on error. The error codes can be obtained by
49L<ERR_get_error(3)|ERR_get_error(3)>.
50
51=head1 CONFORMING TO
52
53US Federal Information Processing Standard FIPS 186 (Digital Signature
54Standard, DSS), ANSI X9.30
55
56=head1 SEE ALSO
57
58L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
59L<DSA_do_sign(3)|DSA_do_sign(3)>
60
61=head1 HISTORY
62
63DSA_sign() and DSA_verify() are available in all versions of SSLeay.
64DSA_sign_setup() was added in SSLeay 0.8.
65
66=cut
diff --git a/src/lib/libssl/src/doc/crypto/DSA_size.pod b/src/lib/libssl/src/doc/crypto/DSA_size.pod
new file mode 100644
index 0000000000..23b6320a4d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/DSA_size.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5DSA_size - get DSA signature size
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 int DSA_size(DSA *dsa);
12
13=head1 DESCRIPTION
14
15This function returns the size of an ASN.1 encoded DSA signature in
16bytes. It can be used to determine how much memory must be allocated
17for a DSA signature.
18
19B<dsa-E<gt>q> must not be B<NULL>.
20
21=head1 RETURN VALUE
22
23The size in bytes.
24
25=head1 SEE ALSO
26
27L<dsa(3)|dsa(3)>, L<DSA_sign(3)|DSA_sign(3)>
28
29=head1 HISTORY
30
31DSA_size() is available in all versions of SSLeay and OpenSSL.
32
33=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_GET_LIB.pod b/src/lib/libssl/src/doc/crypto/ERR_GET_LIB.pod
new file mode 100644
index 0000000000..2a129da036
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_GET_LIB.pod
@@ -0,0 +1,51 @@
1=pod
2
3=head1 NAME
4
5ERR_GET_LIB, ERR_GET_FUNC, ERR_GET_REASON - get library, function and
6reason code
7
8=head1 SYNOPSIS
9
10 #include <openssl/err.h>
11
12 int ERR_GET_LIB(unsigned long e);
13
14 int ERR_GET_FUNC(unsigned long e);
15
16 int ERR_GET_REASON(unsigned long e);
17
18=head1 DESCRIPTION
19
20The error code returned by ERR_get_error() consists of a library
21number, function code and reason code. ERR_GET_LIB(), ERR_GET_FUNC()
22and ERR_GET_REASON() can be used to extract these.
23
24The library number and function code describe where the error
25occurred, the reason code is the information about what went wrong.
26
27Each sub-library of OpenSSL has a unique library number; function and
28reason codes are unique within each sub-library. Note that different
29libraries may use the same value to signal different functions and
30reasons.
31
32B<ERR_R_...> reason codes such as B<ERR_R_MALLOC_FAILURE> are globally
33unique. However, when checking for sub-library specific reason codes,
34be sure to also compare the library number.
35
36ERR_GET_LIB(), ERR_GET_FUNC() and ERR_GET_REASON() are macros.
37
38=head1 RETURN VALUES
39
40The library number, function code and reason code respectively.
41
42=head1 SEE ALSO
43
44L<err(3)|err(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
45
46=head1 HISTORY
47
48ERR_GET_LIB(), ERR_GET_FUNC() and ERR_GET_REASON() are available in
49all versions of SSLeay and OpenSSL.
50
51=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_clear_error.pod b/src/lib/libssl/src/doc/crypto/ERR_clear_error.pod
new file mode 100644
index 0000000000..566e1f4e31
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_clear_error.pod
@@ -0,0 +1,29 @@
1=pod
2
3=head1 NAME
4
5ERR_clear_error - clear the error queue
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_clear_error(void);
12
13=head1 DESCRIPTION
14
15ERR_clear_error() empties the current thread's error queue.
16
17=head1 RETURN VALUES
18
19ERR_clear_error() has no return value.
20
21=head1 SEE ALSO
22
23L<err(3)|err(3)>, L<ERR_get_error(3)|ERR_get_error(3)>
24
25=head1 HISTORY
26
27ERR_clear_error() is available in all versions of SSLeay and OpenSSL.
28
29=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_error_string.pod b/src/lib/libssl/src/doc/crypto/ERR_error_string.pod
new file mode 100644
index 0000000000..0d2417599c
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_error_string.pod
@@ -0,0 +1,65 @@
1=pod
2
3=head1 NAME
4
5ERR_error_string - obtain human-readable error message
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 char *ERR_error_string(unsigned long e, char *buf);
12
13 const char *ERR_lib_error_string(unsigned long e);
14 const char *ERR_func_error_string(unsigned long e);
15 const char *ERR_reason_error_string(unsigned long e);
16
17=head1 DESCRIPTION
18
19ERR_error_string() generates a human-readable string representing the
20error code B<e>, and places it at B<buf>. B<buf> must be at least 120
21bytes long. If B<buf> is B<NULL>, the error string is placed in a
22static buffer.
23
24The string will have the following format:
25
26 error:[error code]:[library name]:[function name]:[reason string]
27
28I<error code> is an 8 digit hexadecimal number, I<library name>,
29I<function name> and I<reason string> are ASCII text.
30
31ERR_lib_error_string(), ERR_func_error_string() and
32ERR_reason_error_string() return the library name, function
33name and reason string respectively.
34
35The OpenSSL error strings should be loaded by calling
36L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)> or, for SSL
37applications, L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>
38first.
39If there is no text string registered for the given error code,
40the error string will contain the numeric code.
41
42L<ERR_print_errors(3)|ERR_print_errors(3)> can be used to print
43all error codes currently in the queue.
44
45=head1 RETURN VALUES
46
47ERR_error_string() returns a pointer to a static buffer containing the
48string if B<buf == NULL>, B<buf> otherwise.
49
50ERR_lib_error_string(), ERR_func_error_string() and
51ERR_reason_error_string() return the strings, and B<NULL> if
52none is registered for the error code.
53
54=head1 SEE ALSO
55
56L<err(3)|err(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
57L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)>,
58L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>
59L<ERR_print_errors(3)|ERR_print_errors(3)>
60
61=head1 HISTORY
62
63ERR_error_string() is available in all versions of SSLeay and OpenSSL.
64
65=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_get_error.pod b/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
new file mode 100644
index 0000000000..75ece00d97
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
@@ -0,0 +1,62 @@
1=pod
2
3=head1 NAME
4
5ERR_get_error, ERR_peek_error - obtain error code
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 unsigned long ERR_get_error(void);
12 unsigned long ERR_peek_error(void);
13
14 unsigned long ERR_get_error_line(const char **file, int *line);
15 unsigned long ERR_peek_error_line(const char **file, int *line);
16
17 unsigned long ERR_get_error_line_data(const char **file, int *line,
18 const char **data, int *flags);
19 unsigned long ERR_peek_error_line_data(const char **file, int *line,
20 const char **data, int *flags);
21
22=head1 DESCRIPTION
23
24ERR_get_error() returns the last error code from the thread's error
25queue and removes the entry. This function can be called repeatedly
26until there are no more error codes to return.
27
28ERR_peek_error() returns the last error code from the thread's
29error queue without modifying it.
30
31See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about
32location and reason of the error, and
33L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error
34messages.
35
36ERR_get_error_line() and ERR_peek_error_line() are the same as the
37above, but they additionally store the file name and line number where
38the error occurred in *B<file> and *B<line>, unless these are B<NULL>.
39
40ERR_get_error_line_data() and ERR_peek_error_line_data() store
41additional data and flags associated with the error code in *B<data>
42and *B<flags>, unless these are B<NULL>. *B<data> contains a string
43if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by Malloc(),
44*B<flags>&B<ERR_TXT_MALLOCED> is true.
45
46=head1 RETURN VALUES
47
48The error code, or 0 if there is no error in the queue.
49
50=head1 SEE ALSO
51
52L<err(3)|err(3)>, L<ERR_error_string(3)|ERR_error_string(3)>,
53L<ERR_GET_LIB(3)|ERR_GET_LIB(3)>
54
55=head1 HISTORY
56
57ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and
58ERR_peek_error_line() are available in all versions of SSLeay and
59OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data()
60were added in SSLeay 0.9.0.
61
62=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_load_crypto_strings.pod b/src/lib/libssl/src/doc/crypto/ERR_load_crypto_strings.pod
new file mode 100644
index 0000000000..9bdec75a46
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_load_crypto_strings.pod
@@ -0,0 +1,46 @@
1=pod
2
3=head1 NAME
4
5ERR_load_crypto_strings, SSL_load_error_strings, ERR_free_strings -
6load and free error strings
7
8=head1 SYNOPSIS
9
10 #include <openssl/err.h>
11
12 void ERR_load_crypto_strings(void);
13 void ERR_free_strings(void);
14
15 #include <openssl/ssl.h>
16
17 void SSL_load_error_strings(void);
18
19=head1 DESCRIPTION
20
21ERR_load_crypto_strings() registers the error strings for all
22B<libcrypto> functions. SSL_load_error_strings() does the same,
23but also registers the B<libssl> error strings.
24
25One of these functions should be called before generating
26textual error messages. However, this is not required when memory
27usage is an issue.
28
29ERR_free_strings() frees all previously loaded error strings.
30
31=head1 RETURN VALUES
32
33ERR_load_crypto_strings(), SSL_load_error_strings() and
34ERR_free_strings() return no values.
35
36=head1 SEE ALSO
37
38L<err(3)|err(3)>, L<ERR_error_string(3)|ERR_error_string(3)>
39
40=head1 HISTORY
41
42ERR_load_error_strings(), SSL_load_error_strings() and
43ERR_free_strings() are available in all versions of SSLeay and
44OpenSSL.
45
46=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_load_strings.pod b/src/lib/libssl/src/doc/crypto/ERR_load_strings.pod
new file mode 100644
index 0000000000..5acdd0edbc
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_load_strings.pod
@@ -0,0 +1,54 @@
1=pod
2
3=head1 NAME
4
5ERR_load_strings, ERR_PACK, ERR_get_next_error_library - load
6arbitrary error strings
7
8=head1 SYNOPSIS
9
10 #include <openssl/err.h>
11
12 void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
13
14 int ERR_get_next_error_library(void);
15
16 unsigned long ERR_PACK(int lib, int func, int reason);
17
18=head1 DESCRIPTION
19
20ERR_load_strings() registers error strings for library number B<lib>.
21
22B<str> is an array of error string data:
23
24 typedef struct ERR_string_data_st
25 {
26 unsigned long error;
27 char *string;
28 } ERR_STRING_DATA;
29
30The error code is generated from the library number and a function and
31reason code: B<error> = ERR_PACK(B<lib>, B<func>, B<reason>).
32ERR_PACK() is a macro.
33
34The last entry in the array is {0,0}.
35
36ERR_get_next_error_library() can be used to assign library numbers
37to user libraries at runtime.
38
39=head1 RETURN VALUE
40
41ERR_load_strings() returns no value. ERR_PACK() return the error code.
42ERR_get_next_error_library() returns a new library number.
43
44=head1 SEE ALSO
45
46L<err(3)|err(3)>, L<ERR_load_strings(3)|ERR_load_strings(3)>
47
48=head1 HISTORY
49
50ERR_load_error_strings() and ERR_PACK() are available in all versions
51of SSLeay and OpenSSL. ERR_get_next_error_library() was added in
52SSLeay 0.9.0.
53
54=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_print_errors.pod b/src/lib/libssl/src/doc/crypto/ERR_print_errors.pod
new file mode 100644
index 0000000000..b100a5fa2b
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_print_errors.pod
@@ -0,0 +1,51 @@
1=pod
2
3=head1 NAME
4
5ERR_print_errors, ERR_print_errors_fp - print error messages
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_print_errors(BIO *bp);
12 void ERR_print_errors_fp(FILE *fp);
13
14=head1 DESCRIPTION
15
16ERR_print_errors() is a convenience function that prints the error
17strings for all errors that OpenSSL has recorded to B<bp>, thus
18emptying the error queue.
19
20ERR_print_errors_fp() is the same, except that the output goes to a
21B<FILE>.
22
23
24The error strings will have the following format:
25
26 [pid]:error:[error code]:[library name]:[function name]:[reason string]:[file name]:[line]:[optional text message]
27
28I<error code> is an 8 digit hexadecimal number. I<library name>,
29I<function name> and I<reason string> are ASCII text, as is I<optional
30text message> if one was set for the respective error code.
31
32If there is no text string registered for the given error code,
33the error string will contain the numeric code.
34
35=head1 RETURN VALUES
36
37ERR_print_errors() and ERR_print_errors_fp() return no values.
38
39=head1 SEE ALSO
40
41L<err(3)|err(3)>, L<ERR_error_string(3)|ERR_error_string(3)>,
42L<ERR_get_error(3)|ERR_get_error(3)>,
43L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)>,
44L<SSL_load_error_strings(3)|SSL_load_error_strings(3)>
45
46=head1 HISTORY
47
48ERR_print_errors() and ERR_print_errors_fp()
49are available in all versions of SSLeay and OpenSSL.
50
51=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_put_error.pod b/src/lib/libssl/src/doc/crypto/ERR_put_error.pod
new file mode 100644
index 0000000000..acd241fbe4
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_put_error.pod
@@ -0,0 +1,44 @@
1=pod
2
3=head1 NAME
4
5ERR_put_error, ERR_add_error_data - record an error
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_put_error(int lib, int func, int reason, const char *file,
12 int line);
13
14 void ERR_add_error_data(int num, ...);
15
16=head1 DESCRIPTION
17
18ERR_put_error() adds an error code to the thread's error queue. It
19signals that the error of reason code B<reason> occurred in function
20B<func> of library B<lib>, in line number B<line> of B<file>.
21This function is usually called by a macro.
22
23ERR_add_error_data() associates the concatenation of its B<num> string
24arguments with the error code added last.
25
26L<ERR_load_strings(3)|ERR_load_strings(3)> can be used to register
27error strings so that the application can a generate human-readable
28error messages for the error code.
29
30=head1 RETURN VALUES
31
32ERR_put_error() and ERR_add_error_data() return
33no values.
34
35=head1 SEE ALSO
36
37L<err(3)|err(3)>, L<ERR_load_strings(3)|ERR_load_strings(3)>
38
39=head1 HISTORY
40
41ERR_put_error() is available in all versions of SSLeay and OpenSSL.
42ERR_add_error_data() was added in SSLeay 0.9.0.
43
44=cut
diff --git a/src/lib/libssl/src/doc/crypto/ERR_remove_state.pod b/src/lib/libssl/src/doc/crypto/ERR_remove_state.pod
new file mode 100644
index 0000000000..ebcdc0f5a5
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ERR_remove_state.pod
@@ -0,0 +1,34 @@
1=pod
2
3=head1 NAME
4
5ERR_remove_state - free a thread's error queue
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_remove_state(unsigned long pid);
12
13=head1 DESCRIPTION
14
15ERR_remove_state() frees the error queue associated with thread B<pid>.
16If B<pid> == 0, the current thread will have its error queue removed.
17
18Since error queue data structures are allocated automatically for new
19threads, they must be freed when threads are terminated in oder to
20avoid memory leaks.
21
22=head1 RETURN VALUE
23
24ERR_remove_state() returns no value.
25
26=head1 SEE ALSO
27
28L<err(3)|err(3)>
29
30=head1 HISTORY
31
32ERR_remove_state() is available in all versions of SSLeay and OpenSSL.
33
34=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod b/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
new file mode 100644
index 0000000000..345b1ddfa7
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
@@ -0,0 +1,197 @@
1=pod
2
3=head1 NAME
4
5EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal - EVP digest routines
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
12 void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
13 void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
14 unsigned int *s);
15
16 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
17
18 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
19
20 #define EVP_MD_type(e) ((e)->type)
21 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
22 #define EVP_MD_size(e) ((e)->md_size)
23 #define EVP_MD_block_size(e) ((e)->block_size)
24
25 #define EVP_MD_CTX_md(e) (e)->digest)
26 #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
27 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
28 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
29
30 EVP_MD *EVP_md_null(void);
31 EVP_MD *EVP_md2(void);
32 EVP_MD *EVP_md5(void);
33 EVP_MD *EVP_sha(void);
34 EVP_MD *EVP_sha1(void);
35 EVP_MD *EVP_dss(void);
36 EVP_MD *EVP_dss1(void);
37 EVP_MD *EVP_mdc2(void);
38 EVP_MD *EVP_ripemd160(void);
39
40 const EVP_MD *EVP_get_digestbyname(const char *name);
41 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
42 #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
43
44=head1 DESCRIPTION
45
46The EVP digest routines are a high level interface to message digests.
47
48EVP_DigestInit() initialises a digest context B<ctx> to use a digest
49B<type>: this will typically be supplied by a function such as
50EVP_sha1().
51
52EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the
53digest context B<ctx>. This funtion can be called several times on the
54same B<ctx> to hash additional data.
55
56EVP_DigestFinal() retrieves the digest value from B<ctx> and places
57it in B<md>. If the B<s> parameter is not NULL then the number of
58bytes of data written (i.e. the length of the digest) will be written
59to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written.
60After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate()
61can be made, but EVP_DigestInit() can be called to initialiase a new
62digest operation.
63
64EVP_MD_CTX_copy() can be used to copy the message digest state from
65B<in> to B<out>. This is useful if large amounts of data are to be
66hashed which only differ in the last few bytes.
67
68EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest
69when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the
70hash.
71
72EVP_MD_block_size() and EVP_MD_CTX_block_size() return the block size of the
73message digest when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure.
74
75EVP_MD_type() and EVP_MD_CTX_type() return the NID of the OBJECT IDENTIFIER
76representing the given message digest when passed an B<EVP_MD> structure.
77For example EVP_MD_type(EVP_sha1()) returns B<NID_sha1>. This function is
78normally used when setting ASN1 OIDs.
79
80EVP_MD_CTX_md() returns the B<EVP_MD> structure corresponding to the passed
81B<EVP_MD_CTX>.
82
83EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated
84with this digest. For example EVP_sha1() is associated with RSA so this will
85return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature
86algorithms may not be retained in future versions of OpenSSL.
87
88EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160()
89return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest
90algorithms respectively. The associated signature algorithm is RSA in each case.
91
92EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
93algorithms but using DSS (DSA) for the signature algorithm.
94
95EVP_md_null() is a "null" message digest that does nothing: i.e. the hash it
96returns is of zero length.
97
98EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
99return an B<EVP_MD> structure when passed a digest name, a digest NID or
100an ASN1_OBJECT structure respectively. The digest table must be initialised
101using, for example, OpenSSL_add_all_digests() for these functions to work.
102
103=head1 RETURN VALUES
104
105EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values.
106
107EVP_MD_CTX_copy() returns 1 if successful or 0 for failure.
108
109EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the
110corresponding OBJECT IDENTIFIER or NID_undef if none exists.
111
112EVP_MD_size(), EVP_MD_block_size(), EVP_MD_CTX_size(e), EVP_MD_size(),
113EVP_MD_CTX_block_size() and EVP_MD_block_size() return the digest or block
114size in bytes.
115
116EVP_md_null(), EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_dss(),
117EVP_dss1(), EVP_mdc2() and EVP_ripemd160() return pointers to the
118corresponding EVP_MD structures.
119
120EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
121return either an B<EVP_MD> structure or NULL if an error occurs.
122
123=head1 NOTES
124
125The B<EVP> interface to message digests should almost always be used in
126preference to the low level interfaces. This is because the code then becomes
127transparent to the digest used and much more flexible.
128
129SHA1 is the digest of choice for new applications. The other digest algorithms
130are still in common use.
131
132=head1 EXAMPLE
133
134This example digests the data "Test Message\n" and "Hello World\n", using the
135digest name passed on the command line.
136
137 #include <stdio.h>
138 #include <openssl/evp.h>
139
140 main(int argc, char *argv[])
141 {
142 EVP_MD_CTX mdctx;
143 const EVP_MD *md;
144 char mess1[] = "Test Message\n";
145 char mess2[] = "Hello World\n";
146 unsigned char md_value[EVP_MAX_MD_SIZE];
147 int md_len, i;
148
149 OpenSSL_add_all_digests();
150
151 if(!argv[1]) {
152 printf("Usage: mdtest digestname\n");
153 exit(1);
154 }
155
156 md = EVP_get_digestbyname(argv[1]);
157
158 if(!md) {
159 printf("Unknown message digest %s\n", argv[1]);
160 exit(1);
161 }
162
163 EVP_DigestInit(&mdctx, md);
164 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
165 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
166 EVP_DigestFinal(&mdctx, md_value, &md_len);
167
168 printf("Digest is: ");
169 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
170 printf("\n");
171 }
172
173=head1 BUGS
174
175Several of the functions do not return values: maybe they should. Although the
176internal digest operations will never fail some future hardware based operations
177might.
178
179The link between digests and signing algorithms results in a situation where
180EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
181even though they are identical digests.
182
183The size of an B<EVP_MD_CTX> structure is determined at compile time: this results
184in code that must be recompiled if the size of B<EVP_MD_CTX> increases.
185
186=head1 SEE ALSO
187
188L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>,
189L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>,
190L<sha(3)|sha(3)>, L<digest(1)|digest(1)>
191
192=head1 HISTORY
193
194EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are
195available in all versions of SSLeay and OpenSSL.
196
197=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod b/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
new file mode 100644
index 0000000000..77ed4ccdba
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
@@ -0,0 +1,224 @@
1=pod
2
3=head1 NAME
4
5EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal - EVP cipher routines
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 void EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
12 unsigned char *key, unsigned char *iv);
13 void EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
14 int *outl, unsigned char *in, int inl);
15 void EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
16 int *outl);
17
18 void EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
19 unsigned char *key, unsigned char *iv);
20 void EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
21 int *outl, unsigned char *in, int inl);
22 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
23 int *outl);
24
25 void EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
26 unsigned char *key, unsigned char *iv, int enc);
27 void EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
28 int *outl, unsigned char *in, int inl);
29 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
30 int *outl);
31
32 void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
33
34 const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
35 #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
36 #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
37
38 #define EVP_CIPHER_nid(e) ((e)->nid)
39 #define EVP_CIPHER_block_size(e) ((e)->block_size)
40 #define EVP_CIPHER_key_length(e) ((e)->key_len)
41 #define EVP_CIPHER_iv_length(e) ((e)->iv_len)
42
43 int EVP_CIPHER_type(const EVP_CIPHER *ctx);
44 #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
45 #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
46 #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
47 #define EVP_CIPHER_CTX_key_length(e) ((e)->cipher->key_len)
48 #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
49 #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
50
51 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
52 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
53
54=head1 DESCRIPTION
55
56The EVP cipher routines are a high level interface to certain
57symmetric ciphers.
58
59EVP_EncryptInit() initialises a cipher context B<ctx> for encryption
60with cipher B<type>. B<type> is normally supplied by a function such
61as EVP_des_cbc() . B<key> is the symmetric key to use and B<iv> is the
62IV to use (if necessary), the actual number of bytes used for the
63key and IV depends on the cipher. It is possible to set all parameters
64to NULL except B<type> in an initial call and supply the remaining
65parameters in subsequent calls. This is normally done when the
66EVP_CIPHER_asn1_to_param() function is called to set the cipher
67parameters from an ASN1 AlgorithmIdentifier and the key from a
68different source.
69
70EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and
71writes the encrypted version to B<out>. This function can be called
72multiple times to encrypt successive blocks of data. The amount
73of data written depends on the block alignment of the encrypted data:
74as a result the amount of data written may be anything from zero bytes
75to (inl + cipher_block_size - 1) so B<outl> should contain sufficient
76room. The actual number of bytes written is placed in B<outl>.
77
78EVP_EncryptFinal() encrypts the "final" data, that is any data that
79remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS
80padding). The encrypted final data is written to B<out> which should
81have sufficient space for one cipher block. The number of bytes written
82is placed in B<outl>. After this function is called the encryption operation
83is finished and no further calls to EVP_EncryptUpdate() should be made.
84
85EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the
86corresponding decryption operations. EVP_DecryptFinal() will return an
87error code if the final block is not correctly formatted. The parameters
88and restrictions are identical to the encryption operations except that
89the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should
90have sufficient room for (B<inl> + cipher_block_size) bytes unless the
91cipher block size is 1 in which case B<inl> bytes is sufficient.
92
93EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions
94that can be used for decryption or encryption. The operation performed
95depends on the value of the B<enc> parameter. It should be set to 1 for
96encryption and 0 for decryption.
97
98EVP_CIPHER_CTX_cleanup() clears all information from a cipher context.
99It should be called after all operations using a cipher are complete
100so sensitive information does not remain in memory.
101
102EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
103return an EVP_CIPHER structure when passed a cipher name, a NID or an
104ASN1_OBJECT structure.
105
106EVP_CIPHER_nid() and EVP_CIPHER_CTX_nid() return the NID of a cipher when
107passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> structure. The actual NID
108value is an internal value which may not have a corresponding OBJECT
109IDENTIFIER.
110
111EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
112length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>
113structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length
114for all ciphers.
115
116EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
117length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>.
118It will return zero if the cipher does not use an IV. The constant
119B<EVP_MAX_IV_LENGTH> is the maximum IV length for all ciphers.
120
121EVP_CIPHER_block_size() and EVP_CIPHER_CTX_block_size() return the block
122size of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>
123structure. The constant B<EVP_MAX_IV_LENGTH> is also the maximum block
124length for all ciphers.
125
126EVP_CIPHER_type() and EVP_CIPHER_CTX_type() return the type of the passed
127cipher or context. This "type" is the actual NID of the cipher OBJECT
128IDENTIFIER as such it ignores the cipher parameters and 40 bit RC2 and
129128 bit RC2 have the same NID. If the cipher does not have an object
130identifier or does not have ASN1 support this function will return
131B<NID_undef>.
132
133EVP_CIPHER_CTX_cipher() returns the B<EVP_CIPHER> structure when passed
134an B<EVP_CIPHER_CTX> structure.
135
136EVP_CIPHER_param_to_asn1() sets the AlgorithmIdentifier "parameter" based
137on the passed cipher. This will typically include any parameters and an
138IV. The cipher IV (if any) must be set when this call is made. This call
139should be made before the cipher is actually "used" (before any
140EVP_EncryptUpdate(), EVP_DecryptUpdate() calls for example). This function
141may fail if the cipher does not have any ASN1 support.
142
143EVP_CIPHER_asn1_to_param() sets the cipher parameters based on an ASN1
144AlgorithmIdentifier "parameter". The precise effect depends on the cipher
145In the case of RC2, for example, it will set the IV and effective key length.
146This function should be called after the base cipher type is set but before
147the key is set. For example EVP_CipherInit() will be called with the IV and
148key set to NULL, EVP_CIPHER_asn1_to_param() will be called and finally
149EVP_CipherInit() again with all parameters except the key set to NULL. It is
150possible for this function to fail if the cipher does not have any ASN1 support
151or the parameters cannot be set (for example the RC2 effective key length
152does not have an B<EVP_CIPHER> structure).
153
154=head1 RETURN VALUES
155
156EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() do not return
157values.
158
159EVP_DecryptInit() and EVP_DecryptUpdate() do not return values.
160EVP_DecryptFinal() returns 0 if the decrypt failed or 1 for success.
161
162EVP_CipherInit() and EVP_CipherUpdate() do not return values.
163EVP_CipherFinal() returns 1 for a decryption failure or 1 for success, if
164the operation is encryption then it always returns 1.
165
166EVP_CIPHER_CTX_cleanup() does not return a value.
167
168EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
169return an B<EVP_CIPHER> structure or NULL on error.
170
171EVP_CIPHER_nid() and EVP_CIPHER_CTX_nid() return a NID.
172
173EVP_CIPHER_block_size() and EVP_CIPHER_CTX_block_size() return the block
174size.
175
176EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
177length.
178
179EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
180length or zero if the cipher does not use an IV.
181
182EVP_CIPHER_type() and EVP_CIPHER_CTX_type() return the NID of the cipher's
183OBJECT IDENTIFIER or NID_undef if it has no defined OBJECT IDENTIFIER.
184
185EVP_CIPHER_CTX_cipher() returns an B<EVP_CIPHER> structure.
186
187EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return 1 for
188success or zero for failure.
189
190=head1 NOTES
191
192Where possible the B<EVP> interface to symmetric ciphers should be used in
193preference to the low level interfaces. This is because the code then becomes
194transparent to the cipher used and much more flexible.
195
196PKCS padding works by adding B<n> padding bytes of value B<n> to make the total
197length of the encrypted data a multiple of the block size. Padding is always
198added so if the data is already a multiple of the block size B<n> will equal
199the block size. For example if the block size is 8 and 11 bytes are to be
200encrypted then 5 padding bytes of value 5 will be added.
201
202When decrypting the final block is checked to see if it has the correct form.
203
204Although the decryption operation can produce an error, it is not a strong
205test that the input data or key is correct. A random block has better than
2061 in 256 chance of being of the correct format and problems with the
207input data earlier on will not produce a final decrypt error.
208
209=head1 BUGS
210
211The current B<EVP> cipher interface is not as flexible as it should be. Only
212certain "spot" encryption algorithms can be used for ciphers which have various
213parameters associated with them (RC2, RC5 for example) this is inadequate.
214
215Several of the functions do not return error codes because the software versions
216can never fail. This is not true of hardware versions.
217
218=head1 SEE ALSO
219
220L<evp(3)|evp(3)>
221
222=head1 HISTORY
223
224=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
new file mode 100644
index 0000000000..b0b1058d19
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod
@@ -0,0 +1,46 @@
1=pod
2
3=head1 NAME
4
5OPENSSL_VERSION_NUMBER, SSLeay - get OpenSSL version number
6
7=head1 SYNOPSIS
8
9 #include <openssl/opensslv.h>
10 #define OPENSSL_VERSION_NUMBER 0xnnnnnnnnnL
11
12 #include <openssl/crypto.h>
13 long SSLeay(void);
14
15=head1 DESCRIPTION
16
17OPENSSL_VERSION_NUMBER is a numeric release version identifier:
18
19 MMNNFFRBB major minor fix final beta/patch
20
21for example
22
23 0x000904100 == 0.9.4 release
24 0x000905000 == 0.9.5 dev
25
26Versions prior to 0.9.3 have identifiers E<lt> 0x0930.
27For backward compatibility, SSLEAY_VERSION_NUMBER is also defined.
28
29SSLeay() returns this number. The return value can be compared to the
30macro to make sure that the correct version of the library has been
31loaded, especially when using DLLs on Windows systems.
32
33=head1 RETURN VALUE
34
35The version number.
36
37=head1 SEE ALSO
38
39L<crypto(3)|crypto(3)>
40
41=head1 HISTORY
42
43SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL.
44OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL.
45
46=cut
diff --git a/src/lib/libssl/src/doc/crypto/OpenSSL_add_all_algorithms.pod b/src/lib/libssl/src/doc/crypto/OpenSSL_add_all_algorithms.pod
new file mode 100644
index 0000000000..1300fe190c
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/OpenSSL_add_all_algorithms.pod
@@ -0,0 +1,65 @@
1=pod
2
3=head1 NAME
4
5OpenSSL_add_all_algorithms() - add algorithms to internal table
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 void OpenSSL_add_all_algorithms(void);
12 void OpenSSL_add_all_ciphers(void);
13 void OpenSSL_add_all_digests(void);
14
15 void EVP_cleanup(void);
16
17=head1 DESCRIPTION
18
19OpenSSL keeps an internal table of digest algorithms and ciphers. It uses
20this table to lookup ciphers via functions such as EVP_get_cipher_byname().
21
22OpenSSL_add_all_digests() adds all digest algorithms to the table.
23
24OpenSSL_add_all_algorithms() adds all algorithms to the table (digests and
25ciphers).
26
27OpenSSL_add_all_ciphers() adds all encryption algorithms to the table including
28password based encryption algorithms.
29
30EVP_cleanup() removes all ciphers and digests from the table.
31
32=head1 RETURN VALUES
33
34None of the functions return a value.
35
36=head1 NOTES
37
38A typical application will will call OpenSSL_add_all_algorithms() initially and
39EVP_cleanup() before exiting.
40
41An application does not need to add algorithms to use them explicitly, for example
42by EVP_sha1(). It just needs to add them if it (or any of the functions it calls)
43needs to lookup algorithms.
44
45The cipher and digest lookup functions are used in many parts of the library. If
46the table is not initialised several functions will misbehave and complain they
47cannot find algorithms. This includes the PEM, PKCS#12, SSL and S/MIME libraries.
48This is a common query in the OpenSSL mailing lists.
49
50Calling OpenSSL_add_all_algorithms() links in all algorithms: as a result a
51statically linked executable can be quite large. If this is important it is possible
52to just add the required ciphers and digests.
53
54=head1 BUGS
55
56Although the functions do not return error codes it is possible for them to fail.
57This will only happen as a result of a memory allocation failure so this is not
58too much of a problem in practice.
59
60=head1 SEE ALSO
61
62L<evp(3)|evp(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>,
63L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>
64
65=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_add.pod b/src/lib/libssl/src/doc/crypto/RAND_add.pod
new file mode 100644
index 0000000000..0a13ec2a92
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RAND_add.pod
@@ -0,0 +1,68 @@
1=pod
2
3=head1 NAME
4
5RAND_add, RAND_seed, RAND_screen - add entropy to the PRNG
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_seed(const void *buf, int num);
12
13 void RAND_add(const void *buf, int num, double entropy);
14
15 int RAND_status(void);
16
17 void RAND_screen(void);
18
19=head1 DESCRIPTION
20
21RAND_add() mixes the B<num> bytes at B<buf> into the PRNG state. Thus,
22if the data at B<buf> are unpredictable to an adversary, this
23increases the uncertainty about the state and makes the PRNG output
24less predictable. Suitable input comes from user interaction (random
25key presses, mouse movements) and certain hardware events. The
26B<entropy> argument is (the lower bound of) an estimate of how much
27randomness is contained in B<buf>, measured in bytes. Details about
28sources of randomness and how to estimate their entropy can be found
29in the literature, e.g. RFC 1750.
30
31RAND_add() may be called with sensitive data such as user entered
32passwords. The seed values cannot be recovered from the PRNG output.
33
34OpenSSL makes sure that the PRNG state is unique for each thread. On
35systems that provide C</dev/urandom>, the randomness device is used
36to seed the PRNG transparently. However, on all other systems, the
37application is responsible for seeding the PRNG by calling RAND_add(),
38L<RAND_egd(3)|RAND_egd(3)>
39or L<RAND_load_file(3)|RAND_load_file(3)>.
40
41RAND_seed() is equivalent to RAND_add() when B<num == entropy>.
42
43The RAND_screen() function is available for the convenience of Windows
44programmers. It adds the current contents of the screen to the PRNG.
45For applications that can catch Windows events, seeding the PRNG with
46the parameters of B<WM_MOUSEMOVE> events is a significantly better
47source of randomness. It should be noted that both methods cannot be
48used on servers that run without user interaction.
49
50=head1 RETURN VALUES
51
52RAND_status() returns 1 if the PRNG has been seeded with enough data,
530 otherwise.
54
55The other functions do not return values.
56
57=head1 SEE ALSO
58
59L<rand(3)|rand(3)>, L<RAND_egd(3)|RAND_egd(3)>,
60L<RAND_load_file(3)|RAND_load_file(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
61
62=head1 HISTORY
63
64RAND_seed() and RAND_screen() are available in all versions of SSLeay
65and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL
660.9.5.
67
68=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_bytes.pod b/src/lib/libssl/src/doc/crypto/RAND_bytes.pod
new file mode 100644
index 0000000000..b6ebd50527
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RAND_bytes.pod
@@ -0,0 +1,46 @@
1=pod
2
3=head1 NAME
4
5RAND_bytes, RAND_pseudo_bytes - generate random data
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 int RAND_bytes(unsigned char *buf, int num);
12
13 int RAND_pseudo_bytes(unsigned char *buf, int num);
14
15=head1 DESCRIPTION
16
17RAND_bytes() puts B<num> cryptographically strong pseudo-random bytes
18into B<buf>. An error occurs if the PRNG has not been seeded with
19enough randomness to ensure an unpredictable byte sequence.
20
21RAND_pseudo_bytes() puts B<num> pseudo-random bytes into B<buf>.
22Pseudo-random byte sequences generated by RAND_pseudo_bytes() will be
23unique if they are of sufficient length, but are not necessarily
24unpredictable. They can be used for non-cryptographic purposes and for
25certain purposes in cryptographic protocols, but usually not for key
26generation etc.
27
28=head1 RETURN VALUES
29
30RAND_bytes() returns 1 on success, 0 otherwise. The error code can be
31obtained by L<ERR_get_error(3)|ERR_get_error(3)>. RAND_pseudo_bytes() returns 1 if the
32bytes generated are cryptographically strong, 0 otherwise. Both
33functions return -1 if they are not supported by the current RAND
34method.
35
36=head1 SEE ALSO
37
38L<rand(3)|rand(3)>, L<err(3)|err(3)>, L<RAND_add(3)|RAND_add(3)>
39
40=head1 HISTORY
41
42RAND_bytes() is available in all versions of SSLeay and OpenSSL. It
43has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
44in OpenSSL 0.9.5.
45
46=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_cleanup.pod b/src/lib/libssl/src/doc/crypto/RAND_cleanup.pod
new file mode 100644
index 0000000000..3a8f0749a8
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RAND_cleanup.pod
@@ -0,0 +1,29 @@
1=pod
2
3=head1 NAME
4
5RAND_cleanup - erase the PRNG state
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_cleanup(void);
12
13=head1 DESCRIPTION
14
15RAND_cleanup() erases the memory used by the PRNG.
16
17=head1 RETURN VALUE
18
19RAND_cleanup() returns no value.
20
21=head1 SEE ALSO
22
23L<rand(3)|rand(3)>
24
25=head1 HISTORY
26
27RAND_cleanup() is available in all versions of SSLeay and OpenSSL.
28
29=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_egd.pod b/src/lib/libssl/src/doc/crypto/RAND_egd.pod
new file mode 100644
index 0000000000..a40bd96198
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RAND_egd.pod
@@ -0,0 +1,38 @@
1=pod
2
3=head1 NAME
4
5RAND_egd - query entropy gathering daemon
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 int RAND_egd(const char *path);
12
13=head1 DESCRIPTION
14
15RAND_egd() queries the entropy gathering daemon EGD on socket B<path>.
16
17EGD is available from http://www.lothar.com/tech/crypto/ (C<perl
18Makefile.PL; make; make install> to install). It is run as B<egd>
19I<path>, where I<path> is an absolute path designating a socket. When
20RAND_egd() is called with that path as an argument, it tries to read
21random bytes that EGD has collected. The read is performed in
22non-blocking mode.
23
24=head1 RETURN VALUE
25
26RAND_egd() returns the number of bytes read from the daemon on
27success, and -1 if the connection failed or the daemon did not return
28enough data to fully seed the PRNG.
29
30=head1 SEE ALSO
31
32L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
33
34=head1 HISTORY
35
36RAND_egd() is available since OpenSSL 0.9.5.
37
38=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_load_file.pod b/src/lib/libssl/src/doc/crypto/RAND_load_file.pod
new file mode 100644
index 0000000000..8dd700ca3d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RAND_load_file.pod
@@ -0,0 +1,53 @@
1=pod
2
3=head1 NAME
4
5RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 const char *RAND_file_name(char *buf, int num);
12
13 int RAND_load_file(const char *filename, long max_bytes);
14
15 int RAND_write_file(const char *filename);
16
17=head1 DESCRIPTION
18
19RAND_file_name() generates a default path for the random seed
20file. B<buf> points to a buffer of size B<num> in which to store the
21filename. The seed file is $RANDFILE if that environment variable is
22set, $HOME/.rnd otherwise. If $HOME is not set either, or B<num> is
23too small for the path name, an error occurs.
24
25RAND_load_file() reads a number of bytes from file B<filename> and
26adds them to the PRNG. If B<max_bytes> is non-negative,
27up to to B<max_bytes> are read; starting with OpenSSL 0.9.5,
28if B<max_bytes> is -1, the complete file is read.
29
30RAND_write_file() writes a number of random bytes (currently 1024) to
31file B<filename> which can be used to initialize the PRNG by calling
32RAND_load_file() in a later session.
33
34=head1 RETURN VALUES
35
36RAND_load_file() returns the number of bytes read.
37
38RAND_write_file() returns the number of bytes written, and -1 if the
39bytes written were generated without appropriate seed.
40
41RAND_file_name() returns a pointer to B<buf> on success, and NULL on
42error.
43
44=head1 SEE ALSO
45
46L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
47
48=head1 HISTORY
49
50RAND_load_file(), RAND_write_file() and RAND_file_name() are available in
51all versions of SSLeay and OpenSSL.
52
53=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_set_rand_method.pod b/src/lib/libssl/src/doc/crypto/RAND_set_rand_method.pod
new file mode 100644
index 0000000000..466e9b8767
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RAND_set_rand_method.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_set_rand_method(RAND_METHOD *meth);
12
13 RAND_METHOD *RAND_get_rand_method(void);
14
15 RAND_METHOD *RAND_SSLeay(void);
16
17=head1 DESCRIPTION
18
19A B<RAND_METHOD> specifies the functions that OpenSSL uses for random
20number generation. By modifying the method, alternative
21implementations such as hardware RNGs may be used. Initially, the
22default is to use the OpenSSL internal implementation. RAND_SSLeay()
23returns a pointer to that method.
24
25RAND_set_rand_method() sets the RAND method to B<meth>.
26RAND_get_rand_method() returns a pointer to the current method.
27
28=head1 THE RAND_METHOD STRUCTURE
29
30 typedef struct rand_meth_st
31 {
32 void (*seed)(const void *buf, int num);
33 int (*bytes)(unsigned char *buf, int num);
34 void (*cleanup)(void);
35 void (*add)(const void *buf, int num, int entropy);
36 int (*pseudorand)(unsigned char *buf, int num);
37 } RAND_METHOD;
38
39The components point to the implementation of RAND_seed(),
40RAND_bytes(), RAND_cleanup(), RAND_add() and RAND_pseudo_rand().
41Each component may be NULL if the function is not implemented.
42
43=head1 RETURN VALUES
44
45RAND_set_rand_method() returns no value. RAND_get_rand_method() and
46RAND_SSLeay() return pointers to the respective methods.
47
48=head1 SEE ALSO
49
50L<rand(3)|rand(3)>
51
52=head1 HISTORY
53
54RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are
55available in all versions of OpenSSL.
56
57=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_blinding_on.pod b/src/lib/libssl/src/doc/crypto/RSA_blinding_on.pod
new file mode 100644
index 0000000000..fd2c69abd8
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_blinding_on.pod
@@ -0,0 +1,43 @@
1=pod
2
3=head1 NAME
4
5RSA_blinding_on, RSA_blinding_off - protect the RSA operation from timing attacks
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
12
13 void RSA_blinding_off(RSA *rsa);
14
15=head1 DESCRIPTION
16
17RSA is vulnerable to timing attacks. In a setup where attackers can
18measure the time of RSA decryption or signature operations, blinding
19must be used to protect the RSA operation from that attack.
20
21RSA_blinding_on() turns blinding on for key B<rsa> and generates a
22random blinding factor. B<ctx> is B<NULL> or a pre-allocated and
23initialized B<BN_CTX>. The random number generator must be seeded
24prior to calling RSA_blinding_on().
25
26RSA_blinding_off() turns blinding off and frees the memory used for
27the blinding factor.
28
29=head1 RETURN VALUES
30
31RSA_blinding_on() returns 1 on success, and 0 if an error occurred.
32
33RSA_blinding_off() returns no value.
34
35=head1 SEE ALSO
36
37L<rsa(3)|rsa(3)>, L<rand(3)|rand(3)>
38
39=head1 HISTORY
40
41RSA_blinding_on() and RSA_blinding_off() appeared in SSLeay 0.9.0.
42
43=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_check_key.pod b/src/lib/libssl/src/doc/crypto/RSA_check_key.pod
new file mode 100644
index 0000000000..79fed753ad
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_check_key.pod
@@ -0,0 +1,39 @@
1=pod
2
3=head1 NAME
4
5RSA_check_key - validate private RSA keys
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_check_key(RSA *rsa);
12
13=head1 DESCRIPTION
14
15This function validates RSA keys. It checks that B<p> and B<q> are
16in fact prime, and that B<n = p*q>.
17
18It also checks that B<d*e = 1 mod (p-1*q-1)>,
19and that B<dmp1>, B<dmq1> and B<iqmp> are set correctly or are B<NULL>.
20
21The key's public components may not be B<NULL>.
22
23=head1 RETURN VALUE
24
25RSA_check_key() returns 1 if B<rsa> is a valid RSA key, and 0 otherwise.
26-1 is returned if an error occurs while checking the key.
27
28If the key is invalid or an error occurred, the reason code can be
29obtained using L<ERR_get_error(3)|ERR_get_error(3)>.
30
31=head1 SEE ALSO
32
33L<rsa(3)|rsa(3)>, L<err(3)|err(3)>
34
35=head1 HISTORY
36
37RSA_check() appeared in OpenSSL 0.9.4.
38
39=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
new file mode 100644
index 0000000000..fdaddbcb13
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
@@ -0,0 +1,68 @@
1=pod
2
3=head1 NAME
4
5RSA_generate_key - generate RSA key pair
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA *RSA_generate_key(int num, unsigned long e,
12 void (*callback)(int,int,void *), void *cb_arg);
13
14=head1 DESCRIPTION
15
16RSA_generate_key() generates a key pair and returns it in a newly
17allocated B<RSA> structure. The pseudo-random number generator must
18be seeded prior to calling RSA_generate_key().
19
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.
22The exponent is an odd number, typically 3 or 65535.
23
24A callback function may be used to provide feedback about the
25progress of the key generation. If B<callback> is not B<NULL>, it
26will be called as follows:
27
28=over 4
29
30=item *
31
32While a random prime number is generated, it is called as
33described in L<BN_generate_prime(3)|BN_generate_prime(3)>.
34
35=item *
36
37When the n-th randomly generated prime is rejected as not
38suitable for the key, B<callback(2, n, cb_arg)> is called.
39
40=item *
41
42When a random p has been found with p-1 relatively prime to B<e>,
43it is called as B<callback(3, 0, cb_arg)>.
44
45=back
46
47The process is then repeated for prime q with B<callback(3, 1, cb_arg)>.
48
49=head1 RETURN VALUE
50
51If key generation fails, RSA_generate_key() returns B<NULL>; the
52error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
53
54=head1 BUGS
55
56B<callback(2, x, cb_arg)> is used with two different meanings.
57
58RSA_generate_key() goes into an infinite loop for illegal input values.
59
60=head1 SEE ALSO
61
62L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_free(3)|RSA_free(3)>
63
64=head1 HISTORY
65
66The B<cb_arg> argument was added in SSLeay 0.9.0.
67
68=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_get_ex_new_index.pod b/src/lib/libssl/src/doc/crypto/RSA_get_ex_new_index.pod
new file mode 100644
index 0000000000..920dc76325
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_get_ex_new_index.pod
@@ -0,0 +1,122 @@
1=pod
2
3=head1 NAME
4
5RSA_get_ex_new_index, RSA_set_ex_data, RSA_get_ex_data - add application specific data to RSA structures
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_get_ex_new_index(long argl, void *argp,
12 CRYPTO_EX_new *new_func,
13 CRYPTO_EX_dup *dup_func,
14 CRYPTO_EX_free *free_func);
15
16 int RSA_set_ex_data(RSA *r, int idx, void *arg);
17
18 void *RSA_get_ex_data(RSA *r, int idx);
19
20 int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
21 int idx, long argl, void *argp);
22
23 void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
24 int idx, long argl, void *argp);
25
26 int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
27 int idx, long argl, void *argp);
28
29=head1 DESCRIPTION
30
31Several OpenSSL structures can have application specific data attached to them.
32This has several potential uses, it can be used to cache data associated with
33a structure (for example the hash of some part of the structure) or some
34additional data (for example a handle to the data in an external library).
35
36Since the application data can be anything at all it is passed and retrieved
37as a B<void *> type.
38
39The B<RSA_get_ex_new_index()> function is initially called to "register" some
40new application specific data. It takes three optional function pointers which
41are called when the parent structure (in this case an RSA structure) is
42initially created, when it is copied and when it is freed up. If any or all of
43these function pointer arguments are not used they should be set to NULL. The
44precise manner in which these function pointers are called is described in more
45detail below. B<RSA_get_ex_new_index()> also takes additional long and pointer
46parameters which will be passed to the supplied functions but which otherwise
47have no special meaning. It returns an B<index> which should be stored
48(typically in a static variable) and passed used in the B<idx> parameter in
49the remaining functions. Each successful call to B<RSA_get_ex_new_index()>
50will return an index greater than any previously returned, this is important
51because the optional functions are called in order of increasing index value.
52
53B<RSA_set_ex_data()> is used to set application specific data, the data is
54supplied in the B<arg> parameter and its precise meaning is up to the
55application.
56
57B<RSA_get_ex_data()> is used to retrieve application specific data. The data
58is returned to the application, this will be the same value as supplied to
59a previous B<RSA_set_ex_data()> call.
60
61B<new_func()> is called when a structure is initially allocated (for example
62with B<RSA_new()>. The parent structure members will not have any meaningful
63values at this point. This function will typically be used to allocate any
64application specific structure.
65
66B<free_func()> is called when a structure is being freed up. The dynamic parent
67structure members should not be accessed because they will be freed up when
68this function is called.
69
70B<new_func()> and B<free_func()> take the same parameters. B<parent> is a
71pointer to the parent RSA structure. B<ptr> is a the application specific data
72(this wont be of much use in B<new_func()>. B<ad> is a pointer to the
73B<CRYPTO_EX_DATA> structure from the parent RSA structure: the functions
74B<CRYPTO_get_ex_data()> and B<CRYPTO_set_ex_data()> can be called to manipulate
75it. The B<idx> parameter is the index: this will be the same value returned by
76B<RSA_get_ex_new_index()> when the functions were initially registered. Finally
77the B<argl> and B<argp> parameters are the values originally passed to the same
78corresponding parameters when B<RSA_get_ex_new_index()> was called.
79
80B<dup_func()> is called when a structure is being copied. Pointers to the
81destination and source B<CRYPTO_EX_DATA> structures are passed in the B<to> and
82B<from> parameters respectively. The B<from_d> parameter is passed a pointer to
83the source application data when the function is called, when the function returns
84the value is copied to the destination: the application can thus modify the data
85pointed to by B<from_d> and have different values in the source and destination.
86The B<idx>, B<argl> and B<argp> parameters are the same as those in B<new_func()>
87and B<free_func()>.
88
89=head1 RETURN VALUES
90
91B<RSA_get_ex_new_index()> returns a new index or -1 on failure (note 0 is a valid
92index value).
93
94B<RSA_set_ex_data()> returns 1 on success or 0 on failure.
95
96B<RSA_get_ex_data()> returns the application data or 0 on failure. 0 may also
97be valid application data but currently it can only fail if given an invalid B<idx>
98parameter.
99
100B<new_func()> and B<dup_func()> should return 0 for failure and 1 for success.
101
102On failure an error code can be obtained from L<ERR_get_error(3)|ERR_get_error(3)>.
103
104=head1 BUGS
105
106B<dup_func()> is currently never called.
107
108The return value of B<new_func()> is ignored.
109
110The B<new_func()> function isn't very useful because no meaningful values are
111present in the parent RSA structure when it is called.
112
113=head1 SEE ALSO
114
115L<rsa(3)|rsa(3)>, L<CRYPTO_set_ex_data(3)|CRYPTO_set_ex_data(3)>
116
117=head1 HISTORY
118
119RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data() are
120available since SSLeay 0.9.0.
121
122=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_new.pod b/src/lib/libssl/src/doc/crypto/RSA_new.pod
new file mode 100644
index 0000000000..f16490ea6a
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_new.pod
@@ -0,0 +1,38 @@
1=pod
2
3=head1 NAME
4
5RSA_new, RSA_free - allocate and free RSA objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA * RSA_new(void);
12
13 void RSA_free(RSA *rsa);
14
15=head1 DESCRIPTION
16
17RSA_new() allocates and initializes an B<RSA> structure.
18
19RSA_free() frees the B<RSA> structure and its components. The key is
20erased before the memory is returned to the system.
21
22=head1 RETURN VALUES
23
24If the allocation fails, RSA_new() returns B<NULL> and sets an error
25code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns
26a pointer to the newly allocated structure.
27
28RSA_free() returns no value.
29
30=head1 SEE ALSO
31
32L<err(3)|err(3)>, L<rsa(3)|rsa(3)>, L<RSA_generate_key(3)|RSA_generate_key(3)>
33
34=head1 HISTORY
35
36RSA_new() and RSA_free() are available in all versions of SSLeay and OpenSSL.
37
38=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_padding_add_PKCS1_type_1.pod b/src/lib/libssl/src/doc/crypto/RSA_padding_add_PKCS1_type_1.pod
new file mode 100644
index 0000000000..b8f678fe72
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_padding_add_PKCS1_type_1.pod
@@ -0,0 +1,124 @@
1=pod
2
3=head1 NAME
4
5RSA_padding_add_PKCS1_type_1, RSA_padding_check_PKCS1_type_1,
6RSA_padding_add_PKCS1_type_2, RSA_padding_check_PKCS1_type_2,
7RSA_padding_add_PKCS1_OAEP, RSA_padding_check_PKCS1_OAEP,
8RSA_padding_add_SSLv23, RSA_padding_check_SSLv23,
9RSA_padding_add_none, RSA_padding_check_none - asymmetric encryption
10padding
11
12=head1 SYNOPSIS
13
14 #include <openssl/rsa.h>
15
16 int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
17 unsigned char *f, int fl);
18
19 int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
20 unsigned char *f, int fl, int rsa_len);
21
22 int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
23 unsigned char *f, int fl);
24
25 int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
26 unsigned char *f, int fl, int rsa_len);
27
28 int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
29 unsigned char *f, int fl, unsigned char *p, int pl);
30
31 int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
32 unsigned char *f, int fl, int rsa_len, unsigned char *p, int pl);
33
34 int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
35 unsigned char *f, int fl);
36
37 int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
38 unsigned char *f, int fl, int rsa_len);
39
40 int RSA_padding_add_none(unsigned char *to, int tlen,
41 unsigned char *f, int fl);
42
43 int RSA_padding_check_none(unsigned char *to, int tlen,
44 unsigned char *f, int fl, int rsa_len);
45
46=head1 DESCRIPTION
47
48The RSA_padding_xxx_xxx() functions are called from the RSA encrypt,
49decrypt, sign and verify functions. Normally they should not be called
50from application programs.
51
52However, they can also be called directly to implement padding for other
53asymmetric ciphers. RSA_padding_add_PKCS1_OAEP() and
54RSA_padding_check_PKCS1_OAEP() may be used in an application combined
55with B<RSA_NO_PADDING> in order to implement OAEP with an encoding
56parameter.
57
58RSA_padding_add_xxx() encodes B<fl> bytes from B<f> so as to fit into
59B<tlen> bytes and stores the result at B<to>. An error occurs if B<fl>
60does not meet the size requirements of the encoding method.
61
62The following encoding methods are implemented:
63
64=over 4
65
66=item PKCS1_type_1
67
68PKCS #1 v2.0 EMSA-PKCS1-v1_5 (PKCS #1 v1.5 block type 1); used for signatures
69
70=item PKCS1_type_2
71
72PKCS #1 v2.0 EME-PKCS1-v1_5 (PKCS #1 v1.5 block type 2)
73
74=item PKCS1_OAEP
75
76PKCS #1 v2.0 EME-OAEP
77
78=item SSLv23
79
80PKCS #1 EME-PKCS1-v1_5 with SSL-specific modification
81
82=item none
83
84simply copy the data
85
86=back
87
88The random number generator must be seeded prior to calling
89RSA_padding_add_xxx().
90
91RSA_padding_check_xxx() verifies that the B<fl> bytes at B<f> contain
92a valid encoding for a B<rsa_len> byte RSA key in the respective
93encoding method and stores the recovered data of at most B<tlen> bytes
94(for B<RSA_NO_PADDING>: of size B<tlen>)
95at B<to>.
96
97For RSA_padding_xxx_OAEP(), B<p> points to the encoding parameter
98of length B<pl>. B<p> may be B<NULL> if B<pl> is 0.
99
100=head1 RETURN VALUES
101
102The RSA_padding_add_xxx() functions return 1 on success, 0 on error.
103The RSA_padding_check_xxx() functions return the length of the
104recovered data, -1 on error. Error codes can be obtained by calling
105L<ERR_get_error(3)|ERR_get_error(3)>.
106
107=head1 SEE ALSO
108
109L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>,
110L<RSA_private_decrypt(3)|RSA_private_decrypt(3)>,
111L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)>
112
113=head1 HISTORY
114
115RSA_padding_add_PKCS1_type_1(), RSA_padding_check_PKCS1_type_1(),
116RSA_padding_add_PKCS1_type_2(), RSA_padding_check_PKCS1_type_2(),
117RSA_padding_add_SSLv23(), RSA_padding_check_SSLv23(),
118RSA_padding_add_none() and RSA_padding_check_none() appeared in
119SSLeay 0.9.0.
120
121RSA_padding_add_PKCS1_OAEP() and RSA_padding_check_PKCS1_OAEP() were
122added in OpenSSL 0.9.2b.
123
124=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_print.pod b/src/lib/libssl/src/doc/crypto/RSA_print.pod
new file mode 100644
index 0000000000..dd968a5274
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_print.pod
@@ -0,0 +1,48 @@
1=pod
2
3=head1 NAME
4
5RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp - print
6cryptographic parameters
7
8=head1 SYNOPSIS
9
10 #include <openssl/rsa.h>
11
12 int RSA_print(BIO *bp, RSA *x, int offset);
13 int RSA_print_fp(FILE *fp, RSA *x, int offset);
14
15 #include <openssl/dsa.h>
16
17 int DSAparams_print(BIO *bp, DSA *x);
18 int DSAparams_print_fp(FILE *fp, DSA *x);
19 int DSA_print(BIO *bp, DSA *x, int offset);
20 int DSA_print_fp(FILE *fp, DSA *x, int offset);
21
22 #include <openssl/dh.h>
23
24 int DHparams_print(BIO *bp, DH *x);
25 int DHparams_print_fp(FILE *fp, DH *x);
26
27=head1 DESCRIPTION
28
29A human-readable hexadecimal output of the components of the RSA
30key, DSA parameters or key or DH parameters is printed to B<bp> or B<fp>.
31
32The output lines are indented by B<offset> spaces.
33
34=head1 RETURN VALUES
35
36These functions return 1 on success, 0 on error.
37
38=head1 SEE ALSO
39
40L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<rsa(3)|rsa(3)>, L<BN_bn2bin(3)|BN_bn2bin(3)>
41
42=head1 HISTORY
43
44RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(),
45DH_print_fp() are available in all versions of SSLeay and OpenSSL.
46DSAparams_print() and DSAparams_print_pf() were added in SSLeay 0.8.
47
48=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod b/src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod
new file mode 100644
index 0000000000..6861a98a10
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_private_encrypt.pod
@@ -0,0 +1,69 @@
1=pod
2
3=head1 NAME
4
5RSA_private_encrypt, RSA_public_decrypt - low level signature operations
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_private_encrypt(int flen, unsigned char *from,
12 unsigned char *to, RSA *rsa, int padding);
13
14 int RSA_public_decrypt(int flen, unsigned char *from,
15 unsigned char *to, RSA *rsa, int padding);
16
17=head1 DESCRIPTION
18
19These functions handle RSA signatures at a low level.
20
21RSA_private_encrypt() signs the B<flen> bytes at B<from> (usually a
22message digest with an algorithm identifier) using the private key
23B<rsa> and stores the signature in B<to>. B<to> must point to
24B<RSA_size(rsa)> bytes of memory.
25
26B<padding> denotes one of the following modes:
27
28=over 4
29
30=item RSA_PKCS1_PADDING
31
32PKCS #1 v1.5 padding. This function does not handle the
33B<algorithmIdentifier> specified in PKCS #1. When generating or
34verifying PKCS #1 signatures, L<RSA_sign(3)|RSA_sign(3)> and L<RSA_verify(3)|RSA_verify(3)> should be
35used.
36
37=item RSA_NO_PADDING
38
39Raw RSA signature. This mode should I<only> be used to implement
40cryptographically sound padding modes in the application code.
41Signing user data directly with RSA is insecure.
42
43=back
44
45RSA_public_decrypt() recovers the message digest from the B<flen>
46bytes long signature at B<from> using the signer's public key
47B<rsa>. B<to> must point to a memory section large enough to hold the
48message digest (which is smaller than B<RSA_size(rsa) -
4911>). B<padding> is the padding mode that was used to sign the data.
50
51=head1 RETURN VALUES
52
53RSA_private_encrypt() returns the size of the signature (i.e.,
54RSA_size(rsa)). RSA_public_decrypt() returns the size of the
55recovered message digest.
56
57On error, -1 is returned; the error codes can be
58obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
59
60=head1 SEE ALSO
61
62L<err(3)|err(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)>
63
64=head1 HISTORY
65
66The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is
67available since SSLeay 0.9.0.
68
69=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod b/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
new file mode 100644
index 0000000000..910c4752b8
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
@@ -0,0 +1,86 @@
1=pod
2
3=head1 NAME
4
5RSA_public_encrypt, RSA_private_decrypt - RSA public key cryptography
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_public_encrypt(int flen, unsigned char *from,
12 unsigned char *to, RSA *rsa, int padding);
13
14 int RSA_private_decrypt(int flen, unsigned char *from,
15 unsigned char *to, RSA *rsa, int padding);
16
17=head1 DESCRIPTION
18
19RSA_public_encrypt() encrypts the B<flen> bytes at B<from> (usually a
20session key) using the public key B<rsa> and stores the ciphertext in
21B<to>. B<to> must point to RSA_size(B<rsa>) bytes of memory.
22
23B<padding> denotes one of the following modes:
24
25=over 4
26
27=item RSA_PKCS1_PADDING
28
29PKCS #1 v1.5 padding. This currently is the most widely used mode.
30
31=item RSA_PKCS1_OAEP_PADDING
32
33EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty
34encoding parameter. This mode is recommended for all new applications.
35
36=item RSA_SSLV23_PADDING
37
38PKCS #1 v1.5 padding with an SSL-specific modification that denotes
39that the server is SSL3 capable.
40
41=item RSA_NO_PADDING
42
43Raw RSA encryption. This mode should I<only> be used to implement
44cryptographically sound padding modes in the application code.
45Encrypting user data directly with RSA is insecure.
46
47=back
48
49B<flen> must be less than RSA_size(B<rsa>) - 11 for the PKCS #1 v1.5
50based padding modes, and less than RSA_size(B<rsa>) - 21 for
51RSA_PKCS1_OAEP_PADDING. The random number generator must be seeded
52prior to calling RSA_public_encrypt().
53
54RSA_private_decrypt() decrypts the B<flen> bytes at B<from> using the
55private key B<rsa> and stores the plaintext in B<to>. B<to> must point
56to a memory section large enough to hold the decrypted data (which is
57smaller than RSA_size(B<rsa>)). B<padding> is the padding mode that
58was used to encrypt the data.
59
60=head1 RETURN VALUES
61
62RSA_public_encrypt() returns the size of the encrypted data (i.e.,
63RSA_size(B<rsa>)). RSA_private_decrypt() returns the size of the
64recovered plaintext.
65
66On error, -1 is returned; the error codes can be
67obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
68
69=head1 CONFORMING TO
70
71SSL, PKCS #1 v2.0
72
73=head1 SEE ALSO
74
75L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)>
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
82
83The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is
84available since SSLeay 0.9.0, OAEP was added in OpenSSL 0.9.2b.
85
86=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_set_method.pod b/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
new file mode 100644
index 0000000000..deb1183a23
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
@@ -0,0 +1,153 @@
1=pod
2
3=head1 NAME
4
5RSA_set_default_method, RSA_get_default_method, RSA_set_method,
6RSA_get_method, RSA_PKCS1_SSLeay, RSA_PKCS1_RSAref,
7RSA_PKCS1_null_method, RSA_flags, RSA_new_method - select RSA method
8
9=head1 SYNOPSIS
10
11 #include <openssl/rsa.h>
12
13 void RSA_set_default_method(RSA_METHOD *meth);
14
15 RSA_METHOD *RSA_get_default_method(void);
16
17 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
18
19 RSA_METHOD *RSA_get_method(RSA *rsa);
20
21 RSA_METHOD *RSA_PKCS1_SSLeay(void);
22
23 RSA_METHOD *RSA_PKCS1_RSAref(void);
24
25 RSA_METHOD *RSA_null_method(void);
26
27 int RSA_flags(RSA *rsa);
28
29 RSA *RSA_new_method(RSA_METHOD *method);
30
31=head1 DESCRIPTION
32
33An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
34operations. By modifying the method, alternative implementations
35such as hardware accelerators may be used.
36
37Initially, the default is to use the OpenSSL internal implementation,
38unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL>
39options. RSA_PKCS1_SSLeay() returns a pointer to that method.
40
41RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref
42library. This is the default method in the C<rsaref> configuration;
43the function is not available in other configurations.
44RSA_null_method() returns a pointer to a method that does not support
45the RSA transformation. It is the default if OpenSSL is compiled with
46C<-DRSA_NULL>. These methods may be useful in the USA because of a
47patent on the RSA cryptosystem.
48
49RSA_set_default_method() makes B<meth> the default method for all B<RSA>
50structures created later.
51
52RSA_get_default_method() returns a pointer to the current default
53method.
54
55RSA_set_method() selects B<meth> for all operations using the key
56B<rsa>.
57
58RSA_get_method() returns a pointer to the method currently selected
59for B<rsa>.
60
61RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
62
63RSA_new_method() allocates and initializes an B<RSA> structure so that
64B<method> will be used for the RSA operations. If B<method> is B<NULL>,
65the default method is used.
66
67=head1 THE RSA_METHOD STRUCTURE
68
69 typedef struct rsa_meth_st
70 {
71 /* name of the implementation */
72 const char *name;
73
74 /* encrypt */
75 int (*rsa_pub_enc)(int flen, unsigned char *from,
76 unsigned char *to, RSA *rsa, int padding);
77
78 /* verify arbitrary data */
79 int (*rsa_pub_dec)(int flen, unsigned char *from,
80 unsigned char *to, RSA *rsa, int padding);
81
82 /* sign arbitrary data */
83 int (*rsa_priv_enc)(int flen, unsigned char *from,
84 unsigned char *to, RSA *rsa, int padding);
85
86 /* decrypt */
87 int (*rsa_priv_dec)(int flen, unsigned char *from,
88 unsigned char *to, RSA *rsa, int padding);
89
90 /* compute r0 = r0 ^ I mod rsa->n. May be NULL */
91 int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
92
93 /* compute r = a ^ p mod m. May be NULL */
94 int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
95 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
96
97 /* called at RSA_new */
98 int (*init)(RSA *rsa);
99
100 /* called at RSA_free */
101 int (*finish)(RSA *rsa);
102
103 /* RSA_FLAG_EXT_PKEY - rsa_mod_exp is called for private key
104 * operations, even if p,q,dmp1,dmq1,iqmp
105 * are NULL
106 * RSA_FLAG_SIGN_VER - enable rsa_sign and rsa_verify
107 * RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match
108 */
109 int flags;
110
111 char *app_data; /* ?? */
112
113 /* sign. For backward compatibility, this is used only
114 * if (flags & RSA_FLAG_SIGN_VER)
115 */
116 int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len,
117 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
118
119 /* verify. For backward compatibility, this is used only
120 * if (flags & RSA_FLAG_SIGN_VER)
121 */
122 int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len,
123 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
124
125 } RSA_METHOD;
126
127=head1 RETURN VALUES
128
129RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(),
130RSA_get_default_method() and RSA_get_method() return pointers to the
131respective B<RSA_METHOD>s.
132
133RSA_set_default_method() returns no value.
134
135RSA_set_method() returns a pointer to the B<RSA_METHOD> previously
136associated with B<rsa>.
137
138RSA_new_method() returns B<NULL> and sets an error code that can be
139obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
140returns a pointer to the newly allocated structure.
141
142=head1 SEE ALSO
143
144L<rsa(3)|rsa(3)>, L<RSA_new(3)|RSA_new(3)>
145
146=head1 HISTORY
147
148RSA_new_method() and RSA_set_default_method() appeared in SSLeay 0.8.
149RSA_get_default_method(), RSA_set_method() and RSA_get_method() as
150well as the rsa_sign and rsa_verify components of RSA_METHOD were
151added in OpenSSL 0.9.4.
152
153=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_sign.pod b/src/lib/libssl/src/doc/crypto/RSA_sign.pod
new file mode 100644
index 0000000000..f0bf6eea1b
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_sign.pod
@@ -0,0 +1,62 @@
1=pod
2
3=head1 NAME
4
5RSA_sign, RSA_verify - RSA signatures
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_sign(int type, unsigned char *m, unsigned int m_len,
12 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
13
14 int RSA_verify(int type, unsigned char *m, unsigned int m_len,
15 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
16
17=head1 DESCRIPTION
18
19RSA_sign() signs the message digest B<m> of size B<m_len> using the
20private key B<rsa> as specified in PKCS #1 v2.0. It stores the
21signature in B<sigret> and the signature size in B<siglen>. B<sigret>
22must point to RSA_size(B<rsa>) bytes of memory.
23
24B<type> denotes the message digest algorithm that was used to generate
25B<m>. It usually is one of B<NID_sha1>, B<NID_ripemd160> and B<NID_md5>;
26see L<objects(3)|objects(3)> for details. If B<type> is B<NID_md5_sha1>,
27an SSL signature (MD5 and SHA1 message digests with PKCS #1 padding
28and no algorithm identifier) is created.
29
30RSA_verify() verifies that the signature B<sigbuf> of size B<siglen>
31matches a given message digest B<m> of size B<m_len>. B<type> denotes
32the message digest algorithm that was used to generate the signature.
33B<rsa> is the signer's public key.
34
35=head1 RETURN VALUES
36
37RSA_sign() returns 1 on success, 0 otherwise. RSA_verify() returns 1
38on successful verification, 0 otherwise.
39
40The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
41
42=head1 BUGS
43
44Certain signatures with an improper algorithm identifier are accepted
45for compatibility with SSLeay 0.4.5 :-)
46
47=head1 CONFORMING TO
48
49SSL, PKCS #1 v2.0
50
51=head1 SEE ALSO
52
53L<err(3)|err(3)>, L<objects(3)|objects(3)>, L<rsa(3)|rsa(3)>,
54L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>,
55L<RSA_public_decrypt(3)|RSA_public_decrypt(3)>
56
57=head1 HISTORY
58
59RSA_sign() and RSA_verify() are available in all versions of SSLeay
60and OpenSSL.
61
62=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod b/src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod
new file mode 100644
index 0000000000..df9ceb339a
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod
@@ -0,0 +1,59 @@
1=pod
2
3=head1 NAME
4
5RSA_sign_ASN1_OCTET_STRING, RSA_verify_ASN1_OCTET_STRING - RSA signatures
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m,
12 unsigned int m_len, unsigned char *sigret, unsigned int *siglen,
13 RSA *rsa);
14
15 int RSA_verify_ASN1_OCTET_STRING(int dummy, unsigned char *m,
16 unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
17 RSA *rsa);
18
19=head1 DESCRIPTION
20
21RSA_sign_ASN1_OCTET_STRING() signs the octet string B<m> of size
22B<m_len> using the private key B<rsa> represented in DER using PKCS #1
23padding. It stores the signature in B<sigret> and the signature size
24in B<siglen>. B<sigret> must point to B<RSA_size(rsa)> bytes of
25memory.
26
27B<dummy> is ignored.
28
29The random number generator must be seeded prior to calling RSA_sign_ASN1_OCTET_STRING().
30
31RSA_verify_ASN1_OCTET_STRING() verifies that the signature B<sigbuf>
32of size B<siglen> is the DER representation of a given octet string
33B<m> of size B<m_len>. B<dummy> is ignored. B<rsa> is the signer's
34public key.
35
36=head1 RETURN VALUES
37
38RSA_sign_ASN1_OCTET_STRING() returns 1 on success, 0 otherwise.
39RSA_verify_ASN1_OCTET_STRING() returns 1 on successful verification, 0
40otherwise.
41
42The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
43
44=head1 BUGS
45
46These functions serve no recognizable purpose.
47
48=head1 SEE ALSO
49
50L<err(3)|err(3)>, L<objects(3)|objects(3)>, L<rand(3)|rand(3)>,
51L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>,
52L<RSA_verify(3)|RSA_verify(3)>
53
54=head1 HISTORY
55
56RSA_sign_ASN1_OCTET_STRING() and RSA_verify_ASN1_OCTET_STRING() were
57added in SSLeay 0.8.
58
59=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_size.pod b/src/lib/libssl/src/doc/crypto/RSA_size.pod
new file mode 100644
index 0000000000..b36b4d58d5
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/RSA_size.pod
@@ -0,0 +1,33 @@
1=pod
2
3=head1 NAME
4
5RSA_size - get RSA modulus size
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 int RSA_size(RSA *rsa);
12
13=head1 DESCRIPTION
14
15This function returns the RSA modulus size in bytes. It can be used to
16determine how much memory must be allocated for an RSA encrypted
17value.
18
19B<rsa-E<gt>n> must not be B<NULL>.
20
21=head1 RETURN VALUE
22
23The size in bytes.
24
25=head1 SEE ALSO
26
27L<rsa(3)|rsa(3)>
28
29=head1 HISTORY
30
31RSA_size() is available in all versions of SSLeay and OpenSSL.
32
33=cut
diff --git a/src/lib/libssl/src/doc/crypto/blowfish.pod b/src/lib/libssl/src/doc/crypto/blowfish.pod
new file mode 100644
index 0000000000..e8c7114311
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/blowfish.pod
@@ -0,0 +1,106 @@
1=pod
2
3=head1 NAME
4
5blowfish, BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt, BF_cbc_encrypt,
6BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options - Blowfish encryption
7
8=head1 SYNOPSIS
9
10 #include <openssl/blowfish.h>
11
12 void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
13
14 void BF_encrypt(BF_LONG *data,const BF_KEY *key);
15 void BF_decrypt(BF_LONG *data,const BF_KEY *key);
16
17 void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
18 BF_KEY *key, int enc);
19 void BF_cbc_encrypt(const unsigned char *in, unsigned char *out,
20 long length, BF_KEY *schedule, unsigned char *ivec, int enc);
21 void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
22 long length, BF_KEY *schedule, unsigned char *ivec, int *num,
23 int enc);
24 void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
25 long length, BF_KEY *schedule, unsigned char *ivec, int *num);
26 const char *BF_options(void);
27
28=head1 DESCRIPTION
29
30This library implements the Blowfish cipher, which is invented and described
31by Counterpane (see http://www.counterpane.com/blowfish/ ).
32
33Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data.
34It uses a variable size key, but typically, 128 bit (16 byte) keys are
35a considered good for strong encryption. Blowfish can be used in the same
36modes as DES (see L<des_modes(7)|des_modes(7)>). Blowfish is currently one
37of the faster block ciphers. It is quite a bit faster than DES, and much
38faster than IDEA or RC2.
39
40Blowfish consists of a key setup phase and the actual encryption or decryption
41phase.
42
43BF_set_key() sets up the B<BF_KEY> B<key> using the B<len> bytes long key
44at B<data>.
45
46BF_encrypt() and BF_decrypt() are the lowest level functions for Blowfish
47encryption. They encrypt/decrypt the first 64 bits of the vector pointed by
48B<data>, using the key B<key>. These functions should not be used unless you
49implement 'modes' of Blowfish.
50
51BF_ecb_encrypt() is the basic Blowfish encryption and decryption function.
52It encrypts or decrypts the first 64 bits of B<in> using the key B<key>,
53putting the result in B<out>. B<enc> decides if encryption (B<BF_ENCRYPT>)
54or decryption (B<BF_DECRYPT>) shall be performed. The vector pointed at by
55B<in> and B<out> must be 64 bits in length, no less. If they are larger,
56everything after the first 64 bits is ignored.
57
58The mode functions BF_cbc_encrypt(), BF_cfb64_encrypt() and BF_ofb64_encrypt()
59all operate on variable length data. They all take an initialisation vector
60B<ivec> which must be initially filled with zeros, but then just need to be
61passed along into the next call of the same function for the same message.
62BF_cbc_encrypt() operates of data that is a multiple of 8 bytes long, while
63BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt an variable
64number of bytes (the amount does not have to be an exact multiple of 8). The
65purpose of the latter two is to simulate stream ciphers, and therefore, they
66need the parameter B<num>, which is a pointer to an integer where the current
67offset in B<ivec> is stored between calls. This integer must be initialised
68to zero when B<ivec> is filled with zeros.
69
70BF_cbc_encrypt() is the Cipher Block Chaining function for Blowfish. It
71encrypts or decrypts the 64 bits chunks of B<in> using the key B<schedule>,
72putting the result in B<out>. B<enc> decides if encryption (BF_ENCRYPT) or
73decryption (BF_DECRYPT) shall be performed. B<ivec> must point at an 8 byte
74long initialisation vector, which must be initially filled with zeros.
75
76BF_cfb64_encrypt() is the CFB mode for Blowfish with 64 bit feedback.
77It encrypts or decrypts the bytes in B<in> using the key B<schedule>,
78putting the result in B<out>. B<enc> decides if encryption (B<BF_ENCRYPT>)
79or decryption (B<BF_DECRYPT>) shall be performed. B<ivec> must point at an
808 byte long initialisation vector, which must be initially filled with zeros.
81B<num> must point at an integer which must be initially zero.
82
83BF_ofb64_encrypt() is the OFB mode for Blowfish with 64 bit feedback.
84It uses the same parameters as BF_cfb64_encrypt(), which must be initialised
85the same way.
86
87=head1 RETURN VALUES
88
89None of the functions presented here return any value.
90
91=head1 NOTE
92
93Applications should use the higher level functions
94L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> etc. instead of calling the
95blowfish functions directly.
96
97=head1 SEE ALSO
98
99L<des_modes(7)|des_modes(7)>
100
101=head1 HISTORY
102
103The Blowfish functions are available in all versions of SSLeay and OpenSSL.
104
105=cut
106
diff --git a/src/lib/libssl/src/doc/crypto/bn.pod b/src/lib/libssl/src/doc/crypto/bn.pod
new file mode 100644
index 0000000000..1504a1c92d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/bn.pod
@@ -0,0 +1,148 @@
1=pod
2
3=head1 NAME
4
5bn - multiprecision integer arithmetics
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 BIGNUM *BN_new(void);
12 void BN_free(BIGNUM *a);
13 void BN_init(BIGNUM *);
14 void BN_clear(BIGNUM *a);
15 void BN_clear_free(BIGNUM *a);
16
17 BN_CTX *BN_CTX_new(void);
18 void BN_CTX_init(BN_CTX *c);
19 void BN_CTX_free(BN_CTX *c);
20
21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
22 BIGNUM *BN_dup(const BIGNUM *a);
23
24 int BN_num_bytes(const BIGNUM *a);
25 int BN_num_bits(const BIGNUM *a);
26 int BN_num_bits_word(BN_ULONG w);
27
28 int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b);
29 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
30 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
31 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
32 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);
35 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
36 BN_CTX *ctx);
37 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
38 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
39 const BIGNUM *m, BN_CTX *ctx);
40 int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
41
42 int BN_add_word(BIGNUM *a, BN_ULONG w);
43 int BN_sub_word(BIGNUM *a, BN_ULONG w);
44 int BN_mul_word(BIGNUM *a, BN_ULONG w);
45 BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
46 BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
47
48 int BN_cmp(BIGNUM *a, BIGNUM *b);
49 int BN_ucmp(BIGNUM *a, BIGNUM *b);
50 int BN_is_zero(BIGNUM *a);
51 int BN_is_one(BIGNUM *a);
52 int BN_is_word(BIGNUM *a, BN_ULONG w);
53 int BN_is_odd(BIGNUM *a);
54
55 int BN_zero(BIGNUM *a);
56 int BN_one(BIGNUM *a);
57 BIGNUM *BN_value_one(void);
58 int BN_set_word(BIGNUM *a, unsigned long w);
59 unsigned long BN_get_word(BIGNUM *a);
60
61 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
62 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
63
64 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add,
65 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
66 int BN_is_prime(const BIGNUM *p, int nchecks,
67 void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg);
68
69 int BN_set_bit(BIGNUM *a, int n);
70 int BN_clear_bit(BIGNUM *a, int n);
71 int BN_is_bit_set(const BIGNUM *a, int n);
72 int BN_mask_bits(BIGNUM *a, int n);
73 int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
74 int BN_lshift1(BIGNUM *r, BIGNUM *a);
75 int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
76 int BN_rshift1(BIGNUM *r, BIGNUM *a);
77
78 int BN_bn2bin(const BIGNUM *a, unsigned char *to);
79 BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
80 char *BN_bn2hex(const BIGNUM *a);
81 char *BN_bn2dec(const BIGNUM *a);
82 int BN_hex2bn(BIGNUM **a, const char *str);
83 int BN_dec2bn(BIGNUM **a, const char *str);
84 int BN_print(BIO *fp, const BIGNUM *a);
85 int BN_print_fp(FILE *fp, const BIGNUM *a);
86 int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
87 BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret);
88
89 BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n,
90 BN_CTX *ctx);
91
92 BN_RECP_CTX *BN_RECP_CTX_new(void);
93 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
94 void BN_RECP_CTX_free(BN_RECP_CTX *recp);
95 int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
96 int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
97 BN_RECP_CTX *recp, BN_CTX *ctx);
98
99 BN_MONT_CTX *BN_MONT_CTX_new(void);
100 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
101 void BN_MONT_CTX_free(BN_MONT_CTX *mont);
102 int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
103 BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
104 int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
105 BN_MONT_CTX *mont, BN_CTX *ctx);
106 int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
107 BN_CTX *ctx);
108 int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
109 BN_CTX *ctx);
110
111
112=head1 DESCRIPTION
113
114This library performs arithmetic operations on integers of arbitrary
115size. It was written for use in public key cryptography, such as RSA
116and Diffie-Hellman.
117
118It uses dynamic memory allocation for storing its data structures.
119That means that there is no limit on the size of the numbers
120manipulated by these functions, but return values must always be
121checked in case a memory allocation error has occurred.
122
123The basic object in this library is a B<BIGNUM>. It is used to hold a
124single large integer. This type should be considered opaque and fields
125should not be modified or accessed directly.
126
127The creation of B<BIGNUM> objects is described in L<BN_new(3)|BN_new(3)>;
128L<BN_add(3)|BN_add(3)> describes most of the arithmetic operations.
129Comparison is described in L<BN_cmp(3)|BN_cmp(3)>; L<BN_zero(3)|BN_zero(3)>
130describes certain assignments, L<BN_rand(3)|BN_rand(3)> the generation of
131random numbers, L<BN_generate_prime(3)|BN_generate_prime(3)> deals with prime
132numbers and L<BN_set_bit(3)|BN_set_bit(3)> with bit operations. The conversion
133of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>.
134
135=head1 SEE ALSO
136
137L<bn_internal(3)|bn_internal(3)>,
138L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
139L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>,
140L<BN_copy(3)|BN_copy(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>,
141L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>,
142L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>,
143L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>,
144L<BN_bn2bin(3)|BN_bn2bin(3)>, L<BN_mod_inverse(3)|BN_mod_inverse(3)>,
145L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>,
146L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)>
147
148=cut
diff --git a/src/lib/libssl/src/doc/crypto/bn_internal.pod b/src/lib/libssl/src/doc/crypto/bn_internal.pod
new file mode 100644
index 0000000000..5af0c791c8
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/bn_internal.pod
@@ -0,0 +1,225 @@
1=pod
2
3=head1 NAME
4
5bn_mul_words, bn_mul_add_words, bn_sqr_words, bn_div_words,
6bn_add_words, bn_sub_words, bn_mul_comba4, bn_mul_comba8,
7bn_sqr_comba4, bn_sqr_comba8, bn_cmp_words, bn_mul_normal,
8bn_mul_low_normal, bn_mul_recursive, bn_mul_part_recursive,
9bn_mul_low_recursive, bn_mul_high, bn_sqr_normal, bn_sqr_recursive,
10bn_expand, bn_wexpand, bn_expand2, bn_fix_top, bn_check_top,
11bn_print, bn_dump, bn_set_max, bn_set_high, bn_set_low - BIGNUM
12library internal functions
13
14=head1 SYNOPSIS
15
16 BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
17 BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num,
18 BN_ULONG w);
19 void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
20 BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
21 BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,
22 int num);
23 BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,
24 int num);
25
26 void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
27 void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
28 void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a);
29 void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a);
30
31 int bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n);
32
33 void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b,
34 int nb);
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,
37 BN_ULONG *tmp);
38 void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
39 int tn, int n, BN_ULONG *tmp);
40 void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
41 int n2, BN_ULONG *tmp);
42 void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l,
43 int n2, BN_ULONG *tmp);
44
45 void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);
46 void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *tmp);
47
48 void mul(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c);
49 void mul_add(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c);
50 void sqr(BN_ULONG r0, BN_ULONG r1, BN_ULONG a);
51
52 BIGNUM *bn_expand(BIGNUM *a, int bits);
53 BIGNUM *bn_wexpand(BIGNUM *a, int n);
54 BIGNUM *bn_expand2(BIGNUM *a, int n);
55 void bn_fix_top(BIGNUM *a);
56
57 void bn_check_top(BIGNUM *a);
58 void bn_print(BIGNUM *a);
59 void bn_dump(BN_ULONG *d, int n);
60 void bn_set_max(BIGNUM *a);
61 void bn_set_high(BIGNUM *r, BIGNUM *a, int n);
62 void bn_set_low(BIGNUM *r, BIGNUM *a, int n);
63
64=head1 DESCRIPTION
65
66This page documents the internal functions used by the OpenSSL
67B<BIGNUM> implementation. They are described here to facilitate
68debugging and extending the library. They are I<not> to be used by
69applications.
70
71=head2 The BIGNUM structure
72
73 typedef struct bignum_st
74 {
75 int top; /* index of last used d (most significant word) */
76 BN_ULONG *d; /* pointer to an array of 'BITS2' bit chunks */
77 int max; /* size of the d array */
78 int neg; /* sign */
79 } BIGNUM;
80
81The big number is stored in B<d>, a malloc()ed array of B<BN_ULONG>s,
82least significant first. A B<BN_ULONG> can be either 16, 32 or 64 bits
83in size (B<BITS2>), depending on the 'number of bits' specified in
84C<openssl/bn.h>.
85
86B<max> is the size of the B<d> array that has been allocated. B<top>
87is the 'last' entry being used, so for a value of 4, bn.d[0]=4 and
88bn.top=1. B<neg> is 1 if the number is negative. When a B<BIGNUM> is
89B<0>, the B<d> field can be B<NULL> and B<top> == B<0>.
90
91Various routines in this library require the use of temporary
92B<BIGNUM> variables during their execution. Since dynamic memory
93allocation to create B<BIGNUM>s is rather expensive when used in
94conjunction with repeated subroutine calls, the B<BN_CTX> structure is
95used. This structure contains B<BN_CTX_NUM> B<BIGNUM>s, see
96L<BN_CTX_start(3)|BN_CTX_start(3)>.
97
98=head2 Low-level arithmetic operations
99
100These functions are implemented in C and for several platforms in
101assembly language:
102
103bn_mul_words(B<rp>, B<ap>, B<num>, B<w>) operates on the B<num> word
104arrays B<rp> and B<ap>. It computes B<ap> * B<w>, places the result
105in B<rp>, and returns the high word (carry).
106
107bn_mul_add_words(B<rp>, B<ap>, B<num>, B<w>) operates on the B<num>
108word arrays B<rp> and B<ap>. It computes B<ap> * B<w> + B<rp>, places
109the result in B<rp>, and returns the high word (carry).
110
111bn_sqr_words(B<rp>, B<ap>, B<n>) operates on the B<num> word array
112B<ap> and the 2*B<num> word array B<ap>. It computes B<ap> * B<ap>
113word-wise, and places the low and high bytes of the result in B<rp>.
114
115bn_div_words(B<h>, B<l>, B<d>) divides the two word number (B<h>,B<l>)
116by B<d> and returns the result.
117
118bn_add_words(B<rp>, B<ap>, B<bp>, B<num>) operates on the B<num> word
119arrays B<ap>, B<bp> and B<rp>. It computes B<ap> + B<bp>, places the
120result in B<rp>, and returns the high word (carry).
121
122bn_sub_words(B<rp>, B<ap>, B<bp>, B<num>) operates on the B<num> word
123arrays B<ap>, B<bp> and B<rp>. It computes B<ap> - B<bp>, places the
124result in B<rp>, and returns the carry (1 if B<bp> E<gt> B<ap>, 0
125otherwise).
126
127bn_mul_comba4(B<r>, B<a>, B<b>) operates on the 4 word arrays B<a> and
128B<b> and the 8 word array B<r>. It computes B<a>*B<b> and places the
129result in B<r>.
130
131bn_mul_comba8(B<r>, B<a>, B<b>) operates on the 8 word arrays B<a> and
132B<b> and the 16 word array B<r>. It computes B<a>*B<b> and places the
133result in B<r>.
134
135bn_sqr_comba4(B<r>, B<a>, B<b>) operates on the 4 word arrays B<a> and
136B<b> and the 8 word array B<r>.
137
138bn_sqr_comba8(B<r>, B<a>, B<b>) operates on the 8 word arrays B<a> and
139B<b> and the 16 word array B<r>.
140
141The following functions are implemented in C:
142
143bn_cmp_words(B<a>, B<b>, B<n>) operates on the B<n> word arrays B<a>
144and B<b>. It returns 1, 0 and -1 if B<a> is greater than, equal and
145less than B<b>.
146
147bn_mul_normal(B<r>, B<a>, B<na>, B<b>, B<nb>) operates on the B<na>
148word array B<a>, the B<nb> word array B<b> and the B<na>+B<nb> word
149array B<r>. It computes B<a>*B<b> and places the result in B<r>.
150
151bn_mul_low_normal(B<r>, B<a>, B<b>, B<n>) operates on the B<n> word
152arrays B<r>, B<a> und B<b>. It computes the B<n> low words of
153B<a>*B<b> and places the result in B<r>.
154
155bn_mul_recursive(B<r>, B<a>, B<b>, B<n2>, B<t>) operates on the B<n2>
156word arrays B<a> and B<b> and the 2*B<n2> word arrays B<r> and B<t>.
157B<n2> must be a power of 2. It computes B<a>*B<b> and places the
158result in B<r>.
159
160bn_mul_part_recursive(B<r>, B<a>, B<b>, B<tn>, B<n>, B<tmp>) operates
161on the B<n>+B<tn> word arrays B<a> and B<b> and the 4*B<n> word arrays
162B<r> and B<tmp>.
163
164bn_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>
166and B<b>.
167
168bn_mul_high(B<r>, B<a>, B<b>, B<l>, B<n2>, B<tmp>) operates on the
169B<n2> word arrays B<r>, B<a>, B<b> and B<l> (?) and the 3*B<n2> word
170array B<tmp>.
171
172BN_mul() calls bn_mul_normal(), or an optimized implementation if the
173factors have the same size: bn_mul_comba8() is used if they are 8
174words long, bn_mul_recursive() if they are larger than
175B<BN_MULL_SIZE_NORMAL> and the size is an exact multiple of the word
176size, and bn_mul_part_recursive() for others that are larger than
177B<BN_MULL_SIZE_NORMAL>.
178
179bn_sqr_normal(B<r>, B<a>, B<n>, B<tmp>) operates on the B<n> word array
180B<a> and the 2*B<n> word arrays B<tmp> and B<r>.
181
182The implementations use the following macros which, depending on the
183architecture, may use "long long" C operations or inline assembler.
184They are defined in C<bn_lcl.h>.
185
186mul(B<r>, B<a>, B<w>, B<c>) computes B<w>*B<a>+B<c> and places the
187low word of the result in B<r> and the high word in B<c>.
188
189mul_add(B<r>, B<a>, B<w>, B<c>) computes B<w>*B<a>+B<r>+B<c> and
190places the low word of the result in B<r> and the high word in B<c>.
191
192sqr(B<r0>, B<r1>, B<a>) computes B<a>*B<a> and places the low word
193of the result in B<r0> and the high word in B<r1>.
194
195=head2 Size changes
196
197bn_expand() ensures that B<b> has enough space for a B<bits> bit
198number. bn_wexpand() ensures that B<b> has enough space for an
199B<n> word number. If the number has to be expanded, both macros
200call bn_expand2(), which allocates a new B<d> array and copies the
201data. They return B<NULL> on error, B<b> otherwise.
202
203The bn_fix_top() macro reduces B<a-E<gt>top> to point to the most
204significant non-zero word when B<a> has shrunk.
205
206=head2 Debugging
207
208bn_check_top() verifies that C<((a)-E<gt>top E<gt>= 0 && (a)-E<gt>top
209E<lt>= (a)-E<gt>max)>. A violation will cause the program to abort.
210
211bn_print() prints B<a> to stderr. bn_dump() prints B<n> words at B<d>
212(in reverse order, i.e. most significant word first) to stderr.
213
214bn_set_max() makes B<a> a static number with a B<max> of its current size.
215This is used by bn_set_low() and bn_set_high() to make B<r> a read-only
216B<BIGNUM> that contains the B<n> low or high words of B<a>.
217
218If B<BN_DEBUG> is not defined, bn_check_top(), bn_print(), bn_dump()
219and bn_set_max() are defined as empty macros.
220
221=head1 SEE ALSO
222
223L<bn(3)|bn(3)>
224
225=cut
diff --git a/src/lib/libssl/src/doc/crypto/buffer.pod b/src/lib/libssl/src/doc/crypto/buffer.pod
new file mode 100644
index 0000000000..7088f51bc4
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/buffer.pod
@@ -0,0 +1,73 @@
1=pod
2
3=head1 NAME
4
5BUF_MEM_new, BUF_MEM_free, BUF_MEM_grow, BUF_strdup - simple
6character arrays structure
7
8=head1 SYNOPSIS
9
10 #include <openssl/buffer.h>
11
12 BUF_MEM *BUF_MEM_new(void);
13
14 void BUF_MEM_free(BUF_MEM *a);
15
16 int BUF_MEM_grow(BUF_MEM *str, int len);
17
18 char * BUF_strdup(const char *str);
19
20=head1 DESCRIPTION
21
22The buffer library handles simple character arrays. Buffers are used for
23various purposes in the library, most notably memory BIOs.
24
25The library uses the BUF_MEM structure defined in buffer.h:
26
27 typedef struct buf_mem_st
28 {
29 int length; /* current number of bytes */
30 char *data;
31 int max; /* size of buffer */
32 } BUF_MEM;
33
34B<length> is the current size of the buffer in bytes, B<max> is the amount of
35memory allocated to the buffer. There are three functions which handle these
36and one "miscellaneous" function.
37
38BUF_MEM_new() allocates a new buffer of zero size.
39
40BUF_MEM_free() frees up an already existing buffer. The data is zeroed
41before freeing up in case the buffer contains sensitive data.
42
43BUF_MEM_grow() changes the size of an already existing buffer to
44B<len>. Any data already in the buffer is preserved if it increases in
45size.
46
47BUF_strdup() copies a null terminated string into a block of allocated
48memory and returns a pointer to the allocated block.
49Unlike the standard C library strdup() this function uses Malloc() and so
50should be used in preference to the standard library strdup() because it can
51be used for memory leak checking or replacing the malloc() function.
52
53The memory allocated from BUF_strdup() should be freed up using the Free()
54function.
55
56=head1 RETURN VALUES
57
58BUF_MEM_new() returns the buffer or NULL on error.
59
60BUF_MEM_free() has no return value.
61
62BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
63
64=head1 SEE ALSO
65
66L<bio(3)|bio(3)>
67
68=head1 HISTORY
69
70BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
71versions of SSLeay and OpenSSL. BUF_strdup() was addded in SSLeay 0.8.
72
73=cut
diff --git a/src/lib/libssl/src/doc/crypto/crypto.pod b/src/lib/libssl/src/doc/crypto/crypto.pod
new file mode 100644
index 0000000000..4b9ceacd91
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/crypto.pod
@@ -0,0 +1,67 @@
1=pod
2
3=head1 NAME
4
5crypto - OpenSSL cryptographic library
6
7=head1 SYNOPSIS
8
9=head1 DESCRIPTION
10
11The OpenSSL B<crypto> library implements a wide range of cryptographic
12algorithms used in various Internet standards. The services provided
13by this library are used by the OpenSSL implementations of SSL, TLS
14and S/MIME, and they have also been used to implement SSH, OpenPGP, and
15other cryptographic standards.
16
17=head1 OVERVIEW
18
19B<libcrypto> consists of a number of sub-libraries that implement the
20individual algorithms.
21
22The functionality includes symmetric encryption, public key
23cryptography and key agreement, certificate handling, cryptographic
24hash functions and a cryptographic pseudo-random number generator.
25
26=over 4
27
28=item SYMMETRIC CIPHERS
29
30L<blowfish(3)|blowfish(3)>, L<cast(3)|cast(3)>, L<des(3)|des(3)>,
31L<idea(3)|idea(3)>, L<rc2(3)|rc2(3)>, L<rc4(3)|rc4(3)>, L<rc5(3)|rc5(3)>
32
33=item PUBLIC KEY CRYPTOGRAPHY AND KEY AGREEMENT
34
35L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>, L<rsa(3)|rsa(3)>
36
37=item CERTIFICATES
38
39L<x509(3)|x509(3)>, L<x509v3(3)|x509v3(3)>
40
41=item AUTHENTICATION CODES, HASH FUNCTIONS
42
43L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>,
44L<ripemd(3)|ripemd(3)>, L<sha(3)|sha(3)>
45
46=item AUXILIARY FUNCTIONS
47
48L<err(3)|err(3)>, L<threads(3)|threads(3)>, L<rand(3)|rand(3)>
49
50=item INPUT/OUTPUT, DATA ENCODING
51
52L<asn1(3)|asn1(3)>, L<bio(3)|bio(3)>, L<evp(3)|evp(3)>, L<pem(3)|pem(3)>,
53L<pkcs7(3)|pkcs7(3)>, L<pkcs12(3)|pkcs12(3)>
54
55=item INTERNAL FUNCTIONS
56
57L<bn(3)|bn(3)>, L<buffer(3)|buffer(3)>, L<lhash(3)|lhash(3)>,
58L<objects(3)|objects(3)>, L<stack(3)|stack(3)>,
59L<txt_db(3)|txt_db(3)>
60
61=back
62
63=head1 SEE ALSO
64
65L<openssl(1)|openssl(1)>, L<ssl(3)|ssl(3)>
66
67=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_DHparams.pod b/src/lib/libssl/src/doc/crypto/d2i_DHparams.pod
new file mode 100644
index 0000000000..a6d1743d39
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_DHparams.pod
@@ -0,0 +1,30 @@
1=pod
2
3=head1 NAME
4
5d2i_DHparams, i2d_DHparams - ...
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH *d2i_DHparams(DH **a, unsigned char **pp, long length);
12 int i2d_DHparams(DH *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16...
17
18=head1 RETURN VALUES
19
20...
21
22=head1 SEE ALSO
23
24...
25
26=head1 HISTORY
27
28...
29
30=cut
diff --git a/src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod b/src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod
new file mode 100644
index 0000000000..ff4d0d57db
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/d2i_RSAPublicKey.pod
@@ -0,0 +1,39 @@
1=pod
2
3=head1 NAME
4
5d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, i2d_Netscape_RSA, d2i_Netscape_RSA - ...
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length);
12
13 int i2d_RSAPublicKey(RSA *a, unsigned char **pp);
14
15 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
16
17 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp);
18
19 int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)());
20
21 RSA * d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)());
22
23=head1 DESCRIPTION
24
25...
26
27=head1 RETURN VALUES
28
29...
30
31=head1 SEE ALSO
32
33...
34
35=head1 HISTORY
36
37...
38
39=cut
diff --git a/src/lib/libssl/src/doc/crypto/des_modes.pod b/src/lib/libssl/src/doc/crypto/des_modes.pod
new file mode 100644
index 0000000000..d8148c86fc
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/des_modes.pod
@@ -0,0 +1,250 @@
1=pod
2
3=head1 NAME
4
5Modes of DES - the variants of DES and other crypto algorithms of OpenSSL
6
7=head1 DESCRIPTION
8
9Several crypto algorithms fo OpenSSL can be used in a number of modes. Those
10are used for using block ciphers in a way similar to stream ciphers, among
11other things.
12
13=head1 OVERVIEW
14
15=head2 Electronic Codebook Mode (ECB)
16
17Normally, this is found as the function I<algorithm>_ecb_encrypt().
18
19=over 2
20
21=item *
22
2364 bits are enciphered at a time.
24
25=item *
26
27The order of the blocks can be rearranged without detection.
28
29=item *
30
31The same plaintext block always produces the same ciphertext block
32(for the same key) making it vulnerable to a 'dictionary attack'.
33
34=item *
35
36An error will only affect one ciphertext block.
37
38=back
39
40=head2 Cipher Block Chaining Mode (CBC)
41
42Normally, this is found as the function I<algorithm>_cbc_encrypt().
43Be aware that des_cbc_encrypt() is not really DES CBC (it does
44not update the IV); use des_ncbc_encrypt() instead.
45
46=over 2
47
48=item *
49
50a multiple of 64 bits are enciphered at a time.
51
52=item *
53
54The CBC mode produces the same ciphertext whenever the same
55plaintext is encrypted using the same key and starting variable.
56
57=item *
58
59The chaining operation makes the ciphertext blocks dependent on the
60current and all preceding plaintext blocks and therefore blocks can not
61be rearranged.
62
63=item *
64
65The use of different starting variables prevents the same plaintext
66enciphering to the same ciphertext.
67
68=item *
69
70An error will affect the current and the following ciphertext blocks.
71
72=back
73
74=head2 Cipher Feedback Mode (CFB)
75
76Normally, this is found as the function I<algorithm>_cfb_encrypt().
77
78=over 2
79
80=item *
81
82a number of bits (j) <= 64 are enciphered at a time.
83
84=item *
85
86The CFB mode produces the same ciphertext whenever the same
87plaintext is encrypted using the same key and starting variable.
88
89=item *
90
91The chaining operation makes the ciphertext variables dependent on the
92current and all preceding variables and therefore j-bit variables are
93chained together and can not be rearranged.
94
95=item *
96
97The use of different starting variables prevents the same plaintext
98enciphering to the same ciphertext.
99
100=item *
101
102The strength of the CFB mode depends on the size of k (maximal if
103j == k). In my implementation this is always the case.
104
105=item *
106
107Selection of a small value for j will require more cycles through
108the encipherment algorithm per unit of plaintext and thus cause
109greater processing overheads.
110
111=item *
112
113Only multiples of j bits can be enciphered.
114
115=item *
116
117An error will affect the current and the following ciphertext variables.
118
119=back
120
121=head2 Output Feedback Mode (OFB)
122
123Normally, this is found as the function I<algorithm>_ofb_encrypt().
124
125=over 2
126
127
128=item *
129
130a number of bits (j) <= 64 are enciphered at a time.
131
132=item *
133
134The OFB mode produces the same ciphertext whenever the same
135plaintext enciphered using the same key and starting variable. More
136over, in the OFB mode the same key stream is produced when the same
137key and start variable are used. Consequently, for security reasons
138a specific start variable should be used only once for a given key.
139
140=item *
141
142The absence of chaining makes the OFB more vulnerable to specific attacks.
143
144=item *
145
146The use of different start variables values prevents the same
147plaintext enciphering to the same ciphertext, by producing different
148key streams.
149
150=item *
151
152Selection of a small value for j will require more cycles through
153the encipherment algorithm per unit of plaintext and thus cause
154greater processing overheads.
155
156=item *
157
158Only multiples of j bits can be enciphered.
159
160=item *
161
162OFB mode of operation does not extend ciphertext errors in the
163resultant plaintext output. Every bit error in the ciphertext causes
164only one bit to be in error in the deciphered plaintext.
165
166=item *
167
168OFB mode is not self-synchronising. If the two operation of
169encipherment and decipherment get out of synchronism, the system needs
170to be re-initialised.
171
172=item *
173
174Each re-initialisation should use a value of the start variable
175different from the start variable values used before with the same
176key. The reason for this is that an identical bit stream would be
177produced each time from the same parameters. This would be
178susceptible to a 'known plaintext' attack.
179
180=back
181
182=head2 Triple ECB Mode
183
184Normally, this is found as the function I<algorithm>_ecb3_encrypt().
185
186=over 2
187
188=item *
189
190Encrypt with key1, decrypt with key2 and encrypt with key3 again.
191
192=item *
193
194As for ECB encryption but increases the key length to 168 bits.
195There are theoretic attacks that can be used that make the effective
196key length 112 bits, but this attack also requires 2^56 blocks of
197memory, not very likely, even for the NSA.
198
199=item *
200
201If both keys are the same it is equivalent to encrypting once with
202just one key.
203
204=item *
205
206If the first and last key are the same, the key length is 112 bits.
207There are attacks that could reduce the key space to 55 bit's but it
208requires 2^56 blocks of memory.
209
210=item *
211
212If all 3 keys are the same, this is effectively the same as normal
213ecb mode.
214
215=back
216
217=head2 Triple CBC Mode
218
219Normally, this is found as the function I<algorithm>_ede3_cbc_encrypt().
220
221=over 2
222
223
224=item *
225
226Encrypt with key1, decrypt with key2 and then encrypt with key3.
227
228=item *
229
230As for CBC encryption but increases the key length to 168 bits with
231the same restrictions as for triple ecb mode.
232
233=back
234
235=head1 NOTES
236
237This text was been written in large parts by Eric Young in his original
238documentation for SSLeay, the predecessor of OpenSSL. In turn, he attributed
239it to:
240
241 AS 2805.5.2
242 Australian Standard
243 Electronic funds transfer - Requirements for interfaces,
244 Part 5.2: Modes of operation for an n-bit block cipher algorithm
245 Appendix A
246
247=head1 SEE ALSO
248
249L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<idea(3)|idea(3)>,
250L<rc2(3)|rc2(3)>
diff --git a/src/lib/libssl/src/doc/crypto/dh.pod b/src/lib/libssl/src/doc/crypto/dh.pod
new file mode 100644
index 0000000000..0a9b7c03a2
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/dh.pod
@@ -0,0 +1,68 @@
1=pod
2
3=head1 NAME
4
5dh - Diffie-Hellman key agreement
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
11 DH * DH_new(void);
12 void DH_free(DH *dh);
13
14 int DH_size(DH *dh);
15
16 DH * DH_generate_parameters(int prime_len, int generator,
17 void (*callback)(int, int, void *), void *cb_arg);
18 int DH_check(DH *dh, int *codes);
19
20 int DH_generate_key(DH *dh);
21 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
22
23 void DH_set_default_method(DH_METHOD *meth);
24 DH_METHOD *DH_get_default_method(void);
25 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
26 DH *DH_new_method(DH_METHOD *meth);
27 DH_METHOD *DH_OpenSSL(void);
28
29 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(),
30 int (*dup_func)(), void (*free_func)());
31 int DH_set_ex_data(DH *d, int idx, char *arg);
32 char *DH_get_ex_data(DH *d, int idx);
33
34 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
35 int i2d_DHparams(DH *a, unsigned char **pp);
36
37 int DHparams_print_fp(FILE *fp, DH *x);
38 int DHparams_print(BIO *bp, DH *x);
39
40=head1 DESCRIPTION
41
42These functions implement the Diffie-Hellman key agreement protocol.
43The generation of shared DH parameters is described in
44L<DH_generate_parameters(3)|DH_generate_parameters(3)>; L<DH_generate_key(3)|DH_generate_key(3)> describes how
45to perform a key agreement.
46
47The B<DH> structure consists of several BIGNUM components.
48
49 struct
50 {
51 BIGNUM *p; // prime number (shared)
52 BIGNUM *g; // generator of Z_p (shared)
53 BIGNUM *priv_key; // private DH value x
54 BIGNUM *pub_key; // public DH value g^x
55 // ...
56 };
57 DH
58
59=head1 SEE ALSO
60
61L<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
62L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<DH_set_method(3)|DH_set_method(3)>,
63L<DH_new(3)|DH_new(3)>, L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>,
64L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
65L<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>,
66L<RSA_print(3)|RSA_print(3)>
67
68=cut
diff --git a/src/lib/libssl/src/doc/crypto/dsa.pod b/src/lib/libssl/src/doc/crypto/dsa.pod
new file mode 100644
index 0000000000..2c09244899
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/dsa.pod
@@ -0,0 +1,104 @@
1=pod
2
3=head1 NAME
4
5dsa - Digital Signature Algorithm
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11 DSA * DSA_new(void);
12 void DSA_free(DSA *dsa);
13
14 int DSA_size(DSA *dsa);
15
16 DSA * DSA_generate_parameters(int bits, unsigned char *seed,
17 int seed_len, int *counter_ret, unsigned long *h_ret,
18 void (*callback)(int, int, void *), void *cb_arg);
19
20 DH * DSA_dup_DH(DSA *r);
21
22 int DSA_generate_key(DSA *dsa);
23
24 int DSA_sign(int dummy, const unsigned char *dgst, int len,
25 unsigned char *sigret, unsigned int *siglen, DSA *dsa);
26 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp,
27 BIGNUM **rp);
28 int DSA_verify(int dummy, const unsigned char *dgst, int len,
29 unsigned char *sigbuf, int siglen, DSA *dsa);
30
31 void DSA_set_default_method(DSA_METHOD *meth);
32 DSA_METHOD *DSA_get_default_method(void);
33 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth);
34 DSA *DSA_new_method(DSA_METHOD *meth);
35 DSA_METHOD *DSA_OpenSSL(void);
36
37 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
38 int (*dup_func)(), void (*free_func)());
39 int DSA_set_ex_data(DSA *d, int idx, char *arg);
40 char *DSA_get_ex_data(DSA *d, int idx);
41
42 DSA_SIG *DSA_SIG_new(void);
43 void DSA_SIG_free(DSA_SIG *a);
44 int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp);
45 DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length);
46
47 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
48 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
49 DSA_SIG *sig, DSA *dsa);
50
51 DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
52 DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
53 DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length);
54 int i2d_DSAPublicKey(DSA *a, unsigned char **pp);
55 int i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
56 int i2d_DSAparams(DSA *a,unsigned char **pp);
57
58 int DSAparams_print(BIO *bp, DSA *x);
59 int DSAparams_print_fp(FILE *fp, DSA *x);
60 int DSA_print(BIO *bp, DSA *x, int off);
61 int DSA_print_fp(FILE *bp, DSA *x, int off);
62
63=head1 DESCRIPTION
64
65These functions implement the Digital Signature Algorithm (DSA). The
66generation of shared DSA parameters is described in
67L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>;
68L<DSA_generate_key(3)|DSA_generate_key(3)> describes how to
69generate a signature key. Signature generation and verification are
70described in L<DSA_sign(3)|DSA_sign(3)>.
71
72The B<DSA> structure consists of several BIGNUM components.
73
74 struct
75 {
76 BIGNUM *p; // prime number (public)
77 BIGNUM *q; // 160-bit subprime, q | p-1 (public)
78 BIGNUM *g; // generator of subgroup (public)
79 BIGNUM *priv_key; // private key x
80 BIGNUM *pub_key; // public key y = g^x
81 // ...
82 }
83 DSA;
84
85In public keys, B<priv_key> is NULL.
86
87=head1 CONFORMING TO
88
89US Federal Information Processing Standard FIPS 186 (Digital Signature
90Standard, DSS), ANSI X9.30
91
92=head1 SEE ALSO
93
94L<bn(3)|bn(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
95L<rsa(3)|rsa(3)>, L<sha(3)|sha(3)>, L<DSA_new(3)|DSA_new(3)>,
96L<DSA_size(3)|DSA_size(3)>,
97L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
98L<DSA_dup_DH(3)|DSA_dup_DH(3)>,
99L<DSA_generate_key(3)|DSA_generate_key(3)>,
100L<DSA_sign(3)|DSA_sign(3)>, L<DSA_set_method(3)|DSA_set_method(3)>,
101L<DSA_get_ex_new_index(3)|DSA_get_ex_new_index(3)>,
102L<RSA_print(3)|RSA_print(3)>
103
104=cut
diff --git a/src/lib/libssl/src/doc/crypto/err.pod b/src/lib/libssl/src/doc/crypto/err.pod
new file mode 100644
index 0000000000..b824c92b57
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/err.pod
@@ -0,0 +1,187 @@
1=pod
2
3=head1 NAME
4
5err - error codes
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 unsigned long ERR_get_error(void);
12 unsigned long ERR_peek_error(void);
13 unsigned long ERR_get_error_line(const char **file, int *line);
14 unsigned long ERR_peek_error_line(const char **file, int *line);
15 unsigned long ERR_get_error_line_data(const char **file, int *line,
16 const char **data, int *flags);
17 unsigned long ERR_peek_error_line_data(const char **file, int *line,
18 const char **data, int *flags);
19
20 int ERR_GET_LIB(unsigned long e);
21 int ERR_GET_FUNC(unsigned long e);
22 int ERR_GET_REASON(unsigned long e);
23
24 void ERR_clear_error(void);
25
26 char *ERR_error_string(unsigned long e, char *buf);
27 const char *ERR_lib_error_string(unsigned long e);
28 const char *ERR_func_error_string(unsigned long e);
29 const char *ERR_reason_error_string(unsigned long e);
30
31 void ERR_print_errors(BIO *bp);
32 void ERR_print_errors_fp(FILE *fp);
33
34 void ERR_load_crypto_strings(void);
35 void ERR_free_strings(void);
36
37 void ERR_remove_state(unsigned long pid);
38
39 void ERR_put_error(int lib, int func, int reason, const char *file,
40 int line);
41 void ERR_add_error_data(int num, ...);
42
43 void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
44 unsigned long ERR_PACK(int lib, int func, int reason);
45 int ERR_get_next_error_library(void);
46
47=head1 DESCRIPTION
48
49When a call to the OpenSSL library fails, this is usually signalled
50by the return value, and an error code is stored in an error queue
51associated with the current thread. The B<err> library provides
52functions to obtain these error codes and textual error messages.
53
54The L<ERR_get_error(3)|ERR_get_error(3)> manpage describes how to
55access error codes.
56
57Error codes contain information about where the error occurred, and
58what went wrong. L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> describes how to
59extract this information. A method to obtain human-readable error
60messages is described in L<ERR_error_string(3)|ERR_error_string(3)>.
61
62L<ERR_clear_error(3)|ERR_clear_error(3)> can be used to clear the
63error queue.
64
65Note that L<ERR_remove_state(3)|ERR_remove_state(3)> should be used to
66avoid memory leaks when threads are terminated.
67
68=head1 ADDING NEW ERROR CODES TO OPENSSL
69
70See L<ERR_put_error(3)> if you want to record error codes in the
71OpenSSL error system from within your application.
72
73The remainder of this section is of interest only if you want to add
74new error codes to OpenSSL or add error codes from external libraries.
75
76=head2 Reporting errors
77
78Each sub-library has a specific macro XXXerr() that is used to report
79errors. Its first argument is a function code B<XXX_F_...>, the second
80argument is a reason code B<XXX_R_...>. Function codes are derived
81from the function names; reason codes consist of textual error
82descriptions. For example, the function ssl23_read() reports a
83"handshake failure" as follows:
84
85 SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE);
86
87Function and reason codes should consist of upper case characters,
88numbers and underscores only. The error file generation script translates
89function codes into function names by looking in the header files
90for an appropriate function name, if none is found it just uses
91the capitalized form such as "SSL23_READ" in the above example.
92
93The trailing section of a reason code (after the "_R_") is translated
94into lower case and underscores changed to spaces.
95
96When you are using new function or reason codes, run B<make errors>.
97The necessary B<#define>s will then automatically be added to the
98sub-library's header file.
99
100Although a library will normally report errors using its own specific
101XXXerr macro, another library's macro can be used. This is normally
102only done when a library wants to include ASN1 code which must use
103the ASN1err() macro.
104
105=head2 Adding new libraries
106
107When adding a new sub-library to OpenSSL, assign it a library number
108B<ERR_LIB_XXX>, define a macro XXXerr() (both in B<err.h>), add its
109name to B<ERR_str_libraries[]> (in B<crypto/err/err.c>), and add
110C<ERR_load_XXX_strings()> to the ERR_load_crypto_strings() function
111(in B<crypto/err/err_all.c>). Finally, add an entry
112
113 L XXX xxx.h xxx_err.c
114
115to B<crypto/err/openssl.ec>, and add B<xxx_err.c> to the Makefile.
116Running B<make errors> will then generate a file B<xxx_err.c>, and
117add all error codes used in the library to B<xxx.h>.
118
119Additionally the library include file must have a certain form.
120Typically it will initially look like this:
121
122 #ifndef HEADER_XXX_H
123 #define HEADER_XXX_H
124
125 #ifdef __cplusplus
126 extern "C" {
127 #endif
128
129 /* Include files */
130
131 #include <openssl/bio.h>
132 #include <openssl/x509.h>
133
134 /* Macros, structures and function prototypes */
135
136
137 /* BEGIN ERROR CODES */
138
139The B<BEGIN ERROR CODES> sequence is used by the error code
140generation script as the point to place new error codes, any text
141after this point will be overwritten when B<make errors> is run.
142The closing #endif etc will be automatically added by the script.
143
144The generated C error code file B<xxx_err.c> will load the header
145files B<stdio.h>, B<openssl/err.h> and B<openssl/xxx.h> so the
146header file must load any additional header files containg any
147definitions it uses.
148
149=head1 USING ERROR CODES IN EXTERNAL LIBRARIES
150
151It is also possible to use OpenSSL's error code scheme in external
152libraries. The library needs to load its own codes and call the OpenSSL
153error code insertion script B<mkerr.pl> explicitly to add codes to
154the header file and generate the C error code file. This will normally
155be done if the external library needs to generate new ASN1 structures
156but it can also be used to add more general purpose error code handling.
157
158TBA more details
159
160=head1 INTERNALS
161
162The error queues are stored in a hash table with one B<ERR_STATE>
163entry for each pid. ERR_get_state() returns the current thread's
164B<ERR_STATE>. An B<ERR_STATE> can hold up to B<ERR_NUM_ERRORS> error
165codes. When more error codes are added, the old ones are overwritten,
166on the assumption that the most recent errors are most important.
167
168Error strings are also stored in hash table. The hash tables can
169be obtained by calling ERR_get_err_state_table(void) and
170ERR_get_string_table(void) respectively.
171
172=head1 SEE ALSO
173
174L<CRYPTO_set_id_callback(3)|CRYPTO_set_id_callback(3)>,
175L<CRYPTO_set_locking_callback(3)|<CRYPTO_set_locking_callback(3)>,
176L<ERR_get_error(3)|ERR_get_error(3)>,
177L<ERR_GET_LIB(3)|ERR_GET_LIB(3)>,
178L<ERR_clear_error(3)|ERR_clear_error(3)>,
179L<ERR_error_string(3)|ERR_error_string(3)>,
180L<ERR_print_errors(3)|ERR_print_errors(3)>,
181L<ERR_load_crypto_strings(3)|ERR_load_crypto_strings(3)>,
182L<ERR_remove_state(3)|ERR_remove_state(3)>,
183L<ERR_put_error(3)|ERR_put_error(3)>,
184L<ERR_load_strings(3)|ERR_load_strings(3)>,
185L<SSL_get_error(3)|SSL_get_error(3)>
186
187=cut
diff --git a/src/lib/libssl/src/doc/crypto/hmac.pod b/src/lib/libssl/src/doc/crypto/hmac.pod
new file mode 100644
index 0000000000..45b6108c39
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/hmac.pod
@@ -0,0 +1,75 @@
1=pod
2
3=head1 NAME
4
5HMAC, HMAC_Init, HMAC_Update, HMAC_Final - HMAC message authentication code
6
7=head1 SYNOPSIS
8
9 #include <openssl/hmac.h>
10
11 unsigned char *HMAC(const EVP_MD *evp_md, const void *key,
12 int key_len, const unsigned char *d, int n,
13 unsigned char *md, unsigned int *md_len);
14
15 void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
16 const EVP_MD *md);
17 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
18 void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
19
20 void HMAC_cleanup(HMAC_CTX *ctx);
21
22=head1 DESCRIPTION
23
24HMAC is a MAC (message authentication code), i.e. a keyed hash
25function used for message authentication, which is based on a hash
26function.
27
28HMAC() computes the message authentication code of the B<n> bytes at
29B<d> using the hash function B<evp_md> and the key B<key> which is
30B<key_len> bytes long.
31
32It places the result in B<md> (which must have space for the output of
33the hash function, which is no more than B<EVP_MAX_MD_SIZE> bytes).
34If B<md> is NULL, the digest is placed in a static array. The size of
35the output is placed in B<md_len>, unless it is B<NULL>.
36
37B<evp_md> can be EVP_sha1(), EVP_ripemd160() etc.
38B<key> and B<evp_md> may be B<NULL> if a key and hash function have
39been set in a previous call to HMAC_Init() for that B<HMAC_CTX>.
40
41HMAC_cleanup() erases the key and other data from the B<HMAC_CTX>.
42
43The following functions may be used if the message is not completely
44stored in memory:
45
46HMAC_Init() initializes a B<HMAC_CTX> structure to use the hash
47function B<evp_md> and the key B<key> which is B<key_len> bytes long.
48
49HMAC_Update() can be called repeatedly with chunks of the message to
50be authenticated (B<len> bytes at B<data>).
51
52HMAC_Final() places the message authentication code in B<md>, which
53must have space for the hash function output.
54
55=head1 RETURN VALUES
56
57HMAC() returns a pointer to the message authentication code.
58
59HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() do not
60return values.
61
62=head1 CONFORMING TO
63
64RFC 2104
65
66=head1 SEE ALSO
67
68L<sha(3)|sha(3)>, L<evp(3)|evp(3)>
69
70=head1 HISTORY
71
72HMAC(), HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup()
73are available since SSLeay 0.9.0.
74
75=cut
diff --git a/src/lib/libssl/src/doc/crypto/lh_stats.pod b/src/lib/libssl/src/doc/crypto/lh_stats.pod
new file mode 100644
index 0000000000..3eeaa72e52
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/lh_stats.pod
@@ -0,0 +1,60 @@
1=pod
2
3=head1 NAME
4
5lh_stats, lh_node_stats, lh_node_usage_stats, lh_stats_bio,
6lh_node_stats_bio, lh_node_usage_stats_bio - LHASH statistics
7
8=head1 SYNOPSIS
9
10 #include <openssl/lhash.h>
11
12 void lh_stats(LHASH *table, FILE *out);
13 void lh_node_stats(LHASH *table, FILE *out);
14 void lh_node_usage_stats(LHASH *table, FILE *out);
15
16 void lh_stats_bio(LHASH *table, BIO *out);
17 void lh_node_stats_bio(LHASH *table, BIO *out);
18 void lh_node_usage_stats_bio(LHASH *table, BIO *out);
19
20=head1 DESCRIPTION
21
22The B<LHASH> structure records statistics about most aspects of
23accessing the hash table. This is mostly a legacy of Eric Young
24writing this library for the reasons of implementing what looked like
25a nice algorithm rather than for a particular software product.
26
27lh_stats() prints out statistics on the size of the hash table, how
28many entries are in it, and the number and result of calls to the
29routines in this library.
30
31lh_node_stats() prints the number of entries for each 'bucket' in the
32hash table.
33
34lh_node_usage_stats() prints out a short summary of the state of the
35hash table. It prints the 'load' and the 'actual load'. The load is
36the average number of data items per 'bucket' in the hash table. The
37'actual load' is the average number of items per 'bucket', but only
38for buckets which contain entries. So the 'actual load' is the
39average number of searches that will need to find an item in the hash
40table, while the 'load' is the average number that will be done to
41record a miss.
42
43lh_stats_bio(), lh_node_stats_bio() and lh_node_usage_stats_bio()
44are the same as the above, except that the output goes to a B<BIO>.
45
46=head1 RETURN VALUES
47
48These functions do not return values.
49
50=head1 SEE ALSO
51
52L<bio(3)|bio(3)>, L<lhash(3)|lhash(3)>
53
54=head1 HISTORY
55
56These functions are available in all versions of SSLeay and OpenSSL.
57
58This manpage is derived from the SSLeay documentation.
59
60=cut
diff --git a/src/lib/libssl/src/doc/crypto/lhash.pod b/src/lib/libssl/src/doc/crypto/lhash.pod
new file mode 100644
index 0000000000..af2c9a7102
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/lhash.pod
@@ -0,0 +1,155 @@
1=pod
2
3=head1 NAME
4
5lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall,
6lh_doall_arg, lh_error - dynamic hash table
7
8=head1 SYNOPSIS
9
10 #include <openssl/lhash.h>
11
12 LHASH *lh_new(unsigned long (*hash)(/*void *a*/),
13 int (*compare)(/*void *a,void *b*/));
14 void lh_free(LHASH *table);
15
16 void *lh_insert(LHASH *table, void *data);
17 void *lh_delete(LHASH *table, void *data);
18 void *lh_retrieve(LHASH *table, void *data);
19
20 void lh_doall(LHASH *table, void (*func)(/*void *b*/));
21 void lh_doall_arg(LHASH *table, void (*func)(/*void *a,void *b*/),
22 void *arg);
23
24 int lh_error(LHASH *table);
25
26=head1 DESCRIPTION
27
28This library implements dynamic hash tables. The hash table entries
29can be arbitrary structures. Usually they consist of key and value
30fields.
31
32lh_new() creates a new B<LHASH> structure. B<hash> takes a pointer to
33the structure and returns an unsigned long hash value of its key
34field. The hash value is normally truncated to a power of 2, so make
35sure that your hash function returns well mixed low order
36bits. B<compare> takes two arguments, and returns 0 if their keys are
37equal, non-zero otherwise.
38
39lh_free() frees the B<LHASH> structure B<table>. Allocated hash table
40entries will not be freed; consider using lh_doall() to deallocate any
41remaining entries in the hash table.
42
43lh_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
45replaced. Note that lh_insert() stores pointers, the data are not
46copied.
47
48lh_delete() deletes an entry from B<table>.
49
50lh_retrieve() looks up an entry in B<table>. Normally, B<data> is
51a structure with the key field(s) set; the function will return a
52pointer to a fully populated structure.
53
54lh_doall() will, for every entry in the hash table, call B<func> with
55the data item as parameters.
56This function can be quite useful when used as follows:
57 void cleanup(STUFF *a)
58 { STUFF_free(a); }
59 lh_doall(hash,cleanup);
60 lh_free(hash);
61This can be used to free all the entries. lh_free() then cleans up the
62'buckets' that point to nothing. When doing this, be careful if you
63delete entries from the hash table in B<func>: the table may decrease
64in size, moving item that you are currently on down lower in the hash
65table. This could cause some entries to be skipped. The best
66solution to this problem is to set hash-E<gt>down_load=0 before you
67start. This will stop the hash table ever being decreased in size.
68
69lh_doall_arg() is the same as lh_doall() except that B<func> will
70be called with B<arg> as the second argument.
71
72lh_error() can be used to determine if an error occurred in the last
73operation. lh_error() is a macro.
74
75=head1 RETURN VALUES
76
77lh_new() returns B<NULL> on error, otherwise a pointer to the new
78B<LHASH> structure.
79
80When a hash table entry is replaced, lh_insert() returns the value
81being replaced. B<NULL> is returned on normal operation and on error.
82
83lh_delete() returns the entry being deleted. B<NULL> is returned if
84there is no such value in the hash table.
85
86lh_retrieve() returns the hash table entry if it has been found,
87B<NULL> otherwise.
88
89lh_error() returns 1 if an error occurred in the last operation, 0
90otherwise.
91
92lh_free(), lh_doall() and lh_doall_arg() return no values.
93
94=head1 BUGS
95
96lh_insert() returns B<NULL> both for success and error.
97
98=head1 INTERNALS
99
100The following description is based on the SSLeay documentation:
101
102The B<lhash> library implements a hash table described in the
103I<Communications of the ACM> in 1991. What makes this hash table
104different is that as the table fills, the hash table is increased (or
105decreased) in size via Realloc(). When a 'resize' is done, instead of
106all hashes being redistributed over twice as many 'buckets', one
107bucket is split. So when an 'expand' is done, there is only a minimal
108cost to redistribute some values. Subsequent inserts will cause more
109single 'bucket' redistributions but there will never be a sudden large
110cost due to redistributing all the 'buckets'.
111
112The state for a particular hash table is kept in the B<LHASH> structure.
113The decision to increase or decrease the hash table size is made
114depending on the 'load' of the hash table. The load is the number of
115items in the hash table divided by the size of the hash table. The
116default values are as follows. If (hash->up_load E<lt> load) =E<gt>
117expand. if (hash-E<gt>down_load E<gt> load) =E<gt> contract. The
118B<up_load> has a default value of 1 and B<down_load> has a default value
119of 2. These numbers can be modified by the application by just
120playing with the B<up_load> and B<down_load> variables. The 'load' is
121kept in a form which is multiplied by 256. So
122hash-E<gt>up_load=8*256; will cause a load of 8 to be set.
123
124If you are interested in performance the field to watch is
125num_comp_calls. The hash library keeps track of the 'hash' value for
126each item so when a lookup is done, the 'hashes' are compared, if
127there is a match, then a full compare is done, and
128hash-E<gt>num_comp_calls is incremented. If num_comp_calls is not equal
129to num_delete plus num_retrieve it means that your hash function is
130generating hashes that are the same for different values. It is
131probably 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
133with 10 B<unsigned long> compares and 10 linked list traverses. This
134will be much less expensive that 10 calls to you compare function.
135
136lh_strhash() is a demo string hashing function:
137
138 unsigned long lh_strhash(const char *c);
139
140Since the B<LHASH> routines would normally be passed structures, this
141routine would not normally be passed to lh_new(), rather it would be
142used in the function passed to lh_new().
143
144=head1 SEE ALSO
145
146L<lh_stats(3)|lh_stats(3)>
147
148=head1 HISTORY
149
150The B<lhash> library is available in all versions of SSLeay and OpenSSL.
151lh_error() was added in SSLeay 0.9.1b.
152
153This manpage is derived from the SSLeay documentation.
154
155=cut
diff --git a/src/lib/libssl/src/doc/crypto/md5.pod b/src/lib/libssl/src/doc/crypto/md5.pod
new file mode 100644
index 0000000000..d7c120023d
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/md5.pod
@@ -0,0 +1,85 @@
1=pod
2
3=head1 NAME
4
5MD2, MD5, MD2_Init, MD2_Update, MD2_Final, MD5_Init, MD5_Update,
6MD5_Final - MD2 and MD5 hash functions
7
8=head1 SYNOPSIS
9
10 #include <openssl/md2.h>
11
12 unsigned char *MD2(const unsigned char *d, unsigned long n,
13 unsigned char *md);
14
15 void MD2_Init(MD2_CTX *c);
16 void MD2_Update(MD2_CTX *c, const unsigned char *data,
17 unsigned long len);
18 void MD2_Final(unsigned char *md, MD2_CTX *c);
19
20
21 #include <openssl/md5.h>
22
23 unsigned char *MD5(const unsigned char *d, unsigned long n,
24 unsigned char *md);
25
26 void MD5_Init(MD5_CTX *c);
27 void MD5_Update(MD5_CTX *c, const void *data,
28 unsigned long len);
29 void MD5_Final(unsigned char *md, MD5_CTX *c);
30
31=head1 DESCRIPTION
32
33MD2 and MD5 are cryptographic hash functions with a 128 bit output.
34
35MD2() and MD5() compute the MD2 and MD5 message digest of the B<n>
36bytes at B<d> and place it in B<md> (which must have space for
37MD2_DIGEST_LENGTH == MD5_DIGEST_LENGTH == 16 bytes of output). If
38B<md> is NULL, the digest is placed in a static array.
39
40The following functions may be used if the message is not completely
41stored in memory:
42
43MD2_Init() initializes a B<MD2_CTX> structure.
44
45MD2_Update() can be called repeatedly with chunks of the message to
46be hashed (B<len> bytes at B<data>).
47
48MD2_Final() places the message digest in B<md>, which must have space
49for MD2_DIGEST_LENGTH == 16 bytes of output, and erases the B<MD2_CTX>.
50
51MD5_Init(), MD5_Update() and MD5_Final() are analogous using an
52B<MD5_CTX> structure.
53
54Applications should use the higher level functions
55L<EVP_DigestInit(3)|EVP_DigestInit(3)>
56etc. instead of calling the hash functions directly.
57
58=head1 NOTE
59
60MD2 and MD5 are recommended only for compatibility with existing
61applications. In new applications, SHA-1 or RIPEMD-160 should be
62preferred.
63
64=head1 RETURN VALUES
65
66MD2() and MD5() return pointers to the hash value.
67
68MD2_Init(), MD2_Update() MD2_Final(), MD5_Init(), MD5_Update() and
69MD5_Final() do not return values.
70
71=head1 CONFORMING TO
72
73RFC 1319, RFC 1321
74
75=head1 SEE ALSO
76
77L<sha(3)|sha(3)>, L<ripemd(3)|ripemd(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>
78
79=head1 HISTORY
80
81MD2(), MD2_Init(), MD2_Update() MD2_Final(), MD5(), MD5_Init(),
82MD5_Update() and MD5_Final() are available in all versions of SSLeay
83and OpenSSL.
84
85=cut
diff --git a/src/lib/libssl/src/doc/crypto/mdc2.pod b/src/lib/libssl/src/doc/crypto/mdc2.pod
new file mode 100644
index 0000000000..11dc303e04
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/mdc2.pod
@@ -0,0 +1,64 @@
1=pod
2
3=head1 NAME
4
5MDC2, MDC2_Init, MDC2_Update, MDC2_Final - MDC2 hash function
6
7=head1 SYNOPSIS
8
9 #include <openssl/mdc2.h>
10
11 unsigned char *MDC2(const unsigned char *d, unsigned long n,
12 unsigned char *md);
13
14 void MDC2_Init(MDC2_CTX *c);
15 void MDC2_Update(MDC2_CTX *c, const unsigned char *data,
16 unsigned long len);
17 void MDC2_Final(unsigned char *md, MDC2_CTX *c);
18
19=head1 DESCRIPTION
20
21MDC2 is a method to construct hash functions with 128 bit output from
22block ciphers. These functions are an implementation of MDC2 with
23DES.
24
25MDC2() computes the MDC2 message digest of the B<n>
26bytes at B<d> and places it in B<md> (which must have space for
27MDC2_DIGEST_LENGTH == 16 bytes of output). If B<md> is NULL, the digest
28is placed in a static array.
29
30The following functions may be used if the message is not completely
31stored in memory:
32
33MDC2_Init() initializes a B<MDC2_CTX> structure.
34
35MDC2_Update() can be called repeatedly with chunks of the message to
36be hashed (B<len> bytes at B<data>).
37
38MDC2_Final() places the message digest in B<md>, which must have space
39for MDC2_DIGEST_LENGTH == 16 bytes of output, and erases the B<MDC2_CTX>.
40
41Applications should use the higher level functions
42L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead of calling the
43hash functions directly.
44
45=head1 RETURN VALUES
46
47MDC2() returns a pointer to the hash value.
48
49MDC2_Init(), MDC2_Update() and MDC2_Final() do not return values.
50
51=head1 CONFORMING TO
52
53ISO/IEC 10118-2, with DES
54
55=head1 SEE ALSO
56
57L<sha(3)|sha(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>
58
59=head1 HISTORY
60
61MDC2(), MDC2_Init(), MDC2_Update() and MDC2_Final() are available since
62SSLeay 0.8.
63
64=cut
diff --git a/src/lib/libssl/src/doc/crypto/rand.pod b/src/lib/libssl/src/doc/crypto/rand.pod
new file mode 100644
index 0000000000..295b681050
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/rand.pod
@@ -0,0 +1,158 @@
1=pod
2
3=head1 NAME
4
5rand - pseudo-random number generator
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 int RAND_bytes(unsigned char *buf,int num);
12 int RAND_pseudo_bytes(unsigned char *buf,int num);
13
14 void RAND_seed(const void *buf,int num);
15 void RAND_add(const void *buf,int num,int entropy);
16 int RAND_status(void);
17 void RAND_screen(void);
18
19 int RAND_load_file(const char *file,long max_bytes);
20 int RAND_write_file(const char *file);
21 const char *RAND_file_name(char *file,int num);
22
23 int RAND_egd(const char *path);
24
25 void RAND_set_rand_method(RAND_METHOD *meth);
26 RAND_METHOD *RAND_get_rand_method(void);
27 RAND_METHOD *RAND_SSLeay(void);
28
29 void RAND_cleanup(void);
30
31=head1 DESCRIPTION
32
33These functions implement a cryptographically secure pseudo-random
34number generator (PRNG). It is used by other library functions for
35example to generate random keys, and applications can use it when they
36need randomness.
37
38A cryptographic PRNG must be seeded with unpredictable data such as
39mouse movements or keys pressed at random by the user. This is
40described in L<RAND_add(3)|RAND_add(3)>. Its state can be saved in a seed file
41(see L<RAND_load_file(3)|RAND_load_file(3)>) to avoid having to go through the
42seeding process whenever the application is started.
43
44L<RAND_bytes(3)|RAND_bytes(3)> describes how to obtain random data from the
45PRNG.
46
47=head1 INTERNALS
48
49The RAND_SSLeay() method implements a PRNG based on a cryptographic
50hash function.
51
52The following description of its design is based on the SSLeay
53documentation:
54
55First up I will state the things I believe I need for a good RNG.
56
57=over 4
58
59=item 1
60
61A good hashing algorithm to mix things up and to convert the RNG 'state'
62to random numbers.
63
64=item 2
65
66An initial source of random 'state'.
67
68=item 3
69
70The state should be very large. If the RNG is being used to generate
714096 bit RSA keys, 2 2048 bit random strings are required (at a minimum).
72If your RNG state only has 128 bits, you are obviously limiting the
73search space to 128 bits, not 2048. I'm probably getting a little
74carried away on this last point but it does indicate that it may not be
75a bad idea to keep quite a lot of RNG state. It should be easier to
76break a cipher than guess the RNG seed data.
77
78=item 4
79
80Any RNG seed data should influence all subsequent random numbers
81generated. This implies that any random seed data entered will have
82an influence on all subsequent random numbers generated.
83
84=item 5
85
86When using data to seed the RNG state, the data used should not be
87extractable from the RNG state. I believe this should be a
88requirement because one possible source of 'secret' semi random
89data would be a private key or a password. This data must
90not be disclosed by either subsequent random numbers or a
91'core' dump left by a program crash.
92
93=item 6
94
95Given the same initial 'state', 2 systems should deviate in their RNG state
96(and hence the random numbers generated) over time if at all possible.
97
98=item 7
99
100Given the random number output stream, it should not be possible to determine
101the RNG state or the next random number.
102
103=back
104
105The algorithm is as follows.
106
107There is global state made up of a 1023 byte buffer (the 'state'), a
108working hash value ('md'), and a counter ('count').
109
110Whenever seed data is added, it is inserted into the 'state' as
111follows.
112
113The input is chopped up into units of 20 bytes (or less for
114the last block). Each of these blocks is run through the hash
115function as follows: The data passed to the hash function
116is the current 'md', the same number of bytes from the 'state'
117(the location determined by in incremented looping index) as
118the current 'block', the new key data 'block', and 'count'
119(which is incremented after each use).
120The result of this is kept in 'md' and also xored into the
121'state' at the same locations that were used as input into the
122hash function. I
123believe this system addresses points 1 (hash function; currently
124SHA-1), 3 (the 'state'), 4 (via the 'md'), 5 (by the use of a hash
125function and xor).
126
127When bytes are extracted from the RNG, the following process is used.
128For each group of 10 bytes (or less), we do the following:
129
130Input into the hash function the top 10 bytes from the local 'md'
131(which is initialized from the global 'md' before any bytes are
132generated), the bytes that are to be overwritten by the random bytes,
133and bytes from the 'state' (incrementing looping index). From this
134digest output (which is kept in 'md'), the top (up to) 10 bytes are
135returned to the caller and the bottom (up to) 10 bytes are xored into
136the 'state'.
137
138Finally, after we have finished 'num' random bytes for the caller,
139'count' (which is incremented) and the local and global 'md' are fed
140into the hash function and the results are kept in the global 'md'.
141
142I believe the above addressed points 1 (use of SHA-1), 6 (by hashing
143into the 'state' the 'old' data from the caller that is about to be
144overwritten) and 7 (by not using the 10 bytes given to the caller to
145update the 'state', but they are used to update 'md').
146
147So of the points raised, only 2 is not addressed (but see
148L<RAND_add(3)|RAND_add(3)>).
149
150=head1 SEE ALSO
151
152L<BN_rand(3)|BN_rand(3)>, L<RAND_add(3)|RAND_add(3)>,
153L<RAND_load_file(3)|RAND_load_file(3)>, L<RAND_egd(3)|RAND_egd(3)>,
154L<RAND_bytes(3)|RAND_bytes(3)>,
155L<RAND_set_rand_method(3)|RAND_set_rand_method(3)>,
156L<RAND_cleanup(3)|RAND_cleanup(3)>
157
158=cut
diff --git a/src/lib/libssl/src/doc/crypto/rc4.pod b/src/lib/libssl/src/doc/crypto/rc4.pod
new file mode 100644
index 0000000000..b6d3a4342c
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/rc4.pod
@@ -0,0 +1,62 @@
1=pod
2
3=head1 NAME
4
5RC4_set_key, RC4 - RC4 encryption
6
7=head1 SYNOPSIS
8
9 #include <openssl/rc4.h>
10
11 void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
12
13 void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
14 unsigned char *outdata);
15
16=head1 DESCRIPTION
17
18This library implements the Alleged RC4 cipher, which is described for
19example in I<Applied Cryptography>. It is believed to be compatible
20with RC4[TM], a proprietary cipher of RSA Security Inc.
21
22RC4 is a stream cipher with variable key length. Typically, 128 bit
23(16 byte) keys are used for strong encryption, but shorter insecure
24key sizes have been widely used due to export restrictions.
25
26RC4 consists of a key setup phase and the actual encryption or
27decryption phase.
28
29RC4_set_key() sets up the B<RC4_KEY> B<key> using the B<len> bytes long
30key at B<data>.
31
32RC4() encrypts or decrypts the B<len> bytes of data at B<indata> using
33B<key> and places the result at B<outdata>. Repeated RC4() calls with
34the same B<key> yield a continuous key stream.
35
36Since RC4 is a stream cipher (the input is XORed with a pseudo-random
37key stream to produce the output), decryption uses the same function
38calls as encryption.
39
40Applications should use the higher level functions
41L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>
42etc. instead of calling the RC4 functions directly.
43
44=head1 RETURN VALUES
45
46RC4_set_key() and RC4() do not return values.
47
48=head1 NOTE
49
50Certain conditions have to be observed to securely use stream ciphers.
51It is not permissible to perform multiple encryptions using the same
52key stream.
53
54=head1 SEE ALSO
55
56L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<rc2(3)|rc2(3)>
57
58=head1 HISTORY
59
60RC4_set_key() and RC4() are available in all versions of SSLeay and OpenSSL.
61
62=cut
diff --git a/src/lib/libssl/src/doc/crypto/ripemd.pod b/src/lib/libssl/src/doc/crypto/ripemd.pod
new file mode 100644
index 0000000000..31054b6a8c
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ripemd.pod
@@ -0,0 +1,66 @@
1=pod
2
3=head1 NAME
4
5RIPEMD160, RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final -
6RIPEMD-160 hash function
7
8=head1 SYNOPSIS
9
10 #include <openssl/ripemd.h>
11
12 unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
13 unsigned char *md);
14
15 void RIPEMD160_Init(RIPEMD160_CTX *c);
16 void RIPEMD160_Update(RIPEMD_CTX *c, const void *data,
17 unsigned long len);
18 void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
19
20=head1 DESCRIPTION
21
22RIPEMD-160 is a cryptographic hash function with a
23160 bit output.
24
25RIPEMD160() computes the RIPEMD-160 message digest of the B<n>
26bytes at B<d> and places it in B<md> (which must have space for
27RIPEMD160_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest
28is placed in a static array.
29
30The following functions may be used if the message is not completely
31stored in memory:
32
33RIPEMD160_Init() initializes a B<RIPEMD160_CTX> structure.
34
35RIPEMD160_Update() can be called repeatedly with chunks of the message to
36be hashed (B<len> bytes at B<data>).
37
38RIPEMD160_Final() places the message digest in B<md>, which must have
39space for RIPEMD160_DIGEST_LENGTH == 20 bytes of output, and erases
40the B<RIPEMD160_CTX>.
41
42Applications should use the higher level functions
43L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead of calling the
44hash functions directly.
45
46=head1 RETURN VALUES
47
48RIPEMD160() returns a pointer to the hash value.
49
50RIPEMD160_Init(), RIPEMD160_Update() and RIPEMD160_Final() do not
51return values.
52
53=head1 CONFORMING TO
54
55ISO/IEC 10118-3 (draft) (??)
56
57=head1 SEE ALSO
58
59L<sha(3)|sha(3)>, L<hmac(3)|hmac(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>
60
61=head1 HISTORY
62
63RIPEMD160(), RIPEMD160_Init(), RIPEMD160_Update() and
64RIPEMD160_Final() are available since SSLeay 0.9.0.
65
66=cut
diff --git a/src/lib/libssl/src/doc/crypto/rsa.pod b/src/lib/libssl/src/doc/crypto/rsa.pod
new file mode 100644
index 0000000000..0486c044a6
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/rsa.pod
@@ -0,0 +1,115 @@
1=pod
2
3=head1 NAME
4
5rsa - RSA public key cryptosystem
6
7=head1 SYNOPSIS
8
9 #include <openssl/rsa.h>
10
11 RSA * RSA_new(void);
12 void RSA_free(RSA *rsa);
13
14 int RSA_public_encrypt(int flen, unsigned char *from,
15 unsigned char *to, RSA *rsa, int padding);
16 int RSA_private_decrypt(int flen, unsigned char *from,
17 unsigned char *to, RSA *rsa, int padding);
18
19 int RSA_sign(int type, unsigned char *m, unsigned int m_len,
20 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
21 int RSA_verify(int type, unsigned char *m, unsigned int m_len,
22 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
23
24 int RSA_size(RSA *rsa);
25
26 RSA *RSA_generate_key(int num, unsigned long e,
27 void (*callback)(int,int,void *), void *cb_arg);
28
29 int RSA_check_key(RSA *rsa);
30
31 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
32 void RSA_blinding_off(RSA *rsa);
33
34 void RSA_set_default_method(RSA_METHOD *meth);
35 RSA_METHOD *RSA_get_default_method(void);
36 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
37 RSA_METHOD *RSA_get_method(RSA *rsa);
38 RSA_METHOD *RSA_PKCS1_SSLeay(void);
39 RSA_METHOD *RSA_PKCS1_RSAref(void);
40 RSA_METHOD *RSA_null_method(void);
41 int RSA_flags(RSA *rsa);
42 RSA *RSA_new_method(RSA_METHOD *method);
43
44 int RSA_print(BIO *bp, RSA *x, int offset);
45 int RSA_print_fp(FILE *fp, RSA *x, int offset);
46
47 int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
48 int (*dup_func)(), void (*free_func)());
49 int RSA_set_ex_data(RSA *r,int idx,char *arg);
50 char *RSA_get_ex_data(RSA *r, int idx);
51
52 int RSA_private_encrypt(int flen, unsigned char *from,
53 unsigned char *to, RSA *rsa,int padding);
54 int RSA_public_decrypt(int flen, unsigned char *from,
55 unsigned char *to, RSA *rsa,int padding);
56
57 int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m,
58 unsigned int m_len, unsigned char *sigret, unsigned int *siglen,
59 RSA *rsa);
60 int RSA_verify_ASN1_OCTET_STRING(int dummy, unsigned char *m,
61 unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
62 RSA *rsa);
63
64=head1 DESCRIPTION
65
66These functions implement RSA public key encryption and signatures
67as defined in PKCS #1 v2.0 [RFC 2437].
68
69The B<RSA> structure consists of several BIGNUM components. It can
70contain public as well as private RSA keys:
71
72 struct
73 {
74 BIGNUM *n; // public modulus
75 BIGNUM *e; // public exponent
76 BIGNUM *d; // private exponent
77 BIGNUM *p; // secret prime factor
78 BIGNUM *q; // secret prime factor
79 BIGNUM *dmp1; // d mod (p-1)
80 BIGNUM *dmq1; // d mod (q-1)
81 BIGNUM *iqmp; // q^-1 mod p
82 // ...
83 };
84 RSA
85
86In public keys, the private exponent and the related secret values are
87B<NULL>.
88
89B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private keys, but the
90RSA operations are much faster when these values are available.
91
92=head1 CONFORMING TO
93
94SSL, PKCS #1 v2.0
95
96=head1 PATENTS
97
98RSA is covered by a US patent which expires in September 2000.
99
100=head1 SEE ALSO
101
102L<rsa(1)|rsa(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>,
103L<rand(3)|rand(3)>, L<RSA_new(3)|RSA_new(3)>,
104L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>,
105L<RSA_sign(3)|RSA_sign(3)>, L<RSA_size(3)|RSA_size(3)>,
106L<RSA_generate_key(3)|RSA_generate_key(3)>,
107L<RSA_check_key(3)|RSA_check_key(3)>,
108L<RSA_blinding_on(3)|RSA_blinding_on(3)>,
109L<RSA_set_method(3)|RSA_set_method(3)>, L<RSA_print(3)|RSA_print(3)>,
110L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>,
111L<RSA_private_encrypt(3)|RSA_private_encrypt(3)>,
112L<RSA_sign_ASN_OCTET_STRING(3)|RSA_sign_ASN_OCTET_STRING(3)>,
113L<RSA_padding_add_PKCS1_type_1(3)|RSA_padding_add_PKCS1_type_1(3)>
114
115=cut
diff --git a/src/lib/libssl/src/doc/crypto/sha.pod b/src/lib/libssl/src/doc/crypto/sha.pod
new file mode 100644
index 0000000000..0ba315d6d7
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/sha.pod
@@ -0,0 +1,70 @@
1=pod
2
3=head1 NAME
4
5SHA1, SHA1_Init, SHA1_Update, SHA1_Final - Secure Hash Algorithm
6
7=head1 SYNOPSIS
8
9 #include <openssl/sha.h>
10
11 unsigned char *SHA1(const unsigned char *d, unsigned long n,
12 unsigned char *md);
13
14 void SHA1_Init(SHA_CTX *c);
15 void SHA1_Update(SHA_CTX *c, const void *data,
16 unsigned long len);
17 void SHA1_Final(unsigned char *md, SHA_CTX *c);
18
19=head1 DESCRIPTION
20
21SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
22160 bit output.
23
24SHA1() computes the SHA-1 message digest of the B<n>
25bytes at B<d> and places it in B<md> (which must have space for
26SHA_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest
27is placed in a static array.
28
29The following functions may be used if the message is not completely
30stored in memory:
31
32SHA1_Init() initializes a B<SHA_CTX> structure.
33
34SHA1_Update() can be called repeatedly with chunks of the message to
35be hashed (B<len> bytes at B<data>).
36
37SHA1_Final() places the message digest in B<md>, which must have space
38for SHA_DIGEST_LENGTH == 20 bytes of output, and erases the B<SHA_CTX>.
39
40Applications should use the higher level functions
41L<EVP_DigestInit(3)|EVP_DigestInit(3)>
42etc. instead of calling the hash functions directly.
43
44The predecessor of SHA-1, SHA, is also implemented, but it should be
45used only when backward compatibility is required.
46
47=head1 RETURN VALUES
48
49SHA1() returns a pointer to the hash value.
50
51SHA1_Init(), SHA1_Update() and SHA1_Final() do not return values.
52
53=head1 CONFORMING TO
54
55SHA: US Federal Information Processing Standard FIPS PUB 180 (Secure Hash
56Standard),
57SHA-1: US Federal Information Processing Standard FIPS PUB 180-1 (Secure Hash
58Standard),
59ANSI X9.30
60
61=head1 SEE ALSO
62
63L<ripemd(3)|ripemd(3)>, L<hmac(3)|hmac(3)>, L<EVP_DigestInit(3)|EVP_DigestInit(3)>
64
65=head1 HISTORY
66
67SHA1(), SHA1_Init(), SHA1_Update() and SHA1_Final() are available in all
68versions of SSLeay and OpenSSL.
69
70=cut
diff --git a/src/lib/libssl/src/doc/crypto/threads.pod b/src/lib/libssl/src/doc/crypto/threads.pod
new file mode 100644
index 0000000000..5da056f3f8
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/threads.pod
@@ -0,0 +1,70 @@
1=pod
2
3=head1 NAME
4
5CRYPTO_set_locking_callback, CRYPTO_set_id_callback - OpenSSL thread support
6
7=head1 SYNOPSIS
8
9 #include <openssl/crypto.h>
10
11 void CRYPTO_set_locking_callback(void (*locking_function)(int mode,
12 int n, const char *file, int line));
13
14 void CRYPTO_set_id_callback(unsigned long (*id_function)(void));
15
16 int CRYPTO_num_locks(void);
17
18=head1 DESCRIPTION
19
20OpenSSL can safely be used in multi-threaded applications provided
21that two callback functions are set.
22
23locking_function(int mode, int n, const char *file, int line) is
24needed to perform locking on shared data stuctures. Multi-threaded
25applications will crash at random if it is not set.
26
27locking_function() must be able to handle up to CRYPTO_num_locks()
28different mutex locks. It sets the B<n>-th lock if B<mode> &
29B<CRYPTO_LOCK>, and releases it otherwise.
30
31B<file> and B<line> are the file number of the function setting the
32lock. They can be useful for debugging.
33
34id_function(void) is a function that returns a thread ID. It is not
35needed on Windows nor on platforms where getpid() returns a different
36ID for each thread (most notably Linux).
37
38=head1 RETURN VALUES
39
40CRYPTO_num_locks() returns the required number of locks.
41The other functions return no values.
42
43=head1 NOTE
44
45You can find out if OpenSSL was configured with thread support:
46
47 #define OPENSSL_THREAD_DEFINES
48 #include <openssl/opensslconf.h>
49 #if defined(THREADS)
50 // thread support enabled
51 #else
52 // no thread support
53 #endif
54
55=head1 EXAMPLES
56
57B<crypto/threads/mttest.c> shows examples of the callback functions on
58Solaris, Irix and Win32.
59
60=head1 HISTORY
61
62CRYPTO_set_locking_callback() and CRYPTO_set_id_callback() are
63available in all versions of SSLeay and OpenSSL.
64CRYPTO_num_locks() was added in OpenSSL 0.9.4.
65
66=head1 SEE ALSO
67
68L<crypto(3)|crypto(3)>
69
70=cut
diff --git a/src/lib/libssl/src/doc/openssl.pod b/src/lib/libssl/src/doc/openssl.pod
index 561f01e0ca..e69de29bb2 100644
--- a/src/lib/libssl/src/doc/openssl.pod
+++ b/src/lib/libssl/src/doc/openssl.pod
@@ -1,304 +0,0 @@
1
2=pod
3
4=head1 NAME
5
6openssl - OpenSSL command line tool
7
8=head1 SYNOPSIS
9
10B<openssl>
11I<command>
12[ I<command_opts> ]
13[ I<command_args> ]
14
15=head1 DESCRIPTION
16
17OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer (SSL
18v2/v3) and Transport Layer Security (TLS v1) network protocols and related
19cryptography standards required by them.
20
21The B<openssl> program is a command line tool for using the various
22cryptography functions of OpenSSL's B<crypto> library from the shell.
23It can be used for
24
25 o Creation of RSA, DH and DSA key parameters
26 o Creation of X.509 certificates, CSRs and CRLs
27 o Calculation of Message Digests
28 o Encryption and Decryption with Ciphers
29 o SSL/TLS Client and Server Tests
30
31=head1 COMMAND SUMMARY
32
33The B<openssl> program provides a rich variety of commands (I<command> in the
34SYNOPSIS above), each of which often has a wealth of options and arguments
35(I<command_opts> and I<command_args> in the SYNOPSIS).
36
37=head2 STANDARD COMMANDS
38
39=over 10
40
41=item B<asn1parse>
42
43Parse an ASN.1 sequence.
44
45=item B<ca>
46
47Certificate Authority (CA) Management.
48
49=item B<ciphers>
50
51Cipher Suite Description Determination.
52
53=item B<crl>
54
55Certificate Revocation List (CRL) Management.
56
57=item B<crl2pkcs7>
58
59CRL2 to PKCS#7 Conversion.
60
61=item B<dgst>
62
63Message Digest Calculation.
64
65=item B<dh>
66
67Diffie-Hellman Data Management.
68
69=item B<dsa>
70
71DSA Data Management.
72
73=item B<dsaparam>
74
75DSA Parameter Generation.
76
77=item B<enc>
78
79Encoding with Ciphers.
80
81=item B<errstr>
82
83Error Number to Error String Conversion.
84
85=item B<gendh>
86
87Generation of Diffie-Hellman Parameters.
88
89=item B<gendsa>
90
91Generation of DSA Parameters.
92
93=item B<genrsa>
94
95Generation of RSA Parameters.
96
97=item B<pkcs7>
98
99PKCS#7 Data Management.
100
101=item B<req>
102
103X.509 Certificate Signing Request (CSR) Management.
104
105=item B<rsa>
106
107RSA Data Management.
108
109=item B<s_client>
110
111This implements a generic SSL/TLS client which can establish a transparent
112connection to a remote server speaking SSL/TLS. It's intended for testing
113purposes only and provides only rudimentary interface functionality but
114internally uses mostly all functionality of the OpenSSL B<ssl> library.
115
116=item B<s_server>
117
118This implements a generic SSL/TLS server which accepts connections from remote
119clients speaking SSL/TLS. It's intended for testing purposes only and provides
120only rudimentary interface functionality but internally uses mostly all
121functionality of the OpenSSL B<ssl> library. It provides both an own command
122line oriented protocol for testing SSL functions and a simple HTTP response
123facility to emulate an SSL/TLS-aware webserver.
124
125=item B<s_time>
126
127SSL Connection Timer.
128
129=item B<sess_id>
130
131SSL Session Data Management.
132
133=item B<speed>
134
135Algorithm Speed Measurement.
136
137=item B<verify>
138
139X.509 Certificate Verification.
140
141=item B<version>
142
143OpenSSL Version Information.
144
145=item B<x509>
146
147X.509 Certificate Data Management.
148
149=back
150
151=head2 MESSAGE DIGEST COMMANDS
152
153=over 10
154
155=item B<md2>
156
157MD2 Digest
158
159=item B<md5>
160
161MD5 Digest
162
163=item B<mdc2>
164
165MDC2 Digest
166
167=item B<rmd160>
168
169RMD-160 Digest
170
171=item B<sha>
172
173SHA Digest
174
175=item B<sha1>
176
177SHA-1 Digest
178
179=back
180
181=head2 ENCODING AND CIPHER COMMANDS
182
183=over 10
184
185=item B<base64>
186
187Base64 Encoding
188
189=item B<bf bf-cbc bf-cfb bf-ecb bf-ofb>
190
191Blowfish Cipher
192
193=item B<cast cast-cbc>
194
195CAST Cipher
196
197=item B<cast5-cbc cast5-cfb cast5-ecb cast5-ofb>
198
199CAST5 Cipher
200
201=item B<des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ofb>
202
203DES Cipher
204
205=item B<des3 desx des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb>
206
207Triple-DES Cipher
208
209=item B<idea idea-cbc idea-cfb idea-ecb idea-ofb>
210
211IDEA Cipher
212
213=item B<rc2 rc2-cbc rc2-cfb rc2-ecb rc2-ofb>
214
215RC2 Cipher
216
217=item B<rc4>
218
219RC4 Cipher
220
221=item B<rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb>
222
223RC5 Cipher
224
225=back
226
227=head1 DETAILED COMMAND DESCRIPTION
228
229The following is a detailed description of every B<openssl> I<command>.
230
231=over 4
232
233=item B<openssl> B<s_client>
234[B<-connect> I<host>B<:>I<port>]
235[B<-verify> I<arg>]
236[B<-cert> I<arg>]
237[B<-key> I<arg>]
238[B<-CApath> I<arg>]
239[B<-CAfile> I<arg>]
240[B<-reconnect>]
241[B<-pause>]
242[B<-debug>]
243[B<-nbio_test>]
244[B<-state>]
245[B<-nbio>]
246[B<-quiet>]
247[B<-ssl2>]
248[B<-ssl3>]
249[B<-tls1>]
250[B<-no_ssl2>]
251[B<-no_ssl3>]
252[B<-no_tls1>]
253[B<-bugs>]
254[B<-cipher>]
255
256The B<s_client> command implements a generic SSL/TLS client which can
257establish a transparent connection to a remote I<host> and I<port> speaking
258SSL/TLS.
259
260=item B<openssl> B<s_server>
261[B<-accept> I<port>]
262[B<-verify> I<arg>]
263[B<-Verify> I<arg>]
264[B<-cert> I<arg>]
265[B<-key> I<arg>]
266[B<-dcert> I<arg>]
267[B<-dkey> I<arg>]
268[B<-nbio>]
269[B<-nbio_test>]
270[B<-debug>]
271[B<-state>]
272[B<-CApath> I<arg>]
273[B<-CAfile> I<arg>]
274[B<-nocert>]
275[B<-cipher> I<arg>]
276[B<-quiet>]
277[B<-no_tmp_rsa>]
278[B<-ssl2>]
279[B<-ssl3>]
280[B<-tls1>]
281[B<-no_ssl2>]
282[B<-no_ssl3>]
283[B<-no_tls1>]
284[B<-bugs>]
285[B<-www>]
286[B<-WWW>]
287
288The B<s_server> command implements a generic SSL/TLS server which accepts
289connections from remote clients on I<port> speaking SSL/TLS.
290
291=back
292
293...
294
295=head1 SEE ALSO
296
297crypto(3), ssl(3)
298
299=head1 HISTORY
300
301The openssl(3) document appeared in OpenSSL 0.9.2
302
303=cut
304
diff --git a/src/lib/libssl/src/doc/openssl.txt b/src/lib/libssl/src/doc/openssl.txt
index 91b85e5f14..880eace4da 100644
--- a/src/lib/libssl/src/doc/openssl.txt
+++ b/src/lib/libssl/src/doc/openssl.txt
@@ -1,53 +1,12 @@
1 1
2This is some preliminary documentation for OpenSSL. 2This is some preliminary documentation for OpenSSL.
3 3
4============================================================================== 4Contents:
5 BUFFER Library
6==============================================================================
7
8The buffer library handles simple character arrays. Buffers are used for
9various purposes in the library, most notably memory BIOs.
10
11The library uses the BUF_MEM structure defined in buffer.h:
12
13typedef struct buf_mem_st
14{
15 int length; /* current number of bytes */
16 char *data;
17 int max; /* size of buffer */
18} BUF_MEM;
19
20'length' is the current size of the buffer in bytes, 'max' is the amount of
21memory allocated to the buffer. There are three functions which handle these
22and one "miscellaneous" function.
23
24BUF_MEM *BUF_MEM_new()
25
26This allocates a new buffer of zero size. Returns the buffer or NULL on error.
27
28void BUF_MEM_free(BUF_MEM *a)
29
30This frees up an already existing buffer. The data is zeroed before freeing
31up in case the buffer contains sensitive data.
32
33int BUF_MEM_grow(BUF_MEM *str, int len)
34
35This changes the size of an already existing buffer. It returns zero on error
36or the new size (i.e. 'len'). Any data already in the buffer is preserved if
37it increases in size.
38
39char * BUF_strdup(char *str)
40 5
41This is the previously mentioned strdup function: like the standard library 6 OpenSSL X509V3 extension configuration
42strdup() it copies a null terminated string into a block of allocated memory 7 X509V3 Extension code: programmers guide
43and returns a pointer to the allocated block. 8 PKCS#12 Library
44 9
45Unlike the standard C library strdup() this function uses Malloc() and so
46should be used in preference to the standard library strdup() because it can
47be used for memory leak checking or replacing the malloc() function.
48
49The memory allocated from BUF_strdup() should be freed up using the Free()
50function.
51 10
52============================================================================== 11==============================================================================
53 OpenSSL X509V3 extension configuration 12 OpenSSL X509V3 extension configuration
@@ -188,7 +147,7 @@ email.1=steve@here
188email.2=steve@there 147email.2=steve@there
189 148
190This is because the configuration file code cannot handle the same name 149This is because the configuration file code cannot handle the same name
191occurring twice in the same extension. 150occurring twice in the same section.
192 151
193The syntax of raw extensions is governed by the extension code: it can 152The syntax of raw extensions is governed by the extension code: it can
194for example contain data in multiple sections. The correct syntax to 153for example contain data in multiple sections. The correct syntax to
@@ -315,6 +274,41 @@ TRUE. An end user certificate MUST NOT have the CA value set to true.
315According to PKIX recommendations it should exclude the extension entirely, 274According to PKIX recommendations it should exclude the extension entirely,
316however some software may require CA set to FALSE for end entity certificates. 275however some software may require CA set to FALSE for end entity certificates.
317 276
277Extended Key Usage.
278
279This extensions consists of a list of usages.
280
281These can either be object short names of the dotted numerical form of OIDs.
282While any OID can be used only certain values make sense. In particular the
283following PKIX, NS and MS values are meaningful:
284
285Value Meaning
286----- -------
287serverAuth SSL/TLS Web Server Authentication.
288clientAuth SSL/TLS Web Client Authentication.
289codeSigning Code signing.
290emailProtection E-mail Protection (S/MIME).
291timeStamping Trusted Timestamping
292msCodeInd Microsoft Individual Code Signing (authenticode)
293msCodeCom Microsoft Commercial Code Signing (authenticode)
294msCTLSign Microsoft Trust List Signing
295msSGC Microsoft Server Gated Crypto
296msEFS Microsoft Encrypted File System
297nsSGC Netscape Server Gated Crypto
298
299For example, under IE5 a CA can be used for any purpose: by including a list
300of the above usages the CA can be restricted to only authorised uses.
301
302Note: software packages may place additional interpretations on certificate
303use, in particular some usages may only work for selected CAs. Don't for example
304expect just including msSGC or nsSGC will automatically mean that a certificate
305can be used for SGC ("step up" encryption) otherwise anyone could use it.
306
307Examples:
308
309extendedKeyUsage=critical,codeSigning,1.2.3.4
310extendedKeyUsage=nsSGC,msSGC
311
318Subject Key Identifier. 312Subject Key Identifier.
319 313
320This is really a string extension and can take two possible values. Either 314This is really a string extension and can take two possible values. Either
@@ -459,16 +453,16 @@ extension in a human or machine readable form.
459 453
4601. Initialisation and cleanup. 4541. Initialisation and cleanup.
461 455
462X509V3_add_standard_extensions(); 456No special initialisation is needed before calling the extension functions.
463 457You used to have to call X509V3_add_standard_extensions(); but this is no longer
464This function should be called before any other extension code. It adds support 458required and this function no longer does anything.
465for some common PKIX and Netscape extensions. Additional custom extensions can
466be added as well (see later).
467 459
468void X509V3_EXT_cleanup(void); 460void X509V3_EXT_cleanup(void);
469 461
470This function should be called last to cleanup the extension code. After this 462This function should be called to cleanup the extension code if any custom
471call no other extension calls should be made. 463extensions have been added. If no custom extensions have been added then this
464call does nothing. After this call all custom extension code is freed up but
465you can still use the standard extensions.
472 466
4732. Printing and parsing extensions. 4672. Printing and parsing extensions.
474 468
@@ -512,7 +506,7 @@ or CRL is due to be signed. Both return 0 on error on non zero for success.
512In each case 'conf' is the LHASH pointer of the configuration file to use 506In each case 'conf' is the LHASH pointer of the configuration file to use
513and 'section' is the section containing the extension details. 507and 'section' is the section containing the extension details.
514 508
515See the 'context functions' section for a description of the ctx paramater. 509See the 'context functions' section for a description of the ctx parameter.
516 510
517 511
518X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, 512X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name,
@@ -531,7 +525,7 @@ takes the NID of the extension rather than its name.
531For example to produce basicConstraints with the CA flag and a path length of 525For example to produce basicConstraints with the CA flag and a path length of
53210: 52610:
533 527
534x = X509V3_EXT_conf_nid(NULL, NULL, NID_basicConstraints, "CA:TRUE,pathlen:10"); 528x = X509V3_EXT_conf_nid(NULL, NULL, NID_basic_constraints,"CA:TRUE,pathlen:10");
535 529
536 530
537X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 531X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
@@ -659,7 +653,7 @@ The same as above but for an unsigned character value.
659int X509V3_add_value_bool(const char *name, int asn1_bool, 653int X509V3_add_value_bool(const char *name, int asn1_bool,
660 STACK_OF(CONF_VALUE) **extlist); 654 STACK_OF(CONF_VALUE) **extlist);
661 655
662This adds either "TRUE" or "FALSE" depending on the value of 'ans1_bool' 656This adds either "TRUE" or "FALSE" depending on the value of 'asn1_bool'
663 657
664int X509V3_add_value_bool_nf(char *name, int asn1_bool, 658int X509V3_add_value_bool_nf(char *name, int asn1_bool,
665 STACK_OF(CONF_VALUE) **extlist); 659 STACK_OF(CONF_VALUE) **extlist);
@@ -686,7 +680,7 @@ Multi value extensions are passed a STACK_OF(CONF_VALUE) name and value pairs
686or return a STACK_OF(CONF_VALUE). 680or return a STACK_OF(CONF_VALUE).
687 681
688Raw extensions are just passed a BIO or a value and it is the extensions 682Raw extensions are just passed a BIO or a value and it is the extensions
689responsiblity to handle all the necessary printing. 683responsibility to handle all the necessary printing.
690 684
691There are two ways to add an extension. One is simply as an alias to an already 685There are two ways to add an extension. One is simply as an alias to an already
692existing extension. An alias is an extension that is identical in ASN1 structure 686existing extension. An alias is an extension that is identical in ASN1 structure
@@ -811,7 +805,7 @@ int i2r(struct v3_ext_method *method, void *ext, BIO *out, int indent);
811 805
812This function is passed the internal extension structure in the ext parameter 806This function is passed the internal extension structure in the ext parameter
813and sends out a human readable version of the extension to out. The 'indent' 807and sends out a human readable version of the extension to out. The 'indent'
814paremeter should be noted to determine the necessary amount of indentation 808parameter should be noted to determine the necessary amount of indentation
815needed on the output. 809needed on the output.
816 810
817void * r2i(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str); 811void * r2i(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str);
@@ -882,7 +876,7 @@ d2i_PKCS12_fp(fp, p12)
882 876
883This is the same but for a FILE pointer. 877This is the same but for a FILE pointer.
884 878
8853. Parsing and creation functions. 8793. High level functions.
886 880
8873.1 Parsing with PKCS12_parse(). 8813.1 Parsing with PKCS12_parse().
888 882
@@ -920,6 +914,14 @@ p12 = PKCS12_create(pass, "My Certificate", pkey, cert, NULL, 0,0,0,0,0);
920i2d_PKCS12_fp(fp, p12); 914i2d_PKCS12_fp(fp, p12);
921PKCS12_free(p12); 915PKCS12_free(p12);
922 916
9173.3 Changing a PKCS#12 structure password.
918
919int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
920
921This changes the password of an already existing PKCS#12 structure. oldpass
922is the old password and newpass is the new one. An error occurs if the old
923password is incorrect.
924
923LOW LEVEL FUNCTIONS. 925LOW LEVEL FUNCTIONS.
924 926
925In some cases the high level functions do not provide the necessary 927In some cases the high level functions do not provide the necessary
diff --git a/src/lib/libssl/src/doc/ssl.pod b/src/lib/libssl/src/doc/ssl.pod
index 46ee443f57..e69de29bb2 100644
--- a/src/lib/libssl/src/doc/ssl.pod
+++ b/src/lib/libssl/src/doc/ssl.pod
@@ -1,633 +0,0 @@
1
2=pod
3
4=head1 NAME
5
6SSL - OpenSSL SSL/TLS library
7
8=head1 SYNOPSIS
9
10=head1 DESCRIPTION
11
12The OpenSSL B<ssl> library implements the Secure Sockets Layer (SSL v2/v3) and
13Transport Layer Security (TLS v1) protocols. It provides a rich API which is
14documented here.
15
16=head1 HEADER FILES
17
18Currently the OpenSSL B<ssl> library provides the following C header files
19containing the prototypes for the data structures and and functions:
20
21=over 4
22
23=item B<ssl.h>
24
25That's the common header file for the SSL/TLS API. Include it into your
26program to make the API of the B<ssl> library available. It internally
27includes both more private SSL headers and headers from the B<crypto> library.
28Whenever you need hard-core details on the internals of the SSL API, look
29inside this header file.
30
31=item B<ssl2.h>
32
33That's the sub header file dealing with the SSLv2 protocol only.
34I<Usually you don't have to include it explicitly because
35it's already included by ssl.h>.
36
37=item B<ssl3.h>
38
39That's the sub header file dealing with the SSLv3 protocol only.
40I<Usually you don't have to include it explicitly because
41it's already included by ssl.h>.
42
43=item B<ssl23.h>
44
45That's the sub header file dealing with the combined use of the SSLv2 and
46SSLv3 protocols.
47I<Usually you don't have to include it explicitly because
48it's already included by ssl.h>.
49
50=item B<tls1.h>
51
52That's the sub header file dealing with the TLSv1 protocol only.
53I<Usually you don't have to include it explicitly because
54it's already included by ssl.h>.
55
56=back
57
58=head1 DATA STRUCTURES
59
60Currently the OpenSSL B<ssl> library functions deals with the following data
61structures:
62
63=over 4
64
65=item B<SSL_METHOD> (SSL Method)
66
67That's a dispatch structure describing the internal B<ssl> library
68methods/functions which implement the various protocol versions (SSLv1, SSLv2
69and TLSv1). It's needed to create an B<SSL_CTX>.
70
71=item B<SSL_CIPHER> (SSL Cipher)
72
73This structure holds the algorithm information for a particular cipher which
74are a core part of the SSL/TLS protocol. The available ciphers are configured
75on a B<SSL_CTX> basis and the actually used ones are then part of the
76B<SSL_SESSION>.
77
78=item B<SSL_CTX> (SSL Context)
79
80That's the global context structure which is created by a server or client
81once per program life-time and which holds mainly default values for the
82B<SSL> structures which are later created for the connections.
83
84=item B<SSL_SESSION> (SSL Session)
85
86This is a structure containing the current SSL session details for a
87connection: B<SSL_CIPHER>s, client and server certificates, keys, etc.
88
89=item B<SSL> (SSL Connection)
90
91That's the main SSL/TLS structure which is created by a server or client per
92established connection. This actually is the core structure in the SSL API.
93Under run-time the application usually deals with this structure which has
94links to mostly all other structures.
95
96=back
97
98=head1 API FUNCTIONS
99
100Currently the OpenSSL B<ssl> library exports 214 API functions.
101They are documented in the following:
102
103=head2 DEALING WITH PROTOCOL METHODS
104
105Here we document the various API functions which deal with the SSL/TLS
106protocol methods defined in B<SSL_METHOD> structures.
107
108=over 4
109
110=item SSL_METHOD *B<SSLv2_client_method>(void);
111
112Constructor for the SSLv2 SSL_METHOD structure for a dedicated client.
113
114=item SSL_METHOD *B<SSLv2_server_method>(void);
115
116Constructor for the SSLv2 SSL_METHOD structure for a dedicated server.
117
118=item SSL_METHOD *B<SSLv2_method>(void);
119
120Constructor for the SSLv2 SSL_METHOD structure for combined client and server.
121
122=item SSL_METHOD *B<SSLv3_client_method>(void);
123
124Constructor for the SSLv3 SSL_METHOD structure for a dedicated client.
125
126=item SSL_METHOD *B<SSLv3_server_method>(void);
127
128Constructor for the SSLv3 SSL_METHOD structure for a dedicated server.
129
130=item SSL_METHOD *B<SSLv3_method>(void);
131
132Constructor for the SSLv3 SSL_METHOD structure for combined client and server.
133
134=item SSL_METHOD *B<TLSv1_client_method>(void);
135
136Constructor for the TLSv1 SSL_METHOD structure for a dedicated client.
137
138=item SSL_METHOD *B<TLSv1_server_method>(void);
139
140Constructor for the TLSv1 SSL_METHOD structure for a dedicated server.
141
142=item SSL_METHOD *B<TLSv1_method>(void);
143
144Constructor for the TLSv1 SSL_METHOD structure for combined client and server.
145
146=back
147
148=head2 DEALING WITH CIPHERS
149
150Here we document the various API functions which deal with the SSL/TLS
151ciphers defined in B<SSL_CIPHER> structures.
152
153=over 4
154
155=item char *B<SSL_CIPHER_description>(SSL_CIPHER *cipher, char *buf, int len);
156
157Write a string to I<buf> (with a maximum size of I<len>) containing a human
158readable description of I<cipher>. Returns I<buf>.
159
160=item int B<SSL_CIPHER_get_bits>(SSL_CIPHER *cipher, int *alg_bits);
161
162Determine the number of bits in I<cipher>. Because of export crippled ciphers
163there are two bits: The bits the algorithm supports in general (stored to
164I<alg_bits>) and the bits which are actually used (the return value).
165
166=item char *B<SSL_CIPHER_get_name>(SSL_CIPHER *cipher);
167
168Return the internal name of I<cipher> as a string. These are the various
169strings defined by the I<SSL2_TXT_xxx>, I<SSL3_TXT_xxx> and I<TLS1_TXT_xxx>
170definitions in the header files.
171
172=item char *B<SSL_CIPHER_get_version>(SSL_CIPHER *cipher);
173
174Returns a string like "C<TLSv1/SSLv3>" or "C<SSLv2>" which indicates the
175SSL/TLS protocol version to which I<cipher> belongs (i.e. where it was defined
176in the specification the first time).
177
178=back
179
180=head2 DEALING WITH PROTOCOL CONTEXTS
181
182Here we document the various API functions which deal with the SSL/TLS
183protocol context defined in the B<SSL_CTX> structure.
184
185=over 4
186
187=item int B<SSL_CTX_add_client_CA>(SSL_CTX *ctx, X509 *x);
188
189=item long B<SSL_CTX_add_extra_chain_cert>(SSL_CTX *ctx, X509 *x509);
190
191=item int B<SSL_CTX_add_session>(SSL_CTX *ctx, SSL_SESSION *c);
192
193=item int B<SSL_CTX_check_private_key>(SSL_CTX *ctx);
194
195=item long B<SSL_CTX_ctrl>(SSL_CTX *ctx, int cmd, long larg, char *parg);
196
197=item void B<SSL_CTX_flush_sessions>(SSL_CTX *s, long t);
198
199=item void B<SSL_CTX_free>(SSL_CTX *a);
200
201=item char *B<SSL_CTX_get_app_data>(SSL_CTX *ctx);
202
203=item X509_STORE *B<SSL_CTX_get_cert_store>(SSL_CTX *ctx);
204
205=item STACK *B<SSL_CTX_get_client_CA_list>(SSL_CTX *ctx);
206
207=item int (*B<SSL_CTX_get_client_cert_cb>(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
208
209=item char *B<SSL_CTX_get_ex_data>(SSL_CTX *s, int idx);
210
211=item int B<SSL_CTX_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
212
213=item void (*B<SSL_CTX_get_info_callback>(SSL_CTX *ctx))(SSL *ssl, int cb, int ret);
214
215=item int B<SSL_CTX_get_quiet_shutdown>(SSL_CTX *ctx);
216
217=item int B<SSL_CTX_get_session_cache_mode>(SSL_CTX *ctx);
218
219=item long B<SSL_CTX_get_timeout>(SSL_CTX *ctx);
220
221=item int (*B<SSL_CTX_get_verify_callback>(SSL_CTX *ctx))(int ok, X509_STORE_CTX *ctx);
222
223=item int B<SSL_CTX_get_verify_mode>(SSL_CTX *ctx);
224
225=item int B<SSL_CTX_load_verify_locations>(SSL_CTX *ctx, char *CAfile, char *CApath);
226
227=item long B<SSL_CTX_need_tmp_RSA>(SSL_CTX *ctx);
228
229=item SSL_CTX *B<SSL_CTX_new>(SSL_METHOD *meth);
230
231=item int B<SSL_CTX_remove_session>(SSL_CTX *ctx, SSL_SESSION *c);
232
233=item int B<SSL_CTX_sess_accept>(SSL_CTX *ctx);
234
235=item int B<SSL_CTX_sess_accept_good>(SSL_CTX *ctx);
236
237=item int B<SSL_CTX_sess_accept_renegotiate>(SSL_CTX *ctx);
238
239=item int B<SSL_CTX_sess_cache_full>(SSL_CTX *ctx);
240
241=item int B<SSL_CTX_sess_cb_hits>(SSL_CTX *ctx);
242
243=item int B<SSL_CTX_sess_connect>(SSL_CTX *ctx);
244
245=item int B<SSL_CTX_sess_connect_good>(SSL_CTX *ctx);
246
247=item int B<SSL_CTX_sess_connect_renegotiate>(SSL_CTX *ctx);
248
249=item int B<SSL_CTX_sess_get_cache_size>(SSL_CTX *ctx);
250
251=item SSL_SESSION *(*B<SSL_CTX_sess_get_get_cb>(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy);
252
253=item int (*B<SSL_CTX_sess_get_new_cb>(SSL_CTX *ctx)(SSL *ssl, SSL_SESSION *sess);
254
255=item void (*B<SSL_CTX_sess_get_remove_cb>(SSL_CTX *ctx)(SSL_CTX *ctx, SSL_SESSION *sess);
256
257=item int B<SSL_CTX_sess_hits>(SSL_CTX *ctx);
258
259=item int B<SSL_CTX_sess_misses>(SSL_CTX *ctx);
260
261=item int B<SSL_CTX_sess_number>(SSL_CTX *ctx);
262
263=item void B<SSL_CTX_sess_set_cache_size>(SSL_CTX *ctx,t);
264
265=item void B<SSL_CTX_sess_set_get_cb>(SSL_CTX *ctx, SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy));
266
267=item void B<SSL_CTX_sess_set_new_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, SSL_SESSION *sess));
268
269=item void B<SSL_CTX_sess_set_remove_cb>(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess));
270
271=item int B<SSL_CTX_sess_timeouts>(SSL_CTX *ctx);
272
273=item LHASH *B<SSL_CTX_sessions>(SSL_CTX *ctx);
274
275=item void B<SSL_CTX_set_app_data>(SSL_CTX *ctx, void *arg);
276
277=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
278
279=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(SSL_CTX *), char *arg)
280
281=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str);
282
283=item void B<SSL_CTX_set_client_CA_list>(SSL_CTX *ctx, STACK *list);
284
285=item void B<SSL_CTX_set_client_cert_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
286
287=item void B<SSL_CTX_set_default_passwd_cb>(SSL_CTX *ctx, int (*cb);(void))
288
289=item void B<SSL_CTX_set_default_read_ahead>(SSL_CTX *ctx, int m);
290
291=item int B<SSL_CTX_set_default_verify_paths>(SSL_CTX *ctx);
292
293=item int B<SSL_CTX_set_ex_data>(SSL_CTX *s, int idx, char *arg);
294
295=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));
296
297=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op);
298
299=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode);
300
301=item void B<SSL_CTX_set_session_cache_mode>(SSL_CTX *ctx, int mode);
302
303=item int B<SSL_CTX_set_ssl_version>(SSL_CTX *ctx, SSL_METHOD *meth);
304
305=item void B<SSL_CTX_set_timeout>(SSL_CTX *ctx, long t);
306
307=item long B<SSL_CTX_set_tmp_dh>(SSL_CTX* ctx, DH *dh);
308
309=item long B<SSL_CTX_set_tmp_dh_callback>(SSL_CTX *ctx, DH *(*cb)(void));
310
311=item long B<SSL_CTX_set_tmp_rsa>(SSL_CTX *ctx, RSA *rsa);
312
313=item SSL_CTX_set_tmp_rsa_callback
314
315C<long B<SSL_CTX_set_tmp_rsa_callback>(SSL_CTX *B<ctx>, RSA *(*B<cb>)(SSL *B<ssl>, int B<export>, int B<keylength>));>
316
317Sets the callback which will be called when a temporary private key is
318required. The B<C<export>> flag will be set if the reason for needing
319a temp key is that an export ciphersuite is in use, in which case,
320B<C<keylength>> will contain the required keylength in bits. Generate a key of
321appropriate size (using ???) and return it.
322
323=item SSL_set_tmp_rsa_callback
324
325long B<SSL_set_tmp_rsa_callback>(SSL *ssl, RSA *(*cb)(SSL *ssl, int export, int keylength));
326
327The same as L<"SSL_CTX_set_tmp_rsa_callback">, except it operates on an SSL
328session instead of a context.
329
330=item void B<SSL_CTX_set_verify>(SSL_CTX *ctx, int mode, int (*cb);(void))
331
332=item int B<SSL_CTX_use_PrivateKey>(SSL_CTX *ctx, EVP_PKEY *pkey);
333
334=item int B<SSL_CTX_use_PrivateKey_ASN1>(int type, SSL_CTX *ctx, unsigned char *d, long len);
335
336=item int B<SSL_CTX_use_PrivateKey_file>(SSL_CTX *ctx, char *file, int type);
337
338=item int B<SSL_CTX_use_RSAPrivateKey>(SSL_CTX *ctx, RSA *rsa);
339
340=item int B<SSL_CTX_use_RSAPrivateKey_ASN1>(SSL_CTX *ctx, unsigned char *d, long len);
341
342=item int B<SSL_CTX_use_RSAPrivateKey_file>(SSL_CTX *ctx, char *file, int type);
343
344=item int B<SSL_CTX_use_certificate>(SSL_CTX *ctx, X509 *x);
345
346=item int B<SSL_CTX_use_certificate_ASN1>(SSL_CTX *ctx, int len, unsigned char *d);
347
348=item int B<SSL_CTX_use_certificate_file>(SSL_CTX *ctx, char *file, int type);
349
350=back
351
352=head2 DEALING WITH SESSIONS
353
354Here we document the various API functions which deal with the SSL/TLS
355sessions defined in the B<SSL_SESSION> structures.
356
357=over 4
358
359=item int B<SSL_SESSION_cmp>(SSL_SESSION *a, SSL_SESSION *b);
360
361=item void B<SSL_SESSION_free>(SSL_SESSION *ss);
362
363=item char *B<SSL_SESSION_get_app_data>(SSL_SESSION *s);
364
365=item char *B<SSL_SESSION_get_ex_data>(SSL_SESSION *s, int idx);
366
367=item int B<SSL_SESSION_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
368
369=item long B<SSL_SESSION_get_time>(SSL_SESSION *s);
370
371=item long B<SSL_SESSION_get_timeout>(SSL_SESSION *s);
372
373=item unsigned long B<SSL_SESSION_hash>(SSL_SESSION *a);
374
375=item SSL_SESSION *B<SSL_SESSION_new>(void);
376
377=item int B<SSL_SESSION_print>(BIO *bp, SSL_SESSION *x);
378
379=item int B<SSL_SESSION_print_fp>(FILE *fp, SSL_SESSION *x);
380
381=item void B<SSL_SESSION_set_app_data>(SSL_SESSION *s, char *a);
382
383=item int B<SSL_SESSION_set_ex_data>(SSL_SESSION *s, int idx, char *arg);
384
385=item long B<SSL_SESSION_set_time>(SSL_SESSION *s, long t);
386
387=item long B<SSL_SESSION_set_timeout>(SSL_SESSION *s, long t);
388
389=back
390
391=head2 DEALING WITH CONNECTIONS
392
393Here we document the various API functions which deal with the SSL/TLS
394connection defined in the B<SSL> structure.
395
396=over 4
397
398=item int B<SSL_accept>(SSL *ssl);
399
400=item int B<SSL_add_dir_cert_subjects_to_stack>(STACK *stack, const char *dir);
401
402=item int B<SSL_add_file_cert_subjects_to_stack>(STACK *stack, const char *file);
403
404=item int B<SSL_add_client_CA>(SSL *ssl, X509 *x);
405
406=item char *B<SSL_alert_desc_string>(int value);
407
408=item char *B<SSL_alert_desc_string_long>(int value);
409
410=item char *B<SSL_alert_type_string>(int value);
411
412=item char *B<SSL_alert_type_string_long>(int value);
413
414=item int B<SSL_check_private_key>(SSL *ssl);
415
416=item void B<SSL_clear>(SSL *ssl);
417
418=item long B<SSL_clear_num_renegotiations>(SSL *ssl);
419
420=item int B<SSL_connect>(SSL *ssl);
421
422=item void B<SSL_copy_session_id>(SSL *t, SSL *f);
423
424=item long B<SSL_ctrl>(SSL *ssl, int cmd, long larg, char *parg);
425
426=item int B<SSL_do_handshake>(SSL *ssl);
427
428=item SSL *B<SSL_dup>(SSL *ssl);
429
430=item STACK *B<SSL_dup_CA_list>(STACK *sk);
431
432=item void B<SSL_free>(SSL *ssl);
433
434=item SSL_CTX *B<SSL_get_SSL_CTX>(SSL *ssl);
435
436=item char *B<SSL_get_app_data>(SSL *ssl);
437
438=item X509 *B<SSL_get_certificate>(SSL *ssl);
439
440=item SSL_CIPHER *B<SSL_get_cipher>(SSL *ssl);
441
442=item int B<SSL_get_cipher_bits>(SSL *ssl, int *alg_bits);
443
444=item char *B<SSL_get_cipher_list>(SSL *ssl, int n);
445
446=item char *B<SSL_get_cipher_name>(SSL *ssl);
447
448=item char *B<SSL_get_cipher_version>(SSL *ssl);
449
450=item STACK *B<SSL_get_ciphers>(SSL *ssl);
451
452=item STACK *B<SSL_get_client_CA_list>(SSL *ssl);
453
454=item SSL_CIPHER *B<SSL_get_current_cipher>(SSL *ssl);
455
456=item long B<SSL_get_default_timeout>(SSL *ssl);
457
458=item int B<SSL_get_error>(SSL *ssl, int i);
459
460=item char *B<SSL_get_ex_data>(SSL *ssl, int idx);
461
462=item int B<SSL_get_ex_data_X509_STORE_CTX_idx>(void);
463
464=item int B<SSL_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
465
466=item int B<SSL_get_fd>(SSL *ssl);
467
468=item void (*B<SSL_get_info_callback>(SSL *ssl);)(void)
469
470=item STACK *B<SSL_get_peer_cert_chain>(SSL *ssl);
471
472=item X509 *B<SSL_get_peer_certificate>(SSL *ssl);
473
474=item EVP_PKEY *B<SSL_get_privatekey>(SSL *ssl);
475
476=item int B<SSL_get_quiet_shutdown>(SSL *ssl);
477
478=item BIO *B<SSL_get_rbio>(SSL *ssl);
479
480=item int B<SSL_get_read_ahead>(SSL *ssl);
481
482=item SSL_SESSION *B<SSL_get_session>(SSL *ssl);
483
484=item char *B<SSL_get_shared_ciphers>(SSL *ssl, char *buf, int len);
485
486=item int B<SSL_get_shutdown>(SSL *ssl);
487
488=item SSL_METHOD *B<SSL_get_ssl_method>(SSL *ssl);
489
490=item int B<SSL_get_state>(SSL *ssl);
491
492=item long B<SSL_get_time>(SSL *ssl);
493
494=item long B<SSL_get_timeout>(SSL *ssl);
495
496=item int (*B<SSL_get_verify_callback>(SSL *ssl);)(void)
497
498=item int B<SSL_get_verify_mode>(SSL *ssl);
499
500=item long B<SSL_get_verify_result>(SSL *ssl);
501
502=item char *B<SSL_get_version>(SSL *ssl);
503
504=item BIO *B<SSL_get_wbio>(SSL *ssl);
505
506=item int B<SSL_in_accept_init>(SSL *ssl);
507
508=item int B<SSL_in_before>(SSL *ssl);
509
510=item int B<SSL_in_connect_init>(SSL *ssl);
511
512=item int B<SSL_in_init>(SSL *ssl);
513
514=item int B<SSL_is_init_finished>(SSL *ssl);
515
516=item STACK *B<SSL_load_client_CA_file>(char *file);
517
518=item void B<SSL_load_error_strings>(void);
519
520=item SSL *B<SSL_new>(SSL_CTX *ctx);
521
522=item long B<SSL_num_renegotiations>(SSL *ssl);
523
524=item int B<SSL_peek>(SSL *ssl, char *buf, int num);
525
526=item int B<SSL_pending>(SSL *ssl);
527
528=item int B<SSL_read>(SSL *ssl, char *buf, int num);
529
530=item int B<SSL_renegotiate>(SSL *ssl);
531
532=item char *B<SSL_rstate_string>(SSL *ssl);
533
534=item char *B<SSL_rstate_string_long>(SSL *ssl);
535
536=item long B<SSL_session_reused>(SSL *ssl);
537
538=item void B<SSL_set_accept_state>(SSL *ssl);
539
540=item void B<SSL_set_app_data>(SSL *ssl, char *arg);
541
542=item void B<SSL_set_bio>(SSL *ssl, BIO *rbio, BIO *wbio);
543
544=item int B<SSL_set_cipher_list>(SSL *ssl, char *str);
545
546=item void B<SSL_set_client_CA_list>(SSL *ssl, STACK *list);
547
548=item void B<SSL_set_connect_state>(SSL *ssl);
549
550=item int B<SSL_set_ex_data>(SSL *ssl, int idx, char *arg);
551
552=item int B<SSL_set_fd>(SSL *ssl, int fd);
553
554=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void))
555
556=item void B<SSL_set_options>(SSL *ssl, unsigned long op);
557
558=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode);
559
560=item void B<SSL_set_read_ahead>(SSL *ssl, int yes);
561
562=item int B<SSL_set_rfd>(SSL *ssl, int fd);
563
564=item int B<SSL_set_session>(SSL *ssl, SSL_SESSION *session);
565
566=item void B<SSL_set_shutdown>(SSL *ssl, int mode);
567
568=item int B<SSL_set_ssl_method>(SSL *ssl, SSL_METHOD *meth);
569
570=item void B<SSL_set_time>(SSL *ssl, long t);
571
572=item void B<SSL_set_timeout>(SSL *ssl, long t);
573
574=item void B<SSL_set_verify>(SSL *ssl, int mode, int (*callback);(void))
575
576=item void B<SSL_set_verify_result>(SSL *ssl, long arg);
577
578=item int B<SSL_set_wfd>(SSL *ssl, int fd);
579
580=item int B<SSL_shutdown>(SSL *ssl);
581
582=item int B<SSL_state>(SSL *ssl);
583
584=item char *B<SSL_state_string>(SSL *ssl);
585
586=item char *B<SSL_state_string_long>(SSL *ssl);
587
588=item long B<SSL_total_renegotiations>(SSL *ssl);
589
590=item int B<SSL_use_PrivateKey>(SSL *ssl, EVP_PKEY *pkey);
591
592=item int B<SSL_use_PrivateKey_ASN1>(int type, SSL *ssl, unsigned char *d, long len);
593
594=item int B<SSL_use_PrivateKey_file>(SSL *ssl, char *file, int type);
595
596=item int B<SSL_use_RSAPrivateKey>(SSL *ssl, RSA *rsa);
597
598=item int B<SSL_use_RSAPrivateKey_ASN1>(SSL *ssl, unsigned char *d, long len);
599
600=item int B<SSL_use_RSAPrivateKey_file>(SSL *ssl, char *file, int type);
601
602=item int B<SSL_use_certificate>(SSL *ssl, X509 *x);
603
604=item int B<SSL_use_certificate_ASN1>(SSL *ssl, int len, unsigned char *d);
605
606=item int B<SSL_use_certificate_file>(SSL *ssl, char *file, int type);
607
608=item int B<SSL_version>(SSL *ssl);
609
610=item int B<SSL_want>(SSL *ssl);
611
612=item int B<SSL_want_nothing>(SSL *ssl);
613
614=item int B<SSL_want_read>(SSL *ssl);
615
616=item int B<SSL_want_write>(SSL *ssl);
617
618=item int B<SSL_want_x509_lookup>(s);
619
620=item int B<SSL_write>(SSL *ssl, char *buf, int num);
621
622=back
623
624=head1 SEE ALSO
625
626openssl(1), crypto(3)
627
628=head1 HISTORY
629
630The ssl(3) document appeared in OpenSSL 0.9.2
631
632=cut
633
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_error.pod b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
new file mode 100644
index 0000000000..9cacdedc57
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
@@ -0,0 +1,91 @@
1=pod
2
3=head1 NAME
4
5SSL_get_error - obtain result code for SSL I/O operation
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_get_error(SSL *ssl, int ret);
12
13=head1 DESCRIPTION
14
15SSL_get_error() returns a result code (suitable for the C "switch"
16statement) for a preceding call to SSL_connect(), SSL_accept(),
17SSL_read(), or SSL_write() on B<ssl>. The value returned by that
18SSL I/O function must be passed to SSL_get_error() in parameter
19B<ret>.
20
21In addition to B<ssl> and B<ret>, SSL_get_error() inspects the
22current thread's OpenSSL error queue. Thus, SSL_get_error() must be
23used in the same thread that performed the SSL I/O operation, and no
24other OpenSSL function calls should appear in between. The current
25thread's error queue must be empty before the SSL I/O operation is
26attempted, or SSL_get_error() will not work reliably.
27
28=head1 RETURN VALUES
29
30The following return values can currently occur:
31
32=over 4
33
34=item SSL_ERROR_NONE
35
36The SSL I/O operation completed. This result code is returned
37if and only if B<ret E<gt> 0>.
38
39=item SSL_ERROR_ZERO_RETURN
40
41The SSL connection has been closed. If the protocol version is SSL 3.0
42or TLS 1.0, this result code is returned only if a closure
43alerts has occurred in the protocol, i.e. if the connection has been
44closed cleanly.
45
46=item SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE
47
48The operation did not complete; the same SSL I/O function should be
49called again later. There will be protocol progress if, by then, the
50underlying B<BIO> has data available for reading (if the result code is
51B<SSL_ERROR_WANT_READ>) or allows writing data (B<SSL_ERROR_WANT_WRITE>).
52For socket B<BIO>s (e.g. when SSL_set_fd() was used) this means that
53select() or poll() on the underlying socket can be used to find out
54when the SSL I/O function should be retried.
55
56Caveat: Any SSL I/O function can lead to either of
57B<SSL_ERROR_WANT_READ> and B<SSL_ERROR_WANT_WRITE>, i.e. SSL_read()
58may want to write data and SSL_write() may want to read data.
59
60=item SSL_ERROR_WANT_X509_LOOKUP
61
62The operation did not complete because an application callback set by
63SSL_CTX_set_client_cert_cb() has asked to be called again.
64The SSL I/O function should be called again later.
65Details depend on the application.
66
67=item SSL_ERROR_SYSCALL
68
69Some I/O error occurred. The OpenSSL error queue may contain more
70information on the error. If the error queue is empty
71(i.e. ERR_get_error() returns 0), B<ret> can be used to find out more
72about the error: If B<ret == 0>, an EOF was observed that violates
73the protocol. If B<ret == -1>, the underlying B<BIO> reported an
74I/O error (for socket I/O on Unix systems, consult B<errno> for details).
75
76=item SSL_ERROR_SSL
77
78A failure in the SSL library occurred, usually a protocol error. The
79OpenSSL error queue contains more information on the error.
80
81=back
82
83=head1 SEE ALSO
84
85L<ssl(3)|ssl(3)>, L<err(3)|err(3)>
86
87=head1 HISTORY
88
89SSL_get_error() was added in SSLeay 0.8.
90
91=cut
diff --git a/src/lib/libssl/src/doc/ssl/ssl.pod b/src/lib/libssl/src/doc/ssl/ssl.pod
new file mode 100644
index 0000000000..e53876654a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/ssl.pod
@@ -0,0 +1,634 @@
1
2=pod
3
4=head1 NAME
5
6SSL - OpenSSL SSL/TLS library
7
8=head1 SYNOPSIS
9
10=head1 DESCRIPTION
11
12The OpenSSL B<ssl> library implements the Secure Sockets Layer (SSL v2/v3) and
13Transport Layer Security (TLS v1) protocols. It provides a rich API which is
14documented here.
15
16=head1 HEADER FILES
17
18Currently the OpenSSL B<ssl> library provides the following C header files
19containing the prototypes for the data structures and and functions:
20
21=over 4
22
23=item B<ssl.h>
24
25That's the common header file for the SSL/TLS API. Include it into your
26program to make the API of the B<ssl> library available. It internally
27includes both more private SSL headers and headers from the B<crypto> library.
28Whenever you need hard-core details on the internals of the SSL API, look
29inside this header file.
30
31=item B<ssl2.h>
32
33That's the sub header file dealing with the SSLv2 protocol only.
34I<Usually you don't have to include it explicitly because
35it's already included by ssl.h>.
36
37=item B<ssl3.h>
38
39That's the sub header file dealing with the SSLv3 protocol only.
40I<Usually you don't have to include it explicitly because
41it's already included by ssl.h>.
42
43=item B<ssl23.h>
44
45That's the sub header file dealing with the combined use of the SSLv2 and
46SSLv3 protocols.
47I<Usually you don't have to include it explicitly because
48it's already included by ssl.h>.
49
50=item B<tls1.h>
51
52That's the sub header file dealing with the TLSv1 protocol only.
53I<Usually you don't have to include it explicitly because
54it's already included by ssl.h>.
55
56=back
57
58=head1 DATA STRUCTURES
59
60Currently the OpenSSL B<ssl> library functions deals with the following data
61structures:
62
63=over 4
64
65=item B<SSL_METHOD> (SSL Method)
66
67That's a dispatch structure describing the internal B<ssl> library
68methods/functions which implement the various protocol versions (SSLv1, SSLv2
69and TLSv1). It's needed to create an B<SSL_CTX>.
70
71=item B<SSL_CIPHER> (SSL Cipher)
72
73This structure holds the algorithm information for a particular cipher which
74are a core part of the SSL/TLS protocol. The available ciphers are configured
75on a B<SSL_CTX> basis and the actually used ones are then part of the
76B<SSL_SESSION>.
77
78=item B<SSL_CTX> (SSL Context)
79
80That's the global context structure which is created by a server or client
81once per program life-time and which holds mainly default values for the
82B<SSL> structures which are later created for the connections.
83
84=item B<SSL_SESSION> (SSL Session)
85
86This is a structure containing the current SSL session details for a
87connection: B<SSL_CIPHER>s, client and server certificates, keys, etc.
88
89=item B<SSL> (SSL Connection)
90
91That's the main SSL/TLS structure which is created by a server or client per
92established connection. This actually is the core structure in the SSL API.
93Under run-time the application usually deals with this structure which has
94links to mostly all other structures.
95
96=back
97
98=head1 API FUNCTIONS
99
100Currently the OpenSSL B<ssl> library exports 214 API functions.
101They are documented in the following:
102
103=head2 DEALING WITH PROTOCOL METHODS
104
105Here we document the various API functions which deal with the SSL/TLS
106protocol methods defined in B<SSL_METHOD> structures.
107
108=over 4
109
110=item SSL_METHOD *B<SSLv2_client_method>(void);
111
112Constructor for the SSLv2 SSL_METHOD structure for a dedicated client.
113
114=item SSL_METHOD *B<SSLv2_server_method>(void);
115
116Constructor for the SSLv2 SSL_METHOD structure for a dedicated server.
117
118=item SSL_METHOD *B<SSLv2_method>(void);
119
120Constructor for the SSLv2 SSL_METHOD structure for combined client and server.
121
122=item SSL_METHOD *B<SSLv3_client_method>(void);
123
124Constructor for the SSLv3 SSL_METHOD structure for a dedicated client.
125
126=item SSL_METHOD *B<SSLv3_server_method>(void);
127
128Constructor for the SSLv3 SSL_METHOD structure for a dedicated server.
129
130=item SSL_METHOD *B<SSLv3_method>(void);
131
132Constructor for the SSLv3 SSL_METHOD structure for combined client and server.
133
134=item SSL_METHOD *B<TLSv1_client_method>(void);
135
136Constructor for the TLSv1 SSL_METHOD structure for a dedicated client.
137
138=item SSL_METHOD *B<TLSv1_server_method>(void);
139
140Constructor for the TLSv1 SSL_METHOD structure for a dedicated server.
141
142=item SSL_METHOD *B<TLSv1_method>(void);
143
144Constructor for the TLSv1 SSL_METHOD structure for combined client and server.
145
146=back
147
148=head2 DEALING WITH CIPHERS
149
150Here we document the various API functions which deal with the SSL/TLS
151ciphers defined in B<SSL_CIPHER> structures.
152
153=over 4
154
155=item char *B<SSL_CIPHER_description>(SSL_CIPHER *cipher, char *buf, int len);
156
157Write a string to I<buf> (with a maximum size of I<len>) containing a human
158readable description of I<cipher>. Returns I<buf>.
159
160=item int B<SSL_CIPHER_get_bits>(SSL_CIPHER *cipher, int *alg_bits);
161
162Determine the number of bits in I<cipher>. Because of export crippled ciphers
163there are two bits: The bits the algorithm supports in general (stored to
164I<alg_bits>) and the bits which are actually used (the return value).
165
166=item char *B<SSL_CIPHER_get_name>(SSL_CIPHER *cipher);
167
168Return the internal name of I<cipher> as a string. These are the various
169strings defined by the I<SSL2_TXT_xxx>, I<SSL3_TXT_xxx> and I<TLS1_TXT_xxx>
170definitions in the header files.
171
172=item char *B<SSL_CIPHER_get_version>(SSL_CIPHER *cipher);
173
174Returns a string like "C<TLSv1/SSLv3>" or "C<SSLv2>" which indicates the
175SSL/TLS protocol version to which I<cipher> belongs (i.e. where it was defined
176in the specification the first time).
177
178=back
179
180=head2 DEALING WITH PROTOCOL CONTEXTS
181
182Here we document the various API functions which deal with the SSL/TLS
183protocol context defined in the B<SSL_CTX> structure.
184
185=over 4
186
187=item int B<SSL_CTX_add_client_CA>(SSL_CTX *ctx, X509 *x);
188
189=item long B<SSL_CTX_add_extra_chain_cert>(SSL_CTX *ctx, X509 *x509);
190
191=item int B<SSL_CTX_add_session>(SSL_CTX *ctx, SSL_SESSION *c);
192
193=item int B<SSL_CTX_check_private_key>(SSL_CTX *ctx);
194
195=item long B<SSL_CTX_ctrl>(SSL_CTX *ctx, int cmd, long larg, char *parg);
196
197=item void B<SSL_CTX_flush_sessions>(SSL_CTX *s, long t);
198
199=item void B<SSL_CTX_free>(SSL_CTX *a);
200
201=item char *B<SSL_CTX_get_app_data>(SSL_CTX *ctx);
202
203=item X509_STORE *B<SSL_CTX_get_cert_store>(SSL_CTX *ctx);
204
205=item STACK *B<SSL_CTX_get_client_CA_list>(SSL_CTX *ctx);
206
207=item int (*B<SSL_CTX_get_client_cert_cb>(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
208
209=item char *B<SSL_CTX_get_ex_data>(SSL_CTX *s, int idx);
210
211=item int B<SSL_CTX_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
212
213=item void (*B<SSL_CTX_get_info_callback>(SSL_CTX *ctx))(SSL *ssl, int cb, int ret);
214
215=item int B<SSL_CTX_get_quiet_shutdown>(SSL_CTX *ctx);
216
217=item int B<SSL_CTX_get_session_cache_mode>(SSL_CTX *ctx);
218
219=item long B<SSL_CTX_get_timeout>(SSL_CTX *ctx);
220
221=item int (*B<SSL_CTX_get_verify_callback>(SSL_CTX *ctx))(int ok, X509_STORE_CTX *ctx);
222
223=item int B<SSL_CTX_get_verify_mode>(SSL_CTX *ctx);
224
225=item int B<SSL_CTX_load_verify_locations>(SSL_CTX *ctx, char *CAfile, char *CApath);
226
227=item long B<SSL_CTX_need_tmp_RSA>(SSL_CTX *ctx);
228
229=item SSL_CTX *B<SSL_CTX_new>(SSL_METHOD *meth);
230
231=item int B<SSL_CTX_remove_session>(SSL_CTX *ctx, SSL_SESSION *c);
232
233=item int B<SSL_CTX_sess_accept>(SSL_CTX *ctx);
234
235=item int B<SSL_CTX_sess_accept_good>(SSL_CTX *ctx);
236
237=item int B<SSL_CTX_sess_accept_renegotiate>(SSL_CTX *ctx);
238
239=item int B<SSL_CTX_sess_cache_full>(SSL_CTX *ctx);
240
241=item int B<SSL_CTX_sess_cb_hits>(SSL_CTX *ctx);
242
243=item int B<SSL_CTX_sess_connect>(SSL_CTX *ctx);
244
245=item int B<SSL_CTX_sess_connect_good>(SSL_CTX *ctx);
246
247=item int B<SSL_CTX_sess_connect_renegotiate>(SSL_CTX *ctx);
248
249=item int B<SSL_CTX_sess_get_cache_size>(SSL_CTX *ctx);
250
251=item SSL_SESSION *(*B<SSL_CTX_sess_get_get_cb>(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy);
252
253=item int (*B<SSL_CTX_sess_get_new_cb>(SSL_CTX *ctx)(SSL *ssl, SSL_SESSION *sess);
254
255=item void (*B<SSL_CTX_sess_get_remove_cb>(SSL_CTX *ctx)(SSL_CTX *ctx, SSL_SESSION *sess);
256
257=item int B<SSL_CTX_sess_hits>(SSL_CTX *ctx);
258
259=item int B<SSL_CTX_sess_misses>(SSL_CTX *ctx);
260
261=item int B<SSL_CTX_sess_number>(SSL_CTX *ctx);
262
263=item void B<SSL_CTX_sess_set_cache_size>(SSL_CTX *ctx,t);
264
265=item void B<SSL_CTX_sess_set_get_cb>(SSL_CTX *ctx, SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy));
266
267=item void B<SSL_CTX_sess_set_new_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, SSL_SESSION *sess));
268
269=item void B<SSL_CTX_sess_set_remove_cb>(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess));
270
271=item int B<SSL_CTX_sess_timeouts>(SSL_CTX *ctx);
272
273=item LHASH *B<SSL_CTX_sessions>(SSL_CTX *ctx);
274
275=item void B<SSL_CTX_set_app_data>(SSL_CTX *ctx, void *arg);
276
277=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
278
279=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(SSL_CTX *), char *arg)
280
281=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str);
282
283=item void B<SSL_CTX_set_client_CA_list>(SSL_CTX *ctx, STACK *list);
284
285=item void B<SSL_CTX_set_client_cert_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
286
287=item void B<SSL_CTX_set_default_passwd_cb>(SSL_CTX *ctx, int (*cb);(void))
288
289=item void B<SSL_CTX_set_default_read_ahead>(SSL_CTX *ctx, int m);
290
291=item int B<SSL_CTX_set_default_verify_paths>(SSL_CTX *ctx);
292
293=item int B<SSL_CTX_set_ex_data>(SSL_CTX *s, int idx, char *arg);
294
295=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));
296
297=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op);
298
299=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode);
300
301=item void B<SSL_CTX_set_session_cache_mode>(SSL_CTX *ctx, int mode);
302
303=item int B<SSL_CTX_set_ssl_version>(SSL_CTX *ctx, SSL_METHOD *meth);
304
305=item void B<SSL_CTX_set_timeout>(SSL_CTX *ctx, long t);
306
307=item long B<SSL_CTX_set_tmp_dh>(SSL_CTX* ctx, DH *dh);
308
309=item long B<SSL_CTX_set_tmp_dh_callback>(SSL_CTX *ctx, DH *(*cb)(void));
310
311=item long B<SSL_CTX_set_tmp_rsa>(SSL_CTX *ctx, RSA *rsa);
312
313=item SSL_CTX_set_tmp_rsa_callback
314
315C<long B<SSL_CTX_set_tmp_rsa_callback>(SSL_CTX *B<ctx>, RSA *(*B<cb>)(SSL *B<ssl>, int B<export>, int B<keylength>));>
316
317Sets the callback which will be called when a temporary private key is
318required. The B<C<export>> flag will be set if the reason for needing
319a temp key is that an export ciphersuite is in use, in which case,
320B<C<keylength>> will contain the required keylength in bits. Generate a key of
321appropriate size (using ???) and return it.
322
323=item SSL_set_tmp_rsa_callback
324
325long B<SSL_set_tmp_rsa_callback>(SSL *ssl, RSA *(*cb)(SSL *ssl, int export, int keylength));
326
327The same as L<"SSL_CTX_set_tmp_rsa_callback">, except it operates on an SSL
328session instead of a context.
329
330=item void B<SSL_CTX_set_verify>(SSL_CTX *ctx, int mode, int (*cb);(void))
331
332=item int B<SSL_CTX_use_PrivateKey>(SSL_CTX *ctx, EVP_PKEY *pkey);
333
334=item int B<SSL_CTX_use_PrivateKey_ASN1>(int type, SSL_CTX *ctx, unsigned char *d, long len);
335
336=item int B<SSL_CTX_use_PrivateKey_file>(SSL_CTX *ctx, char *file, int type);
337
338=item int B<SSL_CTX_use_RSAPrivateKey>(SSL_CTX *ctx, RSA *rsa);
339
340=item int B<SSL_CTX_use_RSAPrivateKey_ASN1>(SSL_CTX *ctx, unsigned char *d, long len);
341
342=item int B<SSL_CTX_use_RSAPrivateKey_file>(SSL_CTX *ctx, char *file, int type);
343
344=item int B<SSL_CTX_use_certificate>(SSL_CTX *ctx, X509 *x);
345
346=item int B<SSL_CTX_use_certificate_ASN1>(SSL_CTX *ctx, int len, unsigned char *d);
347
348=item int B<SSL_CTX_use_certificate_file>(SSL_CTX *ctx, char *file, int type);
349
350=back
351
352=head2 DEALING WITH SESSIONS
353
354Here we document the various API functions which deal with the SSL/TLS
355sessions defined in the B<SSL_SESSION> structures.
356
357=over 4
358
359=item int B<SSL_SESSION_cmp>(SSL_SESSION *a, SSL_SESSION *b);
360
361=item void B<SSL_SESSION_free>(SSL_SESSION *ss);
362
363=item char *B<SSL_SESSION_get_app_data>(SSL_SESSION *s);
364
365=item char *B<SSL_SESSION_get_ex_data>(SSL_SESSION *s, int idx);
366
367=item int B<SSL_SESSION_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
368
369=item long B<SSL_SESSION_get_time>(SSL_SESSION *s);
370
371=item long B<SSL_SESSION_get_timeout>(SSL_SESSION *s);
372
373=item unsigned long B<SSL_SESSION_hash>(SSL_SESSION *a);
374
375=item SSL_SESSION *B<SSL_SESSION_new>(void);
376
377=item int B<SSL_SESSION_print>(BIO *bp, SSL_SESSION *x);
378
379=item int B<SSL_SESSION_print_fp>(FILE *fp, SSL_SESSION *x);
380
381=item void B<SSL_SESSION_set_app_data>(SSL_SESSION *s, char *a);
382
383=item int B<SSL_SESSION_set_ex_data>(SSL_SESSION *s, int idx, char *arg);
384
385=item long B<SSL_SESSION_set_time>(SSL_SESSION *s, long t);
386
387=item long B<SSL_SESSION_set_timeout>(SSL_SESSION *s, long t);
388
389=back
390
391=head2 DEALING WITH CONNECTIONS
392
393Here we document the various API functions which deal with the SSL/TLS
394connection defined in the B<SSL> structure.
395
396=over 4
397
398=item int B<SSL_accept>(SSL *ssl);
399
400=item int B<SSL_add_dir_cert_subjects_to_stack>(STACK *stack, const char *dir);
401
402=item int B<SSL_add_file_cert_subjects_to_stack>(STACK *stack, const char *file);
403
404=item int B<SSL_add_client_CA>(SSL *ssl, X509 *x);
405
406=item char *B<SSL_alert_desc_string>(int value);
407
408=item char *B<SSL_alert_desc_string_long>(int value);
409
410=item char *B<SSL_alert_type_string>(int value);
411
412=item char *B<SSL_alert_type_string_long>(int value);
413
414=item int B<SSL_check_private_key>(SSL *ssl);
415
416=item void B<SSL_clear>(SSL *ssl);
417
418=item long B<SSL_clear_num_renegotiations>(SSL *ssl);
419
420=item int B<SSL_connect>(SSL *ssl);
421
422=item void B<SSL_copy_session_id>(SSL *t, SSL *f);
423
424=item long B<SSL_ctrl>(SSL *ssl, int cmd, long larg, char *parg);
425
426=item int B<SSL_do_handshake>(SSL *ssl);
427
428=item SSL *B<SSL_dup>(SSL *ssl);
429
430=item STACK *B<SSL_dup_CA_list>(STACK *sk);
431
432=item void B<SSL_free>(SSL *ssl);
433
434=item SSL_CTX *B<SSL_get_SSL_CTX>(SSL *ssl);
435
436=item char *B<SSL_get_app_data>(SSL *ssl);
437
438=item X509 *B<SSL_get_certificate>(SSL *ssl);
439
440=item SSL_CIPHER *B<SSL_get_cipher>(SSL *ssl);
441
442=item int B<SSL_get_cipher_bits>(SSL *ssl, int *alg_bits);
443
444=item char *B<SSL_get_cipher_list>(SSL *ssl, int n);
445
446=item char *B<SSL_get_cipher_name>(SSL *ssl);
447
448=item char *B<SSL_get_cipher_version>(SSL *ssl);
449
450=item STACK *B<SSL_get_ciphers>(SSL *ssl);
451
452=item STACK *B<SSL_get_client_CA_list>(SSL *ssl);
453
454=item SSL_CIPHER *B<SSL_get_current_cipher>(SSL *ssl);
455
456=item long B<SSL_get_default_timeout>(SSL *ssl);
457
458=item int B<SSL_get_error>(SSL *ssl, int i);
459
460=item char *B<SSL_get_ex_data>(SSL *ssl, int idx);
461
462=item int B<SSL_get_ex_data_X509_STORE_CTX_idx>(void);
463
464=item int B<SSL_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
465
466=item int B<SSL_get_fd>(SSL *ssl);
467
468=item void (*B<SSL_get_info_callback>(SSL *ssl);)(void)
469
470=item STACK *B<SSL_get_peer_cert_chain>(SSL *ssl);
471
472=item X509 *B<SSL_get_peer_certificate>(SSL *ssl);
473
474=item EVP_PKEY *B<SSL_get_privatekey>(SSL *ssl);
475
476=item int B<SSL_get_quiet_shutdown>(SSL *ssl);
477
478=item BIO *B<SSL_get_rbio>(SSL *ssl);
479
480=item int B<SSL_get_read_ahead>(SSL *ssl);
481
482=item SSL_SESSION *B<SSL_get_session>(SSL *ssl);
483
484=item char *B<SSL_get_shared_ciphers>(SSL *ssl, char *buf, int len);
485
486=item int B<SSL_get_shutdown>(SSL *ssl);
487
488=item SSL_METHOD *B<SSL_get_ssl_method>(SSL *ssl);
489
490=item int B<SSL_get_state>(SSL *ssl);
491
492=item long B<SSL_get_time>(SSL *ssl);
493
494=item long B<SSL_get_timeout>(SSL *ssl);
495
496=item int (*B<SSL_get_verify_callback>(SSL *ssl);)(void)
497
498=item int B<SSL_get_verify_mode>(SSL *ssl);
499
500=item long B<SSL_get_verify_result>(SSL *ssl);
501
502=item char *B<SSL_get_version>(SSL *ssl);
503
504=item BIO *B<SSL_get_wbio>(SSL *ssl);
505
506=item int B<SSL_in_accept_init>(SSL *ssl);
507
508=item int B<SSL_in_before>(SSL *ssl);
509
510=item int B<SSL_in_connect_init>(SSL *ssl);
511
512=item int B<SSL_in_init>(SSL *ssl);
513
514=item int B<SSL_is_init_finished>(SSL *ssl);
515
516=item STACK *B<SSL_load_client_CA_file>(char *file);
517
518=item void B<SSL_load_error_strings>(void);
519
520=item SSL *B<SSL_new>(SSL_CTX *ctx);
521
522=item long B<SSL_num_renegotiations>(SSL *ssl);
523
524=item int B<SSL_peek>(SSL *ssl, char *buf, int num);
525
526=item int B<SSL_pending>(SSL *ssl);
527
528=item int B<SSL_read>(SSL *ssl, char *buf, int num);
529
530=item int B<SSL_renegotiate>(SSL *ssl);
531
532=item char *B<SSL_rstate_string>(SSL *ssl);
533
534=item char *B<SSL_rstate_string_long>(SSL *ssl);
535
536=item long B<SSL_session_reused>(SSL *ssl);
537
538=item void B<SSL_set_accept_state>(SSL *ssl);
539
540=item void B<SSL_set_app_data>(SSL *ssl, char *arg);
541
542=item void B<SSL_set_bio>(SSL *ssl, BIO *rbio, BIO *wbio);
543
544=item int B<SSL_set_cipher_list>(SSL *ssl, char *str);
545
546=item void B<SSL_set_client_CA_list>(SSL *ssl, STACK *list);
547
548=item void B<SSL_set_connect_state>(SSL *ssl);
549
550=item int B<SSL_set_ex_data>(SSL *ssl, int idx, char *arg);
551
552=item int B<SSL_set_fd>(SSL *ssl, int fd);
553
554=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void))
555
556=item void B<SSL_set_options>(SSL *ssl, unsigned long op);
557
558=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode);
559
560=item void B<SSL_set_read_ahead>(SSL *ssl, int yes);
561
562=item int B<SSL_set_rfd>(SSL *ssl, int fd);
563
564=item int B<SSL_set_session>(SSL *ssl, SSL_SESSION *session);
565
566=item void B<SSL_set_shutdown>(SSL *ssl, int mode);
567
568=item int B<SSL_set_ssl_method>(SSL *ssl, SSL_METHOD *meth);
569
570=item void B<SSL_set_time>(SSL *ssl, long t);
571
572=item void B<SSL_set_timeout>(SSL *ssl, long t);
573
574=item void B<SSL_set_verify>(SSL *ssl, int mode, int (*callback);(void))
575
576=item void B<SSL_set_verify_result>(SSL *ssl, long arg);
577
578=item int B<SSL_set_wfd>(SSL *ssl, int fd);
579
580=item int B<SSL_shutdown>(SSL *ssl);
581
582=item int B<SSL_state>(SSL *ssl);
583
584=item char *B<SSL_state_string>(SSL *ssl);
585
586=item char *B<SSL_state_string_long>(SSL *ssl);
587
588=item long B<SSL_total_renegotiations>(SSL *ssl);
589
590=item int B<SSL_use_PrivateKey>(SSL *ssl, EVP_PKEY *pkey);
591
592=item int B<SSL_use_PrivateKey_ASN1>(int type, SSL *ssl, unsigned char *d, long len);
593
594=item int B<SSL_use_PrivateKey_file>(SSL *ssl, char *file, int type);
595
596=item int B<SSL_use_RSAPrivateKey>(SSL *ssl, RSA *rsa);
597
598=item int B<SSL_use_RSAPrivateKey_ASN1>(SSL *ssl, unsigned char *d, long len);
599
600=item int B<SSL_use_RSAPrivateKey_file>(SSL *ssl, char *file, int type);
601
602=item int B<SSL_use_certificate>(SSL *ssl, X509 *x);
603
604=item int B<SSL_use_certificate_ASN1>(SSL *ssl, int len, unsigned char *d);
605
606=item int B<SSL_use_certificate_file>(SSL *ssl, char *file, int type);
607
608=item int B<SSL_version>(SSL *ssl);
609
610=item int B<SSL_want>(SSL *ssl);
611
612=item int B<SSL_want_nothing>(SSL *ssl);
613
614=item int B<SSL_want_read>(SSL *ssl);
615
616=item int B<SSL_want_write>(SSL *ssl);
617
618=item int B<SSL_want_x509_lookup>(s);
619
620=item int B<SSL_write>(SSL *ssl, char *buf, int num);
621
622=back
623
624=head1 SEE ALSO
625
626L<openssl(1)|openssl(1)>, L<crypto(3)|crypto(3)>,
627L<SSL_get_error(3)|SSL_get_error(3)>
628
629=head1 HISTORY
630
631The L<ssl(3)|ssl(3)> document appeared in OpenSSL 0.9.2
632
633=cut
634
diff --git a/src/lib/libssl/src/doc/ssleay.txt b/src/lib/libssl/src/doc/ssleay.txt
index 094e28ce48..3e964c2e9a 100644
--- a/src/lib/libssl/src/doc/ssleay.txt
+++ b/src/lib/libssl/src/doc/ssleay.txt
@@ -6710,8 +6710,8 @@ CRYPTO_set_locking_callback(locking_function);
6710before any multithreading is started. 6710before any multithreading is started.
6711id_function does not need to be defined under Windows NT or 95, the 6711id_function does not need to be defined under Windows NT or 95, the
6712correct function will be called if it is not. Under unix, getpid() 6712correct function will be called if it is not. Under unix, getpid()
6713is call if the id_callback is not defined, for solaris this is wrong 6713is call if the id_callback is not defined, for Solaris this is wrong
6714(since threads id's are not pid's) but under IRIX it is correct 6714(since threads id's are not pid's) but under Linux it is correct
6715(threads are just processes sharing the data segement). 6715(threads are just processes sharing the data segement).
6716 6716
6717The locking_callback is used to perform locking by the SSLeay library. 6717The locking_callback is used to perform locking by the SSLeay library.
diff --git a/src/lib/libssl/src/e_os.h b/src/lib/libssl/src/e_os.h
index 07f039f71c..406bd4fc78 100644
--- a/src/lib/libssl/src/e_os.h
+++ b/src/lib/libssl/src/e_os.h
@@ -82,6 +82,20 @@ extern "C" {
82#define DEVRANDOM "/dev/arandom" 82#define DEVRANDOM "/dev/arandom"
83#endif 83#endif
84 84
85#if defined(__MWERKS__) && defined(macintosh)
86# if macintosh==1
87# ifndef MAC_OS_GUSI_SOURCE
88# define MAC_OS_pre_X
89# define NO_SYS_TYPES_H
90# endif
91# define NO_SYS_PARAM_H
92# define NO_CHMOD
93# define NO_SYSLOG
94# undef DEVRANDOM
95# define GETPID_IS_MEANINGLESS
96# endif
97#endif
98
85/******************************************************************** 99/********************************************************************
86 The Microsoft section 100 The Microsoft section
87 ********************************************************************/ 101 ********************************************************************/
@@ -93,6 +107,10 @@ extern "C" {
93# define MS_STATIC 107# define MS_STATIC
94#endif 108#endif
95 109
110#if defined(_WIN32) && !defined(WIN32)
111# define WIN32
112#endif
113
96#if defined(WIN32) || defined(WIN16) 114#if defined(WIN32) || defined(WIN16)
97# ifndef WINDOWS 115# ifndef WINDOWS
98# define WINDOWS 116# define WINDOWS
@@ -102,6 +120,10 @@ extern "C" {
102# endif 120# endif
103#endif 121#endif
104 122
123#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
124# define GETPID_IS_MEANINGLESS
125#endif
126
105#ifdef WIN32 127#ifdef WIN32
106#define get_last_sys_error() GetLastError() 128#define get_last_sys_error() GetLastError()
107#define clear_sys_error() SetLastError(0) 129#define clear_sys_error() SetLastError(0)
@@ -119,6 +141,12 @@ extern "C" {
119#define readsocket(s,b,n) recv((s),(b),(n),0) 141#define readsocket(s,b,n) recv((s),(b),(n),0)
120#define writesocket(s,b,n) send((s),(b),(n),0) 142#define writesocket(s,b,n) send((s),(b),(n),0)
121#define EADDRINUSE WSAEADDRINUSE 143#define EADDRINUSE WSAEADDRINUSE
144#elif defined(MAC_OS_pre_X)
145#define get_last_socket_error() errno
146#define clear_socket_error() errno=0
147#define closesocket(s) MacSocket_close(s)
148#define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
149#define writesocket(s,b,n) MacSocket_send((s),(b),(n))
122#else 150#else
123#define get_last_socket_error() errno 151#define get_last_socket_error() errno
124#define clear_socket_error() errno=0 152#define clear_socket_error() errno=0
@@ -172,6 +200,7 @@ extern "C" {
172#define _O_TEXT O_TEXT 200#define _O_TEXT O_TEXT
173#define _O_BINARY O_BINARY 201#define _O_BINARY O_BINARY
174#define _int64 __int64 202#define _int64 __int64
203#define _kbhit kbhit
175#endif 204#endif
176 205
177#if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST) 206#if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
@@ -227,9 +256,17 @@ extern "C" {
227 __VMS_EXIT |= 0x10000000; \ 256 __VMS_EXIT |= 0x10000000; \
228 return(n); } while(0) 257 return(n); } while(0)
229# endif 258# endif
259# define NO_SYS_PARAM_H
230# else 260# else
231 /* !defined VMS */ 261 /* !defined VMS */
232# include OPENSSL_UNISTD 262# ifdef OPENSSL_UNISTD
263# include OPENSSL_UNISTD
264# else
265# include <unistd.h>
266# endif
267# ifndef NO_SYS_TYPES_H
268# include <sys/types.h>
269# endif
233 270
234# define OPENSSL_CONF "openssl.cnf" 271# define OPENSSL_CONF "openssl.cnf"
235# define SSLEAY_CONF OPENSSL_CONF 272# define SSLEAY_CONF OPENSSL_CONF
@@ -268,11 +305,17 @@ extern HINSTANCE _hInstance;
268# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); } 305# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
269# endif 306# endif
270 307
308# elif defined(MAC_OS_pre_X)
309
310# include "MacSocket.h"
311# define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
312# define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
313# define SHUTDOWN(fd) MacSocket_close(fd)
314# define SHUTDOWN2(fd) MacSocket_close(fd)
271 315
272# else 316# else
273 317
274# include <sys/types.h> 318# ifndef NO_SYS_PARAM_H
275# ifndef VMS
276# include <sys/param.h> 319# include <sys/param.h>
277# endif 320# endif
278# include <sys/time.h> /* Needed under linux for FD_XXX */ 321# include <sys/time.h> /* Needed under linux for FD_XXX */
@@ -320,8 +363,8 @@ extern HINSTANCE _hInstance;
320 363
321# define SSLeay_Read(a,b,c) read((a),(b),(c)) 364# define SSLeay_Read(a,b,c) read((a),(b),(c))
322# define SSLeay_Write(a,b,c) write((a),(b),(c)) 365# define SSLeay_Write(a,b,c) write((a),(b),(c))
323# define SHUTDOWN(fd) { shutdown((fd),0); close((fd)); } 366# define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
324# define SHUTDOWN2(fd) { shutdown((fd),2); close((fd)); } 367# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
325# define INVALID_SOCKET (-1) 368# define INVALID_SOCKET (-1)
326# endif 369# endif
327#endif 370#endif
diff --git a/src/lib/libssl/src/install.com b/src/lib/libssl/src/install.com
index 16eac9aab2..e09d13ae5f 100644
--- a/src/lib/libssl/src/install.com
+++ b/src/lib/libssl/src/install.com
@@ -56,6 +56,7 @@ $ SDIRS := CRYPTO,SSL,RSAREF,APPS,VMS!,TEST,TOOLS
56$ EXHEADER := e_os.h,e_os2.h 56$ EXHEADER := e_os.h,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$ 60$
60$ I = 0 61$ I = 0
61$ LOOP_SDIRS: 62$ LOOP_SDIRS:
diff --git a/src/lib/libssl/src/makevms.com b/src/lib/libssl/src/makevms.com
index 977f2cee42..e89b309e87 100644
--- a/src/lib/libssl/src/makevms.com
+++ b/src/lib/libssl/src/makevms.com
@@ -17,8 +17,10 @@ $!
17$! Specify one of the following build options for P1. 17$! Specify one of the following build options for P1.
18$! 18$!
19$! ALL Just build "everything". 19$! ALL Just build "everything".
20$! CONFIG Just build the "[.CRYPTO]OPENSSLCONF.H" file.
20$! BUILDINF Just build the "[.CRYPTO]BUILDINF.H" file. 21$! BUILDINF Just build the "[.CRYPTO]BUILDINF.H" file.
21$! SOFTLINKS Just fix the Unix soft links. 22$! SOFTLINKS Just fix the Unix soft links.
23$! BUILDALL Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done.
22$! RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library. 24$! RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library.
23$! CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library. 25$! CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
24$! SSL Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library. 26$! SSL Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library.
@@ -61,6 +63,16 @@ $!
61$! P6, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up) 63$! P6, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
62$! 64$!
63$! 65$!
66$! Check if we're in a batch job, and make sure we get to
67$! the directory this script is in
68$!
69$ IF F$MODE() .EQS. "BATCH"
70$ THEN
71$ COMNAME=F$ENVIRONMENT("PROCEDURE")
72$ COMPATH=F$PARSE("A.;",COMNAME) - "A.;"
73$ SET DEF 'COMPATH'
74$ ENDIF
75$!
64$! Check Which Architecture We Are Using. 76$! Check Which Architecture We Are Using.
65$! 77$!
66$ IF (F$GETSYI("CPU").GE.128) 78$ IF (F$GETSYI("CPU").GE.128)
@@ -88,18 +100,26 @@ $ GOSUB CHECK_OPTIONS
88$! 100$!
89$! Check To See What We Are To Do. 101$! Check To See What We Are To Do.
90$! 102$!
91$ IF (BUILDALL.EQS."TRUE") 103$ IF (BUILDCOMMAND.EQS."ALL")
92$ THEN 104$ THEN
93$! 105$!
94$! Since Nothing Special Was Specified, Do Everything. 106$! Start with building the OpenSSL configuration file.
95$! First, Fix The Unix Softlinks.
96$! 107$!
97$ GOSUB SOFTLINKS 108$ GOSUB CONFIG
98$! 109$!
99$! Create The "BUILDINF.H" Include File. 110$! Create The "BUILDINF.H" Include File.
100$! 111$!
101$ GOSUB BUILDINF 112$ GOSUB BUILDINF
102$! 113$!
114$! Fix The Unix Softlinks.
115$!
116$ GOSUB SOFTLINKS
117$!
118$ ENDIF
119$!
120$ IF (BUILDCOMMAND.EQS."ALL".OR.BUILDCOMMAND.EQS."BUILDALL")
121$ THEN
122$!
103$! Check To See If We Are Going To Be Building The 123$! Check To See If We Are Going To Be Building The
104$! [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library. 124$! [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library.
105$! 125$!
@@ -140,12 +160,121 @@ $ ELSE
140$! 160$!
141$! Build Just What The User Wants Us To Build. 161$! Build Just What The User Wants Us To Build.
142$! 162$!
143$ GOSUB 'BUILDALL' 163$ GOSUB 'BUILDCOMMAND'
164$!
144$ ENDIF 165$ ENDIF
145$! 166$!
146$! Time To EXIT. 167$! Time To EXIT.
147$! 168$!
148$ EXIT 169$ EXIT
170$!
171$! Rebuild The "[.CRYPTO]OPENSSLCONF.H" file.
172$!
173$ CONFIG:
174$!
175$! Tell The User We Are Creating The [.CRYPTO]OPENSSLCONF.H File.
176$!
177$ WRITE SYS$OUTPUT "Creating [.CRYPTO]OPENSSLCONF.H Include File."
178$!
179$! Create The [.CRYPTO]OPENSSLCONF.H File.
180$!
181$ OPEN/WRITE H_FILE SYS$DISK:[.CRYPTO]OPENSSLCONF.H
182$!
183$! Write The [.CRYPTO]OPENSSLCONF.H File.
184$!
185$ WRITE H_FILE "/* This file was automatically built using makevms.com */"
186$ WRITE H_FILE "/* and [.CRYPTO]OPENSSLCONF.H_IN */"
187$
188$! Different tar version may have named the file differently
189$ IF F$SEARCH("[.CRYPTO]OPENSSLCONF.H_IN") .NES. ""
190$ THEN
191$ TYPE [.CRYPTO]OPENSSLCONF.H_IN /OUTPUT=H_FILE:
192$ ELSE
193$ IF F$SEARCH("[.CRYPTO]OPENSSLCONF_H.IN") .NES. ""
194$ THEN
195$ TYPE [.CRYPTO]OPENSSLCONF_H.IN /OUTPUT=H_FILE:
196$ ELSE
197$ WRITE SYS$ERROR "Couldn't find a [.CRYPTO]OPENSSLCONF.H_IN. Exiting!"
198$ EXIT 0
199$ ENDIF
200$ ENDIF
201$!
202$ IF ARCH .EQS. "AXP"
203$ THEN
204$!
205$! Write the Alpha specific data
206$!
207$ WRITE H_FILE "#if defined(HEADER_RC4_H)"
208$ WRITE H_FILE "#undef RC4_INT"
209$ WRITE H_FILE "#define RC4_INT unsigned int"
210$ WRITE H_FILE "#undef RC4_CHUNK"
211$ WRITE H_FILE "#define RC4_CHUNK unsigned long long"
212$ WRITE H_FILE "#endif"
213$!
214$ WRITE H_FILE "#if defined(HEADER_DES_LOCL_H)"
215$ WRITE H_FILE "#undef DES_LONG"
216$ WRITE H_FILE "#define DES_LONG unsigned int"
217$ WRITE H_FILE "#undef DES_PTR"
218$ WRITE H_FILE "#define DES_PTR"
219$ WRITE H_FILE "#undef DES_RISC1"
220$ WRITE H_FILE "#undef DES_RISC2"
221$ WRITE H_FILE "#define DES_RISC1"
222$ WRITE H_FILE "#undef DES_UNROLL"
223$ WRITE H_FILE "#define DES_UNROLL"
224$ WRITE H_FILE "#endif"
225$!
226$ WRITE H_FILE "#if defined(HEADER_BN_H)"
227$ WRITE H_FILE "#undef SIXTY_FOUR_BIT_LONG"
228$ WRITE H_FILE "#undef SIXTY_FOUR_BIT"
229$ WRITE H_FILE "#define SIXTY_FOUR_BIT"
230$ WRITE H_FILE "#undef THIRTY_TWO_BIT"
231$ WRITE H_FILE "#undef SIXTEEN_BIT"
232$ WRITE H_FILE "#undef EIGHT_BIT"
233$ WRITE H_FILE "#endif"
234$!
235$! Else...
236$!
237$ ELSE
238$!
239$! Write the VAX specific data
240$!
241$ WRITE H_FILE "#if defined(HEADER_RC4_H)"
242$ WRITE H_FILE "#undef RC4_INT"
243$ WRITE H_FILE "#define RC4_INT unsigned char"
244$ WRITE H_FILE "#undef RC4_CHUNK"
245$ WRITE H_FILE "#define RC4_CHUNK unsigned long"
246$ WRITE H_FILE "#endif"
247$!
248$ WRITE H_FILE "#if defined(HEADER_DES_LOCL_H)"
249$ WRITE H_FILE "#undef DES_LONG"
250$ WRITE H_FILE "#define DES_LONG unsigned long"
251$ WRITE H_FILE "#undef DES_PTR"
252$ WRITE H_FILE "#define DES_PTR"
253$ WRITE H_FILE "#undef DES_RISC1"
254$ WRITE H_FILE "#undef DES_RISC2"
255$ WRITE H_FILE "#undef DES_UNROLL"
256$ WRITE H_FILE "#endif"
257$!
258$ WRITE H_FILE "#if defined(HEADER_BN_H)"
259$ WRITE H_FILE "#undef SIXTY_FOUR_BIT_LONG"
260$ WRITE H_FILE "#undef SIXTY_FOUR_BIT"
261$ WRITE H_FILE "#undef THIRTY_TWO_BIT"
262$ WRITE H_FILE "#define THIRTY_TWO_BIT"
263$ WRITE H_FILE "#undef SIXTEEN_BIT"
264$ WRITE H_FILE "#undef EIGHT_BIT"
265$ WRITE H_FILE "#endif"
266$!
267$! End
268$!
269$ ENDIF
270$!
271$! Close the [.CRYPTO]OPENSSLCONF.H file
272$!
273$ CLOSE H_FILE
274$!
275$! That's All, Time To RETURN.
276$!
277$ RETURN
149$! 278$!
150$! Rebuild The "[.CRYPTO]BUILDINF.H" file. 279$! Rebuild The "[.CRYPTO]BUILDINF.H" file.
151$! 280$!
@@ -278,9 +407,9 @@ $ IF D .EQS. "," THEN GOTO LOOP_SDIRS_END
278$ tmp = EXHEADER_'D' 407$ tmp = EXHEADER_'D'
279$ IF D .EQS. "" 408$ IF D .EQS. ""
280$ THEN 409$ THEN
281$ COPY [.CRYPTO]'tmp' SYS$DISK:[.INCLUDE.OPENSSL] /LOG 410$ COPY [.CRYPTO]'tmp' SYS$DISK:[.INCLUDE.OPENSSL] !/LOG
282$ ELSE 411$ ELSE
283$ COPY [.CRYPTO.'D']'tmp' SYS$DISK:[.INCLUDE.OPENSSL] /LOG 412$ COPY [.CRYPTO.'D']'tmp' SYS$DISK:[.INCLUDE.OPENSSL] !/LOG
284$ ENDIF 413$ ENDIF
285$ GOTO LOOP_SDIRS 414$ GOTO LOOP_SDIRS
286$ LOOP_SDIRS_END: 415$ LOOP_SDIRS_END:
@@ -323,7 +452,11 @@ $ SET DEFAULT SYS$DISK:[.CRYPTO]
323$! 452$!
324$! Build The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library. 453$! Build The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
325$! 454$!
326$ @CRYPTO-LIB 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN' 455$ @CRYPTO-LIB LIBRARY 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
456$!
457$! Build The [.xxx.EXE.CRYPTO]*.EXE Test Applications.
458$!
459$ @CRYPTO-LIB APPS 'RSAREF' 'DEBUGGER' "''COMPILER'" "''TCPIP_TYPE'" 'ISSEVEN'
327$! 460$!
328$! Go Back To The Main Directory. 461$! Go Back To The Main Directory.
329$! 462$!
@@ -469,7 +602,7 @@ $ THEN
469$! 602$!
470$! P1 Is ALL, So Build Everything. 603$! P1 Is ALL, So Build Everything.
471$! 604$!
472$ BUILDALL = "TRUE" 605$ BUILDCOMMAND = "ALL"
473$! 606$!
474$! Else... 607$! Else...
475$! 608$!
@@ -484,7 +617,7 @@ $ THEN
484$! 617$!
485$! A Valid Arguement. 618$! A Valid Arguement.
486$! 619$!
487$ BUILDALL = P1 620$ BUILDCOMMAND = P1
488$! 621$!
489$! Else... 622$! Else...
490$! 623$!
@@ -496,8 +629,10 @@ $ WRITE SYS$OUTPUT ""
496$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:" 629$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
497$ WRITE SYS$OUTPUT "" 630$ WRITE SYS$OUTPUT ""
498$ WRITE SYS$OUTPUT " ALL : Just Build Everything." 631$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
632$ WRITE SYS$OUTPUT " CONFIG : Just build the [.CRYPTO]OPENSSLCONF.H file."
499$ WRITE SYS$OUTPUT " BUILDINF : Just build the [.CRYPTO]BUILDINF.H file." 633$ WRITE SYS$OUTPUT " BUILDINF : Just build the [.CRYPTO]BUILDINF.H file."
500$ WRITE SYS$OUTPUT " SOFTLINKS: Just Fix The Unix soft links." 634$ WRITE SYS$OUTPUT " SOFTLINKS: Just Fix The Unix soft links."
635$ WRITE SYS$OUTPUT " BUILDALL : Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done."
501$ WRITE SYS$OUTPUT " RSAREF : To Build Just The [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library." 636$ WRITE SYS$OUTPUT " RSAREF : To Build Just The [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library."
502$ WRITE SYS$OUTPUT " CRYPTO : To Build Just The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library." 637$ WRITE SYS$OUTPUT " CRYPTO : To Build Just The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library."
503$ WRITE SYS$OUTPUT " SSL : To Build Just The [.xxx.EXE.SSL]LIBSSL.OLB Library." 638$ WRITE SYS$OUTPUT " SSL : To Build Just The [.xxx.EXE.SSL]LIBSSL.OLB Library."
diff --git a/src/lib/libssl/src/ms/test.bat b/src/lib/libssl/src/ms/test.bat
index a40f7478d7..3506a644f5 100644
--- a/src/lib/libssl/src/ms/test.bat
+++ b/src/lib/libssl/src/ms/test.bat
@@ -7,8 +7,8 @@ set OPENSSL_CONF=..\apps\openssl.cnf
7 7
8rem run this from inside the bin directory 8rem run this from inside the bin directory
9 9
10echo rsa_oaep_test 10echo rsa_test
11rsa_oaep_test 11rsa_test
12if errorlevel 1 goto done 12if errorlevel 1 goto done
13 13
14echo destest 14echo destest
@@ -135,6 +135,10 @@ echo test sslv2 via BIO pair
135ssltest -bio_pair -ssl2 135ssltest -bio_pair -ssl2
136if errorlevel 1 goto done 136if errorlevel 1 goto done
137 137
138echo test sslv2/sslv3 with 1024 bit DHE via BIO pair
139ssltest -bio_pair -dhe1024 -v
140if errorlevel 1 goto done
141
138echo test sslv2 with server authentication via BIO pair 142echo test sslv2 with server authentication via BIO pair
139ssltest -bio_pair -ssl2 -server_auth -CAfile cert.tmp 143ssltest -bio_pair -ssl2 -server_auth -CAfile cert.tmp
140if errorlevel 1 goto done 144if errorlevel 1 goto done
diff --git a/src/lib/libssl/src/mt/README b/src/lib/libssl/src/mt/README
index df6b26e146..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/README
+++ b/src/lib/libssl/src/mt/README
@@ -1,14 +0,0 @@
1Mutithreading testing area.
2
3Since this stuff is very very platorm specific, this is not part of the
4normal build. Have a read of doc/threads.doc.
5
6mttest will do some testing and will currently build under Windows NT/95,
7Solaris and Linux. The IRIX stuff is not finished.
8
9I have tested this program on a 12 CPU ultra sparc box (solaris 2.5.1)
10and things seem to work ok.
11
12The Linux pthreads package can be retrieved from
13http://www.mit.edu:8001/people/proven/pthreads.html
14
diff --git a/src/lib/libssl/src/mt/mttest.c b/src/lib/libssl/src/mt/mttest.c
index b2f332602d..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/mttest.c
+++ b/src/lib/libssl/src/mt/mttest.c
@@ -1,1092 +0,0 @@
1/* mt/mttest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <errno.h>
63#ifdef LINUX
64#include <typedefs.h>
65#endif
66#ifdef WIN32
67#include <windows.h>
68#endif
69#ifdef SOLARIS
70#include <synch.h>
71#include <thread.h>
72#endif
73#ifdef IRIX
74#include <ulocks.h>
75#include <sys/prctl.h>
76#endif
77#include <openssl/lhash.h>
78#include <openssl/crypto.h>
79#include <openssl/buffer.h>
80#include "../e_os.h"
81#include <openssl/x509.h>
82#include <openssl/ssl.h>
83#include <openssl/err.h>
84
85#ifdef NO_FP_API
86#define APPS_WIN16
87#include "../crypto/buffer/bss_file.c"
88#endif
89
90#define TEST_SERVER_CERT "../apps/server.pem"
91#define TEST_CLIENT_CERT "../apps/client.pem"
92
93#define MAX_THREAD_NUMBER 100
94
95int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth,
96 int error,char *arg);
97void thread_setup(void);
98void thread_cleanup(void);
99void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx);
100
101void irix_locking_callback(int mode,int type,char *file,int line);
102void solaris_locking_callback(int mode,int type,char *file,int line);
103void win32_locking_callback(int mode,int type,char *file,int line);
104void pthreads_locking_callback(int mode,int type,char *file,int line);
105
106unsigned long irix_thread_id(void );
107unsigned long solaris_thread_id(void );
108unsigned long pthreads_thread_id(void );
109
110BIO *bio_err=NULL;
111BIO *bio_stdout=NULL;
112
113static char *cipher=NULL;
114int verbose=0;
115#ifdef FIONBIO
116static int s_nbio=0;
117#endif
118
119int thread_number=10;
120int number_of_loops=10;
121int reconnect=0;
122int cache_stats=0;
123
124int doit(char *ctx[4]);
125static void print_stats(fp,ctx)
126FILE *fp;
127SSL_CTX *ctx;
128{
129 fprintf(fp,"%4ld items in the session cache\n",
130 SSL_CTX_sess_number(ctx));
131 fprintf(fp,"%4d client connects (SSL_connect())\n",
132 SSL_CTX_sess_connect(ctx));
133 fprintf(fp,"%4d client connects that finished\n",
134 SSL_CTX_sess_connect_good(ctx));
135 fprintf(fp,"%4d server connects (SSL_accept())\n",
136 SSL_CTX_sess_accept(ctx));
137 fprintf(fp,"%4d server connects that finished\n",
138 SSL_CTX_sess_accept_good(ctx));
139 fprintf(fp,"%4d session cache hits\n",SSL_CTX_sess_hits(ctx));
140 fprintf(fp,"%4d session cache misses\n",SSL_CTX_sess_misses(ctx));
141 fprintf(fp,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ctx));
142 }
143
144static void sv_usage()
145 {
146 fprintf(stderr,"usage: ssltest [args ...]\n");
147 fprintf(stderr,"\n");
148 fprintf(stderr," -server_auth - check server certificate\n");
149 fprintf(stderr," -client_auth - do client authentication\n");
150 fprintf(stderr," -v - more output\n");
151 fprintf(stderr," -CApath arg - PEM format directory of CA's\n");
152 fprintf(stderr," -CAfile arg - PEM format file of CA's\n");
153 fprintf(stderr," -threads arg - number of threads\n");
154 fprintf(stderr," -loops arg - number of 'connections', per thread\n");
155 fprintf(stderr," -reconnect - reuse session-id's\n");
156 fprintf(stderr," -stats - server session-id cache stats\n");
157 fprintf(stderr," -cert arg - server certificate/key\n");
158 fprintf(stderr," -ccert arg - client certificate/key\n");
159 fprintf(stderr," -ssl3 - just SSLv3n\n");
160 }
161
162int main(argc, argv)
163int argc;
164char *argv[];
165 {
166 char *CApath=NULL,*CAfile=NULL;
167 int badop=0;
168 int ret=1;
169 int client_auth=0;
170 int server_auth=0;
171 SSL_CTX *s_ctx=NULL;
172 SSL_CTX *c_ctx=NULL;
173 char *scert=TEST_SERVER_CERT;
174 char *ccert=TEST_CLIENT_CERT;
175 SSL_METHOD *ssl_method=SSLv23_method();
176
177 if (bio_err == NULL)
178 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
179 if (bio_stdout == NULL)
180 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
181 argc--;
182 argv++;
183
184 while (argc >= 1)
185 {
186 if (strcmp(*argv,"-server_auth") == 0)
187 server_auth=1;
188 else if (strcmp(*argv,"-client_auth") == 0)
189 client_auth=1;
190 else if (strcmp(*argv,"-reconnect") == 0)
191 reconnect=1;
192 else if (strcmp(*argv,"-stats") == 0)
193 cache_stats=1;
194 else if (strcmp(*argv,"-ssl3") == 0)
195 ssl_method=SSLv3_method();
196 else if (strcmp(*argv,"-ssl2") == 0)
197 ssl_method=SSLv2_method();
198 else if (strcmp(*argv,"-CApath") == 0)
199 {
200 if (--argc < 1) goto bad;
201 CApath= *(++argv);
202 }
203 else if (strcmp(*argv,"-CAfile") == 0)
204 {
205 if (--argc < 1) goto bad;
206 CAfile= *(++argv);
207 }
208 else if (strcmp(*argv,"-cert") == 0)
209 {
210 if (--argc < 1) goto bad;
211 scert= *(++argv);
212 }
213 else if (strcmp(*argv,"-ccert") == 0)
214 {
215 if (--argc < 1) goto bad;
216 ccert= *(++argv);
217 }
218 else if (strcmp(*argv,"-threads") == 0)
219 {
220 if (--argc < 1) goto bad;
221 thread_number= atoi(*(++argv));
222 if (thread_number == 0) thread_number=1;
223 if (thread_number > MAX_THREAD_NUMBER)
224 thread_number=MAX_THREAD_NUMBER;
225 }
226 else if (strcmp(*argv,"-loops") == 0)
227 {
228 if (--argc < 1) goto bad;
229 number_of_loops= atoi(*(++argv));
230 if (number_of_loops == 0) number_of_loops=1;
231 }
232 else
233 {
234 fprintf(stderr,"unknown option %s\n",*argv);
235 badop=1;
236 break;
237 }
238 argc--;
239 argv++;
240 }
241 if (badop)
242 {
243bad:
244 sv_usage();
245 goto end;
246 }
247
248 if (cipher == NULL) cipher=getenv("SSL_CIPHER");
249
250 SSL_load_error_strings();
251 SSLeay_add_ssl_algorithms();
252
253 c_ctx=SSL_CTX_new(ssl_method);
254 s_ctx=SSL_CTX_new(ssl_method);
255 if ((c_ctx == NULL) || (s_ctx == NULL))
256 {
257 ERR_print_errors(bio_err);
258 goto end;
259 }
260
261 SSL_CTX_set_session_cache_mode(s_ctx,
262 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
263 SSL_CTX_set_session_cache_mode(c_ctx,
264 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
265
266 SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM);
267 SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM);
268
269 if (client_auth)
270 {
271 SSL_CTX_use_certificate_file(c_ctx,ccert,
272 SSL_FILETYPE_PEM);
273 SSL_CTX_use_RSAPrivateKey_file(c_ctx,ccert,
274 SSL_FILETYPE_PEM);
275 }
276
277 if ( (!SSL_CTX_load_verify_locations(s_ctx,CAfile,CApath)) ||
278 (!SSL_CTX_set_default_verify_paths(s_ctx)) ||
279 (!SSL_CTX_load_verify_locations(c_ctx,CAfile,CApath)) ||
280 (!SSL_CTX_set_default_verify_paths(c_ctx)))
281 {
282 fprintf(stderr,"SSL_load_verify_locations\n");
283 ERR_print_errors(bio_err);
284 goto end;
285 }
286
287 if (client_auth)
288 {
289 fprintf(stderr,"client authentication\n");
290 SSL_CTX_set_verify(s_ctx,
291 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
292 verify_callback);
293 }
294 if (server_auth)
295 {
296 fprintf(stderr,"server authentication\n");
297 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,
298 verify_callback);
299 }
300
301 thread_setup();
302 do_threads(s_ctx,c_ctx);
303 thread_cleanup();
304end:
305
306 if (c_ctx != NULL)
307 {
308 fprintf(stderr,"Client SSL_CTX stats then free it\n");
309 print_stats(stderr,c_ctx);
310 SSL_CTX_free(c_ctx);
311 }
312 if (s_ctx != NULL)
313 {
314 fprintf(stderr,"Server SSL_CTX stats then free it\n");
315 print_stats(stderr,s_ctx);
316 if (cache_stats)
317 {
318 fprintf(stderr,"-----\n");
319 lh_stats(SSL_CTX_sessions(s_ctx),stderr);
320 fprintf(stderr,"-----\n");
321 /* lh_node_stats(SSL_CTX_sessions(s_ctx),stderr);
322 fprintf(stderr,"-----\n"); */
323 lh_node_usage_stats(SSL_CTX_sessions(s_ctx),stderr);
324 fprintf(stderr,"-----\n");
325 }
326 SSL_CTX_free(s_ctx);
327 fprintf(stderr,"done free\n");
328 }
329 exit(ret);
330 return(0);
331 }
332
333#define W_READ 1
334#define W_WRITE 2
335#define C_DONE 1
336#define S_DONE 2
337
338int ndoit(ssl_ctx)
339SSL_CTX *ssl_ctx[2];
340 {
341 int i;
342 int ret;
343 char *ctx[4];
344
345 ctx[0]=(char *)ssl_ctx[0];
346 ctx[1]=(char *)ssl_ctx[1];
347
348 if (reconnect)
349 {
350 ctx[2]=(char *)SSL_new(ssl_ctx[0]);
351 ctx[3]=(char *)SSL_new(ssl_ctx[1]);
352 }
353 else
354 {
355 ctx[2]=NULL;
356 ctx[3]=NULL;
357 }
358
359 fprintf(stdout,"started thread %lu\n",CRYPTO_thread_id());
360 for (i=0; i<number_of_loops; i++)
361 {
362/* fprintf(stderr,"%4d %2d ctx->ref (%3d,%3d)\n",
363 CRYPTO_thread_id(),i,
364 ssl_ctx[0]->references,
365 ssl_ctx[1]->references); */
366 /* pthread_delay_np(&tm);*/
367
368 ret=doit(ctx);
369 if (ret != 0)
370 {
371 fprintf(stdout,"error[%d] %lu - %d\n",
372 i,CRYPTO_thread_id(),ret);
373 return(ret);
374 }
375 }
376 fprintf(stdout,"DONE %lu\n",CRYPTO_thread_id());
377 if (reconnect)
378 {
379 SSL_free((SSL *)ctx[2]);
380 SSL_free((SSL *)ctx[3]);
381 }
382 return(0);
383 }
384
385int doit(ctx)
386char *ctx[4];
387 {
388 SSL_CTX *s_ctx,*c_ctx;
389 static char cbuf[200],sbuf[200];
390 SSL *c_ssl=NULL;
391 SSL *s_ssl=NULL;
392 BIO *c_to_s=NULL;
393 BIO *s_to_c=NULL;
394 BIO *c_bio=NULL;
395 BIO *s_bio=NULL;
396 int c_r,c_w,s_r,s_w;
397 int c_want,s_want;
398 int i;
399 int done=0;
400 int c_write,s_write;
401 int do_server=0,do_client=0;
402
403 s_ctx=(SSL_CTX *)ctx[0];
404 c_ctx=(SSL_CTX *)ctx[1];
405
406 if (ctx[2] != NULL)
407 s_ssl=(SSL *)ctx[2];
408 else
409 s_ssl=SSL_new(s_ctx);
410
411 if (ctx[3] != NULL)
412 c_ssl=(SSL *)ctx[3];
413 else
414 c_ssl=SSL_new(c_ctx);
415
416 if ((s_ssl == NULL) || (c_ssl == NULL)) goto err;
417
418 c_to_s=BIO_new(BIO_s_mem());
419 s_to_c=BIO_new(BIO_s_mem());
420 if ((s_to_c == NULL) || (c_to_s == NULL)) goto err;
421
422 c_bio=BIO_new(BIO_f_ssl());
423 s_bio=BIO_new(BIO_f_ssl());
424 if ((c_bio == NULL) || (s_bio == NULL)) goto err;
425
426 SSL_set_connect_state(c_ssl);
427 SSL_set_bio(c_ssl,s_to_c,c_to_s);
428 BIO_set_ssl(c_bio,c_ssl,(ctx[2] == NULL)?BIO_CLOSE:BIO_NOCLOSE);
429
430 SSL_set_accept_state(s_ssl);
431 SSL_set_bio(s_ssl,c_to_s,s_to_c);
432 BIO_set_ssl(s_bio,s_ssl,(ctx[3] == NULL)?BIO_CLOSE:BIO_NOCLOSE);
433
434 c_r=0; s_r=1;
435 c_w=1; s_w=0;
436 c_want=W_WRITE;
437 s_want=0;
438 c_write=1,s_write=0;
439
440 /* We can always do writes */
441 for (;;)
442 {
443 do_server=0;
444 do_client=0;
445
446 i=(int)BIO_pending(s_bio);
447 if ((i && s_r) || s_w) do_server=1;
448
449 i=(int)BIO_pending(c_bio);
450 if ((i && c_r) || c_w) do_client=1;
451
452 if (do_server && verbose)
453 {
454 if (SSL_in_init(s_ssl))
455 printf("server waiting in SSL_accept - %s\n",
456 SSL_state_string_long(s_ssl));
457 else if (s_write)
458 printf("server:SSL_write()\n");
459 else
460 printf("server:SSL_read()\n");
461 }
462
463 if (do_client && verbose)
464 {
465 if (SSL_in_init(c_ssl))
466 printf("client waiting in SSL_connect - %s\n",
467 SSL_state_string_long(c_ssl));
468 else if (c_write)
469 printf("client:SSL_write()\n");
470 else
471 printf("client:SSL_read()\n");
472 }
473
474 if (!do_client && !do_server)
475 {
476 fprintf(stdout,"ERROR IN STARTUP\n");
477 break;
478 }
479 if (do_client && !(done & C_DONE))
480 {
481 if (c_write)
482 {
483 i=BIO_write(c_bio,"hello from client\n",18);
484 if (i < 0)
485 {
486 c_r=0;
487 c_w=0;
488 if (BIO_should_retry(c_bio))
489 {
490 if (BIO_should_read(c_bio))
491 c_r=1;
492 if (BIO_should_write(c_bio))
493 c_w=1;
494 }
495 else
496 {
497 fprintf(stderr,"ERROR in CLIENT\n");
498 return(1);
499 }
500 }
501 else if (i == 0)
502 {
503 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
504 return(1);
505 }
506 else
507 {
508 /* ok */
509 c_write=0;
510 }
511 }
512 else
513 {
514 i=BIO_read(c_bio,cbuf,100);
515 if (i < 0)
516 {
517 c_r=0;
518 c_w=0;
519 if (BIO_should_retry(c_bio))
520 {
521 if (BIO_should_read(c_bio))
522 c_r=1;
523 if (BIO_should_write(c_bio))
524 c_w=1;
525 }
526 else
527 {
528 fprintf(stderr,"ERROR in CLIENT\n");
529 return(1);
530 }
531 }
532 else if (i == 0)
533 {
534 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
535 return(1);
536 }
537 else
538 {
539 done|=C_DONE;
540#ifdef undef
541 fprintf(stdout,"CLIENT:from server:");
542 fwrite(cbuf,1,i,stdout);
543 fflush(stdout);
544#endif
545 }
546 }
547 }
548
549 if (do_server && !(done & S_DONE))
550 {
551 if (!s_write)
552 {
553 i=BIO_read(s_bio,sbuf,100);
554 if (i < 0)
555 {
556 s_r=0;
557 s_w=0;
558 if (BIO_should_retry(s_bio))
559 {
560 if (BIO_should_read(s_bio))
561 s_r=1;
562 if (BIO_should_write(s_bio))
563 s_w=1;
564 }
565 else
566 {
567 fprintf(stderr,"ERROR in SERVER\n");
568 ERR_print_errors_fp(stderr);
569 return(1);
570 }
571 }
572 else if (i == 0)
573 {
574 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
575 return(1);
576 }
577 else
578 {
579 s_write=1;
580 s_w=1;
581#ifdef undef
582 fprintf(stdout,"SERVER:from client:");
583 fwrite(sbuf,1,i,stdout);
584 fflush(stdout);
585#endif
586 }
587 }
588 else
589 {
590 i=BIO_write(s_bio,"hello from server\n",18);
591 if (i < 0)
592 {
593 s_r=0;
594 s_w=0;
595 if (BIO_should_retry(s_bio))
596 {
597 if (BIO_should_read(s_bio))
598 s_r=1;
599 if (BIO_should_write(s_bio))
600 s_w=1;
601 }
602 else
603 {
604 fprintf(stderr,"ERROR in SERVER\n");
605 ERR_print_errors_fp(stderr);
606 return(1);
607 }
608 }
609 else if (i == 0)
610 {
611 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
612 return(1);
613 }
614 else
615 {
616 s_write=0;
617 s_r=1;
618 done|=S_DONE;
619 }
620 }
621 }
622
623 if ((done & S_DONE) && (done & C_DONE)) break;
624 }
625
626 SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
627 SSL_set_shutdown(s_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
628
629#ifdef undef
630 fprintf(stdout,"DONE\n");
631#endif
632err:
633 /* We have to set the BIO's to NULL otherwise they will be
634 * free()ed twice. Once when th s_ssl is SSL_free()ed and
635 * again when c_ssl is SSL_free()ed.
636 * This is a hack required because s_ssl and c_ssl are sharing the same
637 * BIO structure and SSL_set_bio() and SSL_free() automatically
638 * BIO_free non NULL entries.
639 * You should not normally do this or be required to do this */
640
641 if (s_ssl != NULL)
642 {
643 s_ssl->rbio=NULL;
644 s_ssl->wbio=NULL;
645 }
646 if (c_ssl != NULL)
647 {
648 c_ssl->rbio=NULL;
649 c_ssl->wbio=NULL;
650 }
651
652 /* The SSL's are optionally freed in the following calls */
653 if (c_to_s != NULL) BIO_free(c_to_s);
654 if (s_to_c != NULL) BIO_free(s_to_c);
655
656 if (c_bio != NULL) BIO_free(c_bio);
657 if (s_bio != NULL) BIO_free(s_bio);
658 return(0);
659 }
660
661int MS_CALLBACK verify_callback(ok, xs, xi, depth, error, arg)
662int ok;
663X509 *xs;
664X509 *xi;
665int depth;
666int error;
667char *arg;
668 {
669 char buf[256];
670
671 if (verbose)
672 {
673 X509_NAME_oneline(X509_get_subject_name(xs),buf,256);
674 if (ok)
675 fprintf(stderr,"depth=%d %s\n",depth,buf);
676 else
677 fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf);
678 }
679 return(ok);
680 }
681
682#define THREAD_STACK_SIZE (16*1024)
683
684#ifdef WIN32
685
686static PRLOCK lock_cs[CRYPTO_NUM_LOCKS];
687
688void thread_setup()
689 {
690 int i;
691
692 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
693 {
694 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
695 }
696
697 CRYPTO_set_locking_callback((void (*)(int,int,char *,int))win32_locking_callback);
698 /* id callback defined */
699 }
700
701void thread_cleanup()
702 {
703 int i;
704
705 CRYPTO_set_locking_callback(NULL);
706 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
707 CloseHandle(lock_cs[i]);
708 }
709
710void win32_locking_callback(mode,type,file,line)
711int mode;
712int type;
713char *file;
714int line;
715 {
716 if (mode & CRYPTO_LOCK)
717 {
718 WaitForSingleObject(lock_cs[type],INFINITE);
719 }
720 else
721 {
722 ReleaseMutex(lock_cs[type]);
723 }
724 }
725
726void do_threads(s_ctx,c_ctx)
727SSL_CTX *s_ctx,*c_ctx;
728 {
729 double ret;
730 SSL_CTX *ssl_ctx[2];
731 DWORD thread_id[MAX_THREAD_NUMBER];
732 HANDLE thread_handle[MAX_THREAD_NUMBER];
733 int i;
734 SYSTEMTIME start,end;
735
736 ssl_ctx[0]=s_ctx;
737 ssl_ctx[1]=c_ctx;
738
739 GetSystemTime(&start);
740 for (i=0; i<thread_number; i++)
741 {
742 thread_handle[i]=CreateThread(NULL,
743 THREAD_STACK_SIZE,
744 (LPTHREAD_START_ROUTINE)ndoit,
745 (void *)ssl_ctx,
746 0L,
747 &(thread_id[i]));
748 }
749
750 printf("reaping\n");
751 for (i=0; i<thread_number; i+=50)
752 {
753 int j;
754
755 j=(thread_number < (i+50))?(thread_number-i):50;
756
757 if (WaitForMultipleObjects(j,
758 (CONST HANDLE *)&(thread_handle[i]),TRUE,INFINITE)
759 == WAIT_FAILED)
760 {
761 fprintf(stderr,"WaitForMultipleObjects failed:%d\n",GetLastError());
762 exit(1);
763 }
764 }
765 GetSystemTime(&end);
766
767 if (start.wDayOfWeek > end.wDayOfWeek) end.wDayOfWeek+=7;
768 ret=(end.wDayOfWeek-start.wDayOfWeek)*24;
769
770 ret=(ret+end.wHour-start.wHour)*60;
771 ret=(ret+end.wMinute-start.wMinute)*60;
772 ret=(ret+end.wSecond-start.wSecond);
773 ret+=(end.wMilliseconds-start.wMilliseconds)/1000.0;
774
775 printf("win32 threads done - %.3f seconds\n",ret);
776 }
777
778#endif /* WIN32 */
779
780#ifdef SOLARIS
781
782static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
783/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */
784static long lock_count[CRYPTO_NUM_LOCKS];
785
786void thread_setup()
787 {
788 int i;
789
790 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
791 {
792 lock_count[i]=0;
793 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
794 mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
795 }
796
797 CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id);
798 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
799 }
800
801void thread_cleanup()
802 {
803 int i;
804
805 CRYPTO_set_locking_callback(NULL);
806fprintf(stderr,"cleanup\n");
807 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
808 {
809 /* rwlock_destroy(&(lock_cs[i])); */
810 mutex_destroy(&(lock_cs[i]));
811 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
812 }
813fprintf(stderr,"done cleanup\n");
814 }
815
816void solaris_locking_callback(mode,type,file,line)
817int mode;
818int type;
819char *file;
820int line;
821 {
822#ifdef undef
823fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
824 CRYPTO_thread_id(),
825 (mode&CRYPTO_LOCK)?"l":"u",
826 (type&CRYPTO_READ)?"r":"w",file,line);
827#endif
828
829/*
830if (CRYPTO_LOCK_SSL_CERT == type)
831 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
832 CRYPTO_thread_id(),
833 mode,file,line);
834*/
835 if (mode & CRYPTO_LOCK)
836 {
837 /* if (mode & CRYPTO_READ)
838 rw_rdlock(&(lock_cs[type]));
839 else
840 rw_wrlock(&(lock_cs[type])); */
841
842 mutex_lock(&(lock_cs[type]));
843 lock_count[type]++;
844 }
845 else
846 {
847/* rw_unlock(&(lock_cs[type])); */
848 mutex_unlock(&(lock_cs[type]));
849 }
850 }
851
852void do_threads(s_ctx,c_ctx)
853SSL_CTX *s_ctx,*c_ctx;
854 {
855 SSL_CTX *ssl_ctx[2];
856 thread_t thread_ctx[MAX_THREAD_NUMBER];
857 int i;
858
859 ssl_ctx[0]=s_ctx;
860 ssl_ctx[1]=c_ctx;
861
862 thr_setconcurrency(thread_number);
863 for (i=0; i<thread_number; i++)
864 {
865 thr_create(NULL, THREAD_STACK_SIZE,
866 (void *(*)())ndoit,
867 (void *)ssl_ctx,
868 0L,
869 &(thread_ctx[i]));
870 }
871
872 printf("reaping\n");
873 for (i=0; i<thread_number; i++)
874 {
875 thr_join(thread_ctx[i],NULL,NULL);
876 }
877
878 printf("solaris threads done (%d,%d)\n",
879 s_ctx->references,c_ctx->references);
880 }
881
882unsigned long solaris_thread_id()
883 {
884 unsigned long ret;
885
886 ret=(unsigned long)thr_self();
887 return(ret);
888 }
889#endif /* SOLARIS */
890
891#ifdef IRIX
892
893
894static usptr_t *arena;
895static usema_t *lock_cs[CRYPTO_NUM_LOCKS];
896
897void thread_setup()
898 {
899 int i;
900 char filename[20];
901
902 strcpy(filename,"/tmp/mttest.XXXXXX");
903 mktemp(filename);
904
905 usconfig(CONF_STHREADIOOFF);
906 usconfig(CONF_STHREADMALLOCOFF);
907 usconfig(CONF_INITUSERS,100);
908 usconfig(CONF_LOCKTYPE,US_DEBUGPLUS);
909 arena=usinit(filename);
910 unlink(filename);
911
912 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
913 {
914 lock_cs[i]=usnewsema(arena,1);
915 }
916
917 CRYPTO_set_id_callback((unsigned long (*)())irix_thread_id);
918 CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
919 }
920
921void thread_cleanup()
922 {
923 int i;
924
925 CRYPTO_set_locking_callback(NULL);
926 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
927 {
928 char buf[10];
929
930 sprintf(buf,"%2d:",i);
931 usdumpsema(lock_cs[i],stdout,buf);
932 usfreesema(lock_cs[i],arena);
933 }
934 }
935
936void irix_locking_callback(mode,type,file,line)
937int mode;
938int type;
939char *file;
940int line;
941 {
942 if (mode & CRYPTO_LOCK)
943 {
944 printf("lock %d\n",type);
945 uspsema(lock_cs[type]);
946 }
947 else
948 {
949 printf("unlock %d\n",type);
950 usvsema(lock_cs[type]);
951 }
952 }
953
954void do_threads(s_ctx,c_ctx)
955SSL_CTX *s_ctx,*c_ctx;
956 {
957 SSL_CTX *ssl_ctx[2];
958 int thread_ctx[MAX_THREAD_NUMBER];
959 int i;
960
961 ssl_ctx[0]=s_ctx;
962 ssl_ctx[1]=c_ctx;
963
964 for (i=0; i<thread_number; i++)
965 {
966 thread_ctx[i]=sproc((void (*)())ndoit,
967 PR_SADDR|PR_SFDS,(void *)ssl_ctx);
968 }
969
970 printf("reaping\n");
971 for (i=0; i<thread_number; i++)
972 {
973 wait(NULL);
974 }
975
976 printf("irix threads done (%d,%d)\n",
977 s_ctx->references,c_ctx->references);
978 }
979
980unsigned long irix_thread_id()
981 {
982 unsigned long ret;
983
984 ret=(unsigned long)getpid();
985 return(ret);
986 }
987#endif /* IRIX */
988
989#ifdef PTHREADS
990
991static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
992static long lock_count[CRYPTO_NUM_LOCKS];
993
994void thread_setup()
995 {
996 int i;
997
998 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
999 {
1000 lock_count[i]=0;
1001 pthread_mutex_init(&(lock_cs[i]),NULL);
1002 }
1003
1004 CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
1005 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
1006 }
1007
1008void thread_cleanup()
1009 {
1010 int i;
1011
1012 CRYPTO_set_locking_callback(NULL);
1013 fprintf(stderr,"cleanup\n");
1014 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
1015 {
1016 pthread_mutex_destroy(&(lock_cs[i]));
1017 fprintf(stderr,"%8ld:%s\n",lock_count[i],
1018 CRYPTO_get_lock_name(i));
1019 }
1020 fprintf(stderr,"done cleanup\n");
1021 }
1022
1023void pthreads_locking_callback(mode,type,file,line)
1024int mode;
1025int type;
1026char *file;
1027int line;
1028 {
1029#ifdef undef
1030 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
1031 CRYPTO_thread_id(),
1032 (mode&CRYPTO_LOCK)?"l":"u",
1033 (type&CRYPTO_READ)?"r":"w",file,line);
1034#endif
1035/*
1036 if (CRYPTO_LOCK_SSL_CERT == type)
1037 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
1038 CRYPTO_thread_id(),
1039 mode,file,line);
1040*/
1041 if (mode & CRYPTO_LOCK)
1042 {
1043 pthread_mutex_lock(&(lock_cs[type]));
1044 lock_count[type]++;
1045 }
1046 else
1047 {
1048 pthread_mutex_unlock(&(lock_cs[type]));
1049 }
1050 }
1051
1052void do_threads(s_ctx,c_ctx)
1053SSL_CTX *s_ctx,*c_ctx;
1054 {
1055 SSL_CTX *ssl_ctx[2];
1056 pthread_t thread_ctx[MAX_THREAD_NUMBER];
1057 int i;
1058
1059 ssl_ctx[0]=s_ctx;
1060 ssl_ctx[1]=c_ctx;
1061
1062 /*
1063 thr_setconcurrency(thread_number);
1064 */
1065 for (i=0; i<thread_number; i++)
1066 {
1067 pthread_create(&(thread_ctx[i]), NULL,
1068 (void *(*)())ndoit, (void *)ssl_ctx);
1069 }
1070
1071 printf("reaping\n");
1072 for (i=0; i<thread_number; i++)
1073 {
1074 pthread_join(thread_ctx[i],NULL);
1075 }
1076
1077 printf("pthreads threads done (%d,%d)\n",
1078 s_ctx->references,c_ctx->references);
1079 }
1080
1081unsigned long pthreads_thread_id()
1082 {
1083 unsigned long ret;
1084
1085 ret=(unsigned long)pthread_self();
1086 return(ret);
1087 }
1088
1089#endif /* PTHREADS */
1090
1091
1092
diff --git a/src/lib/libssl/src/mt/profile.sh b/src/lib/libssl/src/mt/profile.sh
index de5eb06708..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/profile.sh
+++ b/src/lib/libssl/src/mt/profile.sh
@@ -1,4 +0,0 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -p -DSOLARIS -I../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/mt/ptest.bat b/src/lib/libssl/src/mt/ptest.bat
index ccaccae09d..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/ptest.bat
+++ b/src/lib/libssl/src/mt/ptest.bat
@@ -1,4 +0,0 @@
1del mttest.exe
2
3purify cl /O2 -DWIN32 /MD -I..\out mttest.c /Femttest ..\out\ssl32.lib ..\out\crypt32.lib
4
diff --git a/src/lib/libssl/src/mt/pthread.sh b/src/lib/libssl/src/mt/pthread.sh
index 7d0b6e55f5..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/pthread.sh
+++ b/src/lib/libssl/src/mt/pthread.sh
@@ -1,9 +0,0 @@
1#!/bin/sh
2#
3# build using pthreads
4#
5# http://www.mit.edu:8001/people/proven/pthreads.html
6#
7/bin/rm -f mttest
8pgcc -DPTHREADS -I../include -g mttest.c -o mttest -L.. -lssl -lcrypto
9
diff --git a/src/lib/libssl/src/mt/purify.sh b/src/lib/libssl/src/mt/purify.sh
index 57c4017073..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/purify.sh
+++ b/src/lib/libssl/src/mt/purify.sh
@@ -1,4 +0,0 @@
1#!/bin/sh
2/bin/rm -f mttest
3purify cc -DSOLARIS -I../include -g mttest.c -o mttest -L.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/mt/solaris.sh b/src/lib/libssl/src/mt/solaris.sh
index f6a90b17ee..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/solaris.sh
+++ b/src/lib/libssl/src/mt/solaris.sh
@@ -1,4 +0,0 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -DSOLARIS -I../include -g mttest.c -o mttest -L.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/mt/win32.bat b/src/lib/libssl/src/mt/win32.bat
index 56089f69be..e69de29bb2 100644
--- a/src/lib/libssl/src/mt/win32.bat
+++ b/src/lib/libssl/src/mt/win32.bat
@@ -1,4 +0,0 @@
1del mttest.exe
2
3cl /O2 -DWIN32 /MD -I..\out mttest.c /Femttest ..\out\ssleay32.lib ..\out\libeay32.lib
4
diff --git a/src/lib/libssl/src/rsaref/Makefile.ssl b/src/lib/libssl/src/rsaref/Makefile.ssl
index 03b081bac3..8d06a531d7 100644
--- a/src/lib/libssl/src/rsaref/Makefile.ssl
+++ b/src/lib/libssl/src/rsaref/Makefile.ssl
@@ -88,11 +88,12 @@ clean:
88rsar_err.o: ../include/openssl/bn.h ../include/openssl/crypto.h 88rsar_err.o: ../include/openssl/bn.h ../include/openssl/crypto.h
89rsar_err.o: ../include/openssl/err.h ../include/openssl/opensslconf.h 89rsar_err.o: ../include/openssl/err.h ../include/openssl/opensslconf.h
90rsar_err.o: ../include/openssl/opensslv.h ../include/openssl/rsa.h 90rsar_err.o: ../include/openssl/opensslv.h ../include/openssl/rsa.h
91rsar_err.o: ../include/openssl/rsaref.h ../include/openssl/stack.h 91rsar_err.o: ../include/openssl/rsaref.h ../include/openssl/safestack.h
92rsar_err.o: ../include/openssl/stack.h
92rsaref.o: ../crypto/cryptlib.h ../include/openssl/bio.h ../include/openssl/bn.h 93rsaref.o: ../crypto/cryptlib.h ../include/openssl/bio.h ../include/openssl/bn.h
93rsaref.o: ../include/openssl/buffer.h ../include/openssl/crypto.h 94rsaref.o: ../include/openssl/buffer.h ../include/openssl/crypto.h
94rsaref.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 95rsaref.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
95rsaref.o: ../include/openssl/err.h ../include/openssl/opensslconf.h 96rsaref.o: ../include/openssl/err.h ../include/openssl/opensslconf.h
96rsaref.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 97rsaref.o: ../include/openssl/opensslv.h ../include/openssl/rand.h
97rsaref.o: ../include/openssl/rsa.h ../include/openssl/rsaref.h 98rsaref.o: ../include/openssl/rsa.h ../include/openssl/rsaref.h
98rsaref.o: ../include/openssl/stack.h 99rsaref.o: ../include/openssl/safestack.h ../include/openssl/stack.h
diff --git a/src/lib/libssl/src/rsaref/rsaref.c b/src/lib/libssl/src/rsaref/rsaref.c
index 7677eb9fce..ae70feb3e9 100644
--- a/src/lib/libssl/src/rsaref/rsaref.c
+++ b/src/lib/libssl/src/rsaref/rsaref.c
@@ -279,7 +279,8 @@ int RSA_ref_public_encrypt(int len, unsigned char *from, unsigned char *to,
279 R_GetRandomBytesNeeded((unsigned int *)&i,&rnd); 279 R_GetRandomBytesNeeded((unsigned int *)&i,&rnd);
280 while (i > 0) 280 while (i > 0)
281 { 281 {
282 RAND_bytes(buf,16); 282 if (RAND_bytes(buf,16) <= 0)
283 goto err;
283 R_RandomUpdate(&rnd,buf,(unsigned int)((i>16)?16:i)); 284 R_RandomUpdate(&rnd,buf,(unsigned int)((i>16)?16:i));
284 i-=16; 285 i-=16;
285 } 286 }
@@ -298,4 +299,10 @@ err:
298 memset(&rnd,0,sizeof(rnd)); 299 memset(&rnd,0,sizeof(rnd));
299 return(outlen); 300 return(outlen);
300 } 301 }
302#else /* !NO_RSA */
303
304# if PEDANTIC
305static void *dummy=&dummy;
306# endif
307
301#endif 308#endif
diff --git a/src/lib/libssl/src/ssl/Makefile.ssl b/src/lib/libssl/src/ssl/Makefile.ssl
index f0d4775900..7165804eb3 100644
--- a/src/lib/libssl/src/ssl/Makefile.ssl
+++ b/src/lib/libssl/src/ssl/Makefile.ssl
@@ -537,9 +537,10 @@ ssl_asn1.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h
537ssl_cert.o: ../include/openssl/asn1.h ../include/openssl/bio.h 537ssl_cert.o: ../include/openssl/asn1.h ../include/openssl/bio.h
538ssl_cert.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 538ssl_cert.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
539ssl_cert.o: ../include/openssl/buffer.h ../include/openssl/cast.h 539ssl_cert.o: ../include/openssl/buffer.h ../include/openssl/cast.h
540ssl_cert.o: ../include/openssl/comp.h ../include/openssl/crypto.h 540ssl_cert.o: ../include/openssl/comp.h ../include/openssl/conf.h
541ssl_cert.o: ../include/openssl/des.h ../include/openssl/dh.h 541ssl_cert.o: ../include/openssl/crypto.h ../include/openssl/des.h
542ssl_cert.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 542ssl_cert.o: ../include/openssl/dh.h ../include/openssl/dsa.h
543ssl_cert.o: ../include/openssl/e_os.h ../include/openssl/e_os.h
543ssl_cert.o: ../include/openssl/e_os2.h ../include/openssl/err.h 544ssl_cert.o: ../include/openssl/e_os2.h ../include/openssl/err.h
544ssl_cert.o: ../include/openssl/evp.h ../include/openssl/idea.h 545ssl_cert.o: ../include/openssl/evp.h ../include/openssl/idea.h
545ssl_cert.o: ../include/openssl/lhash.h ../include/openssl/md2.h 546ssl_cert.o: ../include/openssl/lhash.h ../include/openssl/md2.h
@@ -554,7 +555,8 @@ ssl_cert.o: ../include/openssl/sha.h ../include/openssl/ssl.h
554ssl_cert.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 555ssl_cert.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
555ssl_cert.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 556ssl_cert.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
556ssl_cert.o: ../include/openssl/tls1.h ../include/openssl/x509.h 557ssl_cert.o: ../include/openssl/tls1.h ../include/openssl/x509.h
557ssl_cert.o: ../include/openssl/x509_vfy.h ssl_locl.h 558ssl_cert.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h
559ssl_cert.o: ssl_locl.h
558ssl_ciph.o: ../include/openssl/asn1.h ../include/openssl/bio.h 560ssl_ciph.o: ../include/openssl/asn1.h ../include/openssl/bio.h
559ssl_ciph.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 561ssl_ciph.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
560ssl_ciph.o: ../include/openssl/buffer.h ../include/openssl/cast.h 562ssl_ciph.o: ../include/openssl/buffer.h ../include/openssl/cast.h
@@ -619,24 +621,25 @@ ssl_err2.o: ../include/openssl/x509_vfy.h
619ssl_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h 621ssl_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h
620ssl_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 622ssl_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
621ssl_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h 623ssl_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h
622ssl_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h 624ssl_lib.o: ../include/openssl/comp.h ../include/openssl/conf.h
623ssl_lib.o: ../include/openssl/des.h ../include/openssl/dh.h 625ssl_lib.o: ../include/openssl/crypto.h ../include/openssl/des.h
624ssl_lib.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 626ssl_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h
625ssl_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 627ssl_lib.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
626ssl_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h 628ssl_lib.o: ../include/openssl/err.h ../include/openssl/evp.h
627ssl_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h 629ssl_lib.o: ../include/openssl/idea.h ../include/openssl/lhash.h
628ssl_lib.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 630ssl_lib.o: ../include/openssl/md2.h ../include/openssl/md5.h
629ssl_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 631ssl_lib.o: ../include/openssl/mdc2.h ../include/openssl/objects.h
630ssl_lib.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 632ssl_lib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
631ssl_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 633ssl_lib.o: ../include/openssl/pem.h ../include/openssl/pem2.h
632ssl_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 634ssl_lib.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h
633ssl_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 635ssl_lib.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
634ssl_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 636ssl_lib.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
635ssl_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h 637ssl_lib.o: ../include/openssl/safestack.h ../include/openssl/sha.h
636ssl_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 638ssl_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
637ssl_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 639ssl_lib.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
638ssl_lib.o: ../include/openssl/tls1.h ../include/openssl/x509.h 640ssl_lib.o: ../include/openssl/stack.h ../include/openssl/tls1.h
639ssl_lib.o: ../include/openssl/x509_vfy.h ssl_locl.h 641ssl_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
642ssl_lib.o: ../include/openssl/x509v3.h ssl_locl.h
640ssl_rsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 643ssl_rsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h
641ssl_rsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 644ssl_rsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
642ssl_rsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h 645ssl_rsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
diff --git a/src/lib/libssl/src/ssl/bio_ssl.c b/src/lib/libssl/src/ssl/bio_ssl.c
index f62cde4e5d..d73c41adcd 100644
--- a/src/lib/libssl/src/ssl/bio_ssl.c
+++ b/src/lib/libssl/src/ssl/bio_ssl.c
@@ -71,6 +71,7 @@ static int ssl_puts(BIO *h,char *str);
71static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2); 71static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2);
72static int ssl_new(BIO *h); 72static int ssl_new(BIO *h);
73static int ssl_free(BIO *data); 73static int ssl_free(BIO *data);
74static long ssl_callback_ctrl(BIO *h,int cmd,void (*fp)());
74typedef struct bio_ssl_st 75typedef struct bio_ssl_st
75 { 76 {
76 SSL *ssl; /* The ssl handle :-) */ 77 SSL *ssl; /* The ssl handle :-) */
@@ -92,6 +93,7 @@ static BIO_METHOD methods_sslp=
92 ssl_ctrl, 93 ssl_ctrl,
93 ssl_new, 94 ssl_new,
94 ssl_free, 95 ssl_free,
96 ssl_callback_ctrl,
95 }; 97 };
96 98
97BIO_METHOD *BIO_f_ssl(void) 99BIO_METHOD *BIO_f_ssl(void)
@@ -444,7 +446,14 @@ static long ssl_ctrl(BIO *b, int cmd, long num, char *ptr)
444 ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); 446 ret=BIO_ctrl(ssl->rbio,cmd,num,ptr);
445 break; 447 break;
446 case BIO_CTRL_SET_CALLBACK: 448 case BIO_CTRL_SET_CALLBACK:
447 SSL_set_info_callback(ssl,(void (*)())ptr); 449 {
450#if 0 /* FIXME: Should this be used? -- Richard Levitte */
451 BIOerr(SSL_F_SSL_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
452 ret = -1;
453#else
454 ret=0;
455#endif
456 }
448 break; 457 break;
449 case BIO_CTRL_GET_CALLBACK: 458 case BIO_CTRL_GET_CALLBACK:
450 { 459 {
@@ -461,6 +470,28 @@ static long ssl_ctrl(BIO *b, int cmd, long num, char *ptr)
461 return(ret); 470 return(ret);
462 } 471 }
463 472
473static long ssl_callback_ctrl(BIO *b, int cmd, void (*fp)())
474 {
475 SSL *ssl;
476 BIO_SSL *bs;
477 long ret=1;
478
479 bs=(BIO_SSL *)b->ptr;
480 ssl=bs->ssl;
481 switch (cmd)
482 {
483 case BIO_CTRL_SET_CALLBACK:
484 {
485 SSL_set_info_callback(ssl,fp);
486 }
487 break;
488 default:
489 ret=BIO_callback_ctrl(ssl->rbio,cmd,fp);
490 break;
491 }
492 return(ret);
493 }
494
464static int ssl_puts(BIO *bp, char *str) 495static int ssl_puts(BIO *bp, char *str)
465 { 496 {
466 int n,ret; 497 int n,ret;
diff --git a/src/lib/libssl/src/ssl/install.com b/src/lib/libssl/src/ssl/install.com
index 2b62f4e499..5d20201e8a 100644
--- a/src/lib/libssl/src/ssl/install.com
+++ b/src/lib/libssl/src/ssl/install.com
@@ -46,6 +46,7 @@ $ VEXE_DIR := [-.VAX.EXE.SSL]
46$ AEXE_DIR := [-.AXP.EXE.SSL] 46$ AEXE_DIR := [-.AXP.EXE.SSL]
47$ 47$
48$ COPY 'EXHEADER' WRK_SSLINCLUDE:/LOG 48$ COPY 'EXHEADER' WRK_SSLINCLUDE:/LOG
49$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'EXHEADER'
49$ 50$
50$ I = 0 51$ I = 0
51$ LOOP_EXE: 52$ LOOP_EXE:
diff --git a/src/lib/libssl/src/ssl/s23_clnt.c b/src/lib/libssl/src/ssl/s23_clnt.c
index 299d2ae5d2..aaedf6a9bb 100644
--- a/src/lib/libssl/src/ssl/s23_clnt.c
+++ b/src/lib/libssl/src/ssl/s23_clnt.c
@@ -68,8 +68,10 @@ 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 if (ver == SSL2_VERSION) 72 if (ver == SSL2_VERSION)
72 return(SSLv2_client_method()); 73 return(SSLv2_client_method());
74#endif
73 if (ver == SSL3_VERSION) 75 if (ver == SSL3_VERSION)
74 return(SSLv3_client_method()); 76 return(SSLv3_client_method());
75 else if (ver == TLS1_VERSION) 77 else if (ver == TLS1_VERSION)
@@ -102,7 +104,7 @@ int ssl23_connect(SSL *s)
102 int ret= -1; 104 int ret= -1;
103 int new_state,state; 105 int new_state,state;
104 106
105 RAND_seed(&Time,sizeof(Time)); 107 RAND_add(&Time,sizeof(Time),0);
106 ERR_clear_error(); 108 ERR_clear_error();
107 clear_sys_error(); 109 clear_sys_error();
108 110
@@ -222,7 +224,7 @@ static int ssl23_client_hello(SSL *s)
222#endif 224#endif
223 225
224 p=s->s3->client_random; 226 p=s->s3->client_random;
225 RAND_bytes(p,SSL3_RANDOM_SIZE); 227 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE);
226 228
227 /* Do the message type and length last */ 229 /* Do the message type and length last */
228 d= &(buf[2]); 230 d= &(buf[2]);
@@ -283,7 +285,7 @@ static int ssl23_client_hello(SSL *s)
283 i=ch_len; 285 i=ch_len;
284 s2n(i,d); 286 s2n(i,d);
285 memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE); 287 memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE);
286 RAND_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); 288 RAND_pseudo_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);
287 memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); 289 memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);
288 p+=i; 290 p+=i;
289 291
@@ -307,7 +309,7 @@ static int ssl23_get_server_hello(SSL *s)
307 { 309 {
308 char buf[8]; 310 char buf[8];
309 unsigned char *p; 311 unsigned char *p;
310 int i,ch_len; 312 int i;
311 int n; 313 int n;
312 314
313 n=ssl23_read_bytes(s,7); 315 n=ssl23_read_bytes(s,7);
@@ -320,9 +322,14 @@ static int ssl23_get_server_hello(SSL *s)
320 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && 322 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) &&
321 (p[5] == 0x00) && (p[6] == 0x02)) 323 (p[5] == 0x00) && (p[6] == 0x02))
322 { 324 {
325#ifdef NO_SSL2
326 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
327 goto err;
328#else
323 /* we are talking sslv2 */ 329 /* we are talking sslv2 */
324 /* we need to clean up the SSLv3 setup and put in the 330 /* we need to clean up the SSLv3 setup and put in the
325 * sslv2 stuff. */ 331 * sslv2 stuff. */
332 int ch_len;
326 333
327 if (s->options & SSL_OP_NO_SSLv2) 334 if (s->options & SSL_OP_NO_SSLv2)
328 { 335 {
@@ -375,6 +382,7 @@ static int ssl23_get_server_hello(SSL *s)
375 382
376 s->method=SSLv2_client_method(); 383 s->method=SSLv2_client_method();
377 s->handshake_func=s->method->ssl_connect; 384 s->handshake_func=s->method->ssl_connect;
385#endif
378 } 386 }
379 else if ((p[0] == SSL3_RT_HANDSHAKE) && 387 else if ((p[0] == SSL3_RT_HANDSHAKE) &&
380 (p[1] == SSL3_VERSION_MAJOR) && 388 (p[1] == SSL3_VERSION_MAJOR) &&
diff --git a/src/lib/libssl/src/ssl/s23_lib.c b/src/lib/libssl/src/ssl/s23_lib.c
index 822a395837..dded7a19c5 100644
--- a/src/lib/libssl/src/ssl/s23_lib.c
+++ b/src/lib/libssl/src/ssl/s23_lib.c
@@ -67,7 +67,7 @@ static int ssl23_write(SSL *s, const void *buf, int len);
67static long ssl23_default_timeout(void ); 67static long ssl23_default_timeout(void );
68static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); 68static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
69static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p); 69static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p);
70char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT; 70const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT;
71 71
72static SSL_METHOD SSLv23_data= { 72static SSL_METHOD SSLv23_data= {
73 TLS1_VERSION, 73 TLS1_VERSION,
@@ -92,6 +92,9 @@ static SSL_METHOD SSLv23_data= {
92 ssl_bad_method, 92 ssl_bad_method,
93 ssl23_default_timeout, 93 ssl23_default_timeout,
94 &ssl3_undef_enc_method, 94 &ssl3_undef_enc_method,
95 ssl_undefined_function,
96 ssl3_callback_ctrl,
97 ssl3_ctx_callback_ctrl,
95 }; 98 };
96 99
97static long ssl23_default_timeout(void) 100static long ssl23_default_timeout(void)
@@ -106,7 +109,11 @@ SSL_METHOD *sslv23_base_method(void)
106 109
107static int ssl23_num_ciphers(void) 110static int ssl23_num_ciphers(void)
108 { 111 {
109 return(ssl3_num_ciphers()+ssl2_num_ciphers()); 112 return(ssl3_num_ciphers()
113#ifndef NO_SSL2
114 + ssl2_num_ciphers()
115#endif
116 );
110 } 117 }
111 118
112static SSL_CIPHER *ssl23_get_cipher(unsigned int u) 119static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
@@ -116,7 +123,11 @@ static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
116 if (u < uu) 123 if (u < uu)
117 return(ssl3_get_cipher(u)); 124 return(ssl3_get_cipher(u));
118 else 125 else
126#ifndef NO_SSL2
119 return(ssl2_get_cipher(u-uu)); 127 return(ssl2_get_cipher(u-uu));
128#else
129 return(NULL);
130#endif
120 } 131 }
121 132
122/* This function needs to check if the ciphers required are actually 133/* This function needs to check if the ciphers required are actually
@@ -132,8 +143,10 @@ static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p)
132 ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; 143 ((unsigned long)p[1]<<8L)|(unsigned long)p[2];
133 c.id=id; 144 c.id=id;
134 cp=ssl3_get_cipher_by_char(p); 145 cp=ssl3_get_cipher_by_char(p);
146#ifndef NO_SSL2
135 if (cp == NULL) 147 if (cp == NULL)
136 cp=ssl2_get_cipher_by_char(p); 148 cp=ssl2_get_cipher_by_char(p);
149#endif
137 return(cp); 150 return(cp);
138 } 151 }
139 152
diff --git a/src/lib/libssl/src/ssl/s23_pkt.c b/src/lib/libssl/src/ssl/s23_pkt.c
index 8370ea508c..f45e1ce3d8 100644
--- a/src/lib/libssl/src/ssl/s23_pkt.c
+++ b/src/lib/libssl/src/ssl/s23_pkt.c
@@ -89,7 +89,7 @@ int ssl23_write_bytes(SSL *s)
89 } 89 }
90 } 90 }
91 91
92/* only return when we have read 'n' bytes */ 92/* return regularly only when we have read (at least) 'n' bytes */
93int ssl23_read_bytes(SSL *s, int n) 93int ssl23_read_bytes(SSL *s, int n)
94 { 94 {
95 unsigned char *p; 95 unsigned char *p;
diff --git a/src/lib/libssl/src/ssl/s23_srvr.c b/src/lib/libssl/src/ssl/s23_srvr.c
index e4122f2d78..6a3bbb10b9 100644
--- a/src/lib/libssl/src/ssl/s23_srvr.c
+++ b/src/lib/libssl/src/ssl/s23_srvr.c
@@ -67,8 +67,10 @@ static SSL_METHOD *ssl23_get_server_method(int ver);
67int ssl23_get_client_hello(SSL *s); 67int ssl23_get_client_hello(SSL *s);
68static SSL_METHOD *ssl23_get_server_method(int ver) 68static SSL_METHOD *ssl23_get_server_method(int ver)
69 { 69 {
70#ifndef NO_SSL2
70 if (ver == SSL2_VERSION) 71 if (ver == SSL2_VERSION)
71 return(SSLv2_server_method()); 72 return(SSLv2_server_method());
73#endif
72 if (ver == SSL3_VERSION) 74 if (ver == SSL3_VERSION)
73 return(SSLv3_server_method()); 75 return(SSLv3_server_method());
74 else if (ver == TLS1_VERSION) 76 else if (ver == TLS1_VERSION)
@@ -101,7 +103,7 @@ int ssl23_accept(SSL *s)
101 int ret= -1; 103 int ret= -1;
102 int new_state,state; 104 int new_state,state;
103 105
104 RAND_seed(&Time,sizeof(Time)); 106 RAND_add(&Time,sizeof(Time),0);
105 ERR_clear_error(); 107 ERR_clear_error();
106 clear_sys_error(); 108 clear_sys_error();
107 109
@@ -186,23 +188,39 @@ end:
186 188
187int ssl23_get_client_hello(SSL *s) 189int ssl23_get_client_hello(SSL *s)
188 { 190 {
189 char buf_space[8]; 191 char buf_space[11]; /* Request this many bytes in initial read.
192 * We can detect SSL 3.0/TLS 1.0 Client Hellos
193 * ('type == 3') correctly only when the following
194 * is in a single record, which is not guaranteed by
195 * the protocol specification:
196 * Byte Content
197 * 0 type \
198 * 1/2 version > record header
199 * 3/4 length /
200 * 5 msg_type \
201 * 6-8 length > Client Hello message
202 * 9/10 client_version /
203 */
190 char *buf= &(buf_space[0]); 204 char *buf= &(buf_space[0]);
191 unsigned char *p,*d,*dd; 205 unsigned char *p,*d,*dd;
192 unsigned int i; 206 unsigned int i;
193 unsigned int csl,sil,cl; 207 unsigned int csl,sil,cl;
194 int n=0,j,tls1=0; 208 int n=0,j;
195 int type=0,use_sslv2_strong=0; 209 int type=0;
196 int v[2]; 210 int v[2];
211#ifndef NO_RSA
212 int use_sslv2_strong=0;
213#endif
197 214
198 /* read the initial header */
199 v[0]=v[1]=0;
200 if (s->state == SSL23_ST_SR_CLNT_HELLO_A) 215 if (s->state == SSL23_ST_SR_CLNT_HELLO_A)
201 { 216 {
217 /* read the initial header */
218 v[0]=v[1]=0;
219
202 if (!ssl3_setup_buffers(s)) goto err; 220 if (!ssl3_setup_buffers(s)) goto err;
203 221
204 n=ssl23_read_bytes(s,7); 222 n=ssl23_read_bytes(s, sizeof buf_space);
205 if (n != 7) return(n); /* n == -1 || n == 0 */ 223 if (n != sizeof buf_space) return(n); /* n == -1 || n == 0 */
206 224
207 p=s->packet; 225 p=s->packet;
208 226
@@ -210,7 +228,9 @@ int ssl23_get_client_hello(SSL *s)
210 228
211 if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) 229 if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO))
212 { 230 {
213 /* SSLv2 header */ 231 /*
232 * SSLv2 header
233 */
214 if ((p[3] == 0x00) && (p[4] == 0x02)) 234 if ((p[3] == 0x00) && (p[4] == 0x02))
215 { 235 {
216 v[0]=p[3]; v[1]=p[4]; 236 v[0]=p[3]; v[1]=p[4];
@@ -226,11 +246,14 @@ int ssl23_get_client_hello(SSL *s)
226 { 246 {
227 if (!(s->options & SSL_OP_NO_TLSv1)) 247 if (!(s->options & SSL_OP_NO_TLSv1))
228 { 248 {
229 tls1=1; 249 s->version=TLS1_VERSION;
250 /* type=2; */ /* done later to survive restarts */
230 s->state=SSL23_ST_SR_CLNT_HELLO_B; 251 s->state=SSL23_ST_SR_CLNT_HELLO_B;
231 } 252 }
232 else if (!(s->options & SSL_OP_NO_SSLv3)) 253 else if (!(s->options & SSL_OP_NO_SSLv3))
233 { 254 {
255 s->version=SSL3_VERSION;
256 /* type=2; */
234 s->state=SSL23_ST_SR_CLNT_HELLO_B; 257 s->state=SSL23_ST_SR_CLNT_HELLO_B;
235 } 258 }
236 else if (!(s->options & SSL_OP_NO_SSLv2)) 259 else if (!(s->options & SSL_OP_NO_SSLv2))
@@ -239,12 +262,26 @@ int ssl23_get_client_hello(SSL *s)
239 } 262 }
240 } 263 }
241 else if (!(s->options & SSL_OP_NO_SSLv3)) 264 else if (!(s->options & SSL_OP_NO_SSLv3))
265 {
266 s->version=SSL3_VERSION;
267 /* type=2; */
242 s->state=SSL23_ST_SR_CLNT_HELLO_B; 268 s->state=SSL23_ST_SR_CLNT_HELLO_B;
269 }
243 else if (!(s->options & SSL_OP_NO_SSLv2)) 270 else if (!(s->options & SSL_OP_NO_SSLv2))
244 type=1; 271 type=1;
245 272
246 if (s->options & SSL_OP_NON_EXPORT_FIRST) 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 */
247 { 283 {
284#if 0
248 STACK_OF(SSL_CIPHER) *sk; 285 STACK_OF(SSL_CIPHER) *sk;
249 SSL_CIPHER *c; 286 SSL_CIPHER *c;
250 int ne2,ne3; 287 int ne2,ne3;
@@ -294,27 +331,51 @@ int ssl23_get_client_hello(SSL *s)
294 goto next_bit; 331 goto next_bit;
295 } 332 }
296 } 333 }
334#else
335 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_OPTION);
336 goto err;
337#endif
297 } 338 }
298 } 339 }
299 } 340 }
300 else if ((p[0] == SSL3_RT_HANDSHAKE) && 341 else if ((p[0] == SSL3_RT_HANDSHAKE) &&
301 (p[1] == SSL3_VERSION_MAJOR) && 342 (p[1] == SSL3_VERSION_MAJOR) &&
302 (p[5] == SSL3_MT_CLIENT_HELLO)) 343 (p[5] == SSL3_MT_CLIENT_HELLO) &&
344 ((p[3] == 0 && p[4] < 5 /* silly record length? */)
345 || (p[9] == p[1])))
303 { 346 {
304 v[0]=p[1]; v[1]=p[2]; 347 /*
305 /* true SSLv3 or tls1 */ 348 * SSLv3 or tls1 header
306 if (p[2] >= TLS1_VERSION_MINOR) 349 */
350
351 v[0]=p[1]; /* major version */
352 /* We must look at client_version inside the Client Hello message
353 * to get the correct minor version: */
354 v[1]=p[10];
355 /* However if we have only a pathologically small fragment of the
356 * Client Hello message, we simply use the version from the
357 * record header -- this is incorrect but unlikely to fail in
358 * practice */
359 if (p[3] == 0 && p[4] < 6)
360 v[1]=p[2];
361 if (v[1] >= TLS1_VERSION_MINOR)
307 { 362 {
308 if (!(s->options & SSL_OP_NO_TLSv1)) 363 if (!(s->options & SSL_OP_NO_TLSv1))
309 { 364 {
365 s->version=TLS1_VERSION;
310 type=3; 366 type=3;
311 tls1=1;
312 } 367 }
313 else if (!(s->options & SSL_OP_NO_SSLv3)) 368 else if (!(s->options & SSL_OP_NO_SSLv3))
369 {
370 s->version=SSL3_VERSION;
314 type=3; 371 type=3;
372 }
315 } 373 }
316 else if (!(s->options & SSL_OP_NO_SSLv3)) 374 else if (!(s->options & SSL_OP_NO_SSLv3))
375 {
376 s->version=SSL3_VERSION;
317 type=3; 377 type=3;
378 }
318 } 379 }
319 else if ((strncmp("GET ", (char *)p,4) == 0) || 380 else if ((strncmp("GET ", (char *)p,4) == 0) ||
320 (strncmp("POST ",(char *)p,5) == 0) || 381 (strncmp("POST ",(char *)p,5) == 0) ||
@@ -331,12 +392,16 @@ int ssl23_get_client_hello(SSL *s)
331 } 392 }
332 } 393 }
333 394
334next_bit:
335 if (s->state == SSL23_ST_SR_CLNT_HELLO_B) 395 if (s->state == SSL23_ST_SR_CLNT_HELLO_B)
336 { 396 {
337 /* we have a SSLv3/TLSv1 in a SSLv2 header */ 397 /* we have SSLv3/TLSv1 in an SSLv2 header
398 * (other cases skip this state) */
399
338 type=2; 400 type=2;
339 p=s->packet; 401 p=s->packet;
402 v[0] = p[3]; /* == SSL3_VERSION_MAJOR */
403 v[1] = p[4];
404
340 n=((p[0]&0x7f)<<8)|p[1]; 405 n=((p[0]&0x7f)<<8)|p[1];
341 if (n > (1024*4)) 406 if (n > (1024*4))
342 { 407 {
@@ -361,14 +426,11 @@ next_bit:
361 goto err; 426 goto err;
362 } 427 }
363 428
364 *(d++)=SSL3_VERSION_MAJOR; 429 *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */
365 if (tls1) 430 *(d++) = v[1];
366 *(d++)=TLS1_VERSION_MINOR;
367 else
368 *(d++)=SSL3_VERSION_MINOR;
369 431
370 /* lets populate the random area */ 432 /* lets populate the random area */
371 /* get the chalenge_length */ 433 /* get the challenge_length */
372 i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl; 434 i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl;
373 memset(d,0,SSL3_RANDOM_SIZE); 435 memset(d,0,SSL3_RANDOM_SIZE);
374 memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i); 436 memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i);
@@ -402,8 +464,15 @@ next_bit:
402 s->s3->tmp.message_size=i; 464 s->s3->tmp.message_size=i;
403 } 465 }
404 466
467 /* imaginary new state (for program structure): */
468 /* s->state = SSL23_SR_CLNT_HELLO_C */
469
405 if (type == 1) 470 if (type == 1)
406 { 471 {
472#ifdef NO_SSL2
473 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
474 goto err;
475#else
407 /* we are talking sslv2 */ 476 /* we are talking sslv2 */
408 /* we need to clean up the SSLv3/TLSv1 setup and put in the 477 /* we need to clean up the SSLv3/TLSv1 setup and put in the
409 * sslv2 stuff. */ 478 * sslv2 stuff. */
@@ -431,7 +500,7 @@ next_bit:
431 else 500 else
432 s->s2->ssl2_rollback=1; 501 s->s2->ssl2_rollback=1;
433 502
434 /* setup the 5 bytes we have read so we get them from 503 /* setup the n bytes we have read so we get them from
435 * the sslv2 buffer */ 504 * the sslv2 buffer */
436 s->rstate=SSL_ST_READ_HEADER; 505 s->rstate=SSL_ST_READ_HEADER;
437 s->packet_length=n; 506 s->packet_length=n;
@@ -442,11 +511,12 @@ next_bit:
442 511
443 s->method=SSLv2_server_method(); 512 s->method=SSLv2_server_method();
444 s->handshake_func=s->method->ssl_accept; 513 s->handshake_func=s->method->ssl_accept;
514#endif
445 } 515 }
446 516
447 if ((type == 2) || (type == 3)) 517 if ((type == 2) || (type == 3))
448 { 518 {
449 /* we have SSLv3/TLSv1 */ 519 /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */
450 520
451 if (!ssl_init_wbio_buffer(s,1)) goto err; 521 if (!ssl_init_wbio_buffer(s,1)) goto err;
452 522
@@ -471,17 +541,13 @@ next_bit:
471 s->s3->rbuf.offset=0; 541 s->s3->rbuf.offset=0;
472 } 542 }
473 543
474 if (tls1) 544 if (s->version == TLS1_VERSION)
475 { 545 s->method = TLSv1_server_method();
476 s->version=TLS1_VERSION;
477 s->method=TLSv1_server_method();
478 }
479 else 546 else
480 { 547 s->method = SSLv3_server_method();
481 s->version=SSL3_VERSION; 548#if 0 /* ssl3_get_client_hello does this */
482 s->method=SSLv3_server_method();
483 }
484 s->client_version=(v[0]<<8)|v[1]; 549 s->client_version=(v[0]<<8)|v[1];
550#endif
485 s->handshake_func=s->method->ssl_accept; 551 s->handshake_func=s->method->ssl_accept;
486 } 552 }
487 553
@@ -500,4 +566,3 @@ err:
500 if (buf != buf_space) Free(buf); 566 if (buf != buf_space) Free(buf);
501 return(-1); 567 return(-1);
502 } 568 }
503
diff --git a/src/lib/libssl/src/ssl/s2_clnt.c b/src/lib/libssl/src/ssl/s2_clnt.c
index 1fe8bd627d..6ff6a51362 100644
--- a/src/lib/libssl/src/ssl/s2_clnt.c
+++ b/src/lib/libssl/src/ssl/s2_clnt.c
@@ -56,12 +56,12 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#include "ssl_locl.h"
60#ifndef NO_SSL2
60#include <stdio.h> 61#include <stdio.h>
61#include <openssl/rand.h> 62#include <openssl/rand.h>
62#include <openssl/buffer.h> 63#include <openssl/buffer.h>
63#include <openssl/objects.h> 64#include <openssl/objects.h>
64#include "ssl_locl.h"
65#include <openssl/evp.h> 65#include <openssl/evp.h>
66 66
67static SSL_METHOD *ssl2_get_client_method(int ver); 67static SSL_METHOD *ssl2_get_client_method(int ver);
@@ -108,7 +108,7 @@ int ssl2_connect(SSL *s)
108 void (*cb)()=NULL; 108 void (*cb)()=NULL;
109 int new_state,state; 109 int new_state,state;
110 110
111 RAND_seed(&l,sizeof(l)); 111 RAND_add(&l,sizeof(l),0);
112 ERR_clear_error(); 112 ERR_clear_error();
113 clear_sys_error(); 113 clear_sys_error();
114 114
@@ -245,7 +245,7 @@ int ssl2_connect(SSL *s)
245 /* ERR_clear_error();*/ 245 /* ERR_clear_error();*/
246 246
247 /* If we want to cache session-ids in the client 247 /* If we want to cache session-ids in the client
248 * and we sucessfully add the session-id to the 248 * and we successfully add the session-id to the
249 * cache, and there is a callback, then pass it out. 249 * cache, and there is a callback, then pass it out.
250 * 26/11/96 - eay - only add if not a re-used session. 250 * 26/11/96 - eay - only add if not a re-used session.
251 */ 251 */
@@ -310,7 +310,13 @@ static int get_server_hello(SSL *s)
310 SSL_R_PEER_ERROR); 310 SSL_R_PEER_ERROR);
311 return(-1); 311 return(-1);
312 } 312 }
313#ifdef __APPLE_CC__
314 /* The Rhapsody 5.5 (a.k.a. MacOS X) compiler bug
315 * workaround. <appro@fy.chalmers.se> */
316 s->hit=(i=*(p++))?1:0;
317#else
313 s->hit=(*(p++))?1:0; 318 s->hit=(*(p++))?1:0;
319#endif
314 s->s2->tmp.cert_type= *(p++); 320 s->s2->tmp.cert_type= *(p++);
315 n2s(p,i); 321 n2s(p,i);
316 if (i < s->version) s->version=i; 322 if (i < s->version) s->version=i;
@@ -362,7 +368,7 @@ static int get_server_hello(SSL *s)
362 */ 368 */
363#endif 369#endif
364 370
365 /* we need to do this incase we were trying to reuse a 371 /* we need to do this in case we were trying to reuse a
366 * client session but others are already reusing it. 372 * client session but others are already reusing it.
367 * If this was a new 'blank' session ID, the session-id 373 * If this was a new 'blank' session ID, the session-id
368 * length will still be 0 */ 374 * length will still be 0 */
@@ -412,7 +418,7 @@ static int get_server_hello(SSL *s)
412 418
413 /* In theory we could have ciphers sent back that we 419 /* In theory we could have ciphers sent back that we
414 * don't want to use but that does not matter since we 420 * don't want to use but that does not matter since we
415 * will check against the list we origionally sent and 421 * will check against the list we originally sent and
416 * for performance reasons we should not bother to match 422 * for performance reasons we should not bother to match
417 * the two lists up just to check. */ 423 * the two lists up just to check. */
418 for (i=0; i<sk_SSL_CIPHER_num(cl); i++) 424 for (i=0; i<sk_SSL_CIPHER_num(cl); i++)
@@ -429,26 +435,28 @@ static int get_server_hello(SSL *s)
429 return(-1); 435 return(-1);
430 } 436 }
431 s->session->cipher=sk_SSL_CIPHER_value(cl,i); 437 s->session->cipher=sk_SSL_CIPHER_value(cl,i);
432 }
433 438
434 if (s->session->peer != NULL)
435 X509_free(s->session->peer);
436
437#if 0 /* What is all this meant to accomplish?? */
438 /* hmmm, can we have the problem of the other session with this
439 * cert, Free's it before we increment the reference count. */
440 CRYPTO_w_lock(CRYPTO_LOCK_X509);
441 s->session->peer=s->session->sess_cert->key->x509;
442 /* Shouldn't do this: already locked */
443 /*CRYPTO_add(&s->session->peer->references,1,CRYPTO_LOCK_X509);*/
444 s->session->peer->references++;
445 CRYPTO_w_unlock(CRYPTO_LOCK_X509);
446#else
447 s->session->peer = s->session->sess_cert->peer_key->x509;
448 /* peer_key->x509 has been set by ssl2_set_certificate. */
449 CRYPTO_add(&s->session->peer->references, 1, CRYPTO_LOCK_X509);
450#endif
451 439
440 if (s->session->peer != NULL) /* can't happen*/
441 {
442 ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
443 SSLerr(SSL_F_GET_SERVER_HELLO, SSL_R_INTERNAL_ERROR);
444 return(-1);
445 }
446
447 s->session->peer = s->session->sess_cert->peer_key->x509;
448 /* peer_key->x509 has been set by ssl2_set_certificate. */
449 CRYPTO_add(&s->session->peer->references, 1, CRYPTO_LOCK_X509);
450 }
451
452 if (s->session->peer != s->session->sess_cert->peer_key->x509)
453 /* can't happen */
454 {
455 ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
456 SSLerr(SSL_F_GET_SERVER_HELLO, SSL_R_INTERNAL_ERROR);
457 return(-1);
458 }
459
452 s->s2->conn_id_length=s->s2->tmp.conn_id_length; 460 s->s2->conn_id_length=s->s2->tmp.conn_id_length;
453 memcpy(s->s2->conn_id,p,s->s2->tmp.conn_id_length); 461 memcpy(s->s2->conn_id,p,s->s2->tmp.conn_id_length);
454 return(1); 462 return(1);
@@ -509,7 +517,7 @@ static int client_hello(SSL *s)
509 s->s2->challenge_length=SSL2_CHALLENGE_LENGTH; 517 s->s2->challenge_length=SSL2_CHALLENGE_LENGTH;
510 s2n(SSL2_CHALLENGE_LENGTH,p); /* challenge length */ 518 s2n(SSL2_CHALLENGE_LENGTH,p); /* challenge length */
511 /*challenge id data*/ 519 /*challenge id data*/
512 RAND_bytes(s->s2->challenge,SSL2_CHALLENGE_LENGTH); 520 RAND_pseudo_bytes(s->s2->challenge,SSL2_CHALLENGE_LENGTH);
513 memcpy(d,s->s2->challenge,SSL2_CHALLENGE_LENGTH); 521 memcpy(d,s->s2->challenge,SSL2_CHALLENGE_LENGTH);
514 d+=SSL2_CHALLENGE_LENGTH; 522 d+=SSL2_CHALLENGE_LENGTH;
515 523
@@ -551,12 +559,19 @@ static int client_master_key(SSL *s)
551 /* make key_arg data */ 559 /* make key_arg data */
552 i=EVP_CIPHER_iv_length(c); 560 i=EVP_CIPHER_iv_length(c);
553 sess->key_arg_length=i; 561 sess->key_arg_length=i;
554 if (i > 0) RAND_bytes(sess->key_arg,i); 562 if (i > 0) RAND_pseudo_bytes(sess->key_arg,i);
555 563
556 /* make a master key */ 564 /* make a master key */
557 i=EVP_CIPHER_key_length(c); 565 i=EVP_CIPHER_key_length(c);
558 sess->master_key_length=i; 566 sess->master_key_length=i;
559 if (i > 0) RAND_bytes(sess->master_key,i); 567 if (i > 0)
568 {
569 if (RAND_bytes(sess->master_key,i) <= 0)
570 {
571 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
572 return(-1);
573 }
574 }
560 575
561 if (sess->cipher->algorithm2 & SSL2_CF_8_BYTE_ENC) 576 if (sess->cipher->algorithm2 & SSL2_CF_8_BYTE_ENC)
562 enc=8; 577 enc=8;
@@ -753,7 +768,7 @@ static int client_certificate(SSL *s)
753 { 768 {
754 /* this is not good. If things have failed it 769 /* this is not good. If things have failed it
755 * means there so something wrong with the key. 770 * means there so something wrong with the key.
756 * We will contiune with a 0 length signature 771 * We will continue with a 0 length signature
757 */ 772 */
758 } 773 }
759 memset(&ctx,0,sizeof(ctx)); 774 memset(&ctx,0,sizeof(ctx));
@@ -968,4 +983,10 @@ end:
968 EVP_PKEY_free(pkey); 983 EVP_PKEY_free(pkey);
969 return(i); 984 return(i);
970 } 985 }
986#else /* !NO_SSL2 */
987
988# if PEDANTIC
989static void *dummy=&dummy;
990# endif
991
971#endif 992#endif
diff --git a/src/lib/libssl/src/ssl/s2_enc.c b/src/lib/libssl/src/ssl/s2_enc.c
index 09835008a9..a9458e7fa7 100644
--- a/src/lib/libssl/src/ssl/s2_enc.c
+++ b/src/lib/libssl/src/ssl/s2_enc.c
@@ -56,8 +56,9 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h>
60#include "ssl_locl.h" 59#include "ssl_locl.h"
60#ifndef NO_SSL2
61#include <stdio.h>
61 62
62int ssl2_enc_init(SSL *s, int client) 63int ssl2_enc_init(SSL *s, int client)
63 { 64 {
@@ -177,4 +178,10 @@ void ssl2_mac(SSL *s, unsigned char *md, int send)
177 EVP_DigestFinal(&c,md,NULL); 178 EVP_DigestFinal(&c,md,NULL);
178 /* some would say I should zero the md context */ 179 /* some would say I should zero the md context */
179 } 180 }
181#else /* !NO_SSL2 */
182
183# if PEDANTIC
184static void *dummy=&dummy;
185# endif
180 186
187#endif
diff --git a/src/lib/libssl/src/ssl/s2_lib.c b/src/lib/libssl/src/ssl/s2_lib.c
index ff804d8e0d..5ddba23a06 100644
--- a/src/lib/libssl/src/ssl/s2_lib.c
+++ b/src/lib/libssl/src/ssl/s2_lib.c
@@ -56,12 +56,12 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#include "ssl_locl.h"
60#ifndef NO_SSL2
60#include <stdio.h> 61#include <stdio.h>
61#include <openssl/rsa.h> 62#include <openssl/rsa.h>
62#include <openssl/objects.h> 63#include <openssl/objects.h>
63#include <openssl/md5.h> 64#include <openssl/md5.h>
64#include "ssl_locl.h"
65 65
66static long ssl2_default_timeout(void ); 66static long ssl2_default_timeout(void );
67const char *ssl2_version_str="SSLv2" OPENSSL_VERSION_PTEXT; 67const char *ssl2_version_str="SSLv2" OPENSSL_VERSION_PTEXT;
@@ -75,9 +75,12 @@ OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
75 1, 75 1,
76 SSL2_TXT_NULL_WITH_MD5, 76 SSL2_TXT_NULL_WITH_MD5,
77 SSL2_CK_NULL_WITH_MD5, 77 SSL2_CK_NULL_WITH_MD5,
78 SSL_kRSA|SSL_aRSA|SSL_eNULL|SSL_MD5|SSL_EXP40|SSL_SSLV2, 78 SSL_kRSA|SSL_aRSA|SSL_eNULL|SSL_MD5|SSL_SSLV2,
79 SSL_EXPORT|SSL_EXP40,
80 0,
79 0, 81 0,
80 SSL_ALL_CIPHERS, 82 SSL_ALL_CIPHERS,
83 SSL_ALL_STRENGTHS,
81 }, 84 },
82#endif 85#endif
83/* RC4_128_EXPORT40_WITH_MD5 */ 86/* RC4_128_EXPORT40_WITH_MD5 */
@@ -85,63 +88,91 @@ OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
85 1, 88 1,
86 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5, 89 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5,
87 SSL2_CK_RC4_128_EXPORT40_WITH_MD5, 90 SSL2_CK_RC4_128_EXPORT40_WITH_MD5,
88 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_EXP40|SSL_SSLV2, 91 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_SSLV2,
92 SSL_EXPORT|SSL_EXP40,
89 SSL2_CF_5_BYTE_ENC, 93 SSL2_CF_5_BYTE_ENC,
94 40,
95 128,
90 SSL_ALL_CIPHERS, 96 SSL_ALL_CIPHERS,
97 SSL_ALL_STRENGTHS,
91 }, 98 },
92/* RC4_128_WITH_MD5 */ 99/* RC4_128_WITH_MD5 */
93 { 100 {
94 1, 101 1,
95 SSL2_TXT_RC4_128_WITH_MD5, 102 SSL2_TXT_RC4_128_WITH_MD5,
96 SSL2_CK_RC4_128_WITH_MD5, 103 SSL2_CK_RC4_128_WITH_MD5,
97 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_NOT_EXP|SSL_SSLV2|SSL_MEDIUM, 104 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_SSLV2,
105 SSL_NOT_EXP|SSL_MEDIUM,
98 0, 106 0,
107 128,
108 128,
99 SSL_ALL_CIPHERS, 109 SSL_ALL_CIPHERS,
110 SSL_ALL_STRENGTHS,
100 }, 111 },
101/* RC2_128_CBC_EXPORT40_WITH_MD5 */ 112/* RC2_128_CBC_EXPORT40_WITH_MD5 */
102 { 113 {
103 1, 114 1,
104 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5, 115 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5,
105 SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5, 116 SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5,
106 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_EXP40|SSL_SSLV2, 117 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_SSLV2,
118 SSL_EXPORT|SSL_EXP40,
107 SSL2_CF_5_BYTE_ENC, 119 SSL2_CF_5_BYTE_ENC,
120 40,
121 128,
108 SSL_ALL_CIPHERS, 122 SSL_ALL_CIPHERS,
123 SSL_ALL_STRENGTHS,
109 }, 124 },
110/* RC2_128_CBC_WITH_MD5 */ 125/* RC2_128_CBC_WITH_MD5 */
111 { 126 {
112 1, 127 1,
113 SSL2_TXT_RC2_128_CBC_WITH_MD5, 128 SSL2_TXT_RC2_128_CBC_WITH_MD5,
114 SSL2_CK_RC2_128_CBC_WITH_MD5, 129 SSL2_CK_RC2_128_CBC_WITH_MD5,
115 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_NOT_EXP|SSL_SSLV2|SSL_MEDIUM, 130 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_SSLV2,
131 SSL_NOT_EXP|SSL_MEDIUM,
116 0, 132 0,
133 128,
134 128,
117 SSL_ALL_CIPHERS, 135 SSL_ALL_CIPHERS,
136 SSL_ALL_STRENGTHS,
118 }, 137 },
119/* IDEA_128_CBC_WITH_MD5 */ 138/* IDEA_128_CBC_WITH_MD5 */
120 { 139 {
121 1, 140 1,
122 SSL2_TXT_IDEA_128_CBC_WITH_MD5, 141 SSL2_TXT_IDEA_128_CBC_WITH_MD5,
123 SSL2_CK_IDEA_128_CBC_WITH_MD5, 142 SSL2_CK_IDEA_128_CBC_WITH_MD5,
124 SSL_kRSA|SSL_aRSA|SSL_IDEA|SSL_MD5|SSL_NOT_EXP|SSL_SSLV2|SSL_MEDIUM, 143 SSL_kRSA|SSL_aRSA|SSL_IDEA|SSL_MD5|SSL_SSLV2,
144 SSL_NOT_EXP|SSL_MEDIUM,
125 0, 145 0,
146 128,
147 128,
126 SSL_ALL_CIPHERS, 148 SSL_ALL_CIPHERS,
149 SSL_ALL_STRENGTHS,
127 }, 150 },
128/* DES_64_CBC_WITH_MD5 */ 151/* DES_64_CBC_WITH_MD5 */
129 { 152 {
130 1, 153 1,
131 SSL2_TXT_DES_64_CBC_WITH_MD5, 154 SSL2_TXT_DES_64_CBC_WITH_MD5,
132 SSL2_CK_DES_64_CBC_WITH_MD5, 155 SSL2_CK_DES_64_CBC_WITH_MD5,
133 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_MD5|SSL_NOT_EXP|SSL_SSLV2|SSL_LOW, 156 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_MD5|SSL_SSLV2,
157 SSL_NOT_EXP|SSL_LOW,
134 0, 158 0,
159 56,
160 56,
135 SSL_ALL_CIPHERS, 161 SSL_ALL_CIPHERS,
162 SSL_ALL_STRENGTHS,
136 }, 163 },
137/* DES_192_EDE3_CBC_WITH_MD5 */ 164/* DES_192_EDE3_CBC_WITH_MD5 */
138 { 165 {
139 1, 166 1,
140 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5, 167 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5,
141 SSL2_CK_DES_192_EDE3_CBC_WITH_MD5, 168 SSL2_CK_DES_192_EDE3_CBC_WITH_MD5,
142 SSL_kRSA|SSL_aRSA|SSL_3DES|SSL_MD5|SSL_NOT_EXP|SSL_SSLV2|SSL_HIGH, 169 SSL_kRSA|SSL_aRSA|SSL_3DES|SSL_MD5|SSL_SSLV2,
170 SSL_NOT_EXP|SSL_HIGH,
143 0, 171 0,
172 168,
173 168,
144 SSL_ALL_CIPHERS, 174 SSL_ALL_CIPHERS,
175 SSL_ALL_STRENGTHS,
145 }, 176 },
146/* RC4_64_WITH_MD5 */ 177/* RC4_64_WITH_MD5 */
147#if 1 178#if 1
@@ -149,9 +180,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
149 1, 180 1,
150 SSL2_TXT_RC4_64_WITH_MD5, 181 SSL2_TXT_RC4_64_WITH_MD5,
151 SSL2_CK_RC4_64_WITH_MD5, 182 SSL2_CK_RC4_64_WITH_MD5,
152 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_SSLV2|SSL_LOW, 183 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_SSLV2,
184 SSL_NOT_EXP|SSL_LOW,
153 SSL2_CF_8_BYTE_ENC, 185 SSL2_CF_8_BYTE_ENC,
186 64,
187 64,
154 SSL_ALL_CIPHERS, 188 SSL_ALL_CIPHERS,
189 SSL_ALL_STRENGTHS,
155 }, 190 },
156#endif 191#endif
157/* NULL SSLeay (testing) */ 192/* NULL SSLeay (testing) */
@@ -161,7 +196,11 @@ OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
161 SSL2_TXT_NULL, 196 SSL2_TXT_NULL,
162 SSL2_CK_NULL, 197 SSL2_CK_NULL,
163 0, 198 0,
199 0,
200 0,
201 0,
164 SSL_ALL_CIPHERS, 202 SSL_ALL_CIPHERS,
203 SSL_ALL_STRENGTHS,
165 }, 204 },
166#endif 205#endif
167 206
@@ -191,6 +230,9 @@ static SSL_METHOD SSLv2_data= {
191 ssl_bad_method, 230 ssl_bad_method,
192 ssl2_default_timeout, 231 ssl2_default_timeout,
193 &ssl3_undef_enc_method, 232 &ssl3_undef_enc_method,
233 ssl_undefined_function,
234 ssl2_callback_ctrl, /* local */
235 ssl2_ctx_callback_ctrl, /* local */
194 }; 236 };
195 237
196static long ssl2_default_timeout(void) 238static long ssl2_default_timeout(void)
@@ -223,14 +265,14 @@ int ssl2_pending(SSL *s)
223 265
224int ssl2_new(SSL *s) 266int ssl2_new(SSL *s)
225 { 267 {
226 SSL2_CTX *s2; 268 SSL2_STATE *s2;
227 269
228 if ((s2=(SSL2_CTX *)Malloc(sizeof(SSL2_CTX))) == NULL) goto err; 270 if ((s2=Malloc(sizeof *s2)) == NULL) goto err;
229 memset(s2,0,sizeof(SSL2_CTX)); 271 memset(s2,0,sizeof *s2);
230 272
231 if ((s2->rbuf=(unsigned char *)Malloc( 273 if ((s2->rbuf=Malloc(
232 SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER+2)) == NULL) goto err; 274 SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER+2)) == NULL) goto err;
233 if ((s2->wbuf=(unsigned char *)Malloc( 275 if ((s2->wbuf=Malloc(
234 SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER+2)) == NULL) goto err; 276 SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER+2)) == NULL) goto err;
235 s->s2=s2; 277 s->s2=s2;
236 278
@@ -248,7 +290,7 @@ err:
248 290
249void ssl2_free(SSL *s) 291void ssl2_free(SSL *s)
250 { 292 {
251 SSL2_CTX *s2; 293 SSL2_STATE *s2;
252 294
253 if(s == NULL) 295 if(s == NULL)
254 return; 296 return;
@@ -256,14 +298,14 @@ void ssl2_free(SSL *s)
256 s2=s->s2; 298 s2=s->s2;
257 if (s2->rbuf != NULL) Free(s2->rbuf); 299 if (s2->rbuf != NULL) Free(s2->rbuf);
258 if (s2->wbuf != NULL) Free(s2->wbuf); 300 if (s2->wbuf != NULL) Free(s2->wbuf);
259 memset(s2,0,sizeof(SSL2_CTX)); 301 memset(s2,0,sizeof *s2);
260 Free(s2); 302 Free(s2);
261 s->s2=NULL; 303 s->s2=NULL;
262 } 304 }
263 305
264void ssl2_clear(SSL *s) 306void ssl2_clear(SSL *s)
265 { 307 {
266 SSL2_CTX *s2; 308 SSL2_STATE *s2;
267 unsigned char *rbuf,*wbuf; 309 unsigned char *rbuf,*wbuf;
268 310
269 s2=s->s2; 311 s2=s->s2;
@@ -271,7 +313,7 @@ void ssl2_clear(SSL *s)
271 rbuf=s2->rbuf; 313 rbuf=s2->rbuf;
272 wbuf=s2->wbuf; 314 wbuf=s2->wbuf;
273 315
274 memset(s2,0,sizeof(SSL2_CTX)); 316 memset(s2,0,sizeof *s2);
275 317
276 s2->rbuf=rbuf; 318 s2->rbuf=rbuf;
277 s2->wbuf=wbuf; 319 s2->wbuf=wbuf;
@@ -296,11 +338,21 @@ long ssl2_ctrl(SSL *s, int cmd, long larg, char *parg)
296 return(ret); 338 return(ret);
297 } 339 }
298 340
341long ssl2_callback_ctrl(SSL *s, int cmd, void (*fp)())
342 {
343 return(0);
344 }
345
299long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg) 346long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
300 { 347 {
301 return(0); 348 return(0);
302 } 349 }
303 350
351long ssl2_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
352 {
353 return(0);
354 }
355
304/* This function needs to check if the ciphers required are actually 356/* This function needs to check if the ciphers required are actually
305 * available */ 357 * available */
306SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p) 358SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
@@ -372,7 +424,7 @@ void ssl2_generate_key_material(SSL *s)
372 MD5_Init(&ctx); 424 MD5_Init(&ctx);
373 425
374 MD5_Update(&ctx,s->session->master_key,s->session->master_key_length); 426 MD5_Update(&ctx,s->session->master_key,s->session->master_key_length);
375 MD5_Update(&ctx,(unsigned char *)&c,1); 427 MD5_Update(&ctx,&c,1);
376 c++; 428 c++;
377 MD5_Update(&ctx,s->s2->challenge,s->s2->challenge_length); 429 MD5_Update(&ctx,s->s2->challenge,s->s2->challenge_length);
378 MD5_Update(&ctx,s->s2->conn_id,s->s2->conn_id_length); 430 MD5_Update(&ctx,s->s2->conn_id,s->s2->conn_id_length);
@@ -421,4 +473,10 @@ int ssl2_shutdown(SSL *s)
421 s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); 473 s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
422 return(1); 474 return(1);
423 } 475 }
476#else /* !NO_SSL2 */
477
478# if PEDANTIC
479static void *dummy=&dummy;
480# endif
481
424#endif 482#endif
diff --git a/src/lib/libssl/src/ssl/s2_meth.c b/src/lib/libssl/src/ssl/s2_meth.c
index e2add164dd..deb9e1d6f3 100644
--- a/src/lib/libssl/src/ssl/s2_meth.c
+++ b/src/lib/libssl/src/ssl/s2_meth.c
@@ -56,10 +56,10 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#include "ssl_locl.h"
60#ifndef NO_SSL2
60#include <stdio.h> 61#include <stdio.h>
61#include <openssl/objects.h> 62#include <openssl/objects.h>
62#include "ssl_locl.h"
63 63
64static SSL_METHOD *ssl2_get_method(int ver); 64static SSL_METHOD *ssl2_get_method(int ver);
65static SSL_METHOD *ssl2_get_method(int ver) 65static SSL_METHOD *ssl2_get_method(int ver)
@@ -86,4 +86,10 @@ SSL_METHOD *SSLv2_method(void)
86 } 86 }
87 return(&SSLv2_data); 87 return(&SSLv2_data);
88 } 88 }
89#else /* !NO_SSL2 */
90
91# if PEDANTIC
92static void *dummy=&dummy;
93# endif
94
89#endif 95#endif
diff --git a/src/lib/libssl/src/ssl/s2_pkt.c b/src/lib/libssl/src/ssl/s2_pkt.c
index a1bb5bca4b..56662f29fa 100644
--- a/src/lib/libssl/src/ssl/s2_pkt.c
+++ b/src/lib/libssl/src/ssl/s2_pkt.c
@@ -56,10 +56,11 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "ssl_locl.h"
60#ifndef NO_SSL2
59#include <stdio.h> 61#include <stdio.h>
60#include <errno.h> 62#include <errno.h>
61#define USE_SOCKETS 63#define USE_SOCKETS
62#include "ssl_locl.h"
63 64
64static int read_n(SSL *s,unsigned int n,unsigned int max,unsigned int extend); 65static int read_n(SSL *s,unsigned int n,unsigned int max,unsigned int extend);
65static int do_ssl_write(SSL *s, const unsigned char *buf, unsigned int len); 66static int do_ssl_write(SSL *s, const unsigned char *buf, unsigned int len);
@@ -638,3 +639,10 @@ static int ssl_mt_error(int n)
638 } 639 }
639 return(ret); 640 return(ret);
640 } 641 }
642#else /* !NO_SSL2 */
643
644# if PEDANTIC
645static void *dummy=&dummy;
646# endif
647
648#endif
diff --git a/src/lib/libssl/src/ssl/s2_srvr.c b/src/lib/libssl/src/ssl/s2_srvr.c
index 9aeedef55f..332e284451 100644
--- a/src/lib/libssl/src/ssl/s2_srvr.c
+++ b/src/lib/libssl/src/ssl/s2_srvr.c
@@ -56,12 +56,12 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#include "ssl_locl.h"
60#ifndef NO_SSL2
60#include <stdio.h> 61#include <stdio.h>
61#include <openssl/bio.h> 62#include <openssl/bio.h>
62#include <openssl/rand.h> 63#include <openssl/rand.h>
63#include <openssl/objects.h> 64#include <openssl/objects.h>
64#include "ssl_locl.h"
65#include <openssl/evp.h> 65#include <openssl/evp.h>
66 66
67static SSL_METHOD *ssl2_get_server_method(int ver); 67static SSL_METHOD *ssl2_get_server_method(int ver);
@@ -109,7 +109,7 @@ int ssl2_accept(SSL *s)
109 void (*cb)()=NULL; 109 void (*cb)()=NULL;
110 int new_state,state; 110 int new_state,state;
111 111
112 RAND_seed(&l,sizeof(l)); 112 RAND_add(&l,sizeof(l),0);
113 ERR_clear_error(); 113 ERR_clear_error();
114 clear_sys_error(); 114 clear_sys_error();
115 115
@@ -415,7 +415,7 @@ static int get_client_master_key(SSL *s)
415 i=ek; 415 i=ek;
416 else 416 else
417 i=EVP_CIPHER_key_length(c); 417 i=EVP_CIPHER_key_length(c);
418 RAND_bytes(p,i); 418 RAND_pseudo_bytes(p,i);
419 } 419 }
420#else 420#else
421 if (i < 0) 421 if (i < 0)
@@ -680,7 +680,7 @@ static int server_hello(SSL *s)
680 /* make and send conn_id */ 680 /* make and send conn_id */
681 s2n(SSL2_CONNECTION_ID_LENGTH,p); /* add conn_id length */ 681 s2n(SSL2_CONNECTION_ID_LENGTH,p); /* add conn_id length */
682 s->s2->conn_id_length=SSL2_CONNECTION_ID_LENGTH; 682 s->s2->conn_id_length=SSL2_CONNECTION_ID_LENGTH;
683 RAND_bytes(s->s2->conn_id,(int)s->s2->conn_id_length); 683 RAND_pseudo_bytes(s->s2->conn_id,(int)s->s2->conn_id_length);
684 memcpy(d,s->s2->conn_id,SSL2_CONNECTION_ID_LENGTH); 684 memcpy(d,s->s2->conn_id,SSL2_CONNECTION_ID_LENGTH);
685 d+=SSL2_CONNECTION_ID_LENGTH; 685 d+=SSL2_CONNECTION_ID_LENGTH;
686 686
@@ -689,7 +689,7 @@ static int server_hello(SSL *s)
689 s->init_off=0; 689 s->init_off=0;
690 } 690 }
691 /* SSL2_ST_SEND_SERVER_HELLO_B */ 691 /* SSL2_ST_SEND_SERVER_HELLO_B */
692 /* If we are using TCP/IP, the performace is bad if we do 2 692 /* If we are using TCP/IP, the performance is bad if we do 2
693 * writes without a read between them. This occurs when 693 * writes without a read between them. This occurs when
694 * Session-id reuse is used, so I will put in a buffering module 694 * Session-id reuse is used, so I will put in a buffering module
695 */ 695 */
@@ -798,7 +798,7 @@ static int request_certificate(SSL *s)
798 p=(unsigned char *)s->init_buf->data; 798 p=(unsigned char *)s->init_buf->data;
799 *(p++)=SSL2_MT_REQUEST_CERTIFICATE; 799 *(p++)=SSL2_MT_REQUEST_CERTIFICATE;
800 *(p++)=SSL2_AT_MD5_WITH_RSA_ENCRYPTION; 800 *(p++)=SSL2_AT_MD5_WITH_RSA_ENCRYPTION;
801 RAND_bytes(ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH); 801 RAND_pseudo_bytes(ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH);
802 memcpy(p,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH); 802 memcpy(p,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH);
803 803
804 s->state=SSL2_ST_SEND_REQUEST_CERTIFICATE_B; 804 s->state=SSL2_ST_SEND_REQUEST_CERTIFICATE_B;
@@ -898,7 +898,7 @@ static int request_certificate(SSL *s)
898 EVP_VerifyUpdate(&ctx,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH); 898 EVP_VerifyUpdate(&ctx,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH);
899 899
900 i=i2d_X509(s->cert->pkeys[SSL_PKEY_RSA_ENC].x509,NULL); 900 i=i2d_X509(s->cert->pkeys[SSL_PKEY_RSA_ENC].x509,NULL);
901 buf2=(unsigned char *)Malloc((unsigned int)i); 901 buf2=Malloc((unsigned int)i);
902 if (buf2 == NULL) 902 if (buf2 == NULL)
903 { 903 {
904 SSLerr(SSL_F_REQUEST_CERTIFICATE,ERR_R_MALLOC_FAILURE); 904 SSLerr(SSL_F_REQUEST_CERTIFICATE,ERR_R_MALLOC_FAILURE);
@@ -921,6 +921,7 @@ static int request_certificate(SSL *s)
921 X509_free(s->session->peer); 921 X509_free(s->session->peer);
922 s->session->peer=x509; 922 s->session->peer=x509;
923 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509); 923 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509);
924 s->session->verify_result = s->verify_result;
924 ret=1; 925 ret=1;
925 goto end; 926 goto end;
926 } 927 }
@@ -965,4 +966,10 @@ static int ssl_rsa_private_decrypt(CERT *c, int len, unsigned char *from,
965 SSLerr(SSL_F_SSL_RSA_PRIVATE_DECRYPT,ERR_R_RSA_LIB); 966 SSLerr(SSL_F_SSL_RSA_PRIVATE_DECRYPT,ERR_R_RSA_LIB);
966 return(i); 967 return(i);
967 } 968 }
969#else /* !NO_SSL2 */
970
971# if PEDANTIC
972static void *dummy=&dummy;
973# endif
974
968#endif 975#endif
diff --git a/src/lib/libssl/src/ssl/s3_both.c b/src/lib/libssl/src/ssl/s3_both.c
index f3f27715d5..03e0c38770 100644
--- a/src/lib/libssl/src/ssl/s3_both.c
+++ b/src/lib/libssl/src/ssl/s3_both.c
@@ -55,7 +55,61 @@
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 */
58 111
112#include <string.h>
59#include <stdio.h> 113#include <stdio.h>
60#include <openssl/buffer.h> 114#include <openssl/buffer.h>
61#include <openssl/rand.h> 115#include <openssl/rand.h>
@@ -64,8 +118,27 @@
64#include <openssl/x509.h> 118#include <openssl/x509.h>
65#include "ssl_locl.h" 119#include "ssl_locl.h"
66 120
67int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender, 121/* send s->init_buf in records of type 'type' */
68 int slen) 122int ssl3_do_write(SSL *s, int type)
123 {
124 int ret;
125
126 ret=ssl3_write_bytes(s,type,&s->init_buf->data[s->init_off],
127 s->init_num);
128 if (ret < 0) return(-1);
129 if (type == SSL3_RT_HANDSHAKE)
130 /* should not be done for 'Hello Request's, but in that case
131 * we'll ignore the result anyway */
132 ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret);
133
134 if (ret == s->init_num)
135 return(1);
136 s->init_off+=ret;
137 s->init_num-=ret;
138 return(0);
139 }
140
141int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen)
69 { 142 {
70 unsigned char *p,*d; 143 unsigned char *p,*d;
71 int i; 144 int i;
@@ -79,7 +152,9 @@ int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender,
79 i=s->method->ssl3_enc->final_finish_mac(s, 152 i=s->method->ssl3_enc->final_finish_mac(s,
80 &(s->s3->finish_dgst1), 153 &(s->s3->finish_dgst1),
81 &(s->s3->finish_dgst2), 154 &(s->s3->finish_dgst2),
82 sender,slen,p); 155 sender,slen,s->s3->tmp.finish_md);
156 s->s3->tmp.finish_md_len = i;
157 memcpy(p, s->s3->tmp.finish_md, i);
83 p+=i; 158 p+=i;
84 l=i; 159 l=i;
85 160
@@ -109,7 +184,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
109 unsigned char *p; 184 unsigned char *p;
110 185
111 /* the mac has already been generated when we received the 186 /* the mac has already been generated when we received the
112 * change cipher spec message and is in s->s3->tmp.in_dgst[12] 187 * change cipher spec message and is in s->s3->tmp.peer_finish_md
113 */ 188 */
114 189
115 n=ssl3_get_message(s, 190 n=ssl3_get_message(s,
@@ -121,7 +196,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
121 196
122 if (!ok) return((int)n); 197 if (!ok) return((int)n);
123 198
124 /* If this occurs if we has missed a message */ 199 /* If this occurs, we have missed a message */
125 if (!s->s3->change_cipher_spec) 200 if (!s->s3->change_cipher_spec)
126 { 201 {
127 al=SSL_AD_UNEXPECTED_MESSAGE; 202 al=SSL_AD_UNEXPECTED_MESSAGE;
@@ -130,9 +205,8 @@ int ssl3_get_finished(SSL *s, int a, int b)
130 } 205 }
131 s->s3->change_cipher_spec=0; 206 s->s3->change_cipher_spec=0;
132 207
133 p=(unsigned char *)s->init_buf->data; 208 p = (unsigned char *)s->init_buf->data;
134 209 i = s->s3->tmp.peer_finish_md_len;
135 i=s->method->ssl3_enc->finish_mac_length;
136 210
137 if (i != n) 211 if (i != n)
138 { 212 {
@@ -141,7 +215,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
141 goto f_err; 215 goto f_err;
142 } 216 }
143 217
144 if (memcmp( p, (char *)&(s->s3->tmp.finish_md[0]),i) != 0) 218 if (memcmp(p, s->s3->tmp.peer_finish_md, i) != 0)
145 { 219 {
146 al=SSL_AD_DECRYPT_ERROR; 220 al=SSL_AD_DECRYPT_ERROR;
147 SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED); 221 SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED);
@@ -255,6 +329,11 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
255 return(l); 329 return(l);
256 } 330 }
257 331
332/* Obtain handshake message of message type 'mt' (any if mt == -1),
333 * maximum acceptable body length 'max'.
334 * The first four bytes (msg_type and length) are read in state 'st1',
335 * the body is read in state 'stn'.
336 */
258long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) 337long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
259 { 338 {
260 unsigned char *p; 339 unsigned char *p;
@@ -277,15 +356,38 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
277 356
278 p=(unsigned char *)s->init_buf->data; 357 p=(unsigned char *)s->init_buf->data;
279 358
280 if (s->state == st1) 359 if (s->state == st1) /* s->init_num < 4 */
281 { 360 {
282 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num], 361 int skip_message;
283 4-s->init_num); 362
284 if (i < (4-s->init_num)) 363 do
285 { 364 {
286 *ok=0; 365 while (s->init_num < 4)
287 return(ssl3_part_read(s,i)); 366 {
367 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],
368 4 - s->init_num);
369 if (i <= 0)
370 {
371 s->rwstate=SSL_READING;
372 *ok = 0;
373 return i;
374 }
375 s->init_num+=i;
376 }
377
378 skip_message = 0;
379 if (!s->server)
380 if (p[0] == SSL3_MT_HELLO_REQUEST)
381 /* The server may always send 'Hello Request' messages --
382 * we are doing a handshake anyway now, so ignore them
383 * if their format is correct. Does not count for
384 * 'Finished' MAC. */
385 if (p[1] == 0 && p[2] == 0 &&p[3] == 0)
386 skip_message = 1;
288 } 387 }
388 while (skip_message);
389
390 /* s->init_num == 4 */
289 391
290 if ((mt >= 0) && (*p != mt)) 392 if ((mt >= 0) && (*p != mt))
291 { 393 {
@@ -293,6 +395,20 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
293 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE); 395 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE);
294 goto f_err; 396 goto f_err;
295 } 397 }
398 if ((mt < 0) && (*p == SSL3_MT_CLIENT_HELLO) &&
399 (st1 == SSL3_ST_SR_CERT_A) &&
400 (stn == SSL3_ST_SR_CERT_B))
401 {
402 /* At this point we have got an MS SGC second client
403 * hello (maybe we should always allow the client to
404 * start a new handshake?). We need to restart the mac.
405 * Don't increment {num,total}_renegotiations because
406 * we have not completed the handshake. */
407 ssl3_init_finished_mac(s);
408 }
409
410 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, 4);
411
296 s->s3->tmp.message_type= *(p++); 412 s->s3->tmp.message_type= *(p++);
297 413
298 n2l3(p,l); 414 n2l3(p,l);
@@ -316,17 +432,21 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
316 /* next state (stn) */ 432 /* next state (stn) */
317 p=(unsigned char *)s->init_buf->data; 433 p=(unsigned char *)s->init_buf->data;
318 n=s->s3->tmp.message_size; 434 n=s->s3->tmp.message_size;
319 if (n > 0) 435 while (n > 0)
320 { 436 {
321 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n); 437 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n);
322 if (i != (int)n) 438 if (i <= 0)
323 { 439 {
324 *ok=0; 440 s->rwstate=SSL_READING;
325 return(ssl3_part_read(s,i)); 441 *ok = 0;
442 return i;
326 } 443 }
444 s->init_num += i;
445 n -= i;
327 } 446 }
447 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num);
328 *ok=1; 448 *ok=1;
329 return(n); 449 return s->init_num;
330f_err: 450f_err:
331 ssl3_send_alert(s,SSL3_AL_FATAL,al); 451 ssl3_send_alert(s,SSL3_AL_FATAL,al);
332err: 452err:
@@ -447,7 +567,7 @@ int ssl3_setup_buffers(SSL *s)
447 extra=SSL3_RT_MAX_EXTRA; 567 extra=SSL3_RT_MAX_EXTRA;
448 else 568 else
449 extra=0; 569 extra=0;
450 if ((p=(unsigned char *)Malloc(SSL3_RT_MAX_PACKET_SIZE+extra)) 570 if ((p=Malloc(SSL3_RT_MAX_PACKET_SIZE+extra))
451 == NULL) 571 == NULL)
452 goto err; 572 goto err;
453 s->s3->rbuf.buf=p; 573 s->s3->rbuf.buf=p;
@@ -455,7 +575,7 @@ int ssl3_setup_buffers(SSL *s)
455 575
456 if (s->s3->wbuf.buf == NULL) 576 if (s->s3->wbuf.buf == NULL)
457 { 577 {
458 if ((p=(unsigned char *)Malloc(SSL3_RT_MAX_PACKET_SIZE)) 578 if ((p=Malloc(SSL3_RT_MAX_PACKET_SIZE))
459 == NULL) 579 == NULL)
460 goto err; 580 goto err;
461 s->s3->wbuf.buf=p; 581 s->s3->wbuf.buf=p;
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c
index d3e6b4d1e5..279d2c0198 100644
--- a/src/lib/libssl/src/ssl/s3_clnt.c
+++ b/src/lib/libssl/src/ssl/s3_clnt.c
@@ -110,7 +110,7 @@ int ssl3_connect(SSL *s)
110 int ret= -1; 110 int ret= -1;
111 int new_state,state,skip=0;; 111 int new_state,state,skip=0;;
112 112
113 RAND_seed(&Time,sizeof(Time)); 113 RAND_add(&Time,sizeof(Time),0);
114 ERR_clear_error(); 114 ERR_clear_error();
115 clear_sys_error(); 115 clear_sys_error();
116 116
@@ -325,8 +325,8 @@ int ssl3_connect(SSL *s)
325 case SSL3_ST_CW_FINISHED_B: 325 case SSL3_ST_CW_FINISHED_B:
326 ret=ssl3_send_finished(s, 326 ret=ssl3_send_finished(s,
327 SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B, 327 SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,
328 s->method->ssl3_enc->client_finished, 328 s->method->ssl3_enc->client_finished_label,
329 s->method->ssl3_enc->client_finished_len); 329 s->method->ssl3_enc->client_finished_label_len);
330 if (ret <= 0) goto end; 330 if (ret <= 0) goto end;
331 s->state=SSL3_ST_CW_FLUSH; 331 s->state=SSL3_ST_CW_FLUSH;
332 332
@@ -466,7 +466,7 @@ static int ssl3_client_hello(SSL *s)
466 p=s->s3->client_random; 466 p=s->s3->client_random;
467 Time=time(NULL); /* Time */ 467 Time=time(NULL); /* Time */
468 l2n(Time,p); 468 l2n(Time,p);
469 RAND_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); 469 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
470 470
471 /* Do the message type and length last */ 471 /* Do the message type and length last */
472 d=p= &(buf[4]); 472 d=p= &(buf[4]);
@@ -1053,15 +1053,15 @@ static int ssl3_get_key_exchange(SSL *s)
1053 q+=i; 1053 q+=i;
1054 j+=i; 1054 j+=i;
1055 } 1055 }
1056 i=RSA_public_decrypt((int)n,p,p,pkey->pkey.rsa, 1056 i=RSA_verify(NID_md5_sha1, md_buf, j, p, n,
1057 RSA_PKCS1_PADDING); 1057 pkey->pkey.rsa);
1058 if (i <= 0) 1058 if (i < 0)
1059 { 1059 {
1060 al=SSL_AD_DECRYPT_ERROR; 1060 al=SSL_AD_DECRYPT_ERROR;
1061 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); 1061 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT);
1062 goto f_err; 1062 goto f_err;
1063 } 1063 }
1064 if ((j != i) || (memcmp(p,md_buf,i) != 0)) 1064 if (i == 0)
1065 { 1065 {
1066 /* bad signature */ 1066 /* bad signature */
1067 al=SSL_AD_DECRYPT_ERROR; 1067 al=SSL_AD_DECRYPT_ERROR;
@@ -1225,7 +1225,7 @@ fclose(out);
1225 1225
1226 if ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL) 1226 if ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL)
1227 { 1227 {
1228 /* If netscape tollerance is on, ignore errors */ 1228 /* If netscape tolerance is on, ignore errors */
1229 if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG) 1229 if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG)
1230 goto cont; 1230 goto cont;
1231 else 1231 else
@@ -1258,7 +1258,7 @@ cont:
1258 ERR_clear_error(); 1258 ERR_clear_error();
1259 } 1259 }
1260 1260
1261 /* we should setup a certficate to return.... */ 1261 /* we should setup a certificate to return.... */
1262 s->s3->tmp.cert_req=1; 1262 s->s3->tmp.cert_req=1;
1263 s->s3->tmp.ctype_num=ctype_num; 1263 s->s3->tmp.ctype_num=ctype_num;
1264 if (s->s3->tmp.ca_names != NULL) 1264 if (s->s3->tmp.ca_names != NULL)
@@ -1341,7 +1341,8 @@ static int ssl3_send_client_key_exchange(SSL *s)
1341 1341
1342 tmp_buf[0]=s->client_version>>8; 1342 tmp_buf[0]=s->client_version>>8;
1343 tmp_buf[1]=s->client_version&0xff; 1343 tmp_buf[1]=s->client_version&0xff;
1344 RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2); 1344 if (RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2) <= 0)
1345 goto err;
1345 1346
1346 s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; 1347 s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH;
1347 1348
@@ -1460,7 +1461,7 @@ static int ssl3_send_client_verify(SSL *s)
1460 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 1461 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
1461 EVP_PKEY *pkey; 1462 EVP_PKEY *pkey;
1462#ifndef NO_RSA 1463#ifndef NO_RSA
1463 int i=0; 1464 unsigned u=0;
1464#endif 1465#endif
1465 unsigned long n; 1466 unsigned long n;
1466#ifndef NO_DSA 1467#ifndef NO_DSA
@@ -1481,17 +1482,15 @@ static int ssl3_send_client_verify(SSL *s)
1481 { 1482 {
1482 s->method->ssl3_enc->cert_verify_mac(s, 1483 s->method->ssl3_enc->cert_verify_mac(s,
1483 &(s->s3->finish_dgst1),&(data[0])); 1484 &(s->s3->finish_dgst1),&(data[0]));
1484 i=RSA_private_encrypt( 1485 if (RSA_sign(NID_md5_sha1, data,
1485 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, 1486 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
1486 data,&(p[2]),pkey->pkey.rsa, 1487 &(p[2]), &u, pkey->pkey.rsa) <= 0 )
1487 RSA_PKCS1_PADDING);
1488 if (i <= 0)
1489 { 1488 {
1490 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB); 1489 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB);
1491 goto err; 1490 goto err;
1492 } 1491 }
1493 s2n(i,p); 1492 s2n(u,p);
1494 n=i+2; 1493 n=u+2;
1495 } 1494 }
1496 else 1495 else
1497#endif 1496#endif
@@ -1689,13 +1688,13 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1689#endif 1688#endif
1690#endif 1689#endif
1691 1690
1692 if (SSL_IS_EXPORT(algs) && !has_bits(i,EVP_PKT_EXP)) 1691 if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP))
1693 { 1692 {
1694#ifndef NO_RSA 1693#ifndef NO_RSA
1695 if (algs & SSL_kRSA) 1694 if (algs & SSL_kRSA)
1696 { 1695 {
1697 if (rsa == NULL 1696 if (rsa == NULL
1698 || RSA_size(rsa) > SSL_EXPORT_PKEYLENGTH(algs)) 1697 || RSA_size(rsa) > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher))
1699 { 1698 {
1700 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY); 1699 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY);
1701 goto f_err; 1700 goto f_err;
@@ -1707,7 +1706,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1707 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1706 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1708 { 1707 {
1709 if (dh == NULL 1708 if (dh == NULL
1710 || DH_size(dh) > SSL_EXPORT_PKEYLENGTH(algs)) 1709 || DH_size(dh) > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher))
1711 { 1710 {
1712 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY); 1711 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY);
1713 goto f_err; 1712 goto f_err;
diff --git a/src/lib/libssl/src/ssl/s3_enc.c b/src/lib/libssl/src/ssl/s3_enc.c
index 15d4af6dfb..df4acab3d0 100644
--- a/src/lib/libssl/src/ssl/s3_enc.c
+++ b/src/lib/libssl/src/ssl/s3_enc.c
@@ -78,12 +78,8 @@ static unsigned char ssl3_pad_2[48]={
78 0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c, 78 0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,
79 0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c }; 79 0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c,0x5c };
80 80
81#ifndef NO_PROTO
82static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx, 81static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
83 unsigned char *sender, int len, unsigned char *p); 82 const char *sender, int len, unsigned char *p);
84#else
85static int ssl3_handshake_mac();
86#endif
87 83
88static void ssl3_generate_key_block(SSL *s, unsigned char *km, int num) 84static void ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
89 { 85 {
@@ -304,7 +300,7 @@ int ssl3_setup_key_block(SSL *s)
304 300
305 ssl3_cleanup_key_block(s); 301 ssl3_cleanup_key_block(s);
306 302
307 if ((p=(unsigned char *)Malloc(num)) == NULL) 303 if ((p=Malloc(num)) == NULL)
308 goto err; 304 goto err;
309 305
310 s->s3->tmp.key_block_length=num; 306 s->s3->tmp.key_block_length=num;
@@ -416,7 +412,7 @@ int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *ctx, unsigned char *p)
416 } 412 }
417 413
418int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2, 414int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2,
419 unsigned char *sender, int len, unsigned char *p) 415 const char *sender, int len, unsigned char *p)
420 { 416 {
421 int ret; 417 int ret;
422 418
@@ -427,7 +423,7 @@ int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2,
427 } 423 }
428 424
429static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx, 425static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
430 unsigned char *sender, int len, unsigned char *p) 426 const char *sender, int len, unsigned char *p)
431 { 427 {
432 unsigned int ret; 428 unsigned int ret;
433 int npad,n; 429 int npad,n;
@@ -447,7 +443,7 @@ static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
447 EVP_DigestUpdate(&ctx,ssl3_pad_1,npad); 443 EVP_DigestUpdate(&ctx,ssl3_pad_1,npad);
448 EVP_DigestFinal(&ctx,md_buf,&i); 444 EVP_DigestFinal(&ctx,md_buf,&i);
449 445
450 EVP_DigestInit(&ctx,EVP_MD_CTX_type(&ctx)); 446 EVP_DigestInit(&ctx,EVP_MD_CTX_md(&ctx));
451 EVP_DigestUpdate(&ctx,s->session->master_key, 447 EVP_DigestUpdate(&ctx,s->session->master_key,
452 s->session->master_key_length); 448 s->session->master_key_length);
453 EVP_DigestUpdate(&ctx,ssl3_pad_2,npad); 449 EVP_DigestUpdate(&ctx,ssl3_pad_2,npad);
@@ -575,11 +571,11 @@ int ssl3_alert_code(int code)
575 case SSL_AD_ACCESS_DENIED: return(SSL3_AD_HANDSHAKE_FAILURE); 571 case SSL_AD_ACCESS_DENIED: return(SSL3_AD_HANDSHAKE_FAILURE);
576 case SSL_AD_DECODE_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE); 572 case SSL_AD_DECODE_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE);
577 case SSL_AD_DECRYPT_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE); 573 case SSL_AD_DECRYPT_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE);
578 case SSL_AD_EXPORT_RESTRICION: return(SSL3_AD_HANDSHAKE_FAILURE); 574 case SSL_AD_EXPORT_RESTRICTION: return(SSL3_AD_HANDSHAKE_FAILURE);
579 case SSL_AD_PROTOCOL_VERSION: return(SSL3_AD_HANDSHAKE_FAILURE); 575 case SSL_AD_PROTOCOL_VERSION: return(SSL3_AD_HANDSHAKE_FAILURE);
580 case SSL_AD_INSUFFICIENT_SECURITY:return(SSL3_AD_HANDSHAKE_FAILURE); 576 case SSL_AD_INSUFFICIENT_SECURITY:return(SSL3_AD_HANDSHAKE_FAILURE);
581 case SSL_AD_INTERNAL_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE); 577 case SSL_AD_INTERNAL_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE);
582 case SSL_AD_USER_CANCLED: return(SSL3_AD_HANDSHAKE_FAILURE); 578 case SSL_AD_USER_CANCELLED: return(SSL3_AD_HANDSHAKE_FAILURE);
583 case SSL_AD_NO_RENEGOTIATION: return(-1); /* Don't send it :-) */ 579 case SSL_AD_NO_RENEGOTIATION: return(-1); /* Don't send it :-) */
584 default: return(-1); 580 default: return(-1);
585 } 581 }
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c
index aeff6b5c5b..c4b49aaedf 100644
--- a/src/lib/libssl/src/ssl/s3_lib.c
+++ b/src/lib/libssl/src/ssl/s3_lib.c
@@ -75,18 +75,26 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
75 1, 75 1,
76 SSL3_TXT_RSA_NULL_MD5, 76 SSL3_TXT_RSA_NULL_MD5,
77 SSL3_CK_RSA_NULL_MD5, 77 SSL3_CK_RSA_NULL_MD5,
78 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3, 78 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_SSLV3,
79 SSL_NOT_EXP,
80 0,
81 0,
79 0, 82 0,
80 SSL_ALL_CIPHERS, 83 SSL_ALL_CIPHERS,
84 SSL_ALL_STRENGTHS,
81 }, 85 },
82/* Cipher 02 */ 86/* Cipher 02 */
83 { 87 {
84 1, 88 1,
85 SSL3_TXT_RSA_NULL_SHA, 89 SSL3_TXT_RSA_NULL_SHA,
86 SSL3_CK_RSA_NULL_SHA, 90 SSL3_CK_RSA_NULL_SHA,
87 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 91 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_SSLV3,
92 SSL_NOT_EXP,
93 0,
94 0,
88 0, 95 0,
89 SSL_ALL_CIPHERS, 96 SSL_ALL_CIPHERS,
97 SSL_ALL_STRENGTHS,
90 }, 98 },
91 99
92/* anon DH */ 100/* anon DH */
@@ -95,45 +103,65 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
95 1, 103 1,
96 SSL3_TXT_ADH_RC4_40_MD5, 104 SSL3_TXT_ADH_RC4_40_MD5,
97 SSL3_CK_ADH_RC4_40_MD5, 105 SSL3_CK_ADH_RC4_40_MD5,
98 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_EXP40|SSL_SSLV3, 106 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
107 SSL_EXPORT|SSL_EXP40,
99 0, 108 0,
109 40,
110 128,
100 SSL_ALL_CIPHERS, 111 SSL_ALL_CIPHERS,
112 SSL_ALL_STRENGTHS,
101 }, 113 },
102/* Cipher 18 */ 114/* Cipher 18 */
103 { 115 {
104 1, 116 1,
105 SSL3_TXT_ADH_RC4_128_MD5, 117 SSL3_TXT_ADH_RC4_128_MD5,
106 SSL3_CK_ADH_RC4_128_MD5, 118 SSL3_CK_ADH_RC4_128_MD5,
107 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3, 119 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
120 SSL_NOT_EXP,
108 0, 121 0,
122 128,
123 128,
109 SSL_ALL_CIPHERS, 124 SSL_ALL_CIPHERS,
125 SSL_ALL_STRENGTHS,
110 }, 126 },
111/* Cipher 19 */ 127/* Cipher 19 */
112 { 128 {
113 1, 129 1,
114 SSL3_TXT_ADH_DES_40_CBC_SHA, 130 SSL3_TXT_ADH_DES_40_CBC_SHA,
115 SSL3_CK_ADH_DES_40_CBC_SHA, 131 SSL3_CK_ADH_DES_40_CBC_SHA,
116 SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 132 SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_SSLV3,
133 SSL_EXPORT|SSL_EXP40,
117 0, 134 0,
135 40,
136 128,
118 SSL_ALL_CIPHERS, 137 SSL_ALL_CIPHERS,
138 SSL_ALL_STRENGTHS,
119 }, 139 },
120/* Cipher 1A */ 140/* Cipher 1A */
121 { 141 {
122 1, 142 1,
123 SSL3_TXT_ADH_DES_64_CBC_SHA, 143 SSL3_TXT_ADH_DES_64_CBC_SHA,
124 SSL3_CK_ADH_DES_64_CBC_SHA, 144 SSL3_CK_ADH_DES_64_CBC_SHA,
125 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 145 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3,
146 SSL_NOT_EXP,
126 0, 147 0,
148 56,
149 56,
127 SSL_ALL_CIPHERS, 150 SSL_ALL_CIPHERS,
151 SSL_ALL_STRENGTHS,
128 }, 152 },
129/* Cipher 1B */ 153/* Cipher 1B */
130 { 154 {
131 1, 155 1,
132 SSL3_TXT_ADH_DES_192_CBC_SHA, 156 SSL3_TXT_ADH_DES_192_CBC_SHA,
133 SSL3_CK_ADH_DES_192_CBC_SHA, 157 SSL3_CK_ADH_DES_192_CBC_SHA,
134 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 158 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3,
159 SSL_NOT_EXP,
135 0, 160 0,
161 168,
162 168,
136 SSL_ALL_CIPHERS, 163 SSL_ALL_CIPHERS,
164 SSL_ALL_STRENGTHS,
137 }, 165 },
138 166
139/* RSA again */ 167/* RSA again */
@@ -142,72 +170,104 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
142 1, 170 1,
143 SSL3_TXT_RSA_RC4_40_MD5, 171 SSL3_TXT_RSA_RC4_40_MD5,
144 SSL3_CK_RSA_RC4_40_MD5, 172 SSL3_CK_RSA_RC4_40_MD5,
145 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_EXP40|SSL_SSLV3, 173 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
174 SSL_EXPORT|SSL_EXP40,
146 0, 175 0,
176 40,
177 128,
147 SSL_ALL_CIPHERS, 178 SSL_ALL_CIPHERS,
179 SSL_ALL_STRENGTHS,
148 }, 180 },
149/* Cipher 04 */ 181/* Cipher 04 */
150 { 182 {
151 1, 183 1,
152 SSL3_TXT_RSA_RC4_128_MD5, 184 SSL3_TXT_RSA_RC4_128_MD5,
153 SSL3_CK_RSA_RC4_128_MD5, 185 SSL3_CK_RSA_RC4_128_MD5,
154 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, 186 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_SSLV3,
187 SSL_NOT_EXP|SSL_MEDIUM,
155 0, 188 0,
189 128,
190 128,
156 SSL_ALL_CIPHERS, 191 SSL_ALL_CIPHERS,
192 SSL_ALL_STRENGTHS,
157 }, 193 },
158/* Cipher 05 */ 194/* Cipher 05 */
159 { 195 {
160 1, 196 1,
161 SSL3_TXT_RSA_RC4_128_SHA, 197 SSL3_TXT_RSA_RC4_128_SHA,
162 SSL3_CK_RSA_RC4_128_SHA, 198 SSL3_CK_RSA_RC4_128_SHA,
163 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, 199 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_SSLV3,
200 SSL_NOT_EXP|SSL_MEDIUM,
164 0, 201 0,
202 128,
203 128,
165 SSL_ALL_CIPHERS, 204 SSL_ALL_CIPHERS,
205 SSL_ALL_STRENGTHS,
166 }, 206 },
167/* Cipher 06 */ 207/* Cipher 06 */
168 { 208 {
169 1, 209 1,
170 SSL3_TXT_RSA_RC2_40_MD5, 210 SSL3_TXT_RSA_RC2_40_MD5,
171 SSL3_CK_RSA_RC2_40_MD5, 211 SSL3_CK_RSA_RC2_40_MD5,
172 SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_EXP40|SSL_SSLV3, 212 SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_SSLV3,
213 SSL_EXPORT|SSL_EXP40,
173 0, 214 0,
215 40,
216 128,
174 SSL_ALL_CIPHERS, 217 SSL_ALL_CIPHERS,
218 SSL_ALL_STRENGTHS,
175 }, 219 },
176/* Cipher 07 */ 220/* Cipher 07 */
177 { 221 {
178 1, 222 1,
179 SSL3_TXT_RSA_IDEA_128_SHA, 223 SSL3_TXT_RSA_IDEA_128_SHA,
180 SSL3_CK_RSA_IDEA_128_SHA, 224 SSL3_CK_RSA_IDEA_128_SHA,
181 SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, 225 SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_SSLV3,
226 SSL_NOT_EXP|SSL_MEDIUM,
182 0, 227 0,
228 128,
229 128,
183 SSL_ALL_CIPHERS, 230 SSL_ALL_CIPHERS,
231 SSL_ALL_STRENGTHS,
184 }, 232 },
185/* Cipher 08 */ 233/* Cipher 08 */
186 { 234 {
187 1, 235 1,
188 SSL3_TXT_RSA_DES_40_CBC_SHA, 236 SSL3_TXT_RSA_DES_40_CBC_SHA,
189 SSL3_CK_RSA_DES_40_CBC_SHA, 237 SSL3_CK_RSA_DES_40_CBC_SHA,
190 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 238 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
239 SSL_EXPORT|SSL_EXP40,
191 0, 240 0,
241 40,
242 56,
192 SSL_ALL_CIPHERS, 243 SSL_ALL_CIPHERS,
244 SSL_ALL_STRENGTHS,
193 }, 245 },
194/* Cipher 09 */ 246/* Cipher 09 */
195 { 247 {
196 1, 248 1,
197 SSL3_TXT_RSA_DES_64_CBC_SHA, 249 SSL3_TXT_RSA_DES_64_CBC_SHA,
198 SSL3_CK_RSA_DES_64_CBC_SHA, 250 SSL3_CK_RSA_DES_64_CBC_SHA,
199 SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 251 SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
252 SSL_NOT_EXP|SSL_LOW,
200 0, 253 0,
254 56,
255 56,
201 SSL_ALL_CIPHERS, 256 SSL_ALL_CIPHERS,
257 SSL_ALL_STRENGTHS,
202 }, 258 },
203/* Cipher 0A */ 259/* Cipher 0A */
204 { 260 {
205 1, 261 1,
206 SSL3_TXT_RSA_DES_192_CBC3_SHA, 262 SSL3_TXT_RSA_DES_192_CBC3_SHA,
207 SSL3_CK_RSA_DES_192_CBC3_SHA, 263 SSL3_CK_RSA_DES_192_CBC3_SHA,
208 SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 264 SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
265 SSL_NOT_EXP|SSL_HIGH,
209 0, 266 0,
267 168,
268 168,
210 SSL_ALL_CIPHERS, 269 SSL_ALL_CIPHERS,
270 SSL_ALL_STRENGTHS,
211 }, 271 },
212 272
213/* The DH ciphers */ 273/* The DH ciphers */
@@ -216,54 +276,78 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
216 0, 276 0,
217 SSL3_TXT_DH_DSS_DES_40_CBC_SHA, 277 SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
218 SSL3_CK_DH_DSS_DES_40_CBC_SHA, 278 SSL3_CK_DH_DSS_DES_40_CBC_SHA,
219 SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 279 SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
280 SSL_EXPORT|SSL_EXP40,
220 0, 281 0,
282 40,
283 56,
221 SSL_ALL_CIPHERS, 284 SSL_ALL_CIPHERS,
285 SSL_ALL_STRENGTHS,
222 }, 286 },
223/* Cipher 0C */ 287/* Cipher 0C */
224 { 288 {
225 0, 289 0,
226 SSL3_TXT_DH_DSS_DES_64_CBC_SHA, 290 SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
227 SSL3_CK_DH_DSS_DES_64_CBC_SHA, 291 SSL3_CK_DH_DSS_DES_64_CBC_SHA,
228 SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 292 SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
293 SSL_NOT_EXP|SSL_LOW,
229 0, 294 0,
295 56,
296 56,
230 SSL_ALL_CIPHERS, 297 SSL_ALL_CIPHERS,
298 SSL_ALL_STRENGTHS,
231 }, 299 },
232/* Cipher 0D */ 300/* Cipher 0D */
233 { 301 {
234 0, 302 0,
235 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA, 303 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
236 SSL3_CK_DH_DSS_DES_192_CBC3_SHA, 304 SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
237 SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 305 SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
306 SSL_NOT_EXP|SSL_HIGH,
238 0, 307 0,
308 168,
309 168,
239 SSL_ALL_CIPHERS, 310 SSL_ALL_CIPHERS,
311 SSL_ALL_STRENGTHS,
240 }, 312 },
241/* Cipher 0E */ 313/* Cipher 0E */
242 { 314 {
243 0, 315 0,
244 SSL3_TXT_DH_RSA_DES_40_CBC_SHA, 316 SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
245 SSL3_CK_DH_RSA_DES_40_CBC_SHA, 317 SSL3_CK_DH_RSA_DES_40_CBC_SHA,
246 SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 318 SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
319 SSL_EXPORT|SSL_EXP40,
247 0, 320 0,
321 40,
322 56,
248 SSL_ALL_CIPHERS, 323 SSL_ALL_CIPHERS,
324 SSL_ALL_STRENGTHS,
249 }, 325 },
250/* Cipher 0F */ 326/* Cipher 0F */
251 { 327 {
252 0, 328 0,
253 SSL3_TXT_DH_RSA_DES_64_CBC_SHA, 329 SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
254 SSL3_CK_DH_RSA_DES_64_CBC_SHA, 330 SSL3_CK_DH_RSA_DES_64_CBC_SHA,
255 SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 331 SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
332 SSL_NOT_EXP|SSL_LOW,
256 0, 333 0,
334 56,
335 56,
257 SSL_ALL_CIPHERS, 336 SSL_ALL_CIPHERS,
337 SSL_ALL_STRENGTHS,
258 }, 338 },
259/* Cipher 10 */ 339/* Cipher 10 */
260 { 340 {
261 0, 341 0,
262 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA, 342 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
263 SSL3_CK_DH_RSA_DES_192_CBC3_SHA, 343 SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
264 SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 344 SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
345 SSL_NOT_EXP|SSL_HIGH,
265 0, 346 0,
347 168,
348 168,
266 SSL_ALL_CIPHERS, 349 SSL_ALL_CIPHERS,
350 SSL_ALL_STRENGTHS,
267 }, 351 },
268 352
269/* The Ephemeral DH ciphers */ 353/* The Ephemeral DH ciphers */
@@ -272,54 +356,78 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
272 1, 356 1,
273 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA, 357 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA,
274 SSL3_CK_EDH_DSS_DES_40_CBC_SHA, 358 SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
275 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 359 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_SSLV3,
360 SSL_EXPORT|SSL_EXP40,
276 0, 361 0,
362 40,
363 56,
277 SSL_ALL_CIPHERS, 364 SSL_ALL_CIPHERS,
365 SSL_ALL_STRENGTHS,
278 }, 366 },
279/* Cipher 12 */ 367/* Cipher 12 */
280 { 368 {
281 1, 369 1,
282 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA, 370 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
283 SSL3_CK_EDH_DSS_DES_64_CBC_SHA, 371 SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
284 SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 372 SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_SSLV3,
373 SSL_NOT_EXP|SSL_LOW,
285 0, 374 0,
375 56,
376 56,
286 SSL_ALL_CIPHERS, 377 SSL_ALL_CIPHERS,
378 SSL_ALL_STRENGTHS,
287 }, 379 },
288/* Cipher 13 */ 380/* Cipher 13 */
289 { 381 {
290 1, 382 1,
291 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA, 383 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
292 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA, 384 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
293 SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 385 SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_SSLV3,
386 SSL_NOT_EXP|SSL_HIGH,
294 0, 387 0,
388 168,
389 168,
295 SSL_ALL_CIPHERS, 390 SSL_ALL_CIPHERS,
391 SSL_ALL_STRENGTHS,
296 }, 392 },
297/* Cipher 14 */ 393/* Cipher 14 */
298 { 394 {
299 1, 395 1,
300 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA, 396 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
301 SSL3_CK_EDH_RSA_DES_40_CBC_SHA, 397 SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
302 SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_EXP40|SSL_SSLV3, 398 SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
399 SSL_EXPORT|SSL_EXP40,
303 0, 400 0,
401 40,
402 56,
304 SSL_ALL_CIPHERS, 403 SSL_ALL_CIPHERS,
404 SSL_ALL_STRENGTHS,
305 }, 405 },
306/* Cipher 15 */ 406/* Cipher 15 */
307 { 407 {
308 1, 408 1,
309 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA, 409 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
310 SSL3_CK_EDH_RSA_DES_64_CBC_SHA, 410 SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
311 SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, 411 SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
412 SSL_NOT_EXP|SSL_LOW,
312 0, 413 0,
414 56,
415 56,
313 SSL_ALL_CIPHERS, 416 SSL_ALL_CIPHERS,
417 SSL_ALL_STRENGTHS,
314 }, 418 },
315/* Cipher 16 */ 419/* Cipher 16 */
316 { 420 {
317 1, 421 1,
318 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA, 422 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
319 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA, 423 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA,
320 SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, 424 SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
425 SSL_NOT_EXP|SSL_HIGH,
321 0, 426 0,
427 168,
428 168,
322 SSL_ALL_CIPHERS, 429 SSL_ALL_CIPHERS,
430 SSL_ALL_STRENGTHS,
323 }, 431 },
324 432
325/* Fortezza */ 433/* Fortezza */
@@ -328,9 +436,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
328 0, 436 0,
329 SSL3_TXT_FZA_DMS_NULL_SHA, 437 SSL3_TXT_FZA_DMS_NULL_SHA,
330 SSL3_CK_FZA_DMS_NULL_SHA, 438 SSL3_CK_FZA_DMS_NULL_SHA,
331 SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 439 SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_SSLV3,
440 SSL_NOT_EXP,
441 0,
442 0,
332 0, 443 0,
333 SSL_ALL_CIPHERS, 444 SSL_ALL_CIPHERS,
445 SSL_ALL_STRENGTHS,
334 }, 446 },
335 447
336/* Cipher 1D */ 448/* Cipher 1D */
@@ -338,9 +450,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
338 0, 450 0,
339 SSL3_TXT_FZA_DMS_FZA_SHA, 451 SSL3_TXT_FZA_DMS_FZA_SHA,
340 SSL3_CK_FZA_DMS_FZA_SHA, 452 SSL3_CK_FZA_DMS_FZA_SHA,
341 SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 453 SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_SSLV3,
454 SSL_NOT_EXP,
455 0,
456 0,
342 0, 457 0,
343 SSL_ALL_CIPHERS, 458 SSL_ALL_CIPHERS,
459 SSL_ALL_STRENGTHS,
344 }, 460 },
345 461
346/* Cipher 1E */ 462/* Cipher 1E */
@@ -348,9 +464,13 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
348 0, 464 0,
349 SSL3_TXT_FZA_DMS_RC4_SHA, 465 SSL3_TXT_FZA_DMS_RC4_SHA,
350 SSL3_CK_FZA_DMS_RC4_SHA, 466 SSL3_CK_FZA_DMS_RC4_SHA,
351 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, 467 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3,
468 SSL_NOT_EXP,
352 0, 469 0,
470 128,
471 128,
353 SSL_ALL_CIPHERS, 472 SSL_ALL_CIPHERS,
473 SSL_ALL_STRENGTHS,
354 }, 474 },
355 475
356#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 476#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
@@ -360,54 +480,78 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
360 1, 480 1,
361 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5, 481 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
362 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5, 482 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
363 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_EXP56|SSL_TLSV1, 483 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_TLSV1,
484 SSL_EXPORT|SSL_EXP56,
364 0, 485 0,
365 SSL_ALL_CIPHERS 486 56,
487 128,
488 SSL_ALL_CIPHERS,
489 SSL_ALL_STRENGTHS,
366 }, 490 },
367 /* Cipher 61 */ 491 /* Cipher 61 */
368 { 492 {
369 1, 493 1,
370 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5, 494 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
371 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5, 495 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
372 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_EXP56|SSL_TLSV1, 496 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_TLSV1,
497 SSL_EXPORT|SSL_EXP56,
373 0, 498 0,
374 SSL_ALL_CIPHERS 499 56,
500 128,
501 SSL_ALL_CIPHERS,
502 SSL_ALL_STRENGTHS,
375 }, 503 },
376 /* Cipher 62 */ 504 /* Cipher 62 */
377 { 505 {
378 1, 506 1,
379 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA, 507 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
380 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA, 508 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
381 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_EXP56|SSL_TLSV1, 509 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_TLSV1,
510 SSL_EXPORT|SSL_EXP56,
382 0, 511 0,
383 SSL_ALL_CIPHERS 512 56,
513 56,
514 SSL_ALL_CIPHERS,
515 SSL_ALL_STRENGTHS,
384 }, 516 },
385 /* Cipher 63 */ 517 /* Cipher 63 */
386 { 518 {
387 1, 519 1,
388 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, 520 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
389 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, 521 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
390 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_EXP56|SSL_TLSV1, 522 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_TLSV1,
523 SSL_EXPORT|SSL_EXP56,
391 0, 524 0,
392 SSL_ALL_CIPHERS 525 56,
526 56,
527 SSL_ALL_CIPHERS,
528 SSL_ALL_STRENGTHS,
393 }, 529 },
394 /* Cipher 64 */ 530 /* Cipher 64 */
395 { 531 {
396 1, 532 1,
397 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA, 533 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
398 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA, 534 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
399 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_EXP56|SSL_TLSV1, 535 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
536 SSL_EXPORT|SSL_EXP56,
400 0, 537 0,
401 SSL_ALL_CIPHERS 538 56,
539 128,
540 SSL_ALL_CIPHERS,
541 SSL_ALL_STRENGTHS,
402 }, 542 },
403 /* Cipher 65 */ 543 /* Cipher 65 */
404 { 544 {
405 1, 545 1,
406 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, 546 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
407 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, 547 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
408 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_EXP56|SSL_TLSV1, 548 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
549 SSL_EXPORT|SSL_EXP56,
409 0, 550 0,
410 SSL_ALL_CIPHERS 551 56,
552 128,
553 SSL_ALL_CIPHERS,
554 SSL_ALL_STRENGTHS,
411 }, 555 },
412 /* Cipher 66 */ 556 /* Cipher 66 */
413 { 557 {
@@ -415,8 +559,12 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
415 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA, 559 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
416 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA, 560 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
417 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1, 561 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
562 SSL_NOT_EXP,
418 0, 563 0,
419 SSL_ALL_CIPHERS 564 128,
565 128,
566 SSL_ALL_CIPHERS,
567 SSL_ALL_STRENGTHS
420 }, 568 },
421#endif 569#endif
422 570
@@ -460,6 +608,9 @@ static SSL_METHOD SSLv3_data= {
460 ssl_bad_method, 608 ssl_bad_method,
461 ssl3_default_timeout, 609 ssl3_default_timeout,
462 &SSLv3_enc_data, 610 &SSLv3_enc_data,
611 ssl_undefined_function,
612 ssl3_callback_ctrl,
613 ssl3_ctx_callback_ctrl,
463 }; 614 };
464 615
465static long ssl3_default_timeout(void) 616static long ssl3_default_timeout(void)
@@ -495,19 +646,12 @@ int ssl3_pending(SSL *s)
495 646
496int ssl3_new(SSL *s) 647int ssl3_new(SSL *s)
497 { 648 {
498 SSL3_CTX *s3; 649 SSL3_STATE *s3;
499 650
500 if ((s3=(SSL3_CTX *)Malloc(sizeof(SSL3_CTX))) == NULL) goto err; 651 if ((s3=Malloc(sizeof *s3)) == NULL) goto err;
501 memset(s3,0,sizeof(SSL3_CTX)); 652 memset(s3,0,sizeof *s3);
502 653
503 s->s3=s3; 654 s->s3=s3;
504 /*
505 s->s3->tmp.ca_names=NULL;
506 s->s3->tmp.key_block=NULL;
507 s->s3->tmp.key_block_length=0;
508 s->s3->rbuf.buf=NULL;
509 s->s3->wbuf.buf=NULL;
510 */
511 655
512 s->method->ssl_clear(s); 656 s->method->ssl_clear(s);
513 return(1); 657 return(1);
@@ -533,7 +677,7 @@ void ssl3_free(SSL *s)
533#endif 677#endif
534 if (s->s3->tmp.ca_names != NULL) 678 if (s->s3->tmp.ca_names != NULL)
535 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); 679 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
536 memset(s->s3,0,sizeof(SSL3_CTX)); 680 memset(s->s3,0,sizeof *s->s3);
537 Free(s->s3); 681 Free(s->s3);
538 s->s3=NULL; 682 s->s3=NULL;
539 } 683 }
@@ -551,11 +695,15 @@ void ssl3_clear(SSL *s)
551 Free(s->s3->rrec.comp); 695 Free(s->s3->rrec.comp);
552 s->s3->rrec.comp=NULL; 696 s->s3->rrec.comp=NULL;
553 } 697 }
698#ifndef NO_DH
699 if (s->s3->tmp.dh != NULL)
700 DH_free(s->s3->tmp.dh);
701#endif
554 702
555 rp=s->s3->rbuf.buf; 703 rp=s->s3->rbuf.buf;
556 wp=s->s3->wbuf.buf; 704 wp=s->s3->wbuf.buf;
557 705
558 memset(s->s3,0,sizeof(SSL3_CTX)); 706 memset(s->s3,0,sizeof *s->s3);
559 if (rp != NULL) s->s3->rbuf.buf=rp; 707 if (rp != NULL) s->s3->rbuf.buf=rp;
560 if (wp != NULL) s->s3->wbuf.buf=wp; 708 if (wp != NULL) s->s3->wbuf.buf=wp;
561 709
@@ -638,7 +786,10 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
638 } 786 }
639 break; 787 break;
640 case SSL_CTRL_SET_TMP_RSA_CB: 788 case SSL_CTRL_SET_TMP_RSA_CB:
641 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))parg; 789 {
790 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
791 return(ret);
792 }
642 break; 793 break;
643#endif 794#endif
644#ifndef NO_DH 795#ifndef NO_DH
@@ -665,7 +816,54 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
665 } 816 }
666 break; 817 break;
667 case SSL_CTRL_SET_TMP_DH_CB: 818 case SSL_CTRL_SET_TMP_DH_CB:
668 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))parg; 819 {
820 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
821 return(ret);
822 }
823 break;
824#endif
825 default:
826 break;
827 }
828 return(ret);
829 }
830
831long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
832 {
833 int ret=0;
834
835#if !defined(NO_DSA) || !defined(NO_RSA)
836 if (
837#ifndef NO_RSA
838 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
839#endif
840#ifndef NO_DSA
841 cmd == SSL_CTRL_SET_TMP_DH_CB ||
842#endif
843 0)
844 {
845 if (!ssl_cert_inst(&s->cert))
846 {
847 SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
848 return(0);
849 }
850 }
851#endif
852
853 switch (cmd)
854 {
855#ifndef NO_RSA
856 case SSL_CTRL_SET_TMP_RSA_CB:
857 {
858 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
859 }
860 break;
861#endif
862#ifndef NO_DH
863 case SSL_CTRL_SET_TMP_DH_CB:
864 {
865 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
866 }
669 break; 867 break;
670#endif 868#endif
671 default: 869 default:
@@ -721,7 +919,10 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
721 } 919 }
722 /* break; */ 920 /* break; */
723 case SSL_CTRL_SET_TMP_RSA_CB: 921 case SSL_CTRL_SET_TMP_RSA_CB:
724 cert->rsa_tmp_cb=(RSA *(*)(SSL *, int, int))parg; 922 {
923 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
924 return(0);
925 }
725 break; 926 break;
726#endif 927#endif
727#ifndef NO_DH 928#ifndef NO_DH
@@ -748,7 +949,10 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
748 } 949 }
749 /*break; */ 950 /*break; */
750 case SSL_CTRL_SET_TMP_DH_CB: 951 case SSL_CTRL_SET_TMP_DH_CB:
751 cert->dh_tmp_cb=(DH *(*)(SSL *, int, int))parg; 952 {
953 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
954 return(0);
955 }
752 break; 956 break;
753#endif 957#endif
754 /* A Thawte special :-) */ 958 /* A Thawte special :-) */
@@ -767,6 +971,34 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
767 return(1); 971 return(1);
768 } 972 }
769 973
974long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
975 {
976 CERT *cert;
977
978 cert=ctx->cert;
979
980 switch (cmd)
981 {
982#ifndef NO_RSA
983 case SSL_CTRL_SET_TMP_RSA_CB:
984 {
985 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
986 }
987 break;
988#endif
989#ifndef NO_DH
990 case SSL_CTRL_SET_TMP_DH_CB:
991 {
992 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
993 }
994 break;
995#endif
996 default:
997 return(0);
998 }
999 return(1);
1000 }
1001
770/* This function needs to check if the ciphers required are actually 1002/* This function needs to check if the ciphers required are actually
771 * available */ 1003 * available */
772SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) 1004SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
@@ -819,21 +1051,6 @@ int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
819 return(2); 1051 return(2);
820 } 1052 }
821 1053
822int ssl3_part_read(SSL *s, int i)
823 {
824 s->rwstate=SSL_READING;
825
826 if (i < 0)
827 {
828 return(i);
829 }
830 else
831 {
832 s->init_num+=i;
833 return(0);
834 }
835 }
836
837SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have, 1054SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
838 STACK_OF(SSL_CIPHER) *pref) 1055 STACK_OF(SSL_CIPHER) *pref)
839 { 1056 {
@@ -865,7 +1082,7 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
865 emask=cert->export_mask; 1082 emask=cert->export_mask;
866 1083
867 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK); 1084 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK);
868 if (SSL_IS_EXPORT(c->algorithms)) 1085 if (SSL_C_IS_EXPORT(c))
869 { 1086 {
870 ok=((alg & emask) == alg)?1:0; 1087 ok=((alg & emask) == alg)?1:0;
871#ifdef CIPHER_DEBUG 1088#ifdef CIPHER_DEBUG
@@ -1034,8 +1251,12 @@ int ssl3_read(SSL *s, void *buf, int len)
1034 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len); 1251 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len);
1035 if ((ret == -1) && (s->s3->in_read_app_data == 0)) 1252 if ((ret == -1) && (s->s3->in_read_app_data == 0))
1036 { 1253 {
1037 ERR_get_error(); /* clear the error */ 1254 /* ssl3_read_bytes decided to call s->handshake_func, which
1038 s->s3->in_read_app_data=0; 1255 * called ssl3_read_bytes to read handshake data.
1256 * However, ssl3_read_bytes actually found application data
1257 * and thinks that application data makes sense here (signalled
1258 * by resetting 'in_read_app_data', strangely); so disable
1259 * handshake processing and try to read application data again. */
1039 s->in_handshake++; 1260 s->in_handshake++;
1040 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len); 1261 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len);
1041 s->in_handshake--; 1262 s->in_handshake--;
@@ -1092,7 +1313,7 @@ int ssl3_renegotiate_check(SSL *s)
1092 { 1313 {
1093/* 1314/*
1094if we are the server, and we have sent a 'RENEGOTIATE' message, we 1315if we are the server, and we have sent a 'RENEGOTIATE' message, we
1095need to go to SSL_ST_ACCEPT. 1316need to go to SSL_ST_ACCEPT.
1096*/ 1317*/
1097 /* SSL_ST_ACCEPT */ 1318 /* SSL_ST_ACCEPT */
1098 s->state=SSL_ST_RENEGOTIATE; 1319 s->state=SSL_ST_RENEGOTIATE;
diff --git a/src/lib/libssl/src/ssl/s3_pkt.c b/src/lib/libssl/src/ssl/s3_pkt.c
index 7893d03123..eb965310d9 100644
--- a/src/lib/libssl/src/ssl/s3_pkt.c
+++ b/src/lib/libssl/src/ssl/s3_pkt.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-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 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <errno.h> 113#include <errno.h>
@@ -71,104 +124,98 @@ static int ssl3_get_record(SSL *s);
71static int do_compress(SSL *ssl); 124static int do_compress(SSL *ssl);
72static int do_uncompress(SSL *ssl); 125static int do_uncompress(SSL *ssl);
73static int do_change_cipher_spec(SSL *ssl); 126static int do_change_cipher_spec(SSL *ssl);
127
128/* used only by ssl3_get_record */
74static int ssl3_read_n(SSL *s, int n, int max, int extend) 129static int ssl3_read_n(SSL *s, int n, int max, int extend)
75 { 130 {
131 /* If extend == 0, obtain new n-byte packet; if extend == 1, increase
132 * packet by another n bytes.
133 * The packet will be in the sub-array of s->s3->rbuf.buf specified
134 * by s->packet and s->packet_length.
135 * (If s->read_ahead is set, 'max' bytes may be stored in rbuf
136 * [plus s->packet_length bytes if extend == 1].)
137 */
76 int i,off,newb; 138 int i,off,newb;
77 139
78 /* if there is stuff still in the buffer from a previous read, 140 if (!extend)
79 * and there is more than we want, take some. */ 141 {
142 /* start with empty packet ... */
143 if (s->s3->rbuf.left == 0)
144 s->s3->rbuf.offset = 0;
145 s->packet = s->s3->rbuf.buf + s->s3->rbuf.offset;
146 s->packet_length = 0;
147 /* ... now we can act as if 'extend' was set */
148 }
149
150 /* if there is enough in the buffer from a previous read, take some */
80 if (s->s3->rbuf.left >= (int)n) 151 if (s->s3->rbuf.left >= (int)n)
81 { 152 {
82 if (extend) 153 s->packet_length+=n;
83 s->packet_length+=n;
84 else
85 {
86 s->packet= &(s->s3->rbuf.buf[s->s3->rbuf.offset]);
87 s->packet_length=n;
88 }
89 s->s3->rbuf.left-=n; 154 s->s3->rbuf.left-=n;
90 s->s3->rbuf.offset+=n; 155 s->s3->rbuf.offset+=n;
91 return(n); 156 return(n);
92 } 157 }
93 158
94 /* else we need to read more data */ 159 /* else we need to read more data */
95 if (!s->read_ahead) max=n; 160 if (!s->read_ahead)
96 if (max > SSL3_RT_MAX_PACKET_SIZE) 161 max=n;
97 max=SSL3_RT_MAX_PACKET_SIZE;
98
99 /* First check if there is some left or we want to extend */
100 off=0;
101 if ( (s->s3->rbuf.left != 0) ||
102 ((s->packet_length != 0) && extend))
103 {
104 newb=s->s3->rbuf.left;
105 if (extend)
106 {
107 /* Copy bytes back to the front of the buffer
108 * Take the bytes already pointed to by 'packet'
109 * and take the extra ones on the end. */
110 off=s->packet_length;
111 if (s->packet != s->s3->rbuf.buf)
112 memcpy(s->s3->rbuf.buf,s->packet,newb+off);
113 }
114 else if (s->s3->rbuf.offset != 0)
115 { /* so the data is not at the start of the buffer */
116 memcpy(s->s3->rbuf.buf,
117 &(s->s3->rbuf.buf[s->s3->rbuf.offset]),newb);
118 s->s3->rbuf.offset=0;
119 }
120 162
121 s->s3->rbuf.left=0; 163 {
164 /* avoid buffer overflow */
165 int max_max = SSL3_RT_MAX_PACKET_SIZE - 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)
169 max = max_max;
170 }
171 if (n > max) /* does not happen */
172 {
173 SSLerr(SSL_F_SSL3_READ_N,SSL_R_INTERNAL_ERROR);
174 return -1;
122 } 175 }
123 else
124 newb=0;
125 176
126 /* So we now have 'newb' bytes at the front of 177 off = s->packet_length;
127 * s->s3->rbuf.buf and need to read some more in on the end 178 newb = s->s3->rbuf.left;
128 * We start reading into the buffer at 's->s3->rbuf.offset' 179 /* Move any available bytes to front of buffer:
129 */ 180 * 'off' bytes already pointed to by 'packet',
130 s->packet=s->s3->rbuf.buf; 181 * 'newb' extra ones at the end */
182 if (s->packet != s->s3->rbuf.buf)
183 {
184 /* off > 0 */
185 memmove(s->s3->rbuf.buf, s->packet, off+newb);
186 s->packet = s->s3->rbuf.buf;
187 }
131 188
132 while (newb < n) 189 while (newb < n)
133 { 190 {
191 /* Now we have off+newb bytes at the front of s->s3->rbuf.buf and need
192 * to read in more until we have off+n (up to off+max if possible) */
193
134 clear_sys_error(); 194 clear_sys_error();
135 if (s->rbio != NULL) 195 if (s->rbio != NULL)
136 { 196 {
137 s->rwstate=SSL_READING; 197 s->rwstate=SSL_READING;
138 i=BIO_read(s->rbio, 198 i=BIO_read(s->rbio, &(s->s3->rbuf.buf[off+newb]), max-newb);
139 (char *)&(s->s3->rbuf.buf[off+newb]),
140 max-newb);
141 } 199 }
142 else 200 else
143 { 201 {
144 SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET); 202 SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET);
145 i= -1; 203 i = -1;
146 } 204 }
147 205
148 if (i <= 0) 206 if (i <= 0)
149 { 207 {
150 s->s3->rbuf.left+=newb; 208 s->s3->rbuf.left = newb;
151 return(i); 209 return(i);
152 } 210 }
153 newb+=i; 211 newb+=i;
154 } 212 }
155 213
156 /* record used data read */ 214 /* done reading, now the book-keeping */
157 if (newb > n) 215 s->s3->rbuf.offset = off + n;
158 { 216 s->s3->rbuf.left = newb - n;
159 s->s3->rbuf.offset=n+off; 217 s->packet_length += n;
160 s->s3->rbuf.left=newb-n; 218 s->rwstate=SSL_NOTHING;
161 }
162 else
163 {
164 s->s3->rbuf.offset=0;
165 s->s3->rbuf.left=0;
166 }
167
168 if (extend)
169 s->packet_length+=n;
170 else
171 s->packet_length+=n;
172 return(n); 219 return(n);
173 } 220 }
174 221
@@ -176,15 +223,15 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
176 * It will return <= 0 if more data is needed, normally due to an error 223 * It will return <= 0 if more data is needed, normally due to an error
177 * or non-blocking IO. 224 * or non-blocking IO.
178 * When it finishes, one packet has been decoded and can be found in 225 * When it finishes, one packet has been decoded and can be found in
179 * ssl->s3->rrec.type - is the type of record 226 * ssl->s3->rrec.type - is the type of record
180 * ssl->s3->rrec.data, - data 227 * ssl->s3->rrec.data, - data
181 * ssl->s3->rrec.length, - number of bytes 228 * ssl->s3->rrec.length, - number of bytes
182 */ 229 */
230/* used only by ssl3_read_bytes */
183static int ssl3_get_record(SSL *s) 231static int ssl3_get_record(SSL *s)
184 { 232 {
185 int ssl_major,ssl_minor,al; 233 int ssl_major,ssl_minor,al;
186 int n,i,ret= -1; 234 int n,i,ret= -1;
187 SSL3_BUFFER *rb;
188 SSL3_RECORD *rr; 235 SSL3_RECORD *rr;
189 SSL_SESSION *sess; 236 SSL_SESSION *sess;
190 unsigned char *p; 237 unsigned char *p;
@@ -194,7 +241,6 @@ static int ssl3_get_record(SSL *s)
194 int clear=0,extra; 241 int clear=0,extra;
195 242
196 rr= &(s->s3->rrec); 243 rr= &(s->s3->rrec);
197 rb= &(s->s3->rbuf);
198 sess=s->session; 244 sess=s->session;
199 245
200 if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) 246 if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)
@@ -253,27 +299,26 @@ again:
253 goto f_err; 299 goto f_err;
254 } 300 }
255 301
256 s->rstate=SSL_ST_READ_BODY; 302 /* now s->rstate == SSL_ST_READ_BODY */
257 } 303 }
258 304
259 /* get and decode the data */ 305 /* s->rstate == SSL_ST_READ_BODY, get and decode the data */
260 if (s->rstate == SSL_ST_READ_BODY) 306
307 if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH))
261 { 308 {
262 if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH)) 309 /* now s->packet_length == SSL3_RT_HEADER_LENGTH */
263 { 310 i=rr->length;
264 i=rr->length; 311 n=ssl3_read_n(s,i,i,1);
265 /*-(s->packet_length-SSL3_RT_HEADER_LENGTH); */ 312 if (n <= 0) return(n); /* error or non-blocking io */
266 n=ssl3_read_n(s,i,i,1); 313 /* now n == rr->length,
267 if (n <= 0) return(n); /* error or non-blocking io */ 314 * and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */
268 }
269 s->rstate=SSL_ST_READ_HEADER;
270 } 315 }
271 316
272 /* At this point, we have the data in s->packet and there should be 317 s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */
273 * s->packet_length bytes, we must not 'overrun' this buffer :-)
274 * One of the following functions will copy the data from the
275 * s->packet buffer */
276 318
319 /* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length,
320 * and we have that many bytes in s->packet
321 */
277 rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]); 322 rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]);
278 323
279 /* ok, we can now read from 's->packet' data into 'rr' 324 /* ok, we can now read from 's->packet' data into 'rr'
@@ -283,13 +328,10 @@ again:
283 * When the data is 'copied' into the rr->data buffer, 328 * When the data is 'copied' into the rr->data buffer,
284 * rr->input will be pointed at the new buffer */ 329 * rr->input will be pointed at the new buffer */
285 330
286 /* Set the state for the following operations */
287 s->rstate=SSL_ST_READ_HEADER;
288
289 /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] 331 /* We now have - encrypted [ MAC [ compressed [ plain ] ] ]
290 * rr->length bytes of encrypted compressed stuff. */ 332 * rr->length bytes of encrypted compressed stuff. */
291 333
292 /* check is not needed I belive */ 334 /* check is not needed I believe */
293 if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) 335 if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
294 { 336 {
295 al=SSL_AD_RECORD_OVERFLOW; 337 al=SSL_AD_RECORD_OVERFLOW;
@@ -326,7 +368,7 @@ printf("\n");
326 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); 368 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
327 goto f_err; 369 goto f_err;
328 } 370 }
329 /* check MAC for rr->input' */ 371 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */
330 if (rr->length < mac_size) 372 if (rr->length < mac_size)
331 { 373 {
332 al=SSL_AD_DECODE_ERROR; 374 al=SSL_AD_DECODE_ERROR;
@@ -426,12 +468,12 @@ static int do_compress(SSL *ssl)
426 return(1); 468 return(1);
427 } 469 }
428 470
429/* Call this to write data 471/* Call this to write data in records of type 'type'
430 * It will return <= 0 if not all data has been sent or non-blocking IO. 472 * It will return <= 0 if not all data has been sent or non-blocking IO.
431 */ 473 */
432int ssl3_write_bytes(SSL *s, int type, const void *_buf, int len) 474int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
433 { 475 {
434 const unsigned char *buf=_buf; 476 const unsigned char *buf=buf_;
435 unsigned int tot,n,nw; 477 unsigned int tot,n,nw;
436 int i; 478 int i;
437 479
@@ -457,7 +499,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *_buf, int len)
457 nw=SSL3_RT_MAX_PLAIN_LENGTH; 499 nw=SSL3_RT_MAX_PLAIN_LENGTH;
458 else 500 else
459 nw=n; 501 nw=n;
460 502
461 i=do_ssl3_write(s,type,&(buf[tot]),nw); 503 i=do_ssl3_write(s,type,&(buf[tot]),nw);
462 if (i <= 0) 504 if (i <= 0)
463 { 505 {
@@ -465,9 +507,6 @@ int ssl3_write_bytes(SSL *s, int type, const void *_buf, int len)
465 return(i); 507 return(i);
466 } 508 }
467 509
468 if (type == SSL3_RT_HANDSHAKE)
469 ssl3_finish_mac(s,&(buf[tot]),i);
470
471 if ((i == (int)n) || 510 if ((i == (int)n) ||
472 (type == SSL3_RT_APPLICATION_DATA && 511 (type == SSL3_RT_APPLICATION_DATA &&
473 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) 512 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE)))
@@ -503,8 +542,8 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
503 /* if it went, fall through and send more stuff */ 542 /* if it went, fall through and send more stuff */
504 } 543 }
505 544
506 if (len <= 0) return(len); 545 if (len == 0) return(len);
507 546
508 wr= &(s->s3->wrec); 547 wr= &(s->s3->wrec);
509 wb= &(s->s3->wbuf); 548 wb= &(s->s3->wbuf);
510 sess=s->session; 549 sess=s->session;
@@ -527,11 +566,11 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
527 566
528 *(p++)=(s->version>>8); 567 *(p++)=(s->version>>8);
529 *(p++)=s->version&0xff; 568 *(p++)=s->version&0xff;
530 569
531 /* record where we are to write out packet length */ 570 /* record where we are to write out packet length */
532 plen=p; 571 plen=p;
533 p+=2; 572 p+=2;
534 573
535 /* lets setup the record stuff. */ 574 /* lets setup the record stuff. */
536 wr->data=p; 575 wr->data=p;
537 wr->length=(int)len; 576 wr->length=(int)len;
@@ -638,19 +677,75 @@ static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
638 } 677 }
639 } 678 }
640 679
680/* Return up to 'len' payload bytes received in 'type' records.
681 * 'type' is one of the following:
682 *
683 * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us)
684 * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us)
685 * - 0 (during a shutdown, no data has to be returned)
686 *
687 * If we don't have stored data to work from, read a SSL/TLS record first
688 * (possibly multiple records if we still don't have anything to return).
689 *
690 * This function must handle any surprises the peer may have for us, such as
691 * Alert records (e.g. close_notify), ChangeCipherSpec records (not really
692 * a surprise, but handled as if it were), or renegotiation requests.
693 * Also if record payloads contain fragments too small to process, we store
694 * them until there is enough for the respective protocol (the record protocol
695 * may use arbitrary fragmentation and even interleaving):
696 * Change cipher spec protocol
697 * just 1 byte needed, no need for keeping anything stored
698 * Alert protocol
699 * 2 bytes needed (AlertLevel, AlertDescription)
700 * Handshake protocol
701 * 4 bytes needed (HandshakeType, uint24 length) -- we just have
702 * to detect unexpected Client Hello and Hello Request messages
703 * here, anything else is handled by higher layers
704 * Application data protocol
705 * none of our business
706 */
641int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len) 707int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len)
642 { 708 {
643 int al,i,j,n,ret; 709 int al,i,j,ret;
710 unsigned int n;
644 SSL3_RECORD *rr; 711 SSL3_RECORD *rr;
645 void (*cb)()=NULL; 712 void (*cb)()=NULL;
646 BIO *bio;
647 713
648 if (s->s3->rbuf.buf == NULL) /* Not initialize yet */ 714 if (s->s3->rbuf.buf == NULL) /* Not initialized yet */
649 if (!ssl3_setup_buffers(s)) 715 if (!ssl3_setup_buffers(s))
650 return(-1); 716 return(-1);
651 717
718 if ((type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type)
719 {
720 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_INTERNAL_ERROR);
721 return -1;
722 }
723
724 if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0))
725 /* (partially) satisfy request from storage */
726 {
727 unsigned char *src = s->s3->handshake_fragment;
728 unsigned char *dst = buf;
729 unsigned int k;
730
731 n = 0;
732 while ((len > 0) && (s->s3->handshake_fragment_len > 0))
733 {
734 *dst++ = *src++;
735 len--; s->s3->handshake_fragment_len--;
736 n++;
737 }
738 /* move any remaining fragment bytes: */
739 for (k = 0; k < s->s3->handshake_fragment_len; k++)
740 s->s3->handshake_fragment[k] = *src++;
741 return n;
742 }
743
744 /* Now s->s3->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */
745
652 if (!s->in_handshake && SSL_in_init(s)) 746 if (!s->in_handshake && SSL_in_init(s))
653 { 747 {
748 /* type == SSL3_RT_APPLICATION_DATA */
654 i=s->handshake_func(s); 749 i=s->handshake_func(s);
655 if (i < 0) return(i); 750 if (i < 0) return(i);
656 if (i == 0) 751 if (i == 0)
@@ -662,11 +757,11 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len)
662start: 757start:
663 s->rwstate=SSL_NOTHING; 758 s->rwstate=SSL_NOTHING;
664 759
665 /* s->s3->rrec.type - is the type of record 760 /* s->s3->rrec.type - is the type of record
666 * s->s3->rrec.data, - data 761 * s->s3->rrec.data, - data
667 * s->s3->rrec.off, - ofset into 'data' for next read 762 * s->s3->rrec.off, - offset into 'data' for next read
668 * s->s3->rrec.length, - number of bytes. */ 763 * s->s3->rrec.length, - number of bytes. */
669 rr= &(s->s3->rrec); 764 rr = &(s->s3->rrec);
670 765
671 /* get new packet */ 766 /* get new packet */
672 if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) 767 if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY))
@@ -677,7 +772,9 @@ start:
677 772
678 /* we now have a packet which can be read and processed */ 773 /* we now have a packet which can be read and processed */
679 774
680 if (s->s3->change_cipher_spec && (rr->type != SSL3_RT_HANDSHAKE)) 775 if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec,
776 * reset by ssl3_get_finished */
777 && (rr->type != SSL3_RT_HANDSHAKE))
681 { 778 {
682 al=SSL_AD_UNEXPECTED_MESSAGE; 779 al=SSL_AD_UNEXPECTED_MESSAGE;
683 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); 780 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED);
@@ -692,16 +789,98 @@ start:
692 return(0); 789 return(0);
693 } 790 }
694 791
695 /* Check for an incoming 'Client Request' message */ 792
696 if ((rr->type == SSL3_RT_HANDSHAKE) && (rr->length == 4) && 793 if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */
697 (rr->data[0] == SSL3_MT_CLIENT_REQUEST) && 794 {
795 /* make sure that we are not getting application data when we
796 * are doing a handshake for the first time */
797 if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
798 (s->enc_read_ctx == NULL))
799 {
800 al=SSL_AD_UNEXPECTED_MESSAGE;
801 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE);
802 goto f_err;
803 }
804
805 if (len <= 0) return(len);
806
807 if ((unsigned int)len > rr->length)
808 n = rr->length;
809 else
810 n = (unsigned int)len;
811
812 memcpy(buf,&(rr->data[rr->off]),n);
813 rr->length-=n;
814 rr->off+=n;
815 if (rr->length == 0)
816 {
817 s->rstate=SSL_ST_READ_HEADER;
818 rr->off=0;
819 }
820 return(n);
821 }
822
823
824 /* If we get here, then type != rr->type; if we have a handshake
825 * message, then it was unexpected (Hello Request or Client Hello). */
826
827 /* In case of record types for which we have 'fragment' storage,
828 * fill that so that we can process the data at a fixed place.
829 */
830 {
831 unsigned int dest_maxlen = 0;
832 unsigned char *dest = NULL;
833 unsigned int *dest_len = NULL;
834
835 if (rr->type == SSL3_RT_HANDSHAKE)
836 {
837 dest_maxlen = sizeof s->s3->handshake_fragment;
838 dest = s->s3->handshake_fragment;
839 dest_len = &s->s3->handshake_fragment_len;
840 }
841 else if (rr->type == SSL3_RT_ALERT)
842 {
843 dest_maxlen = sizeof s->s3->alert_fragment;
844 dest = s->s3->alert_fragment;
845 dest_len = &s->s3->alert_fragment_len;
846 }
847
848 if (dest_maxlen > 0)
849 {
850 n = dest_maxlen - *dest_len; /* available space in 'dest' */
851 if (rr->length < n)
852 n = rr->length; /* available bytes */
853
854 /* now move 'n' bytes: */
855 while (n-- > 0)
856 {
857 dest[(*dest_len)++] = rr->data[rr->off++];
858 rr->length--;
859 }
860
861 if (*dest_len < dest_maxlen)
862 goto start; /* fragment was too small */
863 }
864 }
865
866 /* s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE;
867 * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT.
868 * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) */
869
870 /* If we are a client, check for an incoming 'Hello Request': */
871 if ((!s->server) &&
872 (s->s3->handshake_fragment_len >= 4) &&
873 (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) &&
698 (s->session != NULL) && (s->session->cipher != NULL)) 874 (s->session != NULL) && (s->session->cipher != NULL))
699 { 875 {
700 if ((rr->data[1] != 0) || (rr->data[2] != 0) || 876 s->s3->handshake_fragment_len = 0;
701 (rr->data[3] != 0)) 877
878 if ((s->s3->handshake_fragment[1] != 0) ||
879 (s->s3->handshake_fragment[2] != 0) ||
880 (s->s3->handshake_fragment[3] != 0))
702 { 881 {
703 al=SSL_AD_DECODE_ERROR; 882 al=SSL_AD_DECODE_ERROR;
704 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CLIENT_REQUEST); 883 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_HELLO_REQUEST);
705 goto err; 884 goto err;
706 } 885 }
707 886
@@ -712,220 +891,209 @@ start:
712 ssl3_renegotiate(s); 891 ssl3_renegotiate(s);
713 if (ssl3_renegotiate_check(s)) 892 if (ssl3_renegotiate_check(s))
714 { 893 {
715 n=s->handshake_func(s); 894 i=s->handshake_func(s);
716 if (n < 0) return(n); 895 if (i < 0) return(i);
717 if (n == 0) 896 if (i == 0)
718 { 897 {
719 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); 898 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
720 return(-1); 899 return(-1);
721 } 900 }
901
902 if (s->s3->rbuf.left == 0) /* no read-ahead left? */
903 {
904 BIO *bio;
905 /* In the case where we try to read application data
906 * the first time, but we trigger an SSL handshake, we
907 * return -1 with the retry option set. I do this
908 * otherwise renegotiation can cause nasty problems
909 * in the blocking world */ /* ? */
910 s->rwstate=SSL_READING;
911 bio=SSL_get_rbio(s);
912 BIO_clear_retry_flags(bio);
913 BIO_set_retry_read(bio);
914 return(-1);
915 }
722 } 916 }
723 } 917 }
724 rr->length=0; 918 /* we either finished a handshake or ignored the request,
725/* ZZZ */ goto start; 919 * now try again to obtain the (application) data we were asked for */
920 goto start;
726 } 921 }
727 922
728 /* if it is not the type we want, or we have shutdown and want 923 if (s->s3->alert_fragment_len >= 2)
729 * the peer shutdown */
730 if ((rr->type != type) || (s->shutdown & SSL_SENT_SHUTDOWN))
731 { 924 {
732 if (rr->type == SSL3_RT_ALERT) 925 int alert_level = s->s3->alert_fragment[0];
733 { 926 int alert_descr = s->s3->alert_fragment[1];
734 if ((rr->length != 2) || (rr->off != 0))
735 {
736 al=SSL_AD_DECODE_ERROR;
737 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_ALERT_RECORD);
738 goto f_err;
739 }
740 927
741 i=rr->data[0]; 928 s->s3->alert_fragment_len = 0;
742 n=rr->data[1];
743 929
744 /* clear from buffer */ 930 if (s->info_callback != NULL)
745 rr->length=0; 931 cb=s->info_callback;
746 932 else if (s->ctx->info_callback != NULL)
747 if (s->info_callback != NULL) 933 cb=s->ctx->info_callback;
748 cb=s->info_callback;
749 else if (s->ctx->info_callback != NULL)
750 cb=s->ctx->info_callback;
751 934
752 if (cb != NULL) 935 if (cb != NULL)
753 { 936 {
754 j=(i<<8)|n; 937 j = (alert_level << 8) | alert_descr;
755 cb(s,SSL_CB_READ_ALERT,j); 938 cb(s, SSL_CB_READ_ALERT, j);
756 } 939 }
757 940
758 if (i == 1) 941 if (alert_level == 1) /* warning */
759 { 942 {
760 s->s3->warn_alert=n; 943 s->s3->warn_alert = alert_descr;
761 if (n == SSL_AD_CLOSE_NOTIFY) 944 if (alert_descr == SSL_AD_CLOSE_NOTIFY)
762 {
763 s->shutdown|=SSL_RECEIVED_SHUTDOWN;
764 return(0);
765 }
766 }
767 else if (i == 2)
768 { 945 {
769 char tmp[16]; 946 s->shutdown |= SSL_RECEIVED_SHUTDOWN;
770
771 s->rwstate=SSL_NOTHING;
772 s->s3->fatal_alert=n;
773 SSLerr(SSL_F_SSL3_READ_BYTES,
774 SSL_AD_REASON_OFFSET+n);
775 sprintf(tmp,"%d",n);
776 ERR_add_error_data(2,"SSL alert number ",tmp);
777 s->shutdown|=SSL_RECEIVED_SHUTDOWN;
778 SSL_CTX_remove_session(s->ctx,s->session);
779 return(0); 947 return(0);
780 } 948 }
781 else
782 {
783 al=SSL_AD_ILLEGAL_PARAMETER;
784 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE);
785 goto f_err;
786 }
787
788 rr->length=0;
789 goto start;
790 } 949 }
791 950 else if (alert_level == 2) /* fatal */
792 if (s->shutdown & SSL_SENT_SHUTDOWN)
793 { 951 {
952 char tmp[16];
953
794 s->rwstate=SSL_NOTHING; 954 s->rwstate=SSL_NOTHING;
795 rr->length=0; 955 s->s3->fatal_alert = alert_descr;
956 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr);
957 sprintf(tmp,"%d",alert_descr);
958 ERR_add_error_data(2,"SSL alert number ",tmp);
959 s->shutdown|=SSL_RECEIVED_SHUTDOWN;
960 SSL_CTX_remove_session(s->ctx,s->session);
796 return(0); 961 return(0);
797 } 962 }
798 963 else
799 if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC)
800 { 964 {
801 if ( (rr->length != 1) || (rr->off != 0) || 965 al=SSL_AD_ILLEGAL_PARAMETER;
802 (rr->data[0] != SSL3_MT_CCS)) 966 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE);
803 { 967 goto f_err;
804 i=SSL_AD_ILLEGAL_PARAMETER; 968 }
805 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC);
806 goto err;
807 }
808 969
809 rr->length=0; 970 goto start;
810 s->s3->change_cipher_spec=1; 971 }
811 if (!do_change_cipher_spec(s)) 972
812 goto err; 973 if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */
813 else 974 {
814 goto start; 975 s->rwstate=SSL_NOTHING;
976 rr->length=0;
977 return(0);
978 }
979
980 if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC)
981 {
982 /* 'Change Cipher Spec' is just a single byte, so we know
983 * exactly what the record payload has to look like */
984 if ( (rr->length != 1) || (rr->off != 0) ||
985 (rr->data[0] != SSL3_MT_CCS))
986 {
987 i=SSL_AD_ILLEGAL_PARAMETER;
988 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC);
989 goto err;
815 } 990 }
816 991
817 /* else we have a handshake */ 992 rr->length=0;
818 if ((rr->type == SSL3_RT_HANDSHAKE) && 993 s->s3->change_cipher_spec=1;
819 !s->in_handshake) 994 if (!do_change_cipher_spec(s))
995 goto err;
996 else
997 goto start;
998 }
999
1000 /* Unexpected handshake message (Client Hello, or protocol violation) */
1001 if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake)
1002 {
1003 if (((s->state&SSL_ST_MASK) == SSL_ST_OK) &&
1004 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS))
820 { 1005 {
821 if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && 1006#if 0 /* worked only because C operator preferences are not as expected (and
822 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) 1007 * because this is not really needed for clients except for detecting
823 { 1008 * protocol violations): */
824 s->state=SSL_ST_BEFORE|(s->server) 1009 s->state=SSL_ST_BEFORE|(s->server)
825 ?SSL_ST_ACCEPT 1010 ?SSL_ST_ACCEPT
826 :SSL_ST_CONNECT; 1011 :SSL_ST_CONNECT;
827 s->new_session=1; 1012#else
828 } 1013 s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT;
829 n=s->handshake_func(s); 1014#endif
830 if (n < 0) return(n); 1015 s->new_session=1;
831 if (n == 0) 1016 }
832 { 1017 i=s->handshake_func(s);
833 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); 1018 if (i < 0) return(i);
834 return(-1); 1019 if (i == 0)
835 } 1020 {
1021 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
1022 return(-1);
1023 }
836 1024
1025 if (s->s3->rbuf.left == 0) /* no read-ahead left? */
1026 {
1027 BIO *bio;
837 /* In the case where we try to read application data 1028 /* In the case where we try to read application data
838 * the first time, but we trigger an SSL handshake, we 1029 * the first time, but we trigger an SSL handshake, we
839 * return -1 with the retry option set. I do this 1030 * return -1 with the retry option set. I do this
840 * otherwise renegotiation can cause nasty problems 1031 * otherwise renegotiation can cause nasty problems
841 * in the non-blocking world */ 1032 * in the blocking world */ /* ? */
842
843 s->rwstate=SSL_READING; 1033 s->rwstate=SSL_READING;
844 bio=SSL_get_rbio(s); 1034 bio=SSL_get_rbio(s);
845 BIO_clear_retry_flags(bio); 1035 BIO_clear_retry_flags(bio);
846 BIO_set_retry_read(bio); 1036 BIO_set_retry_read(bio);
847 return(-1); 1037 return(-1);
848 } 1038 }
1039 goto start;
1040 }
849 1041
850 switch (rr->type) 1042 switch (rr->type)
851 { 1043 {
852 default: 1044 default:
853#ifndef NO_TLS 1045#ifndef NO_TLS
854 /* TLS just ignores unknown message types */ 1046 /* TLS just ignores unknown message types */
855 if (s->version == TLS1_VERSION) 1047 if (s->version == TLS1_VERSION)
856 { 1048 {
857 goto start; 1049 goto start;
858 } 1050 }
859#endif 1051#endif
860 case SSL3_RT_CHANGE_CIPHER_SPEC: 1052 al=SSL_AD_UNEXPECTED_MESSAGE;
861 case SSL3_RT_ALERT: 1053 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);
862 case SSL3_RT_HANDSHAKE: 1054 goto f_err;
1055 case SSL3_RT_CHANGE_CIPHER_SPEC:
1056 case SSL3_RT_ALERT:
1057 case SSL3_RT_HANDSHAKE:
1058 /* we already handled all of these, with the possible exception
1059 * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that
1060 * should not happen when type != rr->type */
1061 al=SSL_AD_UNEXPECTED_MESSAGE;
1062 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_INTERNAL_ERROR);
1063 goto f_err;
1064 case SSL3_RT_APPLICATION_DATA:
1065 /* At this point, we were expecting handshake data,
1066 * but have application data. If the library was
1067 * running inside ssl3_read() (i.e. in_read_app_data
1068 * is set) and it makes sense to read application data
1069 * at this point (session renegotiation not yet started),
1070 * we will indulge it.
1071 */
1072 if (s->s3->in_read_app_data &&
1073 (s->s3->total_renegotiations != 0) &&
1074 ((
1075 (s->state & SSL_ST_CONNECT) &&
1076 (s->state >= SSL3_ST_CW_CLNT_HELLO_A) &&
1077 (s->state <= SSL3_ST_CR_SRVR_HELLO_A)
1078 ) || (
1079 (s->state & SSL_ST_ACCEPT) &&
1080 (s->state <= SSL3_ST_SW_HELLO_REQ_A) &&
1081 (s->state >= SSL3_ST_SR_CLNT_HELLO_A)
1082 )
1083 ))
1084 {
1085 s->s3->in_read_app_data=0;
1086 return(-1);
1087 }
1088 else
1089 {
863 al=SSL_AD_UNEXPECTED_MESSAGE; 1090 al=SSL_AD_UNEXPECTED_MESSAGE;
864 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); 1091 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);
865 goto f_err; 1092 goto f_err;
866 case SSL3_RT_APPLICATION_DATA:
867 /* At this point, we were expecting something else,
868 * but have application data. What we do is set the
869 * error, and return -1. On the way out, if the
870 * library was running inside ssl3_read() and it makes
871 * sense to read application data at this point, we
872 * will indulge it. This will mostly happen during
873 * session renegotiation.
874 */
875 if (s->s3->in_read_app_data &&
876 (s->s3->total_renegotiations != 0) &&
877 ((
878 (s->state & SSL_ST_CONNECT) &&
879 (s->state >= SSL3_ST_CW_CLNT_HELLO_A) &&
880 (s->state <= SSL3_ST_CR_SRVR_HELLO_A)
881 ) || (
882 (s->state & SSL_ST_ACCEPT) &&
883 (s->state <= SSL3_ST_SW_HELLO_REQ_A) &&
884 (s->state >= SSL3_ST_SR_CLNT_HELLO_A)
885 )
886 ))
887 {
888 s->s3->in_read_app_data=0;
889 return(-1);
890 }
891 else
892 {
893 al=SSL_AD_UNEXPECTED_MESSAGE;
894 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);
895 goto f_err;
896 }
897 } 1093 }
898 } 1094 }
1095 /* not reached */
899 1096
900 /* make sure that we are not getting application data when we
901 * are doing a handshake for the first time */
902 if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
903 (s->enc_read_ctx == NULL))
904 {
905 al=SSL_AD_UNEXPECTED_MESSAGE;
906 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE);
907 goto f_err;
908 }
909
910 if (len <= 0) return(len);
911
912 if ((unsigned int)len > rr->length)
913 n=rr->length;
914 else
915 n=len;
916
917 memcpy(buf,&(rr->data[rr->off]),(unsigned int)n);
918 rr->length-=n;
919 rr->off+=n;
920 if (rr->length <= 0)
921 {
922 s->rstate=SSL_ST_READ_HEADER;
923 rr->off=0;
924 }
925
926 if (type == SSL3_RT_HANDSHAKE)
927 ssl3_finish_mac(s,buf,n);
928 return(n);
929f_err: 1097f_err:
930 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1098 ssl3_send_alert(s,SSL3_AL_FATAL,al);
931err: 1099err:
@@ -935,7 +1103,7 @@ err:
935static int do_change_cipher_spec(SSL *s) 1103static int do_change_cipher_spec(SSL *s)
936 { 1104 {
937 int i; 1105 int i;
938 unsigned char *sender; 1106 const char *sender;
939 int slen; 1107 int slen;
940 1108
941 if (s->state & SSL_ST_ACCEPT) 1109 if (s->state & SSL_ST_ACCEPT)
@@ -957,37 +1125,23 @@ static int do_change_cipher_spec(SSL *s)
957 * the finished message */ 1125 * the finished message */
958 if (s->state & SSL_ST_CONNECT) 1126 if (s->state & SSL_ST_CONNECT)
959 { 1127 {
960 sender=s->method->ssl3_enc->server_finished; 1128 sender=s->method->ssl3_enc->server_finished_label;
961 slen=s->method->ssl3_enc->server_finished_len; 1129 slen=s->method->ssl3_enc->server_finished_label_len;
962 } 1130 }
963 else 1131 else
964 { 1132 {
965 sender=s->method->ssl3_enc->client_finished; 1133 sender=s->method->ssl3_enc->client_finished_label;
966 slen=s->method->ssl3_enc->client_finished_len; 1134 slen=s->method->ssl3_enc->client_finished_label_len;
967 } 1135 }
968 1136
969 s->method->ssl3_enc->final_finish_mac(s, 1137 s->s3->tmp.peer_finish_md_len = s->method->ssl3_enc->final_finish_mac(s,
970 &(s->s3->finish_dgst1), 1138 &(s->s3->finish_dgst1),
971 &(s->s3->finish_dgst2), 1139 &(s->s3->finish_dgst2),
972 sender,slen,&(s->s3->tmp.finish_md[0])); 1140 sender,slen,s->s3->tmp.peer_finish_md);
973 1141
974 return(1); 1142 return(1);
975 } 1143 }
976 1144
977int ssl3_do_write(SSL *s, int type)
978 {
979 int ret;
980
981 ret=ssl3_write_bytes(s,type,&s->init_buf->data[s->init_off],
982 s->init_num);
983 if (ret == s->init_num)
984 return(1);
985 if (ret < 0) return(-1);
986 s->init_off+=ret;
987 s->init_num-=ret;
988 return(0);
989 }
990
991void ssl3_send_alert(SSL *s, int level, int desc) 1145void ssl3_send_alert(SSL *s, int level, int desc)
992 { 1146 {
993 /* Map tls/ssl alert value to correct one */ 1147 /* Map tls/ssl alert value to correct one */
@@ -1029,7 +1183,7 @@ int ssl3_dispatch_alert(SSL *s)
1029 cb=s->info_callback; 1183 cb=s->info_callback;
1030 else if (s->ctx->info_callback != NULL) 1184 else if (s->ctx->info_callback != NULL)
1031 cb=s->ctx->info_callback; 1185 cb=s->ctx->info_callback;
1032 1186
1033 if (cb != NULL) 1187 if (cb != NULL)
1034 { 1188 {
1035 j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; 1189 j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1];
@@ -1038,4 +1192,3 @@ int ssl3_dispatch_alert(SSL *s)
1038 } 1192 }
1039 return(i); 1193 return(i);
1040 } 1194 }
1041
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c
index e003d88357..90806e2d99 100644
--- a/src/lib/libssl/src/ssl/s3_srvr.c
+++ b/src/lib/libssl/src/ssl/s3_srvr.c
@@ -57,6 +57,8 @@
57 */ 57 */
58 58
59#define REUSE_CIPHER_BUG 59#define REUSE_CIPHER_BUG
60#define NETSCAPE_HANG_BUG
61
60 62
61#include <stdio.h> 63#include <stdio.h>
62#include <openssl/buffer.h> 64#include <openssl/buffer.h>
@@ -70,13 +72,14 @@
70 72
71static SSL_METHOD *ssl3_get_server_method(int ver); 73static SSL_METHOD *ssl3_get_server_method(int ver);
72static int ssl3_get_client_hello(SSL *s); 74static int ssl3_get_client_hello(SSL *s);
75static int ssl3_check_client_hello(SSL *s);
73static int ssl3_send_server_hello(SSL *s); 76static int ssl3_send_server_hello(SSL *s);
74static int ssl3_send_server_key_exchange(SSL *s); 77static int ssl3_send_server_key_exchange(SSL *s);
75static int ssl3_send_certificate_request(SSL *s); 78static int ssl3_send_certificate_request(SSL *s);
76static int ssl3_send_server_done(SSL *s); 79static int ssl3_send_server_done(SSL *s);
77static int ssl3_get_cert_verify(SSL *s);
78static int ssl3_get_client_key_exchange(SSL *s); 80static int ssl3_get_client_key_exchange(SSL *s);
79static int ssl3_get_client_certificate(SSL *s); 81static int ssl3_get_client_certificate(SSL *s);
82static int ssl3_get_cert_verify(SSL *s);
80static int ssl3_send_hello_request(SSL *s); 83static int ssl3_send_hello_request(SSL *s);
81 84
82static SSL_METHOD *ssl3_get_server_method(int ver) 85static SSL_METHOD *ssl3_get_server_method(int ver)
@@ -112,7 +115,7 @@ int ssl3_accept(SSL *s)
112 int ret= -1; 115 int ret= -1;
113 int new_state,state,skip=0; 116 int new_state,state,skip=0;
114 117
115 RAND_seed(&Time,sizeof(Time)); 118 RAND_add(&Time,sizeof(Time),0);
116 ERR_clear_error(); 119 ERR_clear_error();
117 clear_sys_error(); 120 clear_sys_error();
118 121
@@ -151,7 +154,6 @@ int ssl3_accept(SSL *s)
151 154
152 if ((s->version>>8) != 3) 155 if ((s->version>>8) != 3)
153 abort(); 156 abort();
154 /* s->version=SSL3_VERSION; */
155 s->type=SSL_ST_ACCEPT; 157 s->type=SSL_ST_ACCEPT;
156 158
157 if (s->init_buf == NULL) 159 if (s->init_buf == NULL)
@@ -184,8 +186,8 @@ int ssl3_accept(SSL *s)
184 186
185 if (s->state != SSL_ST_RENEGOTIATE) 187 if (s->state != SSL_ST_RENEGOTIATE)
186 { 188 {
187 s->state=SSL3_ST_SR_CLNT_HELLO_A;
188 ssl3_init_finished_mac(s); 189 ssl3_init_finished_mac(s);
190 s->state=SSL3_ST_SR_CLNT_HELLO_A;
189 s->ctx->stats.sess_accept++; 191 s->ctx->stats.sess_accept++;
190 } 192 }
191 else 193 else
@@ -268,8 +270,8 @@ int ssl3_accept(SSL *s)
268 || (l & (SSL_DH|SSL_kFZA)) 270 || (l & (SSL_DH|SSL_kFZA))
269 || ((l & SSL_kRSA) 271 || ((l & SSL_kRSA)
270 && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL 272 && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL
271 || (SSL_IS_EXPORT(l) 273 || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)
272 && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_EXPORT_PKEYLENGTH(l) 274 && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)
273 ) 275 )
274 ) 276 )
275 ) 277 )
@@ -287,9 +289,19 @@ int ssl3_accept(SSL *s)
287 289
288 case SSL3_ST_SW_CERT_REQ_A: 290 case SSL3_ST_SW_CERT_REQ_A:
289 case SSL3_ST_SW_CERT_REQ_B: 291 case SSL3_ST_SW_CERT_REQ_B:
290 if (!(s->verify_mode & SSL_VERIFY_PEER) || 292 if (/* don't request cert unless asked for it: */
293 !(s->verify_mode & SSL_VERIFY_PEER) ||
294 /* if SSL_VERIFY_CLIENT_ONCE is set,
295 * don't request cert during re-negotiation: */
291 ((s->session->peer != NULL) && 296 ((s->session->peer != NULL) &&
292 (s->verify_mode & SSL_VERIFY_CLIENT_ONCE))) 297 (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
298 /* never request cert in anonymous ciphersuites
299 * (see section "Certificate request" in SSL 3 drafts
300 * and in RFC 2246): */
301 ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) &&
302 /* ... except when the application insists on verification
303 * (against the specs, but s3_clnt.c accepts this for SSL 3) */
304 !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)))
293 { 305 {
294 /* no cert request */ 306 /* no cert request */
295 skip=1; 307 skip=1;
@@ -301,7 +313,12 @@ int ssl3_accept(SSL *s)
301 s->s3->tmp.cert_request=1; 313 s->s3->tmp.cert_request=1;
302 ret=ssl3_send_certificate_request(s); 314 ret=ssl3_send_certificate_request(s);
303 if (ret <= 0) goto end; 315 if (ret <= 0) goto end;
316#ifndef NETSCAPE_HANG_BUG
304 s->state=SSL3_ST_SW_SRVR_DONE_A; 317 s->state=SSL3_ST_SW_SRVR_DONE_A;
318#else
319 s->state=SSL3_ST_SW_FLUSH;
320 s->s3->tmp.next_state=SSL3_ST_SR_CERT_A;
321#endif
305 s->init_num=0; 322 s->init_num=0;
306 } 323 }
307 break; 324 break;
@@ -331,12 +348,20 @@ int ssl3_accept(SSL *s)
331 348
332 case SSL3_ST_SR_CERT_A: 349 case SSL3_ST_SR_CERT_A:
333 case SSL3_ST_SR_CERT_B: 350 case SSL3_ST_SR_CERT_B:
334 /* could be sent for a DH cert, even if we 351 /* Check for second client hello (MS SGC) */
335 * have not asked for it :-) */ 352 ret = ssl3_check_client_hello(s);
336 ret=ssl3_get_client_certificate(s); 353 if (ret <= 0)
337 if (ret <= 0) goto end; 354 goto end;
338 s->init_num=0; 355 if (ret == 2)
339 s->state=SSL3_ST_SR_KEY_EXCH_A; 356 s->state = SSL3_ST_SR_CLNT_HELLO_C;
357 else {
358 /* could be sent for a DH cert, even if we
359 * have not asked for it :-) */
360 ret=ssl3_get_client_certificate(s);
361 if (ret <= 0) goto end;
362 s->init_num=0;
363 s->state=SSL3_ST_SR_KEY_EXCH_A;
364 }
340 break; 365 break;
341 366
342 case SSL3_ST_SR_KEY_EXCH_A: 367 case SSL3_ST_SR_KEY_EXCH_A:
@@ -350,10 +375,10 @@ int ssl3_accept(SSL *s)
350 * a client cert, it can be verified */ 375 * a client cert, it can be verified */
351 s->method->ssl3_enc->cert_verify_mac(s, 376 s->method->ssl3_enc->cert_verify_mac(s,
352 &(s->s3->finish_dgst1), 377 &(s->s3->finish_dgst1),
353 &(s->s3->tmp.finish_md[0])); 378 &(s->s3->tmp.cert_verify_md[0]));
354 s->method->ssl3_enc->cert_verify_mac(s, 379 s->method->ssl3_enc->cert_verify_mac(s,
355 &(s->s3->finish_dgst2), 380 &(s->s3->finish_dgst2),
356 &(s->s3->tmp.finish_md[MD5_DIGEST_LENGTH])); 381 &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]));
357 382
358 break; 383 break;
359 384
@@ -407,8 +432,8 @@ int ssl3_accept(SSL *s)
407 case SSL3_ST_SW_FINISHED_B: 432 case SSL3_ST_SW_FINISHED_B:
408 ret=ssl3_send_finished(s, 433 ret=ssl3_send_finished(s,
409 SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, 434 SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B,
410 s->method->ssl3_enc->server_finished, 435 s->method->ssl3_enc->server_finished_label,
411 s->method->ssl3_enc->server_finished_len); 436 s->method->ssl3_enc->server_finished_label_len);
412 if (ret <= 0) goto end; 437 if (ret <= 0) goto end;
413 s->state=SSL3_ST_SW_FLUSH; 438 s->state=SSL3_ST_SW_FLUSH;
414 if (s->hit) 439 if (s->hit)
@@ -485,7 +510,7 @@ static int ssl3_send_hello_request(SSL *s)
485 if (s->state == SSL3_ST_SW_HELLO_REQ_A) 510 if (s->state == SSL3_ST_SW_HELLO_REQ_A)
486 { 511 {
487 p=(unsigned char *)s->init_buf->data; 512 p=(unsigned char *)s->init_buf->data;
488 *(p++)=SSL3_MT_CLIENT_REQUEST; 513 *(p++)=SSL3_MT_HELLO_REQUEST;
489 *(p++)=0; 514 *(p++)=0;
490 *(p++)=0; 515 *(p++)=0;
491 *(p++)=0; 516 *(p++)=0;
@@ -500,6 +525,37 @@ static int ssl3_send_hello_request(SSL *s)
500 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); 525 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE));
501 } 526 }
502 527
528static int ssl3_check_client_hello(SSL *s)
529 {
530 int ok;
531 long n;
532
533 n=ssl3_get_message(s,
534 SSL3_ST_SR_CERT_A,
535 SSL3_ST_SR_CERT_B,
536 -1,
537 SSL3_RT_MAX_PLAIN_LENGTH,
538 &ok);
539 if (!ok) return((int)n);
540 s->s3->tmp.reuse_message = 1;
541 if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO)
542 {
543 /* Throw away what we have done so far in the current handshake,
544 * which will now be aborted. (A full SSL_clear would be too much.)
545 * I hope that tmp.dh is the only thing that may need to be cleared
546 * when a handshake is not completed ... */
547#ifndef NO_DH
548 if (s->s3->tmp.dh != NULL)
549 {
550 DH_free(s->s3->tmp.dh);
551 s->s3->tmp.dh = NULL;
552 }
553#endif
554 return 2;
555 }
556 return 1;
557}
558
503static int ssl3_get_client_hello(SSL *s) 559static int ssl3_get_client_hello(SSL *s)
504 { 560 {
505 int i,j,ok,al,ret= -1; 561 int i,j,ok,al,ret= -1;
@@ -531,10 +587,9 @@ static int ssl3_get_client_hello(SSL *s)
531 if (!ok) return((int)n); 587 if (!ok) return((int)n);
532 d=p=(unsigned char *)s->init_buf->data; 588 d=p=(unsigned char *)s->init_buf->data;
533 589
534 /* The version number has already been checked in ssl3_get_message. 590 /* use version from inside client hello, not from record header
535 * I a native TLSv1/SSLv3 method, the match must be correct except 591 * (may differ: see RFC 2246, Appendix E, second paragraph) */
536 * perhaps for the first message */ 592 s->client_version=(((int)p[0])<<8)|(int)p[1];
537/* s->client_version=(((int)p[0])<<8)|(int)p[1]; */
538 p+=2; 593 p+=2;
539 594
540 /* load the client random */ 595 /* load the client random */
@@ -754,7 +809,7 @@ static int ssl3_get_client_hello(SSL *s)
754 * compression - basically ignored right now 809 * compression - basically ignored right now
755 * ssl version is set - sslv3 810 * ssl version is set - sslv3
756 * s->session - The ssl session has been setup. 811 * s->session - The ssl session has been setup.
757 * s->hit - sesson reuse flag 812 * s->hit - session reuse flag
758 * s->tmp.new_cipher - the new cipher to use. 813 * s->tmp.new_cipher - the new cipher to use.
759 */ 814 */
760 815
@@ -782,7 +837,7 @@ static int ssl3_send_server_hello(SSL *s)
782 p=s->s3->server_random; 837 p=s->s3->server_random;
783 Time=time(NULL); /* Time */ 838 Time=time(NULL); /* Time */
784 l2n(Time,p); 839 l2n(Time,p);
785 RAND_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); 840 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
786 /* Do the message type and length last */ 841 /* Do the message type and length last */
787 d=p= &(buf[4]); 842 d=p= &(buf[4]);
788 843
@@ -866,9 +921,10 @@ static int ssl3_send_server_key_exchange(SSL *s)
866 int j,num; 921 int j,num;
867 RSA *rsa; 922 RSA *rsa;
868 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 923 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
924 unsigned int u;
869#endif 925#endif
870#ifndef NO_DH 926#ifndef NO_DH
871 DH *dh,*dhp; 927 DH *dh=NULL,*dhp;
872#endif 928#endif
873 EVP_PKEY *pkey; 929 EVP_PKEY *pkey;
874 unsigned char *p,*d; 930 unsigned char *p,*d;
@@ -899,6 +955,12 @@ static int ssl3_send_server_key_exchange(SSL *s)
899 rsa=s->cert->rsa_tmp_cb(s, 955 rsa=s->cert->rsa_tmp_cb(s,
900 SSL_C_IS_EXPORT(s->s3->tmp.new_cipher), 956 SSL_C_IS_EXPORT(s->s3->tmp.new_cipher),
901 SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)); 957 SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher));
958 if(rsa == NULL)
959 {
960 al=SSL_AD_HANDSHAKE_FAILURE;
961 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY);
962 goto f_err;
963 }
902 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 964 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA);
903 cert->rsa_tmp=rsa; 965 cert->rsa_tmp=rsa;
904 } 966 }
@@ -928,6 +990,14 @@ static int ssl3_send_server_key_exchange(SSL *s)
928 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY); 990 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY);
929 goto f_err; 991 goto f_err;
930 } 992 }
993
994 if (s->s3->tmp.dh != NULL)
995 {
996 DH_free(dh);
997 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_INTERNAL_ERROR);
998 goto err;
999 }
1000
931 if ((dh=DHparams_dup(dhp)) == NULL) 1001 if ((dh=DHparams_dup(dhp)) == NULL)
932 { 1002 {
933 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB); 1003 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB);
@@ -1027,15 +1097,14 @@ static int ssl3_send_server_key_exchange(SSL *s)
1027 q+=i; 1097 q+=i;
1028 j+=i; 1098 j+=i;
1029 } 1099 }
1030 i=RSA_private_encrypt(j,md_buf,&(p[2]), 1100 if (RSA_sign(NID_md5_sha1, md_buf, j,
1031 pkey->pkey.rsa,RSA_PKCS1_PADDING); 1101 &(p[2]), &u, pkey->pkey.rsa) <= 0)
1032 if (i <= 0)
1033 { 1102 {
1034 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_RSA); 1103 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_RSA);
1035 goto err; 1104 goto err;
1036 } 1105 }
1037 s2n(i,p); 1106 s2n(u,p);
1038 n+=i+2; 1107 n+=u+2;
1039 } 1108 }
1040 else 1109 else
1041#endif 1110#endif
@@ -1075,7 +1144,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
1075 s->init_off=0; 1144 s->init_off=0;
1076 } 1145 }
1077 1146
1078 /* SSL3_ST_SW_KEY_EXCH_B */ 1147 s->state = SSL3_ST_SW_KEY_EXCH_B;
1079 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); 1148 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE));
1080f_err: 1149f_err:
1081 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1150 ssl3_send_alert(s,SSL3_AL_FATAL,al);
@@ -1152,6 +1221,17 @@ static int ssl3_send_certificate_request(SSL *s)
1152 1221
1153 s->init_num=n+4; 1222 s->init_num=n+4;
1154 s->init_off=0; 1223 s->init_off=0;
1224#ifdef NETSCAPE_HANG_BUG
1225 p=(unsigned char *)s->init_buf->data + s->init_num;
1226
1227 /* do the header */
1228 *(p++)=SSL3_MT_SERVER_DONE;
1229 *(p++)=0;
1230 *(p++)=0;
1231 *(p++)=0;
1232 s->init_num += 4;
1233#endif
1234
1155 } 1235 }
1156 1236
1157 /* SSL3_ST_SW_CERT_REQ_B */ 1237 /* SSL3_ST_SW_CERT_REQ_B */
@@ -1239,31 +1319,6 @@ static int ssl3_get_client_key_exchange(SSL *s)
1239 1319
1240 i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); 1320 i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING);
1241 1321
1242#if 1
1243 /* If a bad decrypt, use a random master key */
1244 if ((i != SSL_MAX_MASTER_KEY_LENGTH) ||
1245 ((p[0] != (s->client_version>>8)) ||
1246 (p[1] != (s->client_version & 0xff))))
1247 {
1248 int bad=1;
1249
1250 if ((i == SSL_MAX_MASTER_KEY_LENGTH) &&
1251 (p[0] == (s->version>>8)) &&
1252 (p[1] == 0))
1253 {
1254 if (s->options & SSL_OP_TLS_ROLLBACK_BUG)
1255 bad=0;
1256 }
1257 if (bad)
1258 {
1259 p[0]=(s->version>>8);
1260 p[1]=(s->version & 0xff);
1261 RAND_bytes(&(p[2]),SSL_MAX_MASTER_KEY_LENGTH-2);
1262 i=SSL_MAX_MASTER_KEY_LENGTH;
1263 }
1264 /* else, an SSLeay bug, ssl only server, tls client */
1265 }
1266#else
1267 if (i != SSL_MAX_MASTER_KEY_LENGTH) 1322 if (i != SSL_MAX_MASTER_KEY_LENGTH)
1268 { 1323 {
1269 al=SSL_AD_DECODE_ERROR; 1324 al=SSL_AD_DECODE_ERROR;
@@ -1271,13 +1326,12 @@ static int ssl3_get_client_key_exchange(SSL *s)
1271 goto f_err; 1326 goto f_err;
1272 } 1327 }
1273 1328
1274 if ((p[0] != (s->version>>8)) || (p[1] != (s->version & 0xff))) 1329 if ((p[0] != (s->client_version>>8)) || (p[1] != (s->client_version & 0xff)))
1275 { 1330 {
1276 al=SSL_AD_DECODE_ERROR; 1331 al=SSL_AD_DECODE_ERROR;
1277 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); 1332 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER);
1278 goto f_err; 1333 goto f_err;
1279 } 1334 }
1280#endif
1281 1335
1282 s->session->master_key_length= 1336 s->session->master_key_length=
1283 s->method->ssl3_enc->generate_master_secret(s, 1337 s->method->ssl3_enc->generate_master_secret(s,
@@ -1450,16 +1504,16 @@ static int ssl3_get_cert_verify(SSL *s)
1450#ifndef NO_RSA 1504#ifndef NO_RSA
1451 if (pkey->type == EVP_PKEY_RSA) 1505 if (pkey->type == EVP_PKEY_RSA)
1452 { 1506 {
1453 i=RSA_public_decrypt(i,p,p,pkey->pkey.rsa,RSA_PKCS1_PADDING); 1507 i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,
1508 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, p, i,
1509 pkey->pkey.rsa);
1454 if (i < 0) 1510 if (i < 0)
1455 { 1511 {
1456 al=SSL_AD_DECRYPT_ERROR; 1512 al=SSL_AD_DECRYPT_ERROR;
1457 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT); 1513 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT);
1458 goto f_err; 1514 goto f_err;
1459 } 1515 }
1460 if ((i != (MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH)) || 1516 if (i == 0)
1461 memcmp(&(s->s3->tmp.finish_md[0]),p,
1462 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH))
1463 { 1517 {
1464 al=SSL_AD_DECRYPT_ERROR; 1518 al=SSL_AD_DECRYPT_ERROR;
1465 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE); 1519 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE);
@@ -1472,7 +1526,7 @@ static int ssl3_get_cert_verify(SSL *s)
1472 if (pkey->type == EVP_PKEY_DSA) 1526 if (pkey->type == EVP_PKEY_DSA)
1473 { 1527 {
1474 j=DSA_verify(pkey->save_type, 1528 j=DSA_verify(pkey->save_type,
1475 &(s->s3->tmp.finish_md[MD5_DIGEST_LENGTH]), 1529 &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]),
1476 SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa); 1530 SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa);
1477 if (j <= 0) 1531 if (j <= 0)
1478 { 1532 {
@@ -1532,7 +1586,7 @@ static int ssl3_get_client_certificate(SSL *s)
1532 al=SSL_AD_HANDSHAKE_FAILURE; 1586 al=SSL_AD_HANDSHAKE_FAILURE;
1533 goto f_err; 1587 goto f_err;
1534 } 1588 }
1535 /* If tls asked for a client cert we must return a 0 list */ 1589 /* If tls asked for a client cert, the client must return a 0 list */
1536 if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) 1590 if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request)
1537 { 1591 {
1538 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST); 1592 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST);
@@ -1628,6 +1682,7 @@ static int ssl3_get_client_certificate(SSL *s)
1628 if (s->session->peer != NULL) /* This should not be needed */ 1682 if (s->session->peer != NULL) /* This should not be needed */
1629 X509_free(s->session->peer); 1683 X509_free(s->session->peer);
1630 s->session->peer=sk_X509_shift(sk); 1684 s->session->peer=sk_X509_shift(sk);
1685 s->session->verify_result = s->verify_result;
1631 1686
1632 /* With the current implementation, sess_cert will always be NULL 1687 /* With the current implementation, sess_cert will always be NULL
1633 * when we arrive here. */ 1688 * when we arrive here. */
diff --git a/src/lib/libssl/src/ssl/ssl-lib.com b/src/lib/libssl/src/ssl/ssl-lib.com
index 75fa89f193..0a8581898c 100644
--- a/src/lib/libssl/src/ssl/ssl-lib.com
+++ b/src/lib/libssl/src/ssl/ssl-lib.com
@@ -897,12 +897,36 @@ $!
897$! Set Up Initial CC Definitions, Possibly With User Ones 897$! Set Up Initial CC Definitions, Possibly With User Ones
898$! 898$!
899$ CCDEFS = "VMS=1,TCPIP_TYPE_''P5'" 899$ CCDEFS = "VMS=1,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"
900$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 924$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
901$ CCEXTRAFLAGS = "" 925$ CCEXTRAFLAGS = ""
902$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 926$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
903$ CCDISABLEWARNINGS = "" 927$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
904$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - 928$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
905 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS 929 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
906$! 930$!
907$! Check To See If The User Entered A Valid Paramter. 931$! Check To See If The User Entered A Valid Paramter.
908$! 932$!
diff --git a/src/lib/libssl/src/ssl/ssl.h b/src/lib/libssl/src/ssl/ssl.h
index fbe4f667fa..f29f775347 100644
--- a/src/lib/libssl/src/ssl/ssl.h
+++ b/src/lib/libssl/src/ssl/ssl.h
@@ -123,8 +123,9 @@ extern "C" {
123#define SSL_TXT_MD5 "MD5" 123#define SSL_TXT_MD5 "MD5"
124#define SSL_TXT_SHA1 "SHA1" 124#define SSL_TXT_SHA1 "SHA1"
125#define SSL_TXT_SHA "SHA" 125#define SSL_TXT_SHA "SHA"
126#define SSL_TXT_EXP40 "EXP" 126#define SSL_TXT_EXP "EXP"
127#define SSL_TXT_EXPORT "EXPORT" 127#define SSL_TXT_EXPORT "EXPORT"
128#define SSL_TXT_EXP40 "EXPORT40"
128#define SSL_TXT_EXP56 "EXPORT56" 129#define SSL_TXT_EXP56 "EXPORT56"
129#define SSL_TXT_SSLV2 "SSLv2" 130#define SSL_TXT_SSLV2 "SSLv2"
130#define SSL_TXT_SSLV3 "SSLv3" 131#define SSL_TXT_SSLV3 "SSLv3"
@@ -133,12 +134,7 @@ extern "C" {
133 134
134/* 'DEFAULT' at the start of the cipher list insert the following string 135/* 'DEFAULT' at the start of the cipher list insert the following string
135 * in addition to this being the default cipher string */ 136 * in addition to this being the default cipher string */
136#ifndef NO_RSA 137#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+SSLv2:@STRENGTH"
137#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP"
138#else
139#define SSL_ALLOW_ADH
140#define SSL_DEFAULT_CIPHER_LIST "HIGH:MEDIUM:LOW:ADH+3DES:ADH+RC4:ADH+DES:+EXP"
141#endif
142 138
143/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ 139/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
144#define SSL_SENT_SHUTDOWN 1 140#define SSL_SENT_SHUTDOWN 1
@@ -151,6 +147,10 @@ extern "C" {
151#include <openssl/pem.h> 147#include <openssl/pem.h>
152#include <openssl/x509.h> 148#include <openssl/x509.h>
153 149
150#if (defined(NO_RSA) || defined(NO_MD5)) && !defined(NO_SSL2)
151#define NO_SSL2
152#endif
153
154#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 154#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
155#define SSL_FILETYPE_PEM X509_FILETYPE_PEM 155#define SSL_FILETYPE_PEM X509_FILETYPE_PEM
156 156
@@ -166,8 +166,12 @@ typedef struct ssl_cipher_st
166 const char *name; /* text name */ 166 const char *name; /* text name */
167 unsigned long id; /* id, 4 bytes, first is version */ 167 unsigned long id; /* id, 4 bytes, first is version */
168 unsigned long algorithms; /* what ciphers are used */ 168 unsigned long algorithms; /* what ciphers are used */
169 unsigned long algo_strength; /* strength and export flags */
169 unsigned long algorithm2; /* Extra flags */ 170 unsigned long algorithm2; /* Extra flags */
171 int strength_bits; /* Number of bits really used */
172 int alg_bits; /* Number of bits for algorithm */
170 unsigned long mask; /* used for matching */ 173 unsigned long mask; /* used for matching */
174 unsigned long mask_strength; /* also used for matching */
171 } SSL_CIPHER; 175 } SSL_CIPHER;
172 176
173DECLARE_STACK_OF(SSL_CIPHER) 177DECLARE_STACK_OF(SSL_CIPHER)
@@ -201,6 +205,8 @@ typedef struct ssl_method_st
201 long (*get_timeout)(void); 205 long (*get_timeout)(void);
202 struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ 206 struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
203 int (*ssl_version)(); 207 int (*ssl_version)();
208 long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)());
209 long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)());
204 } SSL_METHOD; 210 } SSL_METHOD;
205 211
206/* Lets make this into an ASN.1 type structure as follows 212/* Lets make this into an ASN.1 type structure as follows
@@ -215,7 +221,8 @@ typedef struct ssl_method_st
215 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds 221 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
216 * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate 222 * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate
217 * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context 223 * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context
218 * Compression [5] IMPLICIT ASN1_OBJECT -- compression OID XXXXX 224 * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer'
225 * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX
219 * } 226 * }
220 * Look in ssl/ssl_asn1.c for more details 227 * Look in ssl/ssl_asn1.c for more details
221 * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). 228 * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
@@ -249,6 +256,9 @@ typedef struct ssl_session_st
249 * (the latter is not enough as sess_cert is not retained 256 * (the latter is not enough as sess_cert is not retained
250 * in the external representation of sessions, see ssl_asn1.c). */ 257 * in the external representation of sessions, see ssl_asn1.c). */
251 X509 *peer; 258 X509 *peer;
259 /* when app_verify_callback accepts a session where the peer's certificate
260 * is not ok, we must remember the error for session reuse: */
261 long verify_result; /* only for servers */
252 262
253 int references; 263 int references;
254 long timeout; 264 long timeout;
@@ -291,6 +301,7 @@ typedef struct ssl_session_st
291#define SSL_OP_PKCS1_CHECK_1 0x08000000L 301#define SSL_OP_PKCS1_CHECK_1 0x08000000L
292#define SSL_OP_PKCS1_CHECK_2 0x10000000L 302#define SSL_OP_PKCS1_CHECK_2 0x10000000L
293#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L 303#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L
304/* SSL_OP_NON_EXPORT_FIRST looks utterly broken .. */
294#define SSL_OP_NON_EXPORT_FIRST 0x40000000L 305#define SSL_OP_NON_EXPORT_FIRST 0x40000000L
295#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L 306#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L
296#define SSL_OP_ALL 0x000FFFFFL 307#define SSL_OP_ALL 0x000FFFFFL
@@ -355,9 +366,9 @@ struct ssl_ctx_st
355 STACK_OF(SSL_CIPHER) *cipher_list_by_id; 366 STACK_OF(SSL_CIPHER) *cipher_list_by_id;
356 367
357 struct x509_store_st /* X509_STORE */ *cert_store; 368 struct x509_store_st /* X509_STORE */ *cert_store;
358 struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSION's */ 369 struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */
359 /* Most session-ids that will be cached, default is 370 /* Most session-ids that will be cached, default is
360 * SSL_SESSION_CACHE_SIZE_DEFAULT. 0 is unlimited. */ 371 * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
361 unsigned long session_cache_size; 372 unsigned long session_cache_size;
362 struct ssl_session_st *session_cache_head; 373 struct ssl_session_st *session_cache_head;
363 struct ssl_session_st *session_cache_tail; 374 struct ssl_session_st *session_cache_tail;
@@ -424,6 +435,9 @@ struct ssl_ctx_st
424/**/ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; 435/**/ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
425/**/ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); 436/**/ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx);
426 437
438 int purpose; /* Purpose setting */
439 int trust; /* Trust setting */
440
427 /* Default password callback. */ 441 /* Default password callback. */
428/**/ pem_password_cb *default_passwd_callback; 442/**/ pem_password_cb *default_passwd_callback;
429 443
@@ -433,7 +447,7 @@ struct ssl_ctx_st
433 /* get client cert callback */ 447 /* get client cert callback */
434/**/ int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */); 448/**/ int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */);
435 449
436 /* what we put in client requests */ 450 /* what we put in client cert requests */
437 STACK_OF(X509_NAME) *client_CA; 451 STACK_OF(X509_NAME) *client_CA;
438 452
439/**/ int quiet_shutdown; 453/**/ int quiet_shutdown;
@@ -458,6 +472,7 @@ struct ssl_ctx_st
458 * defined, this will still get called. */ 472 * defined, this will still get called. */
459#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 473#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100
460 474
475 struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx);
461#define SSL_CTX_sess_number(ctx) \ 476#define SSL_CTX_sess_number(ctx) \
462 SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) 477 SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
463#define SSL_CTX_sess_connect(ctx) \ 478#define SSL_CTX_sess_connect(ctx) \
@@ -564,17 +579,21 @@ struct ssl_st
564 unsigned char *packet; 579 unsigned char *packet;
565 unsigned int packet_length; 580 unsigned int packet_length;
566 581
567 struct ssl2_ctx_st *s2; /* SSLv2 variables */ 582 struct ssl2_state_st *s2; /* SSLv2 variables */
568 struct ssl3_ctx_st *s3; /* SSLv3 variables */ 583 struct ssl3_state_st *s3; /* SSLv3 variables */
569 584
570 int read_ahead; /* Read as many input bytes as possible */ 585 int read_ahead; /* Read as many input bytes as possible
586 * (for non-blocking reads) */
571 int hit; /* reusing a previous session */ 587 int hit; /* reusing a previous session */
572 588
589 int purpose; /* Purpose setting */
590 int trust; /* Trust setting */
591
573 /* crypto */ 592 /* crypto */
574 STACK_OF(SSL_CIPHER) *cipher_list; 593 STACK_OF(SSL_CIPHER) *cipher_list;
575 STACK_OF(SSL_CIPHER) *cipher_list_by_id; 594 STACK_OF(SSL_CIPHER) *cipher_list_by_id;
576 595
577 /* These are the ones being used, the ones is SSL_SESSION are 596 /* These are the ones being used, the ones in SSL_SESSION are
578 * the ones to be 'copied' into these ones */ 597 * the ones to be 'copied' into these ones */
579 598
580 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ 599 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
@@ -634,7 +653,7 @@ struct ssl_st
634 unsigned long mode; /* API behaviour */ 653 unsigned long mode; /* API behaviour */
635 int first_packet; 654 int first_packet;
636 int client_version; /* what was passed, used for 655 int client_version; /* what was passed, used for
637 * SSLv3/TLS rolback check */ 656 * SSLv3/TLS rollback check */
638 }; 657 };
639 658
640#include <openssl/ssl2.h> 659#include <openssl/ssl2.h>
@@ -642,7 +661,7 @@ struct ssl_st
642#include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */ 661#include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */
643#include <openssl/ssl23.h> 662#include <openssl/ssl23.h>
644 663
645/* compatablity */ 664/* compatibility */
646#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) 665#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg))
647#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) 666#define SSL_get_app_data(s) (SSL_get_ex_data(s,0))
648#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) 667#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a))
@@ -651,7 +670,7 @@ struct ssl_st
651#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) 670#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg))
652 671
653/* The following are the possible values for ssl->state are are 672/* The following are the possible values for ssl->state are are
654 * used to indicate where we are upto in the SSL connection establishment. 673 * used to indicate where we are up to in the SSL connection establishment.
655 * The macros that follow are about the only things you should need to use 674 * The macros that follow are about the only things you should need to use
656 * and even then, only when using non-blocking IO. 675 * and even then, only when using non-blocking IO.
657 * It can also be useful to work out where you were when the connection 676 * It can also be useful to work out where you were when the connection
@@ -693,6 +712,13 @@ struct ssl_st
693#define SSL_ST_READ_BODY 0xF1 712#define SSL_ST_READ_BODY 0xF1
694#define SSL_ST_READ_DONE 0xF2 713#define SSL_ST_READ_DONE 0xF2
695 714
715/* Obtain latest Finished message
716 * -- that we sent (SSL_get_finished)
717 * -- that we expected from peer (SSL_get_peer_finished).
718 * Returns length (0 == no Finished so far), copies up to 'count' bytes. */
719size_t SSL_get_finished(SSL *s, void *buf, size_t count);
720size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
721
696/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options 722/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options
697 * are 'ored' with SSL_VERIFY_PEER if they are desired */ 723 * are 'ored' with SSL_VERIFY_PEER if they are desired */
698#define SSL_VERIFY_NONE 0x00 724#define SSL_VERIFY_NONE 0x00
@@ -700,9 +726,10 @@ struct ssl_st
700#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 726#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
701#define SSL_VERIFY_CLIENT_ONCE 0x04 727#define SSL_VERIFY_CLIENT_ONCE 0x04
702 728
729#define OpenSSL_add_ssl_algorithms() SSL_library_init()
703#define SSLeay_add_ssl_algorithms() SSL_library_init() 730#define SSLeay_add_ssl_algorithms() SSL_library_init()
704 731
705/* this is for backward compatablility */ 732/* this is for backward compatibility */
706#if 0 /* NEW_SSLEAY */ 733#if 0 /* NEW_SSLEAY */
707#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) 734#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)
708#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) 735#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n)
@@ -710,7 +737,7 @@ struct ssl_st
710#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) 737#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b))
711#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) 738#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b))
712#endif 739#endif
713/* More backward compatablity */ 740/* More backward compatibility */
714#define SSL_get_cipher(s) \ 741#define SSL_get_cipher(s) \
715 SSL_CIPHER_get_name(SSL_get_current_cipher(s)) 742 SSL_CIPHER_get_name(SSL_get_current_cipher(s))
716#define SSL_get_cipher_bits(s,np) \ 743#define SSL_get_cipher_bits(s,np) \
@@ -762,11 +789,11 @@ struct ssl_st
762#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ 789#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */
763#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ 790#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */
764#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR 791#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR
765#define SSL_AD_EXPORT_RESTRICION TLS1_AD_EXPORT_RESTRICION/* fatal */ 792#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */
766#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ 793#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */
767#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ 794#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */
768#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ 795#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */
769#define SSL_AD_USER_CANCLED TLS1_AD_USER_CANCLED 796#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED
770#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION 797#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION
771 798
772#define SSL_ERROR_NONE 0 799#define SSL_ERROR_NONE 0
@@ -867,7 +894,7 @@ void BIO_ssl_shutdown(BIO *ssl_bio);
867 894
868#endif 895#endif
869 896
870int SSL_CTX_set_cipher_list(SSL_CTX *,char *str); 897int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str);
871SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); 898SSL_CTX *SSL_CTX_new(SSL_METHOD *meth);
872void SSL_CTX_free(SSL_CTX *); 899void SSL_CTX_free(SSL_CTX *);
873long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); 900long SSL_CTX_set_timeout(SSL_CTX *ctx,long t);
@@ -899,7 +926,7 @@ void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio);
899BIO * SSL_get_rbio(SSL *s); 926BIO * SSL_get_rbio(SSL *s);
900BIO * SSL_get_wbio(SSL *s); 927BIO * SSL_get_wbio(SSL *s);
901#endif 928#endif
902int SSL_set_cipher_list(SSL *s, char *str); 929int SSL_set_cipher_list(SSL *s, const char *str);
903void SSL_set_read_ahead(SSL *s, int yes); 930void SSL_set_read_ahead(SSL *s, int yes);
904int SSL_get_verify_mode(SSL *s); 931int SSL_get_verify_mode(SSL *s);
905int SSL_get_verify_depth(SSL *s); 932int SSL_get_verify_depth(SSL *s);
@@ -998,6 +1025,12 @@ int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx,
998SSL * SSL_new(SSL_CTX *ctx); 1025SSL * SSL_new(SSL_CTX *ctx);
999int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, 1026int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
1000 unsigned int sid_ctx_len); 1027 unsigned int sid_ctx_len);
1028
1029int SSL_CTX_set_purpose(SSL_CTX *s, int purpose);
1030int SSL_set_purpose(SSL *s, int purpose);
1031int SSL_CTX_set_trust(SSL_CTX *s, int trust);
1032int SSL_set_trust(SSL *s, int trust);
1033
1001void SSL_free(SSL *ssl); 1034void SSL_free(SSL *ssl);
1002int SSL_accept(SSL *ssl); 1035int SSL_accept(SSL *ssl);
1003int SSL_connect(SSL *ssl); 1036int SSL_connect(SSL *ssl);
@@ -1005,10 +1038,12 @@ int SSL_read(SSL *ssl,char *buf,int num);
1005int SSL_peek(SSL *ssl,char *buf,int num); 1038int SSL_peek(SSL *ssl,char *buf,int num);
1006int SSL_write(SSL *ssl,const char *buf,int num); 1039int SSL_write(SSL *ssl,const char *buf,int num);
1007long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg); 1040long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg);
1041long SSL_callback_ctrl(SSL *, int, void (*)());
1008long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg); 1042long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg);
1043long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)());
1009 1044
1010int SSL_get_error(SSL *s,int ret_code); 1045int SSL_get_error(SSL *s,int ret_code);
1011char * SSL_get_version(SSL *s); 1046const char *SSL_get_version(SSL *s);
1012 1047
1013/* This sets the 'default' SSL version that SSL_new() will create */ 1048/* This sets the 'default' SSL version that SSL_new() will create */
1014int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); 1049int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth);
@@ -1074,7 +1109,9 @@ int SSL_version(SSL *ssl);
1074int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); 1109int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
1075int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, 1110int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
1076 const char *CApath); 1111 const char *CApath);
1112#define SSL_get0_session SSL_get_session /* just peek at pointer */
1077SSL_SESSION *SSL_get_session(SSL *ssl); 1113SSL_SESSION *SSL_get_session(SSL *ssl);
1114SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
1078SSL_CTX *SSL_get_SSL_CTX(SSL *ssl); 1115SSL_CTX *SSL_get_SSL_CTX(SSL *ssl);
1079void SSL_set_info_callback(SSL *ssl,void (*cb)()); 1116void SSL_set_info_callback(SSL *ssl,void (*cb)());
1080void (*SSL_get_info_callback(SSL *ssl))(); 1117void (*SSL_get_info_callback(SSL *ssl))();
@@ -1085,18 +1122,18 @@ long SSL_get_verify_result(SSL *ssl);
1085 1122
1086int SSL_set_ex_data(SSL *ssl,int idx,void *data); 1123int SSL_set_ex_data(SSL *ssl,int idx,void *data);
1087void *SSL_get_ex_data(SSL *ssl,int idx); 1124void *SSL_get_ex_data(SSL *ssl,int idx);
1088int SSL_get_ex_new_index(long argl, char *argp, int (*new_func)(), 1125int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
1089 int (*dup_func)(), void (*free_func)()); 1126 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
1090 1127
1091int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); 1128int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data);
1092void *SSL_SESSION_get_ex_data(SSL_SESSION *ss,int idx); 1129void *SSL_SESSION_get_ex_data(SSL_SESSION *ss,int idx);
1093int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func)(), 1130int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
1094 int (*dup_func)(), void (*free_func)()); 1131 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
1095 1132
1096int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); 1133int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data);
1097void *SSL_CTX_get_ex_data(SSL_CTX *ssl,int idx); 1134void *SSL_CTX_get_ex_data(SSL_CTX *ssl,int idx);
1098int SSL_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), 1135int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
1099 int (*dup_func)(), void (*free_func)()); 1136 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
1100 1137
1101int SSL_get_ex_data_X509_STORE_CTX_idx(void ); 1138int SSL_get_ex_data_X509_STORE_CTX_idx(void );
1102 1139
@@ -1219,13 +1256,18 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1219#define SSL_F_SSL_CERT_INSTANTIATE 214 1256#define SSL_F_SSL_CERT_INSTANTIATE 214
1220#define SSL_F_SSL_CERT_NEW 162 1257#define SSL_F_SSL_CERT_NEW 162
1221#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 1258#define SSL_F_SSL_CHECK_PRIVATE_KEY 163
1259#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230
1260#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231
1222#define SSL_F_SSL_CLEAR 164 1261#define SSL_F_SSL_CLEAR 164
1223#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 1262#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165
1224#define SSL_F_SSL_CREATE_CIPHER_LIST 166 1263#define SSL_F_SSL_CREATE_CIPHER_LIST 166
1264#define SSL_F_SSL_CTRL 232
1225#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 1265#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168
1226#define SSL_F_SSL_CTX_NEW 169 1266#define SSL_F_SSL_CTX_NEW 169
1267#define SSL_F_SSL_CTX_SET_PURPOSE 226
1227#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 1268#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219
1228#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 1269#define SSL_F_SSL_CTX_SET_SSL_VERSION 170
1270#define SSL_F_SSL_CTX_SET_TRUST 229
1229#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 1271#define SSL_F_SSL_CTX_USE_CERTIFICATE 171
1230#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 1272#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172
1231#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 1273#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220
@@ -1253,9 +1295,11 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1253#define SSL_F_SSL_SET_CERT 191 1295#define SSL_F_SSL_SET_CERT 191
1254#define SSL_F_SSL_SET_FD 192 1296#define SSL_F_SSL_SET_FD 192
1255#define SSL_F_SSL_SET_PKEY 193 1297#define SSL_F_SSL_SET_PKEY 193
1298#define SSL_F_SSL_SET_PURPOSE 227
1256#define SSL_F_SSL_SET_RFD 194 1299#define SSL_F_SSL_SET_RFD 194
1257#define SSL_F_SSL_SET_SESSION 195 1300#define SSL_F_SSL_SET_SESSION 195
1258#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 1301#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218
1302#define SSL_F_SSL_SET_TRUST 228
1259#define SSL_F_SSL_SET_WFD 196 1303#define SSL_F_SSL_SET_WFD 196
1260#define SSL_F_SSL_SHUTDOWN 224 1304#define SSL_F_SSL_SHUTDOWN 224
1261#define SSL_F_SSL_UNDEFINED_FUNCTION 197 1305#define SSL_F_SSL_UNDEFINED_FUNCTION 197
@@ -1282,7 +1326,6 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1282#define SSL_R_BAD_AUTHENTICATION_TYPE 102 1326#define SSL_R_BAD_AUTHENTICATION_TYPE 102
1283#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 1327#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103
1284#define SSL_R_BAD_CHECKSUM 104 1328#define SSL_R_BAD_CHECKSUM 104
1285#define SSL_R_BAD_CLIENT_REQUEST 105
1286#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 1329#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106
1287#define SSL_R_BAD_DECOMPRESSION 107 1330#define SSL_R_BAD_DECOMPRESSION 107
1288#define SSL_R_BAD_DH_G_LENGTH 108 1331#define SSL_R_BAD_DH_G_LENGTH 108
@@ -1290,6 +1333,7 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1290#define SSL_R_BAD_DH_P_LENGTH 110 1333#define SSL_R_BAD_DH_P_LENGTH 110
1291#define SSL_R_BAD_DIGEST_LENGTH 111 1334#define SSL_R_BAD_DIGEST_LENGTH 111
1292#define SSL_R_BAD_DSA_SIGNATURE 112 1335#define SSL_R_BAD_DSA_SIGNATURE 112
1336#define SSL_R_BAD_HELLO_REQUEST 105
1293#define SSL_R_BAD_LENGTH 271 1337#define SSL_R_BAD_LENGTH 271
1294#define SSL_R_BAD_MAC_DECODE 113 1338#define SSL_R_BAD_MAC_DECODE 113
1295#define SSL_R_BAD_MESSAGE_TYPE 114 1339#define SSL_R_BAD_MESSAGE_TYPE 114
@@ -1329,6 +1373,7 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1329#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 1373#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148
1330#define SSL_R_DIGEST_CHECK_FAILED 149 1374#define SSL_R_DIGEST_CHECK_FAILED 149
1331#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 1375#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150
1376#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 1092
1332#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 1377#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151
1333#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 1378#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152
1334#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 1379#define SSL_R_EXTRA_DATA_IN_MESSAGE 153
@@ -1337,6 +1382,9 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1337#define SSL_R_HTTP_REQUEST 156 1382#define SSL_R_HTTP_REQUEST 156
1338#define SSL_R_INTERNAL_ERROR 157 1383#define SSL_R_INTERNAL_ERROR 157
1339#define SSL_R_INVALID_CHALLENGE_LENGTH 158 1384#define SSL_R_INVALID_CHALLENGE_LENGTH 158
1385#define SSL_R_INVALID_COMMAND 280
1386#define SSL_R_INVALID_PURPOSE 278
1387#define SSL_R_INVALID_TRUST 279
1340#define SSL_R_LENGTH_MISMATCH 159 1388#define SSL_R_LENGTH_MISMATCH 159
1341#define SSL_R_LENGTH_TOO_SHORT 160 1389#define SSL_R_LENGTH_TOO_SHORT 160
1342#define SSL_R_LIBRARY_BUG 274 1390#define SSL_R_LIBRARY_BUG 274
@@ -1429,14 +1477,14 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1429#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 1477#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
1430#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 1478#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021
1431#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 1479#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051
1432#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICION 1060 1480#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
1433#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 1481#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
1434#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 1482#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
1435#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 1483#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
1436#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 1484#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
1437#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 1485#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022
1438#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 1486#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048
1439#define SSL_R_TLSV1_ALERT_USER_CANCLED 1090 1487#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
1440#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 1488#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232
1441#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 1489#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233
1442#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 1490#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234
@@ -1464,6 +1512,7 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1464#define SSL_R_UNKNOWN_STATE 255 1512#define SSL_R_UNKNOWN_STATE 255
1465#define SSL_R_UNSUPPORTED_CIPHER 256 1513#define SSL_R_UNSUPPORTED_CIPHER 256
1466#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 1514#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257
1515#define SSL_R_UNSUPPORTED_OPTION 1091
1467#define SSL_R_UNSUPPORTED_PROTOCOL 258 1516#define SSL_R_UNSUPPORTED_PROTOCOL 258
1468#define SSL_R_UNSUPPORTED_SSL_VERSION 259 1517#define SSL_R_UNSUPPORTED_SSL_VERSION 259
1469#define SSL_R_WRITE_BIO_NOT_SET 260 1518#define SSL_R_WRITE_BIO_NOT_SET 260
diff --git a/src/lib/libssl/src/ssl/ssl2.h b/src/lib/libssl/src/ssl/ssl2.h
index d7f24ac1b4..01d41c88c5 100644
--- a/src/lib/libssl/src/ssl/ssl2.h
+++ b/src/lib/libssl/src/ssl/ssl2.h
@@ -151,7 +151,7 @@ extern "C" {
151#define CERT char 151#define CERT char
152#endif 152#endif
153 153
154typedef struct ssl2_ctx_st 154typedef struct ssl2_state_st
155 { 155 {
156 int three_byte_header; 156 int three_byte_header;
157 int clear_text; /* clear text */ 157 int clear_text; /* clear text */
@@ -214,7 +214,7 @@ typedef struct ssl2_ctx_st
214 unsigned int clen; 214 unsigned int clen;
215 unsigned int rlen; 215 unsigned int rlen;
216 } tmp; 216 } tmp;
217 } SSL2_CTX; 217 } SSL2_STATE;
218 218
219/* SSLv2 */ 219/* SSLv2 */
220/* client */ 220/* client */
diff --git a/src/lib/libssl/src/ssl/ssl3.h b/src/lib/libssl/src/ssl/ssl3.h
index 2a9714fc19..f616763830 100644
--- a/src/lib/libssl/src/ssl/ssl3.h
+++ b/src/lib/libssl/src/ssl/ssl3.h
@@ -158,24 +158,8 @@ extern "C" {
158#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) 158#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)
159#define SSL3_RT_MAX_DATA_SIZE (1024*1024) 159#define SSL3_RT_MAX_DATA_SIZE (1024*1024)
160 160
161/* the states that a SSL3_RECORD can be in 161#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54"
162 * For SSL_read it goes 162#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52"
163 * rbuf->ENCODED -> read
164 * ENCODED -> we need to decode everything - call decode_record
165 */
166
167#define SSL3_RS_BLANK 1
168#define SSL3_RS_DATA
169
170#define SSL3_RS_ENCODED 2
171#define SSL3_RS_READ_MORE 3
172#define SSL3_RS_WRITE_MORE
173#define SSL3_RS_PLAIN 3
174#define SSL3_RS_PART_READ 4
175#define SSL3_RS_PART_WRITE 5
176
177#define SSL3_MD_CLIENT_FINISHED_CONST {0x43,0x4C,0x4E,0x54}
178#define SSL3_MD_SERVER_FINISHED_CONST {0x53,0x52,0x56,0x52}
179 163
180#define SSL3_VERSION 0x0300 164#define SSL3_VERSION 0x0300
181#define SSL3_VERSION_MAJOR 0x03 165#define SSL3_VERSION_MAJOR 0x03
@@ -204,22 +188,20 @@ extern "C" {
204 188
205typedef struct ssl3_record_st 189typedef struct ssl3_record_st
206 { 190 {
207/*r */ int type; /* type of record */ 191/*r */ int type; /* type of record */
208/* */ /*int state;*/ /* any data in it? */ 192/*rw*/ unsigned int length; /* How many bytes available */
209/*rw*/ unsigned int length; /* How many bytes available */ 193/*r */ unsigned int off; /* read/write offset into 'buf' */
210/*r */ unsigned int off; /* read/write offset into 'buf' */ 194/*rw*/ unsigned char *data; /* pointer to the record data */
211/*rw*/ unsigned char *data; /* pointer to the record data */ 195/*rw*/ unsigned char *input; /* where the decode bytes are */
212/*rw*/ unsigned char *input; /* where the decode bytes are */ 196/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
213/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
214 } SSL3_RECORD; 197 } SSL3_RECORD;
215 198
216typedef struct ssl3_buffer_st 199typedef struct ssl3_buffer_st
217 { 200 {
218/*r */ int total; /* used in non-blocking writes */ 201 unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes (more if
219/*r */ int wanted; /* how many more bytes we need */ 202 * SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER is set) */
220/*rw*/ int left; /* how many bytes left */ 203 int offset; /* where to 'copy from' */
221/*rw*/ int offset; /* where to 'copy from' */ 204 int left; /* how many bytes left */
222/*rw*/ unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes */
223 } SSL3_BUFFER; 205 } SSL3_BUFFER;
224 206
225#define SSL3_CT_RSA_SIGN 1 207#define SSL3_CT_RSA_SIGN 1
@@ -236,34 +218,7 @@ typedef struct ssl3_buffer_st
236#define SSL3_FLAGS_POP_BUFFER 0x0004 218#define SSL3_FLAGS_POP_BUFFER 0x0004
237#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 219#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008
238 220
239#if 0 221typedef struct ssl3_state_st
240#define AD_CLOSE_NOTIFY 0
241#define AD_UNEXPECTED_MESSAGE 1
242#define AD_BAD_RECORD_MAC 2
243#define AD_DECRYPTION_FAILED 3
244#define AD_RECORD_OVERFLOW 4
245#define AD_DECOMPRESSION_FAILURE 5 /* fatal */
246#define AD_HANDSHAKE_FAILURE 6 /* fatal */
247#define AD_NO_CERTIFICATE 7 /* Not under TLS */
248#define AD_BAD_CERTIFICATE 8
249#define AD_UNSUPPORTED_CERTIFICATE 9
250#define AD_CERTIFICATE_REVOKED 10
251#define AD_CERTIFICATE_EXPIRED 11
252#define AD_CERTIFICATE_UNKNOWN 12
253#define AD_ILLEGAL_PARAMETER 13 /* fatal */
254#define AD_UNKNOWN_CA 14 /* fatal */
255#define AD_ACCESS_DENIED 15 /* fatal */
256#define AD_DECODE_ERROR 16 /* fatal */
257#define AD_DECRYPT_ERROR 17
258#define AD_EXPORT_RESTRICION 18 /* fatal */
259#define AD_PROTOCOL_VERSION 19 /* fatal */
260#define AD_INSUFFICIENT_SECURITY 20 /* fatal */
261#define AD_INTERNAL_ERROR 21 /* fatal */
262#define AD_USER_CANCLED 22
263#define AD_NO_RENEGOTIATION 23
264#endif
265
266typedef struct ssl3_ctx_st
267 { 222 {
268 long flags; 223 long flags;
269 int delay_buf_pop_ret; 224 int delay_buf_pop_ret;
@@ -278,10 +233,16 @@ typedef struct ssl3_ctx_st
278 233
279 SSL3_BUFFER rbuf; /* read IO goes into here */ 234 SSL3_BUFFER rbuf; /* read IO goes into here */
280 SSL3_BUFFER wbuf; /* write IO goes into here */ 235 SSL3_BUFFER wbuf; /* write IO goes into here */
236
281 SSL3_RECORD rrec; /* each decoded record goes in here */ 237 SSL3_RECORD rrec; /* each decoded record goes in here */
282 SSL3_RECORD wrec; /* goes out from here */ 238 SSL3_RECORD wrec; /* goes out from here */
283 /* Used by ssl3_read_n to point 239
284 * to input data packet */ 240 /* storage for Alert/Handshake protocol data received but not
241 * yet processed by ssl3_read_bytes: */
242 unsigned char alert_fragment[2];
243 unsigned int alert_fragment_len;
244 unsigned char handshake_fragment[4];
245 unsigned int handshake_fragment_len;
285 246
286 /* partial write - check the numbers match */ 247 /* partial write - check the numbers match */
287 unsigned int wnum; /* number of bytes sent so far */ 248 unsigned int wnum; /* number of bytes sent so far */
@@ -300,7 +261,7 @@ typedef struct ssl3_ctx_st
300 261
301 int warn_alert; 262 int warn_alert;
302 int fatal_alert; 263 int fatal_alert;
303 /* we alow one fatal and one warning alert to be outstanding, 264 /* we allow one fatal and one warning alert to be outstanding,
304 * send close alert via the warning alert */ 265 * send close alert via the warning alert */
305 int alert_dispatch; 266 int alert_dispatch;
306 unsigned char send_alert[2]; 267 unsigned char send_alert[2];
@@ -314,8 +275,14 @@ typedef struct ssl3_ctx_st
314 int in_read_app_data; 275 int in_read_app_data;
315 276
316 struct { 277 struct {
317 /* Actually only needs to be 16+20 for SSLv3 and 12 for TLS */ 278 /* actually only needs to be 16+20 */
279 unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2];
280
281 /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
318 unsigned char finish_md[EVP_MAX_MD_SIZE*2]; 282 unsigned char finish_md[EVP_MAX_MD_SIZE*2];
283 int finish_md_len;
284 unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2];
285 int peer_finish_md_len;
319 286
320 unsigned long message_size; 287 unsigned long message_size;
321 int message_type; 288 int message_type;
@@ -351,7 +318,7 @@ typedef struct ssl3_ctx_st
351 int cert_request; 318 int cert_request;
352 } tmp; 319 } tmp;
353 320
354 } SSL3_CTX; 321 } SSL3_STATE;
355 322
356/* SSLv3 */ 323/* SSLv3 */
357/*client */ 324/*client */
@@ -429,7 +396,7 @@ typedef struct ssl3_ctx_st
429#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) 396#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT)
430#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) 397#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT)
431 398
432#define SSL3_MT_CLIENT_REQUEST 0 399#define SSL3_MT_HELLO_REQUEST 0
433#define SSL3_MT_CLIENT_HELLO 1 400#define SSL3_MT_CLIENT_HELLO 1
434#define SSL3_MT_SERVER_HELLO 2 401#define SSL3_MT_SERVER_HELLO 2
435#define SSL3_MT_CERTIFICATE 11 402#define SSL3_MT_CERTIFICATE 11
diff --git a/src/lib/libssl/src/ssl/ssl_asn1.c b/src/lib/libssl/src/ssl/ssl_asn1.c
index 0f6a0884e4..e77cdddfd3 100644
--- a/src/lib/libssl/src/ssl/ssl_asn1.c
+++ b/src/lib/libssl/src/ssl/ssl_asn1.c
@@ -60,6 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h>
63#include "ssl_locl.h" 64#include "ssl_locl.h"
64 65
65typedef struct ssl_session_asn1_st 66typedef struct ssl_session_asn1_st
@@ -73,14 +74,15 @@ typedef struct ssl_session_asn1_st
73 ASN1_OCTET_STRING key_arg; 74 ASN1_OCTET_STRING key_arg;
74 ASN1_INTEGER time; 75 ASN1_INTEGER time;
75 ASN1_INTEGER timeout; 76 ASN1_INTEGER timeout;
77 ASN1_INTEGER verify_result;
76 } SSL_SESSION_ASN1; 78 } SSL_SESSION_ASN1;
77 79
78int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) 80int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
79 { 81 {
80#define LSIZE2 (sizeof(long)*2) 82#define LSIZE2 (sizeof(long)*2)
81 int v1=0,v2=0,v3=0,v4=0; 83 int v1=0,v2=0,v3=0,v4=0,v5=0;
82 unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; 84 unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2];
83 unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2]; 85 unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2];
84 long l; 86 long l;
85 SSL_SESSION_ASN1 a; 87 SSL_SESSION_ASN1 a;
86 M_ASN1_I2D_vars(in); 88 M_ASN1_I2D_vars(in);
@@ -89,7 +91,7 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
89 return(0); 91 return(0);
90 92
91 /* Note that I cheat in the following 2 assignments. I know 93 /* Note that I cheat in the following 2 assignments. I know
92 * that if the ASN1_INTERGER passed to ASN1_INTEGER_set 94 * that if the ASN1_INTEGER passed to ASN1_INTEGER_set
93 * is > sizeof(long)+1, the buffer will not be re-Malloc()ed. 95 * is > sizeof(long)+1, the buffer will not be re-Malloc()ed.
94 * This is a bit evil but makes things simple, no dynamic allocation 96 * This is a bit evil but makes things simple, no dynamic allocation
95 * to clean up :-) */ 97 * to clean up :-) */
@@ -156,6 +158,14 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
156 ASN1_INTEGER_set(&(a.timeout),in->timeout); 158 ASN1_INTEGER_set(&(a.timeout),in->timeout);
157 } 159 }
158 160
161 if (in->verify_result != X509_V_OK)
162 {
163 a.verify_result.length=LSIZE2;
164 a.verify_result.type=V_ASN1_INTEGER;
165 a.verify_result.data=ibuf5;
166 ASN1_INTEGER_set(&a.verify_result,in->verify_result);
167 }
168
159 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); 169 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER);
160 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); 170 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER);
161 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); 171 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING);
@@ -170,6 +180,8 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
170 if (in->peer != NULL) 180 if (in->peer != NULL)
171 M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3); 181 M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3);
172 M_ASN1_I2D_len_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,v4); 182 M_ASN1_I2D_len_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,v4);
183 if (in->verify_result != X509_V_OK)
184 M_ASN1_I2D_len_EXP_opt(&(a.verify_result),i2d_ASN1_INTEGER,5,v5);
173 185
174 M_ASN1_I2D_seq_total(); 186 M_ASN1_I2D_seq_total();
175 187
@@ -188,7 +200,8 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
188 M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); 200 M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3);
189 M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4, 201 M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,
190 v4); 202 v4);
191 203 if (in->verify_result != X509_V_OK)
204 M_ASN1_I2D_put_EXP_opt(&a.verify_result,i2d_ASN1_INTEGER,5,v5);
192 M_ASN1_I2D_finish(); 205 M_ASN1_I2D_finish();
193 } 206 }
194 207
@@ -322,6 +335,15 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp,
322 else 335 else
323 ret->sid_ctx_length=0; 336 ret->sid_ctx_length=0;
324 337
338 ai.length=0;
339 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,5);
340 if (ai.data != NULL)
341 {
342 ret->verify_result=ASN1_INTEGER_get(aip);
343 Free(ai.data); ai.data=NULL; ai.length=0;
344 }
345 else
346 ret->verify_result=X509_V_OK;
347
325 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); 348 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION);
326 } 349 }
327
diff --git a/src/lib/libssl/src/ssl/ssl_cert.c b/src/lib/libssl/src/ssl/ssl_cert.c
index 6d2511f76c..48f247ceac 100644
--- a/src/lib/libssl/src/ssl/ssl_cert.c
+++ b/src/lib/libssl/src/ssl/ssl_cert.c
@@ -105,17 +105,26 @@
105 */ 105 */
106 106
107#include <stdio.h> 107#include <stdio.h>
108#include <sys/types.h> 108
109#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) 109#include "openssl/e_os.h"
110
111#ifndef NO_SYS_TYPES_H
112# include <sys/types.h>
113#endif
114
115#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) && !defined(MAC_OS_pre_X)
110#include <dirent.h> 116#include <dirent.h>
111#endif 117#endif
118
112#ifdef NeXT 119#ifdef NeXT
113#include <sys/dir.h> 120#include <sys/dir.h>
114#define dirent direct 121#define dirent direct
115#endif 122#endif
123
116#include <openssl/objects.h> 124#include <openssl/objects.h>
117#include <openssl/bio.h> 125#include <openssl/bio.h>
118#include <openssl/pem.h> 126#include <openssl/pem.h>
127#include <openssl/x509v3.h>
119#include "ssl_locl.h" 128#include "ssl_locl.h"
120 129
121int SSL_get_ex_data_X509_STORE_CTX_idx(void) 130int SSL_get_ex_data_X509_STORE_CTX_idx(void)
@@ -422,8 +431,16 @@ int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk)
422 X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk); 431 X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk);
423 if (SSL_get_verify_depth(s) >= 0) 432 if (SSL_get_verify_depth(s) >= 0)
424 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s)); 433 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s));
425 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(), 434 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s);
426 (char *)s); 435 /* We need to set the verify purpose. The purpose can be determined by
436 * the context: if its a server it will verify SSL client certificates
437 * or vice versa.
438 */
439
440 if(s->server) i = X509_PURPOSE_SSL_CLIENT;
441 else i = X509_PURPOSE_SSL_SERVER;
442
443 X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust);
427 444
428 if (s->ctx->app_verify_callback != NULL) 445 if (s->ctx->app_verify_callback != NULL)
429 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */ 446 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */
@@ -534,7 +551,7 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x)
534 return(add_client_CA(&(ctx->client_CA),x)); 551 return(add_client_CA(&(ctx->client_CA),x));
535 } 552 }
536 553
537static int name_cmp(X509_NAME **a,X509_NAME **b) 554static int xname_cmp(X509_NAME **a,X509_NAME **b)
538 { 555 {
539 return(X509_NAME_cmp(*a,*b)); 556 return(X509_NAME_cmp(*a,*b));
540 } 557 }
@@ -556,7 +573,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
556 STACK_OF(X509_NAME) *ret,*sk; 573 STACK_OF(X509_NAME) *ret,*sk;
557 574
558 ret=sk_X509_NAME_new(NULL); 575 ret=sk_X509_NAME_new(NULL);
559 sk=sk_X509_NAME_new(name_cmp); 576 sk=sk_X509_NAME_new(xname_cmp);
560 577
561 in=BIO_new(BIO_s_file_internal()); 578 in=BIO_new(BIO_s_file_internal());
562 579
@@ -617,7 +634,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
617 int ret=1; 634 int ret=1;
618 int (*oldcmp)(X509_NAME **a, X509_NAME **b); 635 int (*oldcmp)(X509_NAME **a, X509_NAME **b);
619 636
620 oldcmp=sk_X509_NAME_set_cmp_func(stack,name_cmp); 637 oldcmp=sk_X509_NAME_set_cmp_func(stack,xname_cmp);
621 638
622 in=BIO_new(BIO_s_file_internal()); 639 in=BIO_new(BIO_s_file_internal());
623 640
@@ -671,6 +688,7 @@ err:
671 688
672#ifndef WIN32 689#ifndef WIN32
673#ifndef VMS /* XXXX This may be fixed in the future */ 690#ifndef VMS /* XXXX This may be fixed in the future */
691#ifndef MAC_OS_pre_X
674 692
675int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, 693int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
676 const char *dir) 694 const char *dir)
@@ -714,3 +732,4 @@ err:
714 732
715#endif 733#endif
716#endif 734#endif
735#endif
diff --git a/src/lib/libssl/src/ssl/ssl_ciph.c b/src/lib/libssl/src/ssl/ssl_ciph.c
index 4c2989c47a..1cbc2886e9 100644
--- a/src/lib/libssl/src/ssl/ssl_ciph.c
+++ b/src/lib/libssl/src/ssl/ssl_ciph.c
@@ -83,24 +83,11 @@ static const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX]={
83 NULL,NULL, 83 NULL,NULL,
84 }; 84 };
85 85
86typedef struct cipher_sort_st
87 {
88 SSL_CIPHER *cipher;
89 int pref;
90 } CIPHER_SORT;
91
92#define CIPHER_ADD 1 86#define CIPHER_ADD 1
93#define CIPHER_KILL 2 87#define CIPHER_KILL 2
94#define CIPHER_DEL 3 88#define CIPHER_DEL 3
95#define CIPHER_ORD 4 89#define CIPHER_ORD 4
96 90#define CIPHER_SPECIAL 5
97typedef struct cipher_choice_st
98 {
99 int type;
100 unsigned long algorithms;
101 unsigned long mask;
102 long top;
103 } CIPHER_CHOICE;
104 91
105typedef struct cipher_order_st 92typedef struct cipher_order_st
106 { 93 {
@@ -110,59 +97,55 @@ typedef struct cipher_order_st
110 struct cipher_order_st *next,*prev; 97 struct cipher_order_st *next,*prev;
111 } CIPHER_ORDER; 98 } CIPHER_ORDER;
112 99
113static SSL_CIPHER cipher_aliases[]={ 100static const SSL_CIPHER cipher_aliases[]={
114 /* Don't include eNULL unless specifically enabled */ 101 /* Don't include eNULL unless specifically enabled */
115 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL, 0,SSL_ALL}, /* must be first */ 102 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */
116 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,SSL_MKEY_MASK}, 103 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,0,0,0,SSL_MKEY_MASK,0},
117 {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,SSL_MKEY_MASK}, 104 {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,0,0,0,SSL_MKEY_MASK,0},
118 {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,SSL_MKEY_MASK}, 105 {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,0,0,0,SSL_MKEY_MASK,0},
119 {0,SSL_TXT_kEDH,0,SSL_kEDH, 0,SSL_MKEY_MASK}, 106 {0,SSL_TXT_kEDH,0,SSL_kEDH, 0,0,0,0,SSL_MKEY_MASK,0},
120 {0,SSL_TXT_kFZA,0,SSL_kFZA, 0,SSL_MKEY_MASK}, 107 {0,SSL_TXT_kFZA,0,SSL_kFZA, 0,0,0,0,SSL_MKEY_MASK,0},
121 {0,SSL_TXT_DH, 0,SSL_DH, 0,SSL_MKEY_MASK}, 108 {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RONG_MASK}, 143 {0,SSL_TXT_LOW, 0, 0, SSL_LOW, 0,0,0,0,SSL_STRONG_MASK},
144 {0,SSL_TXT_MEDIUM,0, 0,SSL_MEDIUM, 0,0,0,0,SSL_STRONG_MASK},
145 {0,SSL_TXT_HIGH, 0, 0, SSL_HIGH, 0,0,0,0,SSL_STRONG_MASK},
157 }; 146 };
158 147
159static int init_ciphers=1; 148static int init_ciphers=1;
160static void load_ciphers();
161
162static int cmp_by_name(SSL_CIPHER **a, SSL_CIPHER **b)
163 {
164 return(strcmp((*a)->name,(*b)->name));
165 }
166 149
167static void load_ciphers(void) 150static void load_ciphers(void)
168 { 151 {
@@ -294,170 +277,320 @@ static void ll_append_tail(CIPHER_ORDER **head, CIPHER_ORDER *curr,
294 *tail=curr; 277 *tail=curr;
295 } 278 }
296 279
297STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method, 280static unsigned long ssl_cipher_get_disabled(void)
298 STACK_OF(SSL_CIPHER) **cipher_list,
299 STACK_OF(SSL_CIPHER) **cipher_list_by_id,
300 char *str)
301 { 281 {
302 SSL_CIPHER *c; 282 unsigned long mask;
303 char *l;
304 STACK_OF(SSL_CIPHER) *ret=NULL,*ok=NULL;
305#define CL_BUF 40
306 char buf[CL_BUF];
307 char *tmp_str=NULL;
308 unsigned long mask,algorithms,ma;
309 char *start;
310 int i,j,k,num=0,ch,multi;
311 unsigned long al;
312 STACK *ca_list=NULL;
313 int current_x,num_x;
314 CIPHER_CHOICE *ops=NULL;
315 CIPHER_ORDER *list=NULL,*head=NULL,*tail=NULL,*curr,*tail2,*curr2;
316 int list_num;
317 int type;
318 SSL_CIPHER c_tmp,*cp;
319
320 if (str == NULL) return(NULL);
321
322 if (strncmp(str,"DEFAULT",7) == 0)
323 {
324 i=strlen(str)+2+strlen(SSL_DEFAULT_CIPHER_LIST);
325 if ((tmp_str=Malloc(i)) == NULL)
326 {
327 SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
328 goto err;
329 }
330 strcpy(tmp_str,SSL_DEFAULT_CIPHER_LIST);
331 strcat(tmp_str,":");
332 strcat(tmp_str,&(str[7]));
333 str=tmp_str;
334 }
335 if (init_ciphers) load_ciphers();
336
337 num=ssl_method->num_ciphers();
338
339 if ((ret=sk_SSL_CIPHER_new(NULL)) == NULL) goto err;
340 if ((ca_list=(STACK *)sk_new(cmp_by_name)) == NULL) goto err;
341 283
342 mask =SSL_kFZA; 284 mask = SSL_kFZA;
343#ifdef NO_RSA 285#ifdef NO_RSA
344 mask|=SSL_aRSA|SSL_kRSA; 286 mask |= SSL_aRSA|SSL_kRSA;
345#endif 287#endif
346#ifdef NO_DSA 288#ifdef NO_DSA
347 mask|=SSL_aDSS; 289 mask |= SSL_aDSS;
348#endif 290#endif
349#ifdef NO_DH 291#ifdef NO_DH
350 mask|=SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH; 292 mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH;
351#endif 293#endif
352 294
353#ifdef SSL_FORBID_ENULL 295#ifdef SSL_FORBID_ENULL
354 mask|=SSL_eNULL; 296 mask |= SSL_eNULL;
355#endif 297#endif
356 298
357 mask|=(ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL)?SSL_DES :0; 299 mask |= (ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL) ? SSL_DES :0;
358 mask|=(ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL)?SSL_3DES:0; 300 mask |= (ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL) ? SSL_3DES:0;
359 mask|=(ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL)?SSL_RC4 :0; 301 mask |= (ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL) ? SSL_RC4 :0;
360 mask|=(ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL)?SSL_RC2 :0; 302 mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0;
361 mask|=(ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL)?SSL_IDEA:0; 303 mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0;
362 mask|=(ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL)?SSL_eFZA:0; 304 mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0;
305
306 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;
363 308
364 mask|=(ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL)?SSL_MD5 :0; 309 return(mask);
365 mask|=(ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL)?SSL_SHA1:0; 310 }
311
312static void ssl_cipher_collect_ciphers(const SSL_METHOD *ssl_method,
313 int num_of_ciphers, unsigned long mask, CIPHER_ORDER *list,
314 CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p)
315 {
316 int i, list_num;
317 SSL_CIPHER *c;
366 318
367 if ((list=(CIPHER_ORDER *)Malloc(sizeof(CIPHER_ORDER)*num)) == NULL) 319 /*
368 goto err; 320 * We have num_of_ciphers descriptions compiled in, depending on the
321 * method selected (SSLv2 and/or SSLv3, TLSv1 etc).
322 * These will later be sorted in a linked list with at most num
323 * entries.
324 */
369 325
370 /* Get the initial list of ciphers */ 326 /* Get the initial list of ciphers */
371 list_num=0; 327 list_num = 0; /* actual count of ciphers */
372 for (i=0; i<num; i++) 328 for (i = 0; i < num_of_ciphers; i++)
373 { 329 {
374 c=ssl_method->get_cipher((unsigned int)i); 330 c = ssl_method->get_cipher(i);
375 /* drop those that use any of that is not available */ 331 /* drop those that use any of that is not available */
376 if ((c != NULL) && c->valid && !(c->algorithms & mask)) 332 if ((c != NULL) && c->valid && !(c->algorithms & mask))
377 { 333 {
378 list[list_num].cipher=c; 334 list[list_num].cipher = c;
379 list[list_num].next=NULL; 335 list[list_num].next = NULL;
380 list[list_num].prev=NULL; 336 list[list_num].prev = NULL;
381 list[list_num].active=0; 337 list[list_num].active = 0;
382 list_num++; 338 list_num++;
339 /*
383 if (!sk_push(ca_list,(char *)c)) goto err; 340 if (!sk_push(ca_list,(char *)c)) goto err;
341 */
384 } 342 }
385 } 343 }
386 344
387 for (i=1; i<list_num-1; i++) 345 /*
346 * Prepare linked list from list entries
347 */
348 for (i = 1; i < list_num - 1; i++)
388 { 349 {
389 list[i].prev= &(list[i-1]); 350 list[i].prev = &(list[i-1]);
390 list[i].next= &(list[i+1]); 351 list[i].next = &(list[i+1]);
391 } 352 }
392 if (list_num > 0) 353 if (list_num > 0)
393 { 354 {
394 head= &(list[0]); 355 (*head_p) = &(list[0]);
395 head->prev=NULL; 356 (*head_p)->prev = NULL;
396 head->next= &(list[1]); 357 (*head_p)->next = &(list[1]);
397 tail= &(list[list_num-1]); 358 (*tail_p) = &(list[list_num - 1]);
398 tail->prev= &(list[list_num-2]); 359 (*tail_p)->prev = &(list[list_num - 2]);
399 tail->next=NULL; 360 (*tail_p)->next = NULL;
400 } 361 }
362 }
401 363
402 /* special case */ 364static void ssl_cipher_collect_aliases(SSL_CIPHER **ca_list,
403 cipher_aliases[0].algorithms &= ~mask; 365 int num_of_group_aliases, unsigned long mask,
366 CIPHER_ORDER *head)
367 {
368 CIPHER_ORDER *ciph_curr;
369 SSL_CIPHER **ca_curr;
370 int i;
404 371
405 /* get the aliases */ 372 /*
406 k=sizeof(cipher_aliases)/sizeof(SSL_CIPHER); 373 * First, add the real ciphers as already collected
407 for (j=0; j<k; j++) 374 */
375 ciph_curr = head;
376 ca_curr = ca_list;
377 while (ciph_curr != NULL)
408 { 378 {
409 al=cipher_aliases[j].algorithms; 379 *ca_curr = ciph_curr->cipher;
410 /* Drop those that are not relevent */ 380 ca_curr++;
411 if ((al & mask) == al) continue; 381 ciph_curr = ciph_curr->next;
412 if (!sk_push(ca_list,(char *)&(cipher_aliases[j]))) goto err;
413 } 382 }
414 383
415 /* ca_list now holds a 'stack' of SSL_CIPHERS, some real, some 384 /*
416 * 'aliases' */ 385 * Now we add the available ones from the cipher_aliases[] table.
386 * They represent either an algorithm, that must be fully
387 * supported (not match any bit in mask) or represent a cipher
388 * strength value (will be added in any case because algorithms=0).
389 */
390 for (i = 0; i < num_of_group_aliases; i++)
391 {
392 if ((i == 0) || /* always fetch "ALL" */
393 !(cipher_aliases[i].algorithms & mask))
394 {
395 *ca_curr = (SSL_CIPHER *)(cipher_aliases + i);
396 ca_curr++;
397 }
398 }
417 399
418 /* how many parameters are there? */ 400 *ca_curr = NULL; /* end of list */
419 num=1; 401 }
420 for (l=str; *l; l++)
421 if (ITEM_SEP(*l))
422 num++;
423 ops=(CIPHER_CHOICE *)Malloc(sizeof(CIPHER_CHOICE)*num);
424 if (ops == NULL) goto err;
425 memset(ops,0,sizeof(CIPHER_CHOICE)*num);
426 402
427 /* we now parse the input string and create our operations */ 403static void ssl_cipher_apply_rule(unsigned long algorithms, unsigned long mask,
428 l=str; 404 unsigned long algo_strength, unsigned long mask_strength,
429 i=0; 405 int rule, int strength_bits, CIPHER_ORDER *list,
430 current_x=0; 406 CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p)
407 {
408 CIPHER_ORDER *head, *tail, *curr, *curr2, *tail2;
409 SSL_CIPHER *cp;
410 unsigned long ma, ma_s;
431 411
412#ifdef CIPHER_DEBUG
413 printf("Applying rule %d with %08lx %08lx %08lx %08lx (%d)\n",
414 rule, algorithms, mask, algo_strength, mask_strength,
415 strength_bits);
416#endif
417
418 curr = head = *head_p;
419 curr2 = head;
420 tail2 = tail = *tail_p;
432 for (;;) 421 for (;;)
433 { 422 {
434 ch= *l; 423 if ((curr == NULL) || (curr == tail2)) break;
424 curr = curr2;
425 curr2 = curr->next;
426
427 cp = curr->cipher;
428
429 /*
430 * Selection criteria is either the number of strength_bits
431 * or the algorithm used.
432 */
433 if (strength_bits == -1)
434 {
435 ma = mask & cp->algorithms;
436 ma_s = mask_strength & cp->algo_strength;
437
438#ifdef CIPHER_DEBUG
439 printf("\nName: %s:\nAlgo = %08lx Algo_strength = %08lx\nMask = %08lx Mask_strength %08lx\n", cp->name, cp->algorithms, cp->algo_strength, mask, mask_strength);
440 printf("ma = %08lx ma_s %08lx, ma&algo=%08lx, ma_s&algos=%08lx\n", ma, ma_s, ma&algorithms, ma_s&algo_strength);
441#endif
442 /*
443 * Select: if none of the mask bit was met from the
444 * cipher or not all of the bits were met, the
445 * selection does not apply.
446 */
447 if (((ma == 0) && (ma_s == 0)) ||
448 ((ma & algorithms) != ma) ||
449 ((ma_s & algo_strength) != ma_s))
450 continue; /* does not apply */
451 }
452 else if (strength_bits != cp->strength_bits)
453 continue; /* does not apply */
454
455#ifdef CIPHER_DEBUG
456 printf("Action = %d\n", rule);
457#endif
458
459 /* add the cipher if it has not been added yet. */
460 if (rule == CIPHER_ADD)
461 {
462 if (!curr->active)
463 {
464 ll_append_tail(&head, curr, &tail);
465 curr->active = 1;
466 }
467 }
468 /* Move the added cipher to this location */
469 else if (rule == CIPHER_ORD)
470 {
471 if (curr->active)
472 {
473 ll_append_tail(&head, curr, &tail);
474 }
475 }
476 else if (rule == CIPHER_DEL)
477 curr->active = 0;
478 else if (rule == CIPHER_KILL)
479 {
480 if (head == curr)
481 head = curr->next;
482 else
483 curr->prev->next = curr->next;
484 if (tail == curr)
485 tail = curr->prev;
486 curr->active = 0;
487 if (curr->next != NULL)
488 curr->next->prev = curr->prev;
489 if (curr->prev != NULL)
490 curr->prev->next = curr->next;
491 curr->next = NULL;
492 curr->prev = NULL;
493 }
494 }
495
496 *head_p = head;
497 *tail_p = tail;
498 }
499
500static int ssl_cipher_strength_sort(CIPHER_ORDER *list, CIPHER_ORDER **head_p,
501 CIPHER_ORDER **tail_p)
502 {
503 int max_strength_bits, i, *number_uses;
504 CIPHER_ORDER *curr;
505
506 /*
507 * This routine sorts the ciphers with descending strength. The sorting
508 * must keep the pre-sorted sequence, so we apply the normal sorting
509 * routine as '+' movement to the end of the list.
510 */
511 max_strength_bits = 0;
512 curr = *head_p;
513 while (curr != NULL)
514 {
515 if (curr->active &&
516 (curr->cipher->strength_bits > max_strength_bits))
517 max_strength_bits = curr->cipher->strength_bits;
518 curr = curr->next;
519 }
520
521 number_uses = Malloc((max_strength_bits + 1) * sizeof(int));
522 if (!number_uses)
523 {
524 SSLerr(SSL_F_SSL_CIPHER_STRENGTH_SORT,ERR_R_MALLOC_FAILURE);
525 return(0);
526 }
527 memset(number_uses, 0, (max_strength_bits + 1) * sizeof(int));
528
529 /*
530 * Now find the strength_bits values actually used
531 */
532 curr = *head_p;
533 while (curr != NULL)
534 {
535 if (curr->active)
536 number_uses[curr->cipher->strength_bits]++;
537 curr = curr->next;
538 }
539 /*
540 * Go through the list of used strength_bits values in descending
541 * order.
542 */
543 for (i = max_strength_bits; i >= 0; i--)
544 if (number_uses[i] > 0)
545 ssl_cipher_apply_rule(0, 0, 0, 0, CIPHER_ORD, i,
546 list, head_p, tail_p);
547
548 Free(number_uses);
549 return(1);
550 }
435 551
436 if (ch == '\0') break; 552static int ssl_cipher_process_rulestr(const char *rule_str,
553 CIPHER_ORDER *list, CIPHER_ORDER **head_p,
554 CIPHER_ORDER **tail_p, SSL_CIPHER **ca_list)
555 {
556 unsigned long algorithms, mask, algo_strength, mask_strength;
557 const char *l, *start, *buf;
558 int j, multi, found, rule, retval, ok, buflen;
559 char ch;
560
561 retval = 1;
562 l = rule_str;
563 for (;;)
564 {
565 ch = *l;
437 566
567 if (ch == '\0')
568 break; /* done */
438 if (ch == '-') 569 if (ch == '-')
439 { j=CIPHER_DEL; l++; } 570 { rule = CIPHER_DEL; l++; }
440 else if (ch == '+') 571 else if (ch == '+')
441 { j=CIPHER_ORD; l++; } 572 { rule = CIPHER_ORD; l++; }
442 else if (ch == '!') 573 else if (ch == '!')
443 { j=CIPHER_KILL; l++; } 574 { rule = CIPHER_KILL; l++; }
444 else 575 else if (ch == '@')
445 { j=CIPHER_ADD; } 576 { rule = CIPHER_SPECIAL; l++; }
577 else
578 { rule = CIPHER_ADD; }
446 579
447 if (ITEM_SEP(ch)) 580 if (ITEM_SEP(ch))
448 { 581 {
449 l++; 582 l++;
450 continue; 583 continue;
451 } 584 }
452 ops[current_x].type=j; 585
453 ops[current_x].algorithms=0; 586 algorithms = mask = algo_strength = mask_strength = 0;
454 ops[current_x].mask=0;
455 587
456 start=l; 588 start=l;
457 for (;;) 589 for (;;)
458 { 590 {
459 ch= *l; 591 ch = *l;
460 i=0; 592 buf = l;
593 buflen = 0;
461#ifndef CHARSET_EBCDIC 594#ifndef CHARSET_EBCDIC
462 while ( ((ch >= 'A') && (ch <= 'Z')) || 595 while ( ((ch >= 'A') && (ch <= 'Z')) ||
463 ((ch >= '0') && (ch <= '9')) || 596 ((ch >= '0') && (ch <= '9')) ||
@@ -467,12 +600,28 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method,
467 while ( isalnum(ch) || (ch == '-')) 600 while ( isalnum(ch) || (ch == '-'))
468#endif 601#endif
469 { 602 {
470 buf[i]=ch; 603 ch = *(++l);
471 ch= *(++l); 604 buflen++;
472 i++;
473 if (i >= (CL_BUF-2)) break;
474 } 605 }
475 buf[i]='\0'; 606
607 if (buflen == 0)
608 {
609 /*
610 * We hit something, we cannot deal with,
611 * it is no command or separator nor
612 * alphanumeric, so we call this an error.
613 */
614 SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR,
615 SSL_R_INVALID_COMMAND);
616 retval = found = 0;
617 l++;
618 break;
619 }
620
621 if (rule == CIPHER_SPECIAL)
622 {
623 break; /* special treatment */
624 }
476 625
477 /* check for multi-part specification */ 626 /* check for multi-part specification */
478 if (ch == '+') 627 if (ch == '+')
@@ -483,133 +632,237 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method,
483 else 632 else
484 multi=0; 633 multi=0;
485 634
486 c_tmp.name=buf; 635 /*
487 j=sk_find(ca_list,(char *)&c_tmp); 636 * Now search for the name in the ca_list. Be careful
488 if (j < 0) 637 * with the strncmp, because the "buflen" limitation
489 goto end_loop; 638 * will make the rule "ADH:SOME" and the cipher
639 * "ADH-MY-CIPHER" look like a match for buflen=3.
640 * So additionally check, whether the cipher name found
641 * has the correct length. We can save a strlen() call,
642 * just checking for the '\0' at the right place is
643 * sufficient, we have to strncmp() anyway.
644 */
645 j = found = 0;
646 while (ca_list[j])
647 {
648 if ((ca_list[j]->name[buflen] == '\0') &&
649 !strncmp(buf, ca_list[j]->name, buflen))
650 {
651 found = 1;
652 break;
653 }
654 else
655 j++;
656 }
657 if (!found)
658 break; /* ignore this entry */
659
660 algorithms |= ca_list[j]->algorithms;
661 mask |= ca_list[j]->mask;
662 algo_strength |= ca_list[j]->algo_strength;
663 mask_strength |= ca_list[j]->mask_strength;
490 664
491 cp=(SSL_CIPHER *)sk_value(ca_list,j);
492 ops[current_x].algorithms|=cp->algorithms;
493 /* We add the SSL_SSL_MASK so we can match the
494 * SSLv2 and SSLv3 versions of RC4-MD5 */
495 ops[current_x].mask|=cp->mask;
496 if (!multi) break; 665 if (!multi) break;
497 } 666 }
498 current_x++; 667
499 if (ch == '\0') break; 668 /*
500end_loop: 669 * Ok, we have the rule, now apply it
501 /* Make sure we scan until the next valid start point */ 670 */
502 while ((*l != '\0') && ITEM_SEP(*l)) 671 if (rule == CIPHER_SPECIAL)
503 l++; 672 { /* special command */
673 ok = 0;
674 if ((buflen == 8) &&
675 !strncmp(buf, "STRENGTH", 8))
676 ok = ssl_cipher_strength_sort(list,
677 head_p, tail_p);
678 else
679 SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR,
680 SSL_R_INVALID_COMMAND);
681 if (ok == 0)
682 retval = 0;
683 /*
684 * We do not support any "multi" options
685 * together with "@", so throw away the
686 * rest of the command, if any left, until
687 * end or ':' is found.
688 */
689 while ((*l != '\0') && ITEM_SEP(*l))
690 l++;
691 }
692 else if (found)
693 {
694 ssl_cipher_apply_rule(algorithms, mask,
695 algo_strength, mask_strength, rule, -1,
696 list, head_p, tail_p);
697 }
698 else
699 {
700 while ((*l != '\0') && ITEM_SEP(*l))
701 l++;
702 }
703 if (*l == '\0') break; /* done */
504 } 704 }
505 705
506 num_x=current_x; 706 return(retval);
507 current_x=0; 707 }
508 708
509 /* We will now process the list of ciphers, once for each category, to 709STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
510 * decide what we should do with it. */ 710 STACK_OF(SSL_CIPHER) **cipher_list,
511 for (j=0; j<num_x; j++) 711 STACK_OF(SSL_CIPHER) **cipher_list_by_id,
712 const char *rule_str)
713 {
714 int ok, num_of_ciphers, num_of_alias_max, num_of_group_aliases;
715 unsigned long disabled_mask;
716 STACK_OF(SSL_CIPHER) *cipherstack;
717 const char *rule_p;
718 CIPHER_ORDER *list = NULL, *head = NULL, *tail = NULL, *curr;
719 SSL_CIPHER **ca_list = NULL;
720
721 /*
722 * Return with error if nothing to do.
723 */
724 if (rule_str == NULL) return(NULL);
725
726 if (init_ciphers) load_ciphers();
727
728 /*
729 * To reduce the work to do we only want to process the compiled
730 * in algorithms, so we first get the mask of disabled ciphers.
731 */
732 disabled_mask = ssl_cipher_get_disabled();
733
734 /*
735 * Now we have to collect the available ciphers from the compiled
736 * in ciphers. We cannot get more than the number compiled in, so
737 * it is used for allocation.
738 */
739 num_of_ciphers = ssl_method->num_ciphers();
740 list = (CIPHER_ORDER *)Malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
741 if (list == NULL)
512 { 742 {
513 algorithms=ops[j].algorithms; 743 SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
514 type=ops[j].type; 744 return(NULL); /* Failure */
515 mask=ops[j].mask; 745 }
516 746
517 curr=head; 747 ssl_cipher_collect_ciphers(ssl_method, num_of_ciphers, disabled_mask,
518 curr2=head; 748 list, &head, &tail);
519 tail2=tail; 749
520 for (;;) 750 /*
521 { 751 * We also need cipher aliases for selecting based on the rule_str.
522 if ((curr == NULL) || (curr == tail2)) break; 752 * There might be two types of entries in the rule_str: 1) names
523 curr=curr2; 753 * of ciphers themselves 2) aliases for groups of ciphers.
524 curr2=curr->next; 754 * For 1) we need the available ciphers and for 2) the cipher
755 * groups of cipher_aliases added together in one list (otherwise
756 * we would be happy with just the cipher_aliases table).
757 */
758 num_of_group_aliases = sizeof(cipher_aliases) / sizeof(SSL_CIPHER);
759 num_of_alias_max = num_of_ciphers + num_of_group_aliases + 1;
760 ca_list =
761 (SSL_CIPHER **)Malloc(sizeof(SSL_CIPHER *) * num_of_alias_max);
762 if (ca_list == NULL)
763 {
764 Free(list);
765 SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
766 return(NULL); /* Failure */
767 }
768 ssl_cipher_collect_aliases(ca_list, num_of_group_aliases, disabled_mask,
769 head);
770
771 /*
772 * If the rule_string begins with DEFAULT, apply the default rule
773 * before using the (possibly available) additional rules.
774 */
775 ok = 1;
776 rule_p = rule_str;
777 if (strncmp(rule_str,"DEFAULT",7) == 0)
778 {
779 ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST,
780 list, &head, &tail, ca_list);
781 rule_p += 7;
782 if (*rule_p == ':')
783 rule_p++;
784 }
525 785
526 cp=curr->cipher; 786 if (ok && (strlen(rule_p) > 0))
527 ma=mask & cp->algorithms; 787 ok = ssl_cipher_process_rulestr(rule_p, list, &head, &tail,
528 if ((ma == 0) || ((ma & algorithms) != ma)) 788 ca_list);
529 {
530 /* does not apply */
531 continue;
532 }
533 789
534 /* add the cipher if it has not been added yet. */ 790 Free(ca_list); /* Not needed anymore */
535 if (type == CIPHER_ADD) 791
536 { 792 if (!ok)
537 if (!curr->active) 793 { /* Rule processing failure */
538 { 794 Free(list);
539 ll_append_tail(&head,curr,&tail); 795 return(NULL);
540 curr->active=1; 796 }
541 } 797 /*
542 } 798 * Allocate new "cipherstack" for the result, return with error
543 /* Move the added cipher to this location */ 799 * if we cannot get one.
544 else if (type == CIPHER_ORD) 800 */
545 { 801 if ((cipherstack = sk_SSL_CIPHER_new(NULL)) == NULL)
546 if (curr->active) 802 {
547 { 803 Free(list);
548 ll_append_tail(&head,curr,&tail); 804 return(NULL);
549 }
550 }
551 else if (type == CIPHER_DEL)
552 curr->active=0;
553 if (type == CIPHER_KILL)
554 {
555 if (head == curr)
556 head=curr->next;
557 else
558 curr->prev->next=curr->next;
559 if (tail == curr)
560 tail=curr->prev;
561 curr->active=0;
562 if (curr->next != NULL)
563 curr->next->prev=curr->prev;
564 if (curr->prev != NULL)
565 curr->prev->next=curr->next;
566 curr->next=NULL;
567 curr->prev=NULL;
568 }
569 }
570 } 805 }
571 806
572 for (curr=head; curr != NULL; curr=curr->next) 807 /*
808 * The cipher selection for the list is done. The ciphers are added
809 * to the resulting precedence to the STACK_OF(SSL_CIPHER).
810 */
811 for (curr = head; curr != NULL; curr = curr->next)
573 { 812 {
574 if (curr->active) 813 if (curr->active)
575 { 814 {
576 sk_SSL_CIPHER_push(ret,curr->cipher); 815 sk_SSL_CIPHER_push(cipherstack, curr->cipher);
577#ifdef CIPHER_DEBUG 816#ifdef CIPHER_DEBUG
578 printf("<%s>\n",curr->cipher->name); 817 printf("<%s>\n",curr->cipher->name);
579#endif 818#endif
580 } 819 }
581 } 820 }
582 821 Free(list); /* Not needed any longer */
822
823 /*
824 * The following passage is a little bit odd. If pointer variables
825 * were supplied to hold STACK_OF(SSL_CIPHER) return information,
826 * the old memory pointed to is free()ed. Then, however, the
827 * cipher_list entry will be assigned just a copy of the returned
828 * cipher stack. For cipher_list_by_id a copy of the cipher stack
829 * will be created. See next comment...
830 */
583 if (cipher_list != NULL) 831 if (cipher_list != NULL)
584 { 832 {
585 if (*cipher_list != NULL) 833 if (*cipher_list != NULL)
586 sk_SSL_CIPHER_free(*cipher_list); 834 sk_SSL_CIPHER_free(*cipher_list);
587 *cipher_list=ret; 835 *cipher_list = cipherstack;
588 } 836 }
589 837
590 if (cipher_list_by_id != NULL) 838 if (cipher_list_by_id != NULL)
591 { 839 {
592 if (*cipher_list_by_id != NULL) 840 if (*cipher_list_by_id != NULL)
593 sk_SSL_CIPHER_free(*cipher_list_by_id); 841 sk_SSL_CIPHER_free(*cipher_list_by_id);
594 *cipher_list_by_id=sk_SSL_CIPHER_dup(ret); 842 *cipher_list_by_id = sk_SSL_CIPHER_dup(cipherstack);
595 } 843 }
596 844
845 /*
846 * Now it is getting really strange. If something failed during
847 * the previous pointer assignment or if one of the pointers was
848 * not requested, the error condition is met. That might be
849 * discussable. The strange thing is however that in this case
850 * the memory "ret" pointed to is "free()ed" and hence the pointer
851 * cipher_list becomes wild. The memory reserved for
852 * cipher_list_by_id however is not "free()ed" and stays intact.
853 */
597 if ( (cipher_list_by_id == NULL) || 854 if ( (cipher_list_by_id == NULL) ||
598 (*cipher_list_by_id == NULL) || 855 (*cipher_list_by_id == NULL) ||
599 (cipher_list == NULL) || 856 (cipher_list == NULL) ||
600 (*cipher_list == NULL)) 857 (*cipher_list == NULL))
601 goto err; 858 {
859 sk_SSL_CIPHER_free(cipherstack);
860 return(NULL);
861 }
862
602 sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp); 863 sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp);
603 864
604 ok=ret; 865 return(cipherstack);
605 ret=NULL;
606err:
607 if (tmp_str) Free(tmp_str);
608 if (ops != NULL) Free(ops);
609 if (ret != NULL) sk_SSL_CIPHER_free(ret);
610 if (ca_list != NULL) sk_free(ca_list);
611 if (list != NULL) Free(list);
612 return(ok);
613 } 866 }
614 867
615char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len) 868char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
@@ -617,15 +870,16 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
617 int is_export,pkl,kl; 870 int is_export,pkl,kl;
618 char *ver,*exp; 871 char *ver,*exp;
619 char *kx,*au,*enc,*mac; 872 char *kx,*au,*enc,*mac;
620 unsigned long alg,alg2; 873 unsigned long alg,alg2,alg_s;
621 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n"; 874 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n";
622 875
623 alg=cipher->algorithms; 876 alg=cipher->algorithms;
877 alg_s=cipher->algo_strength;
624 alg2=cipher->algorithm2; 878 alg2=cipher->algorithm2;
625 879
626 is_export=SSL_IS_EXPORT(alg); 880 is_export=SSL_C_IS_EXPORT(cipher);
627 pkl=SSL_EXPORT_PKEYLENGTH(alg); 881 pkl=SSL_C_EXPORT_PKEYLENGTH(cipher);
628 kl=SSL_EXPORT_KEYLENGTH(alg); 882 kl=SSL_C_EXPORT_KEYLENGTH(cipher);
629 exp=is_export?" export":""; 883 exp=is_export?" export":"";
630 884
631 if (alg & SSL_SSLV2) 885 if (alg & SSL_SSLV2)
@@ -752,37 +1006,16 @@ const char *SSL_CIPHER_get_name(SSL_CIPHER *c)
752 return("(NONE)"); 1006 return("(NONE)");
753 } 1007 }
754 1008
755/* number of bits for symetric cipher */ 1009/* number of bits for symmetric cipher */
756int SSL_CIPHER_get_bits(SSL_CIPHER *c, int *alg_bits) 1010int SSL_CIPHER_get_bits(SSL_CIPHER *c, int *alg_bits)
757 { 1011 {
758 int ret=0,a=0; 1012 int ret=0;
759 const EVP_CIPHER *enc;
760 const EVP_MD *md;
761 SSL_SESSION ss;
762 1013
763 if (c != NULL) 1014 if (c != NULL)
764 { 1015 {
765 ss.cipher=c; 1016 if (alg_bits != NULL) *alg_bits = c->alg_bits;
766 if (!ssl_cipher_get_evp(&ss,&enc,&md,NULL)) 1017 ret = c->strength_bits;
767 return(0);
768
769 a=EVP_CIPHER_key_length(enc)*8;
770
771 if (SSL_C_IS_EXPORT(c))
772 {
773 ret=SSL_C_EXPORT_KEYLENGTH(c)*8;
774 }
775 else
776 {
777 if (c->algorithm2 & SSL2_CF_8_BYTE_ENC)
778 ret=64;
779 else
780 ret=a;
781 }
782 } 1018 }
783
784 if (alg_bits != NULL) *alg_bits=a;
785
786 return(ret); 1019 return(ret);
787 } 1020 }
788 1021
diff --git a/src/lib/libssl/src/ssl/ssl_err.c b/src/lib/libssl/src/ssl/ssl_err.c
index 3ddc805b53..5618e34a30 100644
--- a/src/lib/libssl/src/ssl/ssl_err.c
+++ b/src/lib/libssl/src/ssl/ssl_err.c
@@ -135,13 +135,18 @@ static ERR_STRING_DATA SSL_str_functs[]=
135{ERR_PACK(0,SSL_F_SSL_CERT_INSTANTIATE,0), "SSL_CERT_INSTANTIATE"}, 135{ERR_PACK(0,SSL_F_SSL_CERT_INSTANTIATE,0), "SSL_CERT_INSTANTIATE"},
136{ERR_PACK(0,SSL_F_SSL_CERT_NEW,0), "SSL_CERT_NEW"}, 136{ERR_PACK(0,SSL_F_SSL_CERT_NEW,0), "SSL_CERT_NEW"},
137{ERR_PACK(0,SSL_F_SSL_CHECK_PRIVATE_KEY,0), "SSL_check_private_key"}, 137{ERR_PACK(0,SSL_F_SSL_CHECK_PRIVATE_KEY,0), "SSL_check_private_key"},
138{ERR_PACK(0,SSL_F_SSL_CIPHER_PROCESS_RULESTR,0), "SSL_CIPHER_PROCESS_RULESTR"},
139{ERR_PACK(0,SSL_F_SSL_CIPHER_STRENGTH_SORT,0), "SSL_CIPHER_STRENGTH_SORT"},
138{ERR_PACK(0,SSL_F_SSL_CLEAR,0), "SSL_clear"}, 140{ERR_PACK(0,SSL_F_SSL_CLEAR,0), "SSL_clear"},
139{ERR_PACK(0,SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,0), "SSL_COMP_add_compression_method"}, 141{ERR_PACK(0,SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,0), "SSL_COMP_add_compression_method"},
140{ERR_PACK(0,SSL_F_SSL_CREATE_CIPHER_LIST,0), "SSL_CREATE_CIPHER_LIST"}, 142{ERR_PACK(0,SSL_F_SSL_CREATE_CIPHER_LIST,0), "SSL_CREATE_CIPHER_LIST"},
143{ERR_PACK(0,SSL_F_SSL_CTRL,0), "SSL_ctrl"},
141{ERR_PACK(0,SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,0), "SSL_CTX_check_private_key"}, 144{ERR_PACK(0,SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,0), "SSL_CTX_check_private_key"},
142{ERR_PACK(0,SSL_F_SSL_CTX_NEW,0), "SSL_CTX_new"}, 145{ERR_PACK(0,SSL_F_SSL_CTX_NEW,0), "SSL_CTX_new"},
146{ERR_PACK(0,SSL_F_SSL_CTX_SET_PURPOSE,0), "SSL_CTX_set_purpose"},
143{ERR_PACK(0,SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,0), "SSL_CTX_set_session_id_context"}, 147{ERR_PACK(0,SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,0), "SSL_CTX_set_session_id_context"},
144{ERR_PACK(0,SSL_F_SSL_CTX_SET_SSL_VERSION,0), "SSL_CTX_set_ssl_version"}, 148{ERR_PACK(0,SSL_F_SSL_CTX_SET_SSL_VERSION,0), "SSL_CTX_set_ssl_version"},
149{ERR_PACK(0,SSL_F_SSL_CTX_SET_TRUST,0), "SSL_CTX_set_trust"},
145{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE,0), "SSL_CTX_use_certificate"}, 150{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE,0), "SSL_CTX_use_certificate"},
146{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1,0), "SSL_CTX_use_certificate_ASN1"}, 151{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1,0), "SSL_CTX_use_certificate_ASN1"},
147{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,0), "SSL_CTX_use_certificate_chain_file"}, 152{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,0), "SSL_CTX_use_certificate_chain_file"},
@@ -169,9 +174,11 @@ static ERR_STRING_DATA SSL_str_functs[]=
169{ERR_PACK(0,SSL_F_SSL_SET_CERT,0), "SSL_SET_CERT"}, 174{ERR_PACK(0,SSL_F_SSL_SET_CERT,0), "SSL_SET_CERT"},
170{ERR_PACK(0,SSL_F_SSL_SET_FD,0), "SSL_set_fd"}, 175{ERR_PACK(0,SSL_F_SSL_SET_FD,0), "SSL_set_fd"},
171{ERR_PACK(0,SSL_F_SSL_SET_PKEY,0), "SSL_SET_PKEY"}, 176{ERR_PACK(0,SSL_F_SSL_SET_PKEY,0), "SSL_SET_PKEY"},
177{ERR_PACK(0,SSL_F_SSL_SET_PURPOSE,0), "SSL_set_purpose"},
172{ERR_PACK(0,SSL_F_SSL_SET_RFD,0), "SSL_set_rfd"}, 178{ERR_PACK(0,SSL_F_SSL_SET_RFD,0), "SSL_set_rfd"},
173{ERR_PACK(0,SSL_F_SSL_SET_SESSION,0), "SSL_set_session"}, 179{ERR_PACK(0,SSL_F_SSL_SET_SESSION,0), "SSL_set_session"},
174{ERR_PACK(0,SSL_F_SSL_SET_SESSION_ID_CONTEXT,0), "SSL_set_session_id_context"}, 180{ERR_PACK(0,SSL_F_SSL_SET_SESSION_ID_CONTEXT,0), "SSL_set_session_id_context"},
181{ERR_PACK(0,SSL_F_SSL_SET_TRUST,0), "SSL_set_trust"},
175{ERR_PACK(0,SSL_F_SSL_SET_WFD,0), "SSL_set_wfd"}, 182{ERR_PACK(0,SSL_F_SSL_SET_WFD,0), "SSL_set_wfd"},
176{ERR_PACK(0,SSL_F_SSL_SHUTDOWN,0), "SSL_shutdown"}, 183{ERR_PACK(0,SSL_F_SSL_SHUTDOWN,0), "SSL_shutdown"},
177{ERR_PACK(0,SSL_F_SSL_UNDEFINED_FUNCTION,0), "SSL_UNDEFINED_FUNCTION"}, 184{ERR_PACK(0,SSL_F_SSL_UNDEFINED_FUNCTION,0), "SSL_UNDEFINED_FUNCTION"},
@@ -201,7 +208,6 @@ static ERR_STRING_DATA SSL_str_reasons[]=
201{SSL_R_BAD_AUTHENTICATION_TYPE ,"bad authentication type"}, 208{SSL_R_BAD_AUTHENTICATION_TYPE ,"bad authentication type"},
202{SSL_R_BAD_CHANGE_CIPHER_SPEC ,"bad change cipher spec"}, 209{SSL_R_BAD_CHANGE_CIPHER_SPEC ,"bad change cipher spec"},
203{SSL_R_BAD_CHECKSUM ,"bad checksum"}, 210{SSL_R_BAD_CHECKSUM ,"bad checksum"},
204{SSL_R_BAD_CLIENT_REQUEST ,"bad client request"},
205{SSL_R_BAD_DATA_RETURNED_BY_CALLBACK ,"bad data returned by callback"}, 211{SSL_R_BAD_DATA_RETURNED_BY_CALLBACK ,"bad data returned by callback"},
206{SSL_R_BAD_DECOMPRESSION ,"bad decompression"}, 212{SSL_R_BAD_DECOMPRESSION ,"bad decompression"},
207{SSL_R_BAD_DH_G_LENGTH ,"bad dh g length"}, 213{SSL_R_BAD_DH_G_LENGTH ,"bad dh g length"},
@@ -209,6 +215,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
209{SSL_R_BAD_DH_P_LENGTH ,"bad dh p length"}, 215{SSL_R_BAD_DH_P_LENGTH ,"bad dh p length"},
210{SSL_R_BAD_DIGEST_LENGTH ,"bad digest length"}, 216{SSL_R_BAD_DIGEST_LENGTH ,"bad digest length"},
211{SSL_R_BAD_DSA_SIGNATURE ,"bad dsa signature"}, 217{SSL_R_BAD_DSA_SIGNATURE ,"bad dsa signature"},
218{SSL_R_BAD_HELLO_REQUEST ,"bad hello request"},
212{SSL_R_BAD_LENGTH ,"bad length"}, 219{SSL_R_BAD_LENGTH ,"bad length"},
213{SSL_R_BAD_MAC_DECODE ,"bad mac decode"}, 220{SSL_R_BAD_MAC_DECODE ,"bad mac decode"},
214{SSL_R_BAD_MESSAGE_TYPE ,"bad message type"}, 221{SSL_R_BAD_MESSAGE_TYPE ,"bad message type"},
@@ -248,6 +255,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
248{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"}, 255{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"},
249{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"}, 256{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"},
250{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"}, 257{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"},
258{SSL_R_ERROR_GENERATING_TMP_RSA_KEY ,"error generating tmp rsa key"},
251{SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST ,"error in received cipher list"}, 259{SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST ,"error in received cipher list"},
252{SSL_R_EXCESSIVE_MESSAGE_SIZE ,"excessive message size"}, 260{SSL_R_EXCESSIVE_MESSAGE_SIZE ,"excessive message size"},
253{SSL_R_EXTRA_DATA_IN_MESSAGE ,"extra data in message"}, 261{SSL_R_EXTRA_DATA_IN_MESSAGE ,"extra data in message"},
@@ -256,6 +264,9 @@ static ERR_STRING_DATA SSL_str_reasons[]=
256{SSL_R_HTTP_REQUEST ,"http request"}, 264{SSL_R_HTTP_REQUEST ,"http request"},
257{SSL_R_INTERNAL_ERROR ,"internal error"}, 265{SSL_R_INTERNAL_ERROR ,"internal error"},
258{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"}, 266{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"},
267{SSL_R_INVALID_COMMAND ,"invalid command"},
268{SSL_R_INVALID_PURPOSE ,"invalid purpose"},
269{SSL_R_INVALID_TRUST ,"invalid trust"},
259{SSL_R_LENGTH_MISMATCH ,"length mismatch"}, 270{SSL_R_LENGTH_MISMATCH ,"length mismatch"},
260{SSL_R_LENGTH_TOO_SHORT ,"length too short"}, 271{SSL_R_LENGTH_TOO_SHORT ,"length too short"},
261{SSL_R_LIBRARY_BUG ,"library bug"}, 272{SSL_R_LIBRARY_BUG ,"library bug"},
@@ -348,14 +359,14 @@ static ERR_STRING_DATA SSL_str_reasons[]=
348{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"}, 359{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"},
349{SSL_R_TLSV1_ALERT_DECRYPTION_FAILED ,"tlsv1 alert decryption failed"}, 360{SSL_R_TLSV1_ALERT_DECRYPTION_FAILED ,"tlsv1 alert decryption failed"},
350{SSL_R_TLSV1_ALERT_DECRYPT_ERROR ,"tlsv1 alert decrypt error"}, 361{SSL_R_TLSV1_ALERT_DECRYPT_ERROR ,"tlsv1 alert decrypt error"},
351{SSL_R_TLSV1_ALERT_EXPORT_RESTRICION ,"tlsv1 alert export restricion"}, 362{SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION ,"tlsv1 alert export restriction"},
352{SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY ,"tlsv1 alert insufficient security"}, 363{SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY ,"tlsv1 alert insufficient security"},
353{SSL_R_TLSV1_ALERT_INTERNAL_ERROR ,"tlsv1 alert internal error"}, 364{SSL_R_TLSV1_ALERT_INTERNAL_ERROR ,"tlsv1 alert internal error"},
354{SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ,"tlsv1 alert no renegotiation"}, 365{SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ,"tlsv1 alert no renegotiation"},
355{SSL_R_TLSV1_ALERT_PROTOCOL_VERSION ,"tlsv1 alert protocol version"}, 366{SSL_R_TLSV1_ALERT_PROTOCOL_VERSION ,"tlsv1 alert protocol version"},
356{SSL_R_TLSV1_ALERT_RECORD_OVERFLOW ,"tlsv1 alert record overflow"}, 367{SSL_R_TLSV1_ALERT_RECORD_OVERFLOW ,"tlsv1 alert record overflow"},
357{SSL_R_TLSV1_ALERT_UNKNOWN_CA ,"tlsv1 alert unknown ca"}, 368{SSL_R_TLSV1_ALERT_UNKNOWN_CA ,"tlsv1 alert unknown ca"},
358{SSL_R_TLSV1_ALERT_USER_CANCLED ,"tlsv1 alert user cancled"}, 369{SSL_R_TLSV1_ALERT_USER_CANCELLED ,"tlsv1 alert user cancelled"},
359{SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER,"tls client cert req with anon cipher"}, 370{SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER,"tls client cert req with anon cipher"},
360{SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST,"tls peer did not respond with certificate list"}, 371{SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST,"tls peer did not respond with certificate list"},
361{SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG,"tls rsa encrypted value length is wrong"}, 372{SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG,"tls rsa encrypted value length is wrong"},
@@ -383,6 +394,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
383{SSL_R_UNKNOWN_STATE ,"unknown state"}, 394{SSL_R_UNKNOWN_STATE ,"unknown state"},
384{SSL_R_UNSUPPORTED_CIPHER ,"unsupported cipher"}, 395{SSL_R_UNSUPPORTED_CIPHER ,"unsupported cipher"},
385{SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM ,"unsupported compression algorithm"}, 396{SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM ,"unsupported compression algorithm"},
397{SSL_R_UNSUPPORTED_OPTION ,"unsupported option"},
386{SSL_R_UNSUPPORTED_PROTOCOL ,"unsupported protocol"}, 398{SSL_R_UNSUPPORTED_PROTOCOL ,"unsupported protocol"},
387{SSL_R_UNSUPPORTED_SSL_VERSION ,"unsupported ssl version"}, 399{SSL_R_UNSUPPORTED_SSL_VERSION ,"unsupported ssl version"},
388{SSL_R_WRITE_BIO_NOT_SET ,"write bio not set"}, 400{SSL_R_WRITE_BIO_NOT_SET ,"write bio not set"},
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c
index e192fc4cac..3109708480 100644
--- a/src/lib/libssl/src/ssl/ssl_lib.c
+++ b/src/lib/libssl/src/ssl/ssl_lib.c
@@ -61,22 +61,24 @@
61#include <stdio.h> 61#include <stdio.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/lhash.h> 63#include <openssl/lhash.h>
64#include <openssl/x509v3.h>
64#include "ssl_locl.h" 65#include "ssl_locl.h"
65 66
66char *SSL_version_str=OPENSSL_VERSION_TEXT; 67const char *SSL_version_str=OPENSSL_VERSION_TEXT;
67 68
68static STACK *ssl_meth=NULL; 69static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_meth=NULL;
69static STACK *ssl_ctx_meth=NULL; 70static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_ctx_meth=NULL;
70static int ssl_meth_num=0; 71static int ssl_meth_num=0;
71static int ssl_ctx_meth_num=0; 72static int ssl_ctx_meth_num=0;
72 73
73OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={ 74OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={
75 /* evil casts, but these functions are only called if there's a library bug */
76 (int (*)(SSL *,int))ssl_undefined_function,
77 (int (*)(SSL *, unsigned char *, int))ssl_undefined_function,
74 ssl_undefined_function, 78 ssl_undefined_function,
75 ssl_undefined_function, 79 (int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function,
76 ssl_undefined_function, 80 (int (*)(SSL*, int))ssl_undefined_function,
77 ssl_undefined_function, 81 (int (*)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char*, int, unsigned char *))ssl_undefined_function
78 ssl_undefined_function,
79 ssl_undefined_function,
80 }; 82 };
81 83
82int SSL_clear(SSL *s) 84int SSL_clear(SSL *s)
@@ -93,10 +95,17 @@ int SSL_clear(SSL *s)
93 s->hit=0; 95 s->hit=0;
94 s->shutdown=0; 96 s->shutdown=0;
95 97
96#if 0 98#if 0 /* Disabled since version 1.10 of this file (early return not
99 * needed because SSL_clear is not called when doing renegotiation) */
97 /* This is set if we are doing dynamic renegotiation so keep 100 /* This is set if we are doing dynamic renegotiation so keep
98 * the old cipher. It is sort of a SSL_clear_lite :-) */ 101 * the old cipher. It is sort of a SSL_clear_lite :-) */
99 if (s->new_session) return(1); 102 if (s->new_session) return(1);
103#else
104 if (s->new_session)
105 {
106 SSLerr(SSL_F_SSL_CLEAR,SSL_R_INTERNAL_ERROR);
107 return 0;
108 }
100#endif 109#endif
101 110
102 state=s->state; /* Keep to check if we throw away the session-id */ 111 state=s->state; /* Keep to check if we throw away the session-id */
@@ -201,6 +210,8 @@ SSL *SSL_new(SSL_CTX *ctx)
201 s->verify_mode=ctx->verify_mode; 210 s->verify_mode=ctx->verify_mode;
202 s->verify_depth=ctx->verify_depth; 211 s->verify_depth=ctx->verify_depth;
203 s->verify_callback=ctx->default_verify_callback; 212 s->verify_callback=ctx->default_verify_callback;
213 s->purpose = ctx->purpose;
214 s->trust = ctx->trust;
204 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); 215 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
205 s->ctx=ctx; 216 s->ctx=ctx;
206 217
@@ -218,7 +229,7 @@ SSL *SSL_new(SSL_CTX *ctx)
218 s->mode=ctx->mode; 229 s->mode=ctx->mode;
219 SSL_clear(s); 230 SSL_clear(s);
220 231
221 CRYPTO_new_ex_data(ssl_meth,(char *)s,&s->ex_data); 232 CRYPTO_new_ex_data(ssl_meth,s,&s->ex_data);
222 233
223 return(s); 234 return(s);
224err: 235err:
@@ -262,6 +273,46 @@ int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
262 return 1; 273 return 1;
263 } 274 }
264 275
276int SSL_CTX_set_purpose(SSL_CTX *s, int purpose)
277{
278 if(X509_PURPOSE_get_by_id(purpose) == -1) {
279 SSLerr(SSL_F_SSL_CTX_SET_PURPOSE, SSL_R_INVALID_PURPOSE);
280 return 0;
281 }
282 s->purpose = purpose;
283 return 1;
284}
285
286int SSL_set_purpose(SSL *s, int purpose)
287{
288 if(X509_PURPOSE_get_by_id(purpose) == -1) {
289 SSLerr(SSL_F_SSL_SET_PURPOSE, SSL_R_INVALID_PURPOSE);
290 return 0;
291 }
292 s->purpose = purpose;
293 return 1;
294}
295
296int SSL_CTX_set_trust(SSL_CTX *s, int trust)
297{
298 if(X509_TRUST_get_by_id(trust) == -1) {
299 SSLerr(SSL_F_SSL_CTX_SET_TRUST, SSL_R_INVALID_TRUST);
300 return 0;
301 }
302 s->trust = trust;
303 return 1;
304}
305
306int SSL_set_trust(SSL *s, int trust)
307{
308 if(X509_TRUST_get_by_id(trust) == -1) {
309 SSLerr(SSL_F_SSL_SET_TRUST, SSL_R_INVALID_TRUST);
310 return 0;
311 }
312 s->trust = trust;
313 return 1;
314}
315
265void SSL_free(SSL *s) 316void SSL_free(SSL *s)
266 { 317 {
267 int i; 318 int i;
@@ -324,7 +375,7 @@ void SSL_free(SSL *s)
324 375
325 if (s->method != NULL) s->method->ssl_free(s); 376 if (s->method != NULL) s->method->ssl_free(s);
326 377
327 Free((char *)s); 378 Free(s);
328 } 379 }
329 380
330void SSL_set_bio(SSL *s,BIO *rbio,BIO *wbio) 381void SSL_set_bio(SSL *s,BIO *rbio,BIO *wbio)
@@ -433,6 +484,38 @@ err:
433 } 484 }
434#endif 485#endif
435 486
487
488/* return length of latest Finished message we sent, copy to 'buf' */
489size_t SSL_get_finished(SSL *s, void *buf, size_t count)
490 {
491 size_t ret = 0;
492
493 if (s->s3 != NULL)
494 {
495 ret = s->s3->tmp.finish_md_len;
496 if (count > ret)
497 count = ret;
498 memcpy(buf, s->s3->tmp.finish_md, count);
499 }
500 return ret;
501 }
502
503/* return length of latest Finished message we expected, copy to 'buf' */
504size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count)
505 {
506 size_t ret = 0;
507
508 if (s->s3 != NULL)
509 {
510 ret = s->s3->tmp.peer_finish_md_len;
511 if (count > ret)
512 count = ret;
513 memcpy(buf, s->s3->tmp.peer_finish_md, count);
514 }
515 return ret;
516 }
517
518
436int SSL_get_verify_mode(SSL *s) 519int SSL_get_verify_mode(SSL *s)
437 { 520 {
438 return(s->verify_mode); 521 return(s->verify_mode);
@@ -706,6 +789,20 @@ long SSL_ctrl(SSL *s,int cmd,long larg,char *parg)
706 } 789 }
707 } 790 }
708 791
792long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)())
793 {
794 switch(cmd)
795 {
796 default:
797 return(s->method->ssl_callback_ctrl(s,cmd,fp));
798 }
799 }
800
801struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx)
802 {
803 return ctx->sessions;
804 }
805
709long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg) 806long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg)
710 { 807 {
711 long l; 808 long l;
@@ -765,6 +862,15 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg)
765 } 862 }
766 } 863 }
767 864
865long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
866 {
867 switch(cmd)
868 {
869 default:
870 return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp));
871 }
872 }
873
768int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b) 874int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b)
769 { 875 {
770 long l; 876 long l;
@@ -834,8 +940,8 @@ const char *SSL_get_cipher_list(SSL *s,int n)
834 return(c->name); 940 return(c->name);
835 } 941 }
836 942
837/** specify the ciphers to be used by defaut by the SSL_CTX */ 943/** specify the ciphers to be used by default by the SSL_CTX */
838int SSL_CTX_set_cipher_list(SSL_CTX *ctx,char *str) 944int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str)
839 { 945 {
840 STACK_OF(SSL_CIPHER) *sk; 946 STACK_OF(SSL_CIPHER) *sk;
841 947
@@ -846,7 +952,7 @@ int SSL_CTX_set_cipher_list(SSL_CTX *ctx,char *str)
846 } 952 }
847 953
848/** specify the ciphers to be used by the SSL */ 954/** specify the ciphers to be used by the SSL */
849int SSL_set_cipher_list(SSL *s,char *str) 955int SSL_set_cipher_list(SSL *s,const char *str)
850 { 956 {
851 STACK_OF(SSL_CIPHER) *sk; 957 STACK_OF(SSL_CIPHER) *sk;
852 958
@@ -1127,7 +1233,7 @@ void SSL_CTX_free(SSL_CTX *a)
1127 sk_X509_pop_free(a->extra_certs,X509_free); 1233 sk_X509_pop_free(a->extra_certs,X509_free);
1128 if (a->comp_methods != NULL) 1234 if (a->comp_methods != NULL)
1129 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free); 1235 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free);
1130 Free((char *)a); 1236 Free(a);
1131 } 1237 }
1132 1238
1133void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb) 1239void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb)
@@ -1254,10 +1360,8 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
1254 emask|=SSL_aDSS; 1360 emask|=SSL_aDSS;
1255 } 1361 }
1256 1362
1257#ifdef SSL_ALLOW_ADH
1258 mask|=SSL_aNULL; 1363 mask|=SSL_aNULL;
1259 emask|=SSL_aNULL; 1364 emask|=SSL_aNULL;
1260#endif
1261 1365
1262 c->mask=mask; 1366 c->mask=mask;
1263 c->export_mask=emask; 1367 c->export_mask=emask;
@@ -1274,7 +1378,7 @@ X509 *ssl_get_server_send_cert(SSL *s)
1274 c=s->cert; 1378 c=s->cert;
1275 ssl_set_cert_masks(c, s->s3->tmp.new_cipher); 1379 ssl_set_cert_masks(c, s->s3->tmp.new_cipher);
1276 alg=s->s3->tmp.new_cipher->algorithms; 1380 alg=s->s3->tmp.new_cipher->algorithms;
1277 is_export=SSL_IS_EXPORT(alg); 1381 is_export=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher);
1278 mask=is_export?c->export_mask:c->mask; 1382 mask=is_export?c->export_mask:c->mask;
1279 kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); 1383 kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK);
1280 1384
@@ -1527,7 +1631,7 @@ SSL_METHOD *ssl_bad_method(int ver)
1527 return(NULL); 1631 return(NULL);
1528 } 1632 }
1529 1633
1530char *SSL_get_version(SSL *s) 1634const char *SSL_get_version(SSL *s)
1531 { 1635 {
1532 if (s->version == TLS1_VERSION) 1636 if (s->version == TLS1_VERSION)
1533 return("TLSv1"); 1637 return("TLSv1");
@@ -1831,8 +1935,8 @@ long SSL_get_verify_result(SSL *ssl)
1831 return(ssl->verify_result); 1935 return(ssl->verify_result);
1832 } 1936 }
1833 1937
1834int SSL_get_ex_new_index(long argl,char *argp,int (*new_func)(), 1938int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1835 int (*dup_func)(),void (*free_func)()) 1939 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1836 { 1940 {
1837 ssl_meth_num++; 1941 ssl_meth_num++;
1838 return(CRYPTO_get_ex_new_index(ssl_meth_num-1, 1942 return(CRYPTO_get_ex_new_index(ssl_meth_num-1,
@@ -1849,8 +1953,8 @@ void *SSL_get_ex_data(SSL *s,int idx)
1849 return(CRYPTO_get_ex_data(&s->ex_data,idx)); 1953 return(CRYPTO_get_ex_data(&s->ex_data,idx));
1850 } 1954 }
1851 1955
1852int SSL_CTX_get_ex_new_index(long argl,char *argp,int (*new_func)(), 1956int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1853 int (*dup_func)(),void (*free_func)()) 1957 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1854 { 1958 {
1855 ssl_ctx_meth_num++; 1959 ssl_ctx_meth_num++;
1856 return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1, 1960 return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1,
@@ -1899,13 +2003,16 @@ int SSL_want(SSL *s)
1899void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, 2003void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl,
1900 int is_export, 2004 int is_export,
1901 int keylength)) 2005 int keylength))
1902 { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); } 2006 {
1903#endif 2007 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb);
2008 }
1904 2009
1905#ifndef NO_RSA 2010void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl,
1906void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl,int is_export, 2011 int is_export,
1907 int keylength)) 2012 int keylength))
1908 { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); } 2013 {
2014 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb);
2015 }
1909#endif 2016#endif
1910 2017
1911#ifdef DOXYGEN 2018#ifdef DOXYGEN
@@ -1932,11 +2039,15 @@ RSA *cb(SSL *ssl,int is_export,int keylength)
1932#ifndef NO_DH 2039#ifndef NO_DH
1933void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, 2040void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export,
1934 int keylength)) 2041 int keylength))
1935 { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); } 2042 {
2043 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2044 }
1936 2045
1937void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, 2046void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export,
1938 int keylength)) 2047 int keylength))
1939 { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); } 2048 {
2049 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2050 }
1940#endif 2051#endif
1941 2052
1942#if defined(_WINDLL) && defined(WIN16) 2053#if defined(_WINDLL) && defined(WIN16)
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h
index 0bfd57db32..9a52bab254 100644
--- a/src/lib/libssl/src/ssl/ssl_locl.h
+++ b/src/lib/libssl/src/ssl/ssl_locl.h
@@ -155,6 +155,19 @@
155#define DEC32(a) ((a)=((a)-1)&0xffffffffL) 155#define DEC32(a) ((a)=((a)-1)&0xffffffffL)
156#define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */ 156#define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */
157 157
158/*
159 * Define the Bitmasks for SSL_CIPHER.algorithms.
160 * This bits are used packed as dense as possible. If new methods/ciphers
161 * etc will be added, the bits a likely to change, so this information
162 * is for internal library use only, even though SSL_CIPHER.algorithms
163 * can be publicly accessed.
164 * Use the according functions for cipher management instead.
165 *
166 * The bit mask handling in the selection and sorting scheme in
167 * ssl_create_cipher_list() has only limited capabilities, reflecting
168 * that the different entities within are mutually exclusive:
169 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
170 */
158#define SSL_MKEY_MASK 0x0000001FL 171#define SSL_MKEY_MASK 0x0000001FL
159#define SSL_kRSA 0x00000001L /* RSA key exchange */ 172#define SSL_kRSA 0x00000001L /* RSA key exchange */
160#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */ 173#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */
@@ -191,36 +204,75 @@
191#define SSL_SHA1 0x00040000L 204#define SSL_SHA1 0x00040000L
192#define SSL_SHA (SSL_SHA1) 205#define SSL_SHA (SSL_SHA1)
193 206
194#define SSL_EXP_MASK 0x00300000L 207#define SSL_SSL_MASK 0x00180000L
195#define SSL_EXP40 0x00100000L 208#define SSL_SSLV2 0x00080000L
196#define SSL_NOT_EXP 0x00200000L 209#define SSL_SSLV3 0x00100000L
197#define SSL_EXP56 0x00300000L 210#define SSL_TLSV1 SSL_SSLV3 /* for now */
198#define SSL_IS_EXPORT(a) ((a)&SSL_EXP40) 211
199#define SSL_IS_EXPORT56(a) (((a)&SSL_EXP_MASK) == SSL_EXP56) 212/* we have used 001fffff - 11 bits left to go */
200#define SSL_IS_EXPORT40(a) (((a)&SSL_EXP_MASK) == SSL_EXP40) 213
201#define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algorithms) 214/*
202#define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algorithms) 215 * Export and cipher strength information. For each cipher we have to decide
203#define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algorithms) 216 * whether it is exportable or not. This information is likely to change
204#define SSL_EXPORT_KEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 5 : \ 217 * over time, since the export control rules are no static technical issue.
218 *
219 * Independent of the export flag the cipher strength is sorted into classes.
220 * SSL_EXP40 was denoting the 40bit US export limit of past times, which now
221 * is at 56bit (SSL_EXP56). If the exportable cipher class is going to change
222 * again (eg. to 64bit) the use of "SSL_EXP*" becomes blurred even more,
223 * since SSL_EXP64 could be similar to SSL_LOW.
224 * For this reason SSL_MICRO and SSL_MINI macros are included to widen the
225 * namespace of SSL_LOW-SSL_HIGH to lower values. As development of speed
226 * and ciphers goes, another extension to SSL_SUPER and/or SSL_ULTRA would
227 * be possible.
228 */
229#define SSL_EXP_MASK 0x00000003L
230#define SSL_NOT_EXP 0x00000001L
231#define SSL_EXPORT 0x00000002L
232
233#define SSL_STRONG_MASK 0x0000007cL
234#define SSL_EXP40 0x00000004L
235#define SSL_MICRO (SSL_EXP40)
236#define SSL_EXP56 0x00000008L
237#define SSL_MINI (SSL_EXP56)
238#define SSL_LOW 0x00000010L
239#define SSL_MEDIUM 0x00000020L
240#define SSL_HIGH 0x00000040L
241
242/* we have used 0000007f - 25 bits left to go */
243
244/*
245 * Macros to check the export status and cipher strength for export ciphers.
246 * Even though the macros for EXPORT and EXPORT40/56 have similar names,
247 * their meaning is different:
248 * *_EXPORT macros check the 'exportable' status.
249 * *_EXPORT40/56 macros are used to check whether a certain cipher strength
250 * is given.
251 * Since the SSL_IS_EXPORT* and SSL_EXPORT* macros depend on the correct
252 * algorithm structure element to be passed (algorithms, algo_strength) and no
253 * typechecking can be done as they are all of type unsigned long, their
254 * direct usage is discouraged.
255 * Use the SSL_C_* macros instead.
256 */
257#define SSL_IS_EXPORT(a) ((a)&SSL_EXPORT)
258#define SSL_IS_EXPORT56(a) ((a)&SSL_EXP56)
259#define SSL_IS_EXPORT40(a) ((a)&SSL_EXP40)
260#define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algo_strength)
261#define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algo_strength)
262#define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algo_strength)
263
264#define SSL_EXPORT_KEYLENGTH(a,s) (SSL_IS_EXPORT40(s) ? 5 : \
205 ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7) 265 ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7)
206#define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024) 266#define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024)
207#define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithms) 267#define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithms, \
208#define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algorithms) 268 (c)->algo_strength)
209 269#define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algo_strength)
210#define SSL_SSL_MASK 0x00c00000L
211#define SSL_SSLV2 0x00400000L
212#define SSL_SSLV3 0x00800000L
213#define SSL_TLSV1 SSL_SSLV3 /* for now */
214 270
215#define SSL_STRONG_MASK 0x07000000L
216#define SSL_LOW 0x01000000L
217#define SSL_MEDIUM 0x02000000L
218#define SSL_HIGH 0x04000000L
219 271
220/* we have used 0fffffff - 4 bits left to go */
221#define SSL_ALL 0xffffffffL 272#define SSL_ALL 0xffffffffL
222#define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\ 273#define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\
223 SSL_MAC_MASK|SSL_EXP_MASK) 274 SSL_MAC_MASK)
275#define SSL_ALL_STRENGTHS (SSL_EXP_MASK|SSL_STRONG_MASK)
224 276
225/* Mostly for SSLv3 */ 277/* Mostly for SSLv3 */
226#define SSL_PKEY_RSA_ENC 0 278#define SSL_PKEY_RSA_ENC 0
@@ -254,9 +306,9 @@ typedef struct cert_st
254 { 306 {
255 /* Current active set */ 307 /* Current active set */
256 CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array 308 CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array
257 * Probably it would make more sense to store 309 * Probably it would make more sense to store
258 * an index, not a pointer. */ 310 * an index, not a pointer. */
259 311
260 /* The following masks are for the key and auth 312 /* The following masks are for the key and auth
261 * algorithms that are supported by the certs below */ 313 * algorithms that are supported by the certs below */
262 int valid; 314 int valid;
@@ -319,28 +371,28 @@ typedef struct sess_cert_st
319 371
320/* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff 372/* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff
321 * It is a bit of a mess of functions, but hell, think of it as 373 * It is a bit of a mess of functions, but hell, think of it as
322 * an opaque strucute :-) */ 374 * an opaque structure :-) */
323typedef struct ssl3_enc_method 375typedef struct ssl3_enc_method
324 { 376 {
325 int (*enc)(); 377 int (*enc)(SSL *, int);
326 int (*mac)(); 378 int (*mac)(SSL *, unsigned char *, int);
327 int (*setup_key_block)(); 379 int (*setup_key_block)(SSL *);
328 int (*generate_master_secret)(); 380 int (*generate_master_secret)(SSL *, unsigned char *, unsigned char *, int);
329 int (*change_cipher_state)(); 381 int (*change_cipher_state)(SSL *, int);
330 int (*final_finish_mac)(); 382 int (*final_finish_mac)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char *, int, unsigned char *);
331 int finish_mac_length; 383 int finish_mac_length;
332 int (*cert_verify_mac)(); 384 int (*cert_verify_mac)(SSL *, EVP_MD_CTX *, unsigned char *);
333 unsigned char client_finished[20]; 385 const char *client_finished_label;
334 int client_finished_len; 386 int client_finished_label_len;
335 unsigned char server_finished[20]; 387 const char *server_finished_label;
336 int server_finished_len; 388 int server_finished_label_len;
337 int (*alert_value)(); 389 int (*alert_value)(int);
338 } SSL3_ENC_METHOD; 390 } SSL3_ENC_METHOD;
339 391
340/* Used for holding the relevant compression methods loaded into SSL_CTX */ 392/* Used for holding the relevant compression methods loaded into SSL_CTX */
341typedef struct ssl3_comp_st 393typedef struct ssl3_comp_st
342 { 394 {
343 int comp_id; /* The identifer byte for this compression type */ 395 int comp_id; /* The identifier byte for this compression type */
344 char *name; /* Text name used for the compression type */ 396 char *name; /* Text name used for the compression type */
345 COMP_METHOD *method; /* The method :-) */ 397 COMP_METHOD *method; /* The method :-) */
346 } SSL3_COMP; 398 } SSL3_COMP;
@@ -376,10 +428,10 @@ int ssl_cipher_ptr_id_cmp(SSL_CIPHER **ap,SSL_CIPHER **bp);
376STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, 428STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
377 STACK_OF(SSL_CIPHER) **skp); 429 STACK_OF(SSL_CIPHER) **skp);
378int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p); 430int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p);
379STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *meth, 431STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth,
380 STACK_OF(SSL_CIPHER) **pref, 432 STACK_OF(SSL_CIPHER) **pref,
381 STACK_OF(SSL_CIPHER) **sorted, 433 STACK_OF(SSL_CIPHER) **sorted,
382 char *str); 434 const char *rule_str);
383void ssl_update_cache(SSL *s, int mode); 435void ssl_update_cache(SSL *s, int mode);
384int ssl_cipher_get_evp(SSL_SESSION *s,const EVP_CIPHER **enc,const EVP_MD **md, 436int ssl_cipher_get_evp(SSL_SESSION *s,const EVP_CIPHER **enc,const EVP_MD **md,
385 SSL_COMP **comp); 437 SSL_COMP **comp);
@@ -416,6 +468,8 @@ int ssl2_shutdown(SSL *s);
416void ssl2_clear(SSL *s); 468void ssl2_clear(SSL *s);
417long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg); 469long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg);
418long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 470long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg);
471long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)());
472long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
419int ssl2_pending(SSL *s); 473int ssl2_pending(SSL *s);
420 474
421SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); 475SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
@@ -433,17 +487,16 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out,
433 unsigned char *p, int len); 487 unsigned char *p, int len);
434int ssl3_get_req_cert_type(SSL *s,unsigned char *p); 488int ssl3_get_req_cert_type(SSL *s,unsigned char *p);
435long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); 489long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
436int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender,int slen); 490int ssl3_send_finished(SSL *s, int a, int b, const char *sender,int slen);
437int ssl3_num_ciphers(void); 491int ssl3_num_ciphers(void);
438SSL_CIPHER *ssl3_get_cipher(unsigned int u); 492SSL_CIPHER *ssl3_get_cipher(unsigned int u);
439int ssl3_renegotiate(SSL *ssl); 493int ssl3_renegotiate(SSL *ssl);
440int ssl3_renegotiate_check(SSL *ssl); 494int ssl3_renegotiate_check(SSL *ssl);
441int ssl3_dispatch_alert(SSL *s); 495int ssl3_dispatch_alert(SSL *s);
442int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len); 496int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len);
443int ssl3_part_read(SSL *s, int i);
444int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); 497int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
445int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1,EVP_MD_CTX *ctx2, 498int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2,
446 unsigned char *sender, int slen,unsigned char *p); 499 const char *sender, int slen,unsigned char *p);
447int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); 500int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
448void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len); 501void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
449int ssl3_enc(SSL *s, int send_data); 502int ssl3_enc(SSL *s, int send_data);
@@ -463,6 +516,8 @@ int ssl3_shutdown(SSL *s);
463void ssl3_clear(SSL *s); 516void ssl3_clear(SSL *s);
464long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg); 517long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg);
465long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 518long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg);
519long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)());
520long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
466int ssl3_pending(SSL *s); 521int ssl3_pending(SSL *s);
467 522
468int ssl23_accept(SSL *s); 523int ssl23_accept(SSL *s);
@@ -474,6 +529,7 @@ int tls1_new(SSL *s);
474void tls1_free(SSL *s); 529void tls1_free(SSL *s);
475void tls1_clear(SSL *s); 530void tls1_clear(SSL *s);
476long tls1_ctrl(SSL *s,int cmd, long larg, char *parg); 531long tls1_ctrl(SSL *s,int cmd, long larg, char *parg);
532long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)());
477SSL_METHOD *tlsv1_base_method(void ); 533SSL_METHOD *tlsv1_base_method(void );
478 534
479int ssl_init_wbio_buffer(SSL *s, int push); 535int ssl_init_wbio_buffer(SSL *s, int push);
@@ -483,7 +539,7 @@ int tls1_change_cipher_state(SSL *s, int which);
483int tls1_setup_key_block(SSL *s); 539int tls1_setup_key_block(SSL *s);
484int tls1_enc(SSL *s, int snd); 540int tls1_enc(SSL *s, int snd);
485int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, 541int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
486 unsigned char *str, int slen, unsigned char *p); 542 const char *str, int slen, unsigned char *p);
487int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); 543int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
488int tls1_mac(SSL *ssl, unsigned char *md, int snd); 544int tls1_mac(SSL *ssl, unsigned char *md, int snd);
489int tls1_generate_master_secret(SSL *s, unsigned char *out, 545int tls1_generate_master_secret(SSL *s, unsigned char *out,
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c
index 681499f08a..9e01f72753 100644
--- a/src/lib/libssl/src/ssl/ssl_sess.c
+++ b/src/lib/libssl/src/ssl/ssl_sess.c
@@ -65,15 +65,31 @@ static 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; 67static int ssl_session_num=0;
68static STACK *ssl_session_meth=NULL; 68static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_session_meth=NULL;
69 69
70SSL_SESSION *SSL_get_session(SSL *ssl) 70SSL_SESSION *SSL_get_session(SSL *ssl)
71/* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */
71 { 72 {
72 return(ssl->session); 73 return(ssl->session);
73 } 74 }
74 75
75int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func)(), 76SSL_SESSION *SSL_get1_session(SSL *ssl)
76 int (*dup_func)(), void (*free_func)()) 77/* variant of SSL_get_session: caller really gets something */
78 {
79 SSL_SESSION *sess;
80 /* Need to lock this all up rather than just use CRYPTO_add so that
81 * somebody doesn't free ssl->session between when we check it's
82 * non-null and when we up the reference count. */
83 CRYPTO_r_lock(CRYPTO_LOCK_SSL_SESSION);
84 sess = ssl->session;
85 if(sess)
86 sess->references++;
87 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_SESSION);
88 return(sess);
89 }
90
91int 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)
77 { 93 {
78 ssl_session_num++; 94 ssl_session_num++;
79 return(CRYPTO_get_ex_new_index(ssl_session_num-1, 95 return(CRYPTO_get_ex_new_index(ssl_session_num-1,
@@ -103,13 +119,14 @@ SSL_SESSION *SSL_SESSION_new(void)
103 } 119 }
104 memset(ss,0,sizeof(SSL_SESSION)); 120 memset(ss,0,sizeof(SSL_SESSION));
105 121
122 ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */
106 ss->references=1; 123 ss->references=1;
107 ss->timeout=60*5+4; /* 5 minute timeout by default */ 124 ss->timeout=60*5+4; /* 5 minute timeout by default */
108 ss->time=time(NULL); 125 ss->time=time(NULL);
109 ss->prev=NULL; 126 ss->prev=NULL;
110 ss->next=NULL; 127 ss->next=NULL;
111 ss->compress_meth=0; 128 ss->compress_meth=0;
112 CRYPTO_new_ex_data(ssl_session_meth,(char *)ss,&ss->ex_data); 129 CRYPTO_new_ex_data(ssl_session_meth,ss,&ss->ex_data);
113 return(ss); 130 return(ss);
114 } 131 }
115 132
@@ -161,15 +178,20 @@ int ssl_get_new_session(SSL *s, int session)
161 { 178 {
162 SSL_SESSION *r; 179 SSL_SESSION *r;
163 180
164 RAND_bytes(ss->session_id,ss->session_id_length); 181 RAND_pseudo_bytes(ss->session_id,ss->session_id_length);
165 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); 182 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
166 r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, 183 r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, ss);
167 (char *)ss);
168 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); 184 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
169 if (r == NULL) break; 185 if (r == NULL) break;
170 /* else - woops a session_id match */ 186 /* else - woops a session_id match */
171 /* XXX should also check external cache! 187 /* XXX We should also check the external cache --
172 * (But the probability of a collision is negligible, anyway...) */ 188 * but the probability of a collision is negligible, and
189 * we could not prevent the concurrent creation of sessions
190 * with identical IDs since we currently don't have means
191 * to atomically check whether a session ID already exists
192 * and make a reservation for it if it does not
193 * (this problem applies to the internal cache as well).
194 */
173 } 195 }
174 } 196 }
175 else 197 else
@@ -181,6 +203,7 @@ int ssl_get_new_session(SSL *s, int session)
181 ss->sid_ctx_length=s->sid_ctx_length; 203 ss->sid_ctx_length=s->sid_ctx_length;
182 s->session=ss; 204 s->session=ss;
183 ss->ssl_version=s->version; 205 ss->ssl_version=s->version;
206 ss->verify_result = X509_V_OK;
184 207
185 return(1); 208 return(1);
186 } 209 }
@@ -192,7 +215,6 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
192 SSL_SESSION *ret=NULL,data; 215 SSL_SESSION *ret=NULL,data;
193 int fatal = 0; 216 int fatal = 0;
194 217
195 /* conn_init();*/
196 data.ssl_version=s->version; 218 data.ssl_version=s->version;
197 data.session_id_length=len; 219 data.session_id_length=len;
198 if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) 220 if (len > SSL_MAX_SSL_SESSION_ID_LENGTH)
@@ -202,7 +224,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
202 if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) 224 if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP))
203 { 225 {
204 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); 226 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
205 ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,(char *)&data); 227 ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,&data);
206 if (ret != NULL) 228 if (ret != NULL)
207 /* don't allow other threads to steal it: */ 229 /* don't allow other threads to steal it: */
208 CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); 230 CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION);
@@ -311,6 +333,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
311 if (s->session != NULL) 333 if (s->session != NULL)
312 SSL_SESSION_free(s->session); 334 SSL_SESSION_free(s->session);
313 s->session=ret; 335 s->session=ret;
336 s->verify_result = s->session->verify_result;
314 return(1); 337 return(1);
315 338
316 err: 339 err:
@@ -327,27 +350,47 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c)
327 int ret=0; 350 int ret=0;
328 SSL_SESSION *s; 351 SSL_SESSION *s;
329 352
330 /* conn_init(); */ 353 /* add just 1 reference count for the SSL_CTX's session cache
354 * even though it has two ways of access: each session is in a
355 * doubly linked list and an lhash */
331 CRYPTO_add(&c->references,1,CRYPTO_LOCK_SSL_SESSION); 356 CRYPTO_add(&c->references,1,CRYPTO_LOCK_SSL_SESSION);
357 /* if session c is in already in cache, we take back the increment later */
332 358
333 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 359 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
334 s=(SSL_SESSION *)lh_insert(ctx->sessions,(char *)c); 360 s=(SSL_SESSION *)lh_insert(ctx->sessions,c);
335 361
336 /* Put on the end of the queue unless it is already in the cache */ 362 /* s != NULL iff we already had a session with the given PID.
363 * In this case, s == c should hold (then we did not really modify
364 * ctx->sessions), or we're in trouble. */
365 if (s != NULL && s != c)
366 {
367 /* We *are* in trouble ... */
368 SSL_SESSION_list_remove(ctx,s);
369 SSL_SESSION_free(s);
370 /* ... so pretend the other session did not exist in cache
371 * (we cannot handle two SSL_SESSION structures with identical
372 * session ID in the same cache, which could happen e.g. when
373 * two threads concurrently obtain the same session from an external
374 * cache) */
375 s = NULL;
376 }
377
378 /* Put at the head of the queue unless it is already in the cache */
337 if (s == NULL) 379 if (s == NULL)
338 SSL_SESSION_list_add(ctx,c); 380 SSL_SESSION_list_add(ctx,c);
339 381
340 /* If the same session if is being 're-added', Free the old
341 * one when the last person stops using it.
342 * This will also work if it is alread in the cache.
343 * The references will go up and then down :-) */
344 if (s != NULL) 382 if (s != NULL)
345 { 383 {
346 SSL_SESSION_free(s); 384 /* existing cache entry -- decrement previously incremented reference
385 * count because it already takes into account the cache */
386
387 SSL_SESSION_free(s); /* s == c */
347 ret=0; 388 ret=0;
348 } 389 }
349 else 390 else
350 { 391 {
392 /* new cache entry -- remove old ones if cache has become too large */
393
351 ret=1; 394 ret=1;
352 395
353 if (SSL_CTX_sess_get_cache_size(ctx) > 0) 396 if (SSL_CTX_sess_get_cache_size(ctx) > 0)
@@ -380,7 +423,7 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
380 if ((c != NULL) && (c->session_id_length != 0)) 423 if ((c != NULL) && (c->session_id_length != 0))
381 { 424 {
382 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 425 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
383 r=(SSL_SESSION *)lh_delete(ctx->sessions,(char *)c); 426 r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
384 if (r != NULL) 427 if (r != NULL)
385 { 428 {
386 ret=1; 429 ret=1;
@@ -422,7 +465,7 @@ void SSL_SESSION_free(SSL_SESSION *ss)
422 } 465 }
423#endif 466#endif
424 467
425 CRYPTO_free_ex_data(ssl_session_meth,(char *)ss,&ss->ex_data); 468 CRYPTO_free_ex_data(ssl_session_meth,ss,&ss->ex_data);
426 469
427 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); 470 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH);
428 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); 471 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH);
@@ -541,7 +584,7 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p)
541 { 584 {
542 /* The reason we don't call SSL_CTX_remove_session() is to 585 /* The reason we don't call SSL_CTX_remove_session() is to
543 * save on locking overhead */ 586 * save on locking overhead */
544 lh_delete(p->cache,(char *)s); 587 lh_delete(p->cache,s);
545 SSL_SESSION_list_remove(p->ctx,s); 588 SSL_SESSION_list_remove(p->ctx,s);
546 s->not_resumable=1; 589 s->not_resumable=1;
547 if (p->ctx->remove_session_cb != NULL) 590 if (p->ctx->remove_session_cb != NULL)
@@ -562,7 +605,7 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
562 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 605 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
563 i=tp.cache->down_load; 606 i=tp.cache->down_load;
564 tp.cache->down_load=0; 607 tp.cache->down_load=0;
565 lh_doall_arg(tp.cache,(void (*)())timeout,(char *)&tp); 608 lh_doall_arg(tp.cache,(void (*)())timeout,&tp);
566 tp.cache->down_load=i; 609 tp.cache->down_load=i;
567 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); 610 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
568 } 611 }
diff --git a/src/lib/libssl/src/ssl/ssl_stat.c b/src/lib/libssl/src/ssl/ssl_stat.c
index 3eca4ee601..8e12461f3b 100644
--- a/src/lib/libssl/src/ssl/ssl_stat.c
+++ b/src/lib/libssl/src/ssl/ssl_stat.c
@@ -183,7 +183,7 @@ case 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(NO_SSL2) && !defined(NO_SSL3)
186/* SSLv2/v3 compatablitity 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;
189case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break; 189case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break;
@@ -331,7 +331,7 @@ case 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(NO_SSL2) && !defined(NO_SSL3)
334/* SSLv2/v3 compatablitity 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;
337case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break; 337case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break;
@@ -402,7 +402,7 @@ char *SSL_alert_desc_string_long(int value)
402 str="close notify"; 402 str="close notify";
403 break; 403 break;
404 case SSL3_AD_UNEXPECTED_MESSAGE: 404 case SSL3_AD_UNEXPECTED_MESSAGE:
405 str="unexected_message"; 405 str="unexpected_message";
406 break; 406 break;
407 case SSL3_AD_BAD_RECORD_MAC: 407 case SSL3_AD_BAD_RECORD_MAC:
408 str="bad record mac"; 408 str="bad record mac";
@@ -429,7 +429,7 @@ char *SSL_alert_desc_string_long(int value)
429 str="certificate expired"; 429 str="certificate expired";
430 break; 430 break;
431 case SSL3_AD_CERTIFICATE_UNKNOWN: 431 case SSL3_AD_CERTIFICATE_UNKNOWN:
432 str="certifcate unknown"; 432 str="certificate unknown";
433 break; 433 break;
434 case SSL3_AD_ILLEGAL_PARAMETER: 434 case SSL3_AD_ILLEGAL_PARAMETER:
435 str="illegal parameter"; 435 str="illegal parameter";
diff --git a/src/lib/libssl/src/ssl/ssl_task.c b/src/lib/libssl/src/ssl/ssl_task.c
index 321e35c83b..cac701a798 100644
--- a/src/lib/libssl/src/ssl/ssl_task.c
+++ b/src/lib/libssl/src/ssl/ssl_task.c
@@ -226,7 +226,7 @@ int main ( int argc, char **argv )
226 printf("cipher list: %s\n", cipher ? cipher : "{undefined}" ); 226 printf("cipher list: %s\n", cipher ? cipher : "{undefined}" );
227 227
228 SSL_load_error_strings(); 228 SSL_load_error_strings();
229 SSLeay_add_all_algorithms(); 229 OpenSSL_add_all_algorithms();
230 230
231/* DRM, this was the original, but there is no such thing as SSLv2() 231/* DRM, this was the original, but there is no such thing as SSLv2()
232 s_ctx=SSL_CTX_new(SSLv2()); 232 s_ctx=SSL_CTX_new(SSLv2());
diff --git a/src/lib/libssl/src/ssl/ssl_txt.c b/src/lib/libssl/src/ssl/ssl_txt.c
index ca67a98d89..7e27857bcf 100644
--- a/src/lib/libssl/src/ssl/ssl_txt.c
+++ b/src/lib/libssl/src/ssl/ssl_txt.c
@@ -112,7 +112,7 @@ int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)
112 sprintf(str,"%02X",x->session_id[i]); 112 sprintf(str,"%02X",x->session_id[i]);
113 if (BIO_puts(bp,str) <= 0) goto err; 113 if (BIO_puts(bp,str) <= 0) goto err;
114 } 114 }
115 if (BIO_puts(bp,"\nSession-ID-ctx: ") <= 0) goto err; 115 if (BIO_puts(bp,"\n Session-ID-ctx: ") <= 0) goto err;
116 for (i=0; i<x->sid_ctx_length; i++) 116 for (i=0; i<x->sid_ctx_length; i++)
117 { 117 {
118 sprintf(str,"%02X",x->sid_ctx[i]); 118 sprintf(str,"%02X",x->sid_ctx[i]);
@@ -163,6 +163,11 @@ int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)
163 if (BIO_puts(bp,str) <= 0) goto err; 163 if (BIO_puts(bp,str) <= 0) goto err;
164 } 164 }
165 if (BIO_puts(bp,"\n") <= 0) goto err; 165 if (BIO_puts(bp,"\n") <= 0) goto err;
166
167 if (BIO_puts(bp, " Verify return code ") <= 0) goto err;
168 sprintf(str, "%ld (%s)\n", x->verify_result,
169 X509_verify_cert_error_string(x->verify_result));
170 if (BIO_puts(bp,str) <= 0) goto err;
166 171
167 return(1); 172 return(1);
168err: 173err:
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c
index 90570f4bee..d655bbbd84 100644
--- a/src/lib/libssl/src/ssl/ssltest.c
+++ b/src/lib/libssl/src/ssl/ssltest.c
@@ -56,11 +56,12 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <assert.h>
60#include <errno.h>
61#include <limits.h>
59#include <stdio.h> 62#include <stdio.h>
60#include <stdlib.h> 63#include <stdlib.h>
61#include <string.h> 64#include <string.h>
62#include <errno.h>
63#include <limits.h>
64 65
65#include "openssl/e_os.h" 66#include "openssl/e_os.h"
66 67
@@ -69,14 +70,11 @@
69#include <openssl/x509.h> 70#include <openssl/x509.h>
70#include <openssl/ssl.h> 71#include <openssl/ssl.h>
71#include <openssl/err.h> 72#include <openssl/err.h>
73#include <openssl/rand.h>
72#ifdef WINDOWS 74#ifdef WINDOWS
73#include "../crypto/bio/bss_file.c" 75#include "../crypto/bio/bss_file.c"
74#endif 76#endif
75 77
76#if defined(NO_RSA) && !defined(NO_SSL2)
77#define NO_SSL2
78#endif
79
80#ifdef VMS 78#ifdef VMS
81# define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" 79# define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM"
82# define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" 80# define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM"
@@ -85,19 +83,23 @@
85# define TEST_CLIENT_CERT "../apps/client.pem" 83# define TEST_CLIENT_CERT "../apps/client.pem"
86#endif 84#endif
87 85
88int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx); 86static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
89#ifndef NO_RSA 87#ifndef NO_RSA
90static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength); 88static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
91#endif 89#endif
92#ifndef NO_DH 90#ifndef NO_DH
93static DH *get_dh512(void); 91static DH *get_dh512(void);
94#endif 92#endif
95BIO *bio_err=NULL; 93#ifndef NO_DSA
96BIO *bio_stdout=NULL; 94static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
95#endif
96
97static BIO *bio_err=NULL;
98static BIO *bio_stdout=NULL;
97 99
98static char *cipher=NULL; 100static char *cipher=NULL;
99int verbose=0; 101static int verbose=0;
100int debug=0; 102static int debug=0;
101#if 0 103#if 0
102/* Not used yet. */ 104/* Not used yet. */
103#ifdef FIONBIO 105#ifdef FIONBIO
@@ -105,6 +107,7 @@ static int s_nbio=0;
105#endif 107#endif
106#endif 108#endif
107 109
110static const char rnd_seed[] = "string to make the random number generator think it has entropy";
108 111
109int doit_biopair(SSL *s_ssl,SSL *c_ssl,long bytes); 112int doit_biopair(SSL *s_ssl,SSL *c_ssl,long bytes);
110int doit(SSL *s_ssl,SSL *c_ssl,long bytes); 113int doit(SSL *s_ssl,SSL *c_ssl,long bytes);
@@ -122,6 +125,9 @@ static void sv_usage(void)
122#if !defined NO_DH && !defined NO_DSA 125#if !defined NO_DH && !defined NO_DSA
123 fprintf(stderr," -dhe1024 - generate 1024 bit key for DHE\n"); 126 fprintf(stderr," -dhe1024 - generate 1024 bit key for DHE\n");
124#endif 127#endif
128#if !defined NO_DH
129 fprintf(stderr," -no_dhe - disable DHE\n");
130#endif
125#ifndef NO_SSL2 131#ifndef NO_SSL2
126 fprintf(stderr," -ssl2 - use SSLv2\n"); 132 fprintf(stderr," -ssl2 - use SSLv2\n");
127#endif 133#endif
@@ -159,16 +165,21 @@ int main(int argc, char *argv[])
159 int number=1,reuse=0; 165 int number=1,reuse=0;
160 long bytes=1L; 166 long bytes=1L;
161 SSL_CIPHER *ciph; 167 SSL_CIPHER *ciph;
162 int dhe1024 = 0; 168 int dhe1024 = 0, no_dhe = 0;
163#ifndef NO_DH 169#ifndef NO_DH
164 DH *dh; 170 DH *dh;
165#endif 171#endif
172 verbose = 0;
173 debug = 0;
174 cipher = 0;
175
176 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
177
178 RAND_seed(rnd_seed, sizeof rnd_seed);
166 179
167 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 180 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
168 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); 181 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
169 182
170 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
171
172 argc--; 183 argc--;
173 argv++; 184 argv++;
174 185
@@ -186,6 +197,8 @@ int main(int argc, char *argv[])
186 reuse=1; 197 reuse=1;
187 else if (strcmp(*argv,"-dhe1024") == 0) 198 else if (strcmp(*argv,"-dhe1024") == 0)
188 dhe1024=1; 199 dhe1024=1;
200 else if (strcmp(*argv,"-no_dhe") == 0)
201 no_dhe=1;
189 else if (strcmp(*argv,"-ssl2") == 0) 202 else if (strcmp(*argv,"-ssl2") == 0)
190 ssl2=1; 203 ssl2=1;
191 else if (strcmp(*argv,"-tls1") == 0) 204 else if (strcmp(*argv,"-tls1") == 0)
@@ -311,31 +324,36 @@ bad:
311 } 324 }
312 325
313#ifndef NO_DH 326#ifndef NO_DH
314# ifndef NO_DSA 327 if (!no_dhe)
315 if (dhe1024)
316 { 328 {
317 DSA *dsa; 329# ifndef NO_DSA
318 330 if (dhe1024)
319 if (verbose)
320 { 331 {
321 fprintf(stdout, "Creating 1024 bit DHE parameters ..."); 332 DSA *dsa;
322 fflush(stdout); 333 unsigned char seed[20];
334
335 if (verbose)
336 {
337 BIO_printf(bio_err, "Creating 1024 bit DHE parameters\n");
338 BIO_flush(bio_err);
339 }
340
341 memcpy(seed, "Random String no. 12", 20);
342 dsa = DSA_generate_parameters(1024, seed, 20, NULL, NULL, dsa_cb, bio_err);
343 dh = DSA_dup_DH(dsa);
344 DSA_free(dsa);
345 /* important: SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */
346 SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE);
347
348 if (verbose)
349 fprintf(stdout, " done\n");
323 } 350 }
324 351 else
325 dsa = DSA_generate_parameters(1024, NULL, 0, NULL, NULL, 0, NULL);
326 dh = DSA_dup_DH(dsa);
327 DSA_free(dsa);
328 /* important: SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */
329 SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE);
330
331 if (verbose)
332 fprintf(stdout, " done\n");
333 }
334 else
335# endif 352# endif
336 dh=get_dh512(); 353 dh=get_dh512();
337 SSL_CTX_set_tmp_dh(s_ctx,dh); 354 SSL_CTX_set_tmp_dh(s_ctx,dh);
338 DH_free(dh); 355 DH_free(dh);
356 }
339#endif 357#endif
340 358
341#ifndef NO_RSA 359#ifndef NO_RSA
@@ -373,17 +391,22 @@ bad:
373 391
374 if (client_auth) 392 if (client_auth)
375 { 393 {
376 fprintf(stderr,"client authentication\n"); 394 BIO_printf(bio_err,"client authentication\n");
377 SSL_CTX_set_verify(s_ctx, 395 SSL_CTX_set_verify(s_ctx,
378 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 396 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
379 verify_callback); 397 verify_callback);
380 } 398 }
381 if (server_auth) 399 if (server_auth)
382 { 400 {
383 fprintf(stderr,"server authentication\n"); 401 BIO_printf(bio_err,"server authentication\n");
384 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER, 402 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,
385 verify_callback); 403 verify_callback);
386 } 404 }
405
406 {
407 int session_id_context = 0;
408 SSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context, sizeof session_id_context);
409 }
387 410
388 c_ssl=SSL_new(c_ctx); 411 c_ssl=SSL_new(c_ctx);
389 s_ssl=SSL_new(s_ctx); 412 s_ssl=SSL_new(s_ctx);
@@ -400,13 +423,13 @@ bad:
400 if (!verbose) 423 if (!verbose)
401 { 424 {
402 ciph=SSL_get_current_cipher(c_ssl); 425 ciph=SSL_get_current_cipher(c_ssl);
403 fprintf(stdout,"Protocol %s, cipher %s, %s\n", 426 BIO_printf(bio_stdout,"Protocol %s, cipher %s, %s\n",
404 SSL_get_version(c_ssl), 427 SSL_get_version(c_ssl),
405 SSL_CIPHER_get_version(ciph), 428 SSL_CIPHER_get_version(ciph),
406 SSL_CIPHER_get_name(ciph)); 429 SSL_CIPHER_get_name(ciph));
407 } 430 }
408 if ((number > 1) || (bytes > 1L)) 431 if ((number > 1) || (bytes > 1L))
409 printf("%d handshakes of %ld bytes done\n",number,bytes); 432 BIO_printf(bio_stdout, "%d handshakes of %ld bytes done\n",number,bytes);
410 433
411 SSL_free(s_ssl); 434 SSL_free(s_ssl);
412 SSL_free(c_ssl); 435 SSL_free(c_ssl);
@@ -421,6 +444,7 @@ end:
421 ERR_remove_state(0); 444 ERR_remove_state(0);
422 EVP_cleanup(); 445 EVP_cleanup();
423 CRYPTO_mem_leaks(bio_err); 446 CRYPTO_mem_leaks(bio_err);
447 if (bio_err != NULL) BIO_free(bio_err);
424 EXIT(ret); 448 EXIT(ret);
425 } 449 }
426 450
@@ -485,7 +509,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
485 * BIO_ctrl_pending(bio) number of bytes we can read now 509 * BIO_ctrl_pending(bio) number of bytes we can read now
486 * BIO_ctrl_get_read_request(bio) number of bytes needed to fulfil 510 * BIO_ctrl_get_read_request(bio) number of bytes needed to fulfil
487 * other side's read attempt 511 * other side's read attempt
488 * BIO_ctrl_get_write_gurantee(bio) number of bytes we can write now 512 * BIO_ctrl_get_write_guarantee(bio) number of bytes we can write now
489 * 513 *
490 * ..._read_request is never more than ..._write_guarantee; 514 * ..._read_request is never more than ..._write_guarantee;
491 * it depends on the application which one you should use. 515 * it depends on the application which one you should use.
@@ -517,7 +541,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
517 else 541 else
518 i = (int)cw_num; 542 i = (int)cw_num;
519 r = BIO_write(c_ssl_bio, cbuf, i); 543 r = BIO_write(c_ssl_bio, cbuf, i);
520 if (r == -1) 544 if (r < 0)
521 { 545 {
522 if (!BIO_should_retry(c_ssl_bio)) 546 if (!BIO_should_retry(c_ssl_bio))
523 { 547 {
@@ -590,7 +614,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
590 else 614 else
591 i = (int)sw_num; 615 i = (int)sw_num;
592 r = BIO_write(s_ssl_bio, sbuf, i); 616 r = BIO_write(s_ssl_bio, sbuf, i);
593 if (r == -1) 617 if (r < 0)
594 { 618 {
595 if (!BIO_should_retry(s_ssl_bio)) 619 if (!BIO_should_retry(s_ssl_bio))
596 { 620 {
@@ -643,45 +667,40 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
643 { 667 {
644 /* "I/O" BETWEEN CLIENT AND SERVER. */ 668 /* "I/O" BETWEEN CLIENT AND SERVER. */
645 669
646#define RELAYBUFSIZ 200
647 static char buf[RELAYBUFSIZ];
648
649 /* RELAYBUF is arbitrary. When writing data over some real
650 * network, use a buffer of the same size as in the BIO_pipe
651 * and make that size large (for reading from the network
652 * small buffers usually won't hurt).
653 * Here sizes differ for testing. */
654
655 size_t r1, r2; 670 size_t r1, r2;
656 size_t num; 671 BIO *io1 = server_io, *io2 = client_io;
657 int r; 672 /* we use the non-copying interface for io1
673 * and the standard BIO_write/BIO_read interface for io2
674 */
675
658 static int prev_progress = 1; 676 static int prev_progress = 1;
659 int progress = 0; 677 int progress = 0;
660 678
661 /* client to server */ 679 /* io1 to io2 */
662 do 680 do
663 { 681 {
664 r1 = BIO_ctrl_pending(client_io); 682 size_t num;
665 r2 = BIO_ctrl_get_write_guarantee(server_io); 683 int r;
684
685 r1 = BIO_ctrl_pending(io1);
686 r2 = BIO_ctrl_get_write_guarantee(io2);
666 687
667 num = r1; 688 num = r1;
668 if (r2 < num) 689 if (r2 < num)
669 num = r2; 690 num = r2;
670 if (num) 691 if (num)
671 { 692 {
672 if (sizeof buf < num) 693 char *dataptr;
673 num = sizeof buf; 694
674 if (INT_MAX < num) /* yeah, right */ 695 if (INT_MAX < num) /* yeah, right */
675 num = INT_MAX; 696 num = INT_MAX;
676 697
677 r = BIO_read(client_io, buf, (int)num); 698 r = BIO_nread(io1, &dataptr, (int)num);
678 if (r != (int)num) /* can't happen */ 699 assert(r > 0);
679 { 700 assert(r <= (int)num);
680 fprintf(stderr, "ERROR: BIO_read could not read " 701 /* possibly r < num (non-contiguous data) */
681 "BIO_ctrl_pending() bytes"); 702 num = r;
682 goto err; 703 r = BIO_write(io2, dataptr, (int)num);
683 }
684 r = BIO_write(server_io, buf, (int)num);
685 if (r != (int)num) /* can't happen */ 704 if (r != (int)num) /* can't happen */
686 { 705 {
687 fprintf(stderr, "ERROR: BIO_write could not write " 706 fprintf(stderr, "ERROR: BIO_write could not write "
@@ -691,48 +710,58 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
691 progress = 1; 710 progress = 1;
692 711
693 if (debug) 712 if (debug)
694 printf("C->S relaying: %d bytes\n", (int)num); 713 printf((io1 == client_io) ?
714 "C->S relaying: %d bytes\n" :
715 "S->C relaying: %d bytes\n",
716 (int)num);
695 } 717 }
696 } 718 }
697 while (r1 && r2); 719 while (r1 && r2);
698 720
699 /* server to client */ 721 /* io2 to io1 */
700 do 722 {
701 { 723 size_t num;
702 r1 = BIO_ctrl_pending(server_io); 724 int r;
703 r2 = BIO_ctrl_get_write_guarantee(client_io); 725
704 726 r1 = BIO_ctrl_pending(io2);
727 r2 = BIO_ctrl_get_read_request(io1);
728 /* here we could use ..._get_write_guarantee instead of
729 * ..._get_read_request, but by using the latter
730 * we test restartability of the SSL implementation
731 * more thoroughly */
705 num = r1; 732 num = r1;
706 if (r2 < num) 733 if (r2 < num)
707 num = r2; 734 num = r2;
708 if (num) 735 if (num)
709 { 736 {
710 if (sizeof buf < num) 737 char *dataptr;
711 num = sizeof buf; 738
712 if (INT_MAX < num) 739 if (INT_MAX < num)
713 num = INT_MAX; 740 num = INT_MAX;
741
742 if (num > 1)
743 --num; /* test restartability even more thoroughly */
714 744
715 r = BIO_read(server_io, buf, (int)num); 745 r = BIO_nwrite(io1, &dataptr, (int)num);
746 assert(r > 0);
747 assert(r <= (int)num);
748 num = r;
749 r = BIO_read(io2, dataptr, (int)num);
716 if (r != (int)num) /* can't happen */ 750 if (r != (int)num) /* can't happen */
717 { 751 {
718 fprintf(stderr, "ERROR: BIO_read could not read " 752 fprintf(stderr, "ERROR: BIO_read could not read "
719 "BIO_ctrl_pending() bytes"); 753 "BIO_ctrl_pending() bytes");
720 goto err; 754 goto err;
721 } 755 }
722 r = BIO_write(client_io, buf, (int)num);
723 if (r != (int)num) /* can't happen */
724 {
725 fprintf(stderr, "ERROR: BIO_write could not write "
726 "BIO_ctrl_get_write_guarantee() bytes");
727 goto err;
728 }
729 progress = 1; 756 progress = 1;
730 757
731 if (debug) 758 if (debug)
732 printf("S->C relaying: %d bytes\n", (int)num); 759 printf((io2 == client_io) ?
760 "C->S relaying: %d bytes\n" :
761 "S->C relaying: %d bytes\n",
762 (int)num);
733 } 763 }
734 } 764 } /* no loop, BIO_ctrl_get_read_request now returns 0 anyway */
735 while (r1 && r2);
736 765
737 if (!progress && !prev_progress) 766 if (!progress && !prev_progress)
738 if (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0) 767 if (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0)
@@ -1091,7 +1120,7 @@ err:
1091 return(ret); 1120 return(ret);
1092 } 1121 }
1093 1122
1094int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx) 1123static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
1095 { 1124 {
1096 char *s,buf[256]; 1125 char *s,buf[256];
1097 1126
@@ -1161,3 +1190,24 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
1161 return(rsa_tmp); 1190 return(rsa_tmp);
1162 } 1191 }
1163#endif 1192#endif
1193
1194#ifndef NO_DSA
1195static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
1196 {
1197 char c='*';
1198 static int ok=0,num=0;
1199
1200 if (p == 0) { c='.'; num++; };
1201 if (p == 1) c='+';
1202 if (p == 2) { c='*'; ok++; }
1203 if (p == 3) c='\n';
1204 BIO_write(arg,&c,1);
1205 (void)BIO_flush(arg);
1206
1207 if (!ok && (p == 0) && (num > 1))
1208 {
1209 BIO_printf((BIO *)arg,"error in dsatest\n");
1210 exit(1);
1211 }
1212 }
1213#endif
diff --git a/src/lib/libssl/src/ssl/t1_enc.c b/src/lib/libssl/src/ssl/t1_enc.c
index 914b743498..279e45db5d 100644
--- a/src/lib/libssl/src/ssl/t1_enc.c
+++ b/src/lib/libssl/src/ssl/t1_enc.c
@@ -494,7 +494,7 @@ int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in_ctx, unsigned char *out)
494 } 494 }
495 495
496int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, 496int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
497 unsigned char *str, int slen, unsigned char *out) 497 const char *str, int slen, unsigned char *out)
498 { 498 {
499 unsigned int i; 499 unsigned int i;
500 EVP_MD_CTX ctx; 500 EVP_MD_CTX ctx;
@@ -621,11 +621,11 @@ int tls1_alert_code(int code)
621 case SSL_AD_ACCESS_DENIED: return(TLS1_AD_ACCESS_DENIED); 621 case SSL_AD_ACCESS_DENIED: return(TLS1_AD_ACCESS_DENIED);
622 case SSL_AD_DECODE_ERROR: return(TLS1_AD_DECODE_ERROR); 622 case SSL_AD_DECODE_ERROR: return(TLS1_AD_DECODE_ERROR);
623 case SSL_AD_DECRYPT_ERROR: return(TLS1_AD_DECRYPT_ERROR); 623 case SSL_AD_DECRYPT_ERROR: return(TLS1_AD_DECRYPT_ERROR);
624 case SSL_AD_EXPORT_RESTRICION: return(TLS1_AD_EXPORT_RESTRICION); 624 case SSL_AD_EXPORT_RESTRICTION: return(TLS1_AD_EXPORT_RESTRICTION);
625 case SSL_AD_PROTOCOL_VERSION: return(TLS1_AD_PROTOCOL_VERSION); 625 case SSL_AD_PROTOCOL_VERSION: return(TLS1_AD_PROTOCOL_VERSION);
626 case SSL_AD_INSUFFICIENT_SECURITY:return(TLS1_AD_INSUFFICIENT_SECURITY); 626 case SSL_AD_INSUFFICIENT_SECURITY:return(TLS1_AD_INSUFFICIENT_SECURITY);
627 case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR); 627 case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR);
628 case SSL_AD_USER_CANCLED: return(TLS1_AD_USER_CANCLED); 628 case SSL_AD_USER_CANCELLED: return(TLS1_AD_USER_CANCELLED);
629 case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION); 629 case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION);
630 default: return(-1); 630 default: return(-1);
631 } 631 }
diff --git a/src/lib/libssl/src/ssl/t1_lib.c b/src/lib/libssl/src/ssl/t1_lib.c
index ddf5c15799..ca6c03d5af 100644
--- a/src/lib/libssl/src/ssl/t1_lib.c
+++ b/src/lib/libssl/src/ssl/t1_lib.c
@@ -60,13 +60,9 @@
60#include <openssl/objects.h> 60#include <openssl/objects.h>
61#include "ssl_locl.h" 61#include "ssl_locl.h"
62 62
63char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT; 63const char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT;
64 64
65#ifndef NO_PROTO
66static long tls1_default_timeout(void); 65static long tls1_default_timeout(void);
67#else
68static long tls1_default_timeout();
69#endif
70 66
71static SSL3_ENC_METHOD TLSv1_enc_data={ 67static SSL3_ENC_METHOD TLSv1_enc_data={
72 tls1_enc, 68 tls1_enc,
@@ -105,6 +101,9 @@ static SSL_METHOD TLSv1_data= {
105 ssl_bad_method, 101 ssl_bad_method,
106 tls1_default_timeout, 102 tls1_default_timeout,
107 &TLSv1_enc_data, 103 &TLSv1_enc_data,
104 ssl_undefined_function,
105 ssl3_callback_ctrl,
106 ssl3_ctx_callback_ctrl,
108 }; 107 };
109 108
110static long tls1_default_timeout(void) 109static long tls1_default_timeout(void)
@@ -142,4 +141,9 @@ long tls1_ctrl(SSL *s, int cmd, long larg, char *parg)
142 { 141 {
143 return(0); 142 return(0);
144 } 143 }
144
145long tls1_callback_ctrl(SSL *s, int cmd, void *(*fp)())
146 {
147 return(0);
148 }
145#endif 149#endif
diff --git a/src/lib/libssl/src/ssl/tls1.h b/src/lib/libssl/src/ssl/tls1.h
index a931efa936..6e2b06d34f 100644
--- a/src/lib/libssl/src/ssl/tls1.h
+++ b/src/lib/libssl/src/ssl/tls1.h
@@ -65,7 +65,7 @@
65extern "C" { 65extern "C" {
66#endif 66#endif
67 67
68#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 68#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 1
69 69
70#define TLS1_VERSION 0x0301 70#define TLS1_VERSION 0x0301
71#define TLS1_VERSION_MAJOR 0x03 71#define TLS1_VERSION_MAJOR 0x03
@@ -77,11 +77,11 @@ extern "C" {
77#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ 77#define TLS1_AD_ACCESS_DENIED 49 /* fatal */
78#define TLS1_AD_DECODE_ERROR 50 /* fatal */ 78#define TLS1_AD_DECODE_ERROR 50 /* fatal */
79#define TLS1_AD_DECRYPT_ERROR 51 79#define TLS1_AD_DECRYPT_ERROR 51
80#define TLS1_AD_EXPORT_RESTRICION 60 /* fatal */ 80#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */
81#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ 81#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */
82#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ 82#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */
83#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ 83#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */
84#define TLS1_AD_USER_CANCLED 90 84#define TLS1_AD_USER_CANCELLED 90
85#define TLS1_AD_NO_RENEGOTIATION 100 85#define TLS1_AD_NO_RENEGOTIATION 100
86 86
87#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 87#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060
diff --git a/src/lib/libssl/src/test/Makefile.ssl b/src/lib/libssl/src/test/Makefile.ssl
index ea86520128..dbb523bf15 100644
--- a/src/lib/libssl/src/test/Makefile.ssl
+++ b/src/lib/libssl/src/test/Makefile.ssl
@@ -13,6 +13,7 @@ INSTALLTOP= /usr/local/ssl
13MAKEFILE= Makefile.ssl 13MAKEFILE= Makefile.ssl
14MAKE= make -f $(MAKEFILE) 14MAKE= make -f $(MAKEFILE)
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
16PERL= perl
16 17
17PEX_LIBS= 18PEX_LIBS=
18EX_LIBS= #-lnsl -lsocket 19EX_LIBS= #-lnsl -lsocket
@@ -50,7 +51,7 @@ DHTEST= dhtest
50DSATEST= dsatest 51DSATEST= dsatest
51METHTEST= methtest 52METHTEST= methtest
52SSLTEST= ssltest 53SSLTEST= ssltest
53RSATEST= rsa_oaep_test 54RSATEST= rsa_test
54 55
55EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \ 56EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \
56 $(RC2TEST) $(RC4TEST) $(RC5TEST) \ 57 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
@@ -98,9 +99,9 @@ tags:
98 99
99tests: exe apps \ 100tests: exe apps \
100 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \ 101 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
101 test_rc2 test_rc4 test_rc5 test_bf test_cast \ 102 test_rmd test_rc2 test_rc4 test_rc5 test_bf test_cast \
102 test_rand test_bn test_enc test_x509 test_rsa test_crl test_sid \ 103 test_rand test_bn test_enc test_x509 test_rsa test_crl test_sid \
103 test_reqgen test_req test_pkcs7 test_verify test_dh test_dsa \ 104 test_gen test_req test_pkcs7 test_verify test_dh test_dsa \
104 test_ss test_ssl test_ca 105 test_ss test_ssl test_ca
105 106
106apps: 107apps:
@@ -180,9 +181,10 @@ test_pkcs7:
180 181
181test_bn: 182test_bn:
182 @echo starting big number library test, could take a while... 183 @echo starting big number library test, could take a while...
183 @(./$(BNTEST)|bc) | awk '{ \ 184 @./$(BNTEST) >tmp.bntest
184if ($$0 != "0") {print "error"; exit(1); } \ 185 @echo quit >>tmp.bntest
185if (((NR+1)%64) == 0) print NR+1," tests done"; }' 186 @echo "running bc"
187 @bc tmp.bntest 2>&1 | $(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"'
186 @echo 'test a^b%c implementations' 188 @echo 'test a^b%c implementations'
187 ./$(EXPTEST) 189 ./$(EXPTEST)
188 190
@@ -192,14 +194,15 @@ test_verify:
192 ../apps/openssl verify -CApath ../certs ../certs/*.pem 194 ../apps/openssl verify -CApath ../certs ../certs/*.pem
193 195
194test_dh: 196test_dh:
195 @echo "Generate as set of DH parameters" 197 @echo "Generate a set of DH parameters"
196 ./$(DHTEST) 198 ./$(DHTEST)
197 199
198test_dsa: 200test_dsa:
199 @echo "Generate as set of DSA parameters" 201 @echo "Generate a set of DSA parameters"
200 ./$(DSATEST) 202 ./$(DSATEST)
203 ./$(DSATEST) -app2_1
201 204
202test_reqgen: 205test_gen:
203 @echo "Generate and verify a certificate request" 206 @echo "Generate and verify a certificate request"
204 @sh ./testgen 207 @sh ./testgen
205 208
@@ -226,7 +229,7 @@ dclean:
226 mv -f Makefile.new $(MAKEFILE) 229 mv -f Makefile.new $(MAKEFILE)
227 230
228clean: 231clean:
229 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log 232 rm -f .rnd tmp.bntest *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log
230 233
231$(DLIBSSL): 234$(DLIBSSL):
232 (cd ../ssl; $(MAKE)) 235 (cd ../ssl; $(MAKE))
@@ -325,16 +328,19 @@ destest.o: ../include/openssl/opensslconf.h
325dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h 328dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h
326dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 329dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
327dhtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 330dhtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
331dhtest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
328dhtest.o: ../include/openssl/stack.h 332dhtest.o: ../include/openssl/stack.h
329dsatest.o: ../include/openssl/bio.h ../include/openssl/bn.h 333dsatest.o: ../include/openssl/bio.h ../include/openssl/bn.h
330dsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 334dsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
331dsatest.o: ../include/openssl/dsa.h ../include/openssl/err.h 335dsatest.o: ../include/openssl/dsa.h ../include/openssl/err.h
332dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 336dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
333dsatest.o: ../include/openssl/rand.h ../include/openssl/stack.h 337dsatest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
338dsatest.o: ../include/openssl/stack.h
334exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h 339exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h
335exptest.o: ../include/openssl/crypto.h ../include/openssl/err.h 340exptest.o: ../include/openssl/crypto.h ../include/openssl/err.h
336exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 341exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
337exptest.o: ../include/openssl/rand.h ../include/openssl/stack.h 342exptest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
343exptest.o: ../include/openssl/stack.h
338hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 344hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
339hmactest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 345hmactest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
340hmactest.o: ../include/openssl/cast.h ../include/openssl/crypto.h 346hmactest.o: ../include/openssl/cast.h ../include/openssl/crypto.h
@@ -359,11 +365,12 @@ rc2test.o: ../include/openssl/opensslconf.h ../include/openssl/rc2.h
359rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h 365rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h
360rc5test.o: ../include/openssl/rc5.h 366rc5test.o: ../include/openssl/rc5.h
361rmdtest.o: ../include/openssl/ripemd.h 367rmdtest.o: ../include/openssl/ripemd.h
362rsa_oaep_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h 368rsa_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
363rsa_oaep_test.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 369rsa_test.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
364rsa_oaep_test.o: ../include/openssl/err.h ../include/openssl/opensslconf.h 370rsa_test.o: ../include/openssl/err.h ../include/openssl/opensslconf.h
365rsa_oaep_test.o: ../include/openssl/opensslv.h ../include/openssl/rsa.h 371rsa_test.o: ../include/openssl/opensslv.h ../include/openssl/rand.h
366rsa_oaep_test.o: ../include/openssl/stack.h 372rsa_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
373rsa_test.o: ../include/openssl/stack.h
367sha1test.o: ../include/openssl/sha.h 374sha1test.o: ../include/openssl/sha.h
368shatest.o: ../include/openssl/sha.h 375shatest.o: ../include/openssl/sha.h
369ssltest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 376ssltest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
@@ -378,11 +385,12 @@ ssltest.o: ../include/openssl/md2.h ../include/openssl/md5.h
378ssltest.o: ../include/openssl/mdc2.h ../include/openssl/objects.h 385ssltest.o: ../include/openssl/mdc2.h ../include/openssl/objects.h
379ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 386ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
380ssltest.o: ../include/openssl/pem.h ../include/openssl/pem2.h 387ssltest.o: ../include/openssl/pem.h ../include/openssl/pem2.h
381ssltest.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 388ssltest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
382ssltest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 389ssltest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
383ssltest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 390ssltest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
384ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h 391ssltest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
385ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 392ssltest.o: ../include/openssl/sha.h ../include/openssl/ssl.h
386ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 393ssltest.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
387ssltest.o: ../include/openssl/stack.h ../include/openssl/tls1.h 394ssltest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
388ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 395ssltest.o: ../include/openssl/tls1.h ../include/openssl/x509.h
396ssltest.o: ../include/openssl/x509_vfy.h
diff --git a/src/lib/libssl/src/test/dsa-ca.pem b/src/lib/libssl/src/test/dsa-ca.pem
index 9eb08f3ddd..e69de29bb2 100644
--- a/src/lib/libssl/src/test/dsa-ca.pem
+++ b/src/lib/libssl/src/test/dsa-ca.pem
@@ -1,43 +0,0 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0
4
5svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0
6Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl
7Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/
8par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr
9zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO
10uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5
11rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx
121QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4
13HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827
14MVqOsYxGCb+kez0FoDSTgw==
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew
19ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW
20sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7O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5UUkkle6KtUn6j7RO04UMh
39MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD
40MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa
41C1Q=
42-----END CERTIFICATE-----
43
diff --git a/src/lib/libssl/src/test/dsa-pca.pem b/src/lib/libssl/src/test/dsa-pca.pem
index e3641ad47e..e69de29bb2 100644
--- a/src/lib/libssl/src/test/dsa-pca.pem
+++ b/src/lib/libssl/src/test/dsa-pca.pem
@@ -1,49 +0,0 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4
4
5GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS
6mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt
7of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr
8FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX
9RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd
10qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1
11diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn
12V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h
13hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf
14dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB
19MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G
20lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O
21Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR
225HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl
23aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6
24kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als
25QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe
266NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ
27yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0
28z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB
29nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww
37ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ
38R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5
39JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps
40BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze
41mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO
42VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C
43uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk
44umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
4529nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D
46AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n
475rKUjNBhSg==
48-----END CERTIFICATE-----
49
diff --git a/src/lib/libssl/src/test/maketests.com b/src/lib/libssl/src/test/maketests.com
index e4b052e688..1246d9a077 100644
--- a/src/lib/libssl/src/test/maketests.com
+++ b/src/lib/libssl/src/test/maketests.com
@@ -147,7 +147,7 @@ $ TEST_FILES = "BNTEST,IDEATEST,MD2TEST,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,"+ -
150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_OAEP_TEST" 150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST"
151$ TCPIP_PROGRAMS = ",," 151$ TCPIP_PROGRAMS = ",,"
152$ IF COMPILER .EQS. "VAXC" THEN - 152$ IF COMPILER .EQS. "VAXC" THEN -
153 TCPIP_PROGRAMS = ",SSLTEST," 153 TCPIP_PROGRAMS = ",SSLTEST,"
@@ -730,12 +730,36 @@ $!
730$! Set Up Initial CC Definitions, Possibly With User Ones 730$! Set Up Initial CC Definitions, Possibly With User Ones
731$! 731$!
732$ CCDEFS = "VMS=1,TCPIP_TYPE_''P4'" 732$ CCDEFS = "VMS=1,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"
733$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 757$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
734$ CCEXTRAFLAGS = "" 758$ CCEXTRAFLAGS = ""
735$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 759$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
736$ CCDISABLEWARNINGS = "" 760$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
737$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - 761$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
738 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS 762 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
739$! 763$!
740$! Check To See If The User Entered A Valid Paramter. 764$! Check To See If The User Entered A Valid Paramter.
741$! 765$!
diff --git a/src/lib/libssl/src/test/rsa_test.c b/src/lib/libssl/src/test/rsa_test.c
new file mode 100644
index 0000000000..e5ae0c1f69
--- /dev/null
+++ b/src/lib/libssl/src/test/rsa_test.c
@@ -0,0 +1,314 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "openssl/e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#include <openssl/rand.h>
11#ifdef NO_RSA
12int main(int argc, char *argv[])
13{
14 printf("No RSA support\n");
15 return(0);
16}
17#else
18#include <openssl/rsa.h>
19
20#define SetKey \
21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
22 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
23 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
24 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
25 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
26 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
27 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
28 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
29 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
30 return (sizeof(ctext_ex) - 1);
31
32static int key1(RSA *key, unsigned char *c)
33 {
34 static unsigned char n[] =
35"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
36"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
37"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
38"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
39"\xF5";
40
41 static unsigned char e[] = "\x11";
42
43 static unsigned char d[] =
44"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
45"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
46"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
47"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
48
49 static unsigned char p[] =
50"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
51"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
52"\x0D";
53
54 static unsigned char q[] =
55"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
56"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
57"\x89";
58
59 static unsigned char dmp1[] =
60"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
61"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
62
63 static unsigned char dmq1[] =
64"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
65"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
66"\x51";
67
68 static unsigned char iqmp[] =
69"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
70"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
71
72 static unsigned char ctext_ex[] =
73"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
74"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
75"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
76"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
77
78 SetKey;
79 }
80
81static int key2(RSA *key, unsigned char *c)
82 {
83 static unsigned char n[] =
84"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
85"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
86"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
87"\x34\x77\xCF";
88
89 static unsigned char e[] = "\x3";
90
91 static unsigned char d[] =
92"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
93"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
94"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
95"\xE5\xEB";
96
97 static unsigned char p[] =
98"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
99"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
100
101 static unsigned char q[] =
102"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
103"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
104
105 static unsigned char dmp1[] =
106"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
107"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
108
109 static unsigned char dmq1[] =
110"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
111"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
112
113 static unsigned char iqmp[] =
114"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
115"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
116
117 static unsigned char ctext_ex[] =
118"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
119"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
120"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
121"\x62\x51";
122
123 SetKey;
124 }
125
126static int key3(RSA *key, unsigned char *c)
127 {
128 static unsigned char n[] =
129"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
130"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
131"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
132"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
133"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
134"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
135"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
136"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
137"\xCB";
138
139 static unsigned char e[] = "\x11";
140
141 static unsigned char d[] =
142"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
143"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
144"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
145"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
146"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
147"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
148"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
149"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
150"\xC1";
151
152 static unsigned char p[] =
153"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
154"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
155"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
156"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
157"\x99";
158
159 static unsigned char q[] =
160"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
161"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
162"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
163"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
164"\x03";
165
166 static unsigned char dmp1[] =
167"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
168"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
169"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
170"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
171
172 static unsigned char dmq1[] =
173"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
174"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
175"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
176"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
177
178 static unsigned char iqmp[] =
179"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
180"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
181"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
182"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
183"\xF7";
184
185 static unsigned char ctext_ex[] =
186"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
187"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
188"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
189"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
190"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
191"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
192"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
193"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
194
195 SetKey;
196 }
197
198static int pad_unknown(void)
199{
200 unsigned long l;
201 while ((l = ERR_get_error()) != 0)
202 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
203 return(1);
204 return(0);
205}
206
207static const char rnd_seed[] = "string to make the random number generator think it has entropy";
208
209int main(int argc, char *argv[])
210 {
211 int err=0;
212 int v;
213 RSA *key;
214 unsigned char ptext[256];
215 unsigned char ctext[256];
216 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
217 unsigned char ctext_ex[256];
218 int plen;
219 int clen = 0;
220 int num;
221
222 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
223
224 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
225
226 plen = sizeof(ptext_ex) - 1;
227
228 for (v = 0; v < 3; v++)
229 {
230 key = RSA_new();
231 switch (v) {
232 case 0:
233 clen = key1(key, ctext_ex);
234 break;
235 case 1:
236 clen = key2(key, ctext_ex);
237 break;
238 case 2:
239 clen = key3(key, ctext_ex);
240 break;
241 }
242
243 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
244 RSA_PKCS1_PADDING);
245 if (num != clen)
246 {
247 printf("PKCS#1 v1.5 encryption failed!\n");
248 err=1;
249 goto oaep;
250 }
251
252 num = RSA_private_decrypt(num, ctext, ptext, key,
253 RSA_PKCS1_PADDING);
254 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
255 {
256 printf("PKCS#1 v1.5 decryption failed!\n");
257 err=1;
258 }
259 else
260 printf("PKCS #1 v1.5 encryption/decryption ok\n");
261
262 oaep:
263 ERR_clear_error();
264 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
265 RSA_PKCS1_OAEP_PADDING);
266 if (num == -1 && pad_unknown())
267 {
268 printf("No OAEP support\n");
269 goto next;
270 }
271 if (num != clen)
272 {
273 printf("OAEP encryption failed!\n");
274 err=1;
275 goto next;
276 }
277
278 num = RSA_private_decrypt(num, ctext, ptext, key,
279 RSA_PKCS1_OAEP_PADDING);
280 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
281 {
282 printf("OAEP decryption (encrypted data) failed!\n");
283 err=1;
284 }
285 else if (memcmp(ctext, ctext_ex, num) == 0)
286 {
287 printf("OAEP test vector %d passed!\n", v);
288 goto next;
289 }
290
291 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
292 Try decrypting ctext_ex */
293
294 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
295 RSA_PKCS1_OAEP_PADDING);
296
297 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
298 {
299 printf("OAEP decryption (test vector data) failed!\n");
300 err=1;
301 }
302 else
303 printf("OAEP encryption/decryption ok\n");
304 next:
305 RSA_free(key);
306 }
307
308 ERR_remove_state(0);
309
310 CRYPTO_mem_leaks_fp(stdout);
311
312 return err;
313 }
314#endif
diff --git a/src/lib/libssl/src/test/tcrl.com b/src/lib/libssl/src/test/tcrl.com
index cef21467bb..2e6ab2814d 100644
--- a/src/lib/libssl/src/test/tcrl.com
+++ b/src/lib/libssl/src/test/tcrl.com
@@ -10,6 +10,9 @@ $ t := testcrl.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing CRL conversions" 12$ write sys$output "testing CRL conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/test/testca.com b/src/lib/libssl/src/test/testca.com
index ea75479cd5..c670f2bf5f 100644
--- a/src/lib/libssl/src/test/testca.com
+++ b/src/lib/libssl/src/test/testca.com
@@ -40,7 +40,9 @@ $
40$ set noon 40$ set noon
41$ call deltree [.demoCA]*.* 41$ call deltree [.demoCA]*.*
42$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) demoCA.dir;* 42$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) demoCA.dir;*
43$ delete demoCA.dir;*,newcert.pem;*,newreq.pem;* 43$ delete demoCA.dir;*
44$ if f$search("newcert.pem") .nes. "" then delete newcert.pem;*
45$ if f$search("newcert.pem") .nes. "" then delete newreq.pem;*
44$ set on 46$ set on
45$! #usage: CA -newcert|-newreq|-newca|-sign|-verify 47$! #usage: CA -newcert|-newreq|-newca|-sign|-verify
46$ 48$
diff --git a/src/lib/libssl/src/test/testenc.com b/src/lib/libssl/src/test/testenc.com
index 0756e8bada..3b66f2e0d0 100644
--- a/src/lib/libssl/src/test/testenc.com
+++ b/src/lib/libssl/src/test/testenc.com
@@ -8,19 +8,23 @@ $ testsrc := makefile.ssl
8$ test := p.txt 8$ test := p.txt
9$ cmd := mcr 'exe_dir'openssl 9$ cmd := mcr 'exe_dir'openssl
10$ 10$
11$ if f$search(test) .nes. "" then delete 'test';*
11$ copy 'testsrc' 'test' 12$ copy 'testsrc' 'test'
12$ 13$
14$ if f$search(test+"-cipher") .nes. "" then delete 'test'-cipher;*
15$ if f$search(test+"-clear") .nes. "" then delete 'test'-clear;*
16$
13$ write sys$output "cat" 17$ write sys$output "cat"
14$ 'cmd' enc -in 'test' -out 'test'-cipher 18$ 'cmd' enc -in 'test' -out 'test'-cipher
15$ 'cmd' enc -in 'test'-cipher -out 'test'-clear 19$ 'cmd' enc -in 'test'-cipher -out 'test'-clear
16$ difference/output=nl: 'test' 'test'-clear 20$ backup/compare 'test' 'test'-clear
17$ if $severity .ne. 1 then exit 3 21$ if $severity .ne. 1 then exit 3
18$ delete 'test'-cipher;*,'test'-clear;* 22$ delete 'test'-cipher;*,'test'-clear;*
19$ 23$
20$ write sys$output "base64" 24$ write sys$output "base64"
21$ 'cmd' enc -a -e -in 'test' -out 'test'-cipher 25$ 'cmd' enc -a -e -in 'test' -out 'test'-cipher
22$ 'cmd' enc -a -d -in 'test'-cipher -out 'test'-clear 26$ 'cmd' enc -a -d -in 'test'-cipher -out 'test'-clear
23$ difference/output=nl: 'test' 'test'-clear 27$ backup/compare 'test' 'test'-clear
24$ if $severity .ne. 1 then exit 3 28$ if $severity .ne. 1 then exit 3
25$ delete 'test'-cipher;*,'test'-clear;* 29$ delete 'test'-cipher;*,'test'-clear;*
26$ 30$
@@ -30,16 +34,22 @@ $ open/read f 'test'-cipher-commands
30$ loop_cipher_commands: 34$ loop_cipher_commands:
31$ read/end=loop_cipher_commands_end f i 35$ read/end=loop_cipher_commands_end f i
32$ write sys$output i 36$ write sys$output i
37$
38$ if f$search(test+"-"+i+"-cipher") .nes. "" then -
39 delete 'test'-'i'-cipher;*
40$ if f$search(test+"-"+i+"-clear") .nes. "" then -
41 delete 'test'-'i'-clear;*
42$
33$ 'cmd' 'i' -bufsize 113 -e -k test -in 'test' -out 'test'-'i'-cipher 43$ 'cmd' 'i' -bufsize 113 -e -k test -in 'test' -out 'test'-'i'-cipher
34$ 'cmd' 'i' -bufsize 157 -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear 44$ 'cmd' 'i' -bufsize 157 -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear
35$ difference/output=nl: 'test' 'test'-'i'-clear 45$ backup/compare 'test' 'test'-'i'-clear
36$ if $severity .ne. 1 then exit 3 46$ if $severity .ne. 1 then exit 3
37$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;* 47$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;*
38$ 48$
39$ write sys$output i," base64" 49$ write sys$output i," base64"
40$ 'cmd' 'i' -bufsize 113 -a -e -k test -in 'test' -out 'test'-'i'-cipher 50$ 'cmd' 'i' -bufsize 113 -a -e -k test -in 'test' -out 'test'-'i'-cipher
41$ 'cmd' 'i' -bufsize 157 -a -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear 51$ 'cmd' 'i' -bufsize 157 -a -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear
42$ difference/output=nl: 'test' 'test'-'i'-clear 52$ backup/compare 'test' 'test'-'i'-clear
43$ if $severity .ne. 1 then exit 3 53$ if $severity .ne. 1 then exit 3
44$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;* 54$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;*
45$ 55$
diff --git a/src/lib/libssl/src/test/testgen b/src/lib/libssl/src/test/testgen
index 3534f5821f..c5f61b582b 100644
--- a/src/lib/libssl/src/test/testgen
+++ b/src/lib/libssl/src/test/testgen
@@ -15,6 +15,8 @@ echo "There should be a 2 sequences of .'s and some +'s."
15echo "There should not be more that at most 80 per line" 15echo "There should not be more that at most 80 per line"
16echo "This could take some time." 16echo "This could take some time."
17 17
18echo "string to make the random number generator think it has entropy" >> ./.rnd
19
18../apps/openssl req -config test.cnf -new -out testreq.pem 20../apps/openssl req -config test.cnf -new -out testreq.pem
19if [ $? != 0 ]; then 21if [ $? != 0 ]; then
20echo problems creating request 22echo problems creating request
diff --git a/src/lib/libssl/src/test/testgen.com b/src/lib/libssl/src/test/testgen.com
index ec302f524a..0e9029371a 100644
--- a/src/lib/libssl/src/test/testgen.com
+++ b/src/lib/libssl/src/test/testgen.com
@@ -20,6 +20,11 @@ $ write sys$output "There should be a 2 sequences of .'s and some +'s."
20$ write sys$output "There should not be more that at most 80 per line" 20$ write sys$output "There should not be more that at most 80 per line"
21$ write sys$output "This could take some time." 21$ write sys$output "This could take some time."
22$ 22$
23$ append/new nl: .rnd
24$ open/append random_file .rnd
25$ write random_file "string to make the random number generator think it has entropy"
26$ close random_file
27$
23$ mcr 'exe_dir'openssl req -config test.cnf -new -out testreq.pem 28$ mcr 'exe_dir'openssl req -config test.cnf -new -out testreq.pem
24$ if $severity .ne. 1 29$ if $severity .ne. 1
25$ then 30$ then
diff --git a/src/lib/libssl/src/test/tests.com b/src/lib/libssl/src/test/tests.com
index 147b8aa838..040dafab8d 100644
--- a/src/lib/libssl/src/test/tests.com
+++ b/src/lib/libssl/src/test/tests.com
@@ -20,9 +20,9 @@ $ tests = p1
20$ else 20$ else
21$ tests := - 21$ tests := -
22 test_des,test_idea,test_sha,test_md5,test_hmac,test_md2,test_mdc2,- 22 test_des,test_idea,test_sha,test_md5,test_hmac,test_md2,test_mdc2,-
23 test_rc2,test_rc4,test_rc5,test_bf,test_cast,- 23 test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,-
24 test_rand,test_bn,test_enc,test_x509,test_rsa,test_crl,test_sid,- 24 test_rand,test_bn,test_enc,test_x509,test_rsa,test_crl,test_sid,-
25 test_reqgen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,- 25 test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,-
26 test_ss,test_ssl,test_ca 26 test_ss,test_ssl,test_ca
27$ endif 27$ endif
28$ tests = f$edit(tests,"COLLAPSE") 28$ tests = f$edit(tests,"COLLAPSE")
@@ -48,7 +48,7 @@ $ DHTEST := dhtest
48$ DSATEST := dsatest 48$ DSATEST := dsatest
49$ METHTEST := methtest 49$ METHTEST := methtest
50$ SSLTEST := ssltest 50$ SSLTEST := ssltest
51$ RSATEST := rsa_oaep_test 51$ RSATEST := rsa_test
52$ 52$
53$ tests_i = 0 53$ tests_i = 0
54$ loop_tests: 54$ loop_tests:
@@ -151,9 +151,7 @@ RECORD
151$ create/fdl=bntest-vms.fdl bntest-vms.sh 151$ create/fdl=bntest-vms.fdl bntest-vms.sh
152$ open/append foo bntest-vms.sh 152$ open/append foo bntest-vms.sh
153$ type/output=foo: sys$input: 153$ type/output=foo: sys$input:
154<< __FOO__ bc | awk '{ \ 154<< __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"'
155if ($$0 != "0") {print "error"; exit(1); } \
156if (((NR+1)%64) == 0) print NR+1," tests done"; }'
157$ define/user sys$output bntest-vms.tmp 155$ define/user sys$output bntest-vms.tmp
158$ mcr 'texe_dir''bntest' 156$ mcr 'texe_dir''bntest'
159$ copy bntest-vms.tmp foo: 157$ copy bntest-vms.tmp foo:
@@ -173,14 +171,14 @@ $ write sys$output "There are definitly a few expired certificates"
173$ @tverify.com 171$ @tverify.com
174$ goto loop_tests 172$ goto loop_tests
175$ test_dh: 173$ test_dh:
176$ write sys$output "Generate as set of DH parameters" 174$ write sys$output "Generate a set of DH parameters"
177$ mcr 'texe_dir''dhtest' 175$ mcr 'texe_dir''dhtest'
178$ goto loop_tests 176$ goto loop_tests
179$ test_dsa: 177$ test_dsa:
180$ write sys$output "Generate as set of DSA parameters" 178$ write sys$output "Generate a set of DSA parameters"
181$ mcr 'texe_dir''dsatest' 179$ mcr 'texe_dir''dsatest'
182$ goto loop_tests 180$ goto loop_tests
183$ test_reqgen: 181$ test_gen:
184$ write sys$output "Generate and verify a certificate request" 182$ write sys$output "Generate and verify a certificate request"
185$ @testgen.com 183$ @testgen.com
186$ goto loop_tests 184$ goto loop_tests
diff --git a/src/lib/libssl/src/test/testssl b/src/lib/libssl/src/test/testssl
index 255ae5e976..a88e290c57 100644
--- a/src/lib/libssl/src/test/testssl
+++ b/src/lib/libssl/src/test/testssl
@@ -63,6 +63,12 @@ echo test sslv3 with both client and server authentication via BIO pair
63echo test sslv2/sslv3 via BIO pair 63echo test sslv2/sslv3 via BIO pair
64./ssltest || exit 1 64./ssltest || exit 1
65 65
66echo test sslv2/sslv3 w/o DHE via BIO pair
67./ssltest -bio_pair -no_dhe || exit 1
68
69echo test sslv2/sslv3 with 1024bit DHE
70./ssltest -bio_pair -dhe1024 -v || exit 1
71
66echo test sslv2/sslv3 with server authentication 72echo test sslv2/sslv3 with server authentication
67./ssltest -bio_pair -server_auth -CApath ../certs || exit 1 73./ssltest -bio_pair -server_auth -CApath ../certs || exit 1
68 74
diff --git a/src/lib/libssl/src/test/testssl.com b/src/lib/libssl/src/test/testssl.com
index 93a9aef802..0b4b0a0ad3 100644
--- a/src/lib/libssl/src/test/testssl.com
+++ b/src/lib/libssl/src/test/testssl.com
@@ -58,6 +58,10 @@ $ write sys$output "test sslv2 via BIO pair"
58$ mcr 'exe_dir'ssltest -bio_pair -ssl2 58$ mcr 'exe_dir'ssltest -bio_pair -ssl2
59$ if $severity .ne. 1 then goto exit3 59$ if $severity .ne. 1 then goto exit3
60$ 60$
61$ write sys$output "test sslv2/sslv3 with 1024 bit DHE via BIO pair"
62$ mcr 'exe_dir'ssltest -bio_pair -dhe1024 -v
63$ if $severity .ne. 1 then goto exit3
64$
61$ write sys$output "test sslv2 with server authentication via BIO pair" 65$ write sys$output "test sslv2 with server authentication via BIO pair"
62$ mcr 'exe_dir'ssltest -bio_pair -ssl2 -server_auth "-CAfile" certs.tmp 66$ mcr 'exe_dir'ssltest -bio_pair -ssl2 -server_auth "-CAfile" certs.tmp
63$ if $severity .ne. 1 then goto exit3 67$ if $severity .ne. 1 then goto exit3
@@ -90,6 +94,10 @@ $ write sys$output "test sslv2/sslv3 via BIO pair"
90$ mcr 'exe_dir'ssltest 94$ mcr 'exe_dir'ssltest
91$ if $severity .ne. 1 then goto exit3 95$ if $severity .ne. 1 then goto exit3
92$ 96$
97$ write sys$output "test sslv2/sslv3 w/o DHE via BIO pair"
98$ mcr 'exe_dir'ssltest -bio_pair -no_dhe
99$ if $severity .ne. 1 then goto exit3
100$
93$ write sys$output "test sslv2/sslv3 with server authentication" 101$ write sys$output "test sslv2/sslv3 with server authentication"
94$ mcr 'exe_dir'ssltest -bio_pair -server_auth "-CAfile" certs.tmp 102$ mcr 'exe_dir'ssltest -bio_pair -server_auth "-CAfile" certs.tmp
95$ if $severity .ne. 1 then goto exit3 103$ if $severity .ne. 1 then goto exit3
diff --git a/src/lib/libssl/src/test/tpkcs7.com b/src/lib/libssl/src/test/tpkcs7.com
index 5ed920ac34..9e345937c6 100644
--- a/src/lib/libssl/src/test/tpkcs7.com
+++ b/src/lib/libssl/src/test/tpkcs7.com
@@ -10,6 +10,9 @@ $ t := testp7.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing PKCS7 conversions" 12$ write sys$output "testing PKCS7 conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -34,16 +37,16 @@ $ write sys$output "p -> p"
34$ 'cmd' -in f.p -inform p -outform p -out ff.p3 37$ 'cmd' -in f.p -inform p -outform p -out ff.p3
35$ if $severity .ne. 1 then exit 3 38$ if $severity .ne. 1 then exit 3
36$ 39$
37$ difference/output=nl: fff.p f.p 40$ backup/compare fff.p f.p
38$ if $severity .ne. 1 then exit 3 41$ if $severity .ne. 1 then exit 3
39$ difference/output=nl: fff.p ff.p1 42$ backup/compare fff.p ff.p1
40$ if $severity .ne. 1 then exit 3 43$ if $severity .ne. 1 then exit 3
41$ difference/output=nl: fff.p ff.p3 44$ backup/compare fff.p ff.p3
42$ if $severity .ne. 1 then exit 3 45$ if $severity .ne. 1 then exit 3
43$ 46$
44$ difference/output=nl: f.p ff.p1 47$ backup/compare f.p ff.p1
45$ if $severity .ne. 1 then exit 3 48$ if $severity .ne. 1 then exit 3
46$ difference/output=nl: f.p ff.p3 49$ backup/compare f.p ff.p3
47$ if $severity .ne. 1 then exit 3 50$ if $severity .ne. 1 then exit 3
48$ 51$
49$ delete f.*;*,ff.*;*,fff.*;* 52$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/test/tpkcs7d.com b/src/lib/libssl/src/test/tpkcs7d.com
index 08d33eaa69..7d4f8794a4 100644
--- a/src/lib/libssl/src/test/tpkcs7d.com
+++ b/src/lib/libssl/src/test/tpkcs7d.com
@@ -10,6 +10,9 @@ $ t := pkcs7-1.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing PKCS7 conversions (2)" 12$ write sys$output "testing PKCS7 conversions (2)"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -34,9 +37,9 @@ $ write sys$output "p -> p"
34$ 'cmd' -in f.p -inform p -outform p -out ff.p3 37$ 'cmd' -in f.p -inform p -outform p -out ff.p3
35$ if $severity .ne. 1 then exit 3 38$ if $severity .ne. 1 then exit 3
36$ 39$
37$ difference/output=nl: f.p ff.p1 40$ backup/compare f.p ff.p1
38$ if $severity .ne. 1 then exit 3 41$ if $severity .ne. 1 then exit 3
39$ difference/output=nl: f.p ff.p3 42$ backup/compare f.p ff.p3
40$ if $severity .ne. 1 then exit 3 43$ if $severity .ne. 1 then exit 3
41$ 44$
42$ delete f.*;*,ff.*;*,fff.*;* 45$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/test/treq.com b/src/lib/libssl/src/test/treq.com
index 9eb1d26f6e..22c22c3aa9 100644
--- a/src/lib/libssl/src/test/treq.com
+++ b/src/lib/libssl/src/test/treq.com
@@ -10,6 +10,9 @@ $ t := testreq.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing req conversions" 12$ write sys$output "testing req conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/test/trsa.com b/src/lib/libssl/src/test/trsa.com
index 9c9083d02b..28add5eefd 100644
--- a/src/lib/libssl/src/test/trsa.com
+++ b/src/lib/libssl/src/test/trsa.com
@@ -10,6 +10,9 @@ $ t := testrsa.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing RSA conversions" 12$ write sys$output "testing RSA conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/test/tsid.com b/src/lib/libssl/src/test/tsid.com
index 28d83e5c4e..bde23f9bb9 100644
--- a/src/lib/libssl/src/test/tsid.com
+++ b/src/lib/libssl/src/test/tsid.com
@@ -10,6 +10,9 @@ $ t := testsid.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing session-id conversions" 12$ write sys$output "testing session-id conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/test/tx509.com b/src/lib/libssl/src/test/tx509.com
index bbcf0a384b..985969c566 100644
--- a/src/lib/libssl/src/test/tx509.com
+++ b/src/lib/libssl/src/test/tx509.com
@@ -10,6 +10,9 @@ $ t := testx509.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing X509 conversions" 12$ write sys$output "testing X509 conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$ difference/output=nl: fff.p ff.p2 62$ backup/compare fff.p ff.p2
60$ if $severity .ne. 1 then exit 3 63$ if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$ difference/output=nl: f.n ff.n1 67$ backup/compare f.n ff.n1
65$ if $severity .ne. 1 then exit 3 68$ if $severity .ne. 1 then exit 3
66$ difference/output=nl: f.n ff.n2 69$ backup/compare f.n ff.n2
67$ if $severity .ne. 1 then exit 3 70$ if $severity .ne. 1 then exit 3
68$ difference/output=nl: f.n ff.n3 71$ backup/compare f.n ff.n3
69$ if $severity .ne. 1 then exit 3 72$ if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$ difference/output=nl: f.p ff.p2 76$ backup/compare f.p ff.p2
74$ if $severity .ne. 1 then exit 3 77$ if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/src/util/domd b/src/lib/libssl/src/util/domd
index 324051f60b..9f75131f22 100644
--- a/src/lib/libssl/src/util/domd
+++ b/src/lib/libssl/src/util/domd
@@ -7,5 +7,5 @@ shift
7 7
8cp Makefile.ssl Makefile.save 8cp Makefile.ssl Makefile.save
9makedepend -f Makefile.ssl $@ 9makedepend -f Makefile.ssl $@
10$TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new 10perl $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new
11mv Makefile.new Makefile.ssl 11mv Makefile.new Makefile.ssl
diff --git a/src/lib/libssl/src/util/libeay.num b/src/lib/libssl/src/util/libeay.num
index 59c2040a29..e3818ef6e4 100644
--- a/src/lib/libssl/src/util/libeay.num
+++ b/src/lib/libssl/src/util/libeay.num
@@ -499,9 +499,9 @@ SHA1_Update 504
499SHA_Final 505 499SHA_Final 505
500SHA_Init 506 500SHA_Init 506
501SHA_Update 507 501SHA_Update 507
502SSLeay_add_all_algorithms 508 502OpenSSL_add_all_algorithms 508
503SSLeay_add_all_ciphers 509 503OpenSSL_add_all_ciphers 509
504SSLeay_add_all_digests 510 504OpenSSL_add_all_digests 510
505TXT_DB_create_index 511 505TXT_DB_create_index 511
506TXT_DB_free 512 506TXT_DB_free 512
507TXT_DB_get_by_index 513 507TXT_DB_get_by_index 513
@@ -1304,13 +1304,12 @@ i2d_SXNETID 1329
1304d2i_SXNETID 1330 1304d2i_SXNETID 1330
1305SXNETID_new 1331 1305SXNETID_new 1331
1306SXNETID_free 1332 1306SXNETID_free 1332
1307DSA_SIG_new 1333 1307DSA_SIG_new 1333
1308DSA_SIG_free 1334 1308DSA_SIG_free 1334
1309DSA_do_sign 1335 1309DSA_do_sign 1335
1310DSA_do_verify 1336 1310DSA_do_verify 1336
1311d2i_DSA_SIG 1337 1311d2i_DSA_SIG 1337
1312i2d_DSA_SIG 1338 1312i2d_DSA_SIG 1338
1313
1314i2d_ASN1_VISIBLESTRING 1339 1313i2d_ASN1_VISIBLESTRING 1339
1315d2i_ASN1_VISIBLESTRING 1340 1314d2i_ASN1_VISIBLESTRING 1340
1316i2d_ASN1_UTF8STRING 1341 1315i2d_ASN1_UTF8STRING 1341
@@ -1844,3 +1843,387 @@ sk_DIST_POINT_sort 1868
1844RSA_check_key 1869 1843RSA_check_key 1869
1845OBJ_obj2txt 1870 1844OBJ_obj2txt 1870
1846DSA_dup_DH 1871 1845DSA_dup_DH 1871
1846X509_REQ_get_extensions 1872
1847X509_REQ_set_extension_nids 1873
1848BIO_nwrite 1874
1849X509_REQ_extension_nid 1875
1850BIO_nread 1876
1851X509_REQ_get_extension_nids 1877
1852BIO_nwrite0 1878
1853X509_REQ_add_extensions_nid 1879
1854BIO_nread0 1880
1855X509_REQ_add_extensions 1881
1856BIO_new_mem_buf 1882
1857DH_set_ex_data 1883
1858DH_set_method 1884
1859DSA_OpenSSL 1885
1860DH_get_ex_data 1886
1861DH_get_ex_new_index 1887
1862DSA_new_method 1888
1863DH_new_method 1889
1864DH_OpenSSL 1890
1865DSA_get_ex_new_index 1891
1866DH_get_default_method 1892
1867DSA_set_ex_data 1893
1868DH_set_default_method 1894
1869DSA_get_ex_data 1895
1870X509V3_EXT_REQ_add_conf 1896
1871NETSCAPE_SPKI_print 1897
1872NETSCAPE_SPKI_set_pubkey 1898
1873NETSCAPE_SPKI_b64_encode 1899
1874NETSCAPE_SPKI_get_pubkey 1900
1875NETSCAPE_SPKI_b64_decode 1901
1876UTF8_putc 1902
1877UTF8_getc 1903
1878RSA_null_method 1904
1879ASN1_tag2str 1905
1880BIO_ctrl_reset_read_request 1906
1881DISPLAYTEXT_new 1907
1882ASN1_GENERALIZEDTIME_free 1908
1883X509_REVOKED_get_ext_d2i 1909
1884X509_set_ex_data 1910
1885X509_reject_set_bit_asc 1911
1886X509_NAME_add_entry_by_txt 1912
1887sk_X509_TRUST_pop 1913
1888X509_NAME_add_entry_by_NID 1914
1889X509_PURPOSE_get0 1915
1890sk_ACCESS_DESCRIPTION_shift 1916
1891PEM_read_X509_AUX 1917
1892d2i_AUTHORITY_INFO_ACCESS 1918
1893sk_X509_TRUST_set_cmp_func 1919
1894sk_X509_TRUST_free 1920
1895PEM_write_PUBKEY 1921
1896sk_X509_TRUST_num 1922
1897sk_ACCESS_DESCRIPTION_delete 1923
1898sk_ASN1_STRING_TABLE_value 1924
1899ACCESS_DESCRIPTION_new 1925
1900X509_CERT_AUX_free 1926
1901d2i_ACCESS_DESCRIPTION 1927
1902X509_trust_clear 1928
1903sk_X509_PURPOSE_value 1929
1904sk_X509_PURPOSE_zero 1930
1905X509_TRUST_add 1931
1906ASN1_VISIBLESTRING_new 1932
1907X509_alias_set1 1933
1908ASN1_PRINTABLESTRING_free 1934
1909EVP_PKEY_get1_DSA 1935
1910ASN1_BMPSTRING_new 1936
1911ASN1_mbstring_copy 1937
1912ASN1_UTF8STRING_new 1938
1913sk_ACCESS_DESCRIPTION_set 1939
1914sk_X509_PURPOSE_pop 1940
1915DSA_get_default_method 1941
1916sk_X509_PURPOSE_push 1942
1917sk_X509_PURPOSE_delete 1943
1918sk_X509_PURPOSE_num 1944
1919i2d_ASN1_SET_OF_ACCESS_DESCRIPTION 1945
1920ASN1_T61STRING_free 1946
1921sk_ACCESS_DESCRIPTION_free 1947
1922sk_ASN1_STRING_TABLE_pop 1948
1923DSA_set_method 1949
1924X509_get_ex_data 1950
1925ASN1_STRING_type 1951
1926X509_PURPOSE_get_by_sname 1952
1927sk_X509_PURPOSE_find 1953
1928ASN1_TIME_free 1954
1929ASN1_OCTET_STRING_cmp 1955
1930sk_ACCESS_DESCRIPTION_value 1956
1931ASN1_BIT_STRING_new 1957
1932X509_get_ext_d2i 1958
1933PEM_read_bio_X509_AUX 1959
1934ASN1_STRING_set_default_mask_asc 1960
1935PEM_write_bio_RSA_PUBKEY 1961
1936sk_ASN1_STRING_TABLE_num 1962
1937ASN1_INTEGER_cmp 1963
1938d2i_RSA_PUBKEY_fp 1964
1939sk_ACCESS_DESCRIPTION_unshift 1965
1940sk_ASN1_STRING_TABLE_delete_ptr 1966
1941X509_trust_set_bit_asc 1967
1942PEM_write_bio_DSA_PUBKEY 1968
1943X509_STORE_CTX_free 1969
1944EVP_PKEY_set1_DSA 1970
1945i2d_DSA_PUBKEY_fp 1971
1946X509_load_cert_crl_file 1972
1947ASN1_TIME_new 1973
1948i2d_RSA_PUBKEY 1974
1949sk_X509_TRUST_pop_free 1975
1950X509_STORE_CTX_purpose_inherit 1976
1951PEM_read_RSA_PUBKEY 1977
1952sk_X509_TRUST_zero 1978
1953sk_ACCESS_DESCRIPTION_pop_free 1979
1954d2i_X509_AUX 1980
1955i2d_DSA_PUBKEY 1981
1956X509_CERT_AUX_print 1982
1957sk_X509_PURPOSE_new_null 1983
1958PEM_read_DSA_PUBKEY 1984
1959i2d_RSA_PUBKEY_bio 1985
1960ASN1_BIT_STRING_num_asc 1986
1961i2d_PUBKEY 1987
1962ASN1_UTCTIME_free 1988
1963DSA_set_default_method 1989
1964X509_PURPOSE_get_by_id 1990
1965sk_X509_TRUST_push 1991
1966sk_ASN1_STRING_TABLE_sort 1992
1967sk_X509_PURPOSE_set_cmp_func 1993
1968ACCESS_DESCRIPTION_free 1994
1969PEM_read_bio_PUBKEY 1995
1970ASN1_STRING_set_by_NID 1996
1971X509_PURPOSE_get_id 1997
1972DISPLAYTEXT_free 1998
1973OTHERNAME_new 1999
1974sk_X509_TRUST_find 2000
1975X509_CERT_AUX_new 2001
1976sk_ACCESS_DESCRIPTION_dup 2002
1977sk_ASN1_STRING_TABLE_pop_free 2003
1978sk_ASN1_STRING_TABLE_unshift 2004
1979sk_X509_TRUST_shift 2005
1980sk_ACCESS_DESCRIPTION_zero 2006
1981X509_TRUST_cleanup 2007
1982X509_NAME_add_entry_by_OBJ 2008
1983X509_CRL_get_ext_d2i 2009
1984sk_X509_TRUST_set 2010
1985X509_PURPOSE_get0_name 2011
1986PEM_read_PUBKEY 2012
1987sk_ACCESS_DESCRIPTION_new 2013
1988i2d_DSA_PUBKEY_bio 2014
1989i2d_OTHERNAME 2015
1990ASN1_OCTET_STRING_free 2016
1991ASN1_BIT_STRING_set_asc 2017
1992sk_ACCESS_DESCRIPTION_push 2018
1993X509_get_ex_new_index 2019
1994ASN1_STRING_TABLE_cleanup 2020
1995X509_TRUST_get_by_id 2021
1996X509_PURPOSE_get_trust 2022
1997ASN1_STRING_length 2023
1998d2i_ASN1_SET_OF_ACCESS_DESCRIPTION 2024
1999ASN1_PRINTABLESTRING_new 2025
2000X509V3_get_d2i 2026
2001ASN1_ENUMERATED_free 2027
2002i2d_X509_CERT_AUX 2028
2003sk_ACCESS_DESCRIPTION_find 2029
2004X509_STORE_CTX_set_trust 2030
2005sk_X509_PURPOSE_unshift 2031
2006ASN1_STRING_set_default_mask 2032
2007X509_STORE_CTX_new 2033
2008EVP_PKEY_get1_RSA 2034
2009sk_X509_PURPOSE_set 2035
2010sk_ASN1_STRING_TABLE_insert 2036
2011sk_X509_PURPOSE_sort 2037
2012DIRECTORYSTRING_free 2038
2013PEM_write_X509_AUX 2039
2014ASN1_OCTET_STRING_set 2040
2015d2i_DSA_PUBKEY_fp 2041
2016sk_ASN1_STRING_TABLE_free 2042
2017sk_X509_TRUST_value 2043
2018d2i_RSA_PUBKEY 2044
2019sk_ASN1_STRING_TABLE_set 2045
2020X509_TRUST_get0_name 2046
2021X509_TRUST_get0 2047
2022AUTHORITY_INFO_ACCESS_free 2048
2023ASN1_IA5STRING_new 2049
2024d2i_DSA_PUBKEY 2050
2025X509_check_purpose 2051
2026ASN1_ENUMERATED_new 2052
2027d2i_RSA_PUBKEY_bio 2053
2028d2i_PUBKEY 2054
2029X509_TRUST_get_trust 2055
2030X509_TRUST_get_flags 2056
2031ASN1_BMPSTRING_free 2057
2032ASN1_T61STRING_new 2058
2033sk_X509_TRUST_unshift 2059
2034ASN1_UTCTIME_new 2060
2035sk_ACCESS_DESCRIPTION_pop 2061
2036i2d_AUTHORITY_INFO_ACCESS 2062
2037EVP_PKEY_set1_RSA 2063
2038X509_STORE_CTX_set_purpose 2064
2039ASN1_IA5STRING_free 2065
2040PEM_write_bio_X509_AUX 2066
2041X509_PURPOSE_get_count 2067
2042CRYPTO_add_info 2068
2043sk_ACCESS_DESCRIPTION_num 2069
2044sk_ASN1_STRING_TABLE_set_cmp_func 2070
2045X509_NAME_ENTRY_create_by_txt 2071
2046ASN1_STRING_get_default_mask 2072
2047sk_X509_TRUST_dup 2073
2048X509_alias_get0 2074
2049ASN1_STRING_data 2075
2050sk_X509_TRUST_insert 2076
2051i2d_ACCESS_DESCRIPTION 2077
2052X509_trust_set_bit 2078
2053sk_X509_PURPOSE_delete_ptr 2079
2054ASN1_BIT_STRING_free 2080
2055PEM_read_bio_RSA_PUBKEY 2081
2056X509_add1_reject_object 2082
2057X509_check_trust 2083
2058sk_X509_TRUST_new_null 2084
2059sk_ACCESS_DESCRIPTION_new_null 2085
2060sk_ACCESS_DESCRIPTION_delete_ptr 2086
2061sk_X509_TRUST_sort 2087
2062PEM_read_bio_DSA_PUBKEY 2088
2063sk_X509_TRUST_new 2089
2064X509_PURPOSE_add 2090
2065ASN1_STRING_TABLE_get 2091
2066ASN1_UTF8STRING_free 2092
2067d2i_DSA_PUBKEY_bio 2093
2068sk_ASN1_STRING_TABLE_delete 2094
2069PEM_write_RSA_PUBKEY 2095
2070d2i_OTHERNAME 2096
2071sk_ACCESS_DESCRIPTION_insert 2097
2072X509_reject_set_bit 2098
2073sk_X509_TRUST_delete_ptr 2099
2074sk_X509_PURPOSE_pop_free 2100
2075PEM_write_DSA_PUBKEY 2101
2076sk_X509_PURPOSE_free 2102
2077sk_X509_PURPOSE_dup 2103
2078sk_ASN1_STRING_TABLE_zero 2104
2079X509_PURPOSE_get0_sname 2105
2080sk_ASN1_STRING_TABLE_shift 2106
2081EVP_PKEY_set1_DH 2107
2082ASN1_OCTET_STRING_dup 2108
2083ASN1_BIT_STRING_set 2109
2084X509_TRUST_get_count 2110
2085ASN1_INTEGER_free 2111
2086OTHERNAME_free 2112
2087i2d_RSA_PUBKEY_fp 2113
2088ASN1_INTEGER_dup 2114
2089d2i_X509_CERT_AUX 2115
2090sk_ASN1_STRING_TABLE_new_null 2116
2091PEM_write_bio_PUBKEY 2117
2092ASN1_VISIBLESTRING_free 2118
2093X509_PURPOSE_cleanup 2119
2094sk_ASN1_STRING_TABLE_push 2120
2095sk_ASN1_STRING_TABLE_dup 2121
2096sk_X509_PURPOSE_shift 2122
2097ASN1_mbstring_ncopy 2123
2098sk_X509_PURPOSE_new 2124
2099sk_X509_PURPOSE_insert 2125
2100ASN1_GENERALIZEDTIME_new 2126
2101sk_ACCESS_DESCRIPTION_sort 2127
2102EVP_PKEY_get1_DH 2128
2103sk_ACCESS_DESCRIPTION_set_cmp_func 2129
2104ASN1_OCTET_STRING_new 2130
2105ASN1_INTEGER_new 2131
2106i2d_X509_AUX 2132
2107sk_ASN1_STRING_TABLE_find 2133
2108ASN1_BIT_STRING_name_print 2134
2109X509_cmp 2135
2110ASN1_STRING_length_set 2136
2111DIRECTORYSTRING_new 2137
2112sk_ASN1_STRING_TABLE_new 2138
2113sk_X509_TRUST_delete 2139
2114X509_add1_trust_object 2140
2115PKCS12_newpass 2141
2116SMIME_write_PKCS7 2142
2117SMIME_read_PKCS7 2143
2118des_set_key_checked 2144
2119PKCS7_verify 2145
2120PKCS7_encrypt 2146
2121des_set_key_unchecked 2147
2122SMIME_crlf_copy 2148
2123i2d_ASN1_PRINTABLESTRING 2149
2124PKCS7_get0_signers 2150
2125PKCS7_decrypt 2151
2126SMIME_text 2152
2127PKCS7_simple_smimecap 2153
2128PKCS7_get_smimecap 2154
2129PKCS7_sign 2155
2130PKCS7_add_attrib_smimecap 2156
2131CRYPTO_dbg_set_options 2157
2132CRYPTO_remove_all_info 2158
2133CRYPTO_get_mem_debug_functions 2159
2134CRYPTO_is_mem_check_on 2160
2135CRYPTO_set_mem_debug_functions 2161
2136CRYPTO_pop_info 2162
2137CRYPTO_push_info_ 2163
2138CRYPTO_set_mem_debug_options 2164
2139PEM_write_PKCS8PrivateKey_nid 2165
2140PEM_write_bio_PKCS8PrivateKey_nid 2166
2141d2i_PKCS8PrivateKey_bio 2167
2142ASN1_NULL_free 2168
2143d2i_ASN1_NULL 2169
2144ASN1_NULL_new 2170
2145i2d_PKCS8PrivateKey_bio 2171
2146i2d_PKCS8PrivateKey_fp 2172
2147i2d_ASN1_NULL 2173
2148i2d_PKCS8PrivateKey_nid_fp 2174
2149d2i_PKCS8PrivateKey_fp 2175
2150i2d_PKCS8PrivateKey_nid_bio 2176
2151i2d_PKCS8PrivateKeyInfo_fp 2177
2152i2d_PKCS8PrivateKeyInfo_bio 2178
2153PEM_cb 2179
2154i2d_PrivateKey_fp 2180
2155d2i_PrivateKey_bio 2181
2156d2i_PrivateKey_fp 2182
2157i2d_PrivateKey_bio 2183
2158X509_reject_clear 2184
2159X509_TRUST_set_default 2185
2160d2i_AutoPrivateKey 2186
2161X509_ATTRIBUTE_get0_type 2187
2162X509_ATTRIBUTE_set1_data 2188
2163X509at_get_attr 2189
2164X509at_get_attr_count 2190
2165X509_ATTRIBUTE_create_by_NID 2191
2166X509_ATTRIBUTE_set1_object 2192
2167X509_ATTRIBUTE_count 2193
2168X509_ATTRIBUTE_create_by_OBJ 2194
2169X509_ATTRIBUTE_get0_object 2195
2170X509at_get_attr_by_NID 2196
2171X509at_add1_attr 2197
2172X509_ATTRIBUTE_get0_data 2198
2173X509at_delete_attr 2199
2174X509at_get_attr_by_OBJ 2200
2175RAND_add 2201
2176BIO_number_written 2202
2177BIO_number_read 2203
2178X509_STORE_CTX_get1_chain 2204
2179ERR_load_RAND_strings 2205
2180RAND_pseudo_bytes 2206
2181X509_REQ_get_attr_by_NID 2207
2182X509_REQ_get_attr 2208
2183X509_REQ_add1_attr_by_NID 2209
2184X509_REQ_get_attr_by_OBJ 2210
2185X509at_add1_attr_by_NID 2211
2186X509_REQ_add1_attr_by_OBJ 2212
2187X509_REQ_get_attr_count 2213
2188X509_REQ_add1_attr 2214
2189X509_REQ_delete_attr 2215
2190X509at_add1_attr_by_OBJ 2216
2191X509_REQ_add1_attr_by_txt 2217
2192X509_ATTRIBUTE_create_by_txt 2218
2193X509at_add1_attr_by_txt 2219
2194sk_CRYPTO_EX_DATA_FUNCS_delete 2220
2195sk_CRYPTO_EX_DATA_FUNCS_set 2221
2196sk_CRYPTO_EX_DATA_FUNCS_unshift 2222
2197sk_CRYPTO_EX_DATA_FUNCS_new_null 2223
2198sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func 2224
2199sk_CRYPTO_EX_DATA_FUNCS_sort 2225
2200sk_CRYPTO_EX_DATA_FUNCS_dup 2226
2201sk_CRYPTO_EX_DATA_FUNCS_shift 2227
2202sk_CRYPTO_EX_DATA_FUNCS_value 2228
2203sk_CRYPTO_EX_DATA_FUNCS_pop 2229
2204sk_CRYPTO_EX_DATA_FUNCS_push 2230
2205sk_CRYPTO_EX_DATA_FUNCS_find 2231
2206sk_CRYPTO_EX_DATA_FUNCS_new 2232
2207sk_CRYPTO_EX_DATA_FUNCS_free 2233
2208sk_CRYPTO_EX_DATA_FUNCS_delete_ptr 2234
2209sk_CRYPTO_EX_DATA_FUNCS_num 2235
2210sk_CRYPTO_EX_DATA_FUNCS_pop_free 2236
2211sk_CRYPTO_EX_DATA_FUNCS_insert 2237
2212sk_CRYPTO_EX_DATA_FUNCS_zero 2238
2213BN_pseudo_rand 2239
2214BN_is_prime_fasttest 2240
2215BN_CTX_end 2241
2216BN_CTX_start 2242
2217BN_CTX_get 2243
2218EVP_PKEY2PKCS8_broken 2244
2219ASN1_STRING_TABLE_add 2245
2220CRYPTO_dbg_get_options 2246
2221AUTHORITY_INFO_ACCESS_new 2247
2222CRYPTO_get_mem_debug_options 2248
2223des_crypt 2249
2224PEM_write_bio_X509_REQ_NEW 2250
2225PEM_write_X509_REQ_NEW 2251
2226BIO_callback_ctrl 2252
2227RAND_egd 2253
2228RAND_status 2254
2229bn_dump1 2255
diff --git a/src/lib/libssl/src/util/mkdef.pl b/src/lib/libssl/src/util/mkdef.pl
index 80384af325..4e2845a4e1 100644
--- a/src/lib/libssl/src/util/mkdef.pl
+++ b/src/lib/libssl/src/util/mkdef.pl
@@ -6,26 +6,34 @@
6# prototyped functions: it then prunes the output. 6# prototyped functions: it then prunes the output.
7# 7#
8 8
9$crypto_num="util/libeay.num"; 9my $crypto_num="util/libeay.num";
10$ssl_num= "util/ssleay.num"; 10my $ssl_num= "util/ssleay.num";
11 11
12my $do_update = 0; 12my $do_update = 0;
13my $do_crypto = 0; 13my $do_crypto = 0;
14my $do_ssl = 0; 14my $do_ssl = 0;
15$rsaref = 0; 15my $do_ctest = 0;
16my $rsaref = 0;
16 17
17$W32=1; 18my $W32=1;
18$NT=0; 19my $NT=0;
19# Set this to make typesafe STACK definitions appear in DEF 20# Set this to make typesafe STACK definitions appear in DEF
20$safe_stack_def = 1; 21my $safe_stack_def = 1;
21 22
22$options=""; 23my $options="";
23open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; 24open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
24while(<IN>) { 25while(<IN>) {
25 $options=$1 if (/^OPTIONS=(.*)$/); 26 $options=$1 if (/^OPTIONS=(.*)$/);
26} 27}
27close(IN); 28close(IN);
28 29
30# The following ciphers may be excluded (by Configure). This means functions
31# defined with ifndef(NO_XXX) are not included in the .def file, and everything
32# in directory xxx is ignored.
33my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
34my $no_cast; my $no_md2; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
35my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0;
36
29foreach (@ARGV, split(/ /, $options)) 37foreach (@ARGV, split(/ /, $options))
30 { 38 {
31 $W32=1 if $_ eq "32"; 39 $W32=1 if $_ eq "32";
@@ -39,6 +47,7 @@ foreach (@ARGV, split(/ /, $options))
39 $do_crypto=1 if $_ eq "libeay"; 47 $do_crypto=1 if $_ eq "libeay";
40 $do_crypto=1 if $_ eq "crypto"; 48 $do_crypto=1 if $_ eq "crypto";
41 $do_update=1 if $_ eq "update"; 49 $do_update=1 if $_ eq "update";
50 $do_ctest=1 if $_ eq "ctest";
42 $rsaref=1 if $_ eq "rsaref"; 51 $rsaref=1 if $_ eq "rsaref";
43 52
44 if (/^no-rc2$/) { $no_rc2=1; } 53 if (/^no-rc2$/) { $no_rc2=1; }
@@ -59,6 +68,7 @@ foreach (@ARGV, split(/ /, $options))
59 elsif (/^no-hmac$/) { $no_hmac=1; } 68 elsif (/^no-hmac$/) { $no_hmac=1; }
60 } 69 }
61 70
71
62if (!$do_ssl && !$do_crypto) 72if (!$do_ssl && !$do_crypto)
63 { 73 {
64 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n"; 74 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n";
@@ -70,9 +80,9 @@ $max_ssl = $max_num;
70%crypto_list=&load_numbers($crypto_num); 80%crypto_list=&load_numbers($crypto_num);
71$max_crypto = $max_num; 81$max_crypto = $max_num;
72 82
73$ssl="ssl/ssl.h"; 83my $ssl="ssl/ssl.h";
74 84
75$crypto ="crypto/crypto.h"; 85my $crypto ="crypto/crypto.h";
76$crypto.=" crypto/des/des.h" unless $no_des; 86$crypto.=" crypto/des/des.h" unless $no_des;
77$crypto.=" crypto/idea/idea.h" unless $no_idea; 87$crypto.=" crypto/idea/idea.h" unless $no_idea;
78$crypto.=" crypto/rc4/rc4.h" unless $no_rc4; 88$crypto.=" crypto/rc4/rc4.h" unless $no_rc4;
@@ -115,8 +125,8 @@ $crypto.=" crypto/rand/rand.h";
115$crypto.=" crypto/comp/comp.h"; 125$crypto.=" crypto/comp/comp.h";
116$crypto.=" crypto/tmdiff.h"; 126$crypto.=" crypto/tmdiff.h";
117 127
118@ssl_func = &do_defs("SSLEAY", $ssl); 128my @ssl_func = &do_defs("SSLEAY", $ssl);
119@crypto_func = &do_defs("LIBEAY", $crypto); 129my @crypto_func = &do_defs("LIBEAY", $crypto);
120 130
121 131
122if ($do_update) { 132if ($do_update) {
@@ -131,7 +141,26 @@ if($do_crypto == 1) {
131 open(OUT, ">>$crypto_num"); 141 open(OUT, ">>$crypto_num");
132 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func); 142 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func);
133 close OUT; 143 close OUT;
134} 144}
145
146} elsif ($do_ctest) {
147
148 print <<"EOF";
149
150/* Test file to check all DEF file symbols are present by trying
151 * to link to all of them. This is *not* intended to be run!
152 */
153
154int main()
155{
156EOF
157 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func)
158 if $do_ssl == 1;
159
160 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func)
161 if $do_crypto == 1;
162
163 print "}\n";
135 164
136} else { 165} else {
137 166
@@ -147,14 +176,15 @@ if($do_crypto == 1) {
147sub do_defs 176sub do_defs
148{ 177{
149 my($name,$files)=@_; 178 my($name,$files)=@_;
179 my $file;
150 my @ret; 180 my @ret;
151 my %funcs; 181 my %funcs;
182 my $cpp;
152 183
153 foreach $file (split(/\s+/,$files)) 184 foreach $file (split(/\s+/,$files))
154 { 185 {
155 open(IN,"<$file") || die "unable to open $file:$!\n"; 186 open(IN,"<$file") || die "unable to open $file:$!\n";
156 187 my $line = "", my $def= "";
157 my $line = "", $def= "";
158 my %tag = ( 188 my %tag = (
159 FreeBSD => 0, 189 FreeBSD => 0,
160 NOPROTO => 0, 190 NOPROTO => 0,
@@ -164,6 +194,22 @@ sub do_defs
164 NO_FP_API => 0, 194 NO_FP_API => 0,
165 CONST_STRICT => 0, 195 CONST_STRICT => 0,
166 TRUE => 1, 196 TRUE => 1,
197 NO_RC2 => 0,
198 NO_RC4 => 0,
199 NO_RC5 => 0,
200 NO_IDEA => 0,
201 NO_DES => 0,
202 NO_BF => 0,
203 NO_CAST => 0,
204 NO_MD2 => 0,
205 NO_MD5 => 0,
206 NO_SHA => 0,
207 NO_RIPEMD => 0,
208 NO_MDC2 => 0,
209 NO_RSA => 0,
210 NO_DSA => 0,
211 NO_DH => 0,
212 NO_HMAC => 0,
167 ); 213 );
168 while(<IN>) { 214 while(<IN>) {
169 last if (/BEGIN ERROR CODES/); 215 last if (/BEGIN ERROR CODES/);
@@ -214,6 +260,11 @@ sub do_defs
214 push(@tag,"TRUE"); 260 push(@tag,"TRUE");
215 $tag{"TRUE"}=1; 261 $tag{"TRUE"}=1;
216 next; 262 next;
263 } elsif (/^\#\s*if\s+0/) {
264 # Dummy tag
265 push(@tag,"TRUE");
266 $tag{"TRUE"}=-1;
267 next;
217 } elsif (/^\#/) { 268 } elsif (/^\#/) {
218 next; 269 next;
219 } 270 }
@@ -250,7 +301,20 @@ sub do_defs
250 } 301 }
251 $funcs{"PEM_read_bio_${1}"} = 1; 302 $funcs{"PEM_read_bio_${1}"} = 1;
252 $funcs{"PEM_write_bio_${1}"} = 1; 303 $funcs{"PEM_write_bio_${1}"} = 1;
253 } elsif ( 304 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
305 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
306 if($W32) {
307 $funcs{"PEM_write_${1}"} = 1;
308 }
309 $funcs{"PEM_write_bio_${1}"} = 1;
310 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
311 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
312 if($W32) {
313 $funcs{"PEM_read_${1}"} = 1;
314 }
315 $funcs{"PEM_read_bio_${1}"} = 1;
316 } elsif (
317 ($tag{'TRUE'} != -1) &&
254 ($tag{'FreeBSD'} != 1) && 318 ($tag{'FreeBSD'} != 1) &&
255 ($tag{'CONST_STRICT'} != 1) && 319 ($tag{'CONST_STRICT'} != 1) &&
256 (($W32 && ($tag{'WIN16'} != 1)) || 320 (($W32 && ($tag{'WIN16'} != 1)) ||
@@ -260,7 +324,23 @@ sub do_defs
260 ((!$W32 && $tag{'_WINDLL'} != -1) || 324 ((!$W32 && $tag{'_WINDLL'} != -1) ||
261 ($W32 && $tag{'_WINDLL'} != 1)) && 325 ($W32 && $tag{'_WINDLL'} != 1)) &&
262 ((($tag{'NO_FP_API'} != 1) && $W32) || 326 ((($tag{'NO_FP_API'} != 1) && $W32) ||
263 (($tag{'NO_FP_API'} != -1) && !$W32))) 327 (($tag{'NO_FP_API'} != -1) && !$W32)) &&
328 ($tag{'NO_RC2'} == 0 || !$no_rc2) &&
329 ($tag{'NO_RC4'} == 0 || !$no_rc4) &&
330 ($tag{'NO_RC5'} == 0 || !$no_rc5) &&
331 ($tag{'NO_IDEA'} == 0 || !$no_idea) &&
332 ($tag{'NO_DES'} == 0 || !$no_des) &&
333 ($tag{'NO_BF'} == 0 || !$no_bf) &&
334 ($tag{'NO_CAST'} == 0 || !$no_cast) &&
335 ($tag{'NO_MD2'} == 0 || !$no_md2) &&
336 ($tag{'NO_MD5'} == 0 || !$no_md5) &&
337 ($tag{'NO_SHA'} == 0 || !$no_sha) &&
338 ($tag{'NO_RIPEMD'} == 0 || !$no_ripemd) &&
339 ($tag{'NO_MDC2'} == 0 || !$no_mdc2) &&
340 ($tag{'NO_RSA'} == 0 || !$no_rsa) &&
341 ($tag{'NO_DSA'} == 0 || !$no_dsa) &&
342 ($tag{'NO_DH'} == 0 || !$no_dh) &&
343 ($tag{'NO_HMAC'} == 0 || !$no_hmac))
264 { 344 {
265 if (/{|\/\*/) { # } 345 if (/{|\/\*/) { # }
266 $line = $_; 346 $line = $_;
@@ -309,8 +389,8 @@ sub do_defs
309 # Prune the returned functions 389 # Prune the returned functions
310 390
311 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"}; 391 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"};
312 delete $funcs{"des_crypt"};
313 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref; 392 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref;
393 delete $funcs{"bn_dump1"};
314 394
315 if($W32) { 395 if($W32) {
316 delete $funcs{"BIO_s_file_internal"}; 396 delete $funcs{"BIO_s_file_internal"};
@@ -334,10 +414,31 @@ sub do_defs
334 return(@ret); 414 return(@ret);
335} 415}
336 416
417sub print_test_file
418{
419 (*OUT,my $name,*nums,my @functions)=@_;
420 my $n = 1; my @e; my @r;
421 my $func;
422
423 (@e)=grep(/^SSLeay/,@functions);
424 (@r)=grep(!/^SSLeay/,@functions);
425 @functions=((sort @e),(sort @r));
426
427 foreach $func (@functions) {
428 if (!defined($nums{$func})) {
429 printf STDERR "$func does not have a number assigned\n"
430 if(!$do_update);
431 } else {
432 $n=$nums{$func};
433 print OUT "\t$func();\n";
434 }
435 }
436}
437
337sub print_def_file 438sub print_def_file
338{ 439{
339 (*OUT,my $name,*nums,@functions)=@_; 440 (*OUT,my $name,*nums,my @functions)=@_;
340 my $n =1; 441 my $n = 1; my @e; my @r;
341 442
342 if ($W32) 443 if ($W32)
343 { $name.="32"; } 444 { $name.="32"; }
diff --git a/src/lib/libssl/src/util/mkerr.pl b/src/lib/libssl/src/util/mkerr.pl
index 4b3bccb13e..ebc059ef22 100644
--- a/src/lib/libssl/src/util/mkerr.pl
+++ b/src/lib/libssl/src/util/mkerr.pl
@@ -450,7 +450,7 @@ void ERR_load_${lib}_strings(void)
450#ifdef ${lib}_LIB_NAME 450#ifdef ${lib}_LIB_NAME
451 ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0); 451 ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0);
452 ERR_load_strings(0,${lib}_lib_name); 452 ERR_load_strings(0,${lib}_lib_name);
453#endif; 453#endif
454 } 454 }
455 } 455 }
456 456
diff --git a/src/lib/libssl/src/util/pl/BC-32.pl b/src/lib/libssl/src/util/pl/BC-32.pl
index 09c45a21a6..df6e2c742e 100644
--- a/src/lib/libssl/src/util/pl/BC-32.pl
+++ b/src/lib/libssl/src/util/pl/BC-32.pl
@@ -19,7 +19,7 @@ $out_def="out32";
19$tmp_def="tmp32"; 19$tmp_def="tmp32";
20$inc_def="inc32"; 20$inc_def="inc32";
21#enable max error messages, disable most common warnings 21#enable max error messages, disable most common warnings
22$cflags="-DWIN32_LEAN_AND_MEAN -j255 -w-aus -w-par -w-inl -c -tWC -tWM -DWINDOWS -DWIN32 -DL_ENDIAN "; 22$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl -c -tWC -tWM -DWINDOWS -DWIN32 -DL_ENDIAN ";
23if ($debug) 23if ($debug)
24{ 24{
25 $cflags.="-Od -y -v -vi- -D_DEBUG"; 25 $cflags.="-Od -y -v -vi- -D_DEBUG";
diff --git a/src/lib/libssl/src/util/pl/Mingw32.pl b/src/lib/libssl/src/util/pl/Mingw32.pl
index 84c2a22db3..585cacd820 100644
--- a/src/lib/libssl/src/util/pl/Mingw32.pl
+++ b/src/lib/libssl/src/util/pl/Mingw32.pl
@@ -17,7 +17,7 @@ $mkdir='gmkdir';
17 17
18$cc='gcc'; 18$cc='gcc';
19if ($debug) 19if ($debug)
20 { $cflags="-g2 -ggdb"; } 20 { $cflags="-DL_ENDIAN -g2 -ggdb"; }
21else 21else
22 { $cflags="-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall"; } 22 { $cflags="-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall"; }
23 23
diff --git a/src/lib/libssl/src/util/pl/VC-32.pl b/src/lib/libssl/src/util/pl/VC-32.pl
index 6db1c9fe23..046f0e253c 100644
--- a/src/lib/libssl/src/util/pl/VC-32.pl
+++ b/src/lib/libssl/src/util/pl/VC-32.pl
@@ -22,7 +22,7 @@ $inc_def="inc32";
22 22
23if ($debug) 23if ($debug)
24 { 24 {
25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWINDOWS -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG"; 25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG";
26 $lflags.=" /debug"; 26 $lflags.=" /debug";
27 $mlflags.=' /debug'; 27 $mlflags.=' /debug';
28 } 28 }
diff --git a/src/lib/libssl/src/util/pod2man.pl b/src/lib/libssl/src/util/pod2man.pl
new file mode 100644
index 0000000000..f5ec0767ed
--- /dev/null
+++ b/src/lib/libssl/src/util/pod2man.pl
@@ -0,0 +1,1181 @@
1: #!/usr/bin/perl-5.005
2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
4
5$DEF_PM_SECTION = '3pm' || '3';
6
7=head1 NAME
8
9pod2man - translate embedded Perl pod directives into man pages
10
11=head1 SYNOPSIS
12
13B<pod2man>
14[ B<--section=>I<manext> ]
15[ B<--release=>I<relpatch> ]
16[ B<--center=>I<string> ]
17[ B<--date=>I<string> ]
18[ B<--fixed=>I<font> ]
19[ B<--official> ]
20[ B<--lax> ]
21I<inputfile>
22
23=head1 DESCRIPTION
24
25B<pod2man> converts its input file containing embedded pod directives (see
26L<perlpod>) into nroff source suitable for viewing with nroff(1) or
27troff(1) using the man(7) macro set.
28
29Besides the obvious pod conversions, B<pod2man> also takes care of
30func(), func(n), and simple variable references like $foo or @bar so
31you don't have to use code escapes for them; complex expressions like
32C<$fred{'stuff'}> will still need to be escaped, though. Other nagging
33little roffish things that it catches include translating the minus in
34something like foo-bar, making a long dash--like this--into a real em
35dash, fixing up "paired quotes", putting a little space after the
36parens in something like func(), making C++ and PI look right, making
37double underbars have a little tiny space between them, making ALLCAPS
38a teeny bit smaller in troff(1), and escaping backslashes so you don't
39have to.
40
41=head1 OPTIONS
42
43=over 8
44
45=item center
46
47Set the centered header to a specific string. The default is
48"User Contributed Perl Documentation", unless the C<--official> flag is
49given, in which case the default is "Perl Programmers Reference Guide".
50
51=item date
52
53Set the left-hand footer string to this value. By default,
54the modification date of the input file will be used.
55
56=item fixed
57
58The fixed font to use for code refs. Defaults to CW.
59
60=item official
61
62Set the default header to indicate that this page is of
63the standard release in case C<--center> is not given.
64
65=item release
66
67Set the centered footer. By default, this is the current
68perl release.
69
70=item section
71
72Set the section for the C<.TH> macro. The standard conventions on
73sections are to use 1 for user commands, 2 for system calls, 3 for
74functions, 4 for devices, 5 for file formats, 6 for games, 7 for
75miscellaneous information, and 8 for administrator commands. This works
76best if you put your Perl man pages in a separate tree, like
77F</usr/local/perl/man/>. By default, section 1 will be used
78unless the file ends in F<.pm> in which case section 3 will be selected.
79
80=item lax
81
82Don't complain when required sections aren't present.
83
84=back
85
86=head1 Anatomy of a Proper Man Page
87
88For those not sure of the proper layout of a man page, here's
89an example of the skeleton of a proper man page. Head of the
90major headers should be setout as a C<=head1> directive, and
91are historically written in the rather startling ALL UPPER CASE
92format, although this is not mandatory.
93Minor headers may be included using C<=head2>, and are
94typically in mixed case.
95
96=over 10
97
98=item NAME
99
100Mandatory section; should be a comma-separated list of programs or
101functions documented by this podpage, such as:
102
103 foo, bar - programs to do something
104
105=item SYNOPSIS
106
107A short usage summary for programs and functions, which
108may someday be deemed mandatory.
109
110=item DESCRIPTION
111
112Long drawn out discussion of the program. It's a good idea to break this
113up into subsections using the C<=head2> directives, like
114
115 =head2 A Sample Subection
116
117 =head2 Yet Another Sample Subection
118
119=item OPTIONS
120
121Some people make this separate from the description.
122
123=item RETURN VALUE
124
125What the program or function returns if successful.
126
127=item ERRORS
128
129Exceptions, return codes, exit stati, and errno settings.
130
131=item EXAMPLES
132
133Give some example uses of the program.
134
135=item ENVIRONMENT
136
137Envariables this program might care about.
138
139=item FILES
140
141All files used by the program. You should probably use the FE<lt>E<gt>
142for these.
143
144=item SEE ALSO
145
146Other man pages to check out, like man(1), man(7), makewhatis(8), or catman(8).
147
148=item NOTES
149
150Miscellaneous commentary.
151
152=item CAVEATS
153
154Things to take special care with; sometimes called WARNINGS.
155
156=item DIAGNOSTICS
157
158All possible messages the program can print out--and
159what they mean.
160
161=item BUGS
162
163Things that are broken or just don't work quite right.
164
165=item RESTRICTIONS
166
167Bugs you don't plan to fix :-)
168
169=item AUTHOR
170
171Who wrote it (or AUTHORS if multiple).
172
173=item HISTORY
174
175Programs derived from other sources sometimes have this, or
176you might keep a modification log here.
177
178=back
179
180=head1 EXAMPLES
181
182 pod2man program > program.1
183 pod2man some_module.pm > /usr/perl/man/man3/some_module.3
184 pod2man --section=7 note.pod > note.7
185
186=head1 DIAGNOSTICS
187
188The following diagnostics are generated by B<pod2man>. Items
189marked "(W)" are non-fatal, whereas the "(F)" errors will cause
190B<pod2man> to immediately exit with a non-zero status.
191
192=over 4
193
194=item bad option in paragraph %d of %s: ``%s'' should be [%s]<%s>
195
196(W) If you start include an option, you should set it off
197as bold, italic, or code.
198
199=item can't open %s: %s
200
201(F) The input file wasn't available for the given reason.
202
203=item Improper man page - no dash in NAME header in paragraph %d of %s
204
205(W) The NAME header did not have an isolated dash in it. This is
206considered important.
207
208=item Invalid man page - no NAME line in %s
209
210(F) You did not include a NAME header, which is essential.
211
212=item roff font should be 1 or 2 chars, not `%s' (F)
213
214(F) The font specified with the C<--fixed> option was not
215a one- or two-digit roff font.
216
217=item %s is missing required section: %s
218
219(W) Required sections include NAME, DESCRIPTION, and if you're
220using a section starting with a 3, also a SYNOPSIS. Actually,
221not having a NAME is a fatal.
222
223=item Unknown escape: %s in %s
224
225(W) An unknown HTML entity (probably for an 8-bit character) was given via
226a C<EE<lt>E<gt>> directive. Besides amp, lt, gt, and quot, recognized
227entities are Aacute, aacute, Acirc, acirc, AElig, aelig, Agrave, agrave,
228Aring, aring, Atilde, atilde, Auml, auml, Ccedil, ccedil, Eacute, eacute,
229Ecirc, ecirc, Egrave, egrave, ETH, eth, Euml, euml, Iacute, iacute, Icirc,
230icirc, Igrave, igrave, Iuml, iuml, Ntilde, ntilde, Oacute, oacute, Ocirc,
231ocirc, Ograve, ograve, Oslash, oslash, Otilde, otilde, Ouml, ouml, szlig,
232THORN, thorn, Uacute, uacute, Ucirc, ucirc, Ugrave, ugrave, Uuml, uuml,
233Yacute, yacute, and yuml.
234
235=item Unmatched =back
236
237(W) You have a C<=back> without a corresponding C<=over>.
238
239=item Unrecognized pod directive: %s
240
241(W) You specified a pod directive that isn't in the known list of
242C<=head1>, C<=head2>, C<=item>, C<=over>, C<=back>, or C<=cut>.
243
244
245=back
246
247=head1 NOTES
248
249If you would like to print out a lot of man page continuously, you
250probably want to set the C and D registers to set contiguous page
251numbering and even/odd paging, at least on some versions of man(7).
252Settting the F register will get you some additional experimental
253indexing:
254
255 troff -man -rC1 -rD1 -rF1 perl.1 perldata.1 perlsyn.1 ...
256
257The indexing merely outputs messages via C<.tm> for each
258major page, section, subsection, item, and any C<XE<lt>E<gt>>
259directives.
260
261
262=head1 RESTRICTIONS
263
264None at this time.
265
266=head1 BUGS
267
268The =over and =back directives don't really work right. They
269take absolute positions instead of offsets, don't nest well, and
270making people count is suboptimal in any event.
271
272=head1 AUTHORS
273
274Original prototype by Larry Wall, but so massively hacked over by
275Tom Christiansen such that Larry probably doesn't recognize it anymore.
276
277=cut
278
279$/ = "";
280$cutting = 1;
281@Indices = ();
282
283# We try first to get the version number from a local binary, in case we're
284# running an installed version of Perl to produce documentation from an
285# uninstalled newer version's pod files.
286if ($^O ne 'plan9' and $^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32') {
287 my $perl = (-x './perl' && -f './perl' ) ?
288 './perl' :
289 ((-x '../perl' && -f '../perl') ?
290 '../perl' :
291 '');
292 ($version,$patch) = `$perl -e 'print $]'` =~ /^(\d\.\d{3})(\d{2})?/ if $perl;
293}
294# No luck; we'll just go with the running Perl's version
295($version,$patch) = $] =~ /^(.{5})(\d{2})?/ unless $version;
296$DEF_RELEASE = "perl $version";
297$DEF_RELEASE .= ", patch $patch" if $patch;
298
299
300sub makedate {
301 my $secs = shift;
302 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs);
303 my $mname = (qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec})[$mon];
304 $year += 1900;
305 return "$mday/$mname/$year";
306}
307
308use Getopt::Long;
309
310$DEF_SECTION = 1;
311$DEF_CENTER = "User Contributed Perl Documentation";
312$STD_CENTER = "Perl Programmers Reference Guide";
313$DEF_FIXED = 'CW';
314$DEF_LAX = 0;
315
316sub usage {
317 warn "$0: @_\n" if @_;
318 die <<EOF;
319usage: $0 [options] podpage
320Options are:
321 --section=manext (default "$DEF_SECTION")
322 --release=relpatch (default "$DEF_RELEASE")
323 --center=string (default "$DEF_CENTER")
324 --date=string (default "$DEF_DATE")
325 --fixed=font (default "$DEF_FIXED")
326 --official (default NOT)
327 --lax (default NOT)
328EOF
329}
330
331$uok = GetOptions( qw(
332 section=s
333 release=s
334 center=s
335 date=s
336 fixed=s
337 official
338 lax
339 help));
340
341$DEF_DATE = makedate((stat($ARGV[0]))[9] || time());
342
343usage("Usage error!") unless $uok;
344usage() if $opt_help;
345usage("Need one and only one podpage argument") unless @ARGV == 1;
346
347$section = $opt_section || ($ARGV[0] =~ /\.pm$/
348 ? $DEF_PM_SECTION : $DEF_SECTION);
349$RP = $opt_release || $DEF_RELEASE;
350$center = $opt_center || ($opt_official ? $STD_CENTER : $DEF_CENTER);
351$lax = $opt_lax || $DEF_LAX;
352
353$CFont = $opt_fixed || $DEF_FIXED;
354
355if (length($CFont) == 2) {
356 $CFont_embed = "\\f($CFont";
357}
358elsif (length($CFont) == 1) {
359 $CFont_embed = "\\f$CFont";
360}
361else {
362 die "roff font should be 1 or 2 chars, not `$CFont_embed'";
363}
364
365$date = $opt_date || $DEF_DATE;
366
367for (qw{NAME DESCRIPTION}) {
368# for (qw{NAME DESCRIPTION AUTHOR}) {
369 $wanna_see{$_}++;
370}
371$wanna_see{SYNOPSIS}++ if $section =~ /^3/;
372
373
374$name = @ARGV ? $ARGV[0] : "<STDIN>";
375$Filename = $name;
376if ($section =~ /^1/) {
377 require File::Basename;
378 $name = uc File::Basename::basename($name);
379}
380$name =~ s/\.(pod|p[lm])$//i;
381
382# Lose everything up to the first of
383# */lib/*perl* standard or site_perl module
384# */*perl*/lib from -D prefix=/opt/perl
385# */*perl*/ random module hierarchy
386# which works.
387$name =~ s-//+-/-g;
388if ($name =~ s-^.*?/lib/[^/]*perl[^/]*/--i
389 or $name =~ s-^.*?/[^/]*perl[^/]*/lib/--i
390 or $name =~ s-^.*?/[^/]*perl[^/]*/--i) {
391 # Lose ^site(_perl)?/.
392 $name =~ s-^site(_perl)?/--;
393 # Lose ^arch/. (XXX should we use Config? Just for archname?)
394 $name =~ s~^(.*-$^O|$^O-.*)/~~o;
395 # Lose ^version/.
396 $name =~ s-^\d+\.\d+/--;
397}
398
399# Translate Getopt/Long to Getopt::Long, etc.
400$name =~ s(/)(::)g;
401
402if ($name ne 'something') {
403 FCHECK: {
404 open(F, "< $ARGV[0]") || die "can't open $ARGV[0]: $!";
405 while (<F>) {
406 next unless /^=\b/;
407 if (/^=head1\s+NAME\s*$/) { # an /m would forgive mistakes
408 $_ = <F>;
409 unless (/\s*-+\s+/) {
410 $oops++;
411 warn "$0: Improper man page - no dash in NAME header in paragraph $. of $ARGV[0]\n"
412 } else {
413 my @n = split /\s+-+\s+/;
414 if (@n != 2) {
415 $oops++;
416 warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
417 }
418 else {
419 %namedesc = @n;
420 }
421 }
422 last FCHECK;
423 }
424 next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME
425 next if /^=pod\b/; # It is OK to have =pod before NAME
426 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
427 }
428 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
429 }
430 close F;
431}
432
433print <<"END";
434.rn '' }`
435''' \$RCSfile\$\$Revision\$\$Date\$
436'''
437''' \$Log\$
438'''
439.de Sh
440.br
441.if t .Sp
442.ne 5
443.PP
444\\fB\\\\\$1\\fR
445.PP
446..
447.de Sp
448.if t .sp .5v
449.if n .sp
450..
451.de Ip
452.br
453.ie \\\\n(.\$>=3 .ne \\\\\$3
454.el .ne 3
455.IP "\\\\\$1" \\\\\$2
456..
457.de Vb
458.ft $CFont
459.nf
460.ne \\\\\$1
461..
462.de Ve
463.ft R
464
465.fi
466..
467'''
468'''
469''' Set up \\*(-- to give an unbreakable dash;
470''' string Tr holds user defined translation string.
471''' Bell System Logo is used as a dummy character.
472'''
473.tr \\(*W-|\\(bv\\*(Tr
474.ie n \\{\\
475.ds -- \\(*W-
476.ds PI pi
477.if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
478.if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
479.ds L" ""
480.ds R" ""
481''' \\*(M", \\*(S", \\*(N" and \\*(T" are the equivalent of
482''' \\*(L" and \\*(R", except that they are used on ".xx" lines,
483''' such as .IP and .SH, which do another additional levels of
484''' double-quote interpretation
485.ds M" """
486.ds S" """
487.ds N" """""
488.ds T" """""
489.ds L' '
490.ds R' '
491.ds M' '
492.ds S' '
493.ds N' '
494.ds T' '
495'br\\}
496.el\\{\\
497.ds -- \\(em\\|
498.tr \\*(Tr
499.ds L" ``
500.ds R" ''
501.ds M" ``
502.ds S" ''
503.ds N" ``
504.ds T" ''
505.ds L' `
506.ds R' '
507.ds M' `
508.ds S' '
509.ds N' `
510.ds T' '
511.ds PI \\(*p
512'br\\}
513END
514
515print <<'END';
516.\" If the F register is turned on, we'll generate
517.\" index entries out stderr for the following things:
518.\" TH Title
519.\" SH Header
520.\" Sh Subsection
521.\" Ip Item
522.\" X<> Xref (embedded
523.\" Of course, you have to process the output yourself
524.\" in some meaninful fashion.
525.if \nF \{
526.de IX
527.tm Index:\\$1\t\\n%\t"\\$2"
528..
529.nr % 0
530.rr F
531.\}
532END
533
534print <<"END";
535.TH $name $section "$RP" "$date" "$center"
536.UC
537END
538
539push(@Indices, qq{.IX Title "$name $section"});
540
541while (($name, $desc) = each %namedesc) {
542 for ($name, $desc) { s/^\s+//; s/\s+$//; }
543 push(@Indices, qq(.IX Name "$name - $desc"\n));
544}
545
546print <<'END';
547.if n .hy 0
548.if n .na
549.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
550.de CQ \" put $1 in typewriter font
551END
552print ".ft $CFont\n";
553print <<'END';
554'if n "\c
555'if t \\&\\$1\c
556'if n \\&\\$1\c
557'if n \&"
558\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
559'.ft R
560..
561.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
562. \" AM - accent mark definitions
563.bd B 3
564. \" fudge factors for nroff and troff
565.if n \{\
566. ds #H 0
567. ds #V .8m
568. ds #F .3m
569. ds #[ \f1
570. ds #] \fP
571.\}
572.if t \{\
573. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
574. ds #V .6m
575. ds #F 0
576. ds #[ \&
577. ds #] \&
578.\}
579. \" simple accents for nroff and troff
580.if n \{\
581. ds ' \&
582. ds ` \&
583. ds ^ \&
584. ds , \&
585. ds ~ ~
586. ds ? ?
587. ds ! !
588. ds /
589. ds q
590.\}
591.if t \{\
592. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
593. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
594. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
595. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
596. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
597. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
598. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
599. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
600. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
601.\}
602. \" troff and (daisy-wheel) nroff accents
603.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
604.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
605.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
606.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
607.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
608.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
609.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
610.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
611.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
612.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
613.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
614.ds ae a\h'-(\w'a'u*4/10)'e
615.ds Ae A\h'-(\w'A'u*4/10)'E
616.ds oe o\h'-(\w'o'u*4/10)'e
617.ds Oe O\h'-(\w'O'u*4/10)'E
618. \" corrections for vroff
619.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
620.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
621. \" for low resolution devices (crt and lpr)
622.if \n(.H>23 .if \n(.V>19 \
623\{\
624. ds : e
625. ds 8 ss
626. ds v \h'-1'\o'\(aa\(ga'
627. ds _ \h'-1'^
628. ds . \h'-1'.
629. ds 3 3
630. ds o a
631. ds d- d\h'-1'\(ga
632. ds D- D\h'-1'\(hy
633. ds th \o'bp'
634. ds Th \o'LP'
635. ds ae ae
636. ds Ae AE
637. ds oe oe
638. ds Oe OE
639.\}
640.rm #[ #] #H #V #F C
641END
642
643$indent = 0;
644
645$begun = "";
646
647# Unrolling [^A-Z>]|[A-Z](?!<) gives: // MRE pp 165.
648my $nonest = '(?:[^A-Z>]*(?:[A-Z](?!<)[^A-Z>]*)*)';
649
650while (<>) {
651 if ($cutting) {
652 next unless /^=/;
653 $cutting = 0;
654 }
655 if ($begun) {
656 if (/^=end\s+$begun/) {
657 $begun = "";
658 }
659 elsif ($begun =~ /^(roff|man)$/) {
660 print STDOUT $_;
661 }
662 next;
663 }
664 chomp;
665
666 # Translate verbatim paragraph
667
668 if (/^\s/) {
669 @lines = split(/\n/);
670 for (@lines) {
671 1 while s
672 {^( [^\t]* ) \t ( \t* ) }
673 { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
674 s/\\/\\e/g;
675 s/\A/\\&/s;
676 }
677 $lines = @lines;
678 makespace() unless $verbatim++;
679 print ".Vb $lines\n";
680 print join("\n", @lines), "\n";
681 print ".Ve\n";
682 $needspace = 0;
683 next;
684 }
685
686 $verbatim = 0;
687
688 if (/^=for\s+(\S+)\s*/s) {
689 if ($1 eq "man" or $1 eq "roff") {
690 print STDOUT $',"\n\n";
691 } else {
692 # ignore unknown for
693 }
694 next;
695 }
696 elsif (/^=begin\s+(\S+)\s*/s) {
697 $begun = $1;
698 if ($1 eq "man" or $1 eq "roff") {
699 print STDOUT $'."\n\n";
700 }
701 next;
702 }
703
704 # check for things that'll hosed our noremap scheme; affects $_
705 init_noremap();
706
707 if (!/^=item/) {
708
709 # trofficate backslashes; must do it before what happens below
710 s/\\/noremap('\\e')/ge;
711
712 # protect leading periods and quotes against *roff
713 # mistaking them for directives
714 s/^(?:[A-Z]<)?[.']/\\&$&/gm;
715
716 # first hide the escapes in case we need to
717 # intuit something and get it wrong due to fmting
718
719 1 while s/([A-Z]<$nonest>)/noremap($1)/ge;
720
721 # func() is a reference to a perl function
722 s{
723 \b
724 (
725 [:\w]+ \(\)
726 )
727 } {I<$1>}gx;
728
729 # func(n) is a reference to a perl function or a man page
730 s{
731 ([:\w]+)
732 (
733 \( [^\051]+ \)
734 )
735 } {I<$1>\\|$2}gx;
736
737 # convert simple variable references
738 s/(\s+)([\$\@%][\w:]+)(?!\()/${1}C<$2>/g;
739
740 if (m{ (
741 [\-\w]+
742 \(
743 [^\051]*?
744 [\@\$,]
745 [^\051]*?
746 \)
747 )
748 }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
749 {
750 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [LCI]<$1>\n";
751 $oops++;
752 }
753
754 while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
755 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [CB]<$1>\n";
756 $oops++;
757 }
758
759 # put it back so we get the <> processed again;
760 clear_noremap(0); # 0 means leave the E's
761
762 } else {
763 # trofficate backslashes
764 s/\\/noremap('\\e')/ge;
765
766 }
767
768 # need to hide E<> first; they're processed in clear_noremap
769 s/(E<[^<>]+>)/noremap($1)/ge;
770
771
772 $maxnest = 10;
773 while ($maxnest-- && /[A-Z]</) {
774
775 # can't do C font here
776 s/([BI])<($nonest)>/font($1) . $2 . font('R')/eg;
777
778 # files and filelike refs in italics
779 s/F<($nonest)>/I<$1>/g;
780
781 # no break -- usually we want C<> for this
782 s/S<($nonest)>/nobreak($1)/eg;
783
784 # LREF: a la HREF L<show this text|man/section>
785 s:L<([^|>]+)\|[^>]+>:$1:g;
786
787 # LREF: a manpage(3f)
788 s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
789
790 # LREF: an =item on another manpage
791 s{
792 L<
793 ([^/]+)
794 /
795 (
796 [:\w]+
797 (\(\))?
798 )
799 >
800 } {the C<$2> entry in the I<$1> manpage}gx;
801
802 # LREF: an =item on this manpage
803 s{
804 ((?:
805 L<
806 /
807 (
808 [:\w]+
809 (\(\))?
810 )
811 >
812 (,?\s+(and\s+)?)?
813 )+)
814 } { internal_lrefs($1) }gex;
815
816 # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
817 # the "func" can disambiguate
818 s{
819 L<
820 (?:
821 ([a-zA-Z]\S+?) /
822 )?
823 "?(.*?)"?
824 >
825 }{
826 do {
827 $1 # if no $1, assume it means on this page.
828 ? "the section on I<$2> in the I<$1> manpage"
829 : "the section on I<$2>"
830 }
831 }gesx; # s in case it goes over multiple lines, so . matches \n
832
833 s/Z<>/\\&/g;
834
835 # comes last because not subject to reprocessing
836 s/C<($nonest)>/noremap("${CFont_embed}${1}\\fR")/eg;
837 }
838
839 if (s/^=//) {
840 $needspace = 0; # Assume this.
841
842 s/\n/ /g;
843
844 ($Cmd, $_) = split(' ', $_, 2);
845
846 $dotlevel = 1;
847 if ($Cmd eq 'head1') {
848 $dotlevel = 1;
849 }
850 elsif ($Cmd eq 'head2') {
851 $dotlevel = 1;
852 }
853 elsif ($Cmd eq 'item') {
854 $dotlevel = 2;
855 }
856
857 if (defined $_) {
858 &escapes($dotlevel);
859 s/"/""/g;
860 }
861
862 clear_noremap(1);
863
864 if ($Cmd eq 'cut') {
865 $cutting = 1;
866 }
867 elsif ($Cmd eq 'head1') {
868 s/\s+$//;
869 delete $wanna_see{$_} if exists $wanna_see{$_};
870 print qq{.SH "$_"\n};
871 push(@Indices, qq{.IX Header "$_"\n});
872 }
873 elsif ($Cmd eq 'head2') {
874 print qq{.Sh "$_"\n};
875 push(@Indices, qq{.IX Subsection "$_"\n});
876 }
877 elsif ($Cmd eq 'over') {
878 push(@indent,$indent);
879 $indent += ($_ + 0) || 5;
880 }
881 elsif ($Cmd eq 'back') {
882 $indent = pop(@indent);
883 warn "$0: Unmatched =back in paragraph $. of $ARGV\n" unless defined $indent;
884 $needspace = 1;
885 }
886 elsif ($Cmd eq 'item') {
887 s/^\*( |$)/\\(bu$1/g;
888 # if you know how to get ":s please do
889 s/\\\*\(L"([^"]+?)\\\*\(R"/'$1'/g;
890 s/\\\*\(L"([^"]+?)""/'$1'/g;
891 s/[^"]""([^"]+?)""[^"]/'$1'/g;
892 # here do something about the $" in perlvar?
893 print STDOUT qq{.Ip "$_" $indent\n};
894 push(@Indices, qq{.IX Item "$_"\n});
895 }
896 elsif ($Cmd eq 'pod') {
897 # this is just a comment
898 }
899 else {
900 warn "$0: Unrecognized pod directive in paragraph $. of $ARGV: $Cmd\n";
901 }
902 }
903 else {
904 if ($needspace) {
905 &makespace;
906 }
907 &escapes(0);
908 clear_noremap(1);
909 print $_, "\n";
910 $needspace = 1;
911 }
912}
913
914print <<"END";
915
916.rn }` ''
917END
918
919if (%wanna_see && !$lax) {
920 @missing = keys %wanna_see;
921 warn "$0: $Filename is missing required section"
922 . (@missing > 1 && "s")
923 . ": @missing\n";
924 $oops++;
925}
926
927foreach (@Indices) { print "$_\n"; }
928
929exit;
930#exit ($oops != 0);
931
932#########################################################################
933
934sub nobreak {
935 my $string = shift;
936 $string =~ s/ /\\ /g;
937 $string;
938}
939
940sub escapes {
941 my $indot = shift;
942
943 s/X<(.*?)>/mkindex($1)/ge;
944
945 # translate the minus in foo-bar into foo\-bar for roff
946 s/([^0-9a-z-])-([^-])/$1\\-$2/g;
947
948 # make -- into the string version \*(-- (defined above)
949 s/\b--\b/\\*(--/g;
950 s/"--([^"])/"\\*(--$1/g; # should be a better way
951 s/([^"])--"/$1\\*(--"/g;
952
953 # fix up quotes; this is somewhat tricky
954 my $dotmacroL = 'L';
955 my $dotmacroR = 'R';
956 if ( $indot == 1 ) {
957 $dotmacroL = 'M';
958 $dotmacroR = 'S';
959 }
960 elsif ( $indot >= 2 ) {
961 $dotmacroL = 'N';
962 $dotmacroR = 'T';
963 }
964 if (!/""/) {
965 s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
966 s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
967 }
968
969 #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
970 #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
971
972
973 # make sure that func() keeps a bit a space tween the parens
974 ### s/\b\(\)/\\|()/g;
975 ### s/\b\(\)/(\\|)/g;
976
977 # make C++ into \*C+, which is a squinched version (defined above)
978 s/\bC\+\+/\\*(C+/g;
979
980 # make double underbars have a little tiny space between them
981 s/__/_\\|_/g;
982
983 # PI goes to \*(PI (defined above)
984 s/\bPI\b/noremap('\\*(PI')/ge;
985
986 # make all caps a teeny bit smaller, but don't muck with embedded code literals
987 my $hidCFont = font('C');
988 if ($Cmd !~ /^head1/) { # SH already makes smaller
989 # /g isn't enough; 1 while or we'll be off
990
991# 1 while s{
992# (?!$hidCFont)(..|^.|^)
993# \b
994# (
995# [A-Z][\/A-Z+:\-\d_$.]+
996# )
997# (s?)
998# \b
999# } {$1\\s-1$2\\s0}gmox;
1000
1001 1 while s{
1002 (?!$hidCFont)(..|^.|^)
1003 (
1004 \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
1005 )
1006 } {
1007 $1 . noremap( '\\s-1' . $2 . '\\s0' )
1008 }egmox;
1009
1010 }
1011}
1012
1013# make troff just be normal, but make small nroff get quoted
1014# decided to just put the quotes in the text; sigh;
1015sub ccvt {
1016 local($_,$prev) = @_;
1017 noremap(qq{.CQ "$_" \n\\&});
1018}
1019
1020sub makespace {
1021 if ($indent) {
1022 print ".Sp\n";
1023 }
1024 else {
1025 print ".PP\n";
1026 }
1027}
1028
1029sub mkindex {
1030 my ($entry) = @_;
1031 my @entries = split m:\s*/\s*:, $entry;
1032 push @Indices, ".IX Xref " . join ' ', map {qq("$_")} @entries;
1033 return '';
1034}
1035
1036sub font {
1037 local($font) = shift;
1038 return '\\f' . noremap($font);
1039}
1040
1041sub noremap {
1042 local($thing_to_hide) = shift;
1043 $thing_to_hide =~ tr/\000-\177/\200-\377/;
1044 return $thing_to_hide;
1045}
1046
1047sub init_noremap {
1048 # escape high bit characters in input stream
1049 s/([\200-\377])/"E<".ord($1).">"/ge;
1050}
1051
1052sub clear_noremap {
1053 my $ready_to_print = $_[0];
1054
1055 tr/\200-\377/\000-\177/;
1056
1057 # trofficate backslashes
1058 # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
1059
1060 # now for the E<>s, which have been hidden until now
1061 # otherwise the interative \w<> processing would have
1062 # been hosed by the E<gt>
1063 s {
1064 E<
1065 (
1066 ( \d + )
1067 | ( [A-Za-z]+ )
1068 )
1069 >
1070 } {
1071 do {
1072 defined $2
1073 ? chr($2)
1074 :
1075 exists $HTML_Escapes{$3}
1076 ? do { $HTML_Escapes{$3} }
1077 : do {
1078 warn "$0: Unknown escape in paragraph $. of $ARGV: ``$&''\n";
1079 "E<$1>";
1080 }
1081 }
1082 }egx if $ready_to_print;
1083}
1084
1085sub internal_lrefs {
1086 local($_) = shift;
1087 local $trailing_and = s/and\s+$// ? "and " : "";
1088
1089 s{L</([^>]+)>}{$1}g;
1090 my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
1091 my $retstr = "the ";
1092 my $i;
1093 for ($i = 0; $i <= $#items; $i++) {
1094 $retstr .= "C<$items[$i]>";
1095 $retstr .= ", " if @items > 2 && $i != $#items;
1096 $retstr .= " and " if $i+2 == @items;
1097 }
1098
1099 $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
1100 . " elsewhere in this document";
1101 # terminal space to avoid words running together (pattern used
1102 # strips terminal spaces)
1103 $retstr .= " " if length $trailing_and;
1104 $retstr .= $trailing_and;
1105
1106 return $retstr;
1107
1108}
1109
1110BEGIN {
1111%HTML_Escapes = (
1112 'amp' => '&', # ampersand
1113 'lt' => '<', # left chevron, less-than
1114 'gt' => '>', # right chevron, greater-than
1115 'quot' => '"', # double quote
1116
1117 "Aacute" => "A\\*'", # capital A, acute accent
1118 "aacute" => "a\\*'", # small a, acute accent
1119 "Acirc" => "A\\*^", # capital A, circumflex accent
1120 "acirc" => "a\\*^", # small a, circumflex accent
1121 "AElig" => '\*(AE', # capital AE diphthong (ligature)
1122 "aelig" => '\*(ae', # small ae diphthong (ligature)
1123 "Agrave" => "A\\*`", # capital A, grave accent
1124 "agrave" => "A\\*`", # small a, grave accent
1125 "Aring" => 'A\\*o', # capital A, ring
1126 "aring" => 'a\\*o', # small a, ring
1127 "Atilde" => 'A\\*~', # capital A, tilde
1128 "atilde" => 'a\\*~', # small a, tilde
1129 "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
1130 "auml" => 'a\\*:', # small a, dieresis or umlaut mark
1131 "Ccedil" => 'C\\*,', # capital C, cedilla
1132 "ccedil" => 'c\\*,', # small c, cedilla
1133 "Eacute" => "E\\*'", # capital E, acute accent
1134 "eacute" => "e\\*'", # small e, acute accent
1135 "Ecirc" => "E\\*^", # capital E, circumflex accent
1136 "ecirc" => "e\\*^", # small e, circumflex accent
1137 "Egrave" => "E\\*`", # capital E, grave accent
1138 "egrave" => "e\\*`", # small e, grave accent
1139 "ETH" => '\\*(D-', # capital Eth, Icelandic
1140 "eth" => '\\*(d-', # small eth, Icelandic
1141 "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
1142 "euml" => "e\\*:", # small e, dieresis or umlaut mark
1143 "Iacute" => "I\\*'", # capital I, acute accent
1144 "iacute" => "i\\*'", # small i, acute accent
1145 "Icirc" => "I\\*^", # capital I, circumflex accent
1146 "icirc" => "i\\*^", # small i, circumflex accent
1147 "Igrave" => "I\\*`", # capital I, grave accent
1148 "igrave" => "i\\*`", # small i, grave accent
1149 "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
1150 "iuml" => "i\\*:", # small i, dieresis or umlaut mark
1151 "Ntilde" => 'N\*~', # capital N, tilde
1152 "ntilde" => 'n\*~', # small n, tilde
1153 "Oacute" => "O\\*'", # capital O, acute accent
1154 "oacute" => "o\\*'", # small o, acute accent
1155 "Ocirc" => "O\\*^", # capital O, circumflex accent
1156 "ocirc" => "o\\*^", # small o, circumflex accent
1157 "Ograve" => "O\\*`", # capital O, grave accent
1158 "ograve" => "o\\*`", # small o, grave accent
1159 "Oslash" => "O\\*/", # capital O, slash
1160 "oslash" => "o\\*/", # small o, slash
1161 "Otilde" => "O\\*~", # capital O, tilde
1162 "otilde" => "o\\*~", # small o, tilde
1163 "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
1164 "ouml" => "o\\*:", # small o, dieresis or umlaut mark
1165 "szlig" => '\*8', # small sharp s, German (sz ligature)
1166 "THORN" => '\\*(Th', # capital THORN, Icelandic
1167 "thorn" => '\\*(th',, # small thorn, Icelandic
1168 "Uacute" => "U\\*'", # capital U, acute accent
1169 "uacute" => "u\\*'", # small u, acute accent
1170 "Ucirc" => "U\\*^", # capital U, circumflex accent
1171 "ucirc" => "u\\*^", # small u, circumflex accent
1172 "Ugrave" => "U\\*`", # capital U, grave accent
1173 "ugrave" => "u\\*`", # small u, grave accent
1174 "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
1175 "uuml" => "u\\*:", # small u, dieresis or umlaut mark
1176 "Yacute" => "Y\\*'", # capital Y, acute accent
1177 "yacute" => "y\\*'", # small y, acute accent
1178 "yuml" => "y\\*:", # small y, dieresis or umlaut mark
1179);
1180}
1181
diff --git a/src/lib/libssl/src/util/selftest.pl b/src/lib/libssl/src/util/selftest.pl
new file mode 100644
index 0000000000..91e962a312
--- /dev/null
+++ b/src/lib/libssl/src/util/selftest.pl
@@ -0,0 +1,174 @@
1#!/usr/local/bin/perl -w
2#
3# Run the test suite and generate a report
4#
5
6if (! -f "Configure") {
7 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
8 exit 1;
9}
10
11my $report="testlog";
12my $os="??";
13my $version="??";
14my $platform0="??";
15my $platform="??";
16my $options="??";
17my $last="??";
18my $ok=0;
19my $cc="cc";
20my $cversion="??";
21my $sep="-----------------------------------------------------------------------------\n";
22
23open(OUT,">$report") or die;
24
25print OUT "OpenSSL self-test report:\n\n";
26
27$uname=`uname -a`;
28$uname="??" if $uname eq "";
29
30$c=`sh config -t`;
31foreach $_ (split("\n",$c)) {
32 $os=$1 if (/Operating system: (.*)$/);
33 $platform0=$1 if (/Configuring for (.*)$/);
34}
35
36system "sh config" if (! -f "Makefile.ssl");
37
38if (open(IN,"<Makefile.ssl")) {
39 while (<IN>) {
40 $version=$1 if (/^VERSION=(.*)$/);
41 $platform=$1 if (/^PLATFORM=(.*)$/);
42 $options=$1 if (/^OPTIONS=(.*)$/);
43 $cc=$1 if (/^CC= *(.*)$/);
44 }
45 close(IN);
46} else {
47 print OUT "Error running config!\n";
48}
49
50$cversion=`$cc -v 2>&1`;
51$cversion=`$cc -V 2>&1` if $cversion =~ "usage";
52$cversion=`$cc --version` if $cversion eq "";
53$cversion =~ s/Reading specs.*\n//;
54$cversion =~ s/usage.*\n//;
55chomp $cversion;
56
57if (open(IN,"<CHANGES")) {
58 while(<IN>) {
59 if (/\*\) (.{0,55})/) {
60 $last=$1;
61 last;
62 }
63 }
64 close(IN);
65}
66
67print OUT "OpenSSL version: $version\n";
68print OUT "Last change: $last...\n";
69print OUT "Options: $options\n" if $options ne "";
70print OUT "OS (uname): $uname";
71print OUT "OS (config): $os\n";
72print OUT "Target (default): $platform0\n";
73print OUT "Target: $platform\n";
74print OUT "Compiler: $cversion\n";
75print OUT "\n";
76
77print "Checking compiler...\n";
78if (open(TEST,">cctest.c")) {
79 print TEST "#include <stdio.h>\nmain(){printf(\"Hello world\\n\");}\n";
80 close(TEST);
81 system("$cc -o cctest cctest.c");
82 if (`./cctest` !~ /Hello world/) {
83 print OUT "Compiler doesn't work.\n";
84 goto err;
85 }
86} else {
87 print OUT "Can't create cctest.c\n";
88}
89if (open(TEST,">cctest.c")) {
90 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
91 close(TEST);
92 system("$cc -o cctest -Iinclude cctest.c");
93 $cctest = `./cctest`;
94 if ($cctest !~ /OpenSSL $version/) {
95 if ($cctest =~ /OpenSSL/) {
96 print OUT "#include uses headers from different OpenSSL version!\n";
97 } else {
98 print OUT "Can't compile test program!\n";
99 }
100 goto err;
101 }
102} else {
103 print OUT "Can't create cctest.c\n";
104}
105
106print "Running make...\n";
107if (system("make 2>&1 | tee make.log") > 255) {
108
109 print OUT "make failed!\n";
110 if (open(IN,"<make.log")) {
111 print OUT $sep;
112 while (<IN>) {
113 print OUT;
114 }
115 close(IN);
116 print OUT $sep;
117 } else {
118 print OUT "make.log not found!\n";
119 }
120 goto err;
121}
122
123$_=$options;
124s/no-asm//;
125if (/no-/)
126{
127 print OUT "Test skipped.\n";
128 goto err;
129}
130
131print "Running make test...\n";
132if (system("make test 2>&1 | tee make.log") > 255)
133 {
134 print OUT "make test failed!\n";
135} else {
136 $ok=1;
137}
138
139if ($ok and open(IN,"<make.log")) {
140 while (<IN>) {
141 $ok=2 if /^platform: $platform/;
142 }
143 close(IN);
144}
145
146if ($ok != 2) {
147 print OUT "Failure!\n";
148 if (open(IN,"<make.log")) {
149 print OUT $sep;
150 while (<IN>) {
151 print OUT;
152 }
153 close(IN);
154 print OUT $sep;
155 } else {
156 print OUT "make.log not found!\n";
157 }
158} else {
159 print OUT "Test passed.\n";
160}
161err:
162close(OUT);
163
164print "\n";
165open(IN,"<$report") or die;
166while (<IN>) {
167 if (/$sep/) {
168 print "[...]\n";
169 last;
170 }
171 print;
172}
173print "\nTest report in file $report\n";
174
diff --git a/src/lib/libssl/src/util/ssleay.num b/src/lib/libssl/src/util/ssleay.num
index 8121738bd6..32b2e960c4 100644
--- a/src/lib/libssl/src/util/ssleay.num
+++ b/src/lib/libssl/src/util/ssleay.num
@@ -215,3 +215,13 @@ SSL_CTX_set_cert_verify_callback 232
215sk_SSL_COMP_sort 233 215sk_SSL_COMP_sort 233
216sk_SSL_CIPHER_sort 234 216sk_SSL_CIPHER_sort 234
217SSL_CTX_set_default_passwd_cb_userdata 235 217SSL_CTX_set_default_passwd_cb_userdata 235
218SSL_set_purpose 236
219SSL_CTX_set_trust 237
220SSL_CTX_set_purpose 238
221SSL_set_trust 239
222SSL_get_finished 240
223SSL_get_peer_finished 241
224SSL_get1_session 242
225SSL_CTX_callback_ctrl 243
226SSL_callback_ctrl 244
227SSL_CTX_sessions 245
diff --git a/src/lib/libssl/ssl-patent/shlib_version b/src/lib/libssl/ssl-patent/shlib_version
index c6e3f4d3fc..b363be4447 100644
--- a/src/lib/libssl/ssl-patent/shlib_version
+++ b/src/lib/libssl/ssl-patent/shlib_version
@@ -1,2 +1,2 @@
1major=2 1major=2
2minor=1 2minor=3
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h
index fbe4f667fa..f29f775347 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/lib/libssl/ssl.h
@@ -123,8 +123,9 @@ extern "C" {
123#define SSL_TXT_MD5 "MD5" 123#define SSL_TXT_MD5 "MD5"
124#define SSL_TXT_SHA1 "SHA1" 124#define SSL_TXT_SHA1 "SHA1"
125#define SSL_TXT_SHA "SHA" 125#define SSL_TXT_SHA "SHA"
126#define SSL_TXT_EXP40 "EXP" 126#define SSL_TXT_EXP "EXP"
127#define SSL_TXT_EXPORT "EXPORT" 127#define SSL_TXT_EXPORT "EXPORT"
128#define SSL_TXT_EXP40 "EXPORT40"
128#define SSL_TXT_EXP56 "EXPORT56" 129#define SSL_TXT_EXP56 "EXPORT56"
129#define SSL_TXT_SSLV2 "SSLv2" 130#define SSL_TXT_SSLV2 "SSLv2"
130#define SSL_TXT_SSLV3 "SSLv3" 131#define SSL_TXT_SSLV3 "SSLv3"
@@ -133,12 +134,7 @@ extern "C" {
133 134
134/* 'DEFAULT' at the start of the cipher list insert the following string 135/* 'DEFAULT' at the start of the cipher list insert the following string
135 * in addition to this being the default cipher string */ 136 * in addition to this being the default cipher string */
136#ifndef NO_RSA 137#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+SSLv2:@STRENGTH"
137#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP"
138#else
139#define SSL_ALLOW_ADH
140#define SSL_DEFAULT_CIPHER_LIST "HIGH:MEDIUM:LOW:ADH+3DES:ADH+RC4:ADH+DES:+EXP"
141#endif
142 138
143/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ 139/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
144#define SSL_SENT_SHUTDOWN 1 140#define SSL_SENT_SHUTDOWN 1
@@ -151,6 +147,10 @@ extern "C" {
151#include <openssl/pem.h> 147#include <openssl/pem.h>
152#include <openssl/x509.h> 148#include <openssl/x509.h>
153 149
150#if (defined(NO_RSA) || defined(NO_MD5)) && !defined(NO_SSL2)
151#define NO_SSL2
152#endif
153
154#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 154#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
155#define SSL_FILETYPE_PEM X509_FILETYPE_PEM 155#define SSL_FILETYPE_PEM X509_FILETYPE_PEM
156 156
@@ -166,8 +166,12 @@ typedef struct ssl_cipher_st
166 const char *name; /* text name */ 166 const char *name; /* text name */
167 unsigned long id; /* id, 4 bytes, first is version */ 167 unsigned long id; /* id, 4 bytes, first is version */
168 unsigned long algorithms; /* what ciphers are used */ 168 unsigned long algorithms; /* what ciphers are used */
169 unsigned long algo_strength; /* strength and export flags */
169 unsigned long algorithm2; /* Extra flags */ 170 unsigned long algorithm2; /* Extra flags */
171 int strength_bits; /* Number of bits really used */
172 int alg_bits; /* Number of bits for algorithm */
170 unsigned long mask; /* used for matching */ 173 unsigned long mask; /* used for matching */
174 unsigned long mask_strength; /* also used for matching */
171 } SSL_CIPHER; 175 } SSL_CIPHER;
172 176
173DECLARE_STACK_OF(SSL_CIPHER) 177DECLARE_STACK_OF(SSL_CIPHER)
@@ -201,6 +205,8 @@ typedef struct ssl_method_st
201 long (*get_timeout)(void); 205 long (*get_timeout)(void);
202 struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ 206 struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
203 int (*ssl_version)(); 207 int (*ssl_version)();
208 long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)());
209 long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)());
204 } SSL_METHOD; 210 } SSL_METHOD;
205 211
206/* Lets make this into an ASN.1 type structure as follows 212/* Lets make this into an ASN.1 type structure as follows
@@ -215,7 +221,8 @@ typedef struct ssl_method_st
215 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds 221 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
216 * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate 222 * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate
217 * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context 223 * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context
218 * Compression [5] IMPLICIT ASN1_OBJECT -- compression OID XXXXX 224 * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer'
225 * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX
219 * } 226 * }
220 * Look in ssl/ssl_asn1.c for more details 227 * Look in ssl/ssl_asn1.c for more details
221 * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). 228 * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
@@ -249,6 +256,9 @@ typedef struct ssl_session_st
249 * (the latter is not enough as sess_cert is not retained 256 * (the latter is not enough as sess_cert is not retained
250 * in the external representation of sessions, see ssl_asn1.c). */ 257 * in the external representation of sessions, see ssl_asn1.c). */
251 X509 *peer; 258 X509 *peer;
259 /* when app_verify_callback accepts a session where the peer's certificate
260 * is not ok, we must remember the error for session reuse: */
261 long verify_result; /* only for servers */
252 262
253 int references; 263 int references;
254 long timeout; 264 long timeout;
@@ -291,6 +301,7 @@ typedef struct ssl_session_st
291#define SSL_OP_PKCS1_CHECK_1 0x08000000L 301#define SSL_OP_PKCS1_CHECK_1 0x08000000L
292#define SSL_OP_PKCS1_CHECK_2 0x10000000L 302#define SSL_OP_PKCS1_CHECK_2 0x10000000L
293#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L 303#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L
304/* SSL_OP_NON_EXPORT_FIRST looks utterly broken .. */
294#define SSL_OP_NON_EXPORT_FIRST 0x40000000L 305#define SSL_OP_NON_EXPORT_FIRST 0x40000000L
295#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L 306#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L
296#define SSL_OP_ALL 0x000FFFFFL 307#define SSL_OP_ALL 0x000FFFFFL
@@ -355,9 +366,9 @@ struct ssl_ctx_st
355 STACK_OF(SSL_CIPHER) *cipher_list_by_id; 366 STACK_OF(SSL_CIPHER) *cipher_list_by_id;
356 367
357 struct x509_store_st /* X509_STORE */ *cert_store; 368 struct x509_store_st /* X509_STORE */ *cert_store;
358 struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSION's */ 369 struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */
359 /* Most session-ids that will be cached, default is 370 /* Most session-ids that will be cached, default is
360 * SSL_SESSION_CACHE_SIZE_DEFAULT. 0 is unlimited. */ 371 * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
361 unsigned long session_cache_size; 372 unsigned long session_cache_size;
362 struct ssl_session_st *session_cache_head; 373 struct ssl_session_st *session_cache_head;
363 struct ssl_session_st *session_cache_tail; 374 struct ssl_session_st *session_cache_tail;
@@ -424,6 +435,9 @@ struct ssl_ctx_st
424/**/ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; 435/**/ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
425/**/ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); 436/**/ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx);
426 437
438 int purpose; /* Purpose setting */
439 int trust; /* Trust setting */
440
427 /* Default password callback. */ 441 /* Default password callback. */
428/**/ pem_password_cb *default_passwd_callback; 442/**/ pem_password_cb *default_passwd_callback;
429 443
@@ -433,7 +447,7 @@ struct ssl_ctx_st
433 /* get client cert callback */ 447 /* get client cert callback */
434/**/ int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */); 448/**/ int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */);
435 449
436 /* what we put in client requests */ 450 /* what we put in client cert requests */
437 STACK_OF(X509_NAME) *client_CA; 451 STACK_OF(X509_NAME) *client_CA;
438 452
439/**/ int quiet_shutdown; 453/**/ int quiet_shutdown;
@@ -458,6 +472,7 @@ struct ssl_ctx_st
458 * defined, this will still get called. */ 472 * defined, this will still get called. */
459#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 473#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100
460 474
475 struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx);
461#define SSL_CTX_sess_number(ctx) \ 476#define SSL_CTX_sess_number(ctx) \
462 SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) 477 SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
463#define SSL_CTX_sess_connect(ctx) \ 478#define SSL_CTX_sess_connect(ctx) \
@@ -564,17 +579,21 @@ struct ssl_st
564 unsigned char *packet; 579 unsigned char *packet;
565 unsigned int packet_length; 580 unsigned int packet_length;
566 581
567 struct ssl2_ctx_st *s2; /* SSLv2 variables */ 582 struct ssl2_state_st *s2; /* SSLv2 variables */
568 struct ssl3_ctx_st *s3; /* SSLv3 variables */ 583 struct ssl3_state_st *s3; /* SSLv3 variables */
569 584
570 int read_ahead; /* Read as many input bytes as possible */ 585 int read_ahead; /* Read as many input bytes as possible
586 * (for non-blocking reads) */
571 int hit; /* reusing a previous session */ 587 int hit; /* reusing a previous session */
572 588
589 int purpose; /* Purpose setting */
590 int trust; /* Trust setting */
591
573 /* crypto */ 592 /* crypto */
574 STACK_OF(SSL_CIPHER) *cipher_list; 593 STACK_OF(SSL_CIPHER) *cipher_list;
575 STACK_OF(SSL_CIPHER) *cipher_list_by_id; 594 STACK_OF(SSL_CIPHER) *cipher_list_by_id;
576 595
577 /* These are the ones being used, the ones is SSL_SESSION are 596 /* These are the ones being used, the ones in SSL_SESSION are
578 * the ones to be 'copied' into these ones */ 597 * the ones to be 'copied' into these ones */
579 598
580 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ 599 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
@@ -634,7 +653,7 @@ struct ssl_st
634 unsigned long mode; /* API behaviour */ 653 unsigned long mode; /* API behaviour */
635 int first_packet; 654 int first_packet;
636 int client_version; /* what was passed, used for 655 int client_version; /* what was passed, used for
637 * SSLv3/TLS rolback check */ 656 * SSLv3/TLS rollback check */
638 }; 657 };
639 658
640#include <openssl/ssl2.h> 659#include <openssl/ssl2.h>
@@ -642,7 +661,7 @@ struct ssl_st
642#include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */ 661#include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */
643#include <openssl/ssl23.h> 662#include <openssl/ssl23.h>
644 663
645/* compatablity */ 664/* compatibility */
646#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) 665#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg))
647#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) 666#define SSL_get_app_data(s) (SSL_get_ex_data(s,0))
648#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) 667#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a))
@@ -651,7 +670,7 @@ struct ssl_st
651#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) 670#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg))
652 671
653/* The following are the possible values for ssl->state are are 672/* The following are the possible values for ssl->state are are
654 * used to indicate where we are upto in the SSL connection establishment. 673 * used to indicate where we are up to in the SSL connection establishment.
655 * The macros that follow are about the only things you should need to use 674 * The macros that follow are about the only things you should need to use
656 * and even then, only when using non-blocking IO. 675 * and even then, only when using non-blocking IO.
657 * It can also be useful to work out where you were when the connection 676 * It can also be useful to work out where you were when the connection
@@ -693,6 +712,13 @@ struct ssl_st
693#define SSL_ST_READ_BODY 0xF1 712#define SSL_ST_READ_BODY 0xF1
694#define SSL_ST_READ_DONE 0xF2 713#define SSL_ST_READ_DONE 0xF2
695 714
715/* Obtain latest Finished message
716 * -- that we sent (SSL_get_finished)
717 * -- that we expected from peer (SSL_get_peer_finished).
718 * Returns length (0 == no Finished so far), copies up to 'count' bytes. */
719size_t SSL_get_finished(SSL *s, void *buf, size_t count);
720size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
721
696/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options 722/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options
697 * are 'ored' with SSL_VERIFY_PEER if they are desired */ 723 * are 'ored' with SSL_VERIFY_PEER if they are desired */
698#define SSL_VERIFY_NONE 0x00 724#define SSL_VERIFY_NONE 0x00
@@ -700,9 +726,10 @@ struct ssl_st
700#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 726#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
701#define SSL_VERIFY_CLIENT_ONCE 0x04 727#define SSL_VERIFY_CLIENT_ONCE 0x04
702 728
729#define OpenSSL_add_ssl_algorithms() SSL_library_init()
703#define SSLeay_add_ssl_algorithms() SSL_library_init() 730#define SSLeay_add_ssl_algorithms() SSL_library_init()
704 731
705/* this is for backward compatablility */ 732/* this is for backward compatibility */
706#if 0 /* NEW_SSLEAY */ 733#if 0 /* NEW_SSLEAY */
707#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) 734#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)
708#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) 735#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n)
@@ -710,7 +737,7 @@ struct ssl_st
710#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) 737#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b))
711#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) 738#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b))
712#endif 739#endif
713/* More backward compatablity */ 740/* More backward compatibility */
714#define SSL_get_cipher(s) \ 741#define SSL_get_cipher(s) \
715 SSL_CIPHER_get_name(SSL_get_current_cipher(s)) 742 SSL_CIPHER_get_name(SSL_get_current_cipher(s))
716#define SSL_get_cipher_bits(s,np) \ 743#define SSL_get_cipher_bits(s,np) \
@@ -762,11 +789,11 @@ struct ssl_st
762#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ 789#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */
763#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ 790#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */
764#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR 791#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR
765#define SSL_AD_EXPORT_RESTRICION TLS1_AD_EXPORT_RESTRICION/* fatal */ 792#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */
766#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ 793#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */
767#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ 794#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */
768#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ 795#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */
769#define SSL_AD_USER_CANCLED TLS1_AD_USER_CANCLED 796#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED
770#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION 797#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION
771 798
772#define SSL_ERROR_NONE 0 799#define SSL_ERROR_NONE 0
@@ -867,7 +894,7 @@ void BIO_ssl_shutdown(BIO *ssl_bio);
867 894
868#endif 895#endif
869 896
870int SSL_CTX_set_cipher_list(SSL_CTX *,char *str); 897int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str);
871SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); 898SSL_CTX *SSL_CTX_new(SSL_METHOD *meth);
872void SSL_CTX_free(SSL_CTX *); 899void SSL_CTX_free(SSL_CTX *);
873long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); 900long SSL_CTX_set_timeout(SSL_CTX *ctx,long t);
@@ -899,7 +926,7 @@ void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio);
899BIO * SSL_get_rbio(SSL *s); 926BIO * SSL_get_rbio(SSL *s);
900BIO * SSL_get_wbio(SSL *s); 927BIO * SSL_get_wbio(SSL *s);
901#endif 928#endif
902int SSL_set_cipher_list(SSL *s, char *str); 929int SSL_set_cipher_list(SSL *s, const char *str);
903void SSL_set_read_ahead(SSL *s, int yes); 930void SSL_set_read_ahead(SSL *s, int yes);
904int SSL_get_verify_mode(SSL *s); 931int SSL_get_verify_mode(SSL *s);
905int SSL_get_verify_depth(SSL *s); 932int SSL_get_verify_depth(SSL *s);
@@ -998,6 +1025,12 @@ int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx,
998SSL * SSL_new(SSL_CTX *ctx); 1025SSL * SSL_new(SSL_CTX *ctx);
999int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, 1026int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
1000 unsigned int sid_ctx_len); 1027 unsigned int sid_ctx_len);
1028
1029int SSL_CTX_set_purpose(SSL_CTX *s, int purpose);
1030int SSL_set_purpose(SSL *s, int purpose);
1031int SSL_CTX_set_trust(SSL_CTX *s, int trust);
1032int SSL_set_trust(SSL *s, int trust);
1033
1001void SSL_free(SSL *ssl); 1034void SSL_free(SSL *ssl);
1002int SSL_accept(SSL *ssl); 1035int SSL_accept(SSL *ssl);
1003int SSL_connect(SSL *ssl); 1036int SSL_connect(SSL *ssl);
@@ -1005,10 +1038,12 @@ int SSL_read(SSL *ssl,char *buf,int num);
1005int SSL_peek(SSL *ssl,char *buf,int num); 1038int SSL_peek(SSL *ssl,char *buf,int num);
1006int SSL_write(SSL *ssl,const char *buf,int num); 1039int SSL_write(SSL *ssl,const char *buf,int num);
1007long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg); 1040long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg);
1041long SSL_callback_ctrl(SSL *, int, void (*)());
1008long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg); 1042long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg);
1043long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)());
1009 1044
1010int SSL_get_error(SSL *s,int ret_code); 1045int SSL_get_error(SSL *s,int ret_code);
1011char * SSL_get_version(SSL *s); 1046const char *SSL_get_version(SSL *s);
1012 1047
1013/* This sets the 'default' SSL version that SSL_new() will create */ 1048/* This sets the 'default' SSL version that SSL_new() will create */
1014int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); 1049int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth);
@@ -1074,7 +1109,9 @@ int SSL_version(SSL *ssl);
1074int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); 1109int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
1075int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, 1110int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
1076 const char *CApath); 1111 const char *CApath);
1112#define SSL_get0_session SSL_get_session /* just peek at pointer */
1077SSL_SESSION *SSL_get_session(SSL *ssl); 1113SSL_SESSION *SSL_get_session(SSL *ssl);
1114SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
1078SSL_CTX *SSL_get_SSL_CTX(SSL *ssl); 1115SSL_CTX *SSL_get_SSL_CTX(SSL *ssl);
1079void SSL_set_info_callback(SSL *ssl,void (*cb)()); 1116void SSL_set_info_callback(SSL *ssl,void (*cb)());
1080void (*SSL_get_info_callback(SSL *ssl))(); 1117void (*SSL_get_info_callback(SSL *ssl))();
@@ -1085,18 +1122,18 @@ long SSL_get_verify_result(SSL *ssl);
1085 1122
1086int SSL_set_ex_data(SSL *ssl,int idx,void *data); 1123int SSL_set_ex_data(SSL *ssl,int idx,void *data);
1087void *SSL_get_ex_data(SSL *ssl,int idx); 1124void *SSL_get_ex_data(SSL *ssl,int idx);
1088int SSL_get_ex_new_index(long argl, char *argp, int (*new_func)(), 1125int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
1089 int (*dup_func)(), void (*free_func)()); 1126 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
1090 1127
1091int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); 1128int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data);
1092void *SSL_SESSION_get_ex_data(SSL_SESSION *ss,int idx); 1129void *SSL_SESSION_get_ex_data(SSL_SESSION *ss,int idx);
1093int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func)(), 1130int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
1094 int (*dup_func)(), void (*free_func)()); 1131 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
1095 1132
1096int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); 1133int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data);
1097void *SSL_CTX_get_ex_data(SSL_CTX *ssl,int idx); 1134void *SSL_CTX_get_ex_data(SSL_CTX *ssl,int idx);
1098int SSL_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), 1135int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
1099 int (*dup_func)(), void (*free_func)()); 1136 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
1100 1137
1101int SSL_get_ex_data_X509_STORE_CTX_idx(void ); 1138int SSL_get_ex_data_X509_STORE_CTX_idx(void );
1102 1139
@@ -1219,13 +1256,18 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1219#define SSL_F_SSL_CERT_INSTANTIATE 214 1256#define SSL_F_SSL_CERT_INSTANTIATE 214
1220#define SSL_F_SSL_CERT_NEW 162 1257#define SSL_F_SSL_CERT_NEW 162
1221#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 1258#define SSL_F_SSL_CHECK_PRIVATE_KEY 163
1259#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230
1260#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231
1222#define SSL_F_SSL_CLEAR 164 1261#define SSL_F_SSL_CLEAR 164
1223#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 1262#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165
1224#define SSL_F_SSL_CREATE_CIPHER_LIST 166 1263#define SSL_F_SSL_CREATE_CIPHER_LIST 166
1264#define SSL_F_SSL_CTRL 232
1225#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 1265#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168
1226#define SSL_F_SSL_CTX_NEW 169 1266#define SSL_F_SSL_CTX_NEW 169
1267#define SSL_F_SSL_CTX_SET_PURPOSE 226
1227#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 1268#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219
1228#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 1269#define SSL_F_SSL_CTX_SET_SSL_VERSION 170
1270#define SSL_F_SSL_CTX_SET_TRUST 229
1229#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 1271#define SSL_F_SSL_CTX_USE_CERTIFICATE 171
1230#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 1272#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172
1231#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 1273#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220
@@ -1253,9 +1295,11 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1253#define SSL_F_SSL_SET_CERT 191 1295#define SSL_F_SSL_SET_CERT 191
1254#define SSL_F_SSL_SET_FD 192 1296#define SSL_F_SSL_SET_FD 192
1255#define SSL_F_SSL_SET_PKEY 193 1297#define SSL_F_SSL_SET_PKEY 193
1298#define SSL_F_SSL_SET_PURPOSE 227
1256#define SSL_F_SSL_SET_RFD 194 1299#define SSL_F_SSL_SET_RFD 194
1257#define SSL_F_SSL_SET_SESSION 195 1300#define SSL_F_SSL_SET_SESSION 195
1258#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 1301#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218
1302#define SSL_F_SSL_SET_TRUST 228
1259#define SSL_F_SSL_SET_WFD 196 1303#define SSL_F_SSL_SET_WFD 196
1260#define SSL_F_SSL_SHUTDOWN 224 1304#define SSL_F_SSL_SHUTDOWN 224
1261#define SSL_F_SSL_UNDEFINED_FUNCTION 197 1305#define SSL_F_SSL_UNDEFINED_FUNCTION 197
@@ -1282,7 +1326,6 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1282#define SSL_R_BAD_AUTHENTICATION_TYPE 102 1326#define SSL_R_BAD_AUTHENTICATION_TYPE 102
1283#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 1327#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103
1284#define SSL_R_BAD_CHECKSUM 104 1328#define SSL_R_BAD_CHECKSUM 104
1285#define SSL_R_BAD_CLIENT_REQUEST 105
1286#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 1329#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106
1287#define SSL_R_BAD_DECOMPRESSION 107 1330#define SSL_R_BAD_DECOMPRESSION 107
1288#define SSL_R_BAD_DH_G_LENGTH 108 1331#define SSL_R_BAD_DH_G_LENGTH 108
@@ -1290,6 +1333,7 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1290#define SSL_R_BAD_DH_P_LENGTH 110 1333#define SSL_R_BAD_DH_P_LENGTH 110
1291#define SSL_R_BAD_DIGEST_LENGTH 111 1334#define SSL_R_BAD_DIGEST_LENGTH 111
1292#define SSL_R_BAD_DSA_SIGNATURE 112 1335#define SSL_R_BAD_DSA_SIGNATURE 112
1336#define SSL_R_BAD_HELLO_REQUEST 105
1293#define SSL_R_BAD_LENGTH 271 1337#define SSL_R_BAD_LENGTH 271
1294#define SSL_R_BAD_MAC_DECODE 113 1338#define SSL_R_BAD_MAC_DECODE 113
1295#define SSL_R_BAD_MESSAGE_TYPE 114 1339#define SSL_R_BAD_MESSAGE_TYPE 114
@@ -1329,6 +1373,7 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1329#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 1373#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148
1330#define SSL_R_DIGEST_CHECK_FAILED 149 1374#define SSL_R_DIGEST_CHECK_FAILED 149
1331#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 1375#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150
1376#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 1092
1332#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 1377#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151
1333#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 1378#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152
1334#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 1379#define SSL_R_EXTRA_DATA_IN_MESSAGE 153
@@ -1337,6 +1382,9 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1337#define SSL_R_HTTP_REQUEST 156 1382#define SSL_R_HTTP_REQUEST 156
1338#define SSL_R_INTERNAL_ERROR 157 1383#define SSL_R_INTERNAL_ERROR 157
1339#define SSL_R_INVALID_CHALLENGE_LENGTH 158 1384#define SSL_R_INVALID_CHALLENGE_LENGTH 158
1385#define SSL_R_INVALID_COMMAND 280
1386#define SSL_R_INVALID_PURPOSE 278
1387#define SSL_R_INVALID_TRUST 279
1340#define SSL_R_LENGTH_MISMATCH 159 1388#define SSL_R_LENGTH_MISMATCH 159
1341#define SSL_R_LENGTH_TOO_SHORT 160 1389#define SSL_R_LENGTH_TOO_SHORT 160
1342#define SSL_R_LIBRARY_BUG 274 1390#define SSL_R_LIBRARY_BUG 274
@@ -1429,14 +1477,14 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1429#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 1477#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
1430#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 1478#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021
1431#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 1479#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051
1432#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICION 1060 1480#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
1433#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 1481#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
1434#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 1482#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
1435#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 1483#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
1436#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 1484#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
1437#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 1485#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022
1438#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 1486#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048
1439#define SSL_R_TLSV1_ALERT_USER_CANCLED 1090 1487#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
1440#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 1488#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232
1441#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 1489#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233
1442#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 1490#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234
@@ -1464,6 +1512,7 @@ int SSL_COMP_add_compression_method(int id,char *cm);
1464#define SSL_R_UNKNOWN_STATE 255 1512#define SSL_R_UNKNOWN_STATE 255
1465#define SSL_R_UNSUPPORTED_CIPHER 256 1513#define SSL_R_UNSUPPORTED_CIPHER 256
1466#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 1514#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257
1515#define SSL_R_UNSUPPORTED_OPTION 1091
1467#define SSL_R_UNSUPPORTED_PROTOCOL 258 1516#define SSL_R_UNSUPPORTED_PROTOCOL 258
1468#define SSL_R_UNSUPPORTED_SSL_VERSION 259 1517#define SSL_R_UNSUPPORTED_SSL_VERSION 259
1469#define SSL_R_WRITE_BIO_NOT_SET 260 1518#define SSL_R_WRITE_BIO_NOT_SET 260
diff --git a/src/lib/libssl/ssl/shlib_version b/src/lib/libssl/ssl/shlib_version
index b52599a164..ba5a3fee58 100644
--- a/src/lib/libssl/ssl/shlib_version
+++ b/src/lib/libssl/ssl/shlib_version
@@ -1,2 +1,2 @@
1major=2 1major=2
2minor=0 2minor=2
diff --git a/src/lib/libssl/ssl2.h b/src/lib/libssl/ssl2.h
index d7f24ac1b4..01d41c88c5 100644
--- a/src/lib/libssl/ssl2.h
+++ b/src/lib/libssl/ssl2.h
@@ -151,7 +151,7 @@ extern "C" {
151#define CERT char 151#define CERT char
152#endif 152#endif
153 153
154typedef struct ssl2_ctx_st 154typedef struct ssl2_state_st
155 { 155 {
156 int three_byte_header; 156 int three_byte_header;
157 int clear_text; /* clear text */ 157 int clear_text; /* clear text */
@@ -214,7 +214,7 @@ typedef struct ssl2_ctx_st
214 unsigned int clen; 214 unsigned int clen;
215 unsigned int rlen; 215 unsigned int rlen;
216 } tmp; 216 } tmp;
217 } SSL2_CTX; 217 } SSL2_STATE;
218 218
219/* SSLv2 */ 219/* SSLv2 */
220/* client */ 220/* client */
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h
index 2a9714fc19..f616763830 100644
--- a/src/lib/libssl/ssl3.h
+++ b/src/lib/libssl/ssl3.h
@@ -158,24 +158,8 @@ extern "C" {
158#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) 158#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)
159#define SSL3_RT_MAX_DATA_SIZE (1024*1024) 159#define SSL3_RT_MAX_DATA_SIZE (1024*1024)
160 160
161/* the states that a SSL3_RECORD can be in 161#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54"
162 * For SSL_read it goes 162#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52"
163 * rbuf->ENCODED -> read
164 * ENCODED -> we need to decode everything - call decode_record
165 */
166
167#define SSL3_RS_BLANK 1
168#define SSL3_RS_DATA
169
170#define SSL3_RS_ENCODED 2
171#define SSL3_RS_READ_MORE 3
172#define SSL3_RS_WRITE_MORE
173#define SSL3_RS_PLAIN 3
174#define SSL3_RS_PART_READ 4
175#define SSL3_RS_PART_WRITE 5
176
177#define SSL3_MD_CLIENT_FINISHED_CONST {0x43,0x4C,0x4E,0x54}
178#define SSL3_MD_SERVER_FINISHED_CONST {0x53,0x52,0x56,0x52}
179 163
180#define SSL3_VERSION 0x0300 164#define SSL3_VERSION 0x0300
181#define SSL3_VERSION_MAJOR 0x03 165#define SSL3_VERSION_MAJOR 0x03
@@ -204,22 +188,20 @@ extern "C" {
204 188
205typedef struct ssl3_record_st 189typedef struct ssl3_record_st
206 { 190 {
207/*r */ int type; /* type of record */ 191/*r */ int type; /* type of record */
208/* */ /*int state;*/ /* any data in it? */ 192/*rw*/ unsigned int length; /* How many bytes available */
209/*rw*/ unsigned int length; /* How many bytes available */ 193/*r */ unsigned int off; /* read/write offset into 'buf' */
210/*r */ unsigned int off; /* read/write offset into 'buf' */ 194/*rw*/ unsigned char *data; /* pointer to the record data */
211/*rw*/ unsigned char *data; /* pointer to the record data */ 195/*rw*/ unsigned char *input; /* where the decode bytes are */
212/*rw*/ unsigned char *input; /* where the decode bytes are */ 196/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
213/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
214 } SSL3_RECORD; 197 } SSL3_RECORD;
215 198
216typedef struct ssl3_buffer_st 199typedef struct ssl3_buffer_st
217 { 200 {
218/*r */ int total; /* used in non-blocking writes */ 201 unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes (more if
219/*r */ int wanted; /* how many more bytes we need */ 202 * SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER is set) */
220/*rw*/ int left; /* how many bytes left */ 203 int offset; /* where to 'copy from' */
221/*rw*/ int offset; /* where to 'copy from' */ 204 int left; /* how many bytes left */
222/*rw*/ unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes */
223 } SSL3_BUFFER; 205 } SSL3_BUFFER;
224 206
225#define SSL3_CT_RSA_SIGN 1 207#define SSL3_CT_RSA_SIGN 1
@@ -236,34 +218,7 @@ typedef struct ssl3_buffer_st
236#define SSL3_FLAGS_POP_BUFFER 0x0004 218#define SSL3_FLAGS_POP_BUFFER 0x0004
237#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 219#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008
238 220
239#if 0 221typedef struct ssl3_state_st
240#define AD_CLOSE_NOTIFY 0
241#define AD_UNEXPECTED_MESSAGE 1
242#define AD_BAD_RECORD_MAC 2
243#define AD_DECRYPTION_FAILED 3
244#define AD_RECORD_OVERFLOW 4
245#define AD_DECOMPRESSION_FAILURE 5 /* fatal */
246#define AD_HANDSHAKE_FAILURE 6 /* fatal */
247#define AD_NO_CERTIFICATE 7 /* Not under TLS */
248#define AD_BAD_CERTIFICATE 8
249#define AD_UNSUPPORTED_CERTIFICATE 9
250#define AD_CERTIFICATE_REVOKED 10
251#define AD_CERTIFICATE_EXPIRED 11
252#define AD_CERTIFICATE_UNKNOWN 12
253#define AD_ILLEGAL_PARAMETER 13 /* fatal */
254#define AD_UNKNOWN_CA 14 /* fatal */
255#define AD_ACCESS_DENIED 15 /* fatal */
256#define AD_DECODE_ERROR 16 /* fatal */
257#define AD_DECRYPT_ERROR 17
258#define AD_EXPORT_RESTRICION 18 /* fatal */
259#define AD_PROTOCOL_VERSION 19 /* fatal */
260#define AD_INSUFFICIENT_SECURITY 20 /* fatal */
261#define AD_INTERNAL_ERROR 21 /* fatal */
262#define AD_USER_CANCLED 22
263#define AD_NO_RENEGOTIATION 23
264#endif
265
266typedef struct ssl3_ctx_st
267 { 222 {
268 long flags; 223 long flags;
269 int delay_buf_pop_ret; 224 int delay_buf_pop_ret;
@@ -278,10 +233,16 @@ typedef struct ssl3_ctx_st
278 233
279 SSL3_BUFFER rbuf; /* read IO goes into here */ 234 SSL3_BUFFER rbuf; /* read IO goes into here */
280 SSL3_BUFFER wbuf; /* write IO goes into here */ 235 SSL3_BUFFER wbuf; /* write IO goes into here */
236
281 SSL3_RECORD rrec; /* each decoded record goes in here */ 237 SSL3_RECORD rrec; /* each decoded record goes in here */
282 SSL3_RECORD wrec; /* goes out from here */ 238 SSL3_RECORD wrec; /* goes out from here */
283 /* Used by ssl3_read_n to point 239
284 * to input data packet */ 240 /* storage for Alert/Handshake protocol data received but not
241 * yet processed by ssl3_read_bytes: */
242 unsigned char alert_fragment[2];
243 unsigned int alert_fragment_len;
244 unsigned char handshake_fragment[4];
245 unsigned int handshake_fragment_len;
285 246
286 /* partial write - check the numbers match */ 247 /* partial write - check the numbers match */
287 unsigned int wnum; /* number of bytes sent so far */ 248 unsigned int wnum; /* number of bytes sent so far */
@@ -300,7 +261,7 @@ typedef struct ssl3_ctx_st
300 261
301 int warn_alert; 262 int warn_alert;
302 int fatal_alert; 263 int fatal_alert;
303 /* we alow one fatal and one warning alert to be outstanding, 264 /* we allow one fatal and one warning alert to be outstanding,
304 * send close alert via the warning alert */ 265 * send close alert via the warning alert */
305 int alert_dispatch; 266 int alert_dispatch;
306 unsigned char send_alert[2]; 267 unsigned char send_alert[2];
@@ -314,8 +275,14 @@ typedef struct ssl3_ctx_st
314 int in_read_app_data; 275 int in_read_app_data;
315 276
316 struct { 277 struct {
317 /* Actually only needs to be 16+20 for SSLv3 and 12 for TLS */ 278 /* actually only needs to be 16+20 */
279 unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2];
280
281 /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
318 unsigned char finish_md[EVP_MAX_MD_SIZE*2]; 282 unsigned char finish_md[EVP_MAX_MD_SIZE*2];
283 int finish_md_len;
284 unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2];
285 int peer_finish_md_len;
319 286
320 unsigned long message_size; 287 unsigned long message_size;
321 int message_type; 288 int message_type;
@@ -351,7 +318,7 @@ typedef struct ssl3_ctx_st
351 int cert_request; 318 int cert_request;
352 } tmp; 319 } tmp;
353 320
354 } SSL3_CTX; 321 } SSL3_STATE;
355 322
356/* SSLv3 */ 323/* SSLv3 */
357/*client */ 324/*client */
@@ -429,7 +396,7 @@ typedef struct ssl3_ctx_st
429#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) 396#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT)
430#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) 397#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT)
431 398
432#define SSL3_MT_CLIENT_REQUEST 0 399#define SSL3_MT_HELLO_REQUEST 0
433#define SSL3_MT_CLIENT_HELLO 1 400#define SSL3_MT_CLIENT_HELLO 1
434#define SSL3_MT_SERVER_HELLO 2 401#define SSL3_MT_SERVER_HELLO 2
435#define SSL3_MT_CERTIFICATE 11 402#define SSL3_MT_CERTIFICATE 11
diff --git a/src/lib/libssl/ssl_asn1.c b/src/lib/libssl/ssl_asn1.c
index 0f6a0884e4..e77cdddfd3 100644
--- a/src/lib/libssl/ssl_asn1.c
+++ b/src/lib/libssl/ssl_asn1.c
@@ -60,6 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h>
63#include "ssl_locl.h" 64#include "ssl_locl.h"
64 65
65typedef struct ssl_session_asn1_st 66typedef struct ssl_session_asn1_st
@@ -73,14 +74,15 @@ typedef struct ssl_session_asn1_st
73 ASN1_OCTET_STRING key_arg; 74 ASN1_OCTET_STRING key_arg;
74 ASN1_INTEGER time; 75 ASN1_INTEGER time;
75 ASN1_INTEGER timeout; 76 ASN1_INTEGER timeout;
77 ASN1_INTEGER verify_result;
76 } SSL_SESSION_ASN1; 78 } SSL_SESSION_ASN1;
77 79
78int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) 80int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
79 { 81 {
80#define LSIZE2 (sizeof(long)*2) 82#define LSIZE2 (sizeof(long)*2)
81 int v1=0,v2=0,v3=0,v4=0; 83 int v1=0,v2=0,v3=0,v4=0,v5=0;
82 unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; 84 unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2];
83 unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2]; 85 unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2];
84 long l; 86 long l;
85 SSL_SESSION_ASN1 a; 87 SSL_SESSION_ASN1 a;
86 M_ASN1_I2D_vars(in); 88 M_ASN1_I2D_vars(in);
@@ -89,7 +91,7 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
89 return(0); 91 return(0);
90 92
91 /* Note that I cheat in the following 2 assignments. I know 93 /* Note that I cheat in the following 2 assignments. I know
92 * that if the ASN1_INTERGER passed to ASN1_INTEGER_set 94 * that if the ASN1_INTEGER passed to ASN1_INTEGER_set
93 * is > sizeof(long)+1, the buffer will not be re-Malloc()ed. 95 * is > sizeof(long)+1, the buffer will not be re-Malloc()ed.
94 * This is a bit evil but makes things simple, no dynamic allocation 96 * This is a bit evil but makes things simple, no dynamic allocation
95 * to clean up :-) */ 97 * to clean up :-) */
@@ -156,6 +158,14 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
156 ASN1_INTEGER_set(&(a.timeout),in->timeout); 158 ASN1_INTEGER_set(&(a.timeout),in->timeout);
157 } 159 }
158 160
161 if (in->verify_result != X509_V_OK)
162 {
163 a.verify_result.length=LSIZE2;
164 a.verify_result.type=V_ASN1_INTEGER;
165 a.verify_result.data=ibuf5;
166 ASN1_INTEGER_set(&a.verify_result,in->verify_result);
167 }
168
159 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); 169 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER);
160 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); 170 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER);
161 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); 171 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING);
@@ -170,6 +180,8 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
170 if (in->peer != NULL) 180 if (in->peer != NULL)
171 M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3); 181 M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3);
172 M_ASN1_I2D_len_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,v4); 182 M_ASN1_I2D_len_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,v4);
183 if (in->verify_result != X509_V_OK)
184 M_ASN1_I2D_len_EXP_opt(&(a.verify_result),i2d_ASN1_INTEGER,5,v5);
173 185
174 M_ASN1_I2D_seq_total(); 186 M_ASN1_I2D_seq_total();
175 187
@@ -188,7 +200,8 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
188 M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); 200 M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3);
189 M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4, 201 M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,
190 v4); 202 v4);
191 203 if (in->verify_result != X509_V_OK)
204 M_ASN1_I2D_put_EXP_opt(&a.verify_result,i2d_ASN1_INTEGER,5,v5);
192 M_ASN1_I2D_finish(); 205 M_ASN1_I2D_finish();
193 } 206 }
194 207
@@ -322,6 +335,15 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp,
322 else 335 else
323 ret->sid_ctx_length=0; 336 ret->sid_ctx_length=0;
324 337
338 ai.length=0;
339 M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,5);
340 if (ai.data != NULL)
341 {
342 ret->verify_result=ASN1_INTEGER_get(aip);
343 Free(ai.data); ai.data=NULL; ai.length=0;
344 }
345 else
346 ret->verify_result=X509_V_OK;
347
325 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); 348 M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION);
326 } 349 }
327
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c
index 6d2511f76c..48f247ceac 100644
--- a/src/lib/libssl/ssl_cert.c
+++ b/src/lib/libssl/ssl_cert.c
@@ -105,17 +105,26 @@
105 */ 105 */
106 106
107#include <stdio.h> 107#include <stdio.h>
108#include <sys/types.h> 108
109#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) 109#include "openssl/e_os.h"
110
111#ifndef NO_SYS_TYPES_H
112# include <sys/types.h>
113#endif
114
115#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) && !defined(MAC_OS_pre_X)
110#include <dirent.h> 116#include <dirent.h>
111#endif 117#endif
118
112#ifdef NeXT 119#ifdef NeXT
113#include <sys/dir.h> 120#include <sys/dir.h>
114#define dirent direct 121#define dirent direct
115#endif 122#endif
123
116#include <openssl/objects.h> 124#include <openssl/objects.h>
117#include <openssl/bio.h> 125#include <openssl/bio.h>
118#include <openssl/pem.h> 126#include <openssl/pem.h>
127#include <openssl/x509v3.h>
119#include "ssl_locl.h" 128#include "ssl_locl.h"
120 129
121int SSL_get_ex_data_X509_STORE_CTX_idx(void) 130int SSL_get_ex_data_X509_STORE_CTX_idx(void)
@@ -422,8 +431,16 @@ int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk)
422 X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk); 431 X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk);
423 if (SSL_get_verify_depth(s) >= 0) 432 if (SSL_get_verify_depth(s) >= 0)
424 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s)); 433 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s));
425 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(), 434 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s);
426 (char *)s); 435 /* We need to set the verify purpose. The purpose can be determined by
436 * the context: if its a server it will verify SSL client certificates
437 * or vice versa.
438 */
439
440 if(s->server) i = X509_PURPOSE_SSL_CLIENT;
441 else i = X509_PURPOSE_SSL_SERVER;
442
443 X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust);
427 444
428 if (s->ctx->app_verify_callback != NULL) 445 if (s->ctx->app_verify_callback != NULL)
429 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */ 446 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */
@@ -534,7 +551,7 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x)
534 return(add_client_CA(&(ctx->client_CA),x)); 551 return(add_client_CA(&(ctx->client_CA),x));
535 } 552 }
536 553
537static int name_cmp(X509_NAME **a,X509_NAME **b) 554static int xname_cmp(X509_NAME **a,X509_NAME **b)
538 { 555 {
539 return(X509_NAME_cmp(*a,*b)); 556 return(X509_NAME_cmp(*a,*b));
540 } 557 }
@@ -556,7 +573,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
556 STACK_OF(X509_NAME) *ret,*sk; 573 STACK_OF(X509_NAME) *ret,*sk;
557 574
558 ret=sk_X509_NAME_new(NULL); 575 ret=sk_X509_NAME_new(NULL);
559 sk=sk_X509_NAME_new(name_cmp); 576 sk=sk_X509_NAME_new(xname_cmp);
560 577
561 in=BIO_new(BIO_s_file_internal()); 578 in=BIO_new(BIO_s_file_internal());
562 579
@@ -617,7 +634,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
617 int ret=1; 634 int ret=1;
618 int (*oldcmp)(X509_NAME **a, X509_NAME **b); 635 int (*oldcmp)(X509_NAME **a, X509_NAME **b);
619 636
620 oldcmp=sk_X509_NAME_set_cmp_func(stack,name_cmp); 637 oldcmp=sk_X509_NAME_set_cmp_func(stack,xname_cmp);
621 638
622 in=BIO_new(BIO_s_file_internal()); 639 in=BIO_new(BIO_s_file_internal());
623 640
@@ -671,6 +688,7 @@ err:
671 688
672#ifndef WIN32 689#ifndef WIN32
673#ifndef VMS /* XXXX This may be fixed in the future */ 690#ifndef VMS /* XXXX This may be fixed in the future */
691#ifndef MAC_OS_pre_X
674 692
675int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, 693int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
676 const char *dir) 694 const char *dir)
@@ -714,3 +732,4 @@ err:
714 732
715#endif 733#endif
716#endif 734#endif
735#endif
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c
index 4c2989c47a..1cbc2886e9 100644
--- a/src/lib/libssl/ssl_ciph.c
+++ b/src/lib/libssl/ssl_ciph.c
@@ -83,24 +83,11 @@ static const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX]={
83 NULL,NULL, 83 NULL,NULL,
84 }; 84 };
85 85
86typedef struct cipher_sort_st
87 {
88 SSL_CIPHER *cipher;
89 int pref;
90 } CIPHER_SORT;
91
92#define CIPHER_ADD 1 86#define CIPHER_ADD 1
93#define CIPHER_KILL 2 87#define CIPHER_KILL 2
94#define CIPHER_DEL 3 88#define CIPHER_DEL 3
95#define CIPHER_ORD 4 89#define CIPHER_ORD 4
96 90#define CIPHER_SPECIAL 5
97typedef struct cipher_choice_st
98 {
99 int type;
100 unsigned long algorithms;
101 unsigned long mask;
102 long top;
103 } CIPHER_CHOICE;
104 91
105typedef struct cipher_order_st 92typedef struct cipher_order_st
106 { 93 {
@@ -110,59 +97,55 @@ typedef struct cipher_order_st
110 struct cipher_order_st *next,*prev; 97 struct cipher_order_st *next,*prev;
111 } CIPHER_ORDER; 98 } CIPHER_ORDER;
112 99
113static SSL_CIPHER cipher_aliases[]={ 100static const SSL_CIPHER cipher_aliases[]={
114 /* Don't include eNULL unless specifically enabled */ 101 /* Don't include eNULL unless specifically enabled */
115 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL, 0,SSL_ALL}, /* must be first */ 102 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */
116 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,SSL_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SL_MASK,0},
151 {0,SSL_TXT_SSLV2, 0,SSL_SSLV2, 0,SSL_SSL_MASK}, 138
152 {0,SSL_TXT_SSLV3, 0,SSL_SSLV3, 0,SSL_SSL_MASK}, 139 {0,SSL_TXT_EXP ,0, 0,SSL_EXPORT, 0,0,0,0,SSL_EXP_MASK},
153 {0,SSL_TXT_TLSV1, 0,SSL_TLSV1, 0,SSL_SSL_MASK}, 140 {0,SSL_TXT_EXPORT,0, 0,SSL_EXPORT, 0,0,0,0,SSL_EXP_MASK},
154 {0,SSL_TXT_LOW, 0,SSL_LOW, 0,SSL_STRONG_MASK}, 141 {0,SSL_TXT_EXP40, 0, 0, SSL_EXP40, 0,0,0,0,SSL_STRONG_MASK},
155 {0,SSL_TXT_MEDIUM,0,SSL_MEDIUM,0,SSL_STRONG_MASK}, 142 {0,SSL_TXT_EXP56, 0, 0, SSL_EXP56, 0,0,0,0,SSL_STRONG_MASK},
156 {0,SSL_TXT_HIGH, 0,SSL_HIGH, 0,SSL_STRONG_MASK}, 143 {0,SSL_TXT_LOW, 0, 0, SSL_LOW, 0,0,0,0,SSL_STRONG_MASK},
144 {0,SSL_TXT_MEDIUM,0, 0,SSL_MEDIUM, 0,0,0,0,SSL_STRONG_MASK},
145 {0,SSL_TXT_HIGH, 0, 0, SSL_HIGH, 0,0,0,0,SSL_STRONG_MASK},
157 }; 146 };
158 147
159static int init_ciphers=1; 148static int init_ciphers=1;
160static void load_ciphers();
161
162static int cmp_by_name(SSL_CIPHER **a, SSL_CIPHER **b)
163 {
164 return(strcmp((*a)->name,(*b)->name));
165 }
166 149
167static void load_ciphers(void) 150static void load_ciphers(void)
168 { 151 {
@@ -294,170 +277,320 @@ static void ll_append_tail(CIPHER_ORDER **head, CIPHER_ORDER *curr,
294 *tail=curr; 277 *tail=curr;
295 } 278 }
296 279
297STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method, 280static unsigned long ssl_cipher_get_disabled(void)
298 STACK_OF(SSL_CIPHER) **cipher_list,
299 STACK_OF(SSL_CIPHER) **cipher_list_by_id,
300 char *str)
301 { 281 {
302 SSL_CIPHER *c; 282 unsigned long mask;
303 char *l;
304 STACK_OF(SSL_CIPHER) *ret=NULL,*ok=NULL;
305#define CL_BUF 40
306 char buf[CL_BUF];
307 char *tmp_str=NULL;
308 unsigned long mask,algorithms,ma;
309 char *start;
310 int i,j,k,num=0,ch,multi;
311 unsigned long al;
312 STACK *ca_list=NULL;
313 int current_x,num_x;
314 CIPHER_CHOICE *ops=NULL;
315 CIPHER_ORDER *list=NULL,*head=NULL,*tail=NULL,*curr,*tail2,*curr2;
316 int list_num;
317 int type;
318 SSL_CIPHER c_tmp,*cp;
319
320 if (str == NULL) return(NULL);
321
322 if (strncmp(str,"DEFAULT",7) == 0)
323 {
324 i=strlen(str)+2+strlen(SSL_DEFAULT_CIPHER_LIST);
325 if ((tmp_str=Malloc(i)) == NULL)
326 {
327 SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
328 goto err;
329 }
330 strcpy(tmp_str,SSL_DEFAULT_CIPHER_LIST);
331 strcat(tmp_str,":");
332 strcat(tmp_str,&(str[7]));
333 str=tmp_str;
334 }
335 if (init_ciphers) load_ciphers();
336
337 num=ssl_method->num_ciphers();
338
339 if ((ret=sk_SSL_CIPHER_new(NULL)) == NULL) goto err;
340 if ((ca_list=(STACK *)sk_new(cmp_by_name)) == NULL) goto err;
341 283
342 mask =SSL_kFZA; 284 mask = SSL_kFZA;
343#ifdef NO_RSA 285#ifdef NO_RSA
344 mask|=SSL_aRSA|SSL_kRSA; 286 mask |= SSL_aRSA|SSL_kRSA;
345#endif 287#endif
346#ifdef NO_DSA 288#ifdef NO_DSA
347 mask|=SSL_aDSS; 289 mask |= SSL_aDSS;
348#endif 290#endif
349#ifdef NO_DH 291#ifdef NO_DH
350 mask|=SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH; 292 mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH;
351#endif 293#endif
352 294
353#ifdef SSL_FORBID_ENULL 295#ifdef SSL_FORBID_ENULL
354 mask|=SSL_eNULL; 296 mask |= SSL_eNULL;
355#endif 297#endif
356 298
357 mask|=(ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL)?SSL_DES :0; 299 mask |= (ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL) ? SSL_DES :0;
358 mask|=(ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL)?SSL_3DES:0; 300 mask |= (ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL) ? SSL_3DES:0;
359 mask|=(ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL)?SSL_RC4 :0; 301 mask |= (ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL) ? SSL_RC4 :0;
360 mask|=(ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL)?SSL_RC2 :0; 302 mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0;
361 mask|=(ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL)?SSL_IDEA:0; 303 mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0;
362 mask|=(ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL)?SSL_eFZA:0; 304 mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0;
305
306 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;
363 308
364 mask|=(ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL)?SSL_MD5 :0; 309 return(mask);
365 mask|=(ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL)?SSL_SHA1:0; 310 }
311
312static void ssl_cipher_collect_ciphers(const SSL_METHOD *ssl_method,
313 int num_of_ciphers, unsigned long mask, CIPHER_ORDER *list,
314 CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p)
315 {
316 int i, list_num;
317 SSL_CIPHER *c;
366 318
367 if ((list=(CIPHER_ORDER *)Malloc(sizeof(CIPHER_ORDER)*num)) == NULL) 319 /*
368 goto err; 320 * We have num_of_ciphers descriptions compiled in, depending on the
321 * method selected (SSLv2 and/or SSLv3, TLSv1 etc).
322 * These will later be sorted in a linked list with at most num
323 * entries.
324 */
369 325
370 /* Get the initial list of ciphers */ 326 /* Get the initial list of ciphers */
371 list_num=0; 327 list_num = 0; /* actual count of ciphers */
372 for (i=0; i<num; i++) 328 for (i = 0; i < num_of_ciphers; i++)
373 { 329 {
374 c=ssl_method->get_cipher((unsigned int)i); 330 c = ssl_method->get_cipher(i);
375 /* drop those that use any of that is not available */ 331 /* drop those that use any of that is not available */
376 if ((c != NULL) && c->valid && !(c->algorithms & mask)) 332 if ((c != NULL) && c->valid && !(c->algorithms & mask))
377 { 333 {
378 list[list_num].cipher=c; 334 list[list_num].cipher = c;
379 list[list_num].next=NULL; 335 list[list_num].next = NULL;
380 list[list_num].prev=NULL; 336 list[list_num].prev = NULL;
381 list[list_num].active=0; 337 list[list_num].active = 0;
382 list_num++; 338 list_num++;
339 /*
383 if (!sk_push(ca_list,(char *)c)) goto err; 340 if (!sk_push(ca_list,(char *)c)) goto err;
341 */
384 } 342 }
385 } 343 }
386 344
387 for (i=1; i<list_num-1; i++) 345 /*
346 * Prepare linked list from list entries
347 */
348 for (i = 1; i < list_num - 1; i++)
388 { 349 {
389 list[i].prev= &(list[i-1]); 350 list[i].prev = &(list[i-1]);
390 list[i].next= &(list[i+1]); 351 list[i].next = &(list[i+1]);
391 } 352 }
392 if (list_num > 0) 353 if (list_num > 0)
393 { 354 {
394 head= &(list[0]); 355 (*head_p) = &(list[0]);
395 head->prev=NULL; 356 (*head_p)->prev = NULL;
396 head->next= &(list[1]); 357 (*head_p)->next = &(list[1]);
397 tail= &(list[list_num-1]); 358 (*tail_p) = &(list[list_num - 1]);
398 tail->prev= &(list[list_num-2]); 359 (*tail_p)->prev = &(list[list_num - 2]);
399 tail->next=NULL; 360 (*tail_p)->next = NULL;
400 } 361 }
362 }
401 363
402 /* special case */ 364static void ssl_cipher_collect_aliases(SSL_CIPHER **ca_list,
403 cipher_aliases[0].algorithms &= ~mask; 365 int num_of_group_aliases, unsigned long mask,
366 CIPHER_ORDER *head)
367 {
368 CIPHER_ORDER *ciph_curr;
369 SSL_CIPHER **ca_curr;
370 int i;
404 371
405 /* get the aliases */ 372 /*
406 k=sizeof(cipher_aliases)/sizeof(SSL_CIPHER); 373 * First, add the real ciphers as already collected
407 for (j=0; j<k; j++) 374 */
375 ciph_curr = head;
376 ca_curr = ca_list;
377 while (ciph_curr != NULL)
408 { 378 {
409 al=cipher_aliases[j].algorithms; 379 *ca_curr = ciph_curr->cipher;
410 /* Drop those that are not relevent */ 380 ca_curr++;
411 if ((al & mask) == al) continue; 381 ciph_curr = ciph_curr->next;
412 if (!sk_push(ca_list,(char *)&(cipher_aliases[j]))) goto err;
413 } 382 }
414 383
415 /* ca_list now holds a 'stack' of SSL_CIPHERS, some real, some 384 /*
416 * 'aliases' */ 385 * Now we add the available ones from the cipher_aliases[] table.
386 * They represent either an algorithm, that must be fully
387 * supported (not match any bit in mask) or represent a cipher
388 * strength value (will be added in any case because algorithms=0).
389 */
390 for (i = 0; i < num_of_group_aliases; i++)
391 {
392 if ((i == 0) || /* always fetch "ALL" */
393 !(cipher_aliases[i].algorithms & mask))
394 {
395 *ca_curr = (SSL_CIPHER *)(cipher_aliases + i);
396 ca_curr++;
397 }
398 }
417 399
418 /* how many parameters are there? */ 400 *ca_curr = NULL; /* end of list */
419 num=1; 401 }
420 for (l=str; *l; l++)
421 if (ITEM_SEP(*l))
422 num++;
423 ops=(CIPHER_CHOICE *)Malloc(sizeof(CIPHER_CHOICE)*num);
424 if (ops == NULL) goto err;
425 memset(ops,0,sizeof(CIPHER_CHOICE)*num);
426 402
427 /* we now parse the input string and create our operations */ 403static void ssl_cipher_apply_rule(unsigned long algorithms, unsigned long mask,
428 l=str; 404 unsigned long algo_strength, unsigned long mask_strength,
429 i=0; 405 int rule, int strength_bits, CIPHER_ORDER *list,
430 current_x=0; 406 CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p)
407 {
408 CIPHER_ORDER *head, *tail, *curr, *curr2, *tail2;
409 SSL_CIPHER *cp;
410 unsigned long ma, ma_s;
431 411
412#ifdef CIPHER_DEBUG
413 printf("Applying rule %d with %08lx %08lx %08lx %08lx (%d)\n",
414 rule, algorithms, mask, algo_strength, mask_strength,
415 strength_bits);
416#endif
417
418 curr = head = *head_p;
419 curr2 = head;
420 tail2 = tail = *tail_p;
432 for (;;) 421 for (;;)
433 { 422 {
434 ch= *l; 423 if ((curr == NULL) || (curr == tail2)) break;
424 curr = curr2;
425 curr2 = curr->next;
426
427 cp = curr->cipher;
428
429 /*
430 * Selection criteria is either the number of strength_bits
431 * or the algorithm used.
432 */
433 if (strength_bits == -1)
434 {
435 ma = mask & cp->algorithms;
436 ma_s = mask_strength & cp->algo_strength;
437
438#ifdef CIPHER_DEBUG
439 printf("\nName: %s:\nAlgo = %08lx Algo_strength = %08lx\nMask = %08lx Mask_strength %08lx\n", cp->name, cp->algorithms, cp->algo_strength, mask, mask_strength);
440 printf("ma = %08lx ma_s %08lx, ma&algo=%08lx, ma_s&algos=%08lx\n", ma, ma_s, ma&algorithms, ma_s&algo_strength);
441#endif
442 /*
443 * Select: if none of the mask bit was met from the
444 * cipher or not all of the bits were met, the
445 * selection does not apply.
446 */
447 if (((ma == 0) && (ma_s == 0)) ||
448 ((ma & algorithms) != ma) ||
449 ((ma_s & algo_strength) != ma_s))
450 continue; /* does not apply */
451 }
452 else if (strength_bits != cp->strength_bits)
453 continue; /* does not apply */
454
455#ifdef CIPHER_DEBUG
456 printf("Action = %d\n", rule);
457#endif
458
459 /* add the cipher if it has not been added yet. */
460 if (rule == CIPHER_ADD)
461 {
462 if (!curr->active)
463 {
464 ll_append_tail(&head, curr, &tail);
465 curr->active = 1;
466 }
467 }
468 /* Move the added cipher to this location */
469 else if (rule == CIPHER_ORD)
470 {
471 if (curr->active)
472 {
473 ll_append_tail(&head, curr, &tail);
474 }
475 }
476 else if (rule == CIPHER_DEL)
477 curr->active = 0;
478 else if (rule == CIPHER_KILL)
479 {
480 if (head == curr)
481 head = curr->next;
482 else
483 curr->prev->next = curr->next;
484 if (tail == curr)
485 tail = curr->prev;
486 curr->active = 0;
487 if (curr->next != NULL)
488 curr->next->prev = curr->prev;
489 if (curr->prev != NULL)
490 curr->prev->next = curr->next;
491 curr->next = NULL;
492 curr->prev = NULL;
493 }
494 }
495
496 *head_p = head;
497 *tail_p = tail;
498 }
499
500static int ssl_cipher_strength_sort(CIPHER_ORDER *list, CIPHER_ORDER **head_p,
501 CIPHER_ORDER **tail_p)
502 {
503 int max_strength_bits, i, *number_uses;
504 CIPHER_ORDER *curr;
505
506 /*
507 * This routine sorts the ciphers with descending strength. The sorting
508 * must keep the pre-sorted sequence, so we apply the normal sorting
509 * routine as '+' movement to the end of the list.
510 */
511 max_strength_bits = 0;
512 curr = *head_p;
513 while (curr != NULL)
514 {
515 if (curr->active &&
516 (curr->cipher->strength_bits > max_strength_bits))
517 max_strength_bits = curr->cipher->strength_bits;
518 curr = curr->next;
519 }
520
521 number_uses = Malloc((max_strength_bits + 1) * sizeof(int));
522 if (!number_uses)
523 {
524 SSLerr(SSL_F_SSL_CIPHER_STRENGTH_SORT,ERR_R_MALLOC_FAILURE);
525 return(0);
526 }
527 memset(number_uses, 0, (max_strength_bits + 1) * sizeof(int));
528
529 /*
530 * Now find the strength_bits values actually used
531 */
532 curr = *head_p;
533 while (curr != NULL)
534 {
535 if (curr->active)
536 number_uses[curr->cipher->strength_bits]++;
537 curr = curr->next;
538 }
539 /*
540 * Go through the list of used strength_bits values in descending
541 * order.
542 */
543 for (i = max_strength_bits; i >= 0; i--)
544 if (number_uses[i] > 0)
545 ssl_cipher_apply_rule(0, 0, 0, 0, CIPHER_ORD, i,
546 list, head_p, tail_p);
547
548 Free(number_uses);
549 return(1);
550 }
435 551
436 if (ch == '\0') break; 552static int ssl_cipher_process_rulestr(const char *rule_str,
553 CIPHER_ORDER *list, CIPHER_ORDER **head_p,
554 CIPHER_ORDER **tail_p, SSL_CIPHER **ca_list)
555 {
556 unsigned long algorithms, mask, algo_strength, mask_strength;
557 const char *l, *start, *buf;
558 int j, multi, found, rule, retval, ok, buflen;
559 char ch;
560
561 retval = 1;
562 l = rule_str;
563 for (;;)
564 {
565 ch = *l;
437 566
567 if (ch == '\0')
568 break; /* done */
438 if (ch == '-') 569 if (ch == '-')
439 { j=CIPHER_DEL; l++; } 570 { rule = CIPHER_DEL; l++; }
440 else if (ch == '+') 571 else if (ch == '+')
441 { j=CIPHER_ORD; l++; } 572 { rule = CIPHER_ORD; l++; }
442 else if (ch == '!') 573 else if (ch == '!')
443 { j=CIPHER_KILL; l++; } 574 { rule = CIPHER_KILL; l++; }
444 else 575 else if (ch == '@')
445 { j=CIPHER_ADD; } 576 { rule = CIPHER_SPECIAL; l++; }
577 else
578 { rule = CIPHER_ADD; }
446 579
447 if (ITEM_SEP(ch)) 580 if (ITEM_SEP(ch))
448 { 581 {
449 l++; 582 l++;
450 continue; 583 continue;
451 } 584 }
452 ops[current_x].type=j; 585
453 ops[current_x].algorithms=0; 586 algorithms = mask = algo_strength = mask_strength = 0;
454 ops[current_x].mask=0;
455 587
456 start=l; 588 start=l;
457 for (;;) 589 for (;;)
458 { 590 {
459 ch= *l; 591 ch = *l;
460 i=0; 592 buf = l;
593 buflen = 0;
461#ifndef CHARSET_EBCDIC 594#ifndef CHARSET_EBCDIC
462 while ( ((ch >= 'A') && (ch <= 'Z')) || 595 while ( ((ch >= 'A') && (ch <= 'Z')) ||
463 ((ch >= '0') && (ch <= '9')) || 596 ((ch >= '0') && (ch <= '9')) ||
@@ -467,12 +600,28 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method,
467 while ( isalnum(ch) || (ch == '-')) 600 while ( isalnum(ch) || (ch == '-'))
468#endif 601#endif
469 { 602 {
470 buf[i]=ch; 603 ch = *(++l);
471 ch= *(++l); 604 buflen++;
472 i++;
473 if (i >= (CL_BUF-2)) break;
474 } 605 }
475 buf[i]='\0'; 606
607 if (buflen == 0)
608 {
609 /*
610 * We hit something, we cannot deal with,
611 * it is no command or separator nor
612 * alphanumeric, so we call this an error.
613 */
614 SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR,
615 SSL_R_INVALID_COMMAND);
616 retval = found = 0;
617 l++;
618 break;
619 }
620
621 if (rule == CIPHER_SPECIAL)
622 {
623 break; /* special treatment */
624 }
476 625
477 /* check for multi-part specification */ 626 /* check for multi-part specification */
478 if (ch == '+') 627 if (ch == '+')
@@ -483,133 +632,237 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method,
483 else 632 else
484 multi=0; 633 multi=0;
485 634
486 c_tmp.name=buf; 635 /*
487 j=sk_find(ca_list,(char *)&c_tmp); 636 * Now search for the name in the ca_list. Be careful
488 if (j < 0) 637 * with the strncmp, because the "buflen" limitation
489 goto end_loop; 638 * will make the rule "ADH:SOME" and the cipher
639 * "ADH-MY-CIPHER" look like a match for buflen=3.
640 * So additionally check, whether the cipher name found
641 * has the correct length. We can save a strlen() call,
642 * just checking for the '\0' at the right place is
643 * sufficient, we have to strncmp() anyway.
644 */
645 j = found = 0;
646 while (ca_list[j])
647 {
648 if ((ca_list[j]->name[buflen] == '\0') &&
649 !strncmp(buf, ca_list[j]->name, buflen))
650 {
651 found = 1;
652 break;
653 }
654 else
655 j++;
656 }
657 if (!found)
658 break; /* ignore this entry */
659
660 algorithms |= ca_list[j]->algorithms;
661 mask |= ca_list[j]->mask;
662 algo_strength |= ca_list[j]->algo_strength;
663 mask_strength |= ca_list[j]->mask_strength;
490 664
491 cp=(SSL_CIPHER *)sk_value(ca_list,j);
492 ops[current_x].algorithms|=cp->algorithms;
493 /* We add the SSL_SSL_MASK so we can match the
494 * SSLv2 and SSLv3 versions of RC4-MD5 */
495 ops[current_x].mask|=cp->mask;
496 if (!multi) break; 665 if (!multi) break;
497 } 666 }
498 current_x++; 667
499 if (ch == '\0') break; 668 /*
500end_loop: 669 * Ok, we have the rule, now apply it
501 /* Make sure we scan until the next valid start point */ 670 */
502 while ((*l != '\0') && ITEM_SEP(*l)) 671 if (rule == CIPHER_SPECIAL)
503 l++; 672 { /* special command */
673 ok = 0;
674 if ((buflen == 8) &&
675 !strncmp(buf, "STRENGTH", 8))
676 ok = ssl_cipher_strength_sort(list,
677 head_p, tail_p);
678 else
679 SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR,
680 SSL_R_INVALID_COMMAND);
681 if (ok == 0)
682 retval = 0;
683 /*
684 * We do not support any "multi" options
685 * together with "@", so throw away the
686 * rest of the command, if any left, until
687 * end or ':' is found.
688 */
689 while ((*l != '\0') && ITEM_SEP(*l))
690 l++;
691 }
692 else if (found)
693 {
694 ssl_cipher_apply_rule(algorithms, mask,
695 algo_strength, mask_strength, rule, -1,
696 list, head_p, tail_p);
697 }
698 else
699 {
700 while ((*l != '\0') && ITEM_SEP(*l))
701 l++;
702 }
703 if (*l == '\0') break; /* done */
504 } 704 }
505 705
506 num_x=current_x; 706 return(retval);
507 current_x=0; 707 }
508 708
509 /* We will now process the list of ciphers, once for each category, to 709STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
510 * decide what we should do with it. */ 710 STACK_OF(SSL_CIPHER) **cipher_list,
511 for (j=0; j<num_x; j++) 711 STACK_OF(SSL_CIPHER) **cipher_list_by_id,
712 const char *rule_str)
713 {
714 int ok, num_of_ciphers, num_of_alias_max, num_of_group_aliases;
715 unsigned long disabled_mask;
716 STACK_OF(SSL_CIPHER) *cipherstack;
717 const char *rule_p;
718 CIPHER_ORDER *list = NULL, *head = NULL, *tail = NULL, *curr;
719 SSL_CIPHER **ca_list = NULL;
720
721 /*
722 * Return with error if nothing to do.
723 */
724 if (rule_str == NULL) return(NULL);
725
726 if (init_ciphers) load_ciphers();
727
728 /*
729 * To reduce the work to do we only want to process the compiled
730 * in algorithms, so we first get the mask of disabled ciphers.
731 */
732 disabled_mask = ssl_cipher_get_disabled();
733
734 /*
735 * Now we have to collect the available ciphers from the compiled
736 * in ciphers. We cannot get more than the number compiled in, so
737 * it is used for allocation.
738 */
739 num_of_ciphers = ssl_method->num_ciphers();
740 list = (CIPHER_ORDER *)Malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
741 if (list == NULL)
512 { 742 {
513 algorithms=ops[j].algorithms; 743 SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
514 type=ops[j].type; 744 return(NULL); /* Failure */
515 mask=ops[j].mask; 745 }
516 746
517 curr=head; 747 ssl_cipher_collect_ciphers(ssl_method, num_of_ciphers, disabled_mask,
518 curr2=head; 748 list, &head, &tail);
519 tail2=tail; 749
520 for (;;) 750 /*
521 { 751 * We also need cipher aliases for selecting based on the rule_str.
522 if ((curr == NULL) || (curr == tail2)) break; 752 * There might be two types of entries in the rule_str: 1) names
523 curr=curr2; 753 * of ciphers themselves 2) aliases for groups of ciphers.
524 curr2=curr->next; 754 * For 1) we need the available ciphers and for 2) the cipher
755 * groups of cipher_aliases added together in one list (otherwise
756 * we would be happy with just the cipher_aliases table).
757 */
758 num_of_group_aliases = sizeof(cipher_aliases) / sizeof(SSL_CIPHER);
759 num_of_alias_max = num_of_ciphers + num_of_group_aliases + 1;
760 ca_list =
761 (SSL_CIPHER **)Malloc(sizeof(SSL_CIPHER *) * num_of_alias_max);
762 if (ca_list == NULL)
763 {
764 Free(list);
765 SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE);
766 return(NULL); /* Failure */
767 }
768 ssl_cipher_collect_aliases(ca_list, num_of_group_aliases, disabled_mask,
769 head);
770
771 /*
772 * If the rule_string begins with DEFAULT, apply the default rule
773 * before using the (possibly available) additional rules.
774 */
775 ok = 1;
776 rule_p = rule_str;
777 if (strncmp(rule_str,"DEFAULT",7) == 0)
778 {
779 ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST,
780 list, &head, &tail, ca_list);
781 rule_p += 7;
782 if (*rule_p == ':')
783 rule_p++;
784 }
525 785
526 cp=curr->cipher; 786 if (ok && (strlen(rule_p) > 0))
527 ma=mask & cp->algorithms; 787 ok = ssl_cipher_process_rulestr(rule_p, list, &head, &tail,
528 if ((ma == 0) || ((ma & algorithms) != ma)) 788 ca_list);
529 {
530 /* does not apply */
531 continue;
532 }
533 789
534 /* add the cipher if it has not been added yet. */ 790 Free(ca_list); /* Not needed anymore */
535 if (type == CIPHER_ADD) 791
536 { 792 if (!ok)
537 if (!curr->active) 793 { /* Rule processing failure */
538 { 794 Free(list);
539 ll_append_tail(&head,curr,&tail); 795 return(NULL);
540 curr->active=1; 796 }
541 } 797 /*
542 } 798 * Allocate new "cipherstack" for the result, return with error
543 /* Move the added cipher to this location */ 799 * if we cannot get one.
544 else if (type == CIPHER_ORD) 800 */
545 { 801 if ((cipherstack = sk_SSL_CIPHER_new(NULL)) == NULL)
546 if (curr->active) 802 {
547 { 803 Free(list);
548 ll_append_tail(&head,curr,&tail); 804 return(NULL);
549 }
550 }
551 else if (type == CIPHER_DEL)
552 curr->active=0;
553 if (type == CIPHER_KILL)
554 {
555 if (head == curr)
556 head=curr->next;
557 else
558 curr->prev->next=curr->next;
559 if (tail == curr)
560 tail=curr->prev;
561 curr->active=0;
562 if (curr->next != NULL)
563 curr->next->prev=curr->prev;
564 if (curr->prev != NULL)
565 curr->prev->next=curr->next;
566 curr->next=NULL;
567 curr->prev=NULL;
568 }
569 }
570 } 805 }
571 806
572 for (curr=head; curr != NULL; curr=curr->next) 807 /*
808 * The cipher selection for the list is done. The ciphers are added
809 * to the resulting precedence to the STACK_OF(SSL_CIPHER).
810 */
811 for (curr = head; curr != NULL; curr = curr->next)
573 { 812 {
574 if (curr->active) 813 if (curr->active)
575 { 814 {
576 sk_SSL_CIPHER_push(ret,curr->cipher); 815 sk_SSL_CIPHER_push(cipherstack, curr->cipher);
577#ifdef CIPHER_DEBUG 816#ifdef CIPHER_DEBUG
578 printf("<%s>\n",curr->cipher->name); 817 printf("<%s>\n",curr->cipher->name);
579#endif 818#endif
580 } 819 }
581 } 820 }
582 821 Free(list); /* Not needed any longer */
822
823 /*
824 * The following passage is a little bit odd. If pointer variables
825 * were supplied to hold STACK_OF(SSL_CIPHER) return information,
826 * the old memory pointed to is free()ed. Then, however, the
827 * cipher_list entry will be assigned just a copy of the returned
828 * cipher stack. For cipher_list_by_id a copy of the cipher stack
829 * will be created. See next comment...
830 */
583 if (cipher_list != NULL) 831 if (cipher_list != NULL)
584 { 832 {
585 if (*cipher_list != NULL) 833 if (*cipher_list != NULL)
586 sk_SSL_CIPHER_free(*cipher_list); 834 sk_SSL_CIPHER_free(*cipher_list);
587 *cipher_list=ret; 835 *cipher_list = cipherstack;
588 } 836 }
589 837
590 if (cipher_list_by_id != NULL) 838 if (cipher_list_by_id != NULL)
591 { 839 {
592 if (*cipher_list_by_id != NULL) 840 if (*cipher_list_by_id != NULL)
593 sk_SSL_CIPHER_free(*cipher_list_by_id); 841 sk_SSL_CIPHER_free(*cipher_list_by_id);
594 *cipher_list_by_id=sk_SSL_CIPHER_dup(ret); 842 *cipher_list_by_id = sk_SSL_CIPHER_dup(cipherstack);
595 } 843 }
596 844
845 /*
846 * Now it is getting really strange. If something failed during
847 * the previous pointer assignment or if one of the pointers was
848 * not requested, the error condition is met. That might be
849 * discussable. The strange thing is however that in this case
850 * the memory "ret" pointed to is "free()ed" and hence the pointer
851 * cipher_list becomes wild. The memory reserved for
852 * cipher_list_by_id however is not "free()ed" and stays intact.
853 */
597 if ( (cipher_list_by_id == NULL) || 854 if ( (cipher_list_by_id == NULL) ||
598 (*cipher_list_by_id == NULL) || 855 (*cipher_list_by_id == NULL) ||
599 (cipher_list == NULL) || 856 (cipher_list == NULL) ||
600 (*cipher_list == NULL)) 857 (*cipher_list == NULL))
601 goto err; 858 {
859 sk_SSL_CIPHER_free(cipherstack);
860 return(NULL);
861 }
862
602 sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp); 863 sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp);
603 864
604 ok=ret; 865 return(cipherstack);
605 ret=NULL;
606err:
607 if (tmp_str) Free(tmp_str);
608 if (ops != NULL) Free(ops);
609 if (ret != NULL) sk_SSL_CIPHER_free(ret);
610 if (ca_list != NULL) sk_free(ca_list);
611 if (list != NULL) Free(list);
612 return(ok);
613 } 866 }
614 867
615char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len) 868char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
@@ -617,15 +870,16 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
617 int is_export,pkl,kl; 870 int is_export,pkl,kl;
618 char *ver,*exp; 871 char *ver,*exp;
619 char *kx,*au,*enc,*mac; 872 char *kx,*au,*enc,*mac;
620 unsigned long alg,alg2; 873 unsigned long alg,alg2,alg_s;
621 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n"; 874 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n";
622 875
623 alg=cipher->algorithms; 876 alg=cipher->algorithms;
877 alg_s=cipher->algo_strength;
624 alg2=cipher->algorithm2; 878 alg2=cipher->algorithm2;
625 879
626 is_export=SSL_IS_EXPORT(alg); 880 is_export=SSL_C_IS_EXPORT(cipher);
627 pkl=SSL_EXPORT_PKEYLENGTH(alg); 881 pkl=SSL_C_EXPORT_PKEYLENGTH(cipher);
628 kl=SSL_EXPORT_KEYLENGTH(alg); 882 kl=SSL_C_EXPORT_KEYLENGTH(cipher);
629 exp=is_export?" export":""; 883 exp=is_export?" export":"";
630 884
631 if (alg & SSL_SSLV2) 885 if (alg & SSL_SSLV2)
@@ -752,37 +1006,16 @@ const char *SSL_CIPHER_get_name(SSL_CIPHER *c)
752 return("(NONE)"); 1006 return("(NONE)");
753 } 1007 }
754 1008
755/* number of bits for symetric cipher */ 1009/* number of bits for symmetric cipher */
756int SSL_CIPHER_get_bits(SSL_CIPHER *c, int *alg_bits) 1010int SSL_CIPHER_get_bits(SSL_CIPHER *c, int *alg_bits)
757 { 1011 {
758 int ret=0,a=0; 1012 int ret=0;
759 const EVP_CIPHER *enc;
760 const EVP_MD *md;
761 SSL_SESSION ss;
762 1013
763 if (c != NULL) 1014 if (c != NULL)
764 { 1015 {
765 ss.cipher=c; 1016 if (alg_bits != NULL) *alg_bits = c->alg_bits;
766 if (!ssl_cipher_get_evp(&ss,&enc,&md,NULL)) 1017 ret = c->strength_bits;
767 return(0);
768
769 a=EVP_CIPHER_key_length(enc)*8;
770
771 if (SSL_C_IS_EXPORT(c))
772 {
773 ret=SSL_C_EXPORT_KEYLENGTH(c)*8;
774 }
775 else
776 {
777 if (c->algorithm2 & SSL2_CF_8_BYTE_ENC)
778 ret=64;
779 else
780 ret=a;
781 }
782 } 1018 }
783
784 if (alg_bits != NULL) *alg_bits=a;
785
786 return(ret); 1019 return(ret);
787 } 1020 }
788 1021
diff --git a/src/lib/libssl/ssl_err.c b/src/lib/libssl/ssl_err.c
index 3ddc805b53..5618e34a30 100644
--- a/src/lib/libssl/ssl_err.c
+++ b/src/lib/libssl/ssl_err.c
@@ -135,13 +135,18 @@ static ERR_STRING_DATA SSL_str_functs[]=
135{ERR_PACK(0,SSL_F_SSL_CERT_INSTANTIATE,0), "SSL_CERT_INSTANTIATE"}, 135{ERR_PACK(0,SSL_F_SSL_CERT_INSTANTIATE,0), "SSL_CERT_INSTANTIATE"},
136{ERR_PACK(0,SSL_F_SSL_CERT_NEW,0), "SSL_CERT_NEW"}, 136{ERR_PACK(0,SSL_F_SSL_CERT_NEW,0), "SSL_CERT_NEW"},
137{ERR_PACK(0,SSL_F_SSL_CHECK_PRIVATE_KEY,0), "SSL_check_private_key"}, 137{ERR_PACK(0,SSL_F_SSL_CHECK_PRIVATE_KEY,0), "SSL_check_private_key"},
138{ERR_PACK(0,SSL_F_SSL_CIPHER_PROCESS_RULESTR,0), "SSL_CIPHER_PROCESS_RULESTR"},
139{ERR_PACK(0,SSL_F_SSL_CIPHER_STRENGTH_SORT,0), "SSL_CIPHER_STRENGTH_SORT"},
138{ERR_PACK(0,SSL_F_SSL_CLEAR,0), "SSL_clear"}, 140{ERR_PACK(0,SSL_F_SSL_CLEAR,0), "SSL_clear"},
139{ERR_PACK(0,SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,0), "SSL_COMP_add_compression_method"}, 141{ERR_PACK(0,SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,0), "SSL_COMP_add_compression_method"},
140{ERR_PACK(0,SSL_F_SSL_CREATE_CIPHER_LIST,0), "SSL_CREATE_CIPHER_LIST"}, 142{ERR_PACK(0,SSL_F_SSL_CREATE_CIPHER_LIST,0), "SSL_CREATE_CIPHER_LIST"},
143{ERR_PACK(0,SSL_F_SSL_CTRL,0), "SSL_ctrl"},
141{ERR_PACK(0,SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,0), "SSL_CTX_check_private_key"}, 144{ERR_PACK(0,SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,0), "SSL_CTX_check_private_key"},
142{ERR_PACK(0,SSL_F_SSL_CTX_NEW,0), "SSL_CTX_new"}, 145{ERR_PACK(0,SSL_F_SSL_CTX_NEW,0), "SSL_CTX_new"},
146{ERR_PACK(0,SSL_F_SSL_CTX_SET_PURPOSE,0), "SSL_CTX_set_purpose"},
143{ERR_PACK(0,SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,0), "SSL_CTX_set_session_id_context"}, 147{ERR_PACK(0,SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,0), "SSL_CTX_set_session_id_context"},
144{ERR_PACK(0,SSL_F_SSL_CTX_SET_SSL_VERSION,0), "SSL_CTX_set_ssl_version"}, 148{ERR_PACK(0,SSL_F_SSL_CTX_SET_SSL_VERSION,0), "SSL_CTX_set_ssl_version"},
149{ERR_PACK(0,SSL_F_SSL_CTX_SET_TRUST,0), "SSL_CTX_set_trust"},
145{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE,0), "SSL_CTX_use_certificate"}, 150{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE,0), "SSL_CTX_use_certificate"},
146{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1,0), "SSL_CTX_use_certificate_ASN1"}, 151{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1,0), "SSL_CTX_use_certificate_ASN1"},
147{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,0), "SSL_CTX_use_certificate_chain_file"}, 152{ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,0), "SSL_CTX_use_certificate_chain_file"},
@@ -169,9 +174,11 @@ static ERR_STRING_DATA SSL_str_functs[]=
169{ERR_PACK(0,SSL_F_SSL_SET_CERT,0), "SSL_SET_CERT"}, 174{ERR_PACK(0,SSL_F_SSL_SET_CERT,0), "SSL_SET_CERT"},
170{ERR_PACK(0,SSL_F_SSL_SET_FD,0), "SSL_set_fd"}, 175{ERR_PACK(0,SSL_F_SSL_SET_FD,0), "SSL_set_fd"},
171{ERR_PACK(0,SSL_F_SSL_SET_PKEY,0), "SSL_SET_PKEY"}, 176{ERR_PACK(0,SSL_F_SSL_SET_PKEY,0), "SSL_SET_PKEY"},
177{ERR_PACK(0,SSL_F_SSL_SET_PURPOSE,0), "SSL_set_purpose"},
172{ERR_PACK(0,SSL_F_SSL_SET_RFD,0), "SSL_set_rfd"}, 178{ERR_PACK(0,SSL_F_SSL_SET_RFD,0), "SSL_set_rfd"},
173{ERR_PACK(0,SSL_F_SSL_SET_SESSION,0), "SSL_set_session"}, 179{ERR_PACK(0,SSL_F_SSL_SET_SESSION,0), "SSL_set_session"},
174{ERR_PACK(0,SSL_F_SSL_SET_SESSION_ID_CONTEXT,0), "SSL_set_session_id_context"}, 180{ERR_PACK(0,SSL_F_SSL_SET_SESSION_ID_CONTEXT,0), "SSL_set_session_id_context"},
181{ERR_PACK(0,SSL_F_SSL_SET_TRUST,0), "SSL_set_trust"},
175{ERR_PACK(0,SSL_F_SSL_SET_WFD,0), "SSL_set_wfd"}, 182{ERR_PACK(0,SSL_F_SSL_SET_WFD,0), "SSL_set_wfd"},
176{ERR_PACK(0,SSL_F_SSL_SHUTDOWN,0), "SSL_shutdown"}, 183{ERR_PACK(0,SSL_F_SSL_SHUTDOWN,0), "SSL_shutdown"},
177{ERR_PACK(0,SSL_F_SSL_UNDEFINED_FUNCTION,0), "SSL_UNDEFINED_FUNCTION"}, 184{ERR_PACK(0,SSL_F_SSL_UNDEFINED_FUNCTION,0), "SSL_UNDEFINED_FUNCTION"},
@@ -201,7 +208,6 @@ static ERR_STRING_DATA SSL_str_reasons[]=
201{SSL_R_BAD_AUTHENTICATION_TYPE ,"bad authentication type"}, 208{SSL_R_BAD_AUTHENTICATION_TYPE ,"bad authentication type"},
202{SSL_R_BAD_CHANGE_CIPHER_SPEC ,"bad change cipher spec"}, 209{SSL_R_BAD_CHANGE_CIPHER_SPEC ,"bad change cipher spec"},
203{SSL_R_BAD_CHECKSUM ,"bad checksum"}, 210{SSL_R_BAD_CHECKSUM ,"bad checksum"},
204{SSL_R_BAD_CLIENT_REQUEST ,"bad client request"},
205{SSL_R_BAD_DATA_RETURNED_BY_CALLBACK ,"bad data returned by callback"}, 211{SSL_R_BAD_DATA_RETURNED_BY_CALLBACK ,"bad data returned by callback"},
206{SSL_R_BAD_DECOMPRESSION ,"bad decompression"}, 212{SSL_R_BAD_DECOMPRESSION ,"bad decompression"},
207{SSL_R_BAD_DH_G_LENGTH ,"bad dh g length"}, 213{SSL_R_BAD_DH_G_LENGTH ,"bad dh g length"},
@@ -209,6 +215,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
209{SSL_R_BAD_DH_P_LENGTH ,"bad dh p length"}, 215{SSL_R_BAD_DH_P_LENGTH ,"bad dh p length"},
210{SSL_R_BAD_DIGEST_LENGTH ,"bad digest length"}, 216{SSL_R_BAD_DIGEST_LENGTH ,"bad digest length"},
211{SSL_R_BAD_DSA_SIGNATURE ,"bad dsa signature"}, 217{SSL_R_BAD_DSA_SIGNATURE ,"bad dsa signature"},
218{SSL_R_BAD_HELLO_REQUEST ,"bad hello request"},
212{SSL_R_BAD_LENGTH ,"bad length"}, 219{SSL_R_BAD_LENGTH ,"bad length"},
213{SSL_R_BAD_MAC_DECODE ,"bad mac decode"}, 220{SSL_R_BAD_MAC_DECODE ,"bad mac decode"},
214{SSL_R_BAD_MESSAGE_TYPE ,"bad message type"}, 221{SSL_R_BAD_MESSAGE_TYPE ,"bad message type"},
@@ -248,6 +255,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
248{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"}, 255{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"},
249{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"}, 256{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"},
250{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"}, 257{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"},
258{SSL_R_ERROR_GENERATING_TMP_RSA_KEY ,"error generating tmp rsa key"},
251{SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST ,"error in received cipher list"}, 259{SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST ,"error in received cipher list"},
252{SSL_R_EXCESSIVE_MESSAGE_SIZE ,"excessive message size"}, 260{SSL_R_EXCESSIVE_MESSAGE_SIZE ,"excessive message size"},
253{SSL_R_EXTRA_DATA_IN_MESSAGE ,"extra data in message"}, 261{SSL_R_EXTRA_DATA_IN_MESSAGE ,"extra data in message"},
@@ -256,6 +264,9 @@ static ERR_STRING_DATA SSL_str_reasons[]=
256{SSL_R_HTTP_REQUEST ,"http request"}, 264{SSL_R_HTTP_REQUEST ,"http request"},
257{SSL_R_INTERNAL_ERROR ,"internal error"}, 265{SSL_R_INTERNAL_ERROR ,"internal error"},
258{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"}, 266{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"},
267{SSL_R_INVALID_COMMAND ,"invalid command"},
268{SSL_R_INVALID_PURPOSE ,"invalid purpose"},
269{SSL_R_INVALID_TRUST ,"invalid trust"},
259{SSL_R_LENGTH_MISMATCH ,"length mismatch"}, 270{SSL_R_LENGTH_MISMATCH ,"length mismatch"},
260{SSL_R_LENGTH_TOO_SHORT ,"length too short"}, 271{SSL_R_LENGTH_TOO_SHORT ,"length too short"},
261{SSL_R_LIBRARY_BUG ,"library bug"}, 272{SSL_R_LIBRARY_BUG ,"library bug"},
@@ -348,14 +359,14 @@ static ERR_STRING_DATA SSL_str_reasons[]=
348{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"}, 359{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"},
349{SSL_R_TLSV1_ALERT_DECRYPTION_FAILED ,"tlsv1 alert decryption failed"}, 360{SSL_R_TLSV1_ALERT_DECRYPTION_FAILED ,"tlsv1 alert decryption failed"},
350{SSL_R_TLSV1_ALERT_DECRYPT_ERROR ,"tlsv1 alert decrypt error"}, 361{SSL_R_TLSV1_ALERT_DECRYPT_ERROR ,"tlsv1 alert decrypt error"},
351{SSL_R_TLSV1_ALERT_EXPORT_RESTRICION ,"tlsv1 alert export restricion"}, 362{SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION ,"tlsv1 alert export restriction"},
352{SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY ,"tlsv1 alert insufficient security"}, 363{SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY ,"tlsv1 alert insufficient security"},
353{SSL_R_TLSV1_ALERT_INTERNAL_ERROR ,"tlsv1 alert internal error"}, 364{SSL_R_TLSV1_ALERT_INTERNAL_ERROR ,"tlsv1 alert internal error"},
354{SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ,"tlsv1 alert no renegotiation"}, 365{SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ,"tlsv1 alert no renegotiation"},
355{SSL_R_TLSV1_ALERT_PROTOCOL_VERSION ,"tlsv1 alert protocol version"}, 366{SSL_R_TLSV1_ALERT_PROTOCOL_VERSION ,"tlsv1 alert protocol version"},
356{SSL_R_TLSV1_ALERT_RECORD_OVERFLOW ,"tlsv1 alert record overflow"}, 367{SSL_R_TLSV1_ALERT_RECORD_OVERFLOW ,"tlsv1 alert record overflow"},
357{SSL_R_TLSV1_ALERT_UNKNOWN_CA ,"tlsv1 alert unknown ca"}, 368{SSL_R_TLSV1_ALERT_UNKNOWN_CA ,"tlsv1 alert unknown ca"},
358{SSL_R_TLSV1_ALERT_USER_CANCLED ,"tlsv1 alert user cancled"}, 369{SSL_R_TLSV1_ALERT_USER_CANCELLED ,"tlsv1 alert user cancelled"},
359{SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER,"tls client cert req with anon cipher"}, 370{SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER,"tls client cert req with anon cipher"},
360{SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST,"tls peer did not respond with certificate list"}, 371{SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST,"tls peer did not respond with certificate list"},
361{SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG,"tls rsa encrypted value length is wrong"}, 372{SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG,"tls rsa encrypted value length is wrong"},
@@ -383,6 +394,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
383{SSL_R_UNKNOWN_STATE ,"unknown state"}, 394{SSL_R_UNKNOWN_STATE ,"unknown state"},
384{SSL_R_UNSUPPORTED_CIPHER ,"unsupported cipher"}, 395{SSL_R_UNSUPPORTED_CIPHER ,"unsupported cipher"},
385{SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM ,"unsupported compression algorithm"}, 396{SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM ,"unsupported compression algorithm"},
397{SSL_R_UNSUPPORTED_OPTION ,"unsupported option"},
386{SSL_R_UNSUPPORTED_PROTOCOL ,"unsupported protocol"}, 398{SSL_R_UNSUPPORTED_PROTOCOL ,"unsupported protocol"},
387{SSL_R_UNSUPPORTED_SSL_VERSION ,"unsupported ssl version"}, 399{SSL_R_UNSUPPORTED_SSL_VERSION ,"unsupported ssl version"},
388{SSL_R_WRITE_BIO_NOT_SET ,"write bio not set"}, 400{SSL_R_WRITE_BIO_NOT_SET ,"write bio not set"},
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index e192fc4cac..3109708480 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -61,22 +61,24 @@
61#include <stdio.h> 61#include <stdio.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/lhash.h> 63#include <openssl/lhash.h>
64#include <openssl/x509v3.h>
64#include "ssl_locl.h" 65#include "ssl_locl.h"
65 66
66char *SSL_version_str=OPENSSL_VERSION_TEXT; 67const char *SSL_version_str=OPENSSL_VERSION_TEXT;
67 68
68static STACK *ssl_meth=NULL; 69static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_meth=NULL;
69static STACK *ssl_ctx_meth=NULL; 70static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_ctx_meth=NULL;
70static int ssl_meth_num=0; 71static int ssl_meth_num=0;
71static int ssl_ctx_meth_num=0; 72static int ssl_ctx_meth_num=0;
72 73
73OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={ 74OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={
75 /* evil casts, but these functions are only called if there's a library bug */
76 (int (*)(SSL *,int))ssl_undefined_function,
77 (int (*)(SSL *, unsigned char *, int))ssl_undefined_function,
74 ssl_undefined_function, 78 ssl_undefined_function,
75 ssl_undefined_function, 79 (int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function,
76 ssl_undefined_function, 80 (int (*)(SSL*, int))ssl_undefined_function,
77 ssl_undefined_function, 81 (int (*)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char*, int, unsigned char *))ssl_undefined_function
78 ssl_undefined_function,
79 ssl_undefined_function,
80 }; 82 };
81 83
82int SSL_clear(SSL *s) 84int SSL_clear(SSL *s)
@@ -93,10 +95,17 @@ int SSL_clear(SSL *s)
93 s->hit=0; 95 s->hit=0;
94 s->shutdown=0; 96 s->shutdown=0;
95 97
96#if 0 98#if 0 /* Disabled since version 1.10 of this file (early return not
99 * needed because SSL_clear is not called when doing renegotiation) */
97 /* This is set if we are doing dynamic renegotiation so keep 100 /* This is set if we are doing dynamic renegotiation so keep
98 * the old cipher. It is sort of a SSL_clear_lite :-) */ 101 * the old cipher. It is sort of a SSL_clear_lite :-) */
99 if (s->new_session) return(1); 102 if (s->new_session) return(1);
103#else
104 if (s->new_session)
105 {
106 SSLerr(SSL_F_SSL_CLEAR,SSL_R_INTERNAL_ERROR);
107 return 0;
108 }
100#endif 109#endif
101 110
102 state=s->state; /* Keep to check if we throw away the session-id */ 111 state=s->state; /* Keep to check if we throw away the session-id */
@@ -201,6 +210,8 @@ SSL *SSL_new(SSL_CTX *ctx)
201 s->verify_mode=ctx->verify_mode; 210 s->verify_mode=ctx->verify_mode;
202 s->verify_depth=ctx->verify_depth; 211 s->verify_depth=ctx->verify_depth;
203 s->verify_callback=ctx->default_verify_callback; 212 s->verify_callback=ctx->default_verify_callback;
213 s->purpose = ctx->purpose;
214 s->trust = ctx->trust;
204 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); 215 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
205 s->ctx=ctx; 216 s->ctx=ctx;
206 217
@@ -218,7 +229,7 @@ SSL *SSL_new(SSL_CTX *ctx)
218 s->mode=ctx->mode; 229 s->mode=ctx->mode;
219 SSL_clear(s); 230 SSL_clear(s);
220 231
221 CRYPTO_new_ex_data(ssl_meth,(char *)s,&s->ex_data); 232 CRYPTO_new_ex_data(ssl_meth,s,&s->ex_data);
222 233
223 return(s); 234 return(s);
224err: 235err:
@@ -262,6 +273,46 @@ int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
262 return 1; 273 return 1;
263 } 274 }
264 275
276int SSL_CTX_set_purpose(SSL_CTX *s, int purpose)
277{
278 if(X509_PURPOSE_get_by_id(purpose) == -1) {
279 SSLerr(SSL_F_SSL_CTX_SET_PURPOSE, SSL_R_INVALID_PURPOSE);
280 return 0;
281 }
282 s->purpose = purpose;
283 return 1;
284}
285
286int SSL_set_purpose(SSL *s, int purpose)
287{
288 if(X509_PURPOSE_get_by_id(purpose) == -1) {
289 SSLerr(SSL_F_SSL_SET_PURPOSE, SSL_R_INVALID_PURPOSE);
290 return 0;
291 }
292 s->purpose = purpose;
293 return 1;
294}
295
296int SSL_CTX_set_trust(SSL_CTX *s, int trust)
297{
298 if(X509_TRUST_get_by_id(trust) == -1) {
299 SSLerr(SSL_F_SSL_CTX_SET_TRUST, SSL_R_INVALID_TRUST);
300 return 0;
301 }
302 s->trust = trust;
303 return 1;
304}
305
306int SSL_set_trust(SSL *s, int trust)
307{
308 if(X509_TRUST_get_by_id(trust) == -1) {
309 SSLerr(SSL_F_SSL_SET_TRUST, SSL_R_INVALID_TRUST);
310 return 0;
311 }
312 s->trust = trust;
313 return 1;
314}
315
265void SSL_free(SSL *s) 316void SSL_free(SSL *s)
266 { 317 {
267 int i; 318 int i;
@@ -324,7 +375,7 @@ void SSL_free(SSL *s)
324 375
325 if (s->method != NULL) s->method->ssl_free(s); 376 if (s->method != NULL) s->method->ssl_free(s);
326 377
327 Free((char *)s); 378 Free(s);
328 } 379 }
329 380
330void SSL_set_bio(SSL *s,BIO *rbio,BIO *wbio) 381void SSL_set_bio(SSL *s,BIO *rbio,BIO *wbio)
@@ -433,6 +484,38 @@ err:
433 } 484 }
434#endif 485#endif
435 486
487
488/* return length of latest Finished message we sent, copy to 'buf' */
489size_t SSL_get_finished(SSL *s, void *buf, size_t count)
490 {
491 size_t ret = 0;
492
493 if (s->s3 != NULL)
494 {
495 ret = s->s3->tmp.finish_md_len;
496 if (count > ret)
497 count = ret;
498 memcpy(buf, s->s3->tmp.finish_md, count);
499 }
500 return ret;
501 }
502
503/* return length of latest Finished message we expected, copy to 'buf' */
504size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count)
505 {
506 size_t ret = 0;
507
508 if (s->s3 != NULL)
509 {
510 ret = s->s3->tmp.peer_finish_md_len;
511 if (count > ret)
512 count = ret;
513 memcpy(buf, s->s3->tmp.peer_finish_md, count);
514 }
515 return ret;
516 }
517
518
436int SSL_get_verify_mode(SSL *s) 519int SSL_get_verify_mode(SSL *s)
437 { 520 {
438 return(s->verify_mode); 521 return(s->verify_mode);
@@ -706,6 +789,20 @@ long SSL_ctrl(SSL *s,int cmd,long larg,char *parg)
706 } 789 }
707 } 790 }
708 791
792long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)())
793 {
794 switch(cmd)
795 {
796 default:
797 return(s->method->ssl_callback_ctrl(s,cmd,fp));
798 }
799 }
800
801struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx)
802 {
803 return ctx->sessions;
804 }
805
709long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg) 806long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg)
710 { 807 {
711 long l; 808 long l;
@@ -765,6 +862,15 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg)
765 } 862 }
766 } 863 }
767 864
865long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
866 {
867 switch(cmd)
868 {
869 default:
870 return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp));
871 }
872 }
873
768int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b) 874int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b)
769 { 875 {
770 long l; 876 long l;
@@ -834,8 +940,8 @@ const char *SSL_get_cipher_list(SSL *s,int n)
834 return(c->name); 940 return(c->name);
835 } 941 }
836 942
837/** specify the ciphers to be used by defaut by the SSL_CTX */ 943/** specify the ciphers to be used by default by the SSL_CTX */
838int SSL_CTX_set_cipher_list(SSL_CTX *ctx,char *str) 944int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str)
839 { 945 {
840 STACK_OF(SSL_CIPHER) *sk; 946 STACK_OF(SSL_CIPHER) *sk;
841 947
@@ -846,7 +952,7 @@ int SSL_CTX_set_cipher_list(SSL_CTX *ctx,char *str)
846 } 952 }
847 953
848/** specify the ciphers to be used by the SSL */ 954/** specify the ciphers to be used by the SSL */
849int SSL_set_cipher_list(SSL *s,char *str) 955int SSL_set_cipher_list(SSL *s,const char *str)
850 { 956 {
851 STACK_OF(SSL_CIPHER) *sk; 957 STACK_OF(SSL_CIPHER) *sk;
852 958
@@ -1127,7 +1233,7 @@ void SSL_CTX_free(SSL_CTX *a)
1127 sk_X509_pop_free(a->extra_certs,X509_free); 1233 sk_X509_pop_free(a->extra_certs,X509_free);
1128 if (a->comp_methods != NULL) 1234 if (a->comp_methods != NULL)
1129 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free); 1235 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free);
1130 Free((char *)a); 1236 Free(a);
1131 } 1237 }
1132 1238
1133void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb) 1239void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb)
@@ -1254,10 +1360,8 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
1254 emask|=SSL_aDSS; 1360 emask|=SSL_aDSS;
1255 } 1361 }
1256 1362
1257#ifdef SSL_ALLOW_ADH
1258 mask|=SSL_aNULL; 1363 mask|=SSL_aNULL;
1259 emask|=SSL_aNULL; 1364 emask|=SSL_aNULL;
1260#endif
1261 1365
1262 c->mask=mask; 1366 c->mask=mask;
1263 c->export_mask=emask; 1367 c->export_mask=emask;
@@ -1274,7 +1378,7 @@ X509 *ssl_get_server_send_cert(SSL *s)
1274 c=s->cert; 1378 c=s->cert;
1275 ssl_set_cert_masks(c, s->s3->tmp.new_cipher); 1379 ssl_set_cert_masks(c, s->s3->tmp.new_cipher);
1276 alg=s->s3->tmp.new_cipher->algorithms; 1380 alg=s->s3->tmp.new_cipher->algorithms;
1277 is_export=SSL_IS_EXPORT(alg); 1381 is_export=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher);
1278 mask=is_export?c->export_mask:c->mask; 1382 mask=is_export?c->export_mask:c->mask;
1279 kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); 1383 kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK);
1280 1384
@@ -1527,7 +1631,7 @@ SSL_METHOD *ssl_bad_method(int ver)
1527 return(NULL); 1631 return(NULL);
1528 } 1632 }
1529 1633
1530char *SSL_get_version(SSL *s) 1634const char *SSL_get_version(SSL *s)
1531 { 1635 {
1532 if (s->version == TLS1_VERSION) 1636 if (s->version == TLS1_VERSION)
1533 return("TLSv1"); 1637 return("TLSv1");
@@ -1831,8 +1935,8 @@ long SSL_get_verify_result(SSL *ssl)
1831 return(ssl->verify_result); 1935 return(ssl->verify_result);
1832 } 1936 }
1833 1937
1834int SSL_get_ex_new_index(long argl,char *argp,int (*new_func)(), 1938int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1835 int (*dup_func)(),void (*free_func)()) 1939 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1836 { 1940 {
1837 ssl_meth_num++; 1941 ssl_meth_num++;
1838 return(CRYPTO_get_ex_new_index(ssl_meth_num-1, 1942 return(CRYPTO_get_ex_new_index(ssl_meth_num-1,
@@ -1849,8 +1953,8 @@ void *SSL_get_ex_data(SSL *s,int idx)
1849 return(CRYPTO_get_ex_data(&s->ex_data,idx)); 1953 return(CRYPTO_get_ex_data(&s->ex_data,idx));
1850 } 1954 }
1851 1955
1852int SSL_CTX_get_ex_new_index(long argl,char *argp,int (*new_func)(), 1956int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1853 int (*dup_func)(),void (*free_func)()) 1957 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1854 { 1958 {
1855 ssl_ctx_meth_num++; 1959 ssl_ctx_meth_num++;
1856 return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1, 1960 return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1,
@@ -1899,13 +2003,16 @@ int SSL_want(SSL *s)
1899void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, 2003void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl,
1900 int is_export, 2004 int is_export,
1901 int keylength)) 2005 int keylength))
1902 { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); } 2006 {
1903#endif 2007 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb);
2008 }
1904 2009
1905#ifndef NO_RSA 2010void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl,
1906void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl,int is_export, 2011 int is_export,
1907 int keylength)) 2012 int keylength))
1908 { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); } 2013 {
2014 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb);
2015 }
1909#endif 2016#endif
1910 2017
1911#ifdef DOXYGEN 2018#ifdef DOXYGEN
@@ -1932,11 +2039,15 @@ RSA *cb(SSL *ssl,int is_export,int keylength)
1932#ifndef NO_DH 2039#ifndef NO_DH
1933void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, 2040void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export,
1934 int keylength)) 2041 int keylength))
1935 { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); } 2042 {
2043 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2044 }
1936 2045
1937void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, 2046void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export,
1938 int keylength)) 2047 int keylength))
1939 { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); } 2048 {
2049 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2050 }
1940#endif 2051#endif
1941 2052
1942#if defined(_WINDLL) && defined(WIN16) 2053#if defined(_WINDLL) && defined(WIN16)
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 0bfd57db32..9a52bab254 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -155,6 +155,19 @@
155#define DEC32(a) ((a)=((a)-1)&0xffffffffL) 155#define DEC32(a) ((a)=((a)-1)&0xffffffffL)
156#define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */ 156#define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */
157 157
158/*
159 * Define the Bitmasks for SSL_CIPHER.algorithms.
160 * This bits are used packed as dense as possible. If new methods/ciphers
161 * etc will be added, the bits a likely to change, so this information
162 * is for internal library use only, even though SSL_CIPHER.algorithms
163 * can be publicly accessed.
164 * Use the according functions for cipher management instead.
165 *
166 * The bit mask handling in the selection and sorting scheme in
167 * ssl_create_cipher_list() has only limited capabilities, reflecting
168 * that the different entities within are mutually exclusive:
169 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
170 */
158#define SSL_MKEY_MASK 0x0000001FL 171#define SSL_MKEY_MASK 0x0000001FL
159#define SSL_kRSA 0x00000001L /* RSA key exchange */ 172#define SSL_kRSA 0x00000001L /* RSA key exchange */
160#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */ 173#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */
@@ -191,36 +204,75 @@
191#define SSL_SHA1 0x00040000L 204#define SSL_SHA1 0x00040000L
192#define SSL_SHA (SSL_SHA1) 205#define SSL_SHA (SSL_SHA1)
193 206
194#define SSL_EXP_MASK 0x00300000L 207#define SSL_SSL_MASK 0x00180000L
195#define SSL_EXP40 0x00100000L 208#define SSL_SSLV2 0x00080000L
196#define SSL_NOT_EXP 0x00200000L 209#define SSL_SSLV3 0x00100000L
197#define SSL_EXP56 0x00300000L 210#define SSL_TLSV1 SSL_SSLV3 /* for now */
198#define SSL_IS_EXPORT(a) ((a)&SSL_EXP40) 211
199#define SSL_IS_EXPORT56(a) (((a)&SSL_EXP_MASK) == SSL_EXP56) 212/* we have used 001fffff - 11 bits left to go */
200#define SSL_IS_EXPORT40(a) (((a)&SSL_EXP_MASK) == SSL_EXP40) 213
201#define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algorithms) 214/*
202#define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algorithms) 215 * Export and cipher strength information. For each cipher we have to decide
203#define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algorithms) 216 * whether it is exportable or not. This information is likely to change
204#define SSL_EXPORT_KEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 5 : \ 217 * over time, since the export control rules are no static technical issue.
218 *
219 * Independent of the export flag the cipher strength is sorted into classes.
220 * SSL_EXP40 was denoting the 40bit US export limit of past times, which now
221 * is at 56bit (SSL_EXP56). If the exportable cipher class is going to change
222 * again (eg. to 64bit) the use of "SSL_EXP*" becomes blurred even more,
223 * since SSL_EXP64 could be similar to SSL_LOW.
224 * For this reason SSL_MICRO and SSL_MINI macros are included to widen the
225 * namespace of SSL_LOW-SSL_HIGH to lower values. As development of speed
226 * and ciphers goes, another extension to SSL_SUPER and/or SSL_ULTRA would
227 * be possible.
228 */
229#define SSL_EXP_MASK 0x00000003L
230#define SSL_NOT_EXP 0x00000001L
231#define SSL_EXPORT 0x00000002L
232
233#define SSL_STRONG_MASK 0x0000007cL
234#define SSL_EXP40 0x00000004L
235#define SSL_MICRO (SSL_EXP40)
236#define SSL_EXP56 0x00000008L
237#define SSL_MINI (SSL_EXP56)
238#define SSL_LOW 0x00000010L
239#define SSL_MEDIUM 0x00000020L
240#define SSL_HIGH 0x00000040L
241
242/* we have used 0000007f - 25 bits left to go */
243
244/*
245 * Macros to check the export status and cipher strength for export ciphers.
246 * Even though the macros for EXPORT and EXPORT40/56 have similar names,
247 * their meaning is different:
248 * *_EXPORT macros check the 'exportable' status.
249 * *_EXPORT40/56 macros are used to check whether a certain cipher strength
250 * is given.
251 * Since the SSL_IS_EXPORT* and SSL_EXPORT* macros depend on the correct
252 * algorithm structure element to be passed (algorithms, algo_strength) and no
253 * typechecking can be done as they are all of type unsigned long, their
254 * direct usage is discouraged.
255 * Use the SSL_C_* macros instead.
256 */
257#define SSL_IS_EXPORT(a) ((a)&SSL_EXPORT)
258#define SSL_IS_EXPORT56(a) ((a)&SSL_EXP56)
259#define SSL_IS_EXPORT40(a) ((a)&SSL_EXP40)
260#define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algo_strength)
261#define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algo_strength)
262#define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algo_strength)
263
264#define SSL_EXPORT_KEYLENGTH(a,s) (SSL_IS_EXPORT40(s) ? 5 : \
205 ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7) 265 ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7)
206#define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024) 266#define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024)
207#define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithms) 267#define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithms, \
208#define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algorithms) 268 (c)->algo_strength)
209 269#define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algo_strength)
210#define SSL_SSL_MASK 0x00c00000L
211#define SSL_SSLV2 0x00400000L
212#define SSL_SSLV3 0x00800000L
213#define SSL_TLSV1 SSL_SSLV3 /* for now */
214 270
215#define SSL_STRONG_MASK 0x07000000L
216#define SSL_LOW 0x01000000L
217#define SSL_MEDIUM 0x02000000L
218#define SSL_HIGH 0x04000000L
219 271
220/* we have used 0fffffff - 4 bits left to go */
221#define SSL_ALL 0xffffffffL 272#define SSL_ALL 0xffffffffL
222#define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\ 273#define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\
223 SSL_MAC_MASK|SSL_EXP_MASK) 274 SSL_MAC_MASK)
275#define SSL_ALL_STRENGTHS (SSL_EXP_MASK|SSL_STRONG_MASK)
224 276
225/* Mostly for SSLv3 */ 277/* Mostly for SSLv3 */
226#define SSL_PKEY_RSA_ENC 0 278#define SSL_PKEY_RSA_ENC 0
@@ -254,9 +306,9 @@ typedef struct cert_st
254 { 306 {
255 /* Current active set */ 307 /* Current active set */
256 CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array 308 CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array
257 * Probably it would make more sense to store 309 * Probably it would make more sense to store
258 * an index, not a pointer. */ 310 * an index, not a pointer. */
259 311
260 /* The following masks are for the key and auth 312 /* The following masks are for the key and auth
261 * algorithms that are supported by the certs below */ 313 * algorithms that are supported by the certs below */
262 int valid; 314 int valid;
@@ -319,28 +371,28 @@ typedef struct sess_cert_st
319 371
320/* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff 372/* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff
321 * It is a bit of a mess of functions, but hell, think of it as 373 * It is a bit of a mess of functions, but hell, think of it as
322 * an opaque strucute :-) */ 374 * an opaque structure :-) */
323typedef struct ssl3_enc_method 375typedef struct ssl3_enc_method
324 { 376 {
325 int (*enc)(); 377 int (*enc)(SSL *, int);
326 int (*mac)(); 378 int (*mac)(SSL *, unsigned char *, int);
327 int (*setup_key_block)(); 379 int (*setup_key_block)(SSL *);
328 int (*generate_master_secret)(); 380 int (*generate_master_secret)(SSL *, unsigned char *, unsigned char *, int);
329 int (*change_cipher_state)(); 381 int (*change_cipher_state)(SSL *, int);
330 int (*final_finish_mac)(); 382 int (*final_finish_mac)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char *, int, unsigned char *);
331 int finish_mac_length; 383 int finish_mac_length;
332 int (*cert_verify_mac)(); 384 int (*cert_verify_mac)(SSL *, EVP_MD_CTX *, unsigned char *);
333 unsigned char client_finished[20]; 385 const char *client_finished_label;
334 int client_finished_len; 386 int client_finished_label_len;
335 unsigned char server_finished[20]; 387 const char *server_finished_label;
336 int server_finished_len; 388 int server_finished_label_len;
337 int (*alert_value)(); 389 int (*alert_value)(int);
338 } SSL3_ENC_METHOD; 390 } SSL3_ENC_METHOD;
339 391
340/* Used for holding the relevant compression methods loaded into SSL_CTX */ 392/* Used for holding the relevant compression methods loaded into SSL_CTX */
341typedef struct ssl3_comp_st 393typedef struct ssl3_comp_st
342 { 394 {
343 int comp_id; /* The identifer byte for this compression type */ 395 int comp_id; /* The identifier byte for this compression type */
344 char *name; /* Text name used for the compression type */ 396 char *name; /* Text name used for the compression type */
345 COMP_METHOD *method; /* The method :-) */ 397 COMP_METHOD *method; /* The method :-) */
346 } SSL3_COMP; 398 } SSL3_COMP;
@@ -376,10 +428,10 @@ int ssl_cipher_ptr_id_cmp(SSL_CIPHER **ap,SSL_CIPHER **bp);
376STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, 428STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
377 STACK_OF(SSL_CIPHER) **skp); 429 STACK_OF(SSL_CIPHER) **skp);
378int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p); 430int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p);
379STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *meth, 431STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth,
380 STACK_OF(SSL_CIPHER) **pref, 432 STACK_OF(SSL_CIPHER) **pref,
381 STACK_OF(SSL_CIPHER) **sorted, 433 STACK_OF(SSL_CIPHER) **sorted,
382 char *str); 434 const char *rule_str);
383void ssl_update_cache(SSL *s, int mode); 435void ssl_update_cache(SSL *s, int mode);
384int ssl_cipher_get_evp(SSL_SESSION *s,const EVP_CIPHER **enc,const EVP_MD **md, 436int ssl_cipher_get_evp(SSL_SESSION *s,const EVP_CIPHER **enc,const EVP_MD **md,
385 SSL_COMP **comp); 437 SSL_COMP **comp);
@@ -416,6 +468,8 @@ int ssl2_shutdown(SSL *s);
416void ssl2_clear(SSL *s); 468void ssl2_clear(SSL *s);
417long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg); 469long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg);
418long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 470long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg);
471long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)());
472long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
419int ssl2_pending(SSL *s); 473int ssl2_pending(SSL *s);
420 474
421SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); 475SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
@@ -433,17 +487,16 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out,
433 unsigned char *p, int len); 487 unsigned char *p, int len);
434int ssl3_get_req_cert_type(SSL *s,unsigned char *p); 488int ssl3_get_req_cert_type(SSL *s,unsigned char *p);
435long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); 489long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
436int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender,int slen); 490int ssl3_send_finished(SSL *s, int a, int b, const char *sender,int slen);
437int ssl3_num_ciphers(void); 491int ssl3_num_ciphers(void);
438SSL_CIPHER *ssl3_get_cipher(unsigned int u); 492SSL_CIPHER *ssl3_get_cipher(unsigned int u);
439int ssl3_renegotiate(SSL *ssl); 493int ssl3_renegotiate(SSL *ssl);
440int ssl3_renegotiate_check(SSL *ssl); 494int ssl3_renegotiate_check(SSL *ssl);
441int ssl3_dispatch_alert(SSL *s); 495int ssl3_dispatch_alert(SSL *s);
442int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len); 496int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len);
443int ssl3_part_read(SSL *s, int i);
444int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); 497int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
445int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1,EVP_MD_CTX *ctx2, 498int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2,
446 unsigned char *sender, int slen,unsigned char *p); 499 const char *sender, int slen,unsigned char *p);
447int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); 500int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
448void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len); 501void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
449int ssl3_enc(SSL *s, int send_data); 502int ssl3_enc(SSL *s, int send_data);
@@ -463,6 +516,8 @@ int ssl3_shutdown(SSL *s);
463void ssl3_clear(SSL *s); 516void ssl3_clear(SSL *s);
464long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg); 517long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg);
465long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 518long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg);
519long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)());
520long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
466int ssl3_pending(SSL *s); 521int ssl3_pending(SSL *s);
467 522
468int ssl23_accept(SSL *s); 523int ssl23_accept(SSL *s);
@@ -474,6 +529,7 @@ int tls1_new(SSL *s);
474void tls1_free(SSL *s); 529void tls1_free(SSL *s);
475void tls1_clear(SSL *s); 530void tls1_clear(SSL *s);
476long tls1_ctrl(SSL *s,int cmd, long larg, char *parg); 531long tls1_ctrl(SSL *s,int cmd, long larg, char *parg);
532long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)());
477SSL_METHOD *tlsv1_base_method(void ); 533SSL_METHOD *tlsv1_base_method(void );
478 534
479int ssl_init_wbio_buffer(SSL *s, int push); 535int ssl_init_wbio_buffer(SSL *s, int push);
@@ -483,7 +539,7 @@ int tls1_change_cipher_state(SSL *s, int which);
483int tls1_setup_key_block(SSL *s); 539int tls1_setup_key_block(SSL *s);
484int tls1_enc(SSL *s, int snd); 540int tls1_enc(SSL *s, int snd);
485int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, 541int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
486 unsigned char *str, int slen, unsigned char *p); 542 const char *str, int slen, unsigned char *p);
487int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); 543int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
488int tls1_mac(SSL *ssl, unsigned char *md, int snd); 544int tls1_mac(SSL *ssl, unsigned char *md, int snd);
489int tls1_generate_master_secret(SSL *s, unsigned char *out, 545int tls1_generate_master_secret(SSL *s, unsigned char *out,
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index 681499f08a..9e01f72753 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -65,15 +65,31 @@ static 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; 67static int ssl_session_num=0;
68static STACK *ssl_session_meth=NULL; 68static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_session_meth=NULL;
69 69
70SSL_SESSION *SSL_get_session(SSL *ssl) 70SSL_SESSION *SSL_get_session(SSL *ssl)
71/* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */
71 { 72 {
72 return(ssl->session); 73 return(ssl->session);
73 } 74 }
74 75
75int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func)(), 76SSL_SESSION *SSL_get1_session(SSL *ssl)
76 int (*dup_func)(), void (*free_func)()) 77/* variant of SSL_get_session: caller really gets something */
78 {
79 SSL_SESSION *sess;
80 /* Need to lock this all up rather than just use CRYPTO_add so that
81 * somebody doesn't free ssl->session between when we check it's
82 * non-null and when we up the reference count. */
83 CRYPTO_r_lock(CRYPTO_LOCK_SSL_SESSION);
84 sess = ssl->session;
85 if(sess)
86 sess->references++;
87 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_SESSION);
88 return(sess);
89 }
90
91int 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)
77 { 93 {
78 ssl_session_num++; 94 ssl_session_num++;
79 return(CRYPTO_get_ex_new_index(ssl_session_num-1, 95 return(CRYPTO_get_ex_new_index(ssl_session_num-1,
@@ -103,13 +119,14 @@ SSL_SESSION *SSL_SESSION_new(void)
103 } 119 }
104 memset(ss,0,sizeof(SSL_SESSION)); 120 memset(ss,0,sizeof(SSL_SESSION));
105 121
122 ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */
106 ss->references=1; 123 ss->references=1;
107 ss->timeout=60*5+4; /* 5 minute timeout by default */ 124 ss->timeout=60*5+4; /* 5 minute timeout by default */
108 ss->time=time(NULL); 125 ss->time=time(NULL);
109 ss->prev=NULL; 126 ss->prev=NULL;
110 ss->next=NULL; 127 ss->next=NULL;
111 ss->compress_meth=0; 128 ss->compress_meth=0;
112 CRYPTO_new_ex_data(ssl_session_meth,(char *)ss,&ss->ex_data); 129 CRYPTO_new_ex_data(ssl_session_meth,ss,&ss->ex_data);
113 return(ss); 130 return(ss);
114 } 131 }
115 132
@@ -161,15 +178,20 @@ int ssl_get_new_session(SSL *s, int session)
161 { 178 {
162 SSL_SESSION *r; 179 SSL_SESSION *r;
163 180
164 RAND_bytes(ss->session_id,ss->session_id_length); 181 RAND_pseudo_bytes(ss->session_id,ss->session_id_length);
165 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); 182 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
166 r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, 183 r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, ss);
167 (char *)ss);
168 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); 184 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
169 if (r == NULL) break; 185 if (r == NULL) break;
170 /* else - woops a session_id match */ 186 /* else - woops a session_id match */
171 /* XXX should also check external cache! 187 /* XXX We should also check the external cache --
172 * (But the probability of a collision is negligible, anyway...) */ 188 * but the probability of a collision is negligible, and
189 * we could not prevent the concurrent creation of sessions
190 * with identical IDs since we currently don't have means
191 * to atomically check whether a session ID already exists
192 * and make a reservation for it if it does not
193 * (this problem applies to the internal cache as well).
194 */
173 } 195 }
174 } 196 }
175 else 197 else
@@ -181,6 +203,7 @@ int ssl_get_new_session(SSL *s, int session)
181 ss->sid_ctx_length=s->sid_ctx_length; 203 ss->sid_ctx_length=s->sid_ctx_length;
182 s->session=ss; 204 s->session=ss;
183 ss->ssl_version=s->version; 205 ss->ssl_version=s->version;
206 ss->verify_result = X509_V_OK;
184 207
185 return(1); 208 return(1);
186 } 209 }
@@ -192,7 +215,6 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
192 SSL_SESSION *ret=NULL,data; 215 SSL_SESSION *ret=NULL,data;
193 int fatal = 0; 216 int fatal = 0;
194 217
195 /* conn_init();*/
196 data.ssl_version=s->version; 218 data.ssl_version=s->version;
197 data.session_id_length=len; 219 data.session_id_length=len;
198 if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) 220 if (len > SSL_MAX_SSL_SESSION_ID_LENGTH)
@@ -202,7 +224,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
202 if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) 224 if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP))
203 { 225 {
204 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); 226 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
205 ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,(char *)&data); 227 ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,&data);
206 if (ret != NULL) 228 if (ret != NULL)
207 /* don't allow other threads to steal it: */ 229 /* don't allow other threads to steal it: */
208 CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); 230 CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION);
@@ -311,6 +333,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len)
311 if (s->session != NULL) 333 if (s->session != NULL)
312 SSL_SESSION_free(s->session); 334 SSL_SESSION_free(s->session);
313 s->session=ret; 335 s->session=ret;
336 s->verify_result = s->session->verify_result;
314 return(1); 337 return(1);
315 338
316 err: 339 err:
@@ -327,27 +350,47 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c)
327 int ret=0; 350 int ret=0;
328 SSL_SESSION *s; 351 SSL_SESSION *s;
329 352
330 /* conn_init(); */ 353 /* add just 1 reference count for the SSL_CTX's session cache
354 * even though it has two ways of access: each session is in a
355 * doubly linked list and an lhash */
331 CRYPTO_add(&c->references,1,CRYPTO_LOCK_SSL_SESSION); 356 CRYPTO_add(&c->references,1,CRYPTO_LOCK_SSL_SESSION);
357 /* if session c is in already in cache, we take back the increment later */
332 358
333 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 359 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
334 s=(SSL_SESSION *)lh_insert(ctx->sessions,(char *)c); 360 s=(SSL_SESSION *)lh_insert(ctx->sessions,c);
335 361
336 /* Put on the end of the queue unless it is already in the cache */ 362 /* s != NULL iff we already had a session with the given PID.
363 * In this case, s == c should hold (then we did not really modify
364 * ctx->sessions), or we're in trouble. */
365 if (s != NULL && s != c)
366 {
367 /* We *are* in trouble ... */
368 SSL_SESSION_list_remove(ctx,s);
369 SSL_SESSION_free(s);
370 /* ... so pretend the other session did not exist in cache
371 * (we cannot handle two SSL_SESSION structures with identical
372 * session ID in the same cache, which could happen e.g. when
373 * two threads concurrently obtain the same session from an external
374 * cache) */
375 s = NULL;
376 }
377
378 /* Put at the head of the queue unless it is already in the cache */
337 if (s == NULL) 379 if (s == NULL)
338 SSL_SESSION_list_add(ctx,c); 380 SSL_SESSION_list_add(ctx,c);
339 381
340 /* If the same session if is being 're-added', Free the old
341 * one when the last person stops using it.
342 * This will also work if it is alread in the cache.
343 * The references will go up and then down :-) */
344 if (s != NULL) 382 if (s != NULL)
345 { 383 {
346 SSL_SESSION_free(s); 384 /* existing cache entry -- decrement previously incremented reference
385 * count because it already takes into account the cache */
386
387 SSL_SESSION_free(s); /* s == c */
347 ret=0; 388 ret=0;
348 } 389 }
349 else 390 else
350 { 391 {
392 /* new cache entry -- remove old ones if cache has become too large */
393
351 ret=1; 394 ret=1;
352 395
353 if (SSL_CTX_sess_get_cache_size(ctx) > 0) 396 if (SSL_CTX_sess_get_cache_size(ctx) > 0)
@@ -380,7 +423,7 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
380 if ((c != NULL) && (c->session_id_length != 0)) 423 if ((c != NULL) && (c->session_id_length != 0))
381 { 424 {
382 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 425 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
383 r=(SSL_SESSION *)lh_delete(ctx->sessions,(char *)c); 426 r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
384 if (r != NULL) 427 if (r != NULL)
385 { 428 {
386 ret=1; 429 ret=1;
@@ -422,7 +465,7 @@ void SSL_SESSION_free(SSL_SESSION *ss)
422 } 465 }
423#endif 466#endif
424 467
425 CRYPTO_free_ex_data(ssl_session_meth,(char *)ss,&ss->ex_data); 468 CRYPTO_free_ex_data(ssl_session_meth,ss,&ss->ex_data);
426 469
427 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); 470 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH);
428 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); 471 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH);
@@ -541,7 +584,7 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p)
541 { 584 {
542 /* The reason we don't call SSL_CTX_remove_session() is to 585 /* The reason we don't call SSL_CTX_remove_session() is to
543 * save on locking overhead */ 586 * save on locking overhead */
544 lh_delete(p->cache,(char *)s); 587 lh_delete(p->cache,s);
545 SSL_SESSION_list_remove(p->ctx,s); 588 SSL_SESSION_list_remove(p->ctx,s);
546 s->not_resumable=1; 589 s->not_resumable=1;
547 if (p->ctx->remove_session_cb != NULL) 590 if (p->ctx->remove_session_cb != NULL)
@@ -562,7 +605,7 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
562 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 605 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
563 i=tp.cache->down_load; 606 i=tp.cache->down_load;
564 tp.cache->down_load=0; 607 tp.cache->down_load=0;
565 lh_doall_arg(tp.cache,(void (*)())timeout,(char *)&tp); 608 lh_doall_arg(tp.cache,(void (*)())timeout,&tp);
566 tp.cache->down_load=i; 609 tp.cache->down_load=i;
567 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); 610 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
568 } 611 }
diff --git a/src/lib/libssl/ssl_stat.c b/src/lib/libssl/ssl_stat.c
index 3eca4ee601..8e12461f3b 100644
--- a/src/lib/libssl/ssl_stat.c
+++ b/src/lib/libssl/ssl_stat.c
@@ -183,7 +183,7 @@ case 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(NO_SSL2) && !defined(NO_SSL3)
186/* SSLv2/v3 compatablitity 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;
189case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break; 189case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break;
@@ -331,7 +331,7 @@ case 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(NO_SSL2) && !defined(NO_SSL3)
334/* SSLv2/v3 compatablitity 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;
337case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break; 337case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break;
@@ -402,7 +402,7 @@ char *SSL_alert_desc_string_long(int value)
402 str="close notify"; 402 str="close notify";
403 break; 403 break;
404 case SSL3_AD_UNEXPECTED_MESSAGE: 404 case SSL3_AD_UNEXPECTED_MESSAGE:
405 str="unexected_message"; 405 str="unexpected_message";
406 break; 406 break;
407 case SSL3_AD_BAD_RECORD_MAC: 407 case SSL3_AD_BAD_RECORD_MAC:
408 str="bad record mac"; 408 str="bad record mac";
@@ -429,7 +429,7 @@ char *SSL_alert_desc_string_long(int value)
429 str="certificate expired"; 429 str="certificate expired";
430 break; 430 break;
431 case SSL3_AD_CERTIFICATE_UNKNOWN: 431 case SSL3_AD_CERTIFICATE_UNKNOWN:
432 str="certifcate unknown"; 432 str="certificate unknown";
433 break; 433 break;
434 case SSL3_AD_ILLEGAL_PARAMETER: 434 case SSL3_AD_ILLEGAL_PARAMETER:
435 str="illegal parameter"; 435 str="illegal parameter";
diff --git a/src/lib/libssl/ssl_txt.c b/src/lib/libssl/ssl_txt.c
index ca67a98d89..7e27857bcf 100644
--- a/src/lib/libssl/ssl_txt.c
+++ b/src/lib/libssl/ssl_txt.c
@@ -112,7 +112,7 @@ int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)
112 sprintf(str,"%02X",x->session_id[i]); 112 sprintf(str,"%02X",x->session_id[i]);
113 if (BIO_puts(bp,str) <= 0) goto err; 113 if (BIO_puts(bp,str) <= 0) goto err;
114 } 114 }
115 if (BIO_puts(bp,"\nSession-ID-ctx: ") <= 0) goto err; 115 if (BIO_puts(bp,"\n Session-ID-ctx: ") <= 0) goto err;
116 for (i=0; i<x->sid_ctx_length; i++) 116 for (i=0; i<x->sid_ctx_length; i++)
117 { 117 {
118 sprintf(str,"%02X",x->sid_ctx[i]); 118 sprintf(str,"%02X",x->sid_ctx[i]);
@@ -163,6 +163,11 @@ int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)
163 if (BIO_puts(bp,str) <= 0) goto err; 163 if (BIO_puts(bp,str) <= 0) goto err;
164 } 164 }
165 if (BIO_puts(bp,"\n") <= 0) goto err; 165 if (BIO_puts(bp,"\n") <= 0) goto err;
166
167 if (BIO_puts(bp, " Verify return code ") <= 0) goto err;
168 sprintf(str, "%ld (%s)\n", x->verify_result,
169 X509_verify_cert_error_string(x->verify_result));
170 if (BIO_puts(bp,str) <= 0) goto err;
166 171
167 return(1); 172 return(1);
168err: 173err:
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c
index 914b743498..279e45db5d 100644
--- a/src/lib/libssl/t1_enc.c
+++ b/src/lib/libssl/t1_enc.c
@@ -494,7 +494,7 @@ int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in_ctx, unsigned char *out)
494 } 494 }
495 495
496int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, 496int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
497 unsigned char *str, int slen, unsigned char *out) 497 const char *str, int slen, unsigned char *out)
498 { 498 {
499 unsigned int i; 499 unsigned int i;
500 EVP_MD_CTX ctx; 500 EVP_MD_CTX ctx;
@@ -621,11 +621,11 @@ int tls1_alert_code(int code)
621 case SSL_AD_ACCESS_DENIED: return(TLS1_AD_ACCESS_DENIED); 621 case SSL_AD_ACCESS_DENIED: return(TLS1_AD_ACCESS_DENIED);
622 case SSL_AD_DECODE_ERROR: return(TLS1_AD_DECODE_ERROR); 622 case SSL_AD_DECODE_ERROR: return(TLS1_AD_DECODE_ERROR);
623 case SSL_AD_DECRYPT_ERROR: return(TLS1_AD_DECRYPT_ERROR); 623 case SSL_AD_DECRYPT_ERROR: return(TLS1_AD_DECRYPT_ERROR);
624 case SSL_AD_EXPORT_RESTRICION: return(TLS1_AD_EXPORT_RESTRICION); 624 case SSL_AD_EXPORT_RESTRICTION: return(TLS1_AD_EXPORT_RESTRICTION);
625 case SSL_AD_PROTOCOL_VERSION: return(TLS1_AD_PROTOCOL_VERSION); 625 case SSL_AD_PROTOCOL_VERSION: return(TLS1_AD_PROTOCOL_VERSION);
626 case SSL_AD_INSUFFICIENT_SECURITY:return(TLS1_AD_INSUFFICIENT_SECURITY); 626 case SSL_AD_INSUFFICIENT_SECURITY:return(TLS1_AD_INSUFFICIENT_SECURITY);
627 case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR); 627 case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR);
628 case SSL_AD_USER_CANCLED: return(TLS1_AD_USER_CANCLED); 628 case SSL_AD_USER_CANCELLED: return(TLS1_AD_USER_CANCELLED);
629 case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION); 629 case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION);
630 default: return(-1); 630 default: return(-1);
631 } 631 }
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c
index ddf5c15799..ca6c03d5af 100644
--- a/src/lib/libssl/t1_lib.c
+++ b/src/lib/libssl/t1_lib.c
@@ -60,13 +60,9 @@
60#include <openssl/objects.h> 60#include <openssl/objects.h>
61#include "ssl_locl.h" 61#include "ssl_locl.h"
62 62
63char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT; 63const char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT;
64 64
65#ifndef NO_PROTO
66static long tls1_default_timeout(void); 65static long tls1_default_timeout(void);
67#else
68static long tls1_default_timeout();
69#endif
70 66
71static SSL3_ENC_METHOD TLSv1_enc_data={ 67static SSL3_ENC_METHOD TLSv1_enc_data={
72 tls1_enc, 68 tls1_enc,
@@ -105,6 +101,9 @@ static SSL_METHOD TLSv1_data= {
105 ssl_bad_method, 101 ssl_bad_method,
106 tls1_default_timeout, 102 tls1_default_timeout,
107 &TLSv1_enc_data, 103 &TLSv1_enc_data,
104 ssl_undefined_function,
105 ssl3_callback_ctrl,
106 ssl3_ctx_callback_ctrl,
108 }; 107 };
109 108
110static long tls1_default_timeout(void) 109static long tls1_default_timeout(void)
@@ -142,4 +141,9 @@ long tls1_ctrl(SSL *s, int cmd, long larg, char *parg)
142 { 141 {
143 return(0); 142 return(0);
144 } 143 }
144
145long tls1_callback_ctrl(SSL *s, int cmd, void *(*fp)())
146 {
147 return(0);
148 }
145#endif 149#endif
diff --git a/src/lib/libssl/test/Makefile.ssl b/src/lib/libssl/test/Makefile.ssl
index ea86520128..dbb523bf15 100644
--- a/src/lib/libssl/test/Makefile.ssl
+++ b/src/lib/libssl/test/Makefile.ssl
@@ -13,6 +13,7 @@ INSTALLTOP= /usr/local/ssl
13MAKEFILE= Makefile.ssl 13MAKEFILE= Makefile.ssl
14MAKE= make -f $(MAKEFILE) 14MAKE= make -f $(MAKEFILE)
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
16PERL= perl
16 17
17PEX_LIBS= 18PEX_LIBS=
18EX_LIBS= #-lnsl -lsocket 19EX_LIBS= #-lnsl -lsocket
@@ -50,7 +51,7 @@ DHTEST= dhtest
50DSATEST= dsatest 51DSATEST= dsatest
51METHTEST= methtest 52METHTEST= methtest
52SSLTEST= ssltest 53SSLTEST= ssltest
53RSATEST= rsa_oaep_test 54RSATEST= rsa_test
54 55
55EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \ 56EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \
56 $(RC2TEST) $(RC4TEST) $(RC5TEST) \ 57 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
@@ -98,9 +99,9 @@ tags:
98 99
99tests: exe apps \ 100tests: exe apps \
100 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \ 101 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
101 test_rc2 test_rc4 test_rc5 test_bf test_cast \ 102 test_rmd test_rc2 test_rc4 test_rc5 test_bf test_cast \
102 test_rand test_bn test_enc test_x509 test_rsa test_crl test_sid \ 103 test_rand test_bn test_enc test_x509 test_rsa test_crl test_sid \
103 test_reqgen test_req test_pkcs7 test_verify test_dh test_dsa \ 104 test_gen test_req test_pkcs7 test_verify test_dh test_dsa \
104 test_ss test_ssl test_ca 105 test_ss test_ssl test_ca
105 106
106apps: 107apps:
@@ -180,9 +181,10 @@ test_pkcs7:
180 181
181test_bn: 182test_bn:
182 @echo starting big number library test, could take a while... 183 @echo starting big number library test, could take a while...
183 @(./$(BNTEST)|bc) | awk '{ \ 184 @./$(BNTEST) >tmp.bntest
184if ($$0 != "0") {print "error"; exit(1); } \ 185 @echo quit >>tmp.bntest
185if (((NR+1)%64) == 0) print NR+1," tests done"; }' 186 @echo "running bc"
187 @bc tmp.bntest 2>&1 | $(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"'
186 @echo 'test a^b%c implementations' 188 @echo 'test a^b%c implementations'
187 ./$(EXPTEST) 189 ./$(EXPTEST)
188 190
@@ -192,14 +194,15 @@ test_verify:
192 ../apps/openssl verify -CApath ../certs ../certs/*.pem 194 ../apps/openssl verify -CApath ../certs ../certs/*.pem
193 195
194test_dh: 196test_dh:
195 @echo "Generate as set of DH parameters" 197 @echo "Generate a set of DH parameters"
196 ./$(DHTEST) 198 ./$(DHTEST)
197 199
198test_dsa: 200test_dsa:
199 @echo "Generate as set of DSA parameters" 201 @echo "Generate a set of DSA parameters"
200 ./$(DSATEST) 202 ./$(DSATEST)
203 ./$(DSATEST) -app2_1
201 204
202test_reqgen: 205test_gen:
203 @echo "Generate and verify a certificate request" 206 @echo "Generate and verify a certificate request"
204 @sh ./testgen 207 @sh ./testgen
205 208
@@ -226,7 +229,7 @@ dclean:
226 mv -f Makefile.new $(MAKEFILE) 229 mv -f Makefile.new $(MAKEFILE)
227 230
228clean: 231clean:
229 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log 232 rm -f .rnd tmp.bntest *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log
230 233
231$(DLIBSSL): 234$(DLIBSSL):
232 (cd ../ssl; $(MAKE)) 235 (cd ../ssl; $(MAKE))
@@ -325,16 +328,19 @@ destest.o: ../include/openssl/opensslconf.h
325dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h 328dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h
326dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 329dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
327dhtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 330dhtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
331dhtest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
328dhtest.o: ../include/openssl/stack.h 332dhtest.o: ../include/openssl/stack.h
329dsatest.o: ../include/openssl/bio.h ../include/openssl/bn.h 333dsatest.o: ../include/openssl/bio.h ../include/openssl/bn.h
330dsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 334dsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
331dsatest.o: ../include/openssl/dsa.h ../include/openssl/err.h 335dsatest.o: ../include/openssl/dsa.h ../include/openssl/err.h
332dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 336dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
333dsatest.o: ../include/openssl/rand.h ../include/openssl/stack.h 337dsatest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
338dsatest.o: ../include/openssl/stack.h
334exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h 339exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h
335exptest.o: ../include/openssl/crypto.h ../include/openssl/err.h 340exptest.o: ../include/openssl/crypto.h ../include/openssl/err.h
336exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 341exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
337exptest.o: ../include/openssl/rand.h ../include/openssl/stack.h 342exptest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
343exptest.o: ../include/openssl/stack.h
338hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 344hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
339hmactest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 345hmactest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
340hmactest.o: ../include/openssl/cast.h ../include/openssl/crypto.h 346hmactest.o: ../include/openssl/cast.h ../include/openssl/crypto.h
@@ -359,11 +365,12 @@ rc2test.o: ../include/openssl/opensslconf.h ../include/openssl/rc2.h
359rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h 365rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h
360rc5test.o: ../include/openssl/rc5.h 366rc5test.o: ../include/openssl/rc5.h
361rmdtest.o: ../include/openssl/ripemd.h 367rmdtest.o: ../include/openssl/ripemd.h
362rsa_oaep_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h 368rsa_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
363rsa_oaep_test.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 369rsa_test.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
364rsa_oaep_test.o: ../include/openssl/err.h ../include/openssl/opensslconf.h 370rsa_test.o: ../include/openssl/err.h ../include/openssl/opensslconf.h
365rsa_oaep_test.o: ../include/openssl/opensslv.h ../include/openssl/rsa.h 371rsa_test.o: ../include/openssl/opensslv.h ../include/openssl/rand.h
366rsa_oaep_test.o: ../include/openssl/stack.h 372rsa_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
373rsa_test.o: ../include/openssl/stack.h
367sha1test.o: ../include/openssl/sha.h 374sha1test.o: ../include/openssl/sha.h
368shatest.o: ../include/openssl/sha.h 375shatest.o: ../include/openssl/sha.h
369ssltest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 376ssltest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
@@ -378,11 +385,12 @@ ssltest.o: ../include/openssl/md2.h ../include/openssl/md5.h
378ssltest.o: ../include/openssl/mdc2.h ../include/openssl/objects.h 385ssltest.o: ../include/openssl/mdc2.h ../include/openssl/objects.h
379ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 386ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
380ssltest.o: ../include/openssl/pem.h ../include/openssl/pem2.h 387ssltest.o: ../include/openssl/pem.h ../include/openssl/pem2.h
381ssltest.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 388ssltest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
382ssltest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 389ssltest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
383ssltest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 390ssltest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
384ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h 391ssltest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
385ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 392ssltest.o: ../include/openssl/sha.h ../include/openssl/ssl.h
386ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 393ssltest.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
387ssltest.o: ../include/openssl/stack.h ../include/openssl/tls1.h 394ssltest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
388ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 395ssltest.o: ../include/openssl/tls1.h ../include/openssl/x509.h
396ssltest.o: ../include/openssl/x509_vfy.h
diff --git a/src/lib/libssl/test/dsa-ca.pem b/src/lib/libssl/test/dsa-ca.pem
index 9eb08f3ddd..e69de29bb2 100644
--- a/src/lib/libssl/test/dsa-ca.pem
+++ b/src/lib/libssl/test/dsa-ca.pem
@@ -1,43 +0,0 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0
4
5svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0
6Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl
7Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/
8par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7T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MDaah4m49uUq
27AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u
283enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v
29AhQfeF5BoMMDbX/kidUVpQ6gadPlZA==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE
37AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi
38ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh
39MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD
40MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa
41C1Q=
42-----END CERTIFICATE-----
43
diff --git a/src/lib/libssl/test/dsa-pca.pem b/src/lib/libssl/test/dsa-pca.pem
index e3641ad47e..e69de29bb2 100644
--- a/src/lib/libssl/test/dsa-pca.pem
+++ b/src/lib/libssl/test/dsa-pca.pem
@@ -1,49 +0,0 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4
4
5GZ9zgFc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+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO
42VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C
43uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk
44umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
4529nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D
46AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n
475rKUjNBhSg==
48-----END CERTIFICATE-----
49
diff --git a/src/lib/libssl/test/maketests.com b/src/lib/libssl/test/maketests.com
index e4b052e688..1246d9a077 100644
--- a/src/lib/libssl/test/maketests.com
+++ b/src/lib/libssl/test/maketests.com
@@ -147,7 +147,7 @@ $ TEST_FILES = "BNTEST,IDEATEST,MD2TEST,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,"+ -
150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_OAEP_TEST" 150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST"
151$ TCPIP_PROGRAMS = ",," 151$ TCPIP_PROGRAMS = ",,"
152$ IF COMPILER .EQS. "VAXC" THEN - 152$ IF COMPILER .EQS. "VAXC" THEN -
153 TCPIP_PROGRAMS = ",SSLTEST," 153 TCPIP_PROGRAMS = ",SSLTEST,"
@@ -730,12 +730,36 @@ $!
730$! Set Up Initial CC Definitions, Possibly With User Ones 730$! Set Up Initial CC Definitions, Possibly With User Ones
731$! 731$!
732$ CCDEFS = "VMS=1,TCPIP_TYPE_''P4'" 732$ CCDEFS = "VMS=1,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"
733$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 757$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
734$ CCEXTRAFLAGS = "" 758$ CCEXTRAFLAGS = ""
735$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 759$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
736$ CCDISABLEWARNINGS = "" 760$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
737$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN - 761$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
738 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS 762 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
739$! 763$!
740$! Check To See If The User Entered A Valid Paramter. 764$! Check To See If The User Entered A Valid Paramter.
741$! 765$!
diff --git a/src/lib/libssl/test/rsa_test.c b/src/lib/libssl/test/rsa_test.c
new file mode 100644
index 0000000000..e5ae0c1f69
--- /dev/null
+++ b/src/lib/libssl/test/rsa_test.c
@@ -0,0 +1,314 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "openssl/e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#include <openssl/rand.h>
11#ifdef NO_RSA
12int main(int argc, char *argv[])
13{
14 printf("No RSA support\n");
15 return(0);
16}
17#else
18#include <openssl/rsa.h>
19
20#define SetKey \
21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
22 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
23 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
24 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
25 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
26 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
27 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
28 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
29 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
30 return (sizeof(ctext_ex) - 1);
31
32static int key1(RSA *key, unsigned char *c)
33 {
34 static unsigned char n[] =
35"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
36"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
37"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
38"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
39"\xF5";
40
41 static unsigned char e[] = "\x11";
42
43 static unsigned char d[] =
44"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
45"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
46"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
47"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
48
49 static unsigned char p[] =
50"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
51"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
52"\x0D";
53
54 static unsigned char q[] =
55"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
56"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
57"\x89";
58
59 static unsigned char dmp1[] =
60"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
61"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
62
63 static unsigned char dmq1[] =
64"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
65"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
66"\x51";
67
68 static unsigned char iqmp[] =
69"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
70"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
71
72 static unsigned char ctext_ex[] =
73"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
74"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
75"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
76"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
77
78 SetKey;
79 }
80
81static int key2(RSA *key, unsigned char *c)
82 {
83 static unsigned char n[] =
84"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
85"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
86"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
87"\x34\x77\xCF";
88
89 static unsigned char e[] = "\x3";
90
91 static unsigned char d[] =
92"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
93"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
94"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
95"\xE5\xEB";
96
97 static unsigned char p[] =
98"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
99"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
100
101 static unsigned char q[] =
102"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
103"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
104
105 static unsigned char dmp1[] =
106"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
107"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
108
109 static unsigned char dmq1[] =
110"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
111"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
112
113 static unsigned char iqmp[] =
114"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
115"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
116
117 static unsigned char ctext_ex[] =
118"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
119"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
120"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
121"\x62\x51";
122
123 SetKey;
124 }
125
126static int key3(RSA *key, unsigned char *c)
127 {
128 static unsigned char n[] =
129"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
130"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
131"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
132"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
133"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
134"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
135"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
136"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
137"\xCB";
138
139 static unsigned char e[] = "\x11";
140
141 static unsigned char d[] =
142"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
143"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
144"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
145"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
146"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
147"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
148"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
149"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
150"\xC1";
151
152 static unsigned char p[] =
153"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
154"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
155"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
156"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
157"\x99";
158
159 static unsigned char q[] =
160"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
161"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
162"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
163"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
164"\x03";
165
166 static unsigned char dmp1[] =
167"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
168"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
169"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
170"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
171
172 static unsigned char dmq1[] =
173"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
174"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
175"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
176"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
177
178 static unsigned char iqmp[] =
179"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
180"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
181"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
182"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
183"\xF7";
184
185 static unsigned char ctext_ex[] =
186"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
187"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
188"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
189"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
190"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
191"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
192"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
193"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
194
195 SetKey;
196 }
197
198static int pad_unknown(void)
199{
200 unsigned long l;
201 while ((l = ERR_get_error()) != 0)
202 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
203 return(1);
204 return(0);
205}
206
207static const char rnd_seed[] = "string to make the random number generator think it has entropy";
208
209int main(int argc, char *argv[])
210 {
211 int err=0;
212 int v;
213 RSA *key;
214 unsigned char ptext[256];
215 unsigned char ctext[256];
216 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
217 unsigned char ctext_ex[256];
218 int plen;
219 int clen = 0;
220 int num;
221
222 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
223
224 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
225
226 plen = sizeof(ptext_ex) - 1;
227
228 for (v = 0; v < 3; v++)
229 {
230 key = RSA_new();
231 switch (v) {
232 case 0:
233 clen = key1(key, ctext_ex);
234 break;
235 case 1:
236 clen = key2(key, ctext_ex);
237 break;
238 case 2:
239 clen = key3(key, ctext_ex);
240 break;
241 }
242
243 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
244 RSA_PKCS1_PADDING);
245 if (num != clen)
246 {
247 printf("PKCS#1 v1.5 encryption failed!\n");
248 err=1;
249 goto oaep;
250 }
251
252 num = RSA_private_decrypt(num, ctext, ptext, key,
253 RSA_PKCS1_PADDING);
254 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
255 {
256 printf("PKCS#1 v1.5 decryption failed!\n");
257 err=1;
258 }
259 else
260 printf("PKCS #1 v1.5 encryption/decryption ok\n");
261
262 oaep:
263 ERR_clear_error();
264 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
265 RSA_PKCS1_OAEP_PADDING);
266 if (num == -1 && pad_unknown())
267 {
268 printf("No OAEP support\n");
269 goto next;
270 }
271 if (num != clen)
272 {
273 printf("OAEP encryption failed!\n");
274 err=1;
275 goto next;
276 }
277
278 num = RSA_private_decrypt(num, ctext, ptext, key,
279 RSA_PKCS1_OAEP_PADDING);
280 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
281 {
282 printf("OAEP decryption (encrypted data) failed!\n");
283 err=1;
284 }
285 else if (memcmp(ctext, ctext_ex, num) == 0)
286 {
287 printf("OAEP test vector %d passed!\n", v);
288 goto next;
289 }
290
291 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
292 Try decrypting ctext_ex */
293
294 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
295 RSA_PKCS1_OAEP_PADDING);
296
297 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
298 {
299 printf("OAEP decryption (test vector data) failed!\n");
300 err=1;
301 }
302 else
303 printf("OAEP encryption/decryption ok\n");
304 next:
305 RSA_free(key);
306 }
307
308 ERR_remove_state(0);
309
310 CRYPTO_mem_leaks_fp(stdout);
311
312 return err;
313 }
314#endif
diff --git a/src/lib/libssl/test/tcrl.com b/src/lib/libssl/test/tcrl.com
index cef21467bb..2e6ab2814d 100644
--- a/src/lib/libssl/test/tcrl.com
+++ b/src/lib/libssl/test/tcrl.com
@@ -10,6 +10,9 @@ $ t := testcrl.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing CRL conversions" 12$ write sys$output "testing CRL conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/test/testca.com b/src/lib/libssl/test/testca.com
index ea75479cd5..c670f2bf5f 100644
--- a/src/lib/libssl/test/testca.com
+++ b/src/lib/libssl/test/testca.com
@@ -40,7 +40,9 @@ $
40$ set noon 40$ set noon
41$ call deltree [.demoCA]*.* 41$ call deltree [.demoCA]*.*
42$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) demoCA.dir;* 42$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) demoCA.dir;*
43$ delete demoCA.dir;*,newcert.pem;*,newreq.pem;* 43$ delete demoCA.dir;*
44$ if f$search("newcert.pem") .nes. "" then delete newcert.pem;*
45$ if f$search("newcert.pem") .nes. "" then delete newreq.pem;*
44$ set on 46$ set on
45$! #usage: CA -newcert|-newreq|-newca|-sign|-verify 47$! #usage: CA -newcert|-newreq|-newca|-sign|-verify
46$ 48$
diff --git a/src/lib/libssl/test/testenc.com b/src/lib/libssl/test/testenc.com
index 0756e8bada..3b66f2e0d0 100644
--- a/src/lib/libssl/test/testenc.com
+++ b/src/lib/libssl/test/testenc.com
@@ -8,19 +8,23 @@ $ testsrc := makefile.ssl
8$ test := p.txt 8$ test := p.txt
9$ cmd := mcr 'exe_dir'openssl 9$ cmd := mcr 'exe_dir'openssl
10$ 10$
11$ if f$search(test) .nes. "" then delete 'test';*
11$ copy 'testsrc' 'test' 12$ copy 'testsrc' 'test'
12$ 13$
14$ if f$search(test+"-cipher") .nes. "" then delete 'test'-cipher;*
15$ if f$search(test+"-clear") .nes. "" then delete 'test'-clear;*
16$
13$ write sys$output "cat" 17$ write sys$output "cat"
14$ 'cmd' enc -in 'test' -out 'test'-cipher 18$ 'cmd' enc -in 'test' -out 'test'-cipher
15$ 'cmd' enc -in 'test'-cipher -out 'test'-clear 19$ 'cmd' enc -in 'test'-cipher -out 'test'-clear
16$ difference/output=nl: 'test' 'test'-clear 20$ backup/compare 'test' 'test'-clear
17$ if $severity .ne. 1 then exit 3 21$ if $severity .ne. 1 then exit 3
18$ delete 'test'-cipher;*,'test'-clear;* 22$ delete 'test'-cipher;*,'test'-clear;*
19$ 23$
20$ write sys$output "base64" 24$ write sys$output "base64"
21$ 'cmd' enc -a -e -in 'test' -out 'test'-cipher 25$ 'cmd' enc -a -e -in 'test' -out 'test'-cipher
22$ 'cmd' enc -a -d -in 'test'-cipher -out 'test'-clear 26$ 'cmd' enc -a -d -in 'test'-cipher -out 'test'-clear
23$ difference/output=nl: 'test' 'test'-clear 27$ backup/compare 'test' 'test'-clear
24$ if $severity .ne. 1 then exit 3 28$ if $severity .ne. 1 then exit 3
25$ delete 'test'-cipher;*,'test'-clear;* 29$ delete 'test'-cipher;*,'test'-clear;*
26$ 30$
@@ -30,16 +34,22 @@ $ open/read f 'test'-cipher-commands
30$ loop_cipher_commands: 34$ loop_cipher_commands:
31$ read/end=loop_cipher_commands_end f i 35$ read/end=loop_cipher_commands_end f i
32$ write sys$output i 36$ write sys$output i
37$
38$ if f$search(test+"-"+i+"-cipher") .nes. "" then -
39 delete 'test'-'i'-cipher;*
40$ if f$search(test+"-"+i+"-clear") .nes. "" then -
41 delete 'test'-'i'-clear;*
42$
33$ 'cmd' 'i' -bufsize 113 -e -k test -in 'test' -out 'test'-'i'-cipher 43$ 'cmd' 'i' -bufsize 113 -e -k test -in 'test' -out 'test'-'i'-cipher
34$ 'cmd' 'i' -bufsize 157 -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear 44$ 'cmd' 'i' -bufsize 157 -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear
35$ difference/output=nl: 'test' 'test'-'i'-clear 45$ backup/compare 'test' 'test'-'i'-clear
36$ if $severity .ne. 1 then exit 3 46$ if $severity .ne. 1 then exit 3
37$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;* 47$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;*
38$ 48$
39$ write sys$output i," base64" 49$ write sys$output i," base64"
40$ 'cmd' 'i' -bufsize 113 -a -e -k test -in 'test' -out 'test'-'i'-cipher 50$ 'cmd' 'i' -bufsize 113 -a -e -k test -in 'test' -out 'test'-'i'-cipher
41$ 'cmd' 'i' -bufsize 157 -a -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear 51$ 'cmd' 'i' -bufsize 157 -a -d -k test -in 'test'-'i'-cipher -out 'test'-'i'-clear
42$ difference/output=nl: 'test' 'test'-'i'-clear 52$ backup/compare 'test' 'test'-'i'-clear
43$ if $severity .ne. 1 then exit 3 53$ if $severity .ne. 1 then exit 3
44$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;* 54$ delete 'test'-'i'-cipher;*,'test'-'i'-clear;*
45$ 55$
diff --git a/src/lib/libssl/test/testgen b/src/lib/libssl/test/testgen
index 3534f5821f..c5f61b582b 100644
--- a/src/lib/libssl/test/testgen
+++ b/src/lib/libssl/test/testgen
@@ -15,6 +15,8 @@ echo "There should be a 2 sequences of .'s and some +'s."
15echo "There should not be more that at most 80 per line" 15echo "There should not be more that at most 80 per line"
16echo "This could take some time." 16echo "This could take some time."
17 17
18echo "string to make the random number generator think it has entropy" >> ./.rnd
19
18../apps/openssl req -config test.cnf -new -out testreq.pem 20../apps/openssl req -config test.cnf -new -out testreq.pem
19if [ $? != 0 ]; then 21if [ $? != 0 ]; then
20echo problems creating request 22echo problems creating request
diff --git a/src/lib/libssl/test/testgen.com b/src/lib/libssl/test/testgen.com
index ec302f524a..0e9029371a 100644
--- a/src/lib/libssl/test/testgen.com
+++ b/src/lib/libssl/test/testgen.com
@@ -20,6 +20,11 @@ $ write sys$output "There should be a 2 sequences of .'s and some +'s."
20$ write sys$output "There should not be more that at most 80 per line" 20$ write sys$output "There should not be more that at most 80 per line"
21$ write sys$output "This could take some time." 21$ write sys$output "This could take some time."
22$ 22$
23$ append/new nl: .rnd
24$ open/append random_file .rnd
25$ write random_file "string to make the random number generator think it has entropy"
26$ close random_file
27$
23$ mcr 'exe_dir'openssl req -config test.cnf -new -out testreq.pem 28$ mcr 'exe_dir'openssl req -config test.cnf -new -out testreq.pem
24$ if $severity .ne. 1 29$ if $severity .ne. 1
25$ then 30$ then
diff --git a/src/lib/libssl/test/tests.com b/src/lib/libssl/test/tests.com
index 147b8aa838..040dafab8d 100644
--- a/src/lib/libssl/test/tests.com
+++ b/src/lib/libssl/test/tests.com
@@ -20,9 +20,9 @@ $ tests = p1
20$ else 20$ else
21$ tests := - 21$ tests := -
22 test_des,test_idea,test_sha,test_md5,test_hmac,test_md2,test_mdc2,- 22 test_des,test_idea,test_sha,test_md5,test_hmac,test_md2,test_mdc2,-
23 test_rc2,test_rc4,test_rc5,test_bf,test_cast,- 23 test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,-
24 test_rand,test_bn,test_enc,test_x509,test_rsa,test_crl,test_sid,- 24 test_rand,test_bn,test_enc,test_x509,test_rsa,test_crl,test_sid,-
25 test_reqgen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,- 25 test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,-
26 test_ss,test_ssl,test_ca 26 test_ss,test_ssl,test_ca
27$ endif 27$ endif
28$ tests = f$edit(tests,"COLLAPSE") 28$ tests = f$edit(tests,"COLLAPSE")
@@ -48,7 +48,7 @@ $ DHTEST := dhtest
48$ DSATEST := dsatest 48$ DSATEST := dsatest
49$ METHTEST := methtest 49$ METHTEST := methtest
50$ SSLTEST := ssltest 50$ SSLTEST := ssltest
51$ RSATEST := rsa_oaep_test 51$ RSATEST := rsa_test
52$ 52$
53$ tests_i = 0 53$ tests_i = 0
54$ loop_tests: 54$ loop_tests:
@@ -151,9 +151,7 @@ RECORD
151$ create/fdl=bntest-vms.fdl bntest-vms.sh 151$ create/fdl=bntest-vms.fdl bntest-vms.sh
152$ open/append foo bntest-vms.sh 152$ open/append foo bntest-vms.sh
153$ type/output=foo: sys$input: 153$ type/output=foo: sys$input:
154<< __FOO__ bc | awk '{ \ 154<< __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"'
155if ($$0 != "0") {print "error"; exit(1); } \
156if (((NR+1)%64) == 0) print NR+1," tests done"; }'
157$ define/user sys$output bntest-vms.tmp 155$ define/user sys$output bntest-vms.tmp
158$ mcr 'texe_dir''bntest' 156$ mcr 'texe_dir''bntest'
159$ copy bntest-vms.tmp foo: 157$ copy bntest-vms.tmp foo:
@@ -173,14 +171,14 @@ $ write sys$output "There are definitly a few expired certificates"
173$ @tverify.com 171$ @tverify.com
174$ goto loop_tests 172$ goto loop_tests
175$ test_dh: 173$ test_dh:
176$ write sys$output "Generate as set of DH parameters" 174$ write sys$output "Generate a set of DH parameters"
177$ mcr 'texe_dir''dhtest' 175$ mcr 'texe_dir''dhtest'
178$ goto loop_tests 176$ goto loop_tests
179$ test_dsa: 177$ test_dsa:
180$ write sys$output "Generate as set of DSA parameters" 178$ write sys$output "Generate a set of DSA parameters"
181$ mcr 'texe_dir''dsatest' 179$ mcr 'texe_dir''dsatest'
182$ goto loop_tests 180$ goto loop_tests
183$ test_reqgen: 181$ test_gen:
184$ write sys$output "Generate and verify a certificate request" 182$ write sys$output "Generate and verify a certificate request"
185$ @testgen.com 183$ @testgen.com
186$ goto loop_tests 184$ goto loop_tests
diff --git a/src/lib/libssl/test/testssl b/src/lib/libssl/test/testssl
index 255ae5e976..a88e290c57 100644
--- a/src/lib/libssl/test/testssl
+++ b/src/lib/libssl/test/testssl
@@ -63,6 +63,12 @@ echo test sslv3 with both client and server authentication via BIO pair
63echo test sslv2/sslv3 via BIO pair 63echo test sslv2/sslv3 via BIO pair
64./ssltest || exit 1 64./ssltest || exit 1
65 65
66echo test sslv2/sslv3 w/o DHE via BIO pair
67./ssltest -bio_pair -no_dhe || exit 1
68
69echo test sslv2/sslv3 with 1024bit DHE
70./ssltest -bio_pair -dhe1024 -v || exit 1
71
66echo test sslv2/sslv3 with server authentication 72echo test sslv2/sslv3 with server authentication
67./ssltest -bio_pair -server_auth -CApath ../certs || exit 1 73./ssltest -bio_pair -server_auth -CApath ../certs || exit 1
68 74
diff --git a/src/lib/libssl/test/testssl.com b/src/lib/libssl/test/testssl.com
index 93a9aef802..0b4b0a0ad3 100644
--- a/src/lib/libssl/test/testssl.com
+++ b/src/lib/libssl/test/testssl.com
@@ -58,6 +58,10 @@ $ write sys$output "test sslv2 via BIO pair"
58$ mcr 'exe_dir'ssltest -bio_pair -ssl2 58$ mcr 'exe_dir'ssltest -bio_pair -ssl2
59$ if $severity .ne. 1 then goto exit3 59$ if $severity .ne. 1 then goto exit3
60$ 60$
61$ write sys$output "test sslv2/sslv3 with 1024 bit DHE via BIO pair"
62$ mcr 'exe_dir'ssltest -bio_pair -dhe1024 -v
63$ if $severity .ne. 1 then goto exit3
64$
61$ write sys$output "test sslv2 with server authentication via BIO pair" 65$ write sys$output "test sslv2 with server authentication via BIO pair"
62$ mcr 'exe_dir'ssltest -bio_pair -ssl2 -server_auth "-CAfile" certs.tmp 66$ mcr 'exe_dir'ssltest -bio_pair -ssl2 -server_auth "-CAfile" certs.tmp
63$ if $severity .ne. 1 then goto exit3 67$ if $severity .ne. 1 then goto exit3
@@ -90,6 +94,10 @@ $ write sys$output "test sslv2/sslv3 via BIO pair"
90$ mcr 'exe_dir'ssltest 94$ mcr 'exe_dir'ssltest
91$ if $severity .ne. 1 then goto exit3 95$ if $severity .ne. 1 then goto exit3
92$ 96$
97$ write sys$output "test sslv2/sslv3 w/o DHE via BIO pair"
98$ mcr 'exe_dir'ssltest -bio_pair -no_dhe
99$ if $severity .ne. 1 then goto exit3
100$
93$ write sys$output "test sslv2/sslv3 with server authentication" 101$ write sys$output "test sslv2/sslv3 with server authentication"
94$ mcr 'exe_dir'ssltest -bio_pair -server_auth "-CAfile" certs.tmp 102$ mcr 'exe_dir'ssltest -bio_pair -server_auth "-CAfile" certs.tmp
95$ if $severity .ne. 1 then goto exit3 103$ if $severity .ne. 1 then goto exit3
diff --git a/src/lib/libssl/test/tpkcs7.com b/src/lib/libssl/test/tpkcs7.com
index 5ed920ac34..9e345937c6 100644
--- a/src/lib/libssl/test/tpkcs7.com
+++ b/src/lib/libssl/test/tpkcs7.com
@@ -10,6 +10,9 @@ $ t := testp7.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing PKCS7 conversions" 12$ write sys$output "testing PKCS7 conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -34,16 +37,16 @@ $ write sys$output "p -> p"
34$ 'cmd' -in f.p -inform p -outform p -out ff.p3 37$ 'cmd' -in f.p -inform p -outform p -out ff.p3
35$ if $severity .ne. 1 then exit 3 38$ if $severity .ne. 1 then exit 3
36$ 39$
37$ difference/output=nl: fff.p f.p 40$ backup/compare fff.p f.p
38$ if $severity .ne. 1 then exit 3 41$ if $severity .ne. 1 then exit 3
39$ difference/output=nl: fff.p ff.p1 42$ backup/compare fff.p ff.p1
40$ if $severity .ne. 1 then exit 3 43$ if $severity .ne. 1 then exit 3
41$ difference/output=nl: fff.p ff.p3 44$ backup/compare fff.p ff.p3
42$ if $severity .ne. 1 then exit 3 45$ if $severity .ne. 1 then exit 3
43$ 46$
44$ difference/output=nl: f.p ff.p1 47$ backup/compare f.p ff.p1
45$ if $severity .ne. 1 then exit 3 48$ if $severity .ne. 1 then exit 3
46$ difference/output=nl: f.p ff.p3 49$ backup/compare f.p ff.p3
47$ if $severity .ne. 1 then exit 3 50$ if $severity .ne. 1 then exit 3
48$ 51$
49$ delete f.*;*,ff.*;*,fff.*;* 52$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/test/tpkcs7d.com b/src/lib/libssl/test/tpkcs7d.com
index 08d33eaa69..7d4f8794a4 100644
--- a/src/lib/libssl/test/tpkcs7d.com
+++ b/src/lib/libssl/test/tpkcs7d.com
@@ -10,6 +10,9 @@ $ t := pkcs7-1.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing PKCS7 conversions (2)" 12$ write sys$output "testing PKCS7 conversions (2)"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -34,9 +37,9 @@ $ write sys$output "p -> p"
34$ 'cmd' -in f.p -inform p -outform p -out ff.p3 37$ 'cmd' -in f.p -inform p -outform p -out ff.p3
35$ if $severity .ne. 1 then exit 3 38$ if $severity .ne. 1 then exit 3
36$ 39$
37$ difference/output=nl: f.p ff.p1 40$ backup/compare f.p ff.p1
38$ if $severity .ne. 1 then exit 3 41$ if $severity .ne. 1 then exit 3
39$ difference/output=nl: f.p ff.p3 42$ backup/compare f.p ff.p3
40$ if $severity .ne. 1 then exit 3 43$ if $severity .ne. 1 then exit 3
41$ 44$
42$ delete f.*;*,ff.*;*,fff.*;* 45$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/test/treq.com b/src/lib/libssl/test/treq.com
index 9eb1d26f6e..22c22c3aa9 100644
--- a/src/lib/libssl/test/treq.com
+++ b/src/lib/libssl/test/treq.com
@@ -10,6 +10,9 @@ $ t := testreq.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing req conversions" 12$ write sys$output "testing req conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/test/trsa.com b/src/lib/libssl/test/trsa.com
index 9c9083d02b..28add5eefd 100644
--- a/src/lib/libssl/test/trsa.com
+++ b/src/lib/libssl/test/trsa.com
@@ -10,6 +10,9 @@ $ t := testrsa.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing RSA conversions" 12$ write sys$output "testing RSA conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/test/tsid.com b/src/lib/libssl/test/tsid.com
index 28d83e5c4e..bde23f9bb9 100644
--- a/src/lib/libssl/test/tsid.com
+++ b/src/lib/libssl/test/tsid.com
@@ -10,6 +10,9 @@ $ t := testsid.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing session-id conversions" 12$ write sys$output "testing session-id conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$! difference/output=nl: fff.p ff.p2 62$! backup/compare fff.p ff.p2
60$! if $severity .ne. 1 then exit 3 63$! if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$! difference/output=nl: f.t ff.t1 67$! backup/compare f.t ff.t1
65$! if $severity .ne. 1 then exit 3 68$! if $severity .ne. 1 then exit 3
66$! difference/output=nl: f.t ff.t2 69$! backup/compare f.t ff.t2
67$! if $severity .ne. 1 then exit 3 70$! if $severity .ne. 1 then exit 3
68$! difference/output=nl: f.t ff.t3 71$! backup/compare f.t ff.t3
69$! if $severity .ne. 1 then exit 3 72$! if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$! difference/output=nl: f.p ff.p2 76$! backup/compare f.p ff.p2
74$! if $severity .ne. 1 then exit 3 77$! if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/test/tx509.com b/src/lib/libssl/test/tx509.com
index bbcf0a384b..985969c566 100644
--- a/src/lib/libssl/test/tx509.com
+++ b/src/lib/libssl/test/tx509.com
@@ -10,6 +10,9 @@ $ t := testx509.pem
10$ if p1 .nes. "" then t = p1 10$ if p1 .nes. "" then t = p1
11$ 11$
12$ write sys$output "testing X509 conversions" 12$ write sys$output "testing X509 conversions"
13$ if f$search("fff.*") .nes "" then delete fff.*;*
14$ if f$search("ff.*") .nes "" then delete ff.*;*
15$ if f$search("f.*") .nes "" then delete f.*;*
13$ copy 't' fff.p 16$ copy 't' fff.p
14$ 17$
15$ write sys$output "p -> d" 18$ write sys$output "p -> d"
@@ -52,27 +55,27 @@ $ write sys$output "p -> p"
52$ 'cmd' -in f.p -inform p -outform p -out ff.p3 55$ 'cmd' -in f.p -inform p -outform p -out ff.p3
53$ if $severity .ne. 1 then exit 3 56$ if $severity .ne. 1 then exit 3
54$ 57$
55$ difference/output=nl: fff.p f.p 58$ backup/compare fff.p f.p
56$ if $severity .ne. 1 then exit 3 59$ if $severity .ne. 1 then exit 3
57$ difference/output=nl: fff.p ff.p1 60$ backup/compare fff.p ff.p1
58$ if $severity .ne. 1 then exit 3 61$ if $severity .ne. 1 then exit 3
59$ difference/output=nl: fff.p ff.p2 62$ backup/compare fff.p ff.p2
60$ if $severity .ne. 1 then exit 3 63$ if $severity .ne. 1 then exit 3
61$ difference/output=nl: fff.p ff.p3 64$ backup/compare fff.p ff.p3
62$ if $severity .ne. 1 then exit 3 65$ if $severity .ne. 1 then exit 3
63$ 66$
64$ difference/output=nl: f.n ff.n1 67$ backup/compare f.n ff.n1
65$ if $severity .ne. 1 then exit 3 68$ if $severity .ne. 1 then exit 3
66$ difference/output=nl: f.n ff.n2 69$ backup/compare f.n ff.n2
67$ if $severity .ne. 1 then exit 3 70$ if $severity .ne. 1 then exit 3
68$ difference/output=nl: f.n ff.n3 71$ backup/compare f.n ff.n3
69$ if $severity .ne. 1 then exit 3 72$ if $severity .ne. 1 then exit 3
70$ 73$
71$ difference/output=nl: f.p ff.p1 74$ backup/compare f.p ff.p1
72$ if $severity .ne. 1 then exit 3 75$ if $severity .ne. 1 then exit 3
73$ difference/output=nl: f.p ff.p2 76$ backup/compare f.p ff.p2
74$ if $severity .ne. 1 then exit 3 77$ if $severity .ne. 1 then exit 3
75$ difference/output=nl: f.p ff.p3 78$ backup/compare f.p ff.p3
76$ if $severity .ne. 1 then exit 3 79$ if $severity .ne. 1 then exit 3
77$ 80$
78$ delete f.*;*,ff.*;*,fff.*;* 81$ delete f.*;*,ff.*;*,fff.*;*
diff --git a/src/lib/libssl/tls1.h b/src/lib/libssl/tls1.h
index a931efa936..6e2b06d34f 100644
--- a/src/lib/libssl/tls1.h
+++ b/src/lib/libssl/tls1.h
@@ -65,7 +65,7 @@
65extern "C" { 65extern "C" {
66#endif 66#endif
67 67
68#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 68#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 1
69 69
70#define TLS1_VERSION 0x0301 70#define TLS1_VERSION 0x0301
71#define TLS1_VERSION_MAJOR 0x03 71#define TLS1_VERSION_MAJOR 0x03
@@ -77,11 +77,11 @@ extern "C" {
77#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ 77#define TLS1_AD_ACCESS_DENIED 49 /* fatal */
78#define TLS1_AD_DECODE_ERROR 50 /* fatal */ 78#define TLS1_AD_DECODE_ERROR 50 /* fatal */
79#define TLS1_AD_DECRYPT_ERROR 51 79#define TLS1_AD_DECRYPT_ERROR 51
80#define TLS1_AD_EXPORT_RESTRICION 60 /* fatal */ 80#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */
81#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ 81#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */
82#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ 82#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */
83#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ 83#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */
84#define TLS1_AD_USER_CANCLED 90 84#define TLS1_AD_USER_CANCELLED 90
85#define TLS1_AD_NO_RENEGOTIATION 100 85#define TLS1_AD_NO_RENEGOTIATION 100
86 86
87#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 87#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060