├── .github └── FUNDING.yml ├── .gitignore ├── Android_crypto.mk ├── Android_ssl.mk ├── Crypto-config-target.mk ├── Crypto.mk ├── NOTICE ├── Ssl-config-target.mk ├── Ssl.mk ├── android-config.mk ├── build-config-32.mk ├── build-config-64.mk ├── build.sh ├── buildinf.h ├── crypto ├── LPdir_unix.c ├── aes │ ├── README │ ├── aes.h │ ├── aes_cbc.c │ ├── aes_cfb.c │ ├── aes_core.c │ ├── aes_ctr.c │ ├── aes_ecb.c │ ├── aes_ige.c │ ├── aes_locl.h │ ├── aes_misc.c │ ├── aes_ofb.c │ ├── aes_wrap.c │ ├── aes_x86core.c │ └── asm │ │ ├── aes-586.S │ │ ├── aes-586.pl │ │ ├── aes-armv4.S │ │ ├── aes-armv4.pl │ │ ├── aes-ia64.S │ │ ├── aes-mips.S │ │ ├── aes-mips.pl │ │ ├── aes-parisc.pl │ │ ├── aes-ppc.pl │ │ ├── aes-s390x.pl │ │ ├── aes-sparcv9.pl │ │ ├── aes-x86_64.S │ │ ├── aes-x86_64.pl │ │ ├── aesni-sha1-x86_64.S │ │ ├── aesni-sha1-x86_64.pl │ │ ├── aesni-x86.S │ │ ├── aesni-x86.pl │ │ ├── aesni-x86_64.S │ │ ├── aesni-x86_64.pl │ │ ├── aesv8-armx-64.S │ │ ├── aesv8-armx.S │ │ ├── aesv8-armx.pl │ │ ├── bsaes-armv7.S │ │ ├── bsaes-armv7.pl │ │ ├── bsaes-x86_64.S │ │ ├── bsaes-x86_64.pl │ │ ├── vpaes-x86.S │ │ ├── vpaes-x86.pl │ │ ├── vpaes-x86_64.S │ │ └── vpaes-x86_64.pl ├── arm64cpuid.S ├── arm_arch.h ├── armcap.c ├── armv4cpuid.S ├── asn1 │ ├── a_bitstr.c │ ├── a_bool.c │ ├── a_bytes.c │ ├── a_d2i_fp.c │ ├── a_digest.c │ ├── a_dup.c │ ├── a_enum.c │ ├── a_gentm.c │ ├── a_i2d_fp.c │ ├── a_int.c │ ├── a_mbstr.c │ ├── a_object.c │ ├── a_octet.c │ ├── a_print.c │ ├── a_set.c │ ├── a_sign.c │ ├── a_strex.c │ ├── a_strnid.c │ ├── a_time.c │ ├── a_type.c │ ├── a_utctm.c │ ├── a_utf8.c │ ├── a_verify.c │ ├── ameth_lib.c │ ├── asn1.h │ ├── asn1_err.c │ ├── asn1_gen.c │ ├── asn1_lib.c │ ├── asn1_locl.h │ ├── asn1_mac.h │ ├── asn1_par.c │ ├── asn1t.h │ ├── asn_mime.c │ ├── asn_moid.c │ ├── asn_pack.c │ ├── bio_asn1.c │ ├── bio_ndef.c │ ├── charmap.h │ ├── charmap.pl │ ├── d2i_pr.c │ ├── d2i_pu.c │ ├── evp_asn1.c │ ├── f_enum.c │ ├── f_int.c │ ├── f_string.c │ ├── i2d_pr.c │ ├── i2d_pu.c │ ├── n_pkey.c │ ├── nsseq.c │ ├── p5_pbe.c │ ├── p5_pbev2.c │ ├── p8_pkey.c │ ├── t_bitst.c │ ├── t_crl.c │ ├── t_pkey.c │ ├── t_req.c │ ├── t_spki.c │ ├── t_x509.c │ ├── t_x509a.c │ ├── tasn_dec.c │ ├── tasn_enc.c │ ├── tasn_fre.c │ ├── tasn_new.c │ ├── tasn_prn.c │ ├── tasn_typ.c │ ├── tasn_utl.c │ ├── x_algor.c │ ├── x_attrib.c │ ├── x_bignum.c │ ├── x_crl.c │ ├── x_exten.c │ ├── x_info.c │ ├── x_long.c │ ├── x_name.c │ ├── x_nx509.c │ ├── x_pkey.c │ ├── x_pubkey.c │ ├── x_req.c │ ├── x_sig.c │ ├── x_spki.c │ ├── x_val.c │ ├── x_x509.c │ └── x_x509a.c ├── bf │ ├── COPYRIGHT │ ├── asm │ │ ├── bf-586.S │ │ ├── bf-586.pl │ │ └── bf-686.pl │ ├── bf_cfb64.c │ ├── bf_ecb.c │ ├── bf_enc.c │ ├── bf_locl.h │ ├── bf_ofb64.c │ ├── bf_pi.h │ ├── bf_skey.c │ └── blowfish.h ├── bio │ ├── b_dump.c │ ├── b_print.c │ ├── b_sock.c │ ├── bf_buff.c │ ├── bf_lbuf.c │ ├── bf_nbio.c │ ├── bf_null.c │ ├── bio.h │ ├── bio_cb.c │ ├── bio_err.c │ ├── bio_lcl.h │ ├── bio_lib.c │ ├── bss_acpt.c │ ├── bss_bio.c │ ├── bss_conn.c │ ├── bss_dgram.c │ ├── bss_fd.c │ ├── bss_file.c │ ├── bss_log.c │ ├── bss_mem.c │ ├── bss_null.c │ └── bss_sock.c ├── bn │ ├── asm │ │ ├── README │ │ ├── alpha-mont.pl │ │ ├── armv4-gf2m.S │ │ ├── armv4-gf2m.pl │ │ ├── armv4-mont.S │ │ ├── armv4-mont.pl │ │ ├── bn-586.S │ │ ├── bn-586.pl │ │ ├── bn-mips.S │ │ ├── co-586.S │ │ ├── co-586.pl │ │ ├── ia64-mont.pl │ │ ├── ia64.S │ │ ├── mips-mont.S │ │ ├── mips-mont.pl │ │ ├── mips.pl │ │ ├── mips3-mont.pl │ │ ├── modexp512-x86_64.S │ │ ├── modexp512-x86_64.pl │ │ ├── pa-risc2.s │ │ ├── pa-risc2W.s │ │ ├── parisc-mont.pl │ │ ├── ppc-mont.pl │ │ ├── ppc.pl │ │ ├── ppc64-mont.pl │ │ ├── s390x-gf2m.pl │ │ ├── s390x-mont.pl │ │ ├── s390x.S │ │ ├── sparcv8.S │ │ ├── sparcv8plus.S │ │ ├── sparcv9-mont.pl │ │ ├── sparcv9a-mont.pl │ │ ├── via-mont.pl │ │ ├── x86-gf2m.S │ │ ├── x86-gf2m.pl │ │ ├── x86-mont.S │ │ ├── x86-mont.pl │ │ ├── x86.pl │ │ ├── x86 │ │ │ ├── add.pl │ │ │ ├── comba.pl │ │ │ ├── div.pl │ │ │ ├── f │ │ │ ├── mul.pl │ │ │ ├── mul_add.pl │ │ │ ├── sqr.pl │ │ │ └── sub.pl │ │ ├── x86_64-gcc.c │ │ ├── x86_64-gf2m.S │ │ ├── x86_64-gf2m.pl │ │ ├── x86_64-mont.S │ │ ├── x86_64-mont.pl │ │ ├── x86_64-mont5.S │ │ └── x86_64-mont5.pl │ ├── bn.h │ ├── bn.mul │ ├── bn_add.c │ ├── bn_asm.c │ ├── bn_blind.c │ ├── bn_const.c │ ├── bn_ctx.c │ ├── bn_depr.c │ ├── bn_div.c │ ├── bn_err.c │ ├── bn_exp.c │ ├── bn_exp2.c │ ├── bn_gcd.c │ ├── bn_gf2m.c │ ├── bn_kron.c │ ├── bn_lcl.h │ ├── bn_lib.c │ ├── bn_mod.c │ ├── bn_mont.c │ ├── bn_mpi.c │ ├── bn_mul.c │ ├── bn_nist.c │ ├── bn_prime.c │ ├── bn_prime.h │ ├── bn_prime.pl │ ├── bn_print.c │ ├── bn_rand.c │ ├── bn_recp.c │ ├── bn_shift.c │ ├── bn_sqr.c │ ├── bn_sqrt.c │ ├── bn_word.c │ ├── bnspeed.c │ ├── bntest.c │ ├── divtest.c │ ├── exp.c │ ├── expspeed.c │ ├── exptest.c │ └── todo ├── buffer │ ├── buf_err.c │ ├── buf_str.c │ ├── buffer.c │ └── buffer.h ├── cmac │ ├── cm_ameth.c │ ├── cm_pmeth.c │ ├── cmac.c │ └── cmac.h ├── cms │ ├── cms.h │ ├── cms_asn1.c │ ├── cms_att.c │ ├── cms_cd.c │ ├── cms_dd.c │ ├── cms_enc.c │ ├── cms_env.c │ ├── cms_err.c │ ├── cms_ess.c │ ├── cms_io.c │ ├── cms_lcl.h │ ├── cms_lib.c │ ├── cms_pwri.c │ ├── cms_sd.c │ └── cms_smime.c ├── comp │ ├── c_rle.c │ ├── c_zlib.c │ ├── comp.h │ ├── comp_err.c │ └── comp_lib.c ├── conf │ ├── README │ ├── cnf_save.c │ ├── conf.h │ ├── conf_api.c │ ├── conf_api.h │ ├── conf_def.c │ ├── conf_def.h │ ├── conf_err.c │ ├── conf_lib.c │ ├── conf_mall.c │ ├── conf_mod.c │ ├── conf_sap.c │ ├── keysets.pl │ ├── ssleay.cnf │ └── test.c ├── constant_time_locl.h ├── cpt_err.c ├── cryptlib.c ├── cryptlib.h ├── crypto.h ├── cversion.c ├── des │ ├── COPYRIGHT │ ├── DES.pm │ ├── DES.xs │ ├── FILES0 │ ├── INSTALL │ ├── Imakefile │ ├── KERBEROS │ ├── README │ ├── VERSION │ ├── asm │ │ ├── crypt586.S │ │ ├── crypt586.pl │ │ ├── des-586.S │ │ ├── des-586.pl │ │ ├── des_enc.m4 │ │ ├── desboth.pl │ │ └── readme │ ├── cbc3_enc.c │ ├── cbc_cksm.c │ ├── cbc_enc.c │ ├── cfb64ede.c │ ├── cfb64enc.c │ ├── cfb_enc.c │ ├── des.c │ ├── des.h │ ├── des.pod │ ├── des3s.cpp │ ├── des_enc.c │ ├── des_locl.h │ ├── des_old.c │ ├── des_old.h │ ├── des_old2.c │ ├── des_opts.c │ ├── des_ver.h │ ├── dess.cpp │ ├── destest.c │ ├── ecb3_enc.c │ ├── ecb_enc.c │ ├── ede_cbcm_enc.c │ ├── enc_read.c │ ├── enc_writ.c │ ├── fcrypt.c │ ├── fcrypt_b.c │ ├── makefile.bc │ ├── ncbc_enc.c │ ├── ofb64ede.c │ ├── ofb64enc.c │ ├── ofb_enc.c │ ├── options.txt │ ├── pcbc_enc.c │ ├── qud_cksm.c │ ├── rand_key.c │ ├── read2pwd.c │ ├── read_pwd.c │ ├── rpc_des.h │ ├── rpc_enc.c │ ├── rpw.c │ ├── set_key.c │ ├── speed.c │ ├── spr.h │ ├── str2key.c │ ├── t │ │ └── test │ ├── times │ │ ├── 486-50.sol │ │ ├── 586-100.lnx │ │ ├── 686-200.fre │ │ ├── aix.cc │ │ ├── alpha.cc │ │ ├── hpux.cc │ │ ├── sparc.gcc │ │ └── usparc.cc │ ├── typemap │ └── xcbc_enc.c ├── dh │ ├── dh.h │ ├── dh1024.pem │ ├── dh192.pem │ ├── dh2048.pem │ ├── dh4096.pem │ ├── dh512.pem │ ├── dh_ameth.c │ ├── dh_asn1.c │ ├── dh_check.c │ ├── dh_depr.c │ ├── dh_err.c │ ├── dh_gen.c │ ├── dh_key.c │ ├── dh_lib.c │ ├── dh_pmeth.c │ ├── dhtest.c │ ├── example │ ├── generate │ ├── p1024.c │ ├── p192.c │ └── p512.c ├── dsa │ ├── README │ ├── dsa.h │ ├── dsa_ameth.c │ ├── dsa_asn1.c │ ├── dsa_depr.c │ ├── dsa_err.c │ ├── dsa_gen.c │ ├── dsa_key.c │ ├── dsa_lib.c │ ├── dsa_locl.h │ ├── dsa_ossl.c │ ├── dsa_pmeth.c │ ├── dsa_prn.c │ ├── dsa_sign.c │ ├── dsa_vrf.c │ ├── dsagen.c │ ├── dsatest.c │ └── fips186a.txt ├── dso │ ├── README │ ├── dso.h │ ├── dso_dl.c │ ├── dso_dlfcn.c │ ├── dso_err.c │ ├── dso_lib.c │ ├── dso_null.c │ └── dso_openssl.c ├── ebcdic.c ├── ec │ ├── ec.h │ ├── ec2_mult.c │ ├── ec2_oct.c │ ├── ec2_smpl.c │ ├── ec_ameth.c │ ├── ec_asn1.c │ ├── ec_check.c │ ├── ec_curve.c │ ├── ec_cvt.c │ ├── ec_err.c │ ├── ec_key.c │ ├── ec_lcl.h │ ├── ec_lib.c │ ├── ec_mult.c │ ├── ec_oct.c │ ├── ec_pmeth.c │ ├── ec_print.c │ ├── eck_prn.c │ ├── ecp_mont.c │ ├── ecp_nist.c │ ├── ecp_oct.c │ ├── ecp_smpl.c │ └── ectest.c ├── ecdh │ ├── ecdh.h │ ├── ecdhtest.c │ ├── ech_err.c │ ├── ech_key.c │ ├── ech_lib.c │ ├── ech_locl.h │ └── ech_ossl.c ├── ecdsa │ ├── ecdsa.h │ ├── ecdsatest.c │ ├── ecs_asn1.c │ ├── ecs_err.c │ ├── ecs_lib.c │ ├── ecs_locl.h │ ├── ecs_ossl.c │ ├── ecs_sign.c │ └── ecs_vrf.c ├── engine │ ├── README │ ├── eng_all.c │ ├── eng_cnf.c │ ├── eng_cryptodev.c │ ├── eng_ctrl.c │ ├── eng_dyn.c │ ├── eng_err.c │ ├── eng_fat.c │ ├── eng_init.c │ ├── eng_int.h │ ├── eng_lib.c │ ├── eng_list.c │ ├── eng_openssl.c │ ├── eng_pkey.c │ ├── eng_table.c │ ├── engine.h │ ├── enginetest.c │ ├── tb_asnmth.c │ ├── tb_cipher.c │ ├── tb_dh.c │ ├── tb_digest.c │ ├── tb_dsa.c │ ├── tb_ecdh.c │ ├── tb_ecdsa.c │ ├── tb_pkmeth.c │ ├── tb_rand.c │ ├── tb_rsa.c │ └── tb_store.c ├── err │ ├── err.c │ ├── err.h │ ├── err_all.c │ ├── err_prn.c │ └── openssl.ec ├── evp │ ├── bio_b64.c │ ├── bio_enc.c │ ├── bio_md.c │ ├── bio_ok.c │ ├── c_all.c │ ├── c_allc.c │ ├── c_alld.c │ ├── digest.c │ ├── e_aes.c │ ├── e_aes_cbc_hmac_sha1.c │ ├── e_bf.c │ ├── e_camellia.c │ ├── e_cast.c │ ├── e_des.c │ ├── e_des3.c │ ├── e_dsa.c │ ├── e_idea.c │ ├── e_null.c │ ├── e_old.c │ ├── e_rc2.c │ ├── e_rc4.c │ ├── e_rc4_hmac_md5.c │ ├── e_rc5.c │ ├── e_seed.c │ ├── e_xcbc_d.c │ ├── encode.c │ ├── evp.h │ ├── evp_acnf.c │ ├── evp_cnf.c │ ├── evp_enc.c │ ├── evp_err.c │ ├── evp_key.c │ ├── evp_lib.c │ ├── evp_locl.h │ ├── evp_pbe.c │ ├── evp_pkey.c │ ├── evp_test.c │ ├── evptests.txt │ ├── m_dss.c │ ├── m_dss1.c │ ├── m_ecdsa.c │ ├── m_md4.c │ ├── m_md5.c │ ├── m_mdc2.c │ ├── m_null.c │ ├── m_ripemd.c │ ├── m_sha1.c │ ├── m_sigver.c │ ├── m_wp.c │ ├── names.c │ ├── openbsd_hw.c │ ├── p5_crpt.c │ ├── p5_crpt2.c │ ├── p_dec.c │ ├── p_enc.c │ ├── p_lib.c │ ├── p_open.c │ ├── p_seal.c │ ├── p_sign.c │ ├── p_verify.c │ ├── pmeth_fn.c │ ├── pmeth_gn.c │ └── pmeth_lib.c ├── ex_data.c ├── hmac │ ├── hm_ameth.c │ ├── hm_pmeth.c │ ├── hmac.c │ ├── hmac.h │ └── hmactest.c ├── krb5 │ ├── krb5_asn.c │ └── krb5_asn.h ├── lhash │ ├── lh_stats.c │ ├── lh_test.c │ ├── lhash.c │ ├── lhash.h │ └── num.pl ├── md32_common.h ├── md4 │ ├── md4.c │ ├── md4.h │ ├── md4_dgst.c │ ├── md4_locl.h │ ├── md4_one.c │ ├── md4s.cpp │ └── md4test.c ├── md5 │ ├── asm │ │ ├── md5-586.S │ │ ├── md5-586.pl │ │ ├── md5-ia64.S │ │ ├── md5-x86_64.S │ │ └── md5-x86_64.pl │ ├── md5.c │ ├── md5.h │ ├── md5_dgst.c │ ├── md5_locl.h │ ├── md5_one.c │ ├── md5s.cpp │ └── md5test.c ├── mem.c ├── mem_clr.c ├── mem_dbg.c ├── modes │ ├── asm │ │ ├── ghash-alpha.pl │ │ ├── ghash-armv4.S │ │ ├── ghash-armv4.pl │ │ ├── ghash-ia64.pl │ │ ├── ghash-parisc.pl │ │ ├── ghash-s390x.pl │ │ ├── ghash-sparcv9.pl │ │ ├── ghash-x86.S │ │ ├── ghash-x86.pl │ │ ├── ghash-x86_64.S │ │ ├── ghash-x86_64.pl │ │ ├── ghashv8-armx-64.S │ │ ├── ghashv8-armx.S │ │ └── ghashv8-armx.pl │ ├── cbc128.c │ ├── ccm128.c │ ├── cfb128.c │ ├── ctr128.c │ ├── gcm128.c │ ├── modes_lcl.h │ ├── ofb128.c │ └── xts128.c ├── o_dir.c ├── o_dir.h ├── o_init.c ├── o_str.c ├── o_str.h ├── o_time.c ├── o_time.h ├── objects │ ├── o_names.c │ ├── obj_dat.c │ ├── obj_dat.h │ ├── obj_dat.pl │ ├── obj_err.c │ ├── obj_lib.c │ ├── obj_mac.h │ ├── obj_mac.num │ ├── obj_xref.c │ ├── obj_xref.h │ ├── obj_xref.txt │ ├── objects.README │ ├── objects.h │ ├── objects.pl │ ├── objects.txt │ └── objxref.pl ├── ocsp │ ├── ocsp.h │ ├── ocsp_asn.c │ ├── ocsp_cl.c │ ├── ocsp_err.c │ ├── ocsp_ext.c │ ├── ocsp_ht.c │ ├── ocsp_lib.c │ ├── ocsp_prn.c │ ├── ocsp_srv.c │ └── ocsp_vfy.c ├── opensslconf-32.h ├── opensslconf-64.h ├── pem │ ├── message │ ├── pem.h │ ├── pem2.h │ ├── pem_all.c │ ├── pem_err.c │ ├── pem_info.c │ ├── pem_lib.c │ ├── pem_oth.c │ ├── pem_pk8.c │ ├── pem_pkey.c │ ├── pem_seal.c │ ├── pem_sign.c │ ├── pem_x509.c │ ├── pem_xaux.c │ ├── pkcs7.lis │ └── pvkfmt.c ├── pkcs12 │ ├── p12_add.c │ ├── p12_asn.c │ ├── p12_attr.c │ ├── p12_crpt.c │ ├── p12_crt.c │ ├── p12_decr.c │ ├── p12_init.c │ ├── p12_key.c │ ├── p12_kiss.c │ ├── p12_mutl.c │ ├── p12_npas.c │ ├── p12_p8d.c │ ├── p12_p8e.c │ ├── p12_utl.c │ ├── pk12err.c │ └── pkcs12.h ├── pkcs7 │ ├── pk7_asn1.c │ ├── pk7_attr.c │ ├── pk7_dgst.c │ ├── pk7_doit.c │ ├── pk7_enc.c │ ├── pk7_lib.c │ ├── pk7_mime.c │ ├── pk7_smime.c │ ├── pkcs7.h │ └── pkcs7err.c ├── pqueue │ ├── pq_test.c │ ├── pqueue.c │ └── pqueue.h ├── rand │ ├── md_rand.c │ ├── rand.h │ ├── rand_egd.c │ ├── rand_err.c │ ├── rand_lcl.h │ ├── rand_lib.c │ ├── rand_nw.c │ ├── rand_os2.c │ ├── rand_unix.c │ ├── rand_win.c │ ├── randfile.c │ └── randtest.c ├── rc2 │ ├── rc2.h │ ├── rc2_cbc.c │ ├── rc2_ecb.c │ ├── rc2_locl.h │ ├── rc2_skey.c │ ├── rc2cfb64.c │ ├── rc2ofb64.c │ ├── rc2speed.c │ ├── rc2test.c │ ├── rrc2.doc │ ├── tab.c │ └── version ├── rc4 │ ├── asm │ │ ├── rc4-586.pl │ │ ├── rc4-ia64.pl │ │ ├── rc4-md5-x86_64.S │ │ ├── rc4-md5-x86_64.pl │ │ ├── rc4-parisc.pl │ │ ├── rc4-s390x.pl │ │ ├── rc4-x86_64.S │ │ └── rc4-x86_64.pl │ ├── rc4.c │ ├── rc4.h │ ├── rc4_enc.c │ ├── rc4_locl.h │ ├── rc4_skey.c │ ├── rc4_utl.c │ ├── rc4s.cpp │ ├── rc4speed.c │ ├── rc4test.c │ └── rrc4.doc ├── rsa │ ├── rsa.h │ ├── rsa_ameth.c │ ├── rsa_asn1.c │ ├── rsa_chk.c │ ├── rsa_crpt.c │ ├── rsa_depr.c │ ├── rsa_eay.c │ ├── rsa_err.c │ ├── rsa_gen.c │ ├── rsa_lib.c │ ├── rsa_locl.h │ ├── rsa_none.c │ ├── rsa_null.c │ ├── rsa_oaep.c │ ├── rsa_pk1.c │ ├── rsa_pmeth.c │ ├── rsa_prn.c │ ├── rsa_pss.c │ ├── rsa_saos.c │ ├── rsa_sign.c │ ├── rsa_ssl.c │ ├── rsa_test.c │ └── rsa_x931.c ├── sha │ ├── asm │ │ ├── README │ │ ├── sha1-586.S │ │ ├── sha1-586.pl │ │ ├── sha1-alpha.pl │ │ ├── sha1-armv4-large.S │ │ ├── sha1-armv4-large.pl │ │ ├── sha1-armv8.S │ │ ├── sha1-armv8.pl │ │ ├── sha1-ia64.pl │ │ ├── sha1-mips.S │ │ ├── sha1-mips.pl │ │ ├── sha1-parisc.pl │ │ ├── sha1-ppc.pl │ │ ├── sha1-s390x.pl │ │ ├── sha1-sparcv9.pl │ │ ├── sha1-sparcv9a.pl │ │ ├── sha1-thumb.pl │ │ ├── sha1-x86_64.S │ │ ├── sha1-x86_64.pl │ │ ├── sha256-586.S │ │ ├── sha256-586.pl │ │ ├── sha256-armv4.S │ │ ├── sha256-armv4.pl │ │ ├── sha256-armv8.S │ │ ├── sha256-mips.S │ │ ├── sha256-x86_64.S │ │ ├── sha512-586.S │ │ ├── sha512-586.pl │ │ ├── sha512-armv4.S │ │ ├── sha512-armv4.pl │ │ ├── sha512-armv8.S │ │ ├── sha512-armv8.pl │ │ ├── sha512-ia64.pl │ │ ├── sha512-mips.pl │ │ ├── sha512-parisc.pl │ │ ├── sha512-ppc.pl │ │ ├── sha512-s390x.pl │ │ ├── sha512-sparcv9.pl │ │ ├── sha512-x86_64.S │ │ └── sha512-x86_64.pl │ ├── sha.c │ ├── sha.h │ ├── sha1.c │ ├── sha1_one.c │ ├── sha1dgst.c │ ├── sha1test.c │ ├── sha256.c │ ├── sha256t.c │ ├── sha512.c │ ├── sha512t.c │ ├── sha_dgst.c │ ├── sha_locl.h │ └── shatest.c ├── srp │ ├── srp.h │ ├── srp_grps.h │ ├── srp_lcl.h │ ├── srp_lib.c │ └── srp_vfy.c ├── stack │ ├── safestack.h │ ├── stack.c │ └── stack.h ├── ts │ └── ts_err.c ├── txt_db │ ├── txt_db.c │ └── txt_db.h ├── ui │ ├── ui.h │ ├── ui_compat.c │ ├── ui_compat.h │ ├── ui_err.c │ ├── ui_lib.c │ ├── ui_locl.h │ ├── ui_openssl.c │ └── ui_util.c ├── uid.c ├── x509 │ ├── by_dir.c │ ├── by_file.c │ ├── x509.h │ ├── x509_att.c │ ├── x509_cmp.c │ ├── x509_d2.c │ ├── x509_def.c │ ├── x509_err.c │ ├── x509_ext.c │ ├── x509_lu.c │ ├── x509_obj.c │ ├── x509_r2x.c │ ├── x509_req.c │ ├── x509_set.c │ ├── x509_trs.c │ ├── x509_txt.c │ ├── x509_v3.c │ ├── x509_vfy.c │ ├── x509_vfy.h │ ├── x509_vpm.c │ ├── x509cset.c │ ├── x509name.c │ ├── x509rset.c │ ├── x509spki.c │ ├── x509type.c │ └── x_all.c ├── x509v3 │ ├── ext_dat.h │ ├── pcy_cache.c │ ├── pcy_data.c │ ├── pcy_int.h │ ├── pcy_lib.c │ ├── pcy_map.c │ ├── pcy_node.c │ ├── pcy_tree.c │ ├── tabtest.c │ ├── v3_addr.c │ ├── v3_akey.c │ ├── v3_akeya.c │ ├── v3_alt.c │ ├── v3_asid.c │ ├── v3_bcons.c │ ├── v3_bitst.c │ ├── v3_conf.c │ ├── v3_cpols.c │ ├── v3_crld.c │ ├── v3_enum.c │ ├── v3_extku.c │ ├── v3_genn.c │ ├── v3_ia5.c │ ├── v3_info.c │ ├── v3_int.c │ ├── v3_lib.c │ ├── v3_ncons.c │ ├── v3_ocsp.c │ ├── v3_pci.c │ ├── v3_pcia.c │ ├── v3_pcons.c │ ├── v3_pku.c │ ├── v3_pmaps.c │ ├── v3_prn.c │ ├── v3_purp.c │ ├── v3_skey.c │ ├── v3_sxnet.c │ ├── v3_utl.c │ ├── v3conf.c │ ├── v3err.c │ ├── v3prin.c │ └── x509v3.h ├── x86_64cpuid.S └── x86cpuid.S ├── e_os.h ├── include └── openssl │ ├── aes.h │ ├── asn1.h │ ├── asn1_mac.h │ ├── asn1t.h │ ├── bio.h │ ├── blowfish.h │ ├── bn.h │ ├── buffer.h │ ├── cmac.h │ ├── cms.h │ ├── comp.h │ ├── conf.h │ ├── conf_api.h │ ├── crypto.h │ ├── des.h │ ├── des_old.h │ ├── dh.h │ ├── dsa.h │ ├── dso.h │ ├── dtls1.h │ ├── e_os2.h │ ├── ec.h │ ├── ecdh.h │ ├── ecdsa.h │ ├── engine.h │ ├── err.h │ ├── evp.h │ ├── hmac.h │ ├── krb5_asn.h │ ├── kssl.h │ ├── lhash.h │ ├── md4.h │ ├── md5.h │ ├── modes.h │ ├── obj_mac.h │ ├── objects.h │ ├── ocsp.h │ ├── opensslconf.h │ ├── opensslv.h │ ├── ossl_typ.h │ ├── pem.h │ ├── pem2.h │ ├── pkcs12.h │ ├── pkcs7.h │ ├── pqueue.h │ ├── rand.h │ ├── rc2.h │ ├── rc4.h │ ├── rsa.h │ ├── safestack.h │ ├── sha.h │ ├── srp.h │ ├── srtp.h │ ├── ssl.h │ ├── ssl2.h │ ├── ssl23.h │ ├── ssl3.h │ ├── stack.h │ ├── symhacks.h │ ├── tls1.h │ ├── ts.h │ ├── txt_db.h │ ├── ui.h │ ├── ui_compat.h │ ├── x509.h │ ├── x509_vfy.h │ └── x509v3.h ├── openssl.version └── ssl ├── bio_ssl.c ├── d1_both.c ├── d1_enc.c ├── d1_lib.c ├── d1_pkt.c ├── d1_srtp.c ├── kssl.c ├── kssl_lcl.h ├── s23_clnt.c ├── s23_lib.c ├── s23_meth.c ├── s23_pkt.c ├── s23_srvr.c ├── s2_clnt.c ├── s2_enc.c ├── s2_lib.c ├── s2_meth.c ├── s2_pkt.c ├── s2_srvr.c ├── s3_both.c ├── s3_cbc.c ├── s3_clnt.c ├── s3_enc.c ├── s3_lib.c ├── s3_meth.c ├── s3_pkt.c ├── s3_srvr.c ├── srtp.h ├── ssl_algs.c ├── ssl_asn1.c ├── ssl_cert.c ├── ssl_ciph.c ├── ssl_err.c ├── ssl_err2.c ├── ssl_lib.c ├── ssl_locl.h ├── ssl_rsa.c ├── ssl_sess.c ├── ssl_stat.c ├── ssl_txt.c ├── t1_clnt.c ├── t1_enc.c ├── t1_lib.c ├── t1_meth.c ├── t1_reneg.c ├── t1_srvr.c └── tls_srp.c /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: osm0sis # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: https://www.paypal.me/osm0sis # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | obj/ 3 | -------------------------------------------------------------------------------- /Android_crypto.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # Enable to be able to use ALOG* with #include "cutils/log.h" 4 | #log_c_includes += system/core/include 5 | #log_shared_libraries := liblog 6 | 7 | # These makefiles are here instead of being Android.mk files in the 8 | # respective crypto, ssl, and apps directories so 9 | # that import_openssl.sh import won't remove them. 10 | include $(LOCAL_PATH)/build-config-64.mk 11 | include $(LOCAL_PATH)/build-config-32.mk 12 | include $(LOCAL_PATH)/Crypto.mk 13 | -------------------------------------------------------------------------------- /Android_ssl.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # Enable to be able to use ALOG* with #include "cutils/log.h" 4 | #log_c_includes += system/core/include 5 | #log_shared_libraries := liblog 6 | 7 | # These makefiles are here instead of being Android.mk files in the 8 | # respective crypto, ssl, and apps directories so 9 | # that import_openssl.sh import won't remove them. 10 | include $(LOCAL_PATH)/build-config-64.mk 11 | include $(LOCAL_PATH)/build-config-32.mk 12 | include $(LOCAL_PATH)/Ssl.mk 13 | -------------------------------------------------------------------------------- /Crypto.mk: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # target static library 3 | include $(CLEAR_VARS) 4 | LOCAL_SHARED_LIBRARIES := $(log_shared_libraries) 5 | LOCAL_C_INCLUDES := $(log_c_includes) 6 | 7 | # The static library should be used in only unbundled apps 8 | # and we don't have clang in unbundled build yet. 9 | LOCAL_SDK_VERSION := 9 10 | 11 | LOCAL_MODULE_TAGS := optional 12 | LOCAL_MODULE := libcrypto_static 13 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/android-config.mk $(LOCAL_PATH)/Crypto.mk 14 | include $(LOCAL_PATH)/Crypto-config-target.mk 15 | include $(LOCAL_PATH)/android-config.mk 16 | 17 | # Replace cflags with static-specific cflags so we dont build in libdl deps 18 | LOCAL_CFLAGS_32 := $(openssl_cflags_static_32) 19 | LOCAL_CFLAGS_64 := $(openssl_cflags_static_64) 20 | 21 | LOCAL_SRC_FILES := $(LOCAL_SRC_FILES_$(TARGET_ARCH)) 22 | LOCAL_CFLAGS := $(LOCAL_CFLAGS_$(TARGET_2ND_ARCH)) $(LOCAL_CFLAGS_$(TARGET_ARCH)) 23 | LOCAL_C_INCLUDES += \ 24 | $(LOCAL_PATH)/crypto \ 25 | $(LOCAL_PATH)/crypto/asn1 \ 26 | $(LOCAL_PATH)/crypto/evp \ 27 | $(LOCAL_PATH)/crypto/modes \ 28 | $(LOCAL_PATH)/include 29 | include $(BUILD_STATIC_LIBRARY) 30 | 31 | -------------------------------------------------------------------------------- /Ssl.mk: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # target static library 3 | include $(CLEAR_VARS) 4 | LOCAL_SHARED_LIBRARIES := $(log_shared_libraries) 5 | LOCAL_C_INCLUDES := $(log_c_includes) 6 | 7 | # The static library should be used in only unbundled apps 8 | # and we don't have clang in unbundled build yet. 9 | LOCAL_SDK_VERSION := 9 10 | 11 | LOCAL_MODULE_TAGS := optional 12 | LOCAL_MODULE := libssl_static 13 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/android-config.mk $(LOCAL_PATH)/Ssl.mk 14 | include $(LOCAL_PATH)/Ssl-config-target.mk 15 | include $(LOCAL_PATH)/android-config.mk 16 | 17 | LOCAL_SRC_FILES += $(LOCAL_SRC_FILES_$(TARGET_ARCH)) 18 | LOCAL_CFLAGS += $(LOCAL_CFLAGS_$(TARGET_2ND_ARCH)) $(LOCAL_CFLAGS_$(TARGET_ARCH)) 19 | LOCAL_C_INCLUDES += \ 20 | $(LOCAL_PATH)/crypto \ 21 | $(LOCAL_PATH)/include 22 | include $(BUILD_STATIC_LIBRARY) 23 | -------------------------------------------------------------------------------- /android-config.mk: -------------------------------------------------------------------------------- 1 | # 2 | # These flags represent the build-time configuration of OpenSSL for android 3 | # 4 | # The value of $(openssl_cflags) was pruned from the Makefile generated 5 | # by running ./Configure from import_openssl.sh. 6 | # 7 | # This script performs minor but required patching for the Android build. 8 | # 9 | 10 | # Directories for ENGINE shared libraries 11 | openssl_cflags_32 += \ 12 | -DOPENSSLDIR="\"/system/lib/ssl\"" \ 13 | -DENGINESDIR="\"/system/lib/ssl/engines\"" 14 | openssl_cflags_static_32 += \ 15 | -DOPENSSLDIR="\"/system/lib/ssl\"" \ 16 | -DENGINESDIR="\"/system/lib/ssl/engines\"" 17 | openssl_cflags_64 += \ 18 | -DOPENSSLDIR="\"/system/lib64/ssl\"" \ 19 | -DENGINESDIR="\"/system/lib64/ssl/engines\"" 20 | openssl_cflags_static_64 += \ 21 | -DOPENSSLDIR="\"/system/lib64/ssl\"" \ 22 | -DENGINESDIR="\"/system/lib64/ssl/engines\"" 23 | 24 | # Intentionally excluded http://b/7079965 25 | ifneq (,$(filter -DZLIB, $(openssl_cflags_32) $(openssl_cflags_64) \ 26 | $(openssl_cflags_static_32) $(openssl_cflags_static_64))) 27 | $(error ZLIB should not be enabled in openssl configuration) 28 | endif 29 | 30 | LOCAL_CFLAGS_32 += $(openssl_cflags_32) 31 | LOCAL_CFLAGS_64 += $(openssl_cflags_64) 32 | 33 | LOCAL_CFLAGS_32 := $(filter-out -DTERMIO, $(LOCAL_CFLAGS_32)) 34 | LOCAL_CFLAGS_64 := $(filter-out -DTERMIO, $(LOCAL_CFLAGS_64)) 35 | # filter out static flags too 36 | openssl_cflags_static_32 := $(filter-out -DTERMIO, $(openssl_cflags_static_32)) 37 | openssl_cflags_static_64 := $(filter-out -DTERMIO, $(openssl_cflags_static_64)) 38 | 39 | ifeq ($(HOST_OS),windows) 40 | LOCAL_CFLAGS_32 := $(filter-out -DDSO_DLFCN -DHAVE_DLFCN_H,$(LOCAL_CFLAGS_32)) 41 | LOCAL_CFLAGS_64 := $(filter-out -DDSO_DLFCN -DHAVE_DLFCN_H,$(LOCAL_CFLAGS_64)) 42 | endif 43 | 44 | LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-parameter 45 | 46 | # Debug 47 | # LOCAL_CFLAGS += -DCIPHER_DEBUG 48 | 49 | # Add clang here when it works on host 50 | # LOCAL_CLANG := true 51 | -------------------------------------------------------------------------------- /build-config-32.mk: -------------------------------------------------------------------------------- 1 | # Auto-generated - DO NOT EDIT! 2 | # To regenerate, edit openssl.config, then run: 3 | # ./import_openssl.sh import /path/to/openssl-1.0.1l.tar.gz 4 | # 5 | openssl_cflags_32 := \ 6 | -DOPENSSL_THREADS \ 7 | -D_REENTRANT \ 8 | -DDSO_DLFCN \ 9 | -DHAVE_DLFCN_H \ 10 | -DL_ENDIAN \ 11 | -DTERMIO \ 12 | -DOPENSSL_NO_CAMELLIA \ 13 | -DOPENSSL_NO_CAPIENG \ 14 | -DOPENSSL_NO_CAST \ 15 | -DOPENSSL_NO_DTLS1 \ 16 | -DOPENSSL_NO_EC_NISTP_64_GCC_128 \ 17 | -DOPENSSL_NO_GMP \ 18 | -DOPENSSL_NO_GOST \ 19 | -DOPENSSL_NO_HEARTBEATS \ 20 | -DOPENSSL_NO_IDEA \ 21 | -DOPENSSL_NO_JPAKE \ 22 | -DOPENSSL_NO_MD2 \ 23 | -DOPENSSL_NO_MDC2 \ 24 | -DOPENSSL_NO_RC5 \ 25 | -DOPENSSL_NO_RDRAND \ 26 | -DOPENSSL_NO_RFC3779 \ 27 | -DOPENSSL_NO_RIPEMD \ 28 | -DOPENSSL_NO_RSAX \ 29 | -DOPENSSL_NO_SCTP \ 30 | -DOPENSSL_NO_SEED \ 31 | -DOPENSSL_NO_SHA0 \ 32 | -DOPENSSL_NO_STATIC_ENGINE \ 33 | -DOPENSSL_NO_STORE \ 34 | -DOPENSSL_NO_UNIT_TEST \ 35 | -DOPENSSL_NO_WHIRLPOOL \ 36 | 37 | openssl_cflags_static_32 := \ 38 | -DOPENSSL_THREADS \ 39 | -D_REENTRANT \ 40 | -DL_ENDIAN \ 41 | -DTERMIO \ 42 | -DOPENSSL_NO_CAMELLIA \ 43 | -DOPENSSL_NO_CAPIENG \ 44 | -DOPENSSL_NO_CAST \ 45 | -DOPENSSL_NO_DTLS1 \ 46 | -DOPENSSL_NO_EC_NISTP_64_GCC_128 \ 47 | -DOPENSSL_NO_GMP \ 48 | -DOPENSSL_NO_GOST \ 49 | -DOPENSSL_NO_HEARTBEATS \ 50 | -DOPENSSL_NO_IDEA \ 51 | -DOPENSSL_NO_JPAKE \ 52 | -DOPENSSL_NO_MD2 \ 53 | -DOPENSSL_NO_MDC2 \ 54 | -DOPENSSL_NO_RC5 \ 55 | -DOPENSSL_NO_RDRAND \ 56 | -DOPENSSL_NO_RFC3779 \ 57 | -DOPENSSL_NO_RIPEMD \ 58 | -DOPENSSL_NO_RSAX \ 59 | -DOPENSSL_NO_SCTP \ 60 | -DOPENSSL_NO_SEED \ 61 | -DOPENSSL_NO_SHA0 \ 62 | -DOPENSSL_NO_STATIC_ENGINE \ 63 | -DOPENSSL_NO_STORE \ 64 | -DOPENSSL_NO_UNIT_TEST \ 65 | -DOPENSSL_NO_WHIRLPOOL \ 66 | 67 | -------------------------------------------------------------------------------- /build-config-64.mk: -------------------------------------------------------------------------------- 1 | # Auto-generated - DO NOT EDIT! 2 | # To regenerate, edit openssl.config, then run: 3 | # ./import_openssl.sh import /path/to/openssl-1.0.1l.tar.gz 4 | # 5 | openssl_cflags_64 := \ 6 | -DOPENSSL_THREADS \ 7 | -D_REENTRANT \ 8 | -DDSO_DLFCN \ 9 | -DHAVE_DLFCN_H \ 10 | -DL_ENDIAN \ 11 | -DTERMIO \ 12 | -DOPENSSL_NO_CAMELLIA \ 13 | -DOPENSSL_NO_CAPIENG \ 14 | -DOPENSSL_NO_CAST \ 15 | -DOPENSSL_NO_DTLS1 \ 16 | -DOPENSSL_NO_EC_NISTP_64_GCC_128 \ 17 | -DOPENSSL_NO_GMP \ 18 | -DOPENSSL_NO_GOST \ 19 | -DOPENSSL_NO_HEARTBEATS \ 20 | -DOPENSSL_NO_IDEA \ 21 | -DOPENSSL_NO_JPAKE \ 22 | -DOPENSSL_NO_MD2 \ 23 | -DOPENSSL_NO_MDC2 \ 24 | -DOPENSSL_NO_RC5 \ 25 | -DOPENSSL_NO_RDRAND \ 26 | -DOPENSSL_NO_RFC3779 \ 27 | -DOPENSSL_NO_RIPEMD \ 28 | -DOPENSSL_NO_RSAX \ 29 | -DOPENSSL_NO_SCTP \ 30 | -DOPENSSL_NO_SEED \ 31 | -DOPENSSL_NO_SHA0 \ 32 | -DOPENSSL_NO_STATIC_ENGINE \ 33 | -DOPENSSL_NO_STORE \ 34 | -DOPENSSL_NO_UNIT_TEST \ 35 | -DOPENSSL_NO_WHIRLPOOL \ 36 | 37 | openssl_cflags_static_64 := \ 38 | -DOPENSSL_THREADS \ 39 | -D_REENTRANT \ 40 | -DL_ENDIAN \ 41 | -DTERMIO \ 42 | -DOPENSSL_NO_CAMELLIA \ 43 | -DOPENSSL_NO_CAPIENG \ 44 | -DOPENSSL_NO_CAST \ 45 | -DOPENSSL_NO_DTLS1 \ 46 | -DOPENSSL_NO_EC_NISTP_64_GCC_128 \ 47 | -DOPENSSL_NO_GMP \ 48 | -DOPENSSL_NO_GOST \ 49 | -DOPENSSL_NO_HEARTBEATS \ 50 | -DOPENSSL_NO_IDEA \ 51 | -DOPENSSL_NO_JPAKE \ 52 | -DOPENSSL_NO_MD2 \ 53 | -DOPENSSL_NO_MDC2 \ 54 | -DOPENSSL_NO_RC5 \ 55 | -DOPENSSL_NO_RDRAND \ 56 | -DOPENSSL_NO_RFC3779 \ 57 | -DOPENSSL_NO_RIPEMD \ 58 | -DOPENSSL_NO_RSAX \ 59 | -DOPENSSL_NO_SCTP \ 60 | -DOPENSSL_NO_SEED \ 61 | -DOPENSSL_NO_SHA0 \ 62 | -DOPENSSL_NO_STATIC_ENGINE \ 63 | -DOPENSSL_NO_STORE \ 64 | -DOPENSSL_NO_UNIT_TEST \ 65 | -DOPENSSL_NO_WHIRLPOOL \ 66 | 67 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case "$(uname -s)" in 4 | CYGWIN*|MINGW32*|MSYS*) ext=.cmd; 5 | esac; 6 | 7 | case $1 in 8 | clean) 9 | rm -rf obj; 10 | exit 0; 11 | ;; 12 | esac; 13 | 14 | if [ ! "$NDK_ROOT" ]; then 15 | NDK_ROOT=$(echo ~/android/android-ndk-r* | cut -d\ -f1); 16 | fi; 17 | 18 | for TARGET_ARCH in arm arm64 x86 x86_64 mips mips64; do 19 | APP_ABI=$TARGET_ARCH; 20 | case $TARGET_ARCH in 21 | arm) NDK_TOOLCHAIN=arm-linux-androideabi-4.9; APP_ABI=armeabi;; 22 | arm64) NDK_TOOLCHAIN=aarch64-linux-android-4.9; APP_ABI=arm64-v8a;; 23 | x86) NDK_TOOLCHAIN=x86-4.9;; 24 | x86_64) NDK_TOOLCHAIN=x86_64-4.9;; 25 | mips) NDK_TOOLCHAIN=mipsel-linux-android-4.9;; 26 | mips64) NDK_TOOLCHAIN=mips64el-linux-android-4.9;; 27 | esac; 28 | case $TARGET_ARCH in 29 | *64) TARGET_2ND_ARCH=64; APP_PLATFORM=android-21;; 30 | *) TARGET_2ND_ARCH=32; APP_PLATFORM=android-14;; 31 | esac; 32 | for out in crypto ssl; do 33 | TARGET_ARCH=$TARGET_ARCH TARGET_2ND_ARCH=$TARGET_2ND_ARCH $NDK_ROOT/ndk-build$ext NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android_$out.mk NDK_TOOLCHAIN=$NDK_TOOLCHAIN APP_ABI=$APP_ABI APP_PLATFORM=$APP_PLATFORM APP_STL=gnustl_static; 34 | done; 35 | done; 36 | 37 | for i in obj/local/*/*.a; do 38 | ln -rs $i ${i/_static/}; 39 | done; 40 | 41 | exit 0; 42 | 43 | -------------------------------------------------------------------------------- /buildinf.h: -------------------------------------------------------------------------------- 1 | /* crypto/Makefile usually creates the file at build time. Since we don't care 2 | * about the build timestamp we fill in placeholder values. */ 3 | #ifndef MK1MF_BUILD 4 | #define CFLAGS "-C flags not included-" 5 | #define PLATFORM "google" 6 | #define DATE "Sun Jan 1 00:00:00 GMT 1970" 7 | #endif 8 | -------------------------------------------------------------------------------- /crypto/aes/README: -------------------------------------------------------------------------------- 1 | This is an OpenSSL-compatible version of AES (also called Rijndael). 2 | aes_core.c is basically the same as rijndael-alg-fst.c but with an 3 | API that looks like the rest of the OpenSSL symmetric cipher suite. 4 | -------------------------------------------------------------------------------- /crypto/aes/aes_cbc.c: -------------------------------------------------------------------------------- 1 | /* crypto/aes/aes_cbc.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | */ 51 | 52 | #include 53 | #include 54 | 55 | void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, 56 | size_t len, const AES_KEY *key, 57 | unsigned char *ivec, const int enc) { 58 | 59 | if (enc) 60 | CRYPTO_cbc128_encrypt(in,out,len,key,ivec,(block128_f)AES_encrypt); 61 | else 62 | CRYPTO_cbc128_decrypt(in,out,len,key,ivec,(block128_f)AES_decrypt); 63 | } 64 | -------------------------------------------------------------------------------- /crypto/aes/aes_ctr.c: -------------------------------------------------------------------------------- 1 | /* crypto/aes/aes_ctr.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | */ 51 | 52 | #include 53 | #include 54 | 55 | void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 56 | size_t length, const AES_KEY *key, 57 | unsigned char ivec[AES_BLOCK_SIZE], 58 | unsigned char ecount_buf[AES_BLOCK_SIZE], 59 | unsigned int *num) { 60 | CRYPTO_ctr128_encrypt(in,out,length,key,ivec,ecount_buf,num,(block128_f)AES_encrypt); 61 | } 62 | -------------------------------------------------------------------------------- /crypto/aes/aes_ecb.c: -------------------------------------------------------------------------------- 1 | /* crypto/aes/aes_ecb.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | */ 51 | 52 | #ifndef AES_DEBUG 53 | # ifndef NDEBUG 54 | # define NDEBUG 55 | # endif 56 | #endif 57 | #include 58 | 59 | #include 60 | #include "aes_locl.h" 61 | 62 | void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, 63 | const AES_KEY *key, const int enc) { 64 | 65 | assert(in && out && key); 66 | assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc)); 67 | 68 | if (AES_ENCRYPT == enc) 69 | AES_encrypt(in, out, key); 70 | else 71 | AES_decrypt(in, out, key); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /crypto/aes/aes_ofb.c: -------------------------------------------------------------------------------- 1 | /* crypto/aes/aes_ofb.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | */ 51 | 52 | #include 53 | #include 54 | 55 | void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, 56 | size_t length, const AES_KEY *key, 57 | unsigned char *ivec, int *num) 58 | { 59 | CRYPTO_ofb128_encrypt(in,out,length,key,ivec,num,(block128_f)AES_encrypt); 60 | } 61 | -------------------------------------------------------------------------------- /crypto/arm64cpuid.S: -------------------------------------------------------------------------------- 1 | #include "arm_arch.h" 2 | 3 | .text 4 | .arch armv8-a+crypto 5 | 6 | .align 5 7 | .global _armv7_neon_probe 8 | .type _armv7_neon_probe,%function 9 | _armv7_neon_probe: 10 | orr v15.16b, v15.16b, v15.16b 11 | ret 12 | .size _armv7_neon_probe,.-_armv7_neon_probe 13 | 14 | .global _armv7_tick 15 | .type _armv7_tick,%function 16 | _armv7_tick: 17 | mrs x0, CNTVCT_EL0 18 | ret 19 | .size _armv7_tick,.-_armv7_tick 20 | 21 | .global _armv8_aes_probe 22 | .type _armv8_aes_probe,%function 23 | _armv8_aes_probe: 24 | aese v0.16b, v0.16b 25 | ret 26 | .size _armv8_aes_probe,.-_armv8_aes_probe 27 | 28 | .global _armv8_sha1_probe 29 | .type _armv8_sha1_probe,%function 30 | _armv8_sha1_probe: 31 | sha1h s0, s0 32 | ret 33 | .size _armv8_sha1_probe,.-_armv8_sha1_probe 34 | 35 | .global _armv8_sha256_probe 36 | .type _armv8_sha256_probe,%function 37 | _armv8_sha256_probe: 38 | sha256su0 v0.4s, v0.4s 39 | ret 40 | .size _armv8_sha256_probe,.-_armv8_sha256_probe 41 | .global _armv8_pmull_probe 42 | .type _armv8_pmull_probe,%function 43 | _armv8_pmull_probe: 44 | pmull v0.1q, v0.1d, v0.1d 45 | ret 46 | .size _armv8_pmull_probe,.-_armv8_pmull_probe 47 | -------------------------------------------------------------------------------- /crypto/arm_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARM_ARCH_H__ 2 | #define __ARM_ARCH_H__ 3 | 4 | #if !defined(__ARM_ARCH__) 5 | # if defined(__CC_ARM) 6 | # define __ARM_ARCH__ __TARGET_ARCH_ARM 7 | # if defined(__BIG_ENDIAN) 8 | # define __ARMEB__ 9 | # else 10 | # define __ARMEL__ 11 | # endif 12 | # elif defined(__GNUC__) 13 | # if defined(__aarch64__) 14 | # define __ARM_ARCH__ 8 15 | # if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ 16 | # define __ARMEB__ 17 | # else 18 | # define __ARMEL__ 19 | # endif 20 | /* 21 | * Why doesn't gcc define __ARM_ARCH__? Instead it defines 22 | * bunch of below macros. See all_architectires[] table in 23 | * gcc/config/arm/arm.c. On a side note it defines 24 | * __ARMEL__/__ARMEB__ for little-/big-endian. 25 | */ 26 | # elif defined(__ARM_ARCH) 27 | # define __ARM_ARCH__ __ARM_ARCH 28 | # elif defined(__ARM_ARCH_8A__) 29 | # define __ARM_ARCH__ 8 30 | # elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ 31 | defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \ 32 | defined(__ARM_ARCH_7EM__) 33 | # define __ARM_ARCH__ 7 34 | # elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \ 35 | defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \ 36 | defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \ 37 | defined(__ARM_ARCH_6T2__) 38 | # define __ARM_ARCH__ 6 39 | # elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \ 40 | defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \ 41 | defined(__ARM_ARCH_5TEJ__) 42 | # define __ARM_ARCH__ 5 43 | # elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) 44 | # define __ARM_ARCH__ 4 45 | # else 46 | # error "unsupported ARM architecture" 47 | # endif 48 | # endif 49 | #endif 50 | 51 | #ifdef OPENSSL_FIPSCANISTER 52 | #include 53 | #endif 54 | 55 | #if !__ASSEMBLER__ 56 | extern unsigned int OPENSSL_armcap_P; 57 | #endif 58 | 59 | #define ARMV7_NEON (1<<0) 60 | #define ARMV7_TICK (1<<1) 61 | #define ARMV8_AES (1<<2) 62 | #define ARMV8_SHA1 (1<<3) 63 | #define ARMV8_SHA256 (1<<4) 64 | #define ARMV8_PMULL (1<<5) 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /crypto/asn1/charmap.h: -------------------------------------------------------------------------------- 1 | /* Auto generated with chartype.pl script. 2 | * Mask of various character properties 3 | */ 4 | 5 | static const unsigned char char_type[] = { 6 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 8 | 120, 0, 1,40, 0, 0, 0,16,16,16, 0,25,25,16,16,16, 9 | 16,16,16,16,16,16,16,16,16,16,16, 9, 9,16, 9,16, 10 | 0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 11 | 16,16,16,16,16,16,16,16,16,16,16, 0, 1, 0, 0, 0, 12 | 0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 13 | 16,16,16,16,16,16,16,16,16,16,16, 0, 0, 0, 0, 2 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /crypto/asn1/charmap.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl -w 2 | 3 | # Written by Dr Stephen N Henson (steve@openssl.org). 4 | # Licensed under the terms of the OpenSSL license. 5 | 6 | use strict; 7 | 8 | my ($i, @arr); 9 | 10 | # Set up an array with the type of ASCII characters 11 | # Each set bit represents a character property. 12 | 13 | # RFC2253 character properties 14 | my $RFC2253_ESC = 1; # Character escaped with \ 15 | my $ESC_CTRL = 2; # Escaped control character 16 | # These are used with RFC1779 quoting using " 17 | my $NOESC_QUOTE = 8; # Not escaped if quoted 18 | my $PSTRING_CHAR = 0x10; # Valid PrintableString character 19 | my $RFC2253_FIRST_ESC = 0x20; # Escaped with \ if first character 20 | my $RFC2253_LAST_ESC = 0x40; # Escaped with \ if last character 21 | 22 | for($i = 0; $i < 128; $i++) { 23 | # Set the RFC2253 escape characters (control) 24 | $arr[$i] = 0; 25 | if(($i < 32) || ($i > 126)) { 26 | $arr[$i] |= $ESC_CTRL; 27 | } 28 | 29 | # Some PrintableString characters 30 | if( ( ( $i >= ord("a")) && ( $i <= ord("z")) ) 31 | || ( ( $i >= ord("A")) && ( $i <= ord("Z")) ) 32 | || ( ( $i >= ord("0")) && ( $i <= ord("9")) ) ) { 33 | $arr[$i] |= $PSTRING_CHAR; 34 | } 35 | } 36 | 37 | # Now setup the rest 38 | 39 | # Remaining RFC2253 escaped characters 40 | 41 | $arr[ord(" ")] |= $NOESC_QUOTE | $RFC2253_FIRST_ESC | $RFC2253_LAST_ESC; 42 | $arr[ord("#")] |= $NOESC_QUOTE | $RFC2253_FIRST_ESC; 43 | 44 | $arr[ord(",")] |= $NOESC_QUOTE | $RFC2253_ESC; 45 | $arr[ord("+")] |= $NOESC_QUOTE | $RFC2253_ESC; 46 | $arr[ord("\"")] |= $RFC2253_ESC; 47 | $arr[ord("\\")] |= $RFC2253_ESC; 48 | $arr[ord("<")] |= $NOESC_QUOTE | $RFC2253_ESC; 49 | $arr[ord(">")] |= $NOESC_QUOTE | $RFC2253_ESC; 50 | $arr[ord(";")] |= $NOESC_QUOTE | $RFC2253_ESC; 51 | 52 | # Remaining PrintableString characters 53 | 54 | $arr[ord(" ")] |= $PSTRING_CHAR; 55 | $arr[ord("'")] |= $PSTRING_CHAR; 56 | $arr[ord("(")] |= $PSTRING_CHAR; 57 | $arr[ord(")")] |= $PSTRING_CHAR; 58 | $arr[ord("+")] |= $PSTRING_CHAR; 59 | $arr[ord(",")] |= $PSTRING_CHAR; 60 | $arr[ord("-")] |= $PSTRING_CHAR; 61 | $arr[ord(".")] |= $PSTRING_CHAR; 62 | $arr[ord("/")] |= $PSTRING_CHAR; 63 | $arr[ord(":")] |= $PSTRING_CHAR; 64 | $arr[ord("=")] |= $PSTRING_CHAR; 65 | $arr[ord("?")] |= $PSTRING_CHAR; 66 | 67 | # Now generate the C code 68 | 69 | print < 60 | #include 61 | #include 62 | #include 63 | 64 | /* Old netscape certificate wrapper format */ 65 | 66 | ASN1_SEQUENCE(NETSCAPE_X509) = { 67 | ASN1_SIMPLE(NETSCAPE_X509, header, ASN1_OCTET_STRING), 68 | ASN1_OPT(NETSCAPE_X509, cert, X509) 69 | } ASN1_SEQUENCE_END(NETSCAPE_X509) 70 | 71 | IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_X509) 72 | 73 | -------------------------------------------------------------------------------- /crypto/bf/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2 | All rights reserved. 3 | 4 | This package is an Blowfish implementation written 5 | by Eric Young (eay@cryptsoft.com). 6 | 7 | This library is free for commercial and non-commercial use as long as 8 | the following conditions are aheared to. The following conditions 9 | apply to all code found in this distribution. 10 | 11 | Copyright remains Eric Young's, and as such any Copyright notices in 12 | the code are not to be removed. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions 16 | are met: 17 | 1. Redistributions of source code must retain the copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 2. Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | 3. All advertising materials mentioning features or use of this software 23 | must display the following acknowledgement: 24 | This product includes software developed by Eric Young (eay@cryptsoft.com) 25 | 26 | THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 27 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | SUCH DAMAGE. 37 | 38 | The license and distribution terms for any publically available version or 39 | derivative of this code cannot be changed. i.e. this code cannot simply be 40 | copied and put under another distrubution license 41 | [including the GNU Public License.] 42 | 43 | The reason behind this being stated in this direct manner is past 44 | experience in code simply being copied and the attribution removed 45 | from it and then being distributed as part of other packages. This 46 | implementation was a non-trivial and unpaid effort. 47 | -------------------------------------------------------------------------------- /crypto/bf/asm/bf-586.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; 4 | push(@INC,"${dir}","${dir}../../perlasm"); 5 | require "x86asm.pl"; 6 | require "cbc.pl"; 7 | 8 | &asm_init($ARGV[0],"bf-586.pl",$ARGV[$#ARGV] eq "386"); 9 | 10 | $BF_ROUNDS=16; 11 | $BF_OFF=($BF_ROUNDS+2)*4; 12 | $L="edi"; 13 | $R="esi"; 14 | $P="ebp"; 15 | $tmp1="eax"; 16 | $tmp2="ebx"; 17 | $tmp3="ecx"; 18 | $tmp4="edx"; 19 | 20 | &BF_encrypt("BF_encrypt",1); 21 | &BF_encrypt("BF_decrypt",0); 22 | &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1); 23 | &asm_finish(); 24 | 25 | sub BF_encrypt 26 | { 27 | local($name,$enc)=@_; 28 | 29 | &function_begin_B($name,""); 30 | 31 | &comment(""); 32 | 33 | &push("ebp"); 34 | &push("ebx"); 35 | &mov($tmp2,&wparam(0)); 36 | &mov($P,&wparam(1)); 37 | &push("esi"); 38 | &push("edi"); 39 | 40 | &comment("Load the 2 words"); 41 | &mov($L,&DWP(0,$tmp2,"",0)); 42 | &mov($R,&DWP(4,$tmp2,"",0)); 43 | 44 | &xor( $tmp1, $tmp1); 45 | 46 | # encrypting part 47 | 48 | if ($enc) 49 | { 50 | &mov($tmp2,&DWP(0,$P,"",0)); 51 | &xor( $tmp3, $tmp3); 52 | 53 | &xor($L,$tmp2); 54 | for ($i=0; $i<$BF_ROUNDS; $i+=2) 55 | { 56 | &comment(""); 57 | &comment("Round $i"); 58 | &BF_ENCRYPT($i+1,$R,$L,$P,$tmp1,$tmp2,$tmp3,$tmp4,1); 59 | 60 | &comment(""); 61 | &comment("Round ".sprintf("%d",$i+1)); 62 | &BF_ENCRYPT($i+2,$L,$R,$P,$tmp1,$tmp2,$tmp3,$tmp4,1); 63 | } 64 | # &mov($tmp1,&wparam(0)); In last loop 65 | &mov($tmp4,&DWP(($BF_ROUNDS+1)*4,$P,"",0)); 66 | } 67 | else 68 | { 69 | &mov($tmp2,&DWP(($BF_ROUNDS+1)*4,$P,"",0)); 70 | &xor( $tmp3, $tmp3); 71 | 72 | &xor($L,$tmp2); 73 | for ($i=$BF_ROUNDS; $i>0; $i-=2) 74 | { 75 | &comment(""); 76 | &comment("Round $i"); 77 | &BF_ENCRYPT($i,$R,$L,$P,$tmp1,$tmp2,$tmp3,$tmp4,0); 78 | &comment(""); 79 | &comment("Round ".sprintf("%d",$i-1)); 80 | &BF_ENCRYPT($i-1,$L,$R,$P,$tmp1,$tmp2,$tmp3,$tmp4,0); 81 | } 82 | # &mov($tmp1,&wparam(0)); In last loop 83 | &mov($tmp4,&DWP(0,$P,"",0)); 84 | } 85 | 86 | &xor($R,$tmp4); 87 | &mov(&DWP(4,$tmp1,"",0),$L); 88 | 89 | &mov(&DWP(0,$tmp1,"",0),$R); 90 | &function_end($name); 91 | } 92 | 93 | sub BF_ENCRYPT 94 | { 95 | local($i,$L,$R,$P,$tmp1,$tmp2,$tmp3,$tmp4,$enc)=@_; 96 | 97 | &mov( $tmp4, &DWP(&n2a($i*4),$P,"",0)); # for next round 98 | 99 | &mov( $tmp2, $R); 100 | &xor( $L, $tmp4); 101 | 102 | &shr( $tmp2, 16); 103 | &mov( $tmp4, $R); 104 | 105 | &movb( &LB($tmp1), &HB($tmp2)); # A 106 | &and( $tmp2, 0xff); # B 107 | 108 | &movb( &LB($tmp3), &HB($tmp4)); # C 109 | &and( $tmp4, 0xff); # D 110 | 111 | &mov( $tmp1, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4)); 112 | &mov( $tmp2, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4)); 113 | 114 | &add( $tmp2, $tmp1); 115 | &mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp3,4)); 116 | 117 | &xor( $tmp2, $tmp1); 118 | &mov( $tmp4, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp4,4)); 119 | 120 | &add( $tmp2, $tmp4); 121 | if (($enc && ($i != 16)) || ((!$enc) && ($i != 1))) 122 | { &xor( $tmp1, $tmp1); } 123 | else 124 | { 125 | &comment("Load parameter 0 ($i) enc=$enc"); 126 | &mov($tmp1,&wparam(0)); 127 | } # In last loop 128 | 129 | &xor( $L, $tmp2); 130 | # delay 131 | } 132 | 133 | sub n2a 134 | { 135 | sprintf("%d",$_[0]); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /crypto/bf/asm/bf-686.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | push(@INC,"perlasm","../../perlasm"); 4 | require "x86asm.pl"; 5 | require "cbc.pl"; 6 | 7 | &asm_init($ARGV[0],"bf-686.pl"); 8 | 9 | $BF_ROUNDS=16; 10 | $BF_OFF=($BF_ROUNDS+2)*4; 11 | $L="ecx"; 12 | $R="edx"; 13 | $P="edi"; 14 | $tot="esi"; 15 | $tmp1="eax"; 16 | $tmp2="ebx"; 17 | $tmp3="ebp"; 18 | 19 | &des_encrypt("BF_encrypt",1); 20 | &des_encrypt("BF_decrypt",0); 21 | &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1); 22 | 23 | &asm_finish(); 24 | 25 | &file_end(); 26 | 27 | sub des_encrypt 28 | { 29 | local($name,$enc)=@_; 30 | 31 | &function_begin($name,""); 32 | 33 | &comment(""); 34 | &comment("Load the 2 words"); 35 | &mov("eax",&wparam(0)); 36 | &mov($L,&DWP(0,"eax","",0)); 37 | &mov($R,&DWP(4,"eax","",0)); 38 | 39 | &comment(""); 40 | &comment("P pointer, s and enc flag"); 41 | &mov($P,&wparam(1)); 42 | 43 | &xor( $tmp1, $tmp1); 44 | &xor( $tmp2, $tmp2); 45 | 46 | # encrypting part 47 | 48 | if ($enc) 49 | { 50 | &xor($L,&DWP(0,$P,"",0)); 51 | for ($i=0; $i<$BF_ROUNDS; $i+=2) 52 | { 53 | &comment(""); 54 | &comment("Round $i"); 55 | &BF_ENCRYPT($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3); 56 | 57 | &comment(""); 58 | &comment("Round ".sprintf("%d",$i+1)); 59 | &BF_ENCRYPT($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3); 60 | } 61 | &xor($R,&DWP(($BF_ROUNDS+1)*4,$P,"",0)); 62 | 63 | &mov("eax",&wparam(0)); 64 | &mov(&DWP(0,"eax","",0),$R); 65 | &mov(&DWP(4,"eax","",0),$L); 66 | &function_end_A($name); 67 | } 68 | else 69 | { 70 | &xor($L,&DWP(($BF_ROUNDS+1)*4,$P,"",0)); 71 | for ($i=$BF_ROUNDS; $i>0; $i-=2) 72 | { 73 | &comment(""); 74 | &comment("Round $i"); 75 | &BF_ENCRYPT($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3); 76 | &comment(""); 77 | &comment("Round ".sprintf("%d",$i-1)); 78 | &BF_ENCRYPT($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3); 79 | } 80 | &xor($R,&DWP(0,$P,"",0)); 81 | 82 | &mov("eax",&wparam(0)); 83 | &mov(&DWP(0,"eax","",0),$R); 84 | &mov(&DWP(4,"eax","",0),$L); 85 | &function_end_A($name); 86 | } 87 | 88 | &function_end_B($name); 89 | } 90 | 91 | sub BF_ENCRYPT 92 | { 93 | local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_; 94 | 95 | &rotr( $R, 16); 96 | &mov( $tot, &DWP(&n2a($i*4),$P,"",0)); 97 | 98 | &movb( &LB($tmp1), &HB($R)); 99 | &movb( &LB($tmp2), &LB($R)); 100 | 101 | &rotr( $R, 16); 102 | &xor( $L, $tot); 103 | 104 | &mov( $tot, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4)); 105 | &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4)); 106 | 107 | &movb( &LB($tmp1), &HB($R)); 108 | &movb( &LB($tmp2), &LB($R)); 109 | 110 | &add( $tot, $tmp3); 111 | &mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp1,4)); # delay 112 | 113 | &xor( $tot, $tmp1); 114 | &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp2,4)); 115 | 116 | &add( $tot, $tmp3); 117 | &xor( $tmp1, $tmp1); 118 | 119 | &xor( $L, $tot); 120 | # delay 121 | } 122 | 123 | sub n2a 124 | { 125 | sprintf("%d",$_[0]); 126 | } 127 | 128 | -------------------------------------------------------------------------------- /crypto/bio/bio_lcl.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if BIO_FLAGS_UPLINK==0 4 | /* Shortcut UPLINK calls on most platforms... */ 5 | #define UP_stdin stdin 6 | #define UP_stdout stdout 7 | #define UP_stderr stderr 8 | #define UP_fprintf fprintf 9 | #define UP_fgets fgets 10 | #define UP_fread fread 11 | #define UP_fwrite fwrite 12 | #undef UP_fsetmod 13 | #define UP_feof feof 14 | #define UP_fclose fclose 15 | 16 | #define UP_fopen fopen 17 | #define UP_fseek fseek 18 | #define UP_ftell ftell 19 | #define UP_fflush fflush 20 | #define UP_ferror ferror 21 | #ifdef _WIN32 22 | #define UP_fileno _fileno 23 | #define UP_open _open 24 | #define UP_read _read 25 | #define UP_write _write 26 | #define UP_lseek _lseek 27 | #define UP_close _close 28 | #else 29 | #define UP_fileno fileno 30 | #define UP_open open 31 | #define UP_read read 32 | #define UP_write write 33 | #define UP_lseek lseek 34 | #define UP_close close 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /crypto/bn/asm/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | All assember in this directory are just version of the file 4 | crypto/bn/bn_asm.c. 5 | 6 | Quite a few of these files are just the assember output from gcc since on 7 | quite a few machines they are 2 times faster than the system compiler. 8 | 9 | For the x86, I have hand written assember because of the bad job all 10 | compilers seem to do on it. This normally gives a 2 time speed up in the RSA 11 | routines. 12 | 13 | For the DEC alpha, I also hand wrote the assember (except the division which 14 | is just the output from the C compiler pasted on the end of the file). 15 | On the 2 alpha C compilers I had access to, it was not possible to do 16 | 64b x 64b -> 128b calculations (both long and the long long data types 17 | were 64 bits). So the hand assember gives access to the 128 bit result and 18 | a 2 times speedup :-). 19 | 20 | There are 3 versions of assember for the HP PA-RISC. 21 | 22 | pa-risc.s is the origional one which works fine and generated using gcc :-) 23 | 24 | pa-risc2W.s and pa-risc2.s are 64 and 32-bit PA-RISC 2.0 implementations 25 | by Chris Ruemmler from HP (with some help from the HP C compiler). 26 | 27 | 28 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | push(@INC,"perlasm","../../perlasm"); 4 | require "x86asm.pl"; 5 | 6 | require("x86/mul_add.pl"); 7 | require("x86/mul.pl"); 8 | require("x86/sqr.pl"); 9 | require("x86/div.pl"); 10 | require("x86/add.pl"); 11 | require("x86/sub.pl"); 12 | require("x86/comba.pl"); 13 | 14 | &asm_init($ARGV[0],$0); 15 | 16 | &bn_mul_add_words("bn_mul_add_words"); 17 | &bn_mul_words("bn_mul_words"); 18 | &bn_sqr_words("bn_sqr_words"); 19 | &bn_div_words("bn_div_words"); 20 | &bn_add_words("bn_add_words"); 21 | &bn_sub_words("bn_sub_words"); 22 | &bn_mul_comba("bn_mul_comba8",8); 23 | &bn_mul_comba("bn_mul_comba4",4); 24 | &bn_sqr_comba("bn_sqr_comba8",8); 25 | &bn_sqr_comba("bn_sqr_comba4",4); 26 | 27 | &asm_finish(); 28 | 29 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/add.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | sub bn_add_words 5 | { 6 | local($name)=@_; 7 | 8 | &function_begin($name,""); 9 | 10 | &comment(""); 11 | $a="esi"; 12 | $b="edi"; 13 | $c="eax"; 14 | $r="ebx"; 15 | $tmp1="ecx"; 16 | $tmp2="edx"; 17 | $num="ebp"; 18 | 19 | &mov($r,&wparam(0)); # get r 20 | &mov($a,&wparam(1)); # get a 21 | &mov($b,&wparam(2)); # get b 22 | &mov($num,&wparam(3)); # get num 23 | &xor($c,$c); # clear carry 24 | &and($num,0xfffffff8); # num / 8 25 | 26 | &jz(&label("aw_finish")); 27 | 28 | &set_label("aw_loop",0); 29 | for ($i=0; $i<8; $i++) 30 | { 31 | &comment("Round $i"); 32 | 33 | &mov($tmp1,&DWP($i*4,$a,"",0)); # *a 34 | &mov($tmp2,&DWP($i*4,$b,"",0)); # *b 35 | &add($tmp1,$c); 36 | &mov($c,0); 37 | &adc($c,$c); 38 | &add($tmp1,$tmp2); 39 | &adc($c,0); 40 | &mov(&DWP($i*4,$r,"",0),$tmp1); # *r 41 | } 42 | 43 | &comment(""); 44 | &add($a,32); 45 | &add($b,32); 46 | &add($r,32); 47 | &sub($num,8); 48 | &jnz(&label("aw_loop")); 49 | 50 | &set_label("aw_finish",0); 51 | &mov($num,&wparam(3)); # get num 52 | &and($num,7); 53 | &jz(&label("aw_end")); 54 | 55 | for ($i=0; $i<7; $i++) 56 | { 57 | &comment("Tail Round $i"); 58 | &mov($tmp1,&DWP($i*4,$a,"",0)); # *a 59 | &mov($tmp2,&DWP($i*4,$b,"",0));# *b 60 | &add($tmp1,$c); 61 | &mov($c,0); 62 | &adc($c,$c); 63 | &add($tmp1,$tmp2); 64 | &adc($c,0); 65 | &dec($num) if ($i != 6); 66 | &mov(&DWP($i*4,$r,"",0),$tmp1); # *a 67 | &jz(&label("aw_end")) if ($i != 6); 68 | } 69 | &set_label("aw_end",0); 70 | 71 | # &mov("eax",$c); # $c is "eax" 72 | 73 | &function_end($name); 74 | } 75 | 76 | 1; 77 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/div.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | sub bn_div_words 5 | { 6 | local($name)=@_; 7 | 8 | &function_begin($name,""); 9 | &mov("edx",&wparam(0)); # 10 | &mov("eax",&wparam(1)); # 11 | &mov("ebx",&wparam(2)); # 12 | &div("ebx"); 13 | &function_end($name); 14 | } 15 | 1; 16 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/f: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/mul.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | sub bn_mul_words 5 | { 6 | local($name)=@_; 7 | 8 | &function_begin($name,""); 9 | 10 | &comment(""); 11 | $Low="eax"; 12 | $High="edx"; 13 | $a="ebx"; 14 | $w="ecx"; 15 | $r="edi"; 16 | $c="esi"; 17 | $num="ebp"; 18 | 19 | &xor($c,$c); # clear carry 20 | &mov($r,&wparam(0)); # 21 | &mov($a,&wparam(1)); # 22 | &mov($num,&wparam(2)); # 23 | &mov($w,&wparam(3)); # 24 | 25 | &and($num,0xfffffff8); # num / 8 26 | &jz(&label("mw_finish")); 27 | 28 | &set_label("mw_loop",0); 29 | for ($i=0; $i<32; $i+=4) 30 | { 31 | &comment("Round $i"); 32 | 33 | &mov("eax",&DWP($i,$a,"",0)); # *a 34 | &mul($w); # *a * w 35 | &add("eax",$c); # L(t)+=c 36 | # XXX 37 | 38 | &adc("edx",0); # H(t)+=carry 39 | &mov(&DWP($i,$r,"",0),"eax"); # *r= L(t); 40 | 41 | &mov($c,"edx"); # c= H(t); 42 | } 43 | 44 | &comment(""); 45 | &add($a,32); 46 | &add($r,32); 47 | &sub($num,8); 48 | &jz(&label("mw_finish")); 49 | &jmp(&label("mw_loop")); 50 | 51 | &set_label("mw_finish",0); 52 | &mov($num,&wparam(2)); # get num 53 | &and($num,7); 54 | &jnz(&label("mw_finish2")); 55 | &jmp(&label("mw_end")); 56 | 57 | &set_label("mw_finish2",1); 58 | for ($i=0; $i<7; $i++) 59 | { 60 | &comment("Tail Round $i"); 61 | &mov("eax",&DWP($i*4,$a,"",0));# *a 62 | &mul($w); # *a * w 63 | &add("eax",$c); # L(t)+=c 64 | # XXX 65 | &adc("edx",0); # H(t)+=carry 66 | &mov(&DWP($i*4,$r,"",0),"eax");# *r= L(t); 67 | &mov($c,"edx"); # c= H(t); 68 | &dec($num) if ($i != 7-1); 69 | &jz(&label("mw_end")) if ($i != 7-1); 70 | } 71 | &set_label("mw_end",0); 72 | &mov("eax",$c); 73 | 74 | &function_end($name); 75 | } 76 | 77 | 1; 78 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/mul_add.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | sub bn_mul_add_words 5 | { 6 | local($name)=@_; 7 | 8 | &function_begin($name,""); 9 | 10 | &comment(""); 11 | $Low="eax"; 12 | $High="edx"; 13 | $a="ebx"; 14 | $w="ebp"; 15 | $r="edi"; 16 | $c="esi"; 17 | 18 | &xor($c,$c); # clear carry 19 | &mov($r,&wparam(0)); # 20 | 21 | &mov("ecx",&wparam(2)); # 22 | &mov($a,&wparam(1)); # 23 | 24 | &and("ecx",0xfffffff8); # num / 8 25 | &mov($w,&wparam(3)); # 26 | 27 | &push("ecx"); # Up the stack for a tmp variable 28 | 29 | &jz(&label("maw_finish")); 30 | 31 | &set_label("maw_loop",0); 32 | 33 | &mov(&swtmp(0),"ecx"); # 34 | 35 | for ($i=0; $i<32; $i+=4) 36 | { 37 | &comment("Round $i"); 38 | 39 | &mov("eax",&DWP($i,$a,"",0)); # *a 40 | &mul($w); # *a * w 41 | &add("eax",$c); # L(t)+= *r 42 | &mov($c,&DWP($i,$r,"",0)); # L(t)+= *r 43 | &adc("edx",0); # H(t)+=carry 44 | &add("eax",$c); # L(t)+=c 45 | &adc("edx",0); # H(t)+=carry 46 | &mov(&DWP($i,$r,"",0),"eax"); # *r= L(t); 47 | &mov($c,"edx"); # c= H(t); 48 | } 49 | 50 | &comment(""); 51 | &mov("ecx",&swtmp(0)); # 52 | &add($a,32); 53 | &add($r,32); 54 | &sub("ecx",8); 55 | &jnz(&label("maw_loop")); 56 | 57 | &set_label("maw_finish",0); 58 | &mov("ecx",&wparam(2)); # get num 59 | &and("ecx",7); 60 | &jnz(&label("maw_finish2")); # helps branch prediction 61 | &jmp(&label("maw_end")); 62 | 63 | &set_label("maw_finish2",1); 64 | for ($i=0; $i<7; $i++) 65 | { 66 | &comment("Tail Round $i"); 67 | &mov("eax",&DWP($i*4,$a,"",0));# *a 68 | &mul($w); # *a * w 69 | &add("eax",$c); # L(t)+=c 70 | &mov($c,&DWP($i*4,$r,"",0)); # L(t)+= *r 71 | &adc("edx",0); # H(t)+=carry 72 | &add("eax",$c); 73 | &adc("edx",0); # H(t)+=carry 74 | &dec("ecx") if ($i != 7-1); 75 | &mov(&DWP($i*4,$r,"",0),"eax"); # *r= L(t); 76 | &mov($c,"edx"); # c= H(t); 77 | &jz(&label("maw_end")) if ($i != 7-1); 78 | } 79 | &set_label("maw_end",0); 80 | &mov("eax",$c); 81 | 82 | &pop("ecx"); # clear variable from 83 | 84 | &function_end($name); 85 | } 86 | 87 | 1; 88 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/sqr.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | sub bn_sqr_words 5 | { 6 | local($name)=@_; 7 | 8 | &function_begin($name,""); 9 | 10 | &comment(""); 11 | $r="esi"; 12 | $a="edi"; 13 | $num="ebx"; 14 | 15 | &mov($r,&wparam(0)); # 16 | &mov($a,&wparam(1)); # 17 | &mov($num,&wparam(2)); # 18 | 19 | &and($num,0xfffffff8); # num / 8 20 | &jz(&label("sw_finish")); 21 | 22 | &set_label("sw_loop",0); 23 | for ($i=0; $i<32; $i+=4) 24 | { 25 | &comment("Round $i"); 26 | &mov("eax",&DWP($i,$a,"",0)); # *a 27 | # XXX 28 | &mul("eax"); # *a * *a 29 | &mov(&DWP($i*2,$r,"",0),"eax"); # 30 | &mov(&DWP($i*2+4,$r,"",0),"edx");# 31 | } 32 | 33 | &comment(""); 34 | &add($a,32); 35 | &add($r,64); 36 | &sub($num,8); 37 | &jnz(&label("sw_loop")); 38 | 39 | &set_label("sw_finish",0); 40 | &mov($num,&wparam(2)); # get num 41 | &and($num,7); 42 | &jz(&label("sw_end")); 43 | 44 | for ($i=0; $i<7; $i++) 45 | { 46 | &comment("Tail Round $i"); 47 | &mov("eax",&DWP($i*4,$a,"",0)); # *a 48 | # XXX 49 | &mul("eax"); # *a * *a 50 | &mov(&DWP($i*8,$r,"",0),"eax"); # 51 | &dec($num) if ($i != 7-1); 52 | &mov(&DWP($i*8+4,$r,"",0),"edx"); 53 | &jz(&label("sw_end")) if ($i != 7-1); 54 | } 55 | &set_label("sw_end",0); 56 | 57 | &function_end($name); 58 | } 59 | 60 | 1; 61 | -------------------------------------------------------------------------------- /crypto/bn/asm/x86/sub.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | # x86 assember 3 | 4 | sub bn_sub_words 5 | { 6 | local($name)=@_; 7 | 8 | &function_begin($name,""); 9 | 10 | &comment(""); 11 | $a="esi"; 12 | $b="edi"; 13 | $c="eax"; 14 | $r="ebx"; 15 | $tmp1="ecx"; 16 | $tmp2="edx"; 17 | $num="ebp"; 18 | 19 | &mov($r,&wparam(0)); # get r 20 | &mov($a,&wparam(1)); # get a 21 | &mov($b,&wparam(2)); # get b 22 | &mov($num,&wparam(3)); # get num 23 | &xor($c,$c); # clear carry 24 | &and($num,0xfffffff8); # num / 8 25 | 26 | &jz(&label("aw_finish")); 27 | 28 | &set_label("aw_loop",0); 29 | for ($i=0; $i<8; $i++) 30 | { 31 | &comment("Round $i"); 32 | 33 | &mov($tmp1,&DWP($i*4,$a,"",0)); # *a 34 | &mov($tmp2,&DWP($i*4,$b,"",0)); # *b 35 | &sub($tmp1,$c); 36 | &mov($c,0); 37 | &adc($c,$c); 38 | &sub($tmp1,$tmp2); 39 | &adc($c,0); 40 | &mov(&DWP($i*4,$r,"",0),$tmp1); # *r 41 | } 42 | 43 | &comment(""); 44 | &add($a,32); 45 | &add($b,32); 46 | &add($r,32); 47 | &sub($num,8); 48 | &jnz(&label("aw_loop")); 49 | 50 | &set_label("aw_finish",0); 51 | &mov($num,&wparam(3)); # get num 52 | &and($num,7); 53 | &jz(&label("aw_end")); 54 | 55 | for ($i=0; $i<7; $i++) 56 | { 57 | &comment("Tail Round $i"); 58 | &mov($tmp1,&DWP($i*4,$a,"",0)); # *a 59 | &mov($tmp2,&DWP($i*4,$b,"",0));# *b 60 | &sub($tmp1,$c); 61 | &mov($c,0); 62 | &adc($c,$c); 63 | &sub($tmp1,$tmp2); 64 | &adc($c,0); 65 | &dec($num) if ($i != 6); 66 | &mov(&DWP($i*4,$r,"",0),$tmp1); # *a 67 | &jz(&label("aw_end")) if ($i != 6); 68 | } 69 | &set_label("aw_end",0); 70 | 71 | # &mov("eax",$c); # $c is "eax" 72 | 73 | &function_end($name); 74 | } 75 | 76 | 1; 77 | -------------------------------------------------------------------------------- /crypto/bn/bn.mul: -------------------------------------------------------------------------------- 1 | We need 2 | 3 | * bn_mul_comba8 4 | * bn_mul_comba4 5 | * bn_mul_normal 6 | * bn_mul_recursive 7 | 8 | * bn_sqr_comba8 9 | * bn_sqr_comba4 10 | bn_sqr_normal -> BN_sqr 11 | * bn_sqr_recursive 12 | 13 | * bn_mul_low_recursive 14 | * bn_mul_low_normal 15 | * bn_mul_high 16 | 17 | * bn_mul_part_recursive # symetric but not power of 2 18 | 19 | bn_mul_asymetric_recursive # uneven, but do the chop up. 20 | -------------------------------------------------------------------------------- /crypto/bn/divtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static int Rand(n) 5 | { 6 | unsigned char x[2]; 7 | RAND_pseudo_bytes(x,2); 8 | return (x[0] + 2*x[1]); 9 | } 10 | 11 | static 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 | 21 | main() 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 | } 42 | -------------------------------------------------------------------------------- /crypto/bn/exp.c: -------------------------------------------------------------------------------- 1 | /* unused */ 2 | 3 | #include 4 | #include 5 | #include "bn_lcl.h" 6 | 7 | #define SIZE 256 8 | #define NUM (8*8*8) 9 | #define MOD (8*8*8*8*8) 10 | 11 | main(argc,argv) 12 | int argc; 13 | char *argv[]; 14 | { 15 | BN_CTX ctx; 16 | BIGNUM a,b,c,r,rr,t,l; 17 | int j,i,size=SIZE,num=NUM,mod=MOD; 18 | char *start,*end; 19 | BN_MONT_CTX mont; 20 | double d,md; 21 | 22 | BN_MONT_CTX_init(&mont); 23 | BN_CTX_init(&ctx); 24 | BN_init(&a); 25 | BN_init(&b); 26 | BN_init(&c); 27 | BN_init(&r); 28 | 29 | start=ms_time_new(); 30 | end=ms_time_new(); 31 | while (size <= 1024*8) 32 | { 33 | BN_rand(&a,size,0,0); 34 | BN_rand(&b,size,1,0); 35 | BN_rand(&c,size,0,1); 36 | 37 | BN_mod(&a,&a,&c,&ctx); 38 | 39 | ms_time_get(start); 40 | for (i=0; i<10; i++) 41 | BN_MONT_CTX_set(&mont,&c,&ctx); 42 | ms_time_get(end); 43 | md=ms_time_diff(start,end); 44 | 45 | ms_time_get(start); 46 | for (i=0; i 63 | 64 | /* Opaque */ 65 | typedef struct CMAC_CTX_st CMAC_CTX; 66 | 67 | CMAC_CTX *CMAC_CTX_new(void); 68 | void CMAC_CTX_cleanup(CMAC_CTX *ctx); 69 | void CMAC_CTX_free(CMAC_CTX *ctx); 70 | EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 71 | int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 72 | 73 | int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 74 | const EVP_CIPHER *cipher, ENGINE *impl); 75 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 76 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 77 | int CMAC_resume(CMAC_CTX *ctx); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif 83 | -------------------------------------------------------------------------------- /crypto/comp/c_rle.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, 8 | unsigned int olen, unsigned char *in, unsigned int ilen); 9 | static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, 10 | unsigned int olen, unsigned char *in, unsigned int ilen); 11 | 12 | static COMP_METHOD rle_method={ 13 | NID_rle_compression, 14 | LN_rle_compression, 15 | NULL, 16 | NULL, 17 | rle_compress_block, 18 | rle_expand_block, 19 | NULL, 20 | NULL, 21 | }; 22 | 23 | COMP_METHOD *COMP_rle(void) 24 | { 25 | return(&rle_method); 26 | } 27 | 28 | static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, 29 | unsigned int olen, unsigned char *in, unsigned int ilen) 30 | { 31 | /* int i; */ 32 | 33 | if (ilen == 0 || olen < (ilen-1)) 34 | { 35 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ 36 | return(-1); 37 | } 38 | 39 | *(out++)=0; 40 | memcpy(out,in,ilen); 41 | return(ilen+1); 42 | } 43 | 44 | static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, 45 | unsigned int olen, unsigned char *in, unsigned int ilen) 46 | { 47 | int i; 48 | 49 | if (olen < (ilen-1)) 50 | { 51 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ 52 | return(-1); 53 | } 54 | 55 | i= *(in++); 56 | if (i == 0) 57 | { 58 | memcpy(out,in,ilen-1); 59 | } 60 | return(ilen-1); 61 | } 62 | -------------------------------------------------------------------------------- /crypto/comp/comp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HEADER_COMP_H 3 | #define HEADER_COMP_H 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct comp_ctx_st COMP_CTX; 12 | 13 | typedef struct comp_method_st 14 | { 15 | int type; /* NID for compression library */ 16 | const char *name; /* A text string to identify the library */ 17 | int (*init)(COMP_CTX *ctx); 18 | void (*finish)(COMP_CTX *ctx); 19 | int (*compress)(COMP_CTX *ctx, 20 | unsigned char *out, unsigned int olen, 21 | unsigned char *in, unsigned int ilen); 22 | int (*expand)(COMP_CTX *ctx, 23 | unsigned char *out, unsigned int olen, 24 | unsigned char *in, unsigned int ilen); 25 | /* The following two do NOTHING, but are kept for backward compatibility */ 26 | long (*ctrl)(void); 27 | long (*callback_ctrl)(void); 28 | } COMP_METHOD; 29 | 30 | struct comp_ctx_st 31 | { 32 | COMP_METHOD *meth; 33 | unsigned long compress_in; 34 | unsigned long compress_out; 35 | unsigned long expand_in; 36 | unsigned long expand_out; 37 | 38 | CRYPTO_EX_DATA ex_data; 39 | }; 40 | 41 | 42 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 43 | void COMP_CTX_free(COMP_CTX *ctx); 44 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 45 | unsigned char *in, int ilen); 46 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 47 | unsigned char *in, int ilen); 48 | COMP_METHOD *COMP_rle(void ); 49 | COMP_METHOD *COMP_zlib(void ); 50 | void COMP_zlib_cleanup(void); 51 | 52 | #ifdef HEADER_BIO_H 53 | #ifdef ZLIB 54 | BIO_METHOD *BIO_f_zlib(void); 55 | #endif 56 | #endif 57 | 58 | /* BEGIN ERROR CODES */ 59 | /* The following lines are auto generated by the script mkerr.pl. Any changes 60 | * made after this point may be overwritten when the script is next run. 61 | */ 62 | void ERR_load_COMP_strings(void); 63 | 64 | /* Error codes for the COMP functions. */ 65 | 66 | /* Function codes. */ 67 | #define COMP_F_BIO_ZLIB_FLUSH 99 68 | #define COMP_F_BIO_ZLIB_NEW 100 69 | #define COMP_F_BIO_ZLIB_READ 101 70 | #define COMP_F_BIO_ZLIB_WRITE 102 71 | 72 | /* Reason codes. */ 73 | #define COMP_R_ZLIB_DEFLATE_ERROR 99 74 | #define COMP_R_ZLIB_INFLATE_ERROR 100 75 | #define COMP_R_ZLIB_NOT_SUPPORTED 101 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | #endif 81 | -------------------------------------------------------------------------------- /crypto/comp/comp_lib.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) 8 | { 9 | COMP_CTX *ret; 10 | 11 | if ((ret=(COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) 12 | { 13 | /* ZZZZZZZZZZZZZZZZ */ 14 | return(NULL); 15 | } 16 | memset(ret,0,sizeof(COMP_CTX)); 17 | ret->meth=meth; 18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 19 | { 20 | OPENSSL_free(ret); 21 | ret=NULL; 22 | } 23 | return(ret); 24 | } 25 | 26 | void COMP_CTX_free(COMP_CTX *ctx) 27 | { 28 | if(ctx == NULL) 29 | return; 30 | 31 | if (ctx->meth->finish != NULL) 32 | ctx->meth->finish(ctx); 33 | 34 | OPENSSL_free(ctx); 35 | } 36 | 37 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 38 | unsigned char *in, int ilen) 39 | { 40 | int ret; 41 | if (ctx->meth->compress == NULL) 42 | { 43 | /* ZZZZZZZZZZZZZZZZZ */ 44 | return(-1); 45 | } 46 | ret=ctx->meth->compress(ctx,out,olen,in,ilen); 47 | if (ret > 0) 48 | { 49 | ctx->compress_in+=ilen; 50 | ctx->compress_out+=ret; 51 | } 52 | return(ret); 53 | } 54 | 55 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 56 | unsigned char *in, int ilen) 57 | { 58 | int ret; 59 | 60 | if (ctx->meth->expand == NULL) 61 | { 62 | /* ZZZZZZZZZZZZZZZZZ */ 63 | return(-1); 64 | } 65 | ret=ctx->meth->expand(ctx,out,olen,in,ilen); 66 | if (ret > 0) 67 | { 68 | ctx->expand_in+=ilen; 69 | ctx->expand_out+=ret; 70 | } 71 | return(ret); 72 | } 73 | -------------------------------------------------------------------------------- /crypto/conf/README: -------------------------------------------------------------------------------- 1 | Configuration modules. These are a set of modules which can perform 2 | various configuration functions. 3 | 4 | Currently the routines should be called at most once when an application 5 | starts up: that is before it starts any threads. 6 | 7 | The routines read a configuration file set up like this: 8 | 9 | ----- 10 | #default section 11 | openssl_conf=init_section 12 | 13 | [init_section] 14 | 15 | module1=value1 16 | #Second instance of module1 17 | module1.1=valueX 18 | module2=value2 19 | module3=dso_literal 20 | module4=dso_section 21 | 22 | [dso_section] 23 | 24 | path=/some/path/to/some/dso.so 25 | other_stuff=other_value 26 | ---- 27 | 28 | When this file is loaded a configuration module with the specified string 29 | (module* in the above example) is looked up and its init function called as: 30 | 31 | int conf_init_func(CONF_IMODULE *md, CONF *cnf); 32 | 33 | The function can then take whatever action is appropriate, for example further 34 | lookups based on the value. Multiple instances of the same config module can be 35 | loaded. 36 | 37 | When the application closes down the modules are cleaned up by calling an 38 | optional finish function: 39 | 40 | void conf_finish_func(CONF_IMODULE *md); 41 | 42 | The finish functions are called in reverse order: that is the last module 43 | loaded is the first one cleaned up. 44 | 45 | If no module exists with a given name then an attempt is made to load a DSO 46 | with the supplied name. This might mean that "module3" attempts to load a DSO 47 | called libmodule3.so or module3.dll for example. An explicit DSO name can be 48 | given by including a separate section as in the module4 example above. 49 | 50 | The DSO is expected to at least contain an initialization function: 51 | 52 | int OPENSSL_init(CONF_IMODULE *md, CONF *cnf); 53 | 54 | and may also include a finish function: 55 | 56 | void OPENSSL_finish(CONF_IMODULE *md); 57 | 58 | Static modules can also be added using, 59 | 60 | int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func 61 | *ffunc); 62 | 63 | where "name" is the name in the configuration file this function corresponds 64 | to. 65 | 66 | A set of builtin modules (currently only an ASN1 non functional test module) 67 | can be added by calling OPENSSL_load_builtin_modules(). 68 | 69 | The function OPENSSL_config() is intended as a simple configuration function 70 | that any application can call to perform various default configuration tasks. 71 | It uses the file openssl.cnf in the usual locations. 72 | 73 | 74 | -------------------------------------------------------------------------------- /crypto/conf/conf_mall.c: -------------------------------------------------------------------------------- 1 | /* conf_mall.c */ 2 | /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL 3 | * project 2001. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #include 60 | #include 61 | #include "cryptlib.h" 62 | #include 63 | #include 64 | #include 65 | #include 66 | #ifndef OPENSSL_NO_ENGINE 67 | #include 68 | #endif 69 | 70 | /* Load all OpenSSL builtin modules */ 71 | 72 | void OPENSSL_load_builtin_modules(void) 73 | { 74 | /* Add builtin modules here */ 75 | ASN1_add_oid_module(); 76 | #ifndef OPENSSL_NO_ENGINE 77 | ENGINE_add_conf_module(); 78 | #endif 79 | EVP_add_alg_module(); 80 | } 81 | 82 | -------------------------------------------------------------------------------- /crypto/conf/ssleay.cnf: -------------------------------------------------------------------------------- 1 | # 2 | # This is a test configuration file for use in SSLeay etc... 3 | # 4 | 5 | init = 5 6 | in\#it1 =10 7 | init2='10' 8 | init3='10\'' 9 | init4="10'" 10 | init5='='10\'' again' 11 | 12 | SSLeay::version = 0.5.0 13 | 14 | [genrsa] 15 | default_bits = 512 16 | SSLEAY::version = 0.5.0 17 | 18 | [gendh] 19 | default_bits = 512 20 | def_generator = 2 21 | 22 | [s_client] 23 | cipher1 = DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5\ 24 | cipher2 = 'DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5' 25 | cipher3 = "DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5" 26 | cipher4 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 27 | 28 | [ default ] 29 | cert_dir = $ENV::HOME/.ca_certs 30 | 31 | HOME = /tmp/eay 32 | 33 | tmp_cert_dir = $HOME/.ca_certs 34 | tmp2_cert_dir = thisis$(HOME)stuff 35 | 36 | LOGNAME = Eric Young (home=$HOME) 37 | 38 | [ special ] 39 | 40 | H=$HOME 41 | H=$default::HOME 42 | H=$ENV::HOME 43 | # 44 | # SSLeay example configuration file. 45 | # This is mostly being used for generation of certificate requests. 46 | # 47 | 48 | RANDFILE = $HOME/.rand 49 | 50 | [ req ] 51 | default_bits = 512 52 | default_keyfile = privkey.pem 53 | 54 | Attribute_type_1 = countryName 55 | Attribute_text_1 = Country Name (2 letter code) 56 | Attribute_default_1 = AU 57 | 58 | Attribute_type_2 = stateOrProvinceName 59 | Attribute_text_2 = State or Province Name (full name) 60 | Attribute_default_2 = Queensland 61 | 62 | Attribute_type_3 = localityName 63 | Attribute_text_3 = Locality Name (eg, city) 64 | 65 | Attribute_type_4 = organizationName 66 | Attribute_text_4 = Organization Name (eg, company) 67 | Attribute_default_4 = Mincom Pty Ltd 68 | 69 | Attribute_type_5 = organizationalUnitName 70 | Attribute_text_5 = Organizational Unit Name (eg, section) 71 | Attribute_default_5 = TR 72 | 73 | Attribute_type_6 = commonName 74 | Attribute_text_6 = Common Name (eg, YOUR name) 75 | 76 | Attribute_type_7 = emailAddress 77 | Attribute_text_7 = Email Address 78 | 79 | -------------------------------------------------------------------------------- /crypto/des/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2 | All rights reserved. 3 | 4 | This package is an DES implementation written by Eric Young (eay@cryptsoft.com). 5 | The implementation was written so as to conform with MIT's libdes. 6 | 7 | This library is free for commercial and non-commercial use as long as 8 | the following conditions are aheared to. The following conditions 9 | apply to all code found in this distribution. 10 | 11 | Copyright remains Eric Young's, and as such any Copyright notices in 12 | the code are not to be removed. 13 | If this package is used in a product, Eric Young should be given attribution 14 | as the author of that the SSL library. This can be in the form of a textual 15 | message at program startup or in documentation (online or textual) provided 16 | with the package. 17 | 18 | Redistribution and use in source and binary forms, with or without 19 | modification, are permitted provided that the following conditions 20 | are met: 21 | 1. Redistributions of source code must retain the copyright 22 | notice, this list of conditions and the following disclaimer. 23 | 2. Redistributions in binary form must reproduce the above copyright 24 | notice, this list of conditions and the following disclaimer in the 25 | documentation and/or other materials provided with the distribution. 26 | 3. All advertising materials mentioning features or use of this software 27 | must display the following acknowledgement: 28 | This product includes software developed by Eric Young (eay@cryptsoft.com) 29 | 30 | THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 31 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 34 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 | SUCH DAMAGE. 41 | 42 | The license and distribution terms for any publically available version or 43 | derivative of this code cannot be changed. i.e. this code cannot simply be 44 | copied and put under another distrubution license 45 | [including the GNU Public License.] 46 | 47 | The reason behind this being stated in this direct manner is past 48 | experience in code simply being copied and the attribution removed 49 | from it and then being distributed as part of other packages. This 50 | implementation was a non-trivial and unpaid effort. 51 | -------------------------------------------------------------------------------- /crypto/des/DES.pm: -------------------------------------------------------------------------------- 1 | package DES; 2 | 3 | require Exporter; 4 | require DynaLoader; 5 | @ISA = qw(Exporter DynaLoader); 6 | # Items to export into callers namespace by default 7 | # (move infrequently used names to @EXPORT_OK below) 8 | @EXPORT = qw( 9 | ); 10 | # Other items we are prepared to export if requested 11 | @EXPORT_OK = qw( 12 | crypt 13 | ); 14 | 15 | # Preloaded methods go here. Autoload methods go after __END__, and are 16 | # processed by the autosplit program. 17 | bootstrap DES; 18 | 1; 19 | __END__ 20 | -------------------------------------------------------------------------------- /crypto/des/INSTALL: -------------------------------------------------------------------------------- 1 | Check the CC and CFLAGS lines in the makefile 2 | 3 | If your C library does not support the times(3) function, change the 4 | #define TIMES to 5 | #undef TIMES in speed.c 6 | If it does, check the HZ value for the times(3) function. 7 | If your system does not define CLK_TCK it will be assumed to 8 | be 100.0. 9 | 10 | If possible use gcc v 2.7.? 11 | Turn on the maximum optimising (normally '-O3 -fomit-frame-pointer' for gcc) 12 | In recent times, some system compilers give better performace. 13 | 14 | type 'make' 15 | 16 | run './destest' to check things are ok. 17 | run './rpw' to check the tty code for reading passwords works. 18 | run './speed' to see how fast those optimisations make the library run :-) 19 | run './des_opts' to determin the best compile time options. 20 | 21 | The output from des_opts should be put in the makefile options and des_enc.c 22 | should be rebuilt. For 64 bit computers, do not use the DES_PTR option. 23 | For the DEC Alpha, edit des.h and change DES_LONG to 'unsigned int' 24 | and then you can use the 'DES_PTR' option. 25 | 26 | The file options.txt has the options listed for best speed on quite a 27 | few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then 28 | turn on the relevant option in the Makefile. 29 | 30 | There are some special Makefile targets that make life easier. 31 | make cc - standard cc build 32 | make gcc - standard gcc build 33 | make x86-elf - x86 assembler (elf), linux-elf. 34 | make x86-out - x86 assembler (a.out), FreeBSD 35 | make x86-solaris- x86 assembler 36 | make x86-bsdi - x86 assembler (a.out with primative assembler). 37 | 38 | If at all possible use the assembler (for Windows NT/95, use 39 | asm/win32.obj to link with). The x86 assembler is very very fast. 40 | 41 | A make install will by default install 42 | libdes.a in /usr/local/lib/libdes.a 43 | des in /usr/local/bin/des 44 | des_crypt.man in /usr/local/man/man3/des_crypt.3 45 | des.man in /usr/local/man/man1/des.1 46 | des.h in /usr/include/des.h 47 | 48 | des(1) should be compatible with sunOS's but I have been unable to 49 | test it. 50 | 51 | These routines should compile on MSDOS, most 32bit and 64bit version 52 | of Unix (BSD and SYSV) and VMS, without modification. 53 | The only problems should be #include files that are in the wrong places. 54 | 55 | These routines can be compiled under MSDOS. 56 | I have successfully encrypted files using des(1) under MSDOS and then 57 | decrypted the files on a SparcStation. 58 | I have been able to compile and test the routines with 59 | Microsoft C v 5.1 and Turbo C v 2.0. 60 | The code in this library is in no way optimised for the 16bit 61 | operation of MSDOS. 62 | 63 | When building for glibc, ignore all of the above and just unpack into 64 | glibc-1.??/des and then gmake as per normal. 65 | 66 | As a final note on performace. Certain CPUs like sparcs and Alpha often give 67 | a %10 speed difference depending on the link order. It is rather anoying 68 | when one program reports 'x' DES encrypts a second and another reports 69 | 'x*0.9' the speed. 70 | -------------------------------------------------------------------------------- /crypto/des/Imakefile: -------------------------------------------------------------------------------- 1 | # This Imakefile has not been tested for a while but it should still 2 | # work when placed in the correct directory in the kerberos v 4 distribution 3 | 4 | SRCS= cbc_cksm.c cbc_enc.c ecb_enc.c pcbc_enc.c \ 5 | qud_cksm.c rand_key.c read_pwd.c set_key.c str2key.c \ 6 | enc_read.c enc_writ.c fcrypt.c cfb_enc.c \ 7 | ecb3_enc.c ofb_enc.c ofb64enc.c 8 | 9 | OBJS= cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \ 10 | qud_cksm.o rand_key.o read_pwd.o set_key.o str2key.o \ 11 | enc_read.o enc_writ.o fcrypt.o cfb_enc.o \ 12 | ecb3_enc.o ofb_enc.o ofb64enc.o 13 | 14 | GENERAL=COPYRIGHT FILES INSTALL Imakefile README VERSION makefile times \ 15 | vms.com KERBEROS 16 | DES= des.c des.man 17 | TESTING=destest.c speed.c rpw.c 18 | LIBDES= des_crypt.man des.h des_locl.h podd.h sk.h spr.h 19 | 20 | PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl 21 | 22 | CODE= $(GENERAL) $(DES) $(TESTING) $(SRCS) $(LIBDES) $(PERL) 23 | 24 | SRCDIR=$(SRCTOP)/lib/des 25 | 26 | DBG= -O 27 | INCLUDE= -I$(SRCDIR) 28 | CC= cc 29 | 30 | library_obj_rule() 31 | 32 | install_library_target(des,$(OBJS),$(SRCS),) 33 | 34 | test(destest,libdes.a,) 35 | test(rpw,libdes.a,) 36 | -------------------------------------------------------------------------------- /crypto/des/KERBEROS: -------------------------------------------------------------------------------- 1 | [ This is an old file, I don't know if it is true anymore 2 | but I will leave the file here - eay 21/11/95 ] 3 | 4 | To use this library with Bones (kerberos without DES): 5 | 1) Get my modified Bones - eBones. It can be found on 6 | gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z 7 | and 8 | nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z 9 | 10 | 2) Unpack this library in src/lib/des, makeing sure it is version 11 | 3.00 or greater (libdes.tar.93-10-07.Z). This versions differences 12 | from the version in comp.sources.misc volume 29 patchlevel2. 13 | The primarily difference is that it should compile under kerberos :-). 14 | It can be found at. 15 | ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z 16 | 17 | Now do a normal kerberos build and things should work. 18 | 19 | One problem I found when I was build on my local sun. 20 | --- 21 | For sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c 22 | 23 | *** make_commands.c.orig Fri Jul 3 04:18:35 1987 24 | --- make_commands.c Wed May 20 08:47:42 1992 25 | *************** 26 | *** 98,104 **** 27 | if (!rename(o_file, z_file)) { 28 | if (!vfork()) { 29 | chdir("/tmp"); 30 | ! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n", 31 | z_file+5, 0); 32 | perror("/bin/ld"); 33 | _exit(1); 34 | --- 98,104 ---- 35 | if (!rename(o_file, z_file)) { 36 | if (!vfork()) { 37 | chdir("/tmp"); 38 | ! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", 39 | z_file+5, 0); 40 | perror("/bin/ld"); 41 | _exit(1); 42 | -------------------------------------------------------------------------------- /crypto/des/README: -------------------------------------------------------------------------------- 1 | 2 | libdes, Version 4.01 10-Jan-97 3 | 4 | Copyright (c) 1997, Eric Young 5 | All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms specified in COPYRIGHT. 9 | 10 | -- 11 | The primary ftp site for this library is 12 | ftp://ftp.psy.uq.oz.au/pub/Crypto/DES/libdes-x.xx.tar.gz 13 | libdes is now also shipped with SSLeay. Primary ftp site of 14 | ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL/SSLeay-x.x.x.tar.gz 15 | 16 | The best way to build this library is to build it as part of SSLeay. 17 | 18 | This kit builds a DES encryption library and a DES encryption program. 19 | It supports ecb, cbc, ofb, cfb, triple ecb, triple cbc, triple ofb, 20 | triple cfb, desx, and MIT's pcbc encryption modes and also has a fast 21 | implementation of crypt(3). 22 | It contains support routines to read keys from a terminal, 23 | generate a random key, generate a key from an arbitrary length string, 24 | read/write encrypted data from/to a file descriptor. 25 | 26 | The implementation was written so as to conform with the manual entry 27 | for the des_crypt(3) library routines from MIT's project Athena. 28 | 29 | destest should be run after compilation to test the des routines. 30 | rpw should be run after compilation to test the read password routines. 31 | The des program is a replacement for the sun des command. I believe it 32 | conforms to the sun version. 33 | 34 | The Imakefile is setup for use in the kerberos distribution. 35 | 36 | These routines are best compiled with gcc or any other good 37 | optimising compiler. 38 | Just turn you optimiser up to the highest settings and run destest 39 | after the build to make sure everything works. 40 | 41 | I believe these routines are close to the fastest and most portable DES 42 | routines that use small lookup tables (4.5k) that are publicly available. 43 | The fcrypt routine is faster than ufc's fcrypt (when compiling with 44 | gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines 45 | (on a sun3/260 168 vs 336). It is a function of CPU on chip cache size. 46 | [ 10-Jan-97 and a function of an incorrect speed testing program in 47 | ufc which gave much better test figures that reality ]. 48 | 49 | It is worth noting that on sparc and Alpha CPUs, performance of the DES 50 | library can vary by upto %10 due to the positioning of files after application 51 | linkage. 52 | 53 | Eric Young (eay@cryptsoft.com) 54 | 55 | -------------------------------------------------------------------------------- /crypto/des/asm/desboth.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | $L="edi"; 4 | $R="esi"; 5 | 6 | sub DES_encrypt3 7 | { 8 | local($name,$enc)=@_; 9 | 10 | &function_begin_B($name,""); 11 | &push("ebx"); 12 | &mov("ebx",&wparam(0)); 13 | 14 | &push("ebp"); 15 | &push("esi"); 16 | 17 | &push("edi"); 18 | 19 | &comment(""); 20 | &comment("Load the data words"); 21 | &mov($L,&DWP(0,"ebx","",0)); 22 | &mov($R,&DWP(4,"ebx","",0)); 23 | &stack_push(3); 24 | 25 | &comment(""); 26 | &comment("IP"); 27 | &IP_new($L,$R,"edx",0); 28 | 29 | # put them back 30 | 31 | if ($enc) 32 | { 33 | &mov(&DWP(4,"ebx","",0),$R); 34 | &mov("eax",&wparam(1)); 35 | &mov(&DWP(0,"ebx","",0),"edx"); 36 | &mov("edi",&wparam(2)); 37 | &mov("esi",&wparam(3)); 38 | } 39 | else 40 | { 41 | &mov(&DWP(4,"ebx","",0),$R); 42 | &mov("esi",&wparam(1)); 43 | &mov(&DWP(0,"ebx","",0),"edx"); 44 | &mov("edi",&wparam(2)); 45 | &mov("eax",&wparam(3)); 46 | } 47 | &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); 48 | &mov(&swtmp(1), "eax"); 49 | &mov(&swtmp(0), "ebx"); 50 | &call("DES_encrypt2"); 51 | &mov(&swtmp(2), (DWC(($enc)?"0":"1"))); 52 | &mov(&swtmp(1), "edi"); 53 | &mov(&swtmp(0), "ebx"); 54 | &call("DES_encrypt2"); 55 | &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); 56 | &mov(&swtmp(1), "esi"); 57 | &mov(&swtmp(0), "ebx"); 58 | &call("DES_encrypt2"); 59 | 60 | &stack_pop(3); 61 | &mov($L,&DWP(0,"ebx","",0)); 62 | &mov($R,&DWP(4,"ebx","",0)); 63 | 64 | &comment(""); 65 | &comment("FP"); 66 | &FP_new($L,$R,"eax",0); 67 | 68 | &mov(&DWP(0,"ebx","",0),"eax"); 69 | &mov(&DWP(4,"ebx","",0),$R); 70 | 71 | &pop("edi"); 72 | &pop("esi"); 73 | &pop("ebp"); 74 | &pop("ebx"); 75 | &ret(); 76 | &function_end_B($name); 77 | } 78 | 79 | 80 | -------------------------------------------------------------------------------- /crypto/des/cbc_enc.c: -------------------------------------------------------------------------------- 1 | /* crypto/des/cbc_enc.c */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #define CBC_ENC_C__DONT_UPDATE_IV 60 | 61 | #include "ncbc_enc.c" /* des_cbc_encrypt */ 62 | -------------------------------------------------------------------------------- /crypto/des/des3s.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // gettsc.inl 3 | // 4 | // gives access to the Pentium's (secret) cycle counter 5 | // 6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) 7 | // in 1996-7 and is entered, by him, into the public domain. 8 | 9 | #if defined(__WATCOMC__) 10 | void GetTSC(unsigned long&); 11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; 12 | #elif defined(__GNUC__) 13 | inline 14 | void GetTSC(unsigned long& tsc) 15 | { 16 | asm volatile(".byte 15, 49\n\t" 17 | : "=eax" (tsc) 18 | : 19 | : "%edx", "%eax"); 20 | } 21 | #elif defined(_MSC_VER) 22 | inline 23 | void GetTSC(unsigned long& tsc) 24 | { 25 | unsigned long a; 26 | __asm _emit 0fh 27 | __asm _emit 31h 28 | __asm mov a, eax; 29 | tsc=a; 30 | } 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | void main(int argc,char *argv[]) 38 | { 39 | des_key_schedule key1,key2,key3; 40 | unsigned long s1,s2,e1,e2; 41 | unsigned long data[2]; 42 | int i,j; 43 | 44 | for (j=0; j<6; j++) 45 | { 46 | for (i=0; i<1000; i++) /**/ 47 | { 48 | des_encrypt3(&data[0],key1,key2,key3); 49 | GetTSC(s1); 50 | des_encrypt3(&data[0],key1,key2,key3); 51 | des_encrypt3(&data[0],key1,key2,key3); 52 | des_encrypt3(&data[0],key1,key2,key3); 53 | GetTSC(e1); 54 | GetTSC(s2); 55 | des_encrypt3(&data[0],key1,key2,key3); 56 | des_encrypt3(&data[0],key1,key2,key3); 57 | des_encrypt3(&data[0],key1,key2,key3); 58 | des_encrypt3(&data[0],key1,key2,key3); 59 | GetTSC(e2); 60 | des_encrypt3(&data[0],key1,key2,key3); 61 | } 62 | 63 | printf("des %d %d (%d)\n", 64 | e1-s1,e2-s2,((e2-s2)-(e1-s1))); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /crypto/des/dess.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // gettsc.inl 3 | // 4 | // gives access to the Pentium's (secret) cycle counter 5 | // 6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) 7 | // in 1996-7 and is entered, by him, into the public domain. 8 | 9 | #if defined(__WATCOMC__) 10 | void GetTSC(unsigned long&); 11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; 12 | #elif defined(__GNUC__) 13 | inline 14 | void GetTSC(unsigned long& tsc) 15 | { 16 | asm volatile(".byte 15, 49\n\t" 17 | : "=eax" (tsc) 18 | : 19 | : "%edx", "%eax"); 20 | } 21 | #elif defined(_MSC_VER) 22 | inline 23 | void GetTSC(unsigned long& tsc) 24 | { 25 | unsigned long a; 26 | __asm _emit 0fh 27 | __asm _emit 31h 28 | __asm mov a, eax; 29 | tsc=a; 30 | } 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | void main(int argc,char *argv[]) 38 | { 39 | des_key_schedule key; 40 | unsigned long s1,s2,e1,e2; 41 | unsigned long data[2]; 42 | int i,j; 43 | 44 | for (j=0; j<6; j++) 45 | { 46 | for (i=0; i<1000; i++) /**/ 47 | { 48 | des_encrypt1(&data[0],key,1); 49 | GetTSC(s1); 50 | des_encrypt1(&data[0],key,1); 51 | des_encrypt1(&data[0],key,1); 52 | des_encrypt1(&data[0],key,1); 53 | GetTSC(e1); 54 | GetTSC(s2); 55 | des_encrypt1(&data[0],key,1); 56 | des_encrypt1(&data[0],key,1); 57 | des_encrypt1(&data[0],key,1); 58 | des_encrypt1(&data[0],key,1); 59 | GetTSC(e2); 60 | des_encrypt1(&data[0],key,1); 61 | } 62 | 63 | printf("des %d %d (%d)\n", 64 | e1-s1,e2-s2,((e2-s2)-(e1-s1))); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /crypto/des/makefile.bc: -------------------------------------------------------------------------------- 1 | # 2 | # Origional BC Makefile from Teun 3 | # 4 | # 5 | CC = bcc 6 | TLIB = tlib /0 /C 7 | # note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s 8 | OPTIMIZE= -3 -O2 9 | #WINDOWS= -W 10 | CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS 11 | LFLAGS = -ml $(WINDOWS) 12 | 13 | .c.obj: 14 | $(CC) $(CFLAGS) $*.c 15 | 16 | .obj.exe: 17 | $(CC) $(LFLAGS) -e$*.exe $*.obj libdes.lib 18 | 19 | all: $(LIB) destest.exe rpw.exe des.exe speed.exe 20 | 21 | # "make clean": use a directory containing only libdes .exe and .obj files... 22 | clean: 23 | del *.exe 24 | del *.obj 25 | del libdes.lib 26 | del libdes.rsp 27 | 28 | OBJS= cbc_cksm.obj cbc_enc.obj ecb_enc.obj pcbc_enc.obj \ 29 | qud_cksm.obj rand_key.obj set_key.obj str2key.obj \ 30 | enc_read.obj enc_writ.obj fcrypt.obj cfb_enc.obj \ 31 | ecb3_enc.obj ofb_enc.obj cbc3_enc.obj read_pwd.obj\ 32 | cfb64enc.obj ofb64enc.obj ede_enc.obj cfb64ede.obj\ 33 | ofb64ede.obj supp.obj 34 | 35 | LIB= libdes.lib 36 | 37 | $(LIB): $(OBJS) 38 | del $(LIB) 39 | makersp "+%s &\n" &&| 40 | $(OBJS) 41 | | >libdes.rsp 42 | $(TLIB) libdes.lib @libdes.rsp,nul 43 | del libdes.rsp 44 | 45 | destest.exe: destest.obj libdes.lib 46 | rpw.exe: rpw.obj libdes.lib 47 | speed.exe: speed.obj libdes.lib 48 | des.exe: des.obj libdes.lib 49 | 50 | 51 | -------------------------------------------------------------------------------- /crypto/des/options.txt: -------------------------------------------------------------------------------- 1 | Note that the UNROLL option makes the 'inner' des loop unroll all 16 rounds 2 | instead of the default 4. 3 | RISC1 and RISC2 are 2 alternatives for the inner loop and 4 | PTR means to use pointers arithmatic instead of arrays. 5 | 6 | FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - assembler 577,000 4620k/s 7 | IRIX 6.2 - R10000 195mhz - cc (-O3 -n32) - UNROLL RISC2 PTR 496,000 3968k/s 8 | solaris 2.5.1 usparc 167mhz?? - SC4.0 - UNROLL RISC1 PTR [1] 459,400 3672k/s 9 | FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - UNROLL RISC1 433,000 3468k/s 10 | solaris 2.5.1 usparc 167mhz?? - gcc 2.7.2 - UNROLL 380,000 3041k/s 11 | linux - pentium 100mhz - gcc 2.7.0 - assembler 281,000 2250k/s 12 | NT 4.0 - pentium 100mhz - VC 4.2 - assembler 281,000 2250k/s 13 | AIX 4.1? - PPC604 100mhz - cc - UNROLL 275,000 2200k/s 14 | IRIX 5.3 - R4400 200mhz - gcc 2.6.3 - UNROLL RISC2 PTR 235,300 1882k/s 15 | IRIX 5.3 - R4400 200mhz - cc - UNROLL RISC2 PTR 233,700 1869k/s 16 | NT 4.0 - pentium 100mhz - VC 4.2 - UNROLL RISC1 PTR 191,000 1528k/s 17 | DEC Alpha 165mhz?? - cc - RISC2 PTR [2] 181,000 1448k/s 18 | linux - pentium 100mhz - gcc 2.7.0 - UNROLL RISC1 PTR 158,500 1268k/s 19 | HPUX 10 - 9000/887 - cc - UNROLL [3] 148,000 1190k/s 20 | solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2 - UNROLL 123,600 989k/s 21 | IRIX 5.3 - R4000 100mhz - cc - UNROLL RISC2 PTR 101,000 808k/s 22 | DGUX - 88100 50mhz(?) - gcc 2.6.3 - UNROLL 81,000 648k/s 23 | solaris 2.4 486 50mhz - gcc 2.6.3 - assembler 65,000 522k/s 24 | HPUX 10 - 9000/887 - k&r cc (default compiler) - UNROLL PTR 76,000 608k/s 25 | solaris 2.4 486 50mhz - gcc 2.6.3 - UNROLL RISC2 43,500 344k/s 26 | AIX - old slow one :-) - cc - 39,000 312k/s 27 | 28 | Notes. 29 | [1] For the ultra sparc, SunC 4.0 30 | cc -xtarget=ultra -xarch=v8plus -Xa -xO5, running 'des_opts' 31 | gives a speed of 344,000 des/s while 'speed' gives 459,000 des/s. 32 | I'll record the higher since it is coming from the library but it 33 | is all rather weird. 34 | [2] Similar to the ultra sparc ([1]), 181,000 for 'des_opts' vs 175,000. 35 | [3] I was unable to get access to this machine when it was not heavily loaded. 36 | As such, my timing program was never able to get more that %30 of the CPU. 37 | This would cause the program to give much lower speed numbers because 38 | it would be 'fighting' to stay in the cache with the other CPU burning 39 | processes. 40 | -------------------------------------------------------------------------------- /crypto/des/rand_key.c: -------------------------------------------------------------------------------- 1 | /* crypto/des/rand_key.c */ 2 | /* ==================================================================== 3 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | * This product includes cryptographic software written by Eric Young 51 | * (eay@cryptsoft.com). This product includes software written by Tim 52 | * Hudson (tjh@cryptsoft.com). 53 | * 54 | */ 55 | 56 | #include 57 | #include 58 | 59 | int DES_random_key(DES_cblock *ret) 60 | { 61 | do 62 | { 63 | if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1) 64 | return (0); 65 | } while (DES_is_weak_key(ret)); 66 | DES_set_odd_parity(ret); 67 | return (1); 68 | } 69 | -------------------------------------------------------------------------------- /crypto/des/t/test: -------------------------------------------------------------------------------- 1 | #!./perl 2 | 3 | BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)); } 4 | 5 | use DES; 6 | 7 | $key='00000000'; 8 | $ks=DES::set_key($key); 9 | @a=split(//,$ks); 10 | foreach (@a) { printf "%02x-",ord($_); } 11 | print "\n"; 12 | 13 | 14 | $key=DES::random_key(); 15 | print "($_)\n"; 16 | @a=split(//,$key); 17 | foreach (@a) { printf "%02x-",ord($_); } 18 | print "\n"; 19 | $str="this is and again into the breach"; 20 | ($k1,$k2)=DES::string_to_2keys($str); 21 | @a=split(//,$k1); 22 | foreach (@a) { printf "%02x-",ord($_); } 23 | print "\n"; 24 | @a=split(//,$k2); 25 | foreach (@a) { printf "%02x-",ord($_); } 26 | print "\n"; 27 | 28 | -------------------------------------------------------------------------------- /crypto/des/times/486-50.sol: -------------------------------------------------------------------------------- 1 | Solaris 2.4, 486 50mhz, gcc 2.6.3 2 | options des ecb/s 3 | 16 r2 i 43552.51 100.0% 4 | 16 r1 i 43487.45 99.9% 5 | 16 c p 43003.23 98.7% 6 | 16 r2 p 42339.00 97.2% 7 | 16 c i 41900.91 96.2% 8 | 16 r1 p 41360.64 95.0% 9 | 4 c i 38728.48 88.9% 10 | 4 c p 38225.63 87.8% 11 | 4 r1 i 38085.79 87.4% 12 | 4 r2 i 37825.64 86.9% 13 | 4 r2 p 34611.00 79.5% 14 | 4 r1 p 31802.00 73.0% 15 | -DDES_UNROLL -DDES_RISC2 16 | 17 | -------------------------------------------------------------------------------- /crypto/des/times/586-100.lnx: -------------------------------------------------------------------------------- 1 | Pentium 100 2 | Linux 2 kernel 3 | gcc 2.7.0 -O3 -fomit-frame-pointer 4 | No X server running, just a console, it makes the top speed jump from 151,000 5 | to 158,000 :-). 6 | options des ecb/s 7 | assember 281000.00 177.1% 8 | 16 r1 p 158667.40 100.0% 9 | 16 r1 i 148471.70 93.6% 10 | 16 r2 p 143961.80 90.7% 11 | 16 r2 i 141689.20 89.3% 12 | 4 r1 i 140100.00 88.3% 13 | 4 r2 i 134049.40 84.5% 14 | 16 c i 124145.20 78.2% 15 | 16 c p 121584.20 76.6% 16 | 4 c i 118116.00 74.4% 17 | 4 r2 p 117977.90 74.4% 18 | 4 c p 114971.40 72.5% 19 | 4 r1 p 114578.40 72.2% 20 | -DDES_UNROLL -DDES_RISC1 -DDES_PTR 21 | -------------------------------------------------------------------------------- /crypto/des/times/686-200.fre: -------------------------------------------------------------------------------- 1 | Pentium 100 2 | Free BSD 2.1.5 kernel 3 | gcc 2.7.2.2 -O3 -fomit-frame-pointer 4 | options des ecb/s 5 | assember 578000.00 133.1% 6 | 16 r2 i 434454.80 100.0% 7 | 16 r1 i 433621.43 99.8% 8 | 16 r2 p 431375.69 99.3% 9 | 4 r1 i 423722.30 97.5% 10 | 4 r2 i 422399.40 97.2% 11 | 16 r1 p 421739.40 97.1% 12 | 16 c i 399027.94 91.8% 13 | 16 c p 372251.70 85.7% 14 | 4 c i 365118.35 84.0% 15 | 4 c p 352880.51 81.2% 16 | 4 r2 p 255104.90 58.7% 17 | 4 r1 p 251289.18 57.8% 18 | -DDES_UNROLL -DDES_RISC2 19 | -------------------------------------------------------------------------------- /crypto/des/times/aix.cc: -------------------------------------------------------------------------------- 1 | From: Paco Garcia 2 | 3 | This machine is a Bull Estrella Minitower Model MT604-100 4 | Processor : PPC604 5 | P.Speed : 100Mhz 6 | Data/Instr Cache : 16 K 7 | L2 Cache : 256 K 8 | PCI BUS Speed : 33 Mhz 9 | TransfRate PCI : 132 MB/s 10 | Memory : 96 MB 11 | 12 | options des ecb/s 13 | 4 c p 275118.61 100.0% 14 | 4 c i 273545.07 99.4% 15 | 4 r2 p 270441.02 98.3% 16 | 4 r1 p 253052.15 92.0% 17 | 4 r2 i 240842.97 87.5% 18 | 4 r1 i 240556.66 87.4% 19 | 16 c i 224603.99 81.6% 20 | 16 c p 224483.98 81.6% 21 | 16 r2 p 215691.19 78.4% 22 | 16 r1 p 208332.83 75.7% 23 | 16 r1 i 199206.50 72.4% 24 | 16 r2 i 198963.70 72.3% 25 | -DDES_PTR 26 | 27 | -------------------------------------------------------------------------------- /crypto/des/times/alpha.cc: -------------------------------------------------------------------------------- 1 | cc -O2 2 | DES_LONG is 'unsigned int' 3 | 4 | options des ecb/s 5 | 4 r2 p 181146.14 100.0% 6 | 16 r2 p 172102.94 95.0% 7 | 4 r2 i 165424.11 91.3% 8 | 16 c p 160468.64 88.6% 9 | 4 c p 156653.59 86.5% 10 | 4 c i 155245.18 85.7% 11 | 4 r1 p 154729.68 85.4% 12 | 16 r2 i 154137.69 85.1% 13 | 16 r1 p 152357.96 84.1% 14 | 16 c i 148743.91 82.1% 15 | 4 r1 i 146695.59 81.0% 16 | 16 r1 i 144961.00 80.0% 17 | -DDES_RISC2 -DDES_PTR 18 | 19 | -------------------------------------------------------------------------------- /crypto/des/times/hpux.cc: -------------------------------------------------------------------------------- 1 | HPUX 10 - 9000/887 - cc -D_HPUX_SOURCE -Aa +ESlit +O2 -Wl,-a,archive 2 | 3 | options des ecb/s 4 | 16 c i 149448.90 100.0% 5 | 4 c i 145861.79 97.6% 6 | 16 r2 i 141710.96 94.8% 7 | 16 r1 i 139455.33 93.3% 8 | 4 r2 i 138800.00 92.9% 9 | 4 r1 i 136692.65 91.5% 10 | 16 r2 p 110228.17 73.8% 11 | 16 r1 p 109397.07 73.2% 12 | 16 c p 109209.89 73.1% 13 | 4 c p 108014.71 72.3% 14 | 4 r2 p 107873.88 72.2% 15 | 4 r1 p 107685.83 72.1% 16 | -DDES_UNROLL 17 | 18 | -------------------------------------------------------------------------------- /crypto/des/times/sparc.gcc: -------------------------------------------------------------------------------- 1 | solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2 2 | 3 | options des ecb/s 4 | 16 c i 124382.70 100.0% 5 | 4 c i 118884.68 95.6% 6 | 16 c p 112261.20 90.3% 7 | 16 r2 i 111777.10 89.9% 8 | 16 r2 p 108896.30 87.5% 9 | 16 r1 p 108791.59 87.5% 10 | 4 c p 107290.10 86.3% 11 | 4 r1 p 104583.80 84.1% 12 | 16 r1 i 104206.20 83.8% 13 | 4 r2 p 103709.80 83.4% 14 | 4 r2 i 98306.43 79.0% 15 | 4 r1 i 91525.80 73.6% 16 | -DDES_UNROLL 17 | 18 | -------------------------------------------------------------------------------- /crypto/des/times/usparc.cc: -------------------------------------------------------------------------------- 1 | solaris 2.5.1 usparc 167mhz?? - SC4.0 cc -fast -Xa -xO5 2 | 3 | For the ultra sparc, SunC 4.0 cc -fast -Xa -xO5, running 'des_opts' 4 | gives a speed of 475,000 des/s while 'speed' gives 417,000 des/s. 5 | I believe the difference is tied up in optimisation that the compiler 6 | is able to perform when the code is 'inlined'. For 'speed', the DES 7 | routines are being linked from a library. I'll record the higher 8 | speed since if performance is everything, you can always inline 9 | 'des_enc.c'. 10 | 11 | [ 16-Jan-06 - I've been playing with the 12 | '-xtarget=ultra -xarch=v8plus -Xa -xO5 -Xa' 13 | and while it makes the des_opts numbers much slower, it makes the 14 | actual 'speed' numbers look better which is a realistic version of 15 | using the libraries. ] 16 | 17 | options des ecb/s 18 | 16 r1 p 475516.90 100.0% 19 | 16 r2 p 439388.10 92.4% 20 | 16 c i 427001.40 89.8% 21 | 16 c p 419516.50 88.2% 22 | 4 r2 p 409491.70 86.1% 23 | 4 r1 p 404266.90 85.0% 24 | 4 c p 398121.00 83.7% 25 | 4 c i 370588.40 77.9% 26 | 4 r1 i 362742.20 76.3% 27 | 16 r2 i 331275.50 69.7% 28 | 16 r1 i 324730.60 68.3% 29 | 4 r2 i 63535.10 13.4% <-- very very weird, must be cache problems. 30 | -DDES_UNROLL -DDES_RISC1 -DDES_PTR 31 | 32 | -------------------------------------------------------------------------------- /crypto/des/typemap: -------------------------------------------------------------------------------- 1 | # 2 | # DES SECTION 3 | # 4 | deschar * T_DESCHARP 5 | des_cblock * T_CBLOCK 6 | des_cblock T_CBLOCK 7 | des_key_schedule T_SCHEDULE 8 | des_key_schedule * T_SCHEDULE 9 | 10 | INPUT 11 | T_CBLOCK 12 | $var=(des_cblock *)SvPV($arg,len); 13 | if (len < DES_KEY_SZ) 14 | { 15 | croak(\"$var needs to be at least %u bytes long\",DES_KEY_SZ); 16 | } 17 | 18 | T_SCHEDULE 19 | $var=(des_key_schedule *)SvPV($arg,len); 20 | if (len < DES_SCHEDULE_SZ) 21 | { 22 | croak(\"$var needs to be at least %u bytes long\", 23 | DES_SCHEDULE_SZ); 24 | } 25 | 26 | OUTPUT 27 | T_CBLOCK 28 | sv_setpvn($arg,(char *)$var,DES_KEY_SZ); 29 | 30 | T_SCHEDULE 31 | sv_setpvn($arg,(char *)$var,DES_SCHEDULE_SZ); 32 | 33 | T_DESCHARP 34 | sv_setpvn($arg,(char *)$var,len); 35 | -------------------------------------------------------------------------------- /crypto/dh/dh1024.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIGHAoGBAJf2QmHKtQXdKCjhPx1ottPb0PMTBH9A6FbaWMsTuKG/K3g6TG1Z1fkq 3 | /Gz/PWk/eLI9TzFgqVAuPvr3q14a1aZeVUMTgo2oO5/y2UHe6VaJ+trqCTat3xlx 4 | /mNbIK9HA2RgPC3gWfVLZQrY+gz3ASHHR5nXWHEyvpuZm7m3h+irAgEC 5 | -----END DH PARAMETERS----- 6 | -------------------------------------------------------------------------------- /crypto/dh/dh192.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MB4CGQDUoLoCULb9LsYm5+/WN992xxbiLQlEuIsCAQM= 3 | -----END DH PARAMETERS----- 4 | -------------------------------------------------------------------------------- /crypto/dh/dh2048.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEA7ZKJNYJFVcs7+6J2WmkEYb8h86tT0s0h2v94GRFS8Q7B4lW9aG9o 3 | AFO5Imov5Jo0H2XMWTKKvbHbSe3fpxJmw/0hBHAY8H/W91hRGXKCeyKpNBgdL8sh 4 | z22SrkO2qCnHJ6PLAMXy5fsKpFmFor2tRfCzrfnggTXu2YOzzK7q62bmqVdmufEo 5 | pT8igNcLpvZxk5uBDvhakObMym9mX3rAEBoe8PwttggMYiiw7NuJKO4MqD1llGkW 6 | aVM8U2ATsCun1IKHrRxynkE1/MJ86VHeYYX8GZt2YA8z+GuzylIOKcMH6JAWzMwA 7 | Gbatw6QwizOhr9iMjZ0B26TE3X8LvW84wwIBAg== 8 | -----END DH PARAMETERS----- 9 | -----BEGIN DH PARAMETERS----- 10 | MIIBCAKCAQEArtA3w73zP6Lu3EOQtwogiXt3AXXpuS6yD4BhzNS1pZFyPHk0/an5 11 | 8ydEkPhQZHKDW+BZJxxPLANaTudWo2YT8TgtvUdN6KSgMiEi6McwqDw+SADuvW+F 12 | SKUYFxG6VFIxyEP6xBdf+vhJxEDbRG2EYsHDRRtJ76gp9cSKTHusf2R+4AAVGqnt 13 | gRAbNqtcOar/7FSj+Pl8G3v0Bty0LcCSpbqgYlnv6z+rErQmmC6PPvSz97TDMCok 14 | yKpCE9hFA1zkqK3TH4FmFvGeIaXJUIBZf4mArWuBTjWFW3nmhESRUn1VK3K3x42N 15 | a5k6c2+EhrMFiLjxuH6JZoqL0/E93FF9SwIBAg== 16 | -----END DH PARAMETERS----- 17 | -------------------------------------------------------------------------------- /crypto/dh/dh4096.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIICCAKCAgEA/urRnb6vkPYc/KEGXWnbCIOaKitq7ySIq9dTH7s+Ri59zs77zty7 3 | vfVlSe6VFTBWgYjD2XKUFmtqq6CqXMhVX5ElUDoYDpAyTH85xqNFLzFC7nKrff/H 4 | TFKNttp22cZE9V0IPpzedPfnQkE7aUdmF9JnDyv21Z/818O93u1B4r0szdnmEvEF 5 | bKuIxEHX+bp0ZR7RqE1AeifXGJX3d6tsd2PMAObxwwsv55RGkn50vHO4QxtTARr1 6 | rRUV5j3B3oPMgC7Offxx+98Xn45B1/G0Prp11anDsR1PGwtaCYipqsvMwQUSJtyE 7 | EOQWk+yFkeMe4vWv367eEi0Sd/wnC+TSXBE3pYvpYerJ8n1MceI5GQTdarJ77OW9 8 | bGTHmxRsLSCM1jpLdPja5jjb4siAa6EHc4qN9c/iFKS3PQPJEnX7pXKBRs5f7AF3 9 | W3RIGt+G9IVNZfXaS7Z/iCpgzgvKCs0VeqN38QsJGtC1aIkwOeyjPNy2G6jJ4yqH 10 | ovXYt/0mc00vCWeSNS1wren0pR2EiLxX0ypjjgsU1mk/Z3b/+zVf7fZSIB+nDLjb 11 | NPtUlJCVGnAeBK1J1nG3TQicqowOXoM6ISkdaXj5GPJdXHab2+S7cqhKGv5qC7rR 12 | jT6sx7RUr0CNTxzLI7muV2/a4tGmj0PSdXQdsZ7tw7gbXlaWT1+MM2MCAQI= 13 | -----END DH PARAMETERS----- 14 | 15 | -------------------------------------------------------------------------------- /crypto/dh/dh512.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MEYCQQDaWDwW2YUiidDkr3VvTMqS3UvlM7gE+w/tlO+cikQD7VdGUNNpmdsp13Yn 3 | a6LT1BLiGPTdHghM9tgAPnxHdOgzAgEC 4 | -----END DH PARAMETERS----- 5 | -------------------------------------------------------------------------------- /crypto/dh/dh_depr.c: -------------------------------------------------------------------------------- 1 | /* crypto/dh/dh_depr.c */ 2 | /* ==================================================================== 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | * This product includes cryptographic software written by Eric Young 51 | * (eay@cryptsoft.com). This product includes software written by Tim 52 | * Hudson (tjh@cryptsoft.com). 53 | * 54 | */ 55 | 56 | 57 | /* This file contains deprecated functions as wrappers to the new ones */ 58 | 59 | #include 60 | #include "cryptlib.h" 61 | #include 62 | #include 63 | 64 | static void *dummy=&dummy; 65 | 66 | #ifndef OPENSSL_NO_DEPRECATED 67 | DH *DH_generate_parameters(int prime_len, int generator, 68 | void (*callback)(int,int,void *), void *cb_arg) 69 | { 70 | BN_GENCB cb; 71 | DH *ret=NULL; 72 | 73 | if((ret=DH_new()) == NULL) 74 | return NULL; 75 | 76 | BN_GENCB_set_old(&cb, callback, cb_arg); 77 | 78 | if(DH_generate_parameters_ex(ret, prime_len, generator, &cb)) 79 | return ret; 80 | DH_free(ret); 81 | return NULL; 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /crypto/dh/example: -------------------------------------------------------------------------------- 1 | From owner-cypherpunks@toad.com Mon Sep 25 10:50:51 1995 2 | Received: from minbne.mincom.oz.au by orb.mincom.oz.au with SMTP id AA10562 3 | (5.65c/IDA-1.4.4 for eay); Wed, 27 Sep 1995 19:41:55 +1000 4 | Received: by minbne.mincom.oz.au id AA19958 5 | (5.65c/IDA-1.4.4 for eay@orb.mincom.oz.au); Wed, 27 Sep 1995 19:34:59 +1000 6 | Received: from relay3.UU.NET by bunyip.cc.uq.oz.au with SMTP (PP); 7 | Wed, 27 Sep 1995 19:13:05 +1000 8 | Received: from toad.com by relay3.UU.NET with SMTP id QQzizb16156; 9 | Wed, 27 Sep 1995 04:48:46 -0400 10 | Received: by toad.com id AA07905; Tue, 26 Sep 95 06:31:45 PDT 11 | Received: from by toad.com id AB07851; Tue, 26 Sep 95 06:31:40 PDT 12 | Received: from servo.qualcomm.com (servo.qualcomm.com [129.46.128.14]) 13 | by cygnus.com (8.6.12/8.6.9) with ESMTP id RAA18442 14 | for ; Mon, 25 Sep 1995 17:52:47 -0700 15 | Received: (karn@localhost) by servo.qualcomm.com (8.6.12/QC-BSD-2.5.1) 16 | id RAA14732; Mon, 25 Sep 1995 17:50:51 -0700 17 | Date: Mon, 25 Sep 1995 17:50:51 -0700 18 | From: Phil Karn 19 | Message-Id: <199509260050.RAA14732@servo.qualcomm.com> 20 | To: cypherpunks@toad.com, ipsec-dev@eit.com 21 | Subject: Primality verification needed 22 | Sender: owner-cypherpunks@toad.com 23 | Precedence: bulk 24 | Status: RO 25 | X-Status: 26 | 27 | Hi. I've generated a 2047-bit "strong" prime number that I would like to 28 | use with Diffie-Hellman key exchange. I assert that not only is this number 29 | 'p' prime, but so is (p-1)/2. 30 | 31 | I've used the mpz_probab_prime() function in the Gnu Math Package (GMP) version 32 | 1.3.2 to test this number. This function uses the Miller-Rabin primality test. 33 | However, to increase my confidence that this number really is a strong prime, 34 | I'd like to ask others to confirm it with other tests. Here's the number in hex: 35 | 36 | 72a925f760b2f954ed287f1b0953f3e6aef92e456172f9fe86fdd8822241b9c9788fbc289982743e 37 | fbcd2ccf062b242d7a567ba8bbb40d79bca7b8e0b6c05f835a5b938d985816bc648985adcff5402a 38 | a76756b36c845a840a1d059ce02707e19cf47af0b5a882f32315c19d1b86a56c5389c5e9bee16b65 39 | fde7b1a8d74a7675de9b707d4c5a4633c0290c95ff30a605aeb7ae864ff48370f13cf01d49adb9f2 40 | 3d19a439f753ee7703cf342d87f431105c843c78ca4df639931f3458fae8a94d1687e99a76ed99d0 41 | ba87189f42fd31ad8262c54a8cf5914ae6c28c540d714a5f6087a171fb74f4814c6f968d72386ef3 42 | 56a05180c3bec7ddd5ef6fe76b1f717b 43 | 44 | The generator, g, for this prime is 2. 45 | 46 | Thanks! 47 | 48 | Phil Karn 49 | 50 | 51 | -------------------------------------------------------------------------------- /crypto/dh/generate: -------------------------------------------------------------------------------- 1 | From: stewarts@ix.netcom.com (Bill Stewart) 2 | Newsgroups: sci.crypt 3 | Subject: Re: Diffie-Hellman key exchange 4 | Date: Wed, 11 Oct 1995 23:08:28 GMT 5 | Organization: Freelance Information Architect 6 | Lines: 32 7 | Message-ID: <45hir2$7l8@ixnews7.ix.netcom.com> 8 | References: <458rhn$76m$1@mhadf.production.compuserve.com> 9 | NNTP-Posting-Host: ix-pl4-16.ix.netcom.com 10 | X-NETCOM-Date: Wed Oct 11 4:09:22 PM PDT 1995 11 | X-Newsreader: Forte Free Agent 1.0.82 12 | 13 | Kent Briggs <72124.3234@CompuServe.COM> wrote: 14 | 15 | >I have a copy of the 1976 IEEE article describing the 16 | >Diffie-Hellman public key exchange algorithm: y=a^x mod q. I'm 17 | >looking for sources that give examples of secure a,q pairs and 18 | >possible some source code that I could examine. 19 | 20 | q should be prime, and ideally should be a "strong prime", 21 | which means it's of the form 2n+1 where n is also prime. 22 | q also needs to be long enough to prevent the attacks LaMacchia and 23 | Odlyzko described (some variant on a factoring attack which generates 24 | a large pile of simultaneous equations and then solves them); 25 | long enough is about the same size as factoring, so 512 bits may not 26 | be secure enough for most applications. (The 192 bits used by 27 | "secure NFS" was certainly not long enough.) 28 | 29 | a should be a generator for q, which means it needs to be 30 | relatively prime to q-1. Usually a small prime like 2, 3 or 5 will 31 | work. 32 | 33 | .... 34 | 35 | Date: Tue, 26 Sep 1995 13:52:36 MST 36 | From: "Richard Schroeppel" 37 | To: karn 38 | Cc: ho@cs.arizona.edu 39 | Subject: random large primes 40 | 41 | Since your prime is really random, proving it is hard. 42 | My personal limit on rigorously proved primes is ~350 digits. 43 | If you really want a proof, we should talk to Francois Morain, 44 | or the Australian group. 45 | 46 | If you want 2 to be a generator (mod P), then you need it 47 | to be a non-square. If (P-1)/2 is also prime, then 48 | non-square == primitive-root for bases << P. 49 | 50 | In the case at hand, this means 2 is a generator iff P = 11 (mod 24). 51 | If you want this, you should restrict your sieve accordingly. 52 | 53 | 3 is a generator iff P = 5 (mod 12). 54 | 55 | 5 is a generator iff P = 3 or 7 (mod 10). 56 | 57 | 2 is perfectly usable as a base even if it's a non-generator, since 58 | it still covers half the space of possible residues. And an 59 | eavesdropper can always determine the low-bit of your exponent for 60 | a generator anyway. 61 | 62 | Rich rcs@cs.arizona.edu 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /crypto/dsa/README: -------------------------------------------------------------------------------- 1 | The stuff in here is based on patches supplied to me by 2 | Steven Schoch to do DSS. 3 | I have since modified a them a little but a debt of gratitude 4 | is due for doing the initial work. 5 | -------------------------------------------------------------------------------- /crypto/dsa/dsa_locl.h: -------------------------------------------------------------------------------- 1 | /* ==================================================================== 2 | * Copyright (c) 2007 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 | #include 56 | 57 | int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, 58 | const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len, 59 | unsigned char *seed_out, 60 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); 61 | -------------------------------------------------------------------------------- /crypto/dsa/fips186a.txt: -------------------------------------------------------------------------------- 1 | The origional FIPE 180 used SHA-0 (FIPS 180) for its appendix 5 2 | examples. This is an updated version that uses SHA-1 (FIPS 180-1) 3 | supplied to me by Wei Dai 4 | -- 5 | APPENDIX 5. EXAMPLE OF THE DSA 6 | 7 | 8 | This appendix is for informational purposes only and is not required to meet 9 | the standard. 10 | 11 | Let L = 512 (size of p). The values in this example are expressed in 12 | hexadecimal notation. The p and q given here were generated by the prime 13 | generation standard described in appendix 2 using the 160-bit SEED: 14 | 15 | d5014e4b 60ef2ba8 b6211b40 62ba3224 e0427dd3 16 | 17 | With this SEED, the algorithm found p and q when the counter was at 105. 18 | 19 | x was generated by the algorithm described in appendix 3, section 3.1, using 20 | the SHA to construct G (as in appendix 3, section 3.3) and a 160-bit XSEED: 21 | 22 | XSEED = 23 | 24 | bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6 25 | 26 | t = 27 | 67452301 EFCDAB89 98BADCFE 10325476 C3D2E1F0 28 | 29 | x = G(t,XSEED) mod q 30 | 31 | k was generated by the algorithm described in appendix 3, section 3.2, using 32 | the SHA to construct G (as in appendix 3, section 3.3) and a 160-bit KSEED: 33 | 34 | KSEED = 35 | 36 | 687a66d9 0648f993 867e121f 4ddf9ddb 01205584 37 | 38 | t = 39 | EFCDAB89 98BADCFE 10325476 C3D2E1F0 67452301 40 | 41 | k = G(t,KSEED) mod q 42 | 43 | Finally: 44 | 45 | h = 2 46 | 47 | p = 48 | 8df2a494 492276aa 3d25759b b06869cb eac0d83a fb8d0cf7 49 | cbb8324f 0d7882e5 d0762fc5 b7210eaf c2e9adac 32ab7aac 50 | 49693dfb f83724c2 ec0736ee 31c80291 51 | 52 | 53 | q = 54 | c773218c 737ec8ee 993b4f2d ed30f48e dace915f 55 | 56 | 57 | g = 58 | 626d0278 39ea0a13 413163a5 5b4cb500 299d5522 956cefcb 59 | 3bff10f3 99ce2c2e 71cb9de5 fa24babf 58e5b795 21925c9c 60 | c42e9f6f 464b088c c572af53 e6d78802 61 | 62 | 63 | x = 64 | 2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614 65 | 66 | 67 | k = 68 | 358dad57 1462710f 50e254cf 1a376b2b deaadfbf 69 | 70 | 71 | kinv = 72 | 73 | 0d516729 8202e49b 4116ac10 4fc3f415 ae52f917 74 | 75 | M = ASCII form of "abc" (See FIPS PUB 180-1, Appendix A) 76 | 77 | SHA(M) = 78 | 79 | a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d 80 | 81 | 82 | y = 83 | 84 | 19131871 d75b1612 a819f29d 78d1b0d7 346f7aa7 7bb62a85 85 | 9bfd6c56 75da9d21 2d3a36ef 1672ef66 0b8c7c25 5cc0ec74 86 | 858fba33 f44c0669 9630a76b 030ee333 87 | 88 | 89 | r = 90 | 8bac1ab6 6410435c b7181f95 b16ab97c 92b341c0 91 | 92 | s = 93 | 41e2345f 1f56df24 58f426d1 55b4ba2d b6dcd8c8 94 | 95 | 96 | w = 97 | 9df4ece5 826be95f ed406d41 b43edc0b 1c18841b 98 | 99 | 100 | u1 = 101 | bf655bd0 46f0b35e c791b004 804afcbb 8ef7d69d 102 | 103 | 104 | u2 = 105 | 821a9263 12e97ade abcc8d08 2b527897 8a2df4b0 106 | 107 | 108 | gu1 mod p = 109 | 110 | 51b1bf86 7888e5f3 af6fb476 9dd016bc fe667a65 aafc2753 111 | 9063bd3d 2b138b4c e02cc0c0 2ec62bb6 7306c63e 4db95bbf 112 | 6f96662a 1987a21b e4ec1071 010b6069 113 | 114 | 115 | yu2 mod p = 116 | 117 | 8b510071 2957e950 50d6b8fd 376a668e 4b0d633c 1e46e665 118 | 5c611a72 e2b28483 be52c74d 4b30de61 a668966e dc307a67 119 | c19441f4 22bf3c34 08aeba1f 0a4dbec7 120 | 121 | v = 122 | 8bac1ab6 6410435c b7181f95 b16ab97c 92b341c0 123 | -------------------------------------------------------------------------------- /crypto/dso/README: -------------------------------------------------------------------------------- 1 | NOTES 2 | ----- 3 | 4 | I've checked out HPUX (well, version 11 at least) and shl_t is 5 | a pointer type so it's safe to use in the way it has been in 6 | dso_dl.c. On the other hand, HPUX11 support dlfcn too and 7 | according to their man page, prefer developers to move to that. 8 | I'll leave Richard's changes there as I guess dso_dl is needed 9 | for HPUX10.20. 10 | 11 | There is now a callback scheme in place where filename conversion can 12 | (a) be turned off altogether through the use of the 13 | DSO_FLAG_NO_NAME_TRANSLATION flag, 14 | (b) be handled by default using the default DSO_METHOD's converter 15 | (c) overriden per-DSO by setting the override callback 16 | (d) a mix of (b) and (c) - eg. implement an override callback that; 17 | (i) checks if we're win32 (if(strstr(dso->meth->name, "win32")....) 18 | and if so, convert "blah" into "blah32.dll" (the default is 19 | otherwise to make it "blah.dll"). 20 | (ii) default to the normal behaviour - we're not on win32, eg. 21 | finish with (return dso->meth->dso_name_converter(dso,NULL)). 22 | 23 | -------------------------------------------------------------------------------- /crypto/ecdsa/ecs_asn1.c: -------------------------------------------------------------------------------- 1 | /* crypto/ecdsa/ecs_asn1.c */ 2 | /* ==================================================================== 3 | * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * licensing@OpenSSL.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | * This product includes cryptographic software written by Eric Young 51 | * (eay@cryptsoft.com). This product includes software written by Tim 52 | * Hudson (tjh@cryptsoft.com). 53 | * 54 | */ 55 | 56 | #include "ecs_locl.h" 57 | #include 58 | #include 59 | 60 | ASN1_SEQUENCE(ECDSA_SIG) = { 61 | ASN1_SIMPLE(ECDSA_SIG, r, CBIGNUM), 62 | ASN1_SIMPLE(ECDSA_SIG, s, CBIGNUM) 63 | } ASN1_SEQUENCE_END(ECDSA_SIG) 64 | 65 | DECLARE_ASN1_FUNCTIONS_const(ECDSA_SIG) 66 | DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECDSA_SIG, ECDSA_SIG) 67 | IMPLEMENT_ASN1_FUNCTIONS_const(ECDSA_SIG) 68 | -------------------------------------------------------------------------------- /crypto/evp/evp_acnf.c: -------------------------------------------------------------------------------- 1 | /* evp_acnf.c */ 2 | /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL 3 | * project 2001. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #include "cryptlib.h" 60 | #include 61 | #include 62 | 63 | 64 | /* Load all algorithms and configure OpenSSL. 65 | * This function is called automatically when 66 | * OPENSSL_LOAD_CONF is set. 67 | */ 68 | 69 | void OPENSSL_add_all_algorithms_conf(void) 70 | { 71 | OPENSSL_add_all_algorithms_noconf(); 72 | OPENSSL_config(NULL); 73 | } 74 | -------------------------------------------------------------------------------- /crypto/evp/m_wp.c: -------------------------------------------------------------------------------- 1 | /* crypto/evp/m_wp.c */ 2 | 3 | #include 4 | #include "cryptlib.h" 5 | 6 | #ifndef OPENSSL_NO_WHIRLPOOL 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "evp_locl.h" 13 | 14 | static int init(EVP_MD_CTX *ctx) 15 | { return WHIRLPOOL_Init(ctx->md_data); } 16 | 17 | static int update(EVP_MD_CTX *ctx,const void *data,size_t count) 18 | { return WHIRLPOOL_Update(ctx->md_data,data,count); } 19 | 20 | static int final(EVP_MD_CTX *ctx,unsigned char *md) 21 | { return WHIRLPOOL_Final(md,ctx->md_data); } 22 | 23 | static const EVP_MD whirlpool_md= 24 | { 25 | NID_whirlpool, 26 | 0, 27 | WHIRLPOOL_DIGEST_LENGTH, 28 | 0, 29 | init, 30 | update, 31 | final, 32 | NULL, 33 | NULL, 34 | EVP_PKEY_NULL_method, 35 | WHIRLPOOL_BBLOCK/8, 36 | sizeof(EVP_MD *)+sizeof(WHIRLPOOL_CTX), 37 | }; 38 | 39 | const EVP_MD *EVP_whirlpool(void) 40 | { 41 | return(&whirlpool_md); 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /crypto/lhash/num.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | #node 10 -> 4 4 | 5 | while (<>) 6 | { 7 | next unless /^node/; 8 | chop; 9 | @a=split; 10 | $num{$a[3]}++; 11 | } 12 | 13 | @a=sort {$a <=> $b } keys %num; 14 | foreach (0 .. $a[$#a]) 15 | { 16 | printf "%4d:%4d\n",$_,$num{$_}; 17 | } 18 | -------------------------------------------------------------------------------- /crypto/md4/md4s.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // gettsc.inl 3 | // 4 | // gives access to the Pentium's (secret) cycle counter 5 | // 6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) 7 | // in 1996-7 and is entered, by him, into the public domain. 8 | 9 | #if defined(__WATCOMC__) 10 | void GetTSC(unsigned long&); 11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; 12 | #elif defined(__GNUC__) 13 | inline 14 | void GetTSC(unsigned long& tsc) 15 | { 16 | asm volatile(".byte 15, 49\n\t" 17 | : "=eax" (tsc) 18 | : 19 | : "%edx", "%eax"); 20 | } 21 | #elif defined(_MSC_VER) 22 | inline 23 | void GetTSC(unsigned long& tsc) 24 | { 25 | unsigned long a; 26 | __asm _emit 0fh 27 | __asm _emit 31h 28 | __asm mov a, eax; 29 | tsc=a; 30 | } 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | extern "C" { 38 | void md4_block_x86(MD4_CTX *ctx, unsigned char *buffer,int num); 39 | } 40 | 41 | void main(int argc,char *argv[]) 42 | { 43 | unsigned char buffer[64*256]; 44 | MD4_CTX ctx; 45 | unsigned long s1,s2,e1,e2; 46 | unsigned char k[16]; 47 | unsigned long data[2]; 48 | unsigned char iv[8]; 49 | int i,num=0,numm; 50 | int j=0; 51 | 52 | if (argc >= 2) 53 | num=atoi(argv[1]); 54 | 55 | if (num == 0) num=16; 56 | if (num > 250) num=16; 57 | numm=num+2; 58 | num*=64; 59 | numm*=64; 60 | 61 | for (j=0; j<6; j++) 62 | { 63 | for (i=0; i<10; i++) /**/ 64 | { 65 | md4_block_x86(&ctx,buffer,numm); 66 | GetTSC(s1); 67 | md4_block_x86(&ctx,buffer,numm); 68 | GetTSC(e1); 69 | GetTSC(s2); 70 | md4_block_x86(&ctx,buffer,num); 71 | GetTSC(e2); 72 | md4_block_x86(&ctx,buffer,num); 73 | } 74 | printf("md4 (%d bytes) %d %d (%.2f)\n",num, 75 | e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /crypto/md5/md5s.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // gettsc.inl 3 | // 4 | // gives access to the Pentium's (secret) cycle counter 5 | // 6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) 7 | // in 1996-7 and is entered, by him, into the public domain. 8 | 9 | #if defined(__WATCOMC__) 10 | void GetTSC(unsigned long&); 11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; 12 | #elif defined(__GNUC__) 13 | inline 14 | void GetTSC(unsigned long& tsc) 15 | { 16 | asm volatile(".byte 15, 49\n\t" 17 | : "=eax" (tsc) 18 | : 19 | : "%edx", "%eax"); 20 | } 21 | #elif defined(_MSC_VER) 22 | inline 23 | void GetTSC(unsigned long& tsc) 24 | { 25 | unsigned long a; 26 | __asm _emit 0fh 27 | __asm _emit 31h 28 | __asm mov a, eax; 29 | tsc=a; 30 | } 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | extern "C" { 38 | void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num); 39 | } 40 | 41 | void main(int argc,char *argv[]) 42 | { 43 | unsigned char buffer[64*256]; 44 | MD5_CTX ctx; 45 | unsigned long s1,s2,e1,e2; 46 | unsigned char k[16]; 47 | unsigned long data[2]; 48 | unsigned char iv[8]; 49 | int i,num=0,numm; 50 | int j=0; 51 | 52 | if (argc >= 2) 53 | num=atoi(argv[1]); 54 | 55 | if (num == 0) num=16; 56 | if (num > 250) num=16; 57 | numm=num+2; 58 | num*=64; 59 | numm*=64; 60 | 61 | for (j=0; j<6; j++) 62 | { 63 | for (i=0; i<10; i++) /**/ 64 | { 65 | md5_block_x86(&ctx,buffer,numm); 66 | GetTSC(s1); 67 | md5_block_x86(&ctx,buffer,numm); 68 | GetTSC(e1); 69 | GetTSC(s2); 70 | md5_block_x86(&ctx,buffer,num); 71 | GetTSC(e2); 72 | md5_block_x86(&ctx,buffer,num); 73 | } 74 | printf("md5 (%d bytes) %d %d (%.2f)\n",num, 75 | e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /crypto/mem_clr.c: -------------------------------------------------------------------------------- 1 | /* crypto/mem_clr.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 3 | * project 2002. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * openssl-core@openssl.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #include 60 | #include 61 | 62 | unsigned char cleanse_ctr = 0; 63 | 64 | void OPENSSL_cleanse(void *ptr, size_t len) 65 | { 66 | unsigned char *p = ptr; 67 | size_t loop = len, ctr = cleanse_ctr; 68 | while(loop--) 69 | { 70 | *(p++) = (unsigned char)ctr; 71 | ctr += (17 + ((size_t)p & 0xF)); 72 | } 73 | p=memchr(ptr, (unsigned char)ctr, len); 74 | if(p) 75 | ctr += (63 + (size_t)p); 76 | cleanse_ctr = (unsigned char)ctr; 77 | } 78 | -------------------------------------------------------------------------------- /crypto/modes/asm/ghashv8-armx-64.S: -------------------------------------------------------------------------------- 1 | #include "arm_arch.h" 2 | 3 | .text 4 | .arch armv8-a+crypto 5 | .global gcm_init_v8 6 | .type gcm_init_v8,%function 7 | .align 4 8 | gcm_init_v8: 9 | ld1 {v17.2d},[x1] //load H 10 | movi v16.16b,#0xe1 11 | ext v3.16b,v17.16b,v17.16b,#8 12 | shl v16.2d,v16.2d,#57 13 | ushr v18.2d,v16.2d,#63 14 | ext v16.16b,v18.16b,v16.16b,#8 //t0=0xc2....01 15 | dup v17.4s,v17.s[1] 16 | ushr v19.2d,v3.2d,#63 17 | sshr v17.4s,v17.4s,#31 //broadcast carry bit 18 | and v19.16b,v19.16b,v16.16b 19 | shl v3.2d,v3.2d,#1 20 | ext v19.16b,v19.16b,v19.16b,#8 21 | and v16.16b,v16.16b,v17.16b 22 | orr v3.16b,v3.16b,v19.16b //H<<<=1 23 | eor v3.16b,v3.16b,v16.16b //twisted H 24 | st1 {v3.2d},[x0] 25 | 26 | ret 27 | .size gcm_init_v8,.-gcm_init_v8 28 | 29 | .global gcm_gmult_v8 30 | .type gcm_gmult_v8,%function 31 | .align 4 32 | gcm_gmult_v8: 33 | ld1 {v17.2d},[x0] //load Xi 34 | movi v19.16b,#0xe1 35 | ld1 {v20.2d},[x1] //load twisted H 36 | shl v19.2d,v19.2d,#57 37 | #ifndef __ARMEB__ 38 | rev64 v17.16b,v17.16b 39 | #endif 40 | ext v21.16b,v20.16b,v20.16b,#8 41 | mov x3,#0 42 | ext v3.16b,v17.16b,v17.16b,#8 43 | mov x12,#0 44 | eor v21.16b,v21.16b,v20.16b //Karatsuba pre-processing 45 | mov x2,x0 46 | b .Lgmult_v8 47 | .size gcm_gmult_v8,.-gcm_gmult_v8 48 | 49 | .global gcm_ghash_v8 50 | .type gcm_ghash_v8,%function 51 | .align 4 52 | gcm_ghash_v8: 53 | ld1 {v0.2d},[x0] //load [rotated] Xi 54 | subs x3,x3,#16 55 | movi v19.16b,#0xe1 56 | mov x12,#16 57 | ld1 {v20.2d},[x1] //load twisted H 58 | csel x12,xzr,x12,eq 59 | ext v0.16b,v0.16b,v0.16b,#8 60 | shl v19.2d,v19.2d,#57 61 | ld1 {v17.2d},[x2],x12 //load [rotated] inp 62 | ext v21.16b,v20.16b,v20.16b,#8 63 | #ifndef __ARMEB__ 64 | rev64 v0.16b,v0.16b 65 | rev64 v17.16b,v17.16b 66 | #endif 67 | eor v21.16b,v21.16b,v20.16b //Karatsuba pre-processing 68 | ext v3.16b,v17.16b,v17.16b,#8 69 | b .Loop_v8 70 | 71 | .align 4 72 | .Loop_v8: 73 | ext v18.16b,v0.16b,v0.16b,#8 74 | eor v3.16b,v3.16b,v0.16b //inp^=Xi 75 | eor v17.16b,v17.16b,v18.16b //v17.16b is rotated inp^Xi 76 | 77 | .Lgmult_v8: 78 | pmull v0.1q,v20.1d,v3.1d //H.lo·Xi.lo 79 | eor v17.16b,v17.16b,v3.16b //Karatsuba pre-processing 80 | pmull2 v2.1q,v20.2d,v3.2d //H.hi·Xi.hi 81 | subs x3,x3,#16 82 | pmull v1.1q,v21.1d,v17.1d //(H.lo+H.hi)·(Xi.lo+Xi.hi) 83 | csel x12,xzr,x12,eq 84 | 85 | ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing 86 | eor v18.16b,v0.16b,v2.16b 87 | eor v1.16b,v1.16b,v17.16b 88 | ld1 {v17.2d},[x2],x12 //load [rotated] inp 89 | eor v1.16b,v1.16b,v18.16b 90 | pmull v18.1q,v0.1d,v19.1d //1st phase 91 | 92 | ins v2.d[0],v1.d[1] 93 | ins v1.d[1],v0.d[0] 94 | #ifndef __ARMEB__ 95 | rev64 v17.16b,v17.16b 96 | #endif 97 | eor v0.16b,v1.16b,v18.16b 98 | ext v3.16b,v17.16b,v17.16b,#8 99 | 100 | ext v18.16b,v0.16b,v0.16b,#8 //2nd phase 101 | pmull v0.1q,v0.1d,v19.1d 102 | eor v18.16b,v18.16b,v2.16b 103 | eor v0.16b,v0.16b,v18.16b 104 | b.hs .Loop_v8 105 | 106 | #ifndef __ARMEB__ 107 | rev64 v0.16b,v0.16b 108 | #endif 109 | ext v0.16b,v0.16b,v0.16b,#8 110 | st1 {v0.2d},[x0] //write out Xi 111 | 112 | ret 113 | .size gcm_ghash_v8,.-gcm_ghash_v8 114 | .asciz "GHASH for ARMv8, CRYPTOGAMS by " 115 | .align 2 116 | -------------------------------------------------------------------------------- /crypto/modes/asm/ghashv8-armx.S: -------------------------------------------------------------------------------- 1 | #include "arm_arch.h" 2 | 3 | .text 4 | .fpu neon 5 | .code 32 6 | .global gcm_init_v8 7 | .type gcm_init_v8,%function 8 | .align 4 9 | gcm_init_v8: 10 | vld1.64 {q9},[r1] @ load H 11 | vmov.i8 q8,#0xe1 12 | vext.8 q3,q9,q9,#8 13 | vshl.i64 q8,q8,#57 14 | vshr.u64 q10,q8,#63 15 | vext.8 q8,q10,q8,#8 @ t0=0xc2....01 16 | vdup.32 q9,d18[1] 17 | vshr.u64 q11,q3,#63 18 | vshr.s32 q9,q9,#31 @ broadcast carry bit 19 | vand q11,q11,q8 20 | vshl.i64 q3,q3,#1 21 | vext.8 q11,q11,q11,#8 22 | vand q8,q8,q9 23 | vorr q3,q3,q11 @ H<<<=1 24 | veor q3,q3,q8 @ twisted H 25 | vst1.64 {q3},[r0] 26 | 27 | bx lr 28 | .size gcm_init_v8,.-gcm_init_v8 29 | 30 | .global gcm_gmult_v8 31 | .type gcm_gmult_v8,%function 32 | .align 4 33 | gcm_gmult_v8: 34 | vld1.64 {q9},[r0] @ load Xi 35 | vmov.i8 q11,#0xe1 36 | vld1.64 {q12},[r1] @ load twisted H 37 | vshl.u64 q11,q11,#57 38 | #ifndef __ARMEB__ 39 | vrev64.8 q9,q9 40 | #endif 41 | vext.8 q13,q12,q12,#8 42 | mov r3,#0 43 | vext.8 q3,q9,q9,#8 44 | mov r12,#0 45 | veor q13,q13,q12 @ Karatsuba pre-processing 46 | mov r2,r0 47 | b .Lgmult_v8 48 | .size gcm_gmult_v8,.-gcm_gmult_v8 49 | 50 | .global gcm_ghash_v8 51 | .type gcm_ghash_v8,%function 52 | .align 4 53 | gcm_ghash_v8: 54 | vld1.64 {q0},[r0] @ load [rotated] Xi 55 | subs r3,r3,#16 56 | vmov.i8 q11,#0xe1 57 | mov r12,#16 58 | vld1.64 {q12},[r1] @ load twisted H 59 | moveq r12,#0 60 | vext.8 q0,q0,q0,#8 61 | vshl.u64 q11,q11,#57 62 | vld1.64 {q9},[r2],r12 @ load [rotated] inp 63 | vext.8 q13,q12,q12,#8 64 | #ifndef __ARMEB__ 65 | vrev64.8 q0,q0 66 | vrev64.8 q9,q9 67 | #endif 68 | veor q13,q13,q12 @ Karatsuba pre-processing 69 | vext.8 q3,q9,q9,#8 70 | b .Loop_v8 71 | 72 | .align 4 73 | .Loop_v8: 74 | vext.8 q10,q0,q0,#8 75 | veor q3,q3,q0 @ inp^=Xi 76 | veor q9,q9,q10 @ q9 is rotated inp^Xi 77 | 78 | .Lgmult_v8: 79 | .byte 0x86,0x0e,0xa8,0xf2 @ pmull q0,q12,q3 @ H.lo·Xi.lo 80 | veor q9,q9,q3 @ Karatsuba pre-processing 81 | .byte 0x87,0x4e,0xa9,0xf2 @ pmull2 q2,q12,q3 @ H.hi·Xi.hi 82 | subs r3,r3,#16 83 | .byte 0xa2,0x2e,0xaa,0xf2 @ pmull q1,q13,q9 @ (H.lo+H.hi)·(Xi.lo+Xi.hi) 84 | moveq r12,#0 85 | 86 | vext.8 q9,q0,q2,#8 @ Karatsuba post-processing 87 | veor q10,q0,q2 88 | veor q1,q1,q9 89 | vld1.64 {q9},[r2],r12 @ load [rotated] inp 90 | veor q1,q1,q10 91 | .byte 0x26,0x4e,0xe0,0xf2 @ pmull q10,q0,q11 @ 1st phase 92 | 93 | vmov d4,d3 @ Xh|Xm - 256-bit result 94 | vmov d3,d0 @ Xm is rotated Xl 95 | #ifndef __ARMEB__ 96 | vrev64.8 q9,q9 97 | #endif 98 | veor q0,q1,q10 99 | vext.8 q3,q9,q9,#8 100 | 101 | vext.8 q10,q0,q0,#8 @ 2nd phase 102 | .byte 0x26,0x0e,0xa0,0xf2 @ pmull q0,q0,q11 103 | veor q10,q10,q2 104 | veor q0,q0,q10 105 | bhs .Loop_v8 106 | 107 | #ifndef __ARMEB__ 108 | vrev64.8 q0,q0 109 | #endif 110 | vext.8 q0,q0,q0,#8 111 | vst1.64 {q0},[r0] @ write out Xi 112 | 113 | bx lr 114 | .size gcm_ghash_v8,.-gcm_ghash_v8 115 | .asciz "GHASH for ARMv8, CRYPTOGAMS by " 116 | .align 2 117 | -------------------------------------------------------------------------------- /crypto/o_dir.h: -------------------------------------------------------------------------------- 1 | /* crypto/o_dir.h -*- mode:C; c-file-style: "eay" -*- */ 2 | /* Copied from Richard Levitte's (richard@levitte.org) LP library. All 3 | * symbol names have been changed, with permission from the author. 4 | */ 5 | 6 | /* $LP: LPlib/source/LPdir.h,v 1.1 2004/06/14 08:56:04 _cvs_levitte Exp $ */ 7 | /* 8 | * Copyright (c) 2004, Richard Levitte 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | 34 | #ifndef O_DIR_H 35 | #define O_DIR_H 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX; 42 | 43 | /* returns NULL on error or end-of-directory. 44 | If it is end-of-directory, errno will be zero */ 45 | const char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory); 46 | /* returns 1 on success, 0 on error */ 47 | int OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* LPDIR_H */ 54 | -------------------------------------------------------------------------------- /crypto/o_init.c: -------------------------------------------------------------------------------- 1 | /* o_init.c */ 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 | * project. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2011 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * openssl-core@openssl.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | */ 54 | 55 | #include 56 | #include 57 | #ifdef OPENSSL_FIPS 58 | #include 59 | #include 60 | #endif 61 | 62 | /* Perform any essential OpenSSL initialization operations. 63 | * Currently only sets FIPS callbacks 64 | */ 65 | 66 | void OPENSSL_init(void) 67 | { 68 | static int done = 0; 69 | if (done) 70 | return; 71 | done = 1; 72 | #ifdef OPENSSL_FIPS 73 | FIPS_set_locking_callbacks(CRYPTO_lock, CRYPTO_add_lock); 74 | FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata); 75 | FIPS_set_malloc_callbacks(CRYPTO_malloc, CRYPTO_free); 76 | RAND_init_fips(); 77 | #endif 78 | #if 0 79 | fprintf(stderr, "Called OPENSSL_init\n"); 80 | #endif 81 | } 82 | 83 | -------------------------------------------------------------------------------- /crypto/o_str.h: -------------------------------------------------------------------------------- 1 | /* crypto/o_str.h -*- mode:C; c-file-style: "eay" -*- */ 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 3 | * project 2003. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2003 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #ifndef HEADER_O_STR_H 60 | #define HEADER_O_STR_H 61 | 62 | #include /* to get size_t */ 63 | 64 | int OPENSSL_strcasecmp(const char *str1, const char *str2); 65 | int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n); 66 | int OPENSSL_memcmp(const void *p1,const void *p2,size_t n); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /crypto/o_time.h: -------------------------------------------------------------------------------- 1 | /* crypto/o_time.h -*- mode:C; c-file-style: "eay" -*- */ 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 3 | * project 2001. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #ifndef HEADER_O_TIME_H 60 | #define HEADER_O_TIME_H 61 | 62 | #include 63 | 64 | struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); 65 | int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /crypto/objects/obj_xref.h: -------------------------------------------------------------------------------- 1 | /* AUTOGENERATED BY objxref.pl, DO NOT EDIT */ 2 | 3 | typedef struct 4 | { 5 | int sign_id; 6 | int hash_id; 7 | int pkey_id; 8 | } nid_triple; 9 | 10 | static const nid_triple sigoid_srt[] = 11 | { 12 | {NID_md2WithRSAEncryption, NID_md2, NID_rsaEncryption}, 13 | {NID_md5WithRSAEncryption, NID_md5, NID_rsaEncryption}, 14 | {NID_shaWithRSAEncryption, NID_sha, NID_rsaEncryption}, 15 | {NID_sha1WithRSAEncryption, NID_sha1, NID_rsaEncryption}, 16 | {NID_dsaWithSHA, NID_sha, NID_dsa}, 17 | {NID_dsaWithSHA1_2, NID_sha1, NID_dsa_2}, 18 | {NID_mdc2WithRSA, NID_mdc2, NID_rsaEncryption}, 19 | {NID_md5WithRSA, NID_md5, NID_rsa}, 20 | {NID_dsaWithSHA1, NID_sha1, NID_dsa}, 21 | {NID_sha1WithRSA, NID_sha1, NID_rsa}, 22 | {NID_ripemd160WithRSA, NID_ripemd160, NID_rsaEncryption}, 23 | {NID_md4WithRSAEncryption, NID_md4, NID_rsaEncryption}, 24 | {NID_ecdsa_with_SHA1, NID_sha1, NID_X9_62_id_ecPublicKey}, 25 | {NID_sha256WithRSAEncryption, NID_sha256, NID_rsaEncryption}, 26 | {NID_sha384WithRSAEncryption, NID_sha384, NID_rsaEncryption}, 27 | {NID_sha512WithRSAEncryption, NID_sha512, NID_rsaEncryption}, 28 | {NID_sha224WithRSAEncryption, NID_sha224, NID_rsaEncryption}, 29 | {NID_ecdsa_with_Recommended, NID_undef, NID_X9_62_id_ecPublicKey}, 30 | {NID_ecdsa_with_Specified, NID_undef, NID_X9_62_id_ecPublicKey}, 31 | {NID_ecdsa_with_SHA224, NID_sha224, NID_X9_62_id_ecPublicKey}, 32 | {NID_ecdsa_with_SHA256, NID_sha256, NID_X9_62_id_ecPublicKey}, 33 | {NID_ecdsa_with_SHA384, NID_sha384, NID_X9_62_id_ecPublicKey}, 34 | {NID_ecdsa_with_SHA512, NID_sha512, NID_X9_62_id_ecPublicKey}, 35 | {NID_dsa_with_SHA224, NID_sha224, NID_dsa}, 36 | {NID_dsa_with_SHA256, NID_sha256, NID_dsa}, 37 | {NID_id_GostR3411_94_with_GostR3410_2001, NID_id_GostR3411_94, NID_id_GostR3410_2001}, 38 | {NID_id_GostR3411_94_with_GostR3410_94, NID_id_GostR3411_94, NID_id_GostR3410_94}, 39 | {NID_id_GostR3411_94_with_GostR3410_94_cc, NID_id_GostR3411_94, NID_id_GostR3410_94_cc}, 40 | {NID_id_GostR3411_94_with_GostR3410_2001_cc, NID_id_GostR3411_94, NID_id_GostR3410_2001_cc}, 41 | {NID_rsassaPss, NID_undef, NID_rsaEncryption}, 42 | }; 43 | 44 | static const nid_triple * const sigoid_srt_xref[] = 45 | { 46 | &sigoid_srt[0], 47 | &sigoid_srt[1], 48 | &sigoid_srt[7], 49 | &sigoid_srt[2], 50 | &sigoid_srt[4], 51 | &sigoid_srt[3], 52 | &sigoid_srt[9], 53 | &sigoid_srt[5], 54 | &sigoid_srt[8], 55 | &sigoid_srt[12], 56 | &sigoid_srt[6], 57 | &sigoid_srt[10], 58 | &sigoid_srt[11], 59 | &sigoid_srt[13], 60 | &sigoid_srt[24], 61 | &sigoid_srt[20], 62 | &sigoid_srt[14], 63 | &sigoid_srt[21], 64 | &sigoid_srt[15], 65 | &sigoid_srt[22], 66 | &sigoid_srt[16], 67 | &sigoid_srt[23], 68 | &sigoid_srt[19], 69 | &sigoid_srt[25], 70 | &sigoid_srt[26], 71 | &sigoid_srt[27], 72 | &sigoid_srt[28], 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /crypto/objects/obj_xref.txt: -------------------------------------------------------------------------------- 1 | # OID cross reference table. 2 | # Links signatures OIDs to their corresponding public key algorithms 3 | # and digests. 4 | 5 | md2WithRSAEncryption md2 rsaEncryption 6 | md5WithRSAEncryption md5 rsaEncryption 7 | shaWithRSAEncryption sha rsaEncryption 8 | sha1WithRSAEncryption sha1 rsaEncryption 9 | md4WithRSAEncryption md4 rsaEncryption 10 | sha256WithRSAEncryption sha256 rsaEncryption 11 | sha384WithRSAEncryption sha384 rsaEncryption 12 | sha512WithRSAEncryption sha512 rsaEncryption 13 | sha224WithRSAEncryption sha224 rsaEncryption 14 | mdc2WithRSA mdc2 rsaEncryption 15 | ripemd160WithRSA ripemd160 rsaEncryption 16 | # For PSS the digest algorithm can vary and depends on the included 17 | # AlgorithmIdentifier. The digest "undef" indicates the public key 18 | # method should handle this explicitly. 19 | rsassaPss undef rsaEncryption 20 | 21 | # Alternative deprecated OIDs. By using the older "rsa" OID this 22 | # type will be recognized by not normally used. 23 | 24 | md5WithRSA md5 rsa 25 | sha1WithRSA sha1 rsa 26 | 27 | dsaWithSHA sha dsa 28 | dsaWithSHA1 sha1 dsa 29 | 30 | dsaWithSHA1_2 sha1 dsa_2 31 | 32 | ecdsa_with_SHA1 sha1 X9_62_id_ecPublicKey 33 | ecdsa_with_SHA224 sha224 X9_62_id_ecPublicKey 34 | ecdsa_with_SHA256 sha256 X9_62_id_ecPublicKey 35 | ecdsa_with_SHA384 sha384 X9_62_id_ecPublicKey 36 | ecdsa_with_SHA512 sha512 X9_62_id_ecPublicKey 37 | ecdsa_with_Recommended undef X9_62_id_ecPublicKey 38 | ecdsa_with_Specified undef X9_62_id_ecPublicKey 39 | 40 | dsa_with_SHA224 sha224 dsa 41 | dsa_with_SHA256 sha256 dsa 42 | 43 | id_GostR3411_94_with_GostR3410_2001 id_GostR3411_94 id_GostR3410_2001 44 | id_GostR3411_94_with_GostR3410_94 id_GostR3411_94 id_GostR3410_94 45 | id_GostR3411_94_with_GostR3410_94_cc id_GostR3411_94 id_GostR3410_94_cc 46 | id_GostR3411_94_with_GostR3410_2001_cc id_GostR3411_94 id_GostR3410_2001_cc 47 | -------------------------------------------------------------------------------- /crypto/objects/objects.README: -------------------------------------------------------------------------------- 1 | objects.txt syntax 2 | ------------------ 3 | 4 | To cover all the naming hacks that were previously in objects.h needed some 5 | kind of hacks in objects.txt. 6 | 7 | The basic syntax for adding an object is as follows: 8 | 9 | 1 2 3 4 : shortName : Long Name 10 | 11 | If the long name doesn't contain spaces, or no short name 12 | exists, the long name is used as basis for the base name 13 | in C. Otherwise, the short name is used. 14 | 15 | The base name (let's call it 'base') will then be used to 16 | create the C macros SN_base, LN_base, NID_base and OBJ_base. 17 | 18 | Note that if the base name contains spaces, dashes or periods, 19 | those will be converte to underscore. 20 | 21 | Then there are some extra commands: 22 | 23 | !Alias foo 1 2 3 4 24 | 25 | This juts makes a name foo for an OID. The C macro 26 | OBJ_foo will be created as a result. 27 | 28 | !Cname foo 29 | 30 | This makes sure that the name foo will be used as base name 31 | in C. 32 | 33 | !module foo 34 | 1 2 3 4 : shortName : Long Name 35 | !global 36 | 37 | The !module command was meant to define a kind of modularity. 38 | What it does is to make sure the module name is prepended 39 | to the base name. !global turns this off. This construction 40 | is not recursive. 41 | 42 | Lines starting with # are treated as comments, as well as any line starting 43 | with ! and not matching the commands above. 44 | 45 | -------------------------------------------------------------------------------- /crypto/objects/objxref.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | use strict; 4 | 5 | my %xref_tbl; 6 | my %oid_tbl; 7 | 8 | my ($mac_file, $xref_file) = @ARGV; 9 | 10 | open(IN, $mac_file) || die "Can't open $mac_file"; 11 | 12 | # Read in OID nid values for a lookup table. 13 | 14 | while () 15 | { 16 | chomp; 17 | my ($name, $num) = /^(\S+)\s+(\S+)$/; 18 | $oid_tbl{$name} = $num; 19 | } 20 | close IN; 21 | 22 | open(IN, $xref_file) || die "Can't open $xref_file"; 23 | 24 | my $ln = 1; 25 | 26 | while () 27 | { 28 | chomp; 29 | s/#.*$//; 30 | next if (/^\S*$/); 31 | my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/; 32 | check_oid($xr); 33 | check_oid($p1); 34 | check_oid($p2); 35 | $xref_tbl{$xr} = [$p1, $p2, $ln]; 36 | } 37 | 38 | my @xrkeys = keys %xref_tbl; 39 | 40 | my @srt1 = sort { $oid_tbl{$a} <=> $oid_tbl{$b}} @xrkeys; 41 | 42 | for(my $i = 0; $i <= $#srt1; $i++) 43 | { 44 | $xref_tbl{$srt1[$i]}[2] = $i; 45 | } 46 | 47 | my @srt2 = sort 48 | { 49 | my$ap1 = $oid_tbl{$xref_tbl{$a}[0]}; 50 | my$bp1 = $oid_tbl{$xref_tbl{$b}[0]}; 51 | return $ap1 - $bp1 if ($ap1 != $bp1); 52 | my$ap2 = $oid_tbl{$xref_tbl{$a}[1]}; 53 | my$bp2 = $oid_tbl{$xref_tbl{$b}[1]}; 54 | 55 | return $ap2 - $bp2; 56 | } @xrkeys; 57 | 58 | my $pname = $0; 59 | 60 | $pname =~ s|^.[^/]/||; 61 | 62 | print < 60 | #include "cryptlib.h" 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | 67 | IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509) 68 | 69 | -------------------------------------------------------------------------------- /crypto/pem/pem_xaux.c: -------------------------------------------------------------------------------- 1 | /* pem_xaux.c */ 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 | * project 2001. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #include 60 | #include "cryptlib.h" 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | 67 | IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX) 68 | IMPLEMENT_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR, PEM_STRING_X509_PAIR, X509_CERT_PAIR) 69 | -------------------------------------------------------------------------------- /crypto/pem/pkcs7.lis: -------------------------------------------------------------------------------- 1 | 21 0:d=0 hl=2 l= 0 cons: univ: SEQUENCE 2 | 00 2:d=0 hl=2 l= 9 prim: univ: OBJECT_IDENTIFIER :pkcs-7-signedData 3 | 21 13:d=0 hl=2 l= 0 cons: cont: 00 # explicit tag 4 | 21 15:d=0 hl=2 l= 0 cons: univ: SEQUENCE 5 | 00 17:d=0 hl=2 l= 1 prim: univ: INTEGER # version 6 | 20 20:d=0 hl=2 l= 0 cons: univ: SET 7 | 21 22:d=0 hl=2 l= 0 cons: univ: SEQUENCE 8 | 00 24:d=0 hl=2 l= 9 prim: univ: OBJECT_IDENTIFIER :pkcs-7-data 9 | 00 35:d=0 hl=2 l= 0 prim: univ: EOC 10 | 21 37:d=0 hl=2 l= 0 cons: cont: 00 # cert tag 11 | 20 39:d=0 hl=4 l=545 cons: univ: SEQUENCE 12 | 20 588:d=0 hl=4 l=524 cons: univ: SEQUENCE 13 | 00 1116:d=0 hl=2 l= 0 prim: univ: EOC 14 | 21 1118:d=0 hl=2 l= 0 cons: cont: 01 # crl tag 15 | 20 1120:d=0 hl=4 l=653 cons: univ: SEQUENCE 16 | 20 1777:d=0 hl=4 l=285 cons: univ: SEQUENCE 17 | 00 2066:d=0 hl=2 l= 0 prim: univ: EOC 18 | 21 2068:d=0 hl=2 l= 0 cons: univ: SET # signers 19 | 00 2070:d=0 hl=2 l= 0 prim: univ: EOC 20 | 00 2072:d=0 hl=2 l= 0 prim: univ: EOC 21 | 00 2074:d=0 hl=2 l= 0 prim: univ: EOC 22 | 00 2076:d=0 hl=2 l= 0 prim: univ: EOC 23 | -------------------------------------------------------------------------------- /crypto/pkcs12/p12_p8d.c: -------------------------------------------------------------------------------- 1 | /* p12_p8d.c */ 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 | * project 2001. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #include 60 | #include "cryptlib.h" 61 | #include 62 | 63 | PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen) 64 | { 65 | return PKCS12_item_decrypt_d2i(p8->algor, ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO), pass, 66 | passlen, p8->digest, 1); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /crypto/rc2/tab.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned char ebits_to_num[256]={ 4 | 0xbd,0x56,0xea,0xf2,0xa2,0xf1,0xac,0x2a, 5 | 0xb0,0x93,0xd1,0x9c,0x1b,0x33,0xfd,0xd0, 6 | 0x30,0x04,0xb6,0xdc,0x7d,0xdf,0x32,0x4b, 7 | 0xf7,0xcb,0x45,0x9b,0x31,0xbb,0x21,0x5a, 8 | 0x41,0x9f,0xe1,0xd9,0x4a,0x4d,0x9e,0xda, 9 | 0xa0,0x68,0x2c,0xc3,0x27,0x5f,0x80,0x36, 10 | 0x3e,0xee,0xfb,0x95,0x1a,0xfe,0xce,0xa8, 11 | 0x34,0xa9,0x13,0xf0,0xa6,0x3f,0xd8,0x0c, 12 | 0x78,0x24,0xaf,0x23,0x52,0xc1,0x67,0x17, 13 | 0xf5,0x66,0x90,0xe7,0xe8,0x07,0xb8,0x60, 14 | 0x48,0xe6,0x1e,0x53,0xf3,0x92,0xa4,0x72, 15 | 0x8c,0x08,0x15,0x6e,0x86,0x00,0x84,0xfa, 16 | 0xf4,0x7f,0x8a,0x42,0x19,0xf6,0xdb,0xcd, 17 | 0x14,0x8d,0x50,0x12,0xba,0x3c,0x06,0x4e, 18 | 0xec,0xb3,0x35,0x11,0xa1,0x88,0x8e,0x2b, 19 | 0x94,0x99,0xb7,0x71,0x74,0xd3,0xe4,0xbf, 20 | 0x3a,0xde,0x96,0x0e,0xbc,0x0a,0xed,0x77, 21 | 0xfc,0x37,0x6b,0x03,0x79,0x89,0x62,0xc6, 22 | 0xd7,0xc0,0xd2,0x7c,0x6a,0x8b,0x22,0xa3, 23 | 0x5b,0x05,0x5d,0x02,0x75,0xd5,0x61,0xe3, 24 | 0x18,0x8f,0x55,0x51,0xad,0x1f,0x0b,0x5e, 25 | 0x85,0xe5,0xc2,0x57,0x63,0xca,0x3d,0x6c, 26 | 0xb4,0xc5,0xcc,0x70,0xb2,0x91,0x59,0x0d, 27 | 0x47,0x20,0xc8,0x4f,0x58,0xe0,0x01,0xe2, 28 | 0x16,0x38,0xc4,0x6f,0x3b,0x0f,0x65,0x46, 29 | 0xbe,0x7e,0x2d,0x7b,0x82,0xf9,0x40,0xb5, 30 | 0x1d,0x73,0xf8,0xeb,0x26,0xc7,0x87,0x97, 31 | 0x25,0x54,0xb1,0x28,0xaa,0x98,0x9d,0xa5, 32 | 0x64,0x6d,0x7a,0xd4,0x10,0x81,0x44,0xef, 33 | 0x49,0xd6,0xae,0x2e,0xdd,0x76,0x5c,0x2f, 34 | 0xa7,0x1c,0xc9,0x09,0x69,0x9a,0x83,0xcf, 35 | 0x29,0x39,0xb9,0xe9,0x4c,0xff,0x43,0xab, 36 | }; 37 | 38 | unsigned char num_to_ebits[256]={ 39 | 0x5d,0xbe,0x9b,0x8b,0x11,0x99,0x6e,0x4d, 40 | 0x59,0xf3,0x85,0xa6,0x3f,0xb7,0x83,0xc5, 41 | 0xe4,0x73,0x6b,0x3a,0x68,0x5a,0xc0,0x47, 42 | 0xa0,0x64,0x34,0x0c,0xf1,0xd0,0x52,0xa5, 43 | 0xb9,0x1e,0x96,0x43,0x41,0xd8,0xd4,0x2c, 44 | 0xdb,0xf8,0x07,0x77,0x2a,0xca,0xeb,0xef, 45 | 0x10,0x1c,0x16,0x0d,0x38,0x72,0x2f,0x89, 46 | 0xc1,0xf9,0x80,0xc4,0x6d,0xae,0x30,0x3d, 47 | 0xce,0x20,0x63,0xfe,0xe6,0x1a,0xc7,0xb8, 48 | 0x50,0xe8,0x24,0x17,0xfc,0x25,0x6f,0xbb, 49 | 0x6a,0xa3,0x44,0x53,0xd9,0xa2,0x01,0xab, 50 | 0xbc,0xb6,0x1f,0x98,0xee,0x9a,0xa7,0x2d, 51 | 0x4f,0x9e,0x8e,0xac,0xe0,0xc6,0x49,0x46, 52 | 0x29,0xf4,0x94,0x8a,0xaf,0xe1,0x5b,0xc3, 53 | 0xb3,0x7b,0x57,0xd1,0x7c,0x9c,0xed,0x87, 54 | 0x40,0x8c,0xe2,0xcb,0x93,0x14,0xc9,0x61, 55 | 0x2e,0xe5,0xcc,0xf6,0x5e,0xa8,0x5c,0xd6, 56 | 0x75,0x8d,0x62,0x95,0x58,0x69,0x76,0xa1, 57 | 0x4a,0xb5,0x55,0x09,0x78,0x33,0x82,0xd7, 58 | 0xdd,0x79,0xf5,0x1b,0x0b,0xde,0x26,0x21, 59 | 0x28,0x74,0x04,0x97,0x56,0xdf,0x3c,0xf0, 60 | 0x37,0x39,0xdc,0xff,0x06,0xa4,0xea,0x42, 61 | 0x08,0xda,0xb4,0x71,0xb0,0xcf,0x12,0x7a, 62 | 0x4e,0xfa,0x6c,0x1d,0x84,0x00,0xc8,0x7f, 63 | 0x91,0x45,0xaa,0x2b,0xc2,0xb1,0x8f,0xd5, 64 | 0xba,0xf2,0xad,0x19,0xb2,0x67,0x36,0xf7, 65 | 0x0f,0x0a,0x92,0x7d,0xe3,0x9d,0xe9,0x90, 66 | 0x3e,0x23,0x27,0x66,0x13,0xec,0x81,0x15, 67 | 0xbd,0x22,0xbf,0x9f,0x7e,0xa9,0x51,0x4b, 68 | 0x4c,0xfb,0x02,0xd3,0x70,0x86,0x31,0xe7, 69 | 0x3b,0x05,0x03,0x54,0x60,0x48,0x65,0x18, 70 | 0xd2,0xcd,0x5f,0x32,0x88,0x0e,0x35,0xfd, 71 | }; 72 | 73 | main() 74 | { 75 | int i,j; 76 | 77 | for (i=0; i<256; i++) 78 | { 79 | for (j=0; j<256; j++) 80 | if (ebits_to_num[j] == i) 81 | { 82 | printf("0x%02x,",j); 83 | break; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /crypto/rc2/version: -------------------------------------------------------------------------------- 1 | 1.1 23/08/96 - eay 2 | Changed RC2_set_key() so it now takes another argument. Many 3 | thanks to Peter Gutmann for the 4 | clarification and origional specification of RC2. BSAFE uses 5 | this last parameter, 'bits'. It the key is 128 bits, BSAFE 6 | also sets this parameter to 128. The old behaviour can be 7 | duplicated by setting this parameter to 1024. 8 | 9 | 1.0 08/04/96 - eay 10 | First version of SSLeay with rc2. This has been written from the spec 11 | posted sci.crypt. It is in this directory under rrc2.doc 12 | I have no test values for any mode other than ecb, my wrappers for the 13 | other modes should be ok since they are basically the same as 14 | the ones taken from idea and des :-). I have implemented them as 15 | little-endian operators. 16 | While rc2 is included because it is used with SSL, I don't know how 17 | far I trust it. It is about the same speed as IDEA and DES. 18 | So if you are paranoid, used Tripple DES, else IDEA. If RC2 19 | does get used more, perhaps more people will look for weaknesses in 20 | it. 21 | 22 | 23 | -------------------------------------------------------------------------------- /crypto/rc4/rc4_locl.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_RC4_LOCL_H 2 | #define HEADER_RC4_LOCL_H 3 | #include 4 | #include 5 | #endif 6 | -------------------------------------------------------------------------------- /crypto/rc4/rc4_utl.c: -------------------------------------------------------------------------------- 1 | /* crypto/rc4/rc4_utl.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2011 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | */ 51 | 52 | #include 53 | #include 54 | #include 55 | 56 | void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) 57 | { 58 | #ifdef OPENSSL_FIPS 59 | fips_cipher_abort(RC4); 60 | #endif 61 | private_RC4_set_key(key, len, data); 62 | } 63 | -------------------------------------------------------------------------------- /crypto/rc4/rc4s.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // gettsc.inl 3 | // 4 | // gives access to the Pentium's (secret) cycle counter 5 | // 6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) 7 | // in 1996-7 and is entered, by him, into the public domain. 8 | 9 | #if defined(__WATCOMC__) 10 | void GetTSC(unsigned long&); 11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; 12 | #elif defined(__GNUC__) 13 | inline 14 | void GetTSC(unsigned long& tsc) 15 | { 16 | asm volatile(".byte 15, 49\n\t" 17 | : "=eax" (tsc) 18 | : 19 | : "%edx", "%eax"); 20 | } 21 | #elif defined(_MSC_VER) 22 | inline 23 | void GetTSC(unsigned long& tsc) 24 | { 25 | unsigned long a; 26 | __asm _emit 0fh 27 | __asm _emit 31h 28 | __asm mov a, eax; 29 | tsc=a; 30 | } 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | void main(int argc,char *argv[]) 38 | { 39 | unsigned char buffer[1024]; 40 | RC4_KEY ctx; 41 | unsigned long s1,s2,e1,e2; 42 | unsigned char k[16]; 43 | unsigned long data[2]; 44 | unsigned char iv[8]; 45 | int i,num=64,numm; 46 | int j=0; 47 | 48 | if (argc >= 2) 49 | num=atoi(argv[1]); 50 | 51 | if (num == 0) num=256; 52 | if (num > 1024-16) num=1024-16; 53 | numm=num+8; 54 | 55 | for (j=0; j<6; j++) 56 | { 57 | for (i=0; i<10; i++) /**/ 58 | { 59 | RC4(&ctx,numm,buffer,buffer); 60 | GetTSC(s1); 61 | RC4(&ctx,numm,buffer,buffer); 62 | GetTSC(e1); 63 | GetTSC(s2); 64 | RC4(&ctx,num,buffer,buffer); 65 | GetTSC(e2); 66 | RC4(&ctx,num,buffer,buffer); 67 | } 68 | 69 | printf("RC4 (%d bytes) %d %d (%d) - 8 bytes\n",num, 70 | e1-s1,e2-s2,(e1-s1)-(e2-s2)); 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /crypto/rsa/rsa_locl.h: -------------------------------------------------------------------------------- 1 | extern int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, 2 | unsigned char *rm, size_t *prm_len, 3 | const unsigned char *sigbuf, size_t siglen, 4 | RSA *rsa); 5 | -------------------------------------------------------------------------------- /crypto/sha/asm/README: -------------------------------------------------------------------------------- 1 | C2.pl works 2 | -------------------------------------------------------------------------------- /crypto/srp/srp_lcl.h: -------------------------------------------------------------------------------- 1 | /* crypto/srp/srp_lcl.h */ 2 | /* Written by Peter Sylvester (peter.sylvester@edelweb.fr) 3 | * for the EdelKey project and contributed to the OpenSSL project 2004. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | #ifndef HEADER_SRP_LCL_H 59 | #define HEADER_SRP_LCL_H 60 | 61 | #include 62 | #include 63 | 64 | #if 0 65 | #define srp_bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \ 66 | fprintf(stderr,"\n");} 67 | #else 68 | #define srp_bn_print(a) 69 | #endif 70 | 71 | 72 | 73 | #ifdef __cplusplus 74 | extern "C" { 75 | #endif 76 | 77 | 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /crypto/ui/ui_compat.c: -------------------------------------------------------------------------------- 1 | /* crypto/ui/ui_compat.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* ==================================================================== 3 | * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * openssl-core@openssl.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | * This product includes cryptographic software written by Eric Young 51 | * (eay@cryptsoft.com). This product includes software written by Tim 52 | * Hudson (tjh@cryptsoft.com). 53 | * 54 | */ 55 | 56 | #include 57 | #include 58 | 59 | int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify) 60 | { 61 | return UI_UTIL_read_pw_string(buf, length, prompt, verify); 62 | } 63 | 64 | int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify) 65 | { 66 | return UI_UTIL_read_pw(buf, buff, size, prompt, verify); 67 | } 68 | -------------------------------------------------------------------------------- /crypto/uid.c: -------------------------------------------------------------------------------- 1 | /* crypto/uid.c */ 2 | /* ==================================================================== 3 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * 3. All advertising materials mentioning features or use of this 18 | * software must display the following acknowledgment: 19 | * "This product includes software developed by the OpenSSL Project 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 21 | * 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 | * endorse or promote products derived from this software without 24 | * prior written permission. For written permission, please contact 25 | * licensing@OpenSSL.org. 26 | * 27 | * 5. Products derived from this software may not be called "OpenSSL" 28 | * nor may "OpenSSL" appear in their names without prior written 29 | * permission of the OpenSSL Project. 30 | * 31 | * 6. Redistributions of any form whatsoever must retain the following 32 | * acknowledgment: 33 | * "This product includes software developed by the OpenSSL Project 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | * ==================================================================== 49 | * 50 | * This product includes cryptographic software written by Eric Young 51 | * (eay@cryptsoft.com). This product includes software written by Tim 52 | * Hudson (tjh@cryptsoft.com). 53 | * 54 | */ 55 | 56 | #include 57 | #include 58 | 59 | #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) 60 | 61 | #include OPENSSL_UNISTD 62 | 63 | int OPENSSL_issetugid(void) 64 | { 65 | return issetugid(); 66 | } 67 | 68 | #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) 69 | 70 | int OPENSSL_issetugid(void) 71 | { 72 | return 0; 73 | } 74 | 75 | #else 76 | 77 | #include OPENSSL_UNISTD 78 | #include 79 | 80 | int OPENSSL_issetugid(void) 81 | { 82 | if (getuid() != geteuid()) return 1; 83 | if (getgid() != getegid()) return 1; 84 | return 0; 85 | } 86 | #endif 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /crypto/x509v3/v3_akeya.c: -------------------------------------------------------------------------------- 1 | /* v3_akey_asn1.c */ 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) 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 60 | #include "cryptlib.h" 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | ASN1_SEQUENCE(AUTHORITY_KEYID) = { 67 | ASN1_IMP_OPT(AUTHORITY_KEYID, keyid, ASN1_OCTET_STRING, 0), 68 | ASN1_IMP_SEQUENCE_OF_OPT(AUTHORITY_KEYID, issuer, GENERAL_NAME, 1), 69 | ASN1_IMP_OPT(AUTHORITY_KEYID, serial, ASN1_INTEGER, 2) 70 | } ASN1_SEQUENCE_END(AUTHORITY_KEYID) 71 | 72 | IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_KEYID) 73 | -------------------------------------------------------------------------------- /crypto/x509v3/v3_pcia.c: -------------------------------------------------------------------------------- 1 | /* v3_pcia.c -*- mode:C; c-file-style: "eay" -*- */ 2 | /* Contributed to the OpenSSL Project 2004 3 | * by Richard Levitte (richard@levitte.org) 4 | */ 5 | /* Copyright (c) 2004 Kungliga Tekniska Högskolan 6 | * (Royal Institute of Technology, Stockholm, Sweden). 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 20 | * 3. Neither the name of the Institute nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | ASN1_SEQUENCE(PROXY_POLICY) = 42 | { 43 | ASN1_SIMPLE(PROXY_POLICY,policyLanguage,ASN1_OBJECT), 44 | ASN1_OPT(PROXY_POLICY,policy,ASN1_OCTET_STRING) 45 | } ASN1_SEQUENCE_END(PROXY_POLICY) 46 | 47 | IMPLEMENT_ASN1_FUNCTIONS(PROXY_POLICY) 48 | 49 | ASN1_SEQUENCE(PROXY_CERT_INFO_EXTENSION) = 50 | { 51 | ASN1_OPT(PROXY_CERT_INFO_EXTENSION,pcPathLengthConstraint,ASN1_INTEGER), 52 | ASN1_SIMPLE(PROXY_CERT_INFO_EXTENSION,proxyPolicy,PROXY_POLICY) 53 | } ASN1_SEQUENCE_END(PROXY_CERT_INFO_EXTENSION) 54 | 55 | IMPLEMENT_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) 56 | -------------------------------------------------------------------------------- /include/openssl/cmac.h: -------------------------------------------------------------------------------- 1 | /* crypto/cmac/cmac.h */ 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 | * project. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | */ 53 | 54 | 55 | #ifndef HEADER_CMAC_H 56 | #define HEADER_CMAC_H 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | #include 63 | 64 | /* Opaque */ 65 | typedef struct CMAC_CTX_st CMAC_CTX; 66 | 67 | CMAC_CTX *CMAC_CTX_new(void); 68 | void CMAC_CTX_cleanup(CMAC_CTX *ctx); 69 | void CMAC_CTX_free(CMAC_CTX *ctx); 70 | EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 71 | int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 72 | 73 | int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 74 | const EVP_CIPHER *cipher, ENGINE *impl); 75 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 76 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 77 | int CMAC_resume(CMAC_CTX *ctx); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif 83 | -------------------------------------------------------------------------------- /include/openssl/comp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HEADER_COMP_H 3 | #define HEADER_COMP_H 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct comp_ctx_st COMP_CTX; 12 | 13 | typedef struct comp_method_st 14 | { 15 | int type; /* NID for compression library */ 16 | const char *name; /* A text string to identify the library */ 17 | int (*init)(COMP_CTX *ctx); 18 | void (*finish)(COMP_CTX *ctx); 19 | int (*compress)(COMP_CTX *ctx, 20 | unsigned char *out, unsigned int olen, 21 | unsigned char *in, unsigned int ilen); 22 | int (*expand)(COMP_CTX *ctx, 23 | unsigned char *out, unsigned int olen, 24 | unsigned char *in, unsigned int ilen); 25 | /* The following two do NOTHING, but are kept for backward compatibility */ 26 | long (*ctrl)(void); 27 | long (*callback_ctrl)(void); 28 | } COMP_METHOD; 29 | 30 | struct comp_ctx_st 31 | { 32 | COMP_METHOD *meth; 33 | unsigned long compress_in; 34 | unsigned long compress_out; 35 | unsigned long expand_in; 36 | unsigned long expand_out; 37 | 38 | CRYPTO_EX_DATA ex_data; 39 | }; 40 | 41 | 42 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 43 | void COMP_CTX_free(COMP_CTX *ctx); 44 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 45 | unsigned char *in, int ilen); 46 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 47 | unsigned char *in, int ilen); 48 | COMP_METHOD *COMP_rle(void ); 49 | COMP_METHOD *COMP_zlib(void ); 50 | void COMP_zlib_cleanup(void); 51 | 52 | #ifdef HEADER_BIO_H 53 | #ifdef ZLIB 54 | BIO_METHOD *BIO_f_zlib(void); 55 | #endif 56 | #endif 57 | 58 | /* BEGIN ERROR CODES */ 59 | /* The following lines are auto generated by the script mkerr.pl. Any changes 60 | * made after this point may be overwritten when the script is next run. 61 | */ 62 | void ERR_load_COMP_strings(void); 63 | 64 | /* Error codes for the COMP functions. */ 65 | 66 | /* Function codes. */ 67 | #define COMP_F_BIO_ZLIB_FLUSH 99 68 | #define COMP_F_BIO_ZLIB_NEW 100 69 | #define COMP_F_BIO_ZLIB_READ 101 70 | #define COMP_F_BIO_ZLIB_WRITE 102 71 | 72 | /* Reason codes. */ 73 | #define COMP_R_ZLIB_DEFLATE_ERROR 99 74 | #define COMP_R_ZLIB_INFLATE_ERROR 100 75 | #define COMP_R_ZLIB_NOT_SUPPORTED 101 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | #endif 81 | -------------------------------------------------------------------------------- /include/openssl/opensslconf.h: -------------------------------------------------------------------------------- 1 | // Auto-generated - DO NOT EDIT! 2 | #ifndef OPENSSL_SYS_TRUSTY 3 | #if defined(__LP64__) 4 | #include "opensslconf-64.h" 5 | #else 6 | #include "opensslconf-32.h" 7 | #endif 8 | #else 9 | #include "opensslconf-trusty.h" 10 | #endif 11 | -------------------------------------------------------------------------------- /include/openssl/pem2.h: -------------------------------------------------------------------------------- 1 | /* ==================================================================== 2 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. All advertising materials mentioning features or use of this 17 | * software must display the following acknowledgment: 18 | * "This product includes software developed by the OpenSSL Project 19 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 20 | * 21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22 | * endorse or promote products derived from this software without 23 | * prior written permission. For written permission, please contact 24 | * licensing@OpenSSL.org. 25 | * 26 | * 5. Products derived from this software may not be called "OpenSSL" 27 | * nor may "OpenSSL" appear in their names without prior written 28 | * permission of the OpenSSL Project. 29 | * 30 | * 6. Redistributions of any form whatsoever must retain the following 31 | * acknowledgment: 32 | * "This product includes software developed by the OpenSSL Project 33 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 34 | * 35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46 | * OF THE POSSIBILITY OF SUCH DAMAGE. 47 | * ==================================================================== 48 | * 49 | * This product includes cryptographic software written by Eric Young 50 | * (eay@cryptsoft.com). This product includes software written by Tim 51 | * Hudson (tjh@cryptsoft.com). 52 | * 53 | */ 54 | 55 | /* 56 | * This header only exists to break a circular dependency between pem and err 57 | * Ben 30 Jan 1999. 58 | */ 59 | 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | 64 | #ifndef HEADER_PEM_H 65 | void ERR_load_PEM_strings(void); 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /openssl.version: -------------------------------------------------------------------------------- 1 | OPENSSL_VERSION=1.0.1l 2 | --------------------------------------------------------------------------------