diff options
| author | beck <> | 2016-09-03 11:33:43 +0000 |
|---|---|---|
| committer | beck <> | 2016-09-03 11:33:43 +0000 |
| commit | bfb40cbd29e3a70915d1708f9660744ebfb3c110 (patch) | |
| tree | bda3f96ee18135da341fa9b72de3608609a4f2b7 | |
| parent | 792b1b7757ae0eebdddba7a0b8601e5c0ae6c579 (diff) | |
| download | openbsd-bfb40cbd29e3a70915d1708f9660744ebfb3c110.tar.gz openbsd-bfb40cbd29e3a70915d1708f9660744ebfb3c110.tar.bz2 openbsd-bfb40cbd29e3a70915d1708f9660744ebfb3c110.zip | |
Remove the libcrypto/crypto directory
41 files changed, 0 insertions, 6330 deletions
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile deleted file mode 100644 index d662aecc24..0000000000 --- a/src/lib/libcrypto/crypto/Makefile +++ /dev/null | |||
| @@ -1,430 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.67 2015/10/19 16:32:37 beck Exp $ | ||
| 2 | |||
| 3 | LIB= crypto | ||
| 4 | |||
| 5 | SSL_SRC= ${.CURDIR}/../../libssl/src | ||
| 6 | LCRYPTO_SRC= ${SSL_SRC}/crypto | ||
| 7 | |||
| 8 | CFLAGS+= -Wall -Wundef -Werror | ||
| 9 | |||
| 10 | .include <bsd.own.mk> # for 'NOPIC' definition | ||
| 11 | .if !defined(NOPIC) | ||
| 12 | CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN | ||
| 13 | .endif | ||
| 14 | |||
| 15 | .if ${MACHINE_ARCH} == "sparc" | ||
| 16 | PICFLAG=-fPIC | ||
| 17 | .endif | ||
| 18 | |||
| 19 | CFLAGS+= -DLIBRESSL_INTERNAL | ||
| 20 | CFLAGS+= -DTERMIOS | ||
| 21 | # Hardware engines | ||
| 22 | CFLAGS+= -DOPENSSL_NO_HW_PADLOCK # XXX enable this? | ||
| 23 | |||
| 24 | CFLAGS+= -I${SSL_SRC} | ||
| 25 | CFLAGS+= -I${LCRYPTO_SRC} | ||
| 26 | CFLAGS+= -I${LCRYPTO_SRC}/modes -I${LCRYPTO_SRC}/asn1 -I${LCRYPTO_SRC}/evp | ||
| 27 | |||
| 28 | # crypto/ | ||
| 29 | SRCS+= cryptlib.c malloc-wrapper.c mem_dbg.c cversion.c ex_data.c cpt_err.c | ||
| 30 | SRCS+= o_time.c o_str.c o_init.c | ||
| 31 | SRCS+= mem_clr.c | ||
| 32 | |||
| 33 | # aes/ | ||
| 34 | SRCS+= aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c | ||
| 35 | SRCS+= aes_ctr.c aes_ige.c aes_wrap.c | ||
| 36 | |||
| 37 | # asn1/ | ||
| 38 | SRCS+= a_object.c a_bitstr.c a_time.c a_int.c a_octet.c | ||
| 39 | SRCS+= a_print.c a_type.c a_dup.c a_d2i_fp.c a_i2d_fp.c | ||
| 40 | SRCS+= a_enum.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c | ||
| 41 | SRCS+= x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_bignum.c | ||
| 42 | SRCS+= x_long.c x_name.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.c | ||
| 43 | SRCS+= x_nx509.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c | ||
| 44 | SRCS+= t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c | ||
| 45 | SRCS+= tasn_new.c tasn_fre.c tasn_enc.c tasn_dec.c tasn_utl.c tasn_typ.c | ||
| 46 | SRCS+= tasn_prn.c ameth_lib.c | ||
| 47 | SRCS+= f_int.c f_string.c n_pkey.c | ||
| 48 | SRCS+= f_enum.c x_pkey.c a_bool.c x_exten.c bio_asn1.c bio_ndef.c asn_mime.c | ||
| 49 | SRCS+= asn1_gen.c asn1_par.c asn1_lib.c asn1_err.c a_bytes.c a_strnid.c | ||
| 50 | SRCS+= evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c asn_moid.c | ||
| 51 | SRCS+= a_set.c | ||
| 52 | SRCS+= a_time_tm.c | ||
| 53 | |||
| 54 | # bf/ | ||
| 55 | SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c | ||
| 56 | |||
| 57 | # bio/ | ||
| 58 | SRCS+= bio_lib.c bio_cb.c bio_err.c | ||
| 59 | SRCS+= bss_mem.c bss_null.c bss_fd.c | ||
| 60 | SRCS+= bss_file.c bss_sock.c bss_conn.c | ||
| 61 | SRCS+= bf_null.c bf_buff.c b_print.c b_dump.c | ||
| 62 | SRCS+= b_posix.c b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c | ||
| 63 | SRCS+= bss_dgram.c | ||
| 64 | |||
| 65 | # bn/ | ||
| 66 | SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c | ||
| 67 | SRCS+= bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c | ||
| 68 | SRCS+= bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c | ||
| 69 | SRCS+= bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c | ||
| 70 | SRCS+= bn_depr.c bn_const.c bn_x931p.c | ||
| 71 | |||
| 72 | # buffer/ | ||
| 73 | SRCS+= buffer.c buf_err.c buf_str.c | ||
| 74 | |||
| 75 | # camellia/ | ||
| 76 | SRCS+= cmll_cfb.c cmll_ctr.c cmll_ecb.c cmll_ofb.c | ||
| 77 | |||
| 78 | # cast/ | ||
| 79 | SRCS+= c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c | ||
| 80 | |||
| 81 | # chacha/ | ||
| 82 | SRCS+= chacha.c | ||
| 83 | |||
| 84 | # cmac/ | ||
| 85 | SRCS+= cmac.c cm_ameth.c cm_pmeth.c | ||
| 86 | |||
| 87 | # cms/ | ||
| 88 | #SRCS+= cms_lib.c cms_asn1.c cms_att.c cms_io.c cms_smime.c cms_err.c | ||
| 89 | #SRCS+= cms_sd.c cms_dd.c cms_cd.c cms_env.c cms_enc.c cms_ess.c | ||
| 90 | #SRCS+= cms_pwri.c | ||
| 91 | |||
| 92 | # comp/ | ||
| 93 | SRCS+= comp_lib.c comp_err.c c_rle.c c_zlib.c | ||
| 94 | |||
| 95 | # conf/ | ||
| 96 | SRCS+= conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c | ||
| 97 | SRCS+= conf_mall.c conf_sap.c | ||
| 98 | |||
| 99 | # des/ | ||
| 100 | SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c | ||
| 101 | SRCS+= ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c | ||
| 102 | SRCS+= fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c | ||
| 103 | SRCS+= qud_cksm.c rand_key.c set_key.c xcbc_enc.c | ||
| 104 | SRCS+= str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c | ||
| 105 | |||
| 106 | # dh/ | ||
| 107 | SRCS+= dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c | ||
| 108 | SRCS+= dh_ameth.c dh_pmeth.c dh_prn.c | ||
| 109 | |||
| 110 | # dsa/ | ||
| 111 | SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c | ||
| 112 | SRCS+= dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c | ||
| 113 | |||
| 114 | # dso/ | ||
| 115 | SRCS+= dso_dlfcn.c dso_err.c dso_lib.c dso_null.c | ||
| 116 | SRCS+= dso_openssl.c | ||
| 117 | |||
| 118 | # ec/ | ||
| 119 | SRCS+= ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c | ||
| 120 | SRCS+= ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c | ||
| 121 | SRCS+= ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c | ||
| 122 | SRCS+= ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c | ||
| 123 | SRCS+= ecp_oct.c ec2_oct.c ec_oct.c | ||
| 124 | |||
| 125 | # ecdh/ | ||
| 126 | SRCS+= ech_lib.c ech_key.c ech_err.c | ||
| 127 | |||
| 128 | # ecdsa/ | ||
| 129 | SRCS+= ecs_lib.c ecs_asn1.c ecs_ossl.c ecs_sign.c ecs_vrf.c ecs_err.c | ||
| 130 | |||
| 131 | # engine/ | ||
| 132 | SRCS+= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c | ||
| 133 | SRCS+= eng_table.c eng_pkey.c eng_fat.c eng_all.c | ||
| 134 | SRCS+= tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c | ||
| 135 | SRCS+= tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c | ||
| 136 | SRCS+= eng_openssl.c eng_cnf.c eng_dyn.c | ||
| 137 | # XXX unnecessary? handled in EVP now... | ||
| 138 | # SRCS+= eng_aesni.c # local addition | ||
| 139 | |||
| 140 | # err/ | ||
| 141 | SRCS+= err.c err_all.c err_prn.c | ||
| 142 | |||
| 143 | # evp/ | ||
| 144 | SRCS+= encode.c digest.c evp_enc.c evp_key.c | ||
| 145 | SRCS+= e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c | ||
| 146 | SRCS+= e_rc4.c e_aes.c names.c | ||
| 147 | SRCS+= e_xcbc_d.c e_rc2.c e_cast.c | ||
| 148 | SRCS+= m_null.c m_md4.c m_md5.c m_sha1.c m_wp.c | ||
| 149 | SRCS+= m_dss.c m_dss1.c m_ripemd.c m_ecdsa.c | ||
| 150 | SRCS+= p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c | ||
| 151 | SRCS+= bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c | ||
| 152 | SRCS+= c_all.c evp_lib.c | ||
| 153 | SRCS+= evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c | ||
| 154 | SRCS+= e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c | ||
| 155 | SRCS+= e_aes_cbc_hmac_sha1.c e_rc4_hmac_md5.c | ||
| 156 | SRCS+= e_chacha.c evp_aead.c e_chacha20poly1305.c | ||
| 157 | SRCS+= e_gost2814789.c m_gost2814789.c m_gostr341194.c m_streebog.c | ||
| 158 | |||
| 159 | # gost/ | ||
| 160 | SRCS+= gost2814789.c gost89_keywrap.c gost89_params.c gost89imit_ameth.c | ||
| 161 | SRCS+= gost89imit_pmeth.c gost_asn1.c gost_err.c gostr341001.c | ||
| 162 | SRCS+= gostr341001_ameth.c gostr341001_key.c gostr341001_params.c | ||
| 163 | SRCS+= gostr341001_pmeth.c gostr341194.c streebog.c | ||
| 164 | |||
| 165 | # hmac/ | ||
| 166 | SRCS+= hmac.c hm_ameth.c hm_pmeth.c | ||
| 167 | |||
| 168 | # idea/ | ||
| 169 | SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c | ||
| 170 | |||
| 171 | # krb5/ | ||
| 172 | SRCS+= krb5_asn.c | ||
| 173 | |||
| 174 | # lhash/ | ||
| 175 | SRCS+= lhash.c lh_stats.c | ||
| 176 | |||
| 177 | # md4/ | ||
| 178 | SRCS+= md4_dgst.c md4_one.c | ||
| 179 | |||
| 180 | # md5/ | ||
| 181 | SRCS+= md5_dgst.c md5_one.c | ||
| 182 | |||
| 183 | # modes/ | ||
| 184 | SRCS+= cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c ccm128.c xts128.c | ||
| 185 | |||
| 186 | # objects/ | ||
| 187 | SRCS+= o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c | ||
| 188 | |||
| 189 | # ocsp/ | ||
| 190 | SRCS+= ocsp_asn.c ocsp_ext.c ocsp_ht.c ocsp_lib.c ocsp_cl.c | ||
| 191 | SRCS+= ocsp_srv.c ocsp_prn.c ocsp_vfy.c ocsp_err.c | ||
| 192 | |||
| 193 | # pem/ | ||
| 194 | SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c | ||
| 195 | SRCS+= pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c pvkfmt.c | ||
| 196 | |||
| 197 | # pkcs12/ | ||
| 198 | SRCS+= p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c | ||
| 199 | SRCS+= p12_init.c p12_key.c p12_kiss.c p12_mutl.c | ||
| 200 | SRCS+= p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c | ||
| 201 | |||
| 202 | # pkcs7/ | ||
| 203 | SRCS+= pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c | ||
| 204 | SRCS+= pk7_mime.c bio_pk7.c | ||
| 205 | |||
| 206 | # poly1305/ | ||
| 207 | SRCS+= poly1305.c | ||
| 208 | |||
| 209 | # rand/ | ||
| 210 | SRCS+= randfile.c rand_lib.c rand_err.c | ||
| 211 | |||
| 212 | # rc2/ | ||
| 213 | SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c | ||
| 214 | |||
| 215 | # ripemd/ | ||
| 216 | SRCS+= rmd_dgst.c rmd_one.c | ||
| 217 | |||
| 218 | # rsa/ | ||
| 219 | SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c | ||
| 220 | SRCS+= rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c | ||
| 221 | SRCS+= rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c | ||
| 222 | SRCS+= rsa_pmeth.c rsa_crpt.c | ||
| 223 | |||
| 224 | # sha/ | ||
| 225 | SRCS+= sha1dgst.c sha1_one.c sha256.c sha512.c | ||
| 226 | |||
| 227 | # stack/ | ||
| 228 | SRCS+= stack.c | ||
| 229 | |||
| 230 | # ts/ | ||
| 231 | SRCS+= ts_err.c ts_req_utils.c ts_req_print.c ts_rsp_utils.c ts_rsp_print.c | ||
| 232 | SRCS+= ts_rsp_sign.c ts_rsp_verify.c ts_verify_ctx.c ts_lib.c ts_conf.c | ||
| 233 | SRCS+= ts_asn1.c | ||
| 234 | |||
| 235 | # txt_db/ | ||
| 236 | SRCS+=txt_db.c | ||
| 237 | |||
| 238 | # ui/ | ||
| 239 | SRCS+= ui_err.c ui_lib.c ui_openssl.c ui_util.c | ||
| 240 | |||
| 241 | # whrlpool/ | ||
| 242 | SRCS+= wp_dgst.c | ||
| 243 | |||
| 244 | # x509/ | ||
| 245 | SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c | ||
| 246 | SRCS+= x509_obj.c x509_req.c x509spki.c x509_vfy.c | ||
| 247 | SRCS+= x509_set.c x509cset.c x509rset.c x509_err.c | ||
| 248 | SRCS+= x509name.c x509_v3.c x509_ext.c x509_att.c | ||
| 249 | SRCS+= x509type.c x509_lu.c x_all.c x509_txt.c | ||
| 250 | SRCS+= x509_trs.c by_file.c by_dir.c by_mem.c x509_vpm.c | ||
| 251 | |||
| 252 | # x509v3/ | ||
| 253 | SRCS+= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c | ||
| 254 | SRCS+= v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c | ||
| 255 | SRCS+= v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c | ||
| 256 | SRCS+= v3_ocsp.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c | ||
| 257 | SRCS+= pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c | ||
| 258 | |||
| 259 | .PATH: ${.CURDIR}/arch/${MACHINE_CPU} \ | ||
| 260 | ${LCRYPTO_SRC} \ | ||
| 261 | ${LCRYPTO_SRC}/aes \ | ||
| 262 | ${LCRYPTO_SRC}/asn1 \ | ||
| 263 | ${LCRYPTO_SRC}/bf \ | ||
| 264 | ${LCRYPTO_SRC}/bio \ | ||
| 265 | ${LCRYPTO_SRC}/bn \ | ||
| 266 | ${LCRYPTO_SRC}/bn/asm \ | ||
| 267 | ${LCRYPTO_SRC}/buffer \ | ||
| 268 | ${LCRYPTO_SRC}/camellia \ | ||
| 269 | ${LCRYPTO_SRC}/cast \ | ||
| 270 | ${LCRYPTO_SRC}/chacha \ | ||
| 271 | ${LCRYPTO_SRC}/cmac \ | ||
| 272 | ${LCRYPTO_SRC}/cms \ | ||
| 273 | ${LCRYPTO_SRC}/comp \ | ||
| 274 | ${LCRYPTO_SRC}/conf \ | ||
| 275 | ${LCRYPTO_SRC}/des \ | ||
| 276 | ${LCRYPTO_SRC}/dh \ | ||
| 277 | ${LCRYPTO_SRC}/dsa \ | ||
| 278 | ${LCRYPTO_SRC}/dso \ | ||
| 279 | ${LCRYPTO_SRC}/ec \ | ||
| 280 | ${LCRYPTO_SRC}/ecdh \ | ||
| 281 | ${LCRYPTO_SRC}/ecdsa \ | ||
| 282 | ${LCRYPTO_SRC}/engine \ | ||
| 283 | ${LCRYPTO_SRC}/err \ | ||
| 284 | ${LCRYPTO_SRC}/evp \ | ||
| 285 | ${LCRYPTO_SRC}/gost \ | ||
| 286 | ${LCRYPTO_SRC}/hmac \ | ||
| 287 | ${LCRYPTO_SRC}/idea \ | ||
| 288 | ${LCRYPTO_SRC}/krb5 \ | ||
| 289 | ${LCRYPTO_SRC}/lhash \ | ||
| 290 | ${LCRYPTO_SRC}/md4 \ | ||
| 291 | ${LCRYPTO_SRC}/md5 \ | ||
| 292 | ${LCRYPTO_SRC}/modes \ | ||
| 293 | ${LCRYPTO_SRC}/objects \ | ||
| 294 | ${LCRYPTO_SRC}/ocsp \ | ||
| 295 | ${LCRYPTO_SRC}/pem \ | ||
| 296 | ${LCRYPTO_SRC}/perlasm \ | ||
| 297 | ${LCRYPTO_SRC}/pkcs12 \ | ||
| 298 | ${LCRYPTO_SRC}/pkcs7 \ | ||
| 299 | ${LCRYPTO_SRC}/poly1305 \ | ||
| 300 | ${LCRYPTO_SRC}/rand \ | ||
| 301 | ${LCRYPTO_SRC}/rc2 \ | ||
| 302 | ${LCRYPTO_SRC}/rc4 \ | ||
| 303 | ${LCRYPTO_SRC}/ripemd \ | ||
| 304 | ${LCRYPTO_SRC}/rsa \ | ||
| 305 | ${LCRYPTO_SRC}/sha \ | ||
| 306 | ${LCRYPTO_SRC}/stack \ | ||
| 307 | ${LCRYPTO_SRC}/threads \ | ||
| 308 | ${LCRYPTO_SRC}/ts \ | ||
| 309 | ${LCRYPTO_SRC}/txt_db \ | ||
| 310 | ${LCRYPTO_SRC}/ui \ | ||
| 311 | ${LCRYPTO_SRC}/whrlpool \ | ||
| 312 | ${LCRYPTO_SRC}/x509 \ | ||
| 313 | ${LCRYPTO_SRC}/x509v3 | ||
| 314 | |||
| 315 | HDRS=\ | ||
| 316 | crypto/aes/aes.h \ | ||
| 317 | crypto/asn1/asn1.h \ | ||
| 318 | crypto/asn1/asn1_mac.h \ | ||
| 319 | crypto/asn1/asn1t.h \ | ||
| 320 | crypto/bf/blowfish.h \ | ||
| 321 | crypto/bio/bio.h \ | ||
| 322 | crypto/bn/bn.h \ | ||
| 323 | crypto/buffer/buffer.h \ | ||
| 324 | crypto/camellia/camellia.h \ | ||
| 325 | crypto/cast/cast.h \ | ||
| 326 | crypto/chacha/chacha.h \ | ||
| 327 | crypto/cmac/cmac.h \ | ||
| 328 | crypto/cms/cms.h \ | ||
| 329 | crypto/comp/comp.h \ | ||
| 330 | crypto/conf/conf.h \ | ||
| 331 | crypto/conf/conf_api.h \ | ||
| 332 | crypto/crypto.h \ | ||
| 333 | crypto/des/des.h \ | ||
| 334 | crypto/dh/dh.h \ | ||
| 335 | crypto/dsa/dsa.h \ | ||
| 336 | crypto/dso/dso.h \ | ||
| 337 | crypto/ec/ec.h \ | ||
| 338 | crypto/ecdh/ecdh.h \ | ||
| 339 | crypto/ecdsa/ecdsa.h \ | ||
| 340 | crypto/engine/engine.h \ | ||
| 341 | crypto/err/err.h \ | ||
| 342 | crypto/evp/evp.h \ | ||
| 343 | crypto/gost/gost.h \ | ||
| 344 | crypto/hmac/hmac.h \ | ||
| 345 | crypto/idea/idea.h \ | ||
| 346 | crypto/krb5/krb5_asn.h \ | ||
| 347 | crypto/lhash/lhash.h \ | ||
| 348 | crypto/md4/md4.h \ | ||
| 349 | crypto/md5/md5.h \ | ||
| 350 | crypto/modes/modes.h \ | ||
| 351 | crypto/objects/objects.h \ | ||
| 352 | crypto/ocsp/ocsp.h \ | ||
| 353 | crypto/opensslfeatures.h \ | ||
| 354 | crypto/opensslv.h \ | ||
| 355 | crypto/ossl_typ.h \ | ||
| 356 | crypto/pem/pem.h \ | ||
| 357 | crypto/pem/pem2.h \ | ||
| 358 | crypto/pkcs12/pkcs12.h \ | ||
| 359 | crypto/pkcs7/pkcs7.h \ | ||
| 360 | crypto/poly1305/poly1305.h \ | ||
| 361 | crypto/rand/rand.h \ | ||
| 362 | crypto/rc2/rc2.h \ | ||
| 363 | crypto/rc4/rc4.h \ | ||
| 364 | crypto/ripemd/ripemd.h \ | ||
| 365 | crypto/rsa/rsa.h \ | ||
| 366 | crypto/sha/sha.h \ | ||
| 367 | crypto/stack/safestack.h \ | ||
| 368 | crypto/stack/stack.h \ | ||
| 369 | crypto/ts/ts.h \ | ||
| 370 | crypto/txt_db/txt_db.h \ | ||
| 371 | crypto/ui/ui.h \ | ||
| 372 | crypto/ui/ui_compat.h \ | ||
| 373 | crypto/whrlpool/whrlpool.h \ | ||
| 374 | crypto/x509/x509.h \ | ||
| 375 | crypto/x509/x509_vfy.h \ | ||
| 376 | crypto/x509v3/x509v3.h | ||
| 377 | |||
| 378 | HDRS_GEN=\ | ||
| 379 | ${.CURDIR}/arch/${MACHINE_CPU}/opensslconf.h \ | ||
| 380 | ${.OBJDIR}/obj_mac.h | ||
| 381 | |||
| 382 | includes: obj_mac.h | ||
| 383 | @test -d ${DESTDIR}/usr/include/openssl || \ | ||
| 384 | mkdir ${DESTDIR}/usr/include/openssl | ||
| 385 | @cd ${SSL_SRC}; \ | ||
| 386 | for i in $(HDRS); do \ | ||
| 387 | j="cmp -s $$i ${DESTDIR}/usr/include/openssl/`basename $$i` || \ | ||
| 388 | ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 $$i\ | ||
| 389 | ${DESTDIR}/usr/include/openssl"; \ | ||
| 390 | echo $$j; \ | ||
| 391 | eval "$$j"; \ | ||
| 392 | done; \ | ||
| 393 | for i in $(HDRS_GEN); do \ | ||
| 394 | j="cmp -s $$i ${DESTDIR}/usr/include/openssl/`basename $$i` || \ | ||
| 395 | ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 $$i\ | ||
| 396 | ${DESTDIR}/usr/include/openssl"; \ | ||
| 397 | echo $$j; \ | ||
| 398 | eval "$$j"; \ | ||
| 399 | done; | ||
| 400 | |||
| 401 | # generated | ||
| 402 | CFLAGS+= -I${.OBJDIR} | ||
| 403 | |||
| 404 | GENERATED=obj_mac.h obj_dat.h | ||
| 405 | CLEANFILES=${GENERATED} obj_mac.num.tmp | ||
| 406 | SSL_OBJECTS=${SSL_SRC}/crypto/objects | ||
| 407 | |||
| 408 | obj_mac.h: ${SSL_OBJECTS}/objects.h ${SSL_OBJECTS}/obj_mac.num ${SSL_OBJECTS}/objects.txt | ||
| 409 | cat ${SSL_OBJECTS}/obj_mac.num > obj_mac.num.tmp | ||
| 410 | /usr/bin/perl ${SSL_OBJECTS}/objects.pl ${SSL_OBJECTS}/objects.txt obj_mac.num.tmp obj_mac.h | ||
| 411 | |||
| 412 | obj_dat.h: obj_mac.h | ||
| 413 | /usr/bin/perl ${SSL_OBJECTS}/obj_dat.pl obj_mac.h obj_dat.h | ||
| 414 | |||
| 415 | .if exists (${.CURDIR}/arch/${MACHINE_CPU}/Makefile.inc) | ||
| 416 | .include "${.CURDIR}/arch/${MACHINE_CPU}/Makefile.inc" | ||
| 417 | .else | ||
| 418 | CFLAGS+=-DOPENSSL_NO_ASM | ||
| 419 | SRCS+= aes_core.c aes_cbc.c | ||
| 420 | SRCS+= bf_enc.c | ||
| 421 | SRCS+= bn_asm.c | ||
| 422 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 423 | SRCS+= des_enc.c fcrypt_b.c | ||
| 424 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 425 | SRCS+= wp_block.c | ||
| 426 | .endif | ||
| 427 | |||
| 428 | all beforedepend: ${GENERATED} | ||
| 429 | |||
| 430 | .include <bsd.lib.mk> | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_aix.h b/src/lib/libcrypto/crypto/arc4random_aix.h deleted file mode 100644 index 3142a1f278..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_aix.h +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_aix.h,v 1.2 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 36 | |||
| 37 | static inline void | ||
| 38 | _getentropy_fail(void) | ||
| 39 | { | ||
| 40 | raise(SIGKILL); | ||
| 41 | } | ||
| 42 | |||
| 43 | static volatile sig_atomic_t _rs_forked; | ||
| 44 | |||
| 45 | static inline void | ||
| 46 | _rs_forkhandler(void) | ||
| 47 | { | ||
| 48 | _rs_forked = 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkdetect(void) | ||
| 53 | { | ||
| 54 | static pid_t _rs_pid = 0; | ||
| 55 | pid_t pid = getpid(); | ||
| 56 | |||
| 57 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
| 58 | _rs_pid = pid; | ||
| 59 | _rs_forked = 0; | ||
| 60 | if (rs) | ||
| 61 | memset(rs, 0, sizeof(*rs)); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | static inline int | ||
| 66 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 67 | { | ||
| 68 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 69 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 70 | return (-1); | ||
| 71 | |||
| 72 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 73 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 74 | munmap(*rsp, sizeof(**rsp)); | ||
| 75 | *rsp = NULL; | ||
| 76 | return (-1); | ||
| 77 | } | ||
| 78 | |||
| 79 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 80 | return (0); | ||
| 81 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_freebsd.h b/src/lib/libcrypto/crypto/arc4random_freebsd.h deleted file mode 100644 index 3faa5e4d31..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_freebsd.h +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_freebsd.h,v 1.4 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | /* | ||
| 36 | * Unfortunately, pthread_atfork() is broken on FreeBSD (at least 9 and 10) if | ||
| 37 | * a program does not link to -lthr. Callbacks registered with pthread_atfork() | ||
| 38 | * appear to fail silently. So, it is not always possible to detect a PID | ||
| 39 | * wraparound. | ||
| 40 | */ | ||
| 41 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 42 | |||
| 43 | static inline void | ||
| 44 | _getentropy_fail(void) | ||
| 45 | { | ||
| 46 | raise(SIGKILL); | ||
| 47 | } | ||
| 48 | |||
| 49 | static volatile sig_atomic_t _rs_forked; | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkhandler(void) | ||
| 53 | { | ||
| 54 | _rs_forked = 1; | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline void | ||
| 58 | _rs_forkdetect(void) | ||
| 59 | { | ||
| 60 | static pid_t _rs_pid = 0; | ||
| 61 | pid_t pid = getpid(); | ||
| 62 | |||
| 63 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
| 64 | _rs_pid = pid; | ||
| 65 | _rs_forked = 0; | ||
| 66 | if (rs) | ||
| 67 | memset(rs, 0, sizeof(*rs)); | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline int | ||
| 72 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 73 | { | ||
| 74 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 75 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 76 | return (-1); | ||
| 77 | |||
| 78 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 79 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 80 | munmap(*rsp, sizeof(**rsp)); | ||
| 81 | *rsp = NULL; | ||
| 82 | return (-1); | ||
| 83 | } | ||
| 84 | |||
| 85 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 86 | return (0); | ||
| 87 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_hpux.h b/src/lib/libcrypto/crypto/arc4random_hpux.h deleted file mode 100644 index 2a3fe8c611..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_hpux.h +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_hpux.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 36 | |||
| 37 | static inline void | ||
| 38 | _getentropy_fail(void) | ||
| 39 | { | ||
| 40 | raise(SIGKILL); | ||
| 41 | } | ||
| 42 | |||
| 43 | static volatile sig_atomic_t _rs_forked; | ||
| 44 | |||
| 45 | static inline void | ||
| 46 | _rs_forkhandler(void) | ||
| 47 | { | ||
| 48 | _rs_forked = 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkdetect(void) | ||
| 53 | { | ||
| 54 | static pid_t _rs_pid = 0; | ||
| 55 | pid_t pid = getpid(); | ||
| 56 | |||
| 57 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
| 58 | _rs_pid = pid; | ||
| 59 | _rs_forked = 0; | ||
| 60 | if (rs) | ||
| 61 | memset(rs, 0, sizeof(*rs)); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | static inline int | ||
| 66 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 67 | { | ||
| 68 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 69 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 70 | return (-1); | ||
| 71 | |||
| 72 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 73 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 74 | munmap(*rsp, sizeof(**rsp)); | ||
| 75 | *rsp = NULL; | ||
| 76 | return (-1); | ||
| 77 | } | ||
| 78 | |||
| 79 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 80 | return (0); | ||
| 81 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_linux.h b/src/lib/libcrypto/crypto/arc4random_linux.h deleted file mode 100644 index 879f966391..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_linux.h +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_linux.h,v 1.11 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | #ifdef __GLIBC__ | ||
| 36 | extern void *__dso_handle; | ||
| 37 | extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *); | ||
| 38 | #define _ARC4_ATFORK(f) __register_atfork(NULL, NULL, (f), __dso_handle) | ||
| 39 | #else | ||
| 40 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 41 | #endif | ||
| 42 | |||
| 43 | static inline void | ||
| 44 | _getentropy_fail(void) | ||
| 45 | { | ||
| 46 | raise(SIGKILL); | ||
| 47 | } | ||
| 48 | |||
| 49 | static volatile sig_atomic_t _rs_forked; | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkhandler(void) | ||
| 53 | { | ||
| 54 | _rs_forked = 1; | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline void | ||
| 58 | _rs_forkdetect(void) | ||
| 59 | { | ||
| 60 | static pid_t _rs_pid = 0; | ||
| 61 | pid_t pid = getpid(); | ||
| 62 | |||
| 63 | /* XXX unusual calls to clone() can bypass checks */ | ||
| 64 | if (_rs_pid == 0 || _rs_pid == 1 || _rs_pid != pid || _rs_forked) { | ||
| 65 | _rs_pid = pid; | ||
| 66 | _rs_forked = 0; | ||
| 67 | if (rs) | ||
| 68 | memset(rs, 0, sizeof(*rs)); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | static inline int | ||
| 73 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 74 | { | ||
| 75 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 76 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 77 | return (-1); | ||
| 78 | |||
| 79 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 80 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 81 | munmap(*rsp, sizeof(**rsp)); | ||
| 82 | *rsp = NULL; | ||
| 83 | return (-1); | ||
| 84 | } | ||
| 85 | |||
| 86 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 87 | return (0); | ||
| 88 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_netbsd.h b/src/lib/libcrypto/crypto/arc4random_netbsd.h deleted file mode 100644 index 611997d54d..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_netbsd.h +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_netbsd.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | /* | ||
| 36 | * Unfortunately, pthread_atfork() is broken on FreeBSD (at least 9 and 10) if | ||
| 37 | * a program does not link to -lthr. Callbacks registered with pthread_atfork() | ||
| 38 | * appear to fail silently. So, it is not always possible to detect a PID | ||
| 39 | * wraparound. | ||
| 40 | */ | ||
| 41 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 42 | |||
| 43 | static inline void | ||
| 44 | _getentropy_fail(void) | ||
| 45 | { | ||
| 46 | raise(SIGKILL); | ||
| 47 | } | ||
| 48 | |||
| 49 | static volatile sig_atomic_t _rs_forked; | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkhandler(void) | ||
| 53 | { | ||
| 54 | _rs_forked = 1; | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline void | ||
| 58 | _rs_forkdetect(void) | ||
| 59 | { | ||
| 60 | static pid_t _rs_pid = 0; | ||
| 61 | pid_t pid = getpid(); | ||
| 62 | |||
| 63 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
| 64 | _rs_pid = pid; | ||
| 65 | _rs_forked = 0; | ||
| 66 | if (rs) | ||
| 67 | memset(rs, 0, sizeof(*rs)); | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline int | ||
| 72 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 73 | { | ||
| 74 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 75 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 76 | return (-1); | ||
| 77 | |||
| 78 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 79 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 80 | munmap(*rsp, sizeof(**rsp)); | ||
| 81 | *rsp = NULL; | ||
| 82 | return (-1); | ||
| 83 | } | ||
| 84 | |||
| 85 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 86 | return (0); | ||
| 87 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_osx.h b/src/lib/libcrypto/crypto/arc4random_osx.h deleted file mode 100644 index 818ae6bbf4..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_osx.h +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_osx.h,v 1.11 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 36 | |||
| 37 | static inline void | ||
| 38 | _getentropy_fail(void) | ||
| 39 | { | ||
| 40 | raise(SIGKILL); | ||
| 41 | } | ||
| 42 | |||
| 43 | static volatile sig_atomic_t _rs_forked; | ||
| 44 | |||
| 45 | static inline void | ||
| 46 | _rs_forkhandler(void) | ||
| 47 | { | ||
| 48 | _rs_forked = 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkdetect(void) | ||
| 53 | { | ||
| 54 | static pid_t _rs_pid = 0; | ||
| 55 | pid_t pid = getpid(); | ||
| 56 | |||
| 57 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
| 58 | _rs_pid = pid; | ||
| 59 | _rs_forked = 0; | ||
| 60 | if (rs) | ||
| 61 | memset(rs, 0, sizeof(*rs)); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | static inline int | ||
| 66 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 67 | { | ||
| 68 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 69 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 70 | return (-1); | ||
| 71 | |||
| 72 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 73 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 74 | munmap(*rsp, sizeof(**rsp)); | ||
| 75 | *rsp = NULL; | ||
| 76 | return (-1); | ||
| 77 | } | ||
| 78 | |||
| 79 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 80 | return (0); | ||
| 81 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_solaris.h b/src/lib/libcrypto/crypto/arc4random_solaris.h deleted file mode 100644 index b1084cda08..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_solaris.h +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_solaris.h,v 1.10 2016/06/30 12:19:51 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <sys/mman.h> | ||
| 27 | |||
| 28 | #include <pthread.h> | ||
| 29 | #include <signal.h> | ||
| 30 | |||
| 31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
| 32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
| 33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
| 34 | |||
| 35 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
| 36 | |||
| 37 | static inline void | ||
| 38 | _getentropy_fail(void) | ||
| 39 | { | ||
| 40 | raise(SIGKILL); | ||
| 41 | } | ||
| 42 | |||
| 43 | static volatile sig_atomic_t _rs_forked; | ||
| 44 | |||
| 45 | static inline void | ||
| 46 | _rs_forkhandler(void) | ||
| 47 | { | ||
| 48 | _rs_forked = 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | static inline void | ||
| 52 | _rs_forkdetect(void) | ||
| 53 | { | ||
| 54 | static pid_t _rs_pid = 0; | ||
| 55 | pid_t pid = getpid(); | ||
| 56 | |||
| 57 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
| 58 | _rs_pid = pid; | ||
| 59 | _rs_forked = 0; | ||
| 60 | if (rs) | ||
| 61 | memset(rs, 0, sizeof(*rs)); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | static inline int | ||
| 66 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 67 | { | ||
| 68 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
| 69 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
| 70 | return (-1); | ||
| 71 | |||
| 72 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
| 73 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 74 | munmap(*rsp, sizeof(**rsp)); | ||
| 75 | *rsp = NULL; | ||
| 76 | return (-1); | ||
| 77 | } | ||
| 78 | |||
| 79 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 80 | return (0); | ||
| 81 | } | ||
diff --git a/src/lib/libcrypto/crypto/arc4random_win.h b/src/lib/libcrypto/crypto/arc4random_win.h deleted file mode 100644 index deec8a1efe..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_win.h +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | /* $OpenBSD: arc4random_win.h,v 1.6 2016/06/30 12:17:29 bcook Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
| 5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
| 6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
| 7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 8 | * | ||
| 9 | * Permission to use, copy, modify, and distribute this software for any | ||
| 10 | * purpose with or without fee is hereby granted, provided that the above | ||
| 11 | * copyright notice and this permission notice appear in all copies. | ||
| 12 | * | ||
| 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Stub functions for portability. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <windows.h> | ||
| 27 | |||
| 28 | static volatile HANDLE arc4random_mtx = NULL; | ||
| 29 | |||
| 30 | /* | ||
| 31 | * Initialize the mutex on the first lock attempt. On collision, each thread | ||
| 32 | * will attempt to allocate a mutex and compare-and-swap it into place as the | ||
| 33 | * global mutex. On failure to swap in the global mutex, the mutex is closed. | ||
| 34 | */ | ||
| 35 | #define _ARC4_LOCK() { \ | ||
| 36 | if (!arc4random_mtx) { \ | ||
| 37 | HANDLE p = CreateMutex(NULL, FALSE, NULL); \ | ||
| 38 | if (InterlockedCompareExchangePointer((void **)&arc4random_mtx, (void *)p, NULL)) \ | ||
| 39 | CloseHandle(p); \ | ||
| 40 | } \ | ||
| 41 | WaitForSingleObject(arc4random_mtx, INFINITE); \ | ||
| 42 | } \ | ||
| 43 | |||
| 44 | #define _ARC4_UNLOCK() ReleaseMutex(arc4random_mtx) | ||
| 45 | |||
| 46 | static inline void | ||
| 47 | _getentropy_fail(void) | ||
| 48 | { | ||
| 49 | TerminateProcess(GetCurrentProcess(), 0); | ||
| 50 | } | ||
| 51 | |||
| 52 | static inline int | ||
| 53 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
| 54 | { | ||
| 55 | *rsp = VirtualAlloc(NULL, sizeof(**rsp), | ||
| 56 | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | ||
| 57 | if (*rsp == NULL) | ||
| 58 | return (-1); | ||
| 59 | |||
| 60 | *rsxp = VirtualAlloc(NULL, sizeof(**rsxp), | ||
| 61 | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | ||
| 62 | if (*rsxp == NULL) { | ||
| 63 | VirtualFree(*rsp, 0, MEM_RELEASE); | ||
| 64 | *rsp = NULL; | ||
| 65 | return (-1); | ||
| 66 | } | ||
| 67 | return (0); | ||
| 68 | } | ||
| 69 | |||
| 70 | static inline void | ||
| 71 | _rs_forkhandler(void) | ||
| 72 | { | ||
| 73 | } | ||
| 74 | |||
| 75 | static inline void | ||
| 76 | _rs_forkdetect(void) | ||
| 77 | { | ||
| 78 | } | ||
diff --git a/src/lib/libcrypto/crypto/arch/alpha/Makefile.inc b/src/lib/libcrypto/crypto/arch/alpha/Makefile.inc deleted file mode 100644 index 82fa9fc1f4..0000000000 --- a/src/lib/libcrypto/crypto/arch/alpha/Makefile.inc +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.3 2014/11/17 20:31:21 miod Exp $ | ||
| 2 | |||
| 3 | # alpha-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_core.c aes_cbc.c | ||
| 7 | # bf | ||
| 8 | SRCS+= bf_enc.c | ||
| 9 | # bn | ||
| 10 | SRCS+= bn_asm.c | ||
| 11 | SSLASM+= bn alpha-mont | ||
| 12 | CFLAGS+= -DOPENSSL_BN_ASM_MONT | ||
| 13 | # camellia | ||
| 14 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 15 | # des | ||
| 16 | SRCS+= des_enc.c fcrypt_b.c | ||
| 17 | # modes | ||
| 18 | CFLAGS+= -DGHASH_ASM | ||
| 19 | SSLASM+= modes ghash-alpha | ||
| 20 | # rc4 | ||
| 21 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 22 | ## rc5 | ||
| 23 | #SRCS+= rc5_enc.c | ||
| 24 | # sha | ||
| 25 | CFLAGS+= -DSHA1_ASM | ||
| 26 | SSLASM+= sha sha1-alpha | ||
| 27 | # whrlpool | ||
| 28 | SRCS+= wp_block.c | ||
| 29 | |||
| 30 | .for dir f in ${SSLASM} | ||
| 31 | SRCS+= ${f}.S | ||
| 32 | GENERATED+=${f}.S | ||
| 33 | ${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl | ||
| 34 | /usr/bin/perl \ | ||
| 35 | ${LCRYPTO_SRC}/${dir}/asm/${f}.pl > ${.TARGET} | ||
| 36 | .endfor | ||
| 37 | |||
| 38 | CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 39 | SRCS+= alphacpuid.S | ||
| 40 | GENERATED+=alphacpuid.S | ||
| 41 | alphacpuid.S: ${LCRYPTO_SRC}/alphacpuid.pl | ||
| 42 | /usr/bin/perl \ | ||
| 43 | ${LCRYPTO_SRC}/alphacpuid.pl > ${.TARGET} | ||
diff --git a/src/lib/libcrypto/crypto/arch/alpha/opensslconf.h b/src/lib/libcrypto/crypto/arch/alpha/opensslconf.h deleted file mode 100644 index a74c6df644..0000000000 --- a/src/lib/libcrypto/crypto/arch/alpha/opensslconf.h +++ /dev/null | |||
| @@ -1,155 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #define RC4_CHUNK unsigned long | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #undef BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #define SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #undef THIRTY_TWO_BIT | ||
| 70 | #endif | ||
| 71 | |||
| 72 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 73 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 74 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 75 | * speedup on x86 */ | ||
| 76 | #undef RC4_INDEX | ||
| 77 | #endif | ||
| 78 | |||
| 79 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 80 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 81 | #define BF_PTR | ||
| 82 | #endif /* HEADER_BF_LOCL_H */ | ||
| 83 | |||
| 84 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 85 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 86 | #ifndef DES_DEFAULT_OPTIONS | ||
| 87 | /* the following is tweaked from a config script, that is why it is a | ||
| 88 | * protected undef/define */ | ||
| 89 | #ifndef DES_PTR | ||
| 90 | #define DES_PTR | ||
| 91 | #endif | ||
| 92 | |||
| 93 | /* This helps C compiler generate the correct code for multiple functional | ||
| 94 | * units. It reduces register dependancies at the expense of 2 more | ||
| 95 | * registers */ | ||
| 96 | #ifndef DES_RISC1 | ||
| 97 | #undef DES_RISC1 | ||
| 98 | #endif | ||
| 99 | |||
| 100 | #ifndef DES_RISC2 | ||
| 101 | #define DES_RISC2 | ||
| 102 | #endif | ||
| 103 | |||
| 104 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 105 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 106 | #endif | ||
| 107 | |||
| 108 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 109 | * Very mucy CPU dependant */ | ||
| 110 | #ifndef DES_UNROLL | ||
| 111 | #undef DES_UNROLL | ||
| 112 | #endif | ||
| 113 | |||
| 114 | /* These default values were supplied by | ||
| 115 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 116 | * They are only used if nothing else has been defined */ | ||
| 117 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 118 | /* Special defines which change the way the code is built depending on the | ||
| 119 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 120 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 121 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 122 | there's no way to tell at compile time what it is you're running on */ | ||
| 123 | |||
| 124 | #if defined( sun ) /* Newer Sparc's */ | ||
| 125 | # define DES_PTR | ||
| 126 | # define DES_RISC1 | ||
| 127 | # define DES_UNROLL | ||
| 128 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 129 | # define DES_PTR | ||
| 130 | # define DES_RISC2 | ||
| 131 | # define DES_UNROLL | ||
| 132 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 133 | # define DES_PTR | ||
| 134 | # define DES_RISC2 | ||
| 135 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 136 | /* Unknown */ | ||
| 137 | #elif defined( __hpux ) /* HP-PA */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __aux ) /* 68K */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 142 | # define DES_UNROLL | ||
| 143 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 144 | # define DES_PTR | ||
| 145 | # define DES_RISC2 | ||
| 146 | # define DES_UNROLL | ||
| 147 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 148 | # define DES_PTR | ||
| 149 | # define DES_RISC1 | ||
| 150 | # define DES_UNROLL | ||
| 151 | #endif /* Systems-specific speed defines */ | ||
| 152 | #endif | ||
| 153 | |||
| 154 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 155 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/amd64/Makefile.inc b/src/lib/libcrypto/crypto/arch/amd64/Makefile.inc deleted file mode 100644 index 081ed3c252..0000000000 --- a/src/lib/libcrypto/crypto/arch/amd64/Makefile.inc +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.5 2015/09/11 14:48:06 miod Exp $ | ||
| 2 | |||
| 3 | # amd64-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | CFLAGS+= -DAES_ASM | ||
| 7 | SSLASM+= aes aes-x86_64 | ||
| 8 | CFLAGS+= -DBSAES_ASM | ||
| 9 | SSLASM+= aes bsaes-x86_64 | ||
| 10 | CFLAGS+= -DVPAES_ASM | ||
| 11 | SSLASM+= aes vpaes-x86_64 | ||
| 12 | SSLASM+= aes aesni-x86_64 | ||
| 13 | SSLASM+= aes aesni-sha1-x86_64 | ||
| 14 | # bf | ||
| 15 | SRCS+= bf_enc.c | ||
| 16 | # bn | ||
| 17 | CFLAGS+= -DOPENSSL_IA32_SSE2 | ||
| 18 | CFLAGS+= -DRSA_ASM | ||
| 19 | SSLASM+= bn modexp512-x86_64 | ||
| 20 | CFLAGS+= -DOPENSSL_BN_ASM_MONT | ||
| 21 | SSLASM+= bn x86_64-mont | ||
| 22 | CFLAGS+= -DOPENSSL_BN_ASM_MONT5 | ||
| 23 | SSLASM+= bn x86_64-mont5 | ||
| 24 | CFLAGS+= -DOPENSSL_BN_ASM_GF2m | ||
| 25 | SSLASM+= bn x86_64-gf2m | ||
| 26 | # camellia | ||
| 27 | SRCS+= cmll_misc.c | ||
| 28 | SSLASM+= camellia cmll-x86_64 | ||
| 29 | # des | ||
| 30 | SRCS+= des_enc.c fcrypt_b.c | ||
| 31 | # md5 | ||
| 32 | CFLAGS+= -DMD5_ASM | ||
| 33 | SSLASM+= md5 md5-x86_64 | ||
| 34 | # modes | ||
| 35 | CFLAGS+= -DGHASH_ASM | ||
| 36 | SSLASM+= modes ghash-x86_64 | ||
| 37 | # rc4 | ||
| 38 | CFLAGS+= -DRC4_MD5_ASM | ||
| 39 | SSLASM+= rc4 rc4-x86_64 | ||
| 40 | SSLASM+= rc4 rc4-md5-x86_64 | ||
| 41 | # ripemd | ||
| 42 | # sha | ||
| 43 | CFLAGS+= -DSHA1_ASM | ||
| 44 | SSLASM+= sha sha1-x86_64 | ||
| 45 | CFLAGS+= -DSHA256_ASM | ||
| 46 | SRCS+= sha256-x86_64.S | ||
| 47 | GENERATED+= sha256-x86_64.S | ||
| 48 | sha256-x86_64.S: ${LCRYPTO_SRC}/sha/asm/sha512-x86_64.pl | ||
| 49 | cd ${LCRYPTO_SRC}/sha/asm ; \ | ||
| 50 | /usr/bin/perl ./sha512-x86_64.pl ${.OBJDIR}/${.TARGET} | ||
| 51 | CFLAGS+= -DSHA512_ASM | ||
| 52 | SRCS+= sha512-x86_64.S | ||
| 53 | GENERATED+= sha512-x86_64.S | ||
| 54 | sha512-x86_64.S: ${LCRYPTO_SRC}/sha/asm/sha512-x86_64.pl | ||
| 55 | cd ${LCRYPTO_SRC}/sha/asm ; \ | ||
| 56 | /usr/bin/perl ./sha512-x86_64.pl ${.OBJDIR}/${.TARGET} | ||
| 57 | # whrlpool | ||
| 58 | CFLAGS+= -DWHIRLPOOL_ASM | ||
| 59 | SSLASM+= whrlpool wp-x86_64 | ||
| 60 | |||
| 61 | .for dir f in ${SSLASM} | ||
| 62 | SRCS+= ${f}.S | ||
| 63 | GENERATED+=${f}.S | ||
| 64 | ${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl | ||
| 65 | (cd ${LCRYPTO_SRC}/${dir} ; \ | ||
| 66 | /usr/bin/perl ./asm/${f}.pl openbsd) > ${.TARGET} | ||
| 67 | .endfor | ||
| 68 | |||
| 69 | CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 70 | SRCS+= x86_64cpuid.S x86_64-gcc.c | ||
| 71 | GENERATED+=x86_64cpuid.S | ||
| 72 | |||
| 73 | x86_64cpuid.S: ${LCRYPTO_SRC}/x86_64cpuid.pl | ||
| 74 | (cd ${LCRYPTO_SRC}/${dir} ; \ | ||
| 75 | /usr/bin/perl ./x86_64cpuid.pl) > ${.TARGET} | ||
diff --git a/src/lib/libcrypto/crypto/arch/amd64/opensslconf.h b/src/lib/libcrypto/crypto/arch/amd64/opensslconf.h deleted file mode 100644 index cbd5d53ca4..0000000000 --- a/src/lib/libcrypto/crypto/arch/amd64/opensslconf.h +++ /dev/null | |||
| @@ -1,152 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #define RC4_CHUNK unsigned long | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #undef BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | #define SIXTY_FOUR_BIT_LONG | ||
| 65 | #undef SIXTY_FOUR_BIT | ||
| 66 | #undef THIRTY_TWO_BIT | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 70 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 71 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 72 | * speedup on x86 */ | ||
| 73 | #undef RC4_INDEX | ||
| 74 | #endif | ||
| 75 | |||
| 76 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 77 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 78 | #undef BF_PTR | ||
| 79 | #endif /* HEADER_BF_LOCL_H */ | ||
| 80 | |||
| 81 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 83 | #ifndef DES_DEFAULT_OPTIONS | ||
| 84 | /* the following is tweaked from a config script, that is why it is a | ||
| 85 | * protected undef/define */ | ||
| 86 | #ifndef DES_PTR | ||
| 87 | #undef DES_PTR | ||
| 88 | #endif | ||
| 89 | |||
| 90 | /* This helps C compiler generate the correct code for multiple functional | ||
| 91 | * units. It reduces register dependancies at the expense of 2 more | ||
| 92 | * registers */ | ||
| 93 | #ifndef DES_RISC1 | ||
| 94 | #undef DES_RISC1 | ||
| 95 | #endif | ||
| 96 | |||
| 97 | #ifndef DES_RISC2 | ||
| 98 | #undef DES_RISC2 | ||
| 99 | #endif | ||
| 100 | |||
| 101 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 102 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 103 | #endif | ||
| 104 | |||
| 105 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 106 | * Very mucy CPU dependant */ | ||
| 107 | #ifndef DES_UNROLL | ||
| 108 | #define DES_UNROLL | ||
| 109 | #endif | ||
| 110 | |||
| 111 | /* These default values were supplied by | ||
| 112 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 113 | * They are only used if nothing else has been defined */ | ||
| 114 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 115 | /* Special defines which change the way the code is built depending on the | ||
| 116 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 117 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 118 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 119 | there's no way to tell at compile time what it is you're running on */ | ||
| 120 | |||
| 121 | #if defined( sun ) /* Newer Sparc's */ | ||
| 122 | # define DES_PTR | ||
| 123 | # define DES_RISC1 | ||
| 124 | # define DES_UNROLL | ||
| 125 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 126 | # define DES_PTR | ||
| 127 | # define DES_RISC2 | ||
| 128 | # define DES_UNROLL | ||
| 129 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 130 | # define DES_PTR | ||
| 131 | # define DES_RISC2 | ||
| 132 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 133 | /* Unknown */ | ||
| 134 | #elif defined( __hpux ) /* HP-PA */ | ||
| 135 | /* Unknown */ | ||
| 136 | #elif defined( __aux ) /* 68K */ | ||
| 137 | /* Unknown */ | ||
| 138 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 139 | # define DES_UNROLL | ||
| 140 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 141 | # define DES_PTR | ||
| 142 | # define DES_RISC2 | ||
| 143 | # define DES_UNROLL | ||
| 144 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 145 | # define DES_PTR | ||
| 146 | # define DES_RISC1 | ||
| 147 | # define DES_UNROLL | ||
| 148 | #endif /* Systems-specific speed defines */ | ||
| 149 | #endif | ||
| 150 | |||
| 151 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 152 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/arm/Makefile.inc b/src/lib/libcrypto/crypto/arch/arm/Makefile.inc deleted file mode 100644 index 22145a79cc..0000000000 --- a/src/lib/libcrypto/crypto/arch/arm/Makefile.inc +++ /dev/null | |||
| @@ -1,47 +0,0 @@ | |||
| 1 | # $oPenBSD: Makefile.inc,v 1.2 2014/05/02 18:21:39 miod Exp $ | ||
| 2 | |||
| 3 | # arm-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_cbc.c | ||
| 7 | CFLAGS+= -DAES_ASM | ||
| 8 | SSLASM+= aes aes-armv4 | ||
| 9 | # bf | ||
| 10 | SRCS+= bf_enc.c | ||
| 11 | # bn | ||
| 12 | SRCS+= bn_asm.c | ||
| 13 | CFLAGS+= -DOPENSSL_BN_ASM_MONT | ||
| 14 | SSLASM+= bn armv4-mont | ||
| 15 | CFLAGS+= -DOPENSSL_BN_ASM_GF2m | ||
| 16 | SSLASM+= bn armv4-gf2m | ||
| 17 | # camellia | ||
| 18 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 19 | # des | ||
| 20 | SRCS+= des_enc.c fcrypt_b.c | ||
| 21 | # modes | ||
| 22 | CFLAGS+= -DGHASH_ASM | ||
| 23 | SSLASM+= modes ghash-armv4 | ||
| 24 | # rc4 | ||
| 25 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 26 | ## rc5 | ||
| 27 | #SRCS+= rc5_enc.c | ||
| 28 | # sha | ||
| 29 | CFLAGS+= -DSHA1_ASM | ||
| 30 | SSLASM+= sha sha1-armv4-large | ||
| 31 | CFLAGS+= -DSHA256_ASM | ||
| 32 | SSLASM+= sha sha256-armv4 | ||
| 33 | CFLAGS+= -DSHA512_ASM | ||
| 34 | SSLASM+= sha sha512-armv4 | ||
| 35 | # whrlpool | ||
| 36 | SRCS+= wp_block.c | ||
| 37 | |||
| 38 | .for dir f in ${SSLASM} | ||
| 39 | SRCS+= ${f}.S | ||
| 40 | GENERATED+=${f}.S | ||
| 41 | ${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl | ||
| 42 | /usr/bin/perl \ | ||
| 43 | ${LCRYPTO_SRC}/${dir}/asm/${f}.pl void ${.TARGET} > ${.TARGET} | ||
| 44 | .endfor | ||
| 45 | |||
| 46 | CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 47 | SRCS+= armv4cpuid.S armcap.c | ||
diff --git a/src/lib/libcrypto/crypto/arch/arm/opensslconf.h b/src/lib/libcrypto/crypto/arch/arm/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/arm/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/hppa/Makefile.inc b/src/lib/libcrypto/crypto/arch/hppa/Makefile.inc deleted file mode 100644 index 0e18de2074..0000000000 --- a/src/lib/libcrypto/crypto/arch/hppa/Makefile.inc +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.9 2015/03/18 05:26:10 miod Exp $ | ||
| 2 | |||
| 3 | # hppa-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_core.c aes_cbc.c | ||
| 7 | CFLAGS+= -DAES_ASM | ||
| 8 | SSLASM+= aes aes-parisc aes-parisc | ||
| 9 | # bf | ||
| 10 | SRCS+= bf_enc.c | ||
| 11 | # bn | ||
| 12 | SRCS+= bn_asm.c | ||
| 13 | SSLASM+= bn parisc-mont parisc-mont | ||
| 14 | CFLAGS+= -DOPENSSL_BN_ASM_MONT -DBN_DIV2W | ||
| 15 | # camellia | ||
| 16 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 17 | # des | ||
| 18 | SRCS+= des_enc.c fcrypt_b.c | ||
| 19 | # modes | ||
| 20 | CFLAGS+= -DGHASH_ASM | ||
| 21 | SSLASM+= modes ghash-parisc ghash-parisc | ||
| 22 | # rc4 | ||
| 23 | .if 0 # about 35% slower than C code | ||
| 24 | SSLASM+= rc4 rc4-parisc rc4-parisc | ||
| 25 | .else | ||
| 26 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 27 | .endif | ||
| 28 | ## rc5 | ||
| 29 | #SRCS+= rc5_enc.c | ||
| 30 | # sha | ||
| 31 | CFLAGS+= -DSHA1_ASM | ||
| 32 | SSLASM+= sha sha1-parisc sha1-parisc | ||
| 33 | CFLAGS+= -DSHA256_ASM | ||
| 34 | SSLASM+= sha sha512-parisc sha256-parisc | ||
| 35 | # whrlpool | ||
| 36 | SRCS+= wp_block.c | ||
| 37 | |||
| 38 | .for dir src dst in ${SSLASM} | ||
| 39 | SRCS+= ${dst}.S | ||
| 40 | GENERATED+=${dst}.S | ||
| 41 | ${dst}.S: ${LCRYPTO_SRC}/${dir}/asm/${src}.pl | ||
| 42 | /usr/bin/perl \ | ||
| 43 | ${LCRYPTO_SRC}/${dir}/asm/${src}.pl 32 ${.TARGET} > ${.TARGET} | ||
| 44 | .endfor | ||
| 45 | |||
| 46 | CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 47 | SRCS+= pariscid.S | ||
| 48 | GENERATED+=pariscid.S | ||
| 49 | pariscid.S: ${LCRYPTO_SRC}/pariscid.pl | ||
| 50 | /usr/bin/perl \ | ||
| 51 | ${LCRYPTO_SRC}/pariscid.pl 32 > ${.TARGET} | ||
diff --git a/src/lib/libcrypto/crypto/arch/hppa/opensslconf.h b/src/lib/libcrypto/crypto/arch/hppa/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/hppa/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/i386/Makefile.inc b/src/lib/libcrypto/crypto/arch/i386/Makefile.inc deleted file mode 100644 index f4e1f36b1c..0000000000 --- a/src/lib/libcrypto/crypto/arch/i386/Makefile.inc +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.4 2014/11/17 20:31:22 miod Exp $ | ||
| 2 | |||
| 3 | # i386-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | CFLAGS+= -DAES_ASM | ||
| 7 | SSLASM+= aes aes-586 | ||
| 8 | CFLAGS+= -DVPAES_ASM | ||
| 9 | SSLASM+= aes vpaes-x86 | ||
| 10 | SSLASM+= aes aesni-x86 | ||
| 11 | # bf | ||
| 12 | SRCS+= bf_cbc.c | ||
| 13 | SSLASM+= bf bf-586 | ||
| 14 | # bn | ||
| 15 | CFLAGS+= -DOPENSSL_IA32_SSE2 | ||
| 16 | CFLAGS+= -DOPENSSL_BN_ASM_PART_WORDS | ||
| 17 | SSLASM+= bn bn-586 | ||
| 18 | SSLASM+= bn co-586 | ||
| 19 | CFLAGS+= -DOPENSSL_BN_ASM_MONT | ||
| 20 | SSLASM+= bn x86-mont | ||
| 21 | CFLAGS+= -DOPENSSL_BN_ASM_GF2m | ||
| 22 | SSLASM+= bn x86-gf2m | ||
| 23 | # camellia | ||
| 24 | SSLASM+= camellia cmll-x86 | ||
| 25 | # des | ||
| 26 | SRCS+= fcrypt_b.c | ||
| 27 | SSLASM+= des des-586 | ||
| 28 | # md5 | ||
| 29 | CFLAGS+= -DMD5_ASM | ||
| 30 | SSLASM+= md5 md5-586 | ||
| 31 | # modes | ||
| 32 | CFLAGS+= -DGHASH_ASM | ||
| 33 | SSLASM+= modes ghash-x86 | ||
| 34 | # rc4 | ||
| 35 | SSLASM+= rc4 rc4-586 | ||
| 36 | # ripemd | ||
| 37 | CFLAGS+= -DRMD160_ASM | ||
| 38 | SSLASM+= ripemd rmd-586 | ||
| 39 | # sha | ||
| 40 | CFLAGS+= -DSHA1_ASM | ||
| 41 | SSLASM+= sha sha1-586 | ||
| 42 | CFLAGS+= -DSHA256_ASM | ||
| 43 | SSLASM+= sha sha256-586 | ||
| 44 | CFLAGS+= -DSHA512_ASM | ||
| 45 | SSLASM+= sha sha512-586 | ||
| 46 | # whrlpool | ||
| 47 | SRCS+= wp_block.c | ||
| 48 | CFLAGS+= -DWHIRLPOOL_ASM | ||
| 49 | SSLASM+= whrlpool wp-mmx | ||
| 50 | |||
| 51 | .for dir f in ${SSLASM} | ||
| 52 | SRCS+= ${f}.S | ||
| 53 | GENERATED+=${f}.S | ||
| 54 | ${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl ${LCRYPTO_SRC}/perlasm/x86gas.pl | ||
| 55 | /usr/bin/perl -I${LCRYPTO_SRC}/perlasm -I${LCRYPTO_SRC}/${dir}/asm \ | ||
| 56 | ${LCRYPTO_SRC}/${dir}/asm/${f}.pl \ | ||
| 57 | openbsd-elf ${CFLAGS} 386 ${PICFLAG} > ${.TARGET} | ||
| 58 | .endfor | ||
| 59 | |||
| 60 | CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 61 | SRCS+= x86cpuid.S | ||
| 62 | GENERATED+=x86cpuid.S | ||
| 63 | |||
| 64 | x86cpuid.S: ${LCRYPTO_SRC}/x86cpuid.pl ${LCRYPTO_SRC}/perlasm/x86gas.pl | ||
| 65 | /usr/bin/perl -I${LCRYPTO_SRC}/perlasm ${LCRYPTO_SRC}/x86cpuid.pl \ | ||
| 66 | openbsd-elf ${CFLAGS} 386 ${PICFLAG} > ${.TARGET} | ||
diff --git a/src/lib/libcrypto/crypto/arch/i386/opensslconf.h b/src/lib/libcrypto/crypto/arch/i386/opensslconf.h deleted file mode 100644 index 37137ff102..0000000000 --- a/src/lib/libcrypto/crypto/arch/i386/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned long | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #define DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #define DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/m88k/opensslconf.h b/src/lib/libcrypto/crypto/arch/m88k/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/m88k/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/mips64/Makefile.inc b/src/lib/libcrypto/crypto/arch/mips64/Makefile.inc deleted file mode 100644 index b6fc8971e7..0000000000 --- a/src/lib/libcrypto/crypto/arch/mips64/Makefile.inc +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.4 2014/12/07 15:45:44 miod Exp $ | ||
| 2 | |||
| 3 | # mips64-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_cbc.c | ||
| 7 | CFLAGS+= -DAES_ASM | ||
| 8 | SSLASM+= aes aes-mips aes-mips | ||
| 9 | # bf | ||
| 10 | SRCS+= bf_enc.c | ||
| 11 | # bn | ||
| 12 | .if ${MACHINE} == "sgi" # because of R4000 support | ||
| 13 | SRCS+= bn_asm.c | ||
| 14 | .else | ||
| 15 | SSLASM+= bn mips bn-mips | ||
| 16 | CFLAGS+= -DBN_DIV3W | ||
| 17 | .endif | ||
| 18 | SSLASM+= bn mips-mont mips-mont | ||
| 19 | CFLAGS+= -DOPENSSL_BN_ASM_MONT | ||
| 20 | # camellia | ||
| 21 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 22 | # des | ||
| 23 | SRCS+= des_enc.c fcrypt_b.c | ||
| 24 | # rc4 | ||
| 25 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 26 | ## rc5 | ||
| 27 | #SRCS+= rc5_enc.c | ||
| 28 | # sha | ||
| 29 | SSLASM+= sha sha1-mips sha1-mips | ||
| 30 | CFLAGS+= -DSHA1_ASM | ||
| 31 | SSLASM+= sha sha512-mips sha256-mips | ||
| 32 | CFLAGS+= -DSHA256_ASM | ||
| 33 | SSLASM+= sha sha512-mips sha512-mips | ||
| 34 | CFLAGS+= -DSHA512_ASM | ||
| 35 | # whrlpool | ||
| 36 | SRCS+= wp_block.c | ||
| 37 | |||
| 38 | .for dir src dst in ${SSLASM} | ||
| 39 | SRCS+= ${dst}.S | ||
| 40 | GENERATED+=${dst}.S | ||
| 41 | ${dst}.S: ${LCRYPTO_SRC}/${dir}/asm/${src}.pl | ||
| 42 | /usr/bin/env CC=${CC} /usr/bin/perl \ | ||
| 43 | ${LCRYPTO_SRC}/${dir}/asm/${src}.pl 64 ${.TARGET} > ${.TARGET} | ||
| 44 | .endfor | ||
diff --git a/src/lib/libcrypto/crypto/arch/mips64/opensslconf.h b/src/lib/libcrypto/crypto/arch/mips64/opensslconf.h deleted file mode 100644 index ef7a679d94..0000000000 --- a/src/lib/libcrypto/crypto/arch/mips64/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #define RC4_CHUNK unsigned long | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #undef BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #define SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #undef THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #undef RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #define BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #define DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #define DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #undef DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/powerpc/Makefile.inc b/src/lib/libcrypto/crypto/arch/powerpc/Makefile.inc deleted file mode 100644 index 46790859b5..0000000000 --- a/src/lib/libcrypto/crypto/arch/powerpc/Makefile.inc +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.2 2014/11/17 20:31:22 miod Exp $ | ||
| 2 | |||
| 3 | # powerpc-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_core.c aes_cbc.c | ||
| 7 | # slower than C code | ||
| 8 | #CFLAGS+= -DAES_ASM | ||
| 9 | #SSLASM+= aes aes-ppc aes-ppc | ||
| 10 | # bf | ||
| 11 | SRCS+= bf_enc.c | ||
| 12 | # bn | ||
| 13 | SSLASM+= bn ppc bn-ppc | ||
| 14 | SSLASM+= bn ppc-mont ppc-mont # bn_mul_mont_int | ||
| 15 | #SSLASM+= bn ppc64-mont ppc64-mont # bn_mul_mont_fpu64 | ||
| 16 | CFLAGS+= -DOPENSSL_BN_ASM_MONT | ||
| 17 | # camellia | ||
| 18 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 19 | # des | ||
| 20 | SRCS+= des_enc.c fcrypt_b.c | ||
| 21 | # rc4 | ||
| 22 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 23 | ## rc5 | ||
| 24 | #SRCS+= rc5_enc.c | ||
| 25 | # sha | ||
| 26 | CFLAGS+= -DSHA1_ASM | ||
| 27 | SSLASM+= sha sha1-ppc sha1-ppc | ||
| 28 | CFLAGS+= -DSHA256_ASM | ||
| 29 | SSLASM+= sha sha512-ppc sha256-ppc | ||
| 30 | # whrlpool | ||
| 31 | SRCS+= wp_block.c | ||
| 32 | |||
| 33 | .for dir src dst in ${SSLASM} | ||
| 34 | SRCS+= ${dst}.S | ||
| 35 | GENERATED+=${dst}.S | ||
| 36 | ${dst}.S: ${LCRYPTO_SRC}/${dir}/asm/${src}.pl | ||
| 37 | /usr/bin/perl \ | ||
| 38 | ${LCRYPTO_SRC}/${dir}/asm/${src}.pl linux32 ${.TARGET} > ${.TARGET} | ||
| 39 | .endfor | ||
| 40 | |||
| 41 | #CFLAGS+= -DOPENSSL_CPUID_OBJ # it's commented out in ppccap.c | ||
| 42 | SRCS+= ppccpuid.S ppccap.c | ||
| 43 | GENERATED+=ppccpuid.S | ||
| 44 | ppccpuid.S: ${LCRYPTO_SRC}/ppccpuid.pl | ||
| 45 | /usr/bin/perl \ | ||
| 46 | ${LCRYPTO_SRC}/ppccpuid.pl linux32 > ${.TARGET} | ||
diff --git a/src/lib/libcrypto/crypto/arch/powerpc/opensslconf.h b/src/lib/libcrypto/crypto/arch/powerpc/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/powerpc/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/sh/opensslconf.h b/src/lib/libcrypto/crypto/arch/sh/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/sh/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/sparc/Makefile.inc b/src/lib/libcrypto/crypto/arch/sparc/Makefile.inc deleted file mode 100644 index ba9954c85e..0000000000 --- a/src/lib/libcrypto/crypto/arch/sparc/Makefile.inc +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.2 2014/11/17 20:31:22 miod Exp $ | ||
| 2 | |||
| 3 | # sparc-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_core.c aes_cbc.c | ||
| 7 | # bf | ||
| 8 | SRCS+= bf_enc.c | ||
| 9 | # bn | ||
| 10 | .if 0 # uses `umul' and `udiv' instructions | ||
| 11 | SRCS+= sparcv8.S | ||
| 12 | .PATH: ${LCRYPTO_SRC}/bn/asm | ||
| 13 | .else | ||
| 14 | SRCS+= bn_asm.c | ||
| 15 | .endif | ||
| 16 | # camellia | ||
| 17 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 18 | # des | ||
| 19 | SRCS+= fcrypt_b.c | ||
| 20 | SRCS+= des_enc-sparc.S | ||
| 21 | GENERATED+= des_enc-sparc.S | ||
| 22 | des_enc-sparc.S: ${LCRYPTO_SRC}/des/asm/des_enc.m4 | ||
| 23 | m4 ${LCRYPTO_SRC}/des/asm/des_enc.m4 > ${.TARGET} | ||
| 24 | # rc4 | ||
| 25 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 26 | ## rc5 | ||
| 27 | #SRCS+= rc5_enc.c | ||
| 28 | # whrlpool | ||
| 29 | SRCS+= wp_block.c | ||
diff --git a/src/lib/libcrypto/crypto/arch/sparc/opensslconf.h b/src/lib/libcrypto/crypto/arch/sparc/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/sparc/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/sparc64/Makefile.inc b/src/lib/libcrypto/crypto/arch/sparc64/Makefile.inc deleted file mode 100644 index e3f217dbb8..0000000000 --- a/src/lib/libcrypto/crypto/arch/sparc64/Makefile.inc +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.2 2014/11/17 20:31:22 miod Exp $ | ||
| 2 | |||
| 3 | # sparc64-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | SRCS+= aes_core.c aes_cbc.c | ||
| 7 | CFLAGS+= -DAES_ASM | ||
| 8 | SSLASM+= aes aes-sparcv9 aes-sparcv9 | ||
| 9 | # bf | ||
| 10 | SRCS+= bf_enc.c | ||
| 11 | # bn | ||
| 12 | SRCS+= bn_asm.c | ||
| 13 | # camellia | ||
| 14 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 15 | # des | ||
| 16 | SRCS+= fcrypt_b.c | ||
| 17 | SRCS+= des_enc-sparc.S | ||
| 18 | GENERATED+= des_enc-sparc.S | ||
| 19 | des_enc-sparc.S: ${LCRYPTO_SRC}/des/asm/des_enc.m4 | ||
| 20 | m4 ${LCRYPTO_SRC}/des/asm/des_enc.m4 > ${.TARGET} | ||
| 21 | # modes | ||
| 22 | CFLAGS+= -DGHASH_ASM | ||
| 23 | SSLASM+= modes ghash-sparcv9 ghash-sparcv9 | ||
| 24 | # rc4 | ||
| 25 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 26 | ## rc5 | ||
| 27 | #SRCS+= rc5_enc.c | ||
| 28 | # sha | ||
| 29 | SSLASM+= sha sha1-sparcv9 sha1-sparcv9 | ||
| 30 | CFLAGS+= -DSHA1_ASM | ||
| 31 | SSLASM+= sha sha512-sparcv9 sha256-sparcv9 | ||
| 32 | CFLAGS+= -DSHA256_ASM | ||
| 33 | SSLASM+= sha sha512-sparcv9 sha512-sparcv9 | ||
| 34 | CFLAGS+= -DSHA512_ASM | ||
| 35 | # whrlpool | ||
| 36 | SRCS+= wp_block.c | ||
| 37 | |||
| 38 | .for dir src dst in ${SSLASM} | ||
| 39 | SRCS+= ${dst}.S | ||
| 40 | GENERATED+=${dst}.S | ||
| 41 | ${dst}.S: ${LCRYPTO_SRC}/${dir}/asm/${src}.pl | ||
| 42 | /usr/bin/env CC=${CC} /usr/bin/perl \ | ||
| 43 | ${LCRYPTO_SRC}/${dir}/asm/${src}.pl ${.TARGET} -m64 > ${.TARGET} | ||
| 44 | .endfor | ||
| 45 | |||
| 46 | # not until Montgomery code enabled | ||
| 47 | #CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 48 | #SRCS+= sparccpuid.S sparcv9cap.c | ||
diff --git a/src/lib/libcrypto/crypto/arch/sparc64/opensslconf.h b/src/lib/libcrypto/crypto/arch/sparc64/opensslconf.h deleted file mode 100644 index ef7a679d94..0000000000 --- a/src/lib/libcrypto/crypto/arch/sparc64/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #define RC4_CHUNK unsigned long | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #undef BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #define SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #undef THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #undef RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #define BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #define DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #define DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #undef DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/arch/vax/Makefile.inc b/src/lib/libcrypto/crypto/arch/vax/Makefile.inc deleted file mode 100644 index f7764cf44a..0000000000 --- a/src/lib/libcrypto/crypto/arch/vax/Makefile.inc +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.2 2014/11/17 20:31:22 miod Exp $ | ||
| 2 | |||
| 3 | # vax-specific libcrypto build rules | ||
| 4 | |||
| 5 | # aes | ||
| 6 | CFLAGS+=-DOPENSSL_NO_ASM | ||
| 7 | SRCS+= aes_core.c aes_cbc.c | ||
| 8 | # bf | ||
| 9 | SRCS+= bf_enc.c | ||
| 10 | # bn | ||
| 11 | SRCS+= bn_asm_vax.S | ||
| 12 | # camellia | ||
| 13 | SRCS+= camellia.c cmll_cbc.c cmll_misc.c | ||
| 14 | # des | ||
| 15 | SRCS+= des_enc.c fcrypt_b.c | ||
| 16 | # rc4 | ||
| 17 | SRCS+= rc4_enc.c rc4_skey.c | ||
| 18 | ## rc5 | ||
| 19 | #SRCS+= rc5_enc.c | ||
| 20 | # whrlpool | ||
| 21 | SRCS+= wp_block.c | ||
diff --git a/src/lib/libcrypto/crypto/arch/vax/bn_asm_vax.S b/src/lib/libcrypto/crypto/arch/vax/bn_asm_vax.S deleted file mode 100644 index 2969ae9dac..0000000000 --- a/src/lib/libcrypto/crypto/arch/vax/bn_asm_vax.S +++ /dev/null | |||
| @@ -1,436 +0,0 @@ | |||
| 1 | # $OpenBSD: bn_asm_vax.S,v 1.1 2014/04/11 22:51:53 miod Exp $ | ||
| 2 | # $NetBSD: bn_asm_vax.S,v 1.1 2003/11/03 10:22:28 ragge Exp $ | ||
| 3 | |||
| 4 | #include <machine/asm.h> | ||
| 5 | |||
| 6 | # w.j.m. 15-jan-1999 | ||
| 7 | # | ||
| 8 | # it's magic ... | ||
| 9 | # | ||
| 10 | # ULONG bn_mul_add_words(ULONG r[],ULONG a[],int n,ULONG w) { | ||
| 11 | # ULONG c = 0; | ||
| 12 | # int i; | ||
| 13 | # for(i = 0; i < n; i++) <c,r[i]> := r[i] + c + a[i] * w ; | ||
| 14 | # return c; | ||
| 15 | # } | ||
| 16 | |||
| 17 | ENTRY(bn_mul_add_words,R6) | ||
| 18 | movl 4(%ap),%r2 # *r | ||
| 19 | movl 8(%ap),%r3 # *a | ||
| 20 | movl 12(%ap),%r4 # n | ||
| 21 | movl 16(%ap),%r5 # w | ||
| 22 | clrl %r6 # return value ("carry") | ||
| 23 | |||
| 24 | 0: emul %r5,(%r3),(%r2),%r0 # w * a[0] + r[0] -> r0 | ||
| 25 | |||
| 26 | # fixup for "negative" r[] | ||
| 27 | tstl (%r2) | ||
| 28 | bgeq 1f | ||
| 29 | incl %r1 # add 1 to highword | ||
| 30 | |||
| 31 | 1: # add saved carry to result | ||
| 32 | addl2 %r6,%r0 | ||
| 33 | adwc $0,%r1 | ||
| 34 | |||
| 35 | # combined fixup for "negative" w, a[] | ||
| 36 | tstl %r5 # if w is negative... | ||
| 37 | bgeq 1f | ||
| 38 | addl2 (%r3),%r1 # ...add a[0] again to highword | ||
| 39 | 1: tstl (%r3) # if a[0] is negative... | ||
| 40 | bgeq 1f | ||
| 41 | addl2 %r5,%r1 # ...add w again to highword | ||
| 42 | 1: | ||
| 43 | movl %r0,(%r2)+ # save low word in dest & advance *r | ||
| 44 | addl2 $4,%r3 # advance *a | ||
| 45 | movl %r1,%r6 # high word in r6 for return value | ||
| 46 | |||
| 47 | sobgtr %r4,0b # loop? | ||
| 48 | |||
| 49 | movl %r6,%r0 | ||
| 50 | ret | ||
| 51 | |||
| 52 | # .title vax_bn_mul_words unsigned multiply & add, 32*32+32=>64 | ||
| 53 | #; | ||
| 54 | #; w.j.m. 15-jan-1999 | ||
| 55 | #; | ||
| 56 | #; it's magic ... | ||
| 57 | #; | ||
| 58 | #; ULONG bn_mul_words(ULONG r[],ULONG a[],int n,ULONG w) { | ||
| 59 | #; ULONG c = 0; | ||
| 60 | #; int i; | ||
| 61 | #; for(i = 0; i < num; i++) <c,r[i]> := a[i] * w + c ; | ||
| 62 | #; return(c); | ||
| 63 | #; } | ||
| 64 | # | ||
| 65 | |||
| 66 | ENTRY(bn_mul_words,R6) | ||
| 67 | movl 4(%ap),%r2 # *r | ||
| 68 | movl 8(%ap),%r3 # *a | ||
| 69 | movl 12(%ap),%r4 # n | ||
| 70 | movl 16(%ap),%r5 # w | ||
| 71 | clrl %r6 # carry | ||
| 72 | |||
| 73 | 0: emul %r5,(%r3),%r6,%r0 # w * a[0] + carry -> r0 | ||
| 74 | |||
| 75 | # fixup for "negative" carry | ||
| 76 | tstl %r6 | ||
| 77 | bgeq 1f | ||
| 78 | incl %r1 | ||
| 79 | |||
| 80 | 1: # combined fixup for "negative" w, a[] | ||
| 81 | tstl %r5 | ||
| 82 | bgeq 1f | ||
| 83 | addl2 (%r3),%r1 | ||
| 84 | 1: tstl (%r3) | ||
| 85 | bgeq 1f | ||
| 86 | addl2 %r5,%r1 | ||
| 87 | |||
| 88 | 1: movl %r0,(%r2)+ | ||
| 89 | addl2 $4,%r3 | ||
| 90 | movl %r1,%r6 | ||
| 91 | |||
| 92 | sobgtr %r4,0b | ||
| 93 | |||
| 94 | movl %r6,%r0 | ||
| 95 | ret | ||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | # .title vax_bn_sqr_words unsigned square, 32*32=>64 | ||
| 100 | #; | ||
| 101 | #; w.j.m. 15-jan-1999 | ||
| 102 | #; | ||
| 103 | #; it's magic ... | ||
| 104 | #; | ||
| 105 | #; void bn_sqr_words(ULONG r[],ULONG a[],int n) { | ||
| 106 | #; int i; | ||
| 107 | #; for(i = 0; i < n; i++) <r[2*i+1],r[2*i]> := a[i] * a[i] ; | ||
| 108 | #; } | ||
| 109 | # | ||
| 110 | |||
| 111 | ENTRY(bn_sqr_words,0) | ||
| 112 | movl 4(%ap),%r2 # r | ||
| 113 | movl 8(%ap),%r3 # a | ||
| 114 | movl 12(%ap),%r4 # n | ||
| 115 | |||
| 116 | 0: movl (%r3)+,%r5 # r5 = a[] & advance | ||
| 117 | |||
| 118 | emul %r5,%r5,$0,%r0 # a[0] * a[0] + 0 -> r0 | ||
| 119 | |||
| 120 | # fixup for "negative" a[] | ||
| 121 | tstl %r5 | ||
| 122 | bgeq 1f | ||
| 123 | addl2 %r5,%r1 | ||
| 124 | addl2 %r5,%r1 | ||
| 125 | |||
| 126 | 1: movq %r0,(%r2)+ # store 64-bit result | ||
| 127 | |||
| 128 | sobgtr %r4,0b # loop | ||
| 129 | |||
| 130 | ret | ||
| 131 | |||
| 132 | |||
| 133 | # .title vax_bn_div_words unsigned divide | ||
| 134 | #; | ||
| 135 | #; Richard Levitte 20-Nov-2000 | ||
| 136 | #; | ||
| 137 | #; ULONG bn_div_words(ULONG h, ULONG l, ULONG d) | ||
| 138 | #; { | ||
| 139 | #; return ((ULONG)((((ULLONG)h)<<32)|l) / (ULLONG)d); | ||
| 140 | #; } | ||
| 141 | #; | ||
| 142 | #; Using EDIV would be very easy, if it didn't do signed calculations. | ||
| 143 | #; Any time any of the input numbers are signed, there are problems, | ||
| 144 | #; usually with integer overflow, at which point it returns useless | ||
| 145 | #; data (the quotient gets the value of l, and the remainder becomes 0). | ||
| 146 | #; | ||
| 147 | #; If it was just for the dividend, it would be very easy, just divide | ||
| 148 | #; it by 2 (unsigned), do the division, multiply the resulting quotient | ||
| 149 | #; and remainder by 2, add the bit that was dropped when dividing by 2 | ||
| 150 | #; to the remainder, and do some adjustment so the remainder doesn't | ||
| 151 | #; end up larger than the divisor. For some cases when the divisor is | ||
| 152 | #; negative (from EDIV's point of view, i.e. when the highest bit is set), | ||
| 153 | #; dividing the dividend by 2 isn't enough, and since some operations | ||
| 154 | #; might generate integer overflows even when the dividend is divided by | ||
| 155 | #; 4 (when the high part of the shifted down dividend ends up being exactly | ||
| 156 | #; half of the divisor, the result is the quotient 0x80000000, which is | ||
| 157 | #; negative...) it needs to be divided by 8. Furthermore, the divisor needs | ||
| 158 | #; to be divided by 2 (unsigned) as well, to avoid more problems with the sign. | ||
| 159 | #; In this case, a little extra fiddling with the remainder is required. | ||
| 160 | #; | ||
| 161 | #; So, the simplest way to handle this is always to divide the dividend | ||
| 162 | #; by 8, and to divide the divisor by 2 if it's highest bit is set. | ||
| 163 | #; After EDIV has been used, the quotient gets multiplied by 8 if the | ||
| 164 | #; original divisor was positive, otherwise 4. The remainder, oddly | ||
| 165 | #; enough, is *always* multiplied by 8. | ||
| 166 | #; NOTE: in the case mentioned above, where the high part of the shifted | ||
| 167 | #; down dividend ends up being exactly half the shifted down divisor, we | ||
| 168 | #; end up with a 33 bit quotient. That's no problem however, it usually | ||
| 169 | #; means we have ended up with a too large remainder as well, and the | ||
| 170 | #; problem is fixed by the last part of the algorithm (next paragraph). | ||
| 171 | #; | ||
| 172 | #; The routine ends with comparing the resulting remainder with the | ||
| 173 | #; original divisor and if the remainder is larger, subtract the | ||
| 174 | #; original divisor from it, and increase the quotient by 1. This is | ||
| 175 | #; done until the remainder is smaller than the divisor. | ||
| 176 | #; | ||
| 177 | #; The complete algorithm looks like this: | ||
| 178 | #; | ||
| 179 | #; d' = d | ||
| 180 | #; l' = l & 7 | ||
| 181 | #; [h,l] = [h,l] >> 3 | ||
| 182 | #; [q,r] = floor([h,l] / d) # This is the EDIV operation | ||
| 183 | #; if (q < 0) q = -q # I doubt this is necessary any more | ||
| 184 | #; | ||
| 185 | #; r' = r >> 29 | ||
| 186 | #; if (d' >= 0) | ||
| 187 | #; q' = q >> 29 | ||
| 188 | #; q = q << 3 | ||
| 189 | #; else | ||
| 190 | #; q' = q >> 30 | ||
| 191 | #; q = q << 2 | ||
| 192 | #; r = (r << 3) + l' | ||
| 193 | #; | ||
| 194 | #; if (d' < 0) | ||
| 195 | #; { | ||
| 196 | #; [r',r] = [r',r] - q | ||
| 197 | #; while ([r',r] < 0) | ||
| 198 | #; { | ||
| 199 | #; [r',r] = [r',r] + d | ||
| 200 | #; [q',q] = [q',q] - 1 | ||
| 201 | #; } | ||
| 202 | #; } | ||
| 203 | #; | ||
| 204 | #; while ([r',r] >= d') | ||
| 205 | #; { | ||
| 206 | #; [r',r] = [r',r] - d' | ||
| 207 | #; [q',q] = [q',q] + 1 | ||
| 208 | #; } | ||
| 209 | #; | ||
| 210 | #; return q | ||
| 211 | # | ||
| 212 | #;r2 = l, q | ||
| 213 | #;r3 = h, r | ||
| 214 | #;r4 = d | ||
| 215 | #;r5 = l' | ||
| 216 | #;r6 = r' | ||
| 217 | #;r7 = d' | ||
| 218 | #;r8 = q' | ||
| 219 | # | ||
| 220 | |||
| 221 | ENTRY(bn_div_words,R6|R7|R8) | ||
| 222 | movl 4(%ap),%r3 # h | ||
| 223 | movl 8(%ap),%r2 # l | ||
| 224 | movl 12(%ap),%r4 # d | ||
| 225 | |||
| 226 | bicl3 $-8,%r2,%r5 # l' = l & 7 | ||
| 227 | bicl3 $7,%r2,%r2 | ||
| 228 | |||
| 229 | bicl3 $-8,%r3,%r6 | ||
| 230 | bicl3 $7,%r3,%r3 | ||
| 231 | |||
| 232 | addl2 %r6,%r2 | ||
| 233 | |||
| 234 | rotl $-3,%r2,%r2 # l = l >> 3 | ||
| 235 | rotl $-3,%r3,%r3 # h = h >> 3 | ||
| 236 | |||
| 237 | movl %r4,%r7 # d' = d | ||
| 238 | |||
| 239 | clrl %r6 # r' = 0 | ||
| 240 | clrl %r8 # q' = 0 | ||
| 241 | |||
| 242 | tstl %r4 | ||
| 243 | beql 0f # Uh-oh, the divisor is 0... | ||
| 244 | bgtr 1f | ||
| 245 | rotl $-1,%r4,%r4 # If d is negative, shift it right. | ||
| 246 | bicl2 $0x80000000,%r4 # Since d is then a large number, the | ||
| 247 | # lowest bit is insignificant | ||
| 248 | # (contradict that, and I'll fix the problem!) | ||
| 249 | 1: | ||
| 250 | ediv %r4,%r2,%r2,%r3 # Do the actual division | ||
| 251 | |||
| 252 | tstl %r2 | ||
| 253 | bgeq 1f | ||
| 254 | mnegl %r2,%r2 # if q < 0, negate it | ||
| 255 | 1: | ||
| 256 | tstl %r7 | ||
| 257 | blss 1f | ||
| 258 | rotl $3,%r2,%r2 # q = q << 3 | ||
| 259 | bicl3 $-8,%r2,%r8 # q' gets the high bits from q | ||
| 260 | bicl3 $7,%r2,%r2 | ||
| 261 | brb 2f | ||
| 262 | |||
| 263 | 1: # else | ||
| 264 | rotl $2,%r2,%r2 # q = q << 2 | ||
| 265 | bicl3 $-4,%r2,%r8 # q' gets the high bits from q | ||
| 266 | bicl3 $3,%r2,%r2 | ||
| 267 | 2: | ||
| 268 | rotl $3,%r3,%r3 # r = r << 3 | ||
| 269 | bicl3 $-8,%r3,%r6 # r' gets the high bits from r | ||
| 270 | bicl3 $7,%r3,%r3 | ||
| 271 | addl2 %r5,%r3 # r = r + l' | ||
| 272 | |||
| 273 | tstl %r7 | ||
| 274 | bgeq 5f | ||
| 275 | bitl $1,%r7 | ||
| 276 | beql 5f # if d' < 0 && d' & 1 | ||
| 277 | subl2 %r2,%r3 # [r',r] = [r',r] - [q',q] | ||
| 278 | sbwc %r8,%r6 | ||
| 279 | 3: | ||
| 280 | bgeq 5f # while r < 0 | ||
| 281 | decl %r2 # [q',q] = [q',q] - 1 | ||
| 282 | sbwc $0,%r8 | ||
| 283 | addl2 %r7,%r3 # [r',r] = [r',r] + d' | ||
| 284 | adwc $0,%r6 | ||
| 285 | brb 3b | ||
| 286 | |||
| 287 | # The return points are placed in the middle to keep a short distance from | ||
| 288 | # all the branch points | ||
| 289 | 1: | ||
| 290 | # movl %r3,%r1 | ||
| 291 | movl %r2,%r0 | ||
| 292 | ret | ||
| 293 | 0: | ||
| 294 | movl $-1,%r0 | ||
| 295 | ret | ||
| 296 | 5: | ||
| 297 | tstl %r6 | ||
| 298 | bneq 6f | ||
| 299 | cmpl %r3,%r7 | ||
| 300 | blssu 1b # while [r',r] >= d' | ||
| 301 | 6: | ||
| 302 | subl2 %r7,%r3 # [r',r] = [r',r] - d' | ||
| 303 | sbwc $0,%r6 | ||
| 304 | incl %r2 # [q',q] = [q',q] + 1 | ||
| 305 | adwc $0,%r8 | ||
| 306 | brb 5b | ||
| 307 | |||
| 308 | |||
| 309 | |||
| 310 | # .title vax_bn_add_words unsigned add of two arrays | ||
| 311 | #; | ||
| 312 | #; Richard Levitte 20-Nov-2000 | ||
| 313 | #; | ||
| 314 | #; ULONG bn_add_words(ULONG r[], ULONG a[], ULONG b[], int n) { | ||
| 315 | #; ULONG c = 0; | ||
| 316 | #; int i; | ||
| 317 | #; for (i = 0; i < n; i++) <c,r[i]> = a[i] + b[i] + c; | ||
| 318 | #; return(c); | ||
| 319 | #; } | ||
| 320 | # | ||
| 321 | |||
| 322 | ENTRY(bn_add_words,0) | ||
| 323 | movl 4(%ap),%r2 # r | ||
| 324 | movl 8(%ap),%r3 # a | ||
| 325 | movl 12(%ap),%r4 # b | ||
| 326 | movl 16(%ap),%r5 # n | ||
| 327 | clrl %r0 | ||
| 328 | |||
| 329 | tstl %r5 | ||
| 330 | bleq 1f | ||
| 331 | |||
| 332 | 0: movl (%r3)+,%r1 # carry untouched | ||
| 333 | adwc (%r4)+,%r1 # carry used and touched | ||
| 334 | movl %r1,(%r2)+ # carry untouched | ||
| 335 | sobgtr %r5,0b # carry untouched | ||
| 336 | |||
| 337 | adwc $0,%r0 | ||
| 338 | 1: ret | ||
| 339 | |||
| 340 | #; | ||
| 341 | #; Richard Levitte 20-Nov-2000 | ||
| 342 | #; | ||
| 343 | #; ULONG bn_sub_words(ULONG r[], ULONG a[], ULONG b[], int n) { | ||
| 344 | #; ULONG c = 0; | ||
| 345 | #; int i; | ||
| 346 | #; for (i = 0; i < n; i++) <c,r[i]> = a[i] - b[i] - c; | ||
| 347 | #; return(c); | ||
| 348 | #; } | ||
| 349 | # | ||
| 350 | |||
| 351 | ENTRY(bn_sub_words,R6) | ||
| 352 | movl 4(%ap),%r2 # r | ||
| 353 | movl 8(%ap),%r3 # a | ||
| 354 | movl 12(%ap),%r4 # b | ||
| 355 | movl 16(%ap),%r5 # n | ||
| 356 | clrl %r0 | ||
| 357 | |||
| 358 | tstl %r5 | ||
| 359 | bleq 1f | ||
| 360 | |||
| 361 | 0: movl (%r3)+,%r6 # carry untouched | ||
| 362 | sbwc (%r4)+,%r6 # carry used and touched | ||
| 363 | movl %r6,(%r2)+ # carry untouched | ||
| 364 | sobgtr %r5,0b # carry untouched | ||
| 365 | |||
| 366 | 1: adwc $0,%r0 | ||
| 367 | ret | ||
| 368 | |||
| 369 | # | ||
| 370 | # Ragge 20-Sep-2003 | ||
| 371 | # | ||
| 372 | # Multiply a vector of 4/8 longword by another. | ||
| 373 | # Uses two loops and 16/64 emuls. | ||
| 374 | # | ||
| 375 | |||
| 376 | ENTRY(bn_mul_comba4,R6|R7|R8|R9) | ||
| 377 | movl $4,%r9 # 4*4 | ||
| 378 | brb 6f | ||
| 379 | |||
| 380 | ENTRY(bn_mul_comba8,R6|R7|R8|R9) | ||
| 381 | movl $8,%r9 # 8*8 | ||
| 382 | |||
| 383 | 6: movl 8(%ap),%r3 # a[] | ||
| 384 | movl 12(%ap),%r7 # b[] | ||
| 385 | brb 5f | ||
| 386 | |||
| 387 | ENTRY(bn_sqr_comba4,R6|R7|R8|R9) | ||
| 388 | movl $4,%r9 # 4*4 | ||
| 389 | brb 0f | ||
| 390 | |||
| 391 | ENTRY(bn_sqr_comba8,R6|R7|R8|R9) | ||
| 392 | movl $8,%r9 # 8*8 | ||
| 393 | |||
| 394 | 0: | ||
| 395 | movl 8(%ap),%r3 # a[] | ||
| 396 | movl %r3,%r7 # a[] | ||
| 397 | |||
| 398 | 5: movl 4(%ap),%r5 # r[] | ||
| 399 | movl %r9,%r8 | ||
| 400 | |||
| 401 | clrq (%r5) # clear destinatino, for add. | ||
| 402 | clrq 8(%r5) | ||
| 403 | clrq 16(%r5) # these only needed for comba8 | ||
| 404 | clrq 24(%r5) | ||
| 405 | |||
| 406 | 2: clrl %r4 # carry | ||
| 407 | movl %r9,%r6 # inner loop count | ||
| 408 | movl (%r7)+,%r2 # value to multiply with | ||
| 409 | |||
| 410 | 1: emul %r2,(%r3),%r4,%r0 | ||
| 411 | tstl %r4 | ||
| 412 | bgeq 3f | ||
| 413 | incl %r1 | ||
| 414 | 3: tstl %r2 | ||
| 415 | bgeq 3f | ||
| 416 | addl2 (%r3),%r1 | ||
| 417 | 3: tstl (%r3) | ||
| 418 | bgeq 3f | ||
| 419 | addl2 %r2,%r1 | ||
| 420 | |||
| 421 | 3: addl2 %r0,(%r5)+ # add to destination | ||
| 422 | adwc $0,%r1 # remember carry | ||
| 423 | movl %r1,%r4 # add carry in next emul | ||
| 424 | addl2 $4,%r3 | ||
| 425 | sobgtr %r6,1b | ||
| 426 | |||
| 427 | movl %r4,(%r5) # save highest add result | ||
| 428 | |||
| 429 | ashl $2,%r9,%r4 | ||
| 430 | subl2 %r4,%r3 | ||
| 431 | subl2 $4,%r4 | ||
| 432 | subl2 %r4,%r5 | ||
| 433 | |||
| 434 | sobgtr %r8,2b | ||
| 435 | |||
| 436 | ret | ||
diff --git a/src/lib/libcrypto/crypto/arch/vax/opensslconf.h b/src/lib/libcrypto/crypto/arch/vax/opensslconf.h deleted file mode 100644 index e3795ce73a..0000000000 --- a/src/lib/libcrypto/crypto/arch/vax/opensslconf.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | #include <openssl/opensslfeatures.h> | ||
| 2 | /* crypto/opensslconf.h.in */ | ||
| 3 | |||
| 4 | /* Generate 80386 code? */ | ||
| 5 | #undef I386_ONLY | ||
| 6 | |||
| 7 | #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) | ||
| 8 | #define OPENSSLDIR "/etc/ssl" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #undef OPENSSL_UNISTD | ||
| 12 | #define OPENSSL_UNISTD <unistd.h> | ||
| 13 | |||
| 14 | #undef OPENSSL_EXPORT_VAR_AS_FUNCTION | ||
| 15 | |||
| 16 | #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) | ||
| 17 | #define IDEA_INT unsigned int | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if defined(HEADER_MD2_H) && !defined(MD2_INT) | ||
| 21 | #define MD2_INT unsigned int | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(HEADER_RC2_H) && !defined(RC2_INT) | ||
| 25 | /* I need to put in a mod for the alpha - eay */ | ||
| 26 | #define RC2_INT unsigned int | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(HEADER_RC4_H) | ||
| 30 | #if !defined(RC4_INT) | ||
| 31 | /* using int types make the structure larger but make the code faster | ||
| 32 | * on most boxes I have tested - up to %20 faster. */ | ||
| 33 | /* | ||
| 34 | * I don't know what does "most" mean, but declaring "int" is a must on: | ||
| 35 | * - Intel P6 because partial register stalls are very expensive; | ||
| 36 | * - elder Alpha because it lacks byte load/store instructions; | ||
| 37 | */ | ||
| 38 | #define RC4_INT unsigned int | ||
| 39 | #endif | ||
| 40 | #if !defined(RC4_CHUNK) | ||
| 41 | /* | ||
| 42 | * This enables code handling data aligned at natural CPU word | ||
| 43 | * boundary. See crypto/rc4/rc4_enc.c for further details. | ||
| 44 | */ | ||
| 45 | #undef RC4_CHUNK | ||
| 46 | #endif | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) | ||
| 50 | /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a | ||
| 51 | * %20 speed up (longs are 8 bytes, int's are 4). */ | ||
| 52 | #ifndef DES_LONG | ||
| 53 | #define DES_LONG unsigned int | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) | ||
| 58 | #define CONFIG_HEADER_BN_H | ||
| 59 | #define BN_LLONG | ||
| 60 | |||
| 61 | /* Should we define BN_DIV2W here? */ | ||
| 62 | |||
| 63 | /* Only one for the following should be defined */ | ||
| 64 | /* The prime number generation stuff may not work when | ||
| 65 | * EIGHT_BIT but I don't care since I've only used this mode | ||
| 66 | * for debuging the bignum libraries */ | ||
| 67 | #undef SIXTY_FOUR_BIT_LONG | ||
| 68 | #undef SIXTY_FOUR_BIT | ||
| 69 | #define THIRTY_TWO_BIT | ||
| 70 | #undef SIXTEEN_BIT | ||
| 71 | #undef EIGHT_BIT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) | ||
| 75 | #define CONFIG_HEADER_RC4_LOCL_H | ||
| 76 | /* if this is defined data[i] is used instead of *data, this is a %20 | ||
| 77 | * speedup on x86 */ | ||
| 78 | #define RC4_INDEX | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) | ||
| 82 | #define CONFIG_HEADER_BF_LOCL_H | ||
| 83 | #undef BF_PTR | ||
| 84 | #endif /* HEADER_BF_LOCL_H */ | ||
| 85 | |||
| 86 | #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) | ||
| 87 | #define CONFIG_HEADER_DES_LOCL_H | ||
| 88 | #ifndef DES_DEFAULT_OPTIONS | ||
| 89 | /* the following is tweaked from a config script, that is why it is a | ||
| 90 | * protected undef/define */ | ||
| 91 | #ifndef DES_PTR | ||
| 92 | #undef DES_PTR | ||
| 93 | #endif | ||
| 94 | |||
| 95 | /* This helps C compiler generate the correct code for multiple functional | ||
| 96 | * units. It reduces register dependancies at the expense of 2 more | ||
| 97 | * registers */ | ||
| 98 | #ifndef DES_RISC1 | ||
| 99 | #undef DES_RISC1 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef DES_RISC2 | ||
| 103 | #undef DES_RISC2 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #if defined(DES_RISC1) && defined(DES_RISC2) | ||
| 107 | YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Unroll the inner loop, this sometimes helps, sometimes hinders. | ||
| 111 | * Very mucy CPU dependant */ | ||
| 112 | #ifndef DES_UNROLL | ||
| 113 | #define DES_UNROLL | ||
| 114 | #endif | ||
| 115 | |||
| 116 | /* These default values were supplied by | ||
| 117 | * Peter Gutman <pgut001@cs.auckland.ac.nz> | ||
| 118 | * They are only used if nothing else has been defined */ | ||
| 119 | #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) | ||
| 120 | /* Special defines which change the way the code is built depending on the | ||
| 121 | CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find | ||
| 122 | even newer MIPS CPU's, but at the moment one size fits all for | ||
| 123 | optimization options. Older Sparc's work better with only UNROLL, but | ||
| 124 | there's no way to tell at compile time what it is you're running on */ | ||
| 125 | |||
| 126 | #if defined( sun ) /* Newer Sparc's */ | ||
| 127 | # define DES_PTR | ||
| 128 | # define DES_RISC1 | ||
| 129 | # define DES_UNROLL | ||
| 130 | #elif defined( __ultrix ) /* Older MIPS */ | ||
| 131 | # define DES_PTR | ||
| 132 | # define DES_RISC2 | ||
| 133 | # define DES_UNROLL | ||
| 134 | #elif defined( __osf1__ ) /* Alpha */ | ||
| 135 | # define DES_PTR | ||
| 136 | # define DES_RISC2 | ||
| 137 | #elif defined ( _AIX ) /* RS6000 */ | ||
| 138 | /* Unknown */ | ||
| 139 | #elif defined( __hpux ) /* HP-PA */ | ||
| 140 | /* Unknown */ | ||
| 141 | #elif defined( __aux ) /* 68K */ | ||
| 142 | /* Unknown */ | ||
| 143 | #elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ | ||
| 144 | # define DES_UNROLL | ||
| 145 | #elif defined( __sgi ) /* Newer MIPS */ | ||
| 146 | # define DES_PTR | ||
| 147 | # define DES_RISC2 | ||
| 148 | # define DES_UNROLL | ||
| 149 | #elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ | ||
| 150 | # define DES_PTR | ||
| 151 | # define DES_RISC1 | ||
| 152 | # define DES_UNROLL | ||
| 153 | #endif /* Systems-specific speed defines */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #endif /* DES_DEFAULT_OPTIONS */ | ||
| 157 | #endif /* HEADER_DES_LOCL_H */ | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_aix.c b/src/lib/libcrypto/crypto/getentropy_aix.c deleted file mode 100644 index ff48ae7071..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_aix.c +++ /dev/null | |||
| @@ -1,425 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_aix.c,v 1.5 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2015 Michael Felt <aixtools@gmail.com> | ||
| 5 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | ||
| 6 | * Copyright (c) 2014 Bob Beck <beck@obtuse.com> | ||
| 7 | * | ||
| 8 | * Permission to use, copy, modify, and distribute this software for any | ||
| 9 | * purpose with or without fee is hereby granted, provided that the above | ||
| 10 | * copyright notice and this permission notice appear in all copies. | ||
| 11 | * | ||
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 19 | * | ||
| 20 | * Emulation of getentropy(2) as documented at: | ||
| 21 | * http://man.openbsd.org/getentropy.2 | ||
| 22 | */ | ||
| 23 | /* | ||
| 24 | * -lperfstat is needed for the psuedo entropy data | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include <sys/mman.h> | ||
| 28 | #include <sys/procfs.h> | ||
| 29 | #include <sys/protosw.h> | ||
| 30 | #include <sys/resource.h> | ||
| 31 | #include <sys/socket.h> | ||
| 32 | #include <sys/stat.h> | ||
| 33 | #include <sys/statvfs.h> | ||
| 34 | #include <sys/timers.h> | ||
| 35 | #include <errno.h> | ||
| 36 | #include <fcntl.h> | ||
| 37 | #include <signal.h> | ||
| 38 | #include <stdio.h> | ||
| 39 | #include <string.h> | ||
| 40 | #include <termios.h> | ||
| 41 | |||
| 42 | #include <openssl/sha.h> | ||
| 43 | |||
| 44 | #include <libperfstat.h> | ||
| 45 | |||
| 46 | #define REPEAT 5 | ||
| 47 | #define min(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 48 | |||
| 49 | #define HX(a, b) \ | ||
| 50 | do { \ | ||
| 51 | if ((a)) \ | ||
| 52 | HD(errno); \ | ||
| 53 | else \ | ||
| 54 | HD(b); \ | ||
| 55 | } while (0) | ||
| 56 | |||
| 57 | #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) | ||
| 58 | #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) | ||
| 59 | #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) | ||
| 60 | |||
| 61 | int getentropy(void *buf, size_t len); | ||
| 62 | |||
| 63 | static int gotdata(char *buf, size_t len); | ||
| 64 | static int getentropy_urandom(void *buf, size_t len, const char *path, | ||
| 65 | int devfscheck); | ||
| 66 | static int getentropy_fallback(void *buf, size_t len); | ||
| 67 | |||
| 68 | int | ||
| 69 | getentropy(void *buf, size_t len) | ||
| 70 | { | ||
| 71 | int ret = -1; | ||
| 72 | |||
| 73 | if (len > 256) { | ||
| 74 | errno = EIO; | ||
| 75 | return (-1); | ||
| 76 | } | ||
| 77 | |||
| 78 | /* | ||
| 79 | * Try to get entropy with /dev/urandom | ||
| 80 | */ | ||
| 81 | ret = getentropy_urandom(buf, len, "/dev/urandom", 0); | ||
| 82 | if (ret != -1) | ||
| 83 | return (ret); | ||
| 84 | |||
| 85 | /* | ||
| 86 | * Entropy collection via /dev/urandom has failed. | ||
| 87 | * | ||
| 88 | * No other API exists for collecting entropy, and we have | ||
| 89 | * no failsafe way to get it on AIX that is not sensitive | ||
| 90 | * to resource exhaustion. | ||
| 91 | * | ||
| 92 | * We have very few options: | ||
| 93 | * - Even syslog_r is unsafe to call at this low level, so | ||
| 94 | * there is no way to alert the user or program. | ||
| 95 | * - Cannot call abort() because some systems have unsafe | ||
| 96 | * corefiles. | ||
| 97 | * - Could raise(SIGKILL) resulting in silent program termination. | ||
| 98 | * - Return EIO, to hint that arc4random's stir function | ||
| 99 | * should raise(SIGKILL) | ||
| 100 | * - Do the best under the circumstances.... | ||
| 101 | * | ||
| 102 | * This code path exists to bring light to the issue that AIX | ||
| 103 | * does not provide a failsafe API for entropy collection. | ||
| 104 | * | ||
| 105 | * We hope this demonstrates that AIX should consider | ||
| 106 | * providing a new failsafe API which works in a chroot or | ||
| 107 | * when file descriptors are exhausted. | ||
| 108 | */ | ||
| 109 | #undef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 110 | #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 111 | raise(SIGKILL); | ||
| 112 | #endif | ||
| 113 | ret = getentropy_fallback(buf, len); | ||
| 114 | if (ret != -1) | ||
| 115 | return (ret); | ||
| 116 | |||
| 117 | errno = EIO; | ||
| 118 | return (ret); | ||
| 119 | } | ||
| 120 | |||
| 121 | /* | ||
| 122 | * Basic sanity checking; wish we could do better. | ||
| 123 | */ | ||
| 124 | static int | ||
| 125 | gotdata(char *buf, size_t len) | ||
| 126 | { | ||
| 127 | char any_set = 0; | ||
| 128 | size_t i; | ||
| 129 | |||
| 130 | for (i = 0; i < len; ++i) | ||
| 131 | any_set |= buf[i]; | ||
| 132 | if (any_set == 0) | ||
| 133 | return (-1); | ||
| 134 | return (0); | ||
| 135 | } | ||
| 136 | |||
| 137 | static int | ||
| 138 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) | ||
| 139 | { | ||
| 140 | struct stat st; | ||
| 141 | size_t i; | ||
| 142 | int fd, flags; | ||
| 143 | int save_errno = errno; | ||
| 144 | |||
| 145 | start: | ||
| 146 | |||
| 147 | flags = O_RDONLY; | ||
| 148 | #ifdef O_NOFOLLOW | ||
| 149 | flags |= O_NOFOLLOW; | ||
| 150 | #endif | ||
| 151 | #ifdef O_CLOEXEC | ||
| 152 | flags |= O_CLOEXEC; | ||
| 153 | #endif | ||
| 154 | fd = open(path, flags, 0); | ||
| 155 | if (fd == -1) { | ||
| 156 | if (errno == EINTR) | ||
| 157 | goto start; | ||
| 158 | goto nodevrandom; | ||
| 159 | } | ||
| 160 | #ifndef O_CLOEXEC | ||
| 161 | fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); | ||
| 162 | #endif | ||
| 163 | |||
| 164 | /* Lightly verify that the device node looks sane */ | ||
| 165 | if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { | ||
| 166 | close(fd); | ||
| 167 | goto nodevrandom; | ||
| 168 | } | ||
| 169 | for (i = 0; i < len; ) { | ||
| 170 | size_t wanted = len - i; | ||
| 171 | ssize_t ret = read(fd, (char *)buf + i, wanted); | ||
| 172 | |||
| 173 | if (ret == -1) { | ||
| 174 | if (errno == EAGAIN || errno == EINTR) | ||
| 175 | continue; | ||
| 176 | close(fd); | ||
| 177 | goto nodevrandom; | ||
| 178 | } | ||
| 179 | i += ret; | ||
| 180 | } | ||
| 181 | close(fd); | ||
| 182 | if (gotdata(buf, len) == 0) { | ||
| 183 | errno = save_errno; | ||
| 184 | return (0); /* satisfied */ | ||
| 185 | } | ||
| 186 | nodevrandom: | ||
| 187 | errno = EIO; | ||
| 188 | return (-1); | ||
| 189 | } | ||
| 190 | |||
| 191 | static const int cl[] = { | ||
| 192 | CLOCK_REALTIME, | ||
| 193 | #ifdef CLOCK_MONOTONIC | ||
| 194 | CLOCK_MONOTONIC, | ||
| 195 | #endif | ||
| 196 | #ifdef CLOCK_MONOTONIC_RAW | ||
| 197 | CLOCK_MONOTONIC_RAW, | ||
| 198 | #endif | ||
| 199 | #ifdef CLOCK_TAI | ||
| 200 | CLOCK_TAI, | ||
| 201 | #endif | ||
| 202 | #ifdef CLOCK_VIRTUAL | ||
| 203 | CLOCK_VIRTUAL, | ||
| 204 | #endif | ||
| 205 | #ifdef CLOCK_UPTIME | ||
| 206 | CLOCK_UPTIME, | ||
| 207 | #endif | ||
| 208 | #ifdef CLOCK_PROCESS_CPUTIME_ID | ||
| 209 | CLOCK_PROCESS_CPUTIME_ID, | ||
| 210 | #endif | ||
| 211 | #ifdef CLOCK_THREAD_CPUTIME_ID | ||
| 212 | CLOCK_THREAD_CPUTIME_ID, | ||
| 213 | #endif | ||
| 214 | }; | ||
| 215 | |||
| 216 | static int | ||
| 217 | getentropy_fallback(void *buf, size_t len) | ||
| 218 | { | ||
| 219 | uint8_t results[SHA512_DIGEST_LENGTH]; | ||
| 220 | int save_errno = errno, e, pgs = sysconf(_SC_PAGESIZE), faster = 0, repeat; | ||
| 221 | static int cnt; | ||
| 222 | struct timespec ts; | ||
| 223 | struct timeval tv; | ||
| 224 | perfstat_cpu_total_t cpustats; | ||
| 225 | #ifdef _AIX61 | ||
| 226 | perfstat_cpu_total_wpar_t cpustats_wpar; | ||
| 227 | #endif | ||
| 228 | perfstat_partition_total_t lparstats; | ||
| 229 | perfstat_disk_total_t diskinfo; | ||
| 230 | perfstat_netinterface_total_t netinfo; | ||
| 231 | struct rusage ru; | ||
| 232 | sigset_t sigset; | ||
| 233 | struct stat st; | ||
| 234 | SHA512_CTX ctx; | ||
| 235 | static pid_t lastpid; | ||
| 236 | pid_t pid; | ||
| 237 | size_t i, ii, m; | ||
| 238 | char *p; | ||
| 239 | |||
| 240 | pid = getpid(); | ||
| 241 | if (lastpid == pid) { | ||
| 242 | faster = 1; | ||
| 243 | repeat = 2; | ||
| 244 | } else { | ||
| 245 | faster = 0; | ||
| 246 | lastpid = pid; | ||
| 247 | repeat = REPEAT; | ||
| 248 | } | ||
| 249 | for (i = 0; i < len; ) { | ||
| 250 | int j; | ||
| 251 | SHA512_Init(&ctx); | ||
| 252 | for (j = 0; j < repeat; j++) { | ||
| 253 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 254 | if (e != -1) { | ||
| 255 | cnt += (int)tv.tv_sec; | ||
| 256 | cnt += (int)tv.tv_usec; | ||
| 257 | } | ||
| 258 | |||
| 259 | HX(perfstat_cpu_total(NULL, &cpustats, | ||
| 260 | sizeof(cpustats), 1) == -1, cpustats); | ||
| 261 | |||
| 262 | #ifdef _AIX61 | ||
| 263 | HX(perfstat_cpu_total_wpar(NULL, &cpustats_wpar, | ||
| 264 | sizeof(cpustats_wpar), 1) == -1, cpustats_wpar); | ||
| 265 | #endif | ||
| 266 | |||
| 267 | HX(perfstat_partition_total(NULL, &lparstats, | ||
| 268 | sizeof(lparstats), 1) == -1, lparstats); | ||
| 269 | |||
| 270 | HX(perfstat_disk_total(NULL, &diskinfo, | ||
| 271 | sizeof(diskinfo), 1) == -1, diskinfo); | ||
| 272 | |||
| 273 | HX(perfstat_netinterface_total(NULL, &netinfo, | ||
| 274 | sizeof(netinfo), 1) == -1, netinfo); | ||
| 275 | |||
| 276 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) | ||
| 277 | HX(clock_gettime(cl[ii], &ts) == -1, ts); | ||
| 278 | |||
| 279 | HX((pid = getpid()) == -1, pid); | ||
| 280 | HX((pid = getsid(pid)) == -1, pid); | ||
| 281 | HX((pid = getppid()) == -1, pid); | ||
| 282 | HX((pid = getpgid(0)) == -1, pid); | ||
| 283 | HX((e = getpriority(0, 0)) == -1, e); | ||
| 284 | |||
| 285 | if (!faster) { | ||
| 286 | ts.tv_sec = 0; | ||
| 287 | ts.tv_nsec = 1; | ||
| 288 | (void) nanosleep(&ts, NULL); | ||
| 289 | } | ||
| 290 | |||
| 291 | HX(sigpending(&sigset) == -1, sigset); | ||
| 292 | HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, | ||
| 293 | sigset); | ||
| 294 | |||
| 295 | HF(getentropy); /* an addr in this library */ | ||
| 296 | HF(printf); /* an addr in libc */ | ||
| 297 | p = (char *)&p; | ||
| 298 | HD(p); /* an addr on stack */ | ||
| 299 | p = (char *)&errno; | ||
| 300 | HD(p); /* the addr of errno */ | ||
| 301 | |||
| 302 | if (i == 0) { | ||
| 303 | struct sockaddr_storage ss; | ||
| 304 | struct statvfs stvfs; | ||
| 305 | struct termios tios; | ||
| 306 | socklen_t ssl; | ||
| 307 | off_t off; | ||
| 308 | |||
| 309 | /* | ||
| 310 | * Prime-sized mappings encourage fragmentation; | ||
| 311 | * thus exposing some address entropy. | ||
| 312 | */ | ||
| 313 | struct mm { | ||
| 314 | size_t npg; | ||
| 315 | void *p; | ||
| 316 | } mm[] = { | ||
| 317 | { 17, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 318 | { 11, MAP_FAILED }, { 2, MAP_FAILED }, | ||
| 319 | { 5, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 320 | { 7, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 321 | { 57, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 322 | { 131, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 323 | }; | ||
| 324 | |||
| 325 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 326 | HX(mm[m].p = mmap(NULL, | ||
| 327 | mm[m].npg * pgs, | ||
| 328 | PROT_READ|PROT_WRITE, | ||
| 329 | MAP_PRIVATE|MAP_ANON, -1, | ||
| 330 | (off_t)0), mm[m].p); | ||
| 331 | if (mm[m].p != MAP_FAILED) { | ||
| 332 | size_t mo; | ||
| 333 | |||
| 334 | /* Touch some memory... */ | ||
| 335 | p = mm[m].p; | ||
| 336 | mo = cnt % | ||
| 337 | (mm[m].npg * pgs - 1); | ||
| 338 | p[mo] = 1; | ||
| 339 | cnt += (int)((long)(mm[m].p) | ||
| 340 | / pgs); | ||
| 341 | } | ||
| 342 | |||
| 343 | /* Check cnts and times... */ | ||
| 344 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); | ||
| 345 | ii++) { | ||
| 346 | HX((e = clock_gettime(cl[ii], | ||
| 347 | &ts)) == -1, ts); | ||
| 348 | if (e != -1) | ||
| 349 | cnt += (int)ts.tv_nsec; | ||
| 350 | } | ||
| 351 | |||
| 352 | HX((e = getrusage(RUSAGE_SELF, | ||
| 353 | &ru)) == -1, ru); | ||
| 354 | if (e != -1) { | ||
| 355 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 356 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 357 | } | ||
| 358 | } | ||
| 359 | |||
| 360 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 361 | if (mm[m].p != MAP_FAILED) | ||
| 362 | munmap(mm[m].p, mm[m].npg * pgs); | ||
| 363 | mm[m].p = MAP_FAILED; | ||
| 364 | } | ||
| 365 | |||
| 366 | HX(stat(".", &st) == -1, st); | ||
| 367 | HX(statvfs(".", &stvfs) == -1, stvfs); | ||
| 368 | |||
| 369 | HX(stat("/", &st) == -1, st); | ||
| 370 | HX(statvfs("/", &stvfs) == -1, stvfs); | ||
| 371 | |||
| 372 | HX((e = fstat(0, &st)) == -1, st); | ||
| 373 | if (e == -1) { | ||
| 374 | if (S_ISREG(st.st_mode) || | ||
| 375 | S_ISFIFO(st.st_mode) || | ||
| 376 | S_ISSOCK(st.st_mode)) { | ||
| 377 | HX(fstatvfs(0, &stvfs) == -1, | ||
| 378 | stvfs); | ||
| 379 | HX((off = lseek(0, (off_t)0, | ||
| 380 | SEEK_CUR)) < 0, off); | ||
| 381 | } | ||
| 382 | if (S_ISCHR(st.st_mode)) { | ||
| 383 | HX(tcgetattr(0, &tios) == -1, | ||
| 384 | tios); | ||
| 385 | } else if (S_ISSOCK(st.st_mode)) { | ||
| 386 | memset(&ss, 0, sizeof ss); | ||
| 387 | ssl = sizeof(ss); | ||
| 388 | HX(getpeername(0, | ||
| 389 | (void *)&ss, &ssl) == -1, | ||
| 390 | ss); | ||
| 391 | } | ||
| 392 | } | ||
| 393 | |||
| 394 | HX((e = getrusage(RUSAGE_CHILDREN, | ||
| 395 | &ru)) == -1, ru); | ||
| 396 | if (e != -1) { | ||
| 397 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 398 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 399 | } | ||
| 400 | } else { | ||
| 401 | /* Subsequent hashes absorb previous result */ | ||
| 402 | HD(results); | ||
| 403 | } | ||
| 404 | |||
| 405 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 406 | if (e != -1) { | ||
| 407 | cnt += (int)tv.tv_sec; | ||
| 408 | cnt += (int)tv.tv_usec; | ||
| 409 | } | ||
| 410 | |||
| 411 | HD(cnt); | ||
| 412 | } | ||
| 413 | SHA512_Final(results, &ctx); | ||
| 414 | memcpy((char *)buf + i, results, min(sizeof(results), len - i)); | ||
| 415 | i += min(sizeof(results), len - i); | ||
| 416 | } | ||
| 417 | explicit_bzero(&ctx, sizeof ctx); | ||
| 418 | explicit_bzero(results, sizeof results); | ||
| 419 | if (gotdata(buf, len) == 0) { | ||
| 420 | errno = save_errno; | ||
| 421 | return (0); /* satisfied */ | ||
| 422 | } | ||
| 423 | errno = EIO; | ||
| 424 | return (-1); | ||
| 425 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_freebsd.c b/src/lib/libcrypto/crypto/getentropy_freebsd.c deleted file mode 100644 index 30cd68e97d..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_freebsd.c +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_freebsd.c,v 1.3 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014 Pawel Jakub Dawidek <pjd@FreeBSD.org> | ||
| 5 | * Copyright (c) 2014 Brent Cook <bcook@openbsd.org> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <sys/types.h> | ||
| 24 | #include <sys/sysctl.h> | ||
| 25 | |||
| 26 | #include <errno.h> | ||
| 27 | #include <stddef.h> | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Derived from lib/libc/gen/arc4random.c from FreeBSD. | ||
| 31 | */ | ||
| 32 | static size_t | ||
| 33 | getentropy_sysctl(u_char *buf, size_t size) | ||
| 34 | { | ||
| 35 | int mib[2]; | ||
| 36 | size_t len, done; | ||
| 37 | |||
| 38 | mib[0] = CTL_KERN; | ||
| 39 | mib[1] = KERN_ARND; | ||
| 40 | done = 0; | ||
| 41 | |||
| 42 | do { | ||
| 43 | len = size; | ||
| 44 | if (sysctl(mib, 2, buf, &len, NULL, 0) == -1) | ||
| 45 | return (done); | ||
| 46 | done += len; | ||
| 47 | buf += len; | ||
| 48 | size -= len; | ||
| 49 | } while (size > 0); | ||
| 50 | |||
| 51 | return (done); | ||
| 52 | } | ||
| 53 | |||
| 54 | int | ||
| 55 | getentropy(void *buf, size_t len) | ||
| 56 | { | ||
| 57 | if (len <= 256 && getentropy_sysctl(buf, len) == len) | ||
| 58 | return (0); | ||
| 59 | |||
| 60 | errno = EIO; | ||
| 61 | return (-1); | ||
| 62 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_hpux.c b/src/lib/libcrypto/crypto/getentropy_hpux.c deleted file mode 100644 index 3ae6a6aa42..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_hpux.c +++ /dev/null | |||
| @@ -1,419 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_hpux.c,v 1.5 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | ||
| 5 | * Copyright (c) 2014 Bob Beck <beck@obtuse.com> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <sys/types.h> | ||
| 24 | #include <sys/param.h> | ||
| 25 | #include <sys/ioctl.h> | ||
| 26 | #include <sys/resource.h> | ||
| 27 | #include <sys/syscall.h> | ||
| 28 | #include <sys/statvfs.h> | ||
| 29 | #include <sys/socket.h> | ||
| 30 | #include <sys/mount.h> | ||
| 31 | #include <sys/mman.h> | ||
| 32 | #include <sys/stat.h> | ||
| 33 | #include <sys/time.h> | ||
| 34 | #include <stdlib.h> | ||
| 35 | #include <stdint.h> | ||
| 36 | #include <stdio.h> | ||
| 37 | #include <termios.h> | ||
| 38 | #include <fcntl.h> | ||
| 39 | #include <signal.h> | ||
| 40 | #include <string.h> | ||
| 41 | #include <errno.h> | ||
| 42 | #include <unistd.h> | ||
| 43 | #include <time.h> | ||
| 44 | #include <openssl/sha.h> | ||
| 45 | |||
| 46 | #include <sys/vfs.h> | ||
| 47 | |||
| 48 | #include <sys/pstat.h> | ||
| 49 | |||
| 50 | #define REPEAT 5 | ||
| 51 | #define min(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 52 | |||
| 53 | #define HX(a, b) \ | ||
| 54 | do { \ | ||
| 55 | if ((a)) \ | ||
| 56 | HD(errno); \ | ||
| 57 | else \ | ||
| 58 | HD(b); \ | ||
| 59 | } while (0) | ||
| 60 | |||
| 61 | #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) | ||
| 62 | #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) | ||
| 63 | #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) | ||
| 64 | |||
| 65 | int getentropy(void *buf, size_t len); | ||
| 66 | |||
| 67 | static int gotdata(char *buf, size_t len); | ||
| 68 | static int getentropy_urandom(void *buf, size_t len, const char *path, | ||
| 69 | int devfscheck); | ||
| 70 | static int getentropy_fallback(void *buf, size_t len); | ||
| 71 | |||
| 72 | int | ||
| 73 | getentropy(void *buf, size_t len) | ||
| 74 | { | ||
| 75 | int ret = -1; | ||
| 76 | |||
| 77 | if (len > 256) { | ||
| 78 | errno = EIO; | ||
| 79 | return (-1); | ||
| 80 | } | ||
| 81 | |||
| 82 | /* | ||
| 83 | * Try to get entropy with /dev/urandom | ||
| 84 | */ | ||
| 85 | ret = getentropy_urandom(buf, len, "/dev/urandom", 0); | ||
| 86 | if (ret != -1) | ||
| 87 | return (ret); | ||
| 88 | |||
| 89 | /* | ||
| 90 | * Entropy collection via /dev/urandom has failed. | ||
| 91 | * | ||
| 92 | * No other API exists for collecting entropy, and we have | ||
| 93 | * no failsafe way to get it on hpux that is not sensitive | ||
| 94 | * to resource exhaustion. | ||
| 95 | * | ||
| 96 | * We have very few options: | ||
| 97 | * - Even syslog_r is unsafe to call at this low level, so | ||
| 98 | * there is no way to alert the user or program. | ||
| 99 | * - Cannot call abort() because some systems have unsafe | ||
| 100 | * corefiles. | ||
| 101 | * - Could raise(SIGKILL) resulting in silent program termination. | ||
| 102 | * - Return EIO, to hint that arc4random's stir function | ||
| 103 | * should raise(SIGKILL) | ||
| 104 | * - Do the best under the circumstances.... | ||
| 105 | * | ||
| 106 | * This code path exists to bring light to the issue that hpux | ||
| 107 | * does not provide a failsafe API for entropy collection. | ||
| 108 | * | ||
| 109 | * We hope this demonstrates that hpux should consider | ||
| 110 | * providing a new failsafe API which works in a chroot or | ||
| 111 | * when file descriptors are exhausted. | ||
| 112 | */ | ||
| 113 | #undef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 114 | #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 115 | raise(SIGKILL); | ||
| 116 | #endif | ||
| 117 | ret = getentropy_fallback(buf, len); | ||
| 118 | if (ret != -1) | ||
| 119 | return (ret); | ||
| 120 | |||
| 121 | errno = EIO; | ||
| 122 | return (ret); | ||
| 123 | } | ||
| 124 | |||
| 125 | /* | ||
| 126 | * Basic sanity checking; wish we could do better. | ||
| 127 | */ | ||
| 128 | static int | ||
| 129 | gotdata(char *buf, size_t len) | ||
| 130 | { | ||
| 131 | char any_set = 0; | ||
| 132 | size_t i; | ||
| 133 | |||
| 134 | for (i = 0; i < len; ++i) | ||
| 135 | any_set |= buf[i]; | ||
| 136 | if (any_set == 0) | ||
| 137 | return (-1); | ||
| 138 | return (0); | ||
| 139 | } | ||
| 140 | |||
| 141 | static int | ||
| 142 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) | ||
| 143 | { | ||
| 144 | struct stat st; | ||
| 145 | size_t i; | ||
| 146 | int fd, flags; | ||
| 147 | int save_errno = errno; | ||
| 148 | |||
| 149 | start: | ||
| 150 | |||
| 151 | flags = O_RDONLY; | ||
| 152 | #ifdef O_NOFOLLOW | ||
| 153 | flags |= O_NOFOLLOW; | ||
| 154 | #endif | ||
| 155 | #ifdef O_CLOEXEC | ||
| 156 | flags |= O_CLOEXEC; | ||
| 157 | #endif | ||
| 158 | fd = open(path, flags, 0); | ||
| 159 | if (fd == -1) { | ||
| 160 | if (errno == EINTR) | ||
| 161 | goto start; | ||
| 162 | goto nodevrandom; | ||
| 163 | } | ||
| 164 | #ifndef O_CLOEXEC | ||
| 165 | fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); | ||
| 166 | #endif | ||
| 167 | |||
| 168 | /* Lightly verify that the device node looks sane */ | ||
| 169 | if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { | ||
| 170 | close(fd); | ||
| 171 | goto nodevrandom; | ||
| 172 | } | ||
| 173 | for (i = 0; i < len; ) { | ||
| 174 | size_t wanted = len - i; | ||
| 175 | ssize_t ret = read(fd, (char *)buf + i, wanted); | ||
| 176 | |||
| 177 | if (ret == -1) { | ||
| 178 | if (errno == EAGAIN || errno == EINTR) | ||
| 179 | continue; | ||
| 180 | close(fd); | ||
| 181 | goto nodevrandom; | ||
| 182 | } | ||
| 183 | i += ret; | ||
| 184 | } | ||
| 185 | close(fd); | ||
| 186 | if (gotdata(buf, len) == 0) { | ||
| 187 | errno = save_errno; | ||
| 188 | return (0); /* satisfied */ | ||
| 189 | } | ||
| 190 | nodevrandom: | ||
| 191 | errno = EIO; | ||
| 192 | return (-1); | ||
| 193 | } | ||
| 194 | |||
| 195 | static const int cl[] = { | ||
| 196 | CLOCK_REALTIME, | ||
| 197 | #ifdef CLOCK_MONOTONIC | ||
| 198 | CLOCK_MONOTONIC, | ||
| 199 | #endif | ||
| 200 | #ifdef CLOCK_MONOTONIC_RAW | ||
| 201 | CLOCK_MONOTONIC_RAW, | ||
| 202 | #endif | ||
| 203 | #ifdef CLOCK_TAI | ||
| 204 | CLOCK_TAI, | ||
| 205 | #endif | ||
| 206 | #ifdef CLOCK_VIRTUAL | ||
| 207 | CLOCK_VIRTUAL, | ||
| 208 | #endif | ||
| 209 | #ifdef CLOCK_UPTIME | ||
| 210 | CLOCK_UPTIME, | ||
| 211 | #endif | ||
| 212 | #ifdef CLOCK_PROCESS_CPUTIME_ID | ||
| 213 | CLOCK_PROCESS_CPUTIME_ID, | ||
| 214 | #endif | ||
| 215 | #ifdef CLOCK_THREAD_CPUTIME_ID | ||
| 216 | CLOCK_THREAD_CPUTIME_ID, | ||
| 217 | #endif | ||
| 218 | }; | ||
| 219 | |||
| 220 | static int | ||
| 221 | getentropy_fallback(void *buf, size_t len) | ||
| 222 | { | ||
| 223 | uint8_t results[SHA512_DIGEST_LENGTH]; | ||
| 224 | int save_errno = errno, e, pgs = sysconf(_SC_PAGESIZE), faster = 0, repeat; | ||
| 225 | static int cnt; | ||
| 226 | struct timespec ts; | ||
| 227 | struct timeval tv; | ||
| 228 | struct pst_vminfo pvi; | ||
| 229 | struct pst_vm_status pvs; | ||
| 230 | struct pst_dynamic pdy; | ||
| 231 | struct rusage ru; | ||
| 232 | sigset_t sigset; | ||
| 233 | struct stat st; | ||
| 234 | SHA512_CTX ctx; | ||
| 235 | static pid_t lastpid; | ||
| 236 | pid_t pid; | ||
| 237 | size_t i, ii, m; | ||
| 238 | char *p; | ||
| 239 | |||
| 240 | pid = getpid(); | ||
| 241 | if (lastpid == pid) { | ||
| 242 | faster = 1; | ||
| 243 | repeat = 2; | ||
| 244 | } else { | ||
| 245 | faster = 0; | ||
| 246 | lastpid = pid; | ||
| 247 | repeat = REPEAT; | ||
| 248 | } | ||
| 249 | for (i = 0; i < len; ) { | ||
| 250 | int j; | ||
| 251 | SHA512_Init(&ctx); | ||
| 252 | for (j = 0; j < repeat; j++) { | ||
| 253 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 254 | if (e != -1) { | ||
| 255 | cnt += (int)tv.tv_sec; | ||
| 256 | cnt += (int)tv.tv_usec; | ||
| 257 | } | ||
| 258 | |||
| 259 | HX(pstat_getvminfo(&pvi, sizeof(pvi), 1, 0) != 1, pvi); | ||
| 260 | HX(pstat_getprocvm(&pvs, sizeof(pvs), 0, 0) != 1, pvs); | ||
| 261 | |||
| 262 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) | ||
| 263 | HX(clock_gettime(cl[ii], &ts) == -1, ts); | ||
| 264 | |||
| 265 | HX((pid = getpid()) == -1, pid); | ||
| 266 | HX((pid = getsid(pid)) == -1, pid); | ||
| 267 | HX((pid = getppid()) == -1, pid); | ||
| 268 | HX((pid = getpgid(0)) == -1, pid); | ||
| 269 | HX((e = getpriority(0, 0)) == -1, e); | ||
| 270 | |||
| 271 | if(pstat_getdynamic(&pdy, sizeof(pdy), 1, 0) != 1) { | ||
| 272 | HD(errno); | ||
| 273 | } else { | ||
| 274 | HD(pdy.psd_avg_1_min); | ||
| 275 | HD(pdy.psd_avg_5_min); | ||
| 276 | HD(pdy.psd_avg_15_min); | ||
| 277 | } | ||
| 278 | |||
| 279 | if (!faster) { | ||
| 280 | ts.tv_sec = 0; | ||
| 281 | ts.tv_nsec = 1; | ||
| 282 | (void) nanosleep(&ts, NULL); | ||
| 283 | } | ||
| 284 | |||
| 285 | HX(sigpending(&sigset) == -1, sigset); | ||
| 286 | HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, | ||
| 287 | sigset); | ||
| 288 | |||
| 289 | HF(getentropy); /* an addr in this library */ | ||
| 290 | HF(printf); /* an addr in libc */ | ||
| 291 | p = (char *)&p; | ||
| 292 | HD(p); /* an addr on stack */ | ||
| 293 | p = (char *)&errno; | ||
| 294 | HD(p); /* the addr of errno */ | ||
| 295 | |||
| 296 | if (i == 0) { | ||
| 297 | struct sockaddr_storage ss; | ||
| 298 | struct statvfs stvfs; | ||
| 299 | struct termios tios; | ||
| 300 | socklen_t ssl; | ||
| 301 | off_t off; | ||
| 302 | |||
| 303 | /* | ||
| 304 | * Prime-sized mappings encourage fragmentation; | ||
| 305 | * thus exposing some address entropy. | ||
| 306 | */ | ||
| 307 | struct mm { | ||
| 308 | size_t npg; | ||
| 309 | void *p; | ||
| 310 | } mm[] = { | ||
| 311 | { 17, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 312 | { 11, MAP_FAILED }, { 2, MAP_FAILED }, | ||
| 313 | { 5, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 314 | { 7, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 315 | { 57, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 316 | { 131, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 317 | }; | ||
| 318 | |||
| 319 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 320 | HX(mm[m].p = mmap(NULL, | ||
| 321 | mm[m].npg * pgs, | ||
| 322 | PROT_READ|PROT_WRITE, | ||
| 323 | MAP_PRIVATE|MAP_ANON, -1, | ||
| 324 | (off_t)0), mm[m].p); | ||
| 325 | if (mm[m].p != MAP_FAILED) { | ||
| 326 | size_t mo; | ||
| 327 | |||
| 328 | /* Touch some memory... */ | ||
| 329 | p = mm[m].p; | ||
| 330 | mo = cnt % | ||
| 331 | (mm[m].npg * pgs - 1); | ||
| 332 | p[mo] = 1; | ||
| 333 | cnt += (int)((long)(mm[m].p) | ||
| 334 | / pgs); | ||
| 335 | } | ||
| 336 | |||
| 337 | /* Check cnts and times... */ | ||
| 338 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); | ||
| 339 | ii++) { | ||
| 340 | HX((e = clock_gettime(cl[ii], | ||
| 341 | &ts)) == -1, ts); | ||
| 342 | if (e != -1) | ||
| 343 | cnt += (int)ts.tv_nsec; | ||
| 344 | } | ||
| 345 | |||
| 346 | HX((e = getrusage(RUSAGE_SELF, | ||
| 347 | &ru)) == -1, ru); | ||
| 348 | if (e != -1) { | ||
| 349 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 350 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 351 | } | ||
| 352 | } | ||
| 353 | |||
| 354 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 355 | if (mm[m].p != MAP_FAILED) | ||
| 356 | munmap(mm[m].p, mm[m].npg * pgs); | ||
| 357 | mm[m].p = MAP_FAILED; | ||
| 358 | } | ||
| 359 | |||
| 360 | HX(stat(".", &st) == -1, st); | ||
| 361 | HX(statvfs(".", &stvfs) == -1, stvfs); | ||
| 362 | |||
| 363 | HX(stat("/", &st) == -1, st); | ||
| 364 | HX(statvfs("/", &stvfs) == -1, stvfs); | ||
| 365 | |||
| 366 | HX((e = fstat(0, &st)) == -1, st); | ||
| 367 | if (e == -1) { | ||
| 368 | if (S_ISREG(st.st_mode) || | ||
| 369 | S_ISFIFO(st.st_mode) || | ||
| 370 | S_ISSOCK(st.st_mode)) { | ||
| 371 | HX(fstatvfs(0, &stvfs) == -1, | ||
| 372 | stvfs); | ||
| 373 | HX((off = lseek(0, (off_t)0, | ||
| 374 | SEEK_CUR)) < 0, off); | ||
| 375 | } | ||
| 376 | if (S_ISCHR(st.st_mode)) { | ||
| 377 | HX(tcgetattr(0, &tios) == -1, | ||
| 378 | tios); | ||
| 379 | } else if (S_ISSOCK(st.st_mode)) { | ||
| 380 | memset(&ss, 0, sizeof ss); | ||
| 381 | ssl = sizeof(ss); | ||
| 382 | HX(getpeername(0, | ||
| 383 | (void *)&ss, &ssl) == -1, | ||
| 384 | ss); | ||
| 385 | } | ||
| 386 | } | ||
| 387 | |||
| 388 | HX((e = getrusage(RUSAGE_CHILDREN, | ||
| 389 | &ru)) == -1, ru); | ||
| 390 | if (e != -1) { | ||
| 391 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 392 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 393 | } | ||
| 394 | } else { | ||
| 395 | /* Subsequent hashes absorb previous result */ | ||
| 396 | HD(results); | ||
| 397 | } | ||
| 398 | |||
| 399 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 400 | if (e != -1) { | ||
| 401 | cnt += (int)tv.tv_sec; | ||
| 402 | cnt += (int)tv.tv_usec; | ||
| 403 | } | ||
| 404 | |||
| 405 | HD(cnt); | ||
| 406 | } | ||
| 407 | SHA512_Final(results, &ctx); | ||
| 408 | memcpy((char *)buf + i, results, min(sizeof(results), len - i)); | ||
| 409 | i += min(sizeof(results), len - i); | ||
| 410 | } | ||
| 411 | explicit_bzero(&ctx, sizeof ctx); | ||
| 412 | explicit_bzero(results, sizeof results); | ||
| 413 | if (gotdata(buf, len) == 0) { | ||
| 414 | errno = save_errno; | ||
| 415 | return (0); /* satisfied */ | ||
| 416 | } | ||
| 417 | errno = EIO; | ||
| 418 | return (-1); | ||
| 419 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_linux.c b/src/lib/libcrypto/crypto/getentropy_linux.c deleted file mode 100644 index ac97658efe..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_linux.c +++ /dev/null | |||
| @@ -1,547 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_linux.c,v 1.43 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | ||
| 5 | * Copyright (c) 2014 Bob Beck <beck@obtuse.com> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #define _POSIX_C_SOURCE 199309L | ||
| 24 | #define _GNU_SOURCE 1 | ||
| 25 | #include <sys/types.h> | ||
| 26 | #include <sys/param.h> | ||
| 27 | #include <sys/ioctl.h> | ||
| 28 | #include <sys/resource.h> | ||
| 29 | #include <sys/syscall.h> | ||
| 30 | #ifdef SYS__sysctl | ||
| 31 | #include <linux/sysctl.h> | ||
| 32 | #endif | ||
| 33 | #include <sys/statvfs.h> | ||
| 34 | #include <sys/socket.h> | ||
| 35 | #include <sys/mount.h> | ||
| 36 | #include <sys/mman.h> | ||
| 37 | #include <sys/stat.h> | ||
| 38 | #include <sys/time.h> | ||
| 39 | #include <stdlib.h> | ||
| 40 | #include <stdint.h> | ||
| 41 | #include <stdio.h> | ||
| 42 | #include <link.h> | ||
| 43 | #include <termios.h> | ||
| 44 | #include <fcntl.h> | ||
| 45 | #include <signal.h> | ||
| 46 | #include <string.h> | ||
| 47 | #include <errno.h> | ||
| 48 | #include <unistd.h> | ||
| 49 | #include <time.h> | ||
| 50 | #include <openssl/sha.h> | ||
| 51 | |||
| 52 | #include <linux/types.h> | ||
| 53 | #include <linux/random.h> | ||
| 54 | #ifdef HAVE_GETAUXVAL | ||
| 55 | #include <sys/auxv.h> | ||
| 56 | #endif | ||
| 57 | #include <sys/vfs.h> | ||
| 58 | |||
| 59 | #define REPEAT 5 | ||
| 60 | #define min(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 61 | |||
| 62 | #define HX(a, b) \ | ||
| 63 | do { \ | ||
| 64 | if ((a)) \ | ||
| 65 | HD(errno); \ | ||
| 66 | else \ | ||
| 67 | HD(b); \ | ||
| 68 | } while (0) | ||
| 69 | |||
| 70 | #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) | ||
| 71 | #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) | ||
| 72 | #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) | ||
| 73 | |||
| 74 | int getentropy(void *buf, size_t len); | ||
| 75 | |||
| 76 | static int gotdata(char *buf, size_t len); | ||
| 77 | #ifdef SYS_getrandom | ||
| 78 | static int getentropy_getrandom(void *buf, size_t len); | ||
| 79 | #endif | ||
| 80 | static int getentropy_urandom(void *buf, size_t len); | ||
| 81 | #ifdef SYS__sysctl | ||
| 82 | static int getentropy_sysctl(void *buf, size_t len); | ||
| 83 | #endif | ||
| 84 | static int getentropy_fallback(void *buf, size_t len); | ||
| 85 | static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data); | ||
| 86 | |||
| 87 | int | ||
| 88 | getentropy(void *buf, size_t len) | ||
| 89 | { | ||
| 90 | int ret = -1; | ||
| 91 | |||
| 92 | if (len > 256) { | ||
| 93 | errno = EIO; | ||
| 94 | return (-1); | ||
| 95 | } | ||
| 96 | |||
| 97 | #ifdef SYS_getrandom | ||
| 98 | /* | ||
| 99 | * Try descriptor-less getrandom() | ||
| 100 | */ | ||
| 101 | ret = getentropy_getrandom(buf, len); | ||
| 102 | if (ret != -1) | ||
| 103 | return (ret); | ||
| 104 | if (errno != ENOSYS) | ||
| 105 | return (-1); | ||
| 106 | #endif | ||
| 107 | |||
| 108 | /* | ||
| 109 | * Try to get entropy with /dev/urandom | ||
| 110 | * | ||
| 111 | * This can fail if the process is inside a chroot or if file | ||
| 112 | * descriptors are exhausted. | ||
| 113 | */ | ||
| 114 | ret = getentropy_urandom(buf, len); | ||
| 115 | if (ret != -1) | ||
| 116 | return (ret); | ||
| 117 | |||
| 118 | #ifdef SYS__sysctl | ||
| 119 | /* | ||
| 120 | * Try to use sysctl CTL_KERN, KERN_RANDOM, RANDOM_UUID. | ||
| 121 | * sysctl is a failsafe API, so it guarantees a result. This | ||
| 122 | * should work inside a chroot, or when file descriptors are | ||
| 123 | * exhausted. | ||
| 124 | * | ||
| 125 | * However this can fail if the Linux kernel removes support | ||
| 126 | * for sysctl. Starting in 2007, there have been efforts to | ||
| 127 | * deprecate the sysctl API/ABI, and push callers towards use | ||
| 128 | * of the chroot-unavailable fd-using /proc mechanism -- | ||
| 129 | * essentially the same problems as /dev/urandom. | ||
| 130 | * | ||
| 131 | * Numerous setbacks have been encountered in their deprecation | ||
| 132 | * schedule, so as of June 2014 the kernel ABI still exists on | ||
| 133 | * most Linux architectures. The sysctl() stub in libc is missing | ||
| 134 | * on some systems. There are also reports that some kernels | ||
| 135 | * spew messages to the console. | ||
| 136 | */ | ||
| 137 | ret = getentropy_sysctl(buf, len); | ||
| 138 | if (ret != -1) | ||
| 139 | return (ret); | ||
| 140 | #endif /* SYS__sysctl */ | ||
| 141 | |||
| 142 | /* | ||
| 143 | * Entropy collection via /dev/urandom and sysctl have failed. | ||
| 144 | * | ||
| 145 | * No other API exists for collecting entropy. See the large | ||
| 146 | * comment block above. | ||
| 147 | * | ||
| 148 | * We have very few options: | ||
| 149 | * - Even syslog_r is unsafe to call at this low level, so | ||
| 150 | * there is no way to alert the user or program. | ||
| 151 | * - Cannot call abort() because some systems have unsafe | ||
| 152 | * corefiles. | ||
| 153 | * - Could raise(SIGKILL) resulting in silent program termination. | ||
| 154 | * - Return EIO, to hint that arc4random's stir function | ||
| 155 | * should raise(SIGKILL) | ||
| 156 | * - Do the best under the circumstances.... | ||
| 157 | * | ||
| 158 | * This code path exists to bring light to the issue that Linux | ||
| 159 | * does not provide a failsafe API for entropy collection. | ||
| 160 | * | ||
| 161 | * We hope this demonstrates that Linux should either retain their | ||
| 162 | * sysctl ABI, or consider providing a new failsafe API which | ||
| 163 | * works in a chroot or when file descriptors are exhausted. | ||
| 164 | */ | ||
| 165 | #undef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 166 | #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 167 | raise(SIGKILL); | ||
| 168 | #endif | ||
| 169 | ret = getentropy_fallback(buf, len); | ||
| 170 | if (ret != -1) | ||
| 171 | return (ret); | ||
| 172 | |||
| 173 | errno = EIO; | ||
| 174 | return (ret); | ||
| 175 | } | ||
| 176 | |||
| 177 | /* | ||
| 178 | * Basic sanity checking; wish we could do better. | ||
| 179 | */ | ||
| 180 | static int | ||
| 181 | gotdata(char *buf, size_t len) | ||
| 182 | { | ||
| 183 | char any_set = 0; | ||
| 184 | size_t i; | ||
| 185 | |||
| 186 | for (i = 0; i < len; ++i) | ||
| 187 | any_set |= buf[i]; | ||
| 188 | if (any_set == 0) | ||
| 189 | return (-1); | ||
| 190 | return (0); | ||
| 191 | } | ||
| 192 | |||
| 193 | #ifdef SYS_getrandom | ||
| 194 | static int | ||
| 195 | getentropy_getrandom(void *buf, size_t len) | ||
| 196 | { | ||
| 197 | int pre_errno = errno; | ||
| 198 | int ret; | ||
| 199 | if (len > 256) | ||
| 200 | return (-1); | ||
| 201 | do { | ||
| 202 | ret = syscall(SYS_getrandom, buf, len, 0); | ||
| 203 | } while (ret == -1 && errno == EINTR); | ||
| 204 | |||
| 205 | if (ret != len) | ||
| 206 | return (-1); | ||
| 207 | errno = pre_errno; | ||
| 208 | return (0); | ||
| 209 | } | ||
| 210 | #endif | ||
| 211 | |||
| 212 | static int | ||
| 213 | getentropy_urandom(void *buf, size_t len) | ||
| 214 | { | ||
| 215 | struct stat st; | ||
| 216 | size_t i; | ||
| 217 | int fd, cnt, flags; | ||
| 218 | int save_errno = errno; | ||
| 219 | |||
| 220 | start: | ||
| 221 | |||
| 222 | flags = O_RDONLY; | ||
| 223 | #ifdef O_NOFOLLOW | ||
| 224 | flags |= O_NOFOLLOW; | ||
| 225 | #endif | ||
| 226 | #ifdef O_CLOEXEC | ||
| 227 | flags |= O_CLOEXEC; | ||
| 228 | #endif | ||
| 229 | fd = open("/dev/urandom", flags, 0); | ||
| 230 | if (fd == -1) { | ||
| 231 | if (errno == EINTR) | ||
| 232 | goto start; | ||
| 233 | goto nodevrandom; | ||
| 234 | } | ||
| 235 | #ifndef O_CLOEXEC | ||
| 236 | fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); | ||
| 237 | #endif | ||
| 238 | |||
| 239 | /* Lightly verify that the device node looks sane */ | ||
| 240 | if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { | ||
| 241 | close(fd); | ||
| 242 | goto nodevrandom; | ||
| 243 | } | ||
| 244 | if (ioctl(fd, RNDGETENTCNT, &cnt) == -1) { | ||
| 245 | close(fd); | ||
| 246 | goto nodevrandom; | ||
| 247 | } | ||
| 248 | for (i = 0; i < len; ) { | ||
| 249 | size_t wanted = len - i; | ||
| 250 | ssize_t ret = read(fd, (char *)buf + i, wanted); | ||
| 251 | |||
| 252 | if (ret == -1) { | ||
| 253 | if (errno == EAGAIN || errno == EINTR) | ||
| 254 | continue; | ||
| 255 | close(fd); | ||
| 256 | goto nodevrandom; | ||
| 257 | } | ||
| 258 | i += ret; | ||
| 259 | } | ||
| 260 | close(fd); | ||
| 261 | if (gotdata(buf, len) == 0) { | ||
| 262 | errno = save_errno; | ||
| 263 | return (0); /* satisfied */ | ||
| 264 | } | ||
| 265 | nodevrandom: | ||
| 266 | errno = EIO; | ||
| 267 | return (-1); | ||
| 268 | } | ||
| 269 | |||
| 270 | #ifdef SYS__sysctl | ||
| 271 | static int | ||
| 272 | getentropy_sysctl(void *buf, size_t len) | ||
| 273 | { | ||
| 274 | static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; | ||
| 275 | size_t i; | ||
| 276 | int save_errno = errno; | ||
| 277 | |||
| 278 | for (i = 0; i < len; ) { | ||
| 279 | size_t chunk = min(len - i, 16); | ||
| 280 | |||
| 281 | /* SYS__sysctl because some systems already removed sysctl() */ | ||
| 282 | struct __sysctl_args args = { | ||
| 283 | .name = mib, | ||
| 284 | .nlen = 3, | ||
| 285 | .oldval = (char *)buf + i, | ||
| 286 | .oldlenp = &chunk, | ||
| 287 | }; | ||
| 288 | if (syscall(SYS__sysctl, &args) != 0) | ||
| 289 | goto sysctlfailed; | ||
| 290 | i += chunk; | ||
| 291 | } | ||
| 292 | if (gotdata(buf, len) == 0) { | ||
| 293 | errno = save_errno; | ||
| 294 | return (0); /* satisfied */ | ||
| 295 | } | ||
| 296 | sysctlfailed: | ||
| 297 | errno = EIO; | ||
| 298 | return (-1); | ||
| 299 | } | ||
| 300 | #endif /* SYS__sysctl */ | ||
| 301 | |||
| 302 | static const int cl[] = { | ||
| 303 | CLOCK_REALTIME, | ||
| 304 | #ifdef CLOCK_MONOTONIC | ||
| 305 | CLOCK_MONOTONIC, | ||
| 306 | #endif | ||
| 307 | #ifdef CLOCK_MONOTONIC_RAW | ||
| 308 | CLOCK_MONOTONIC_RAW, | ||
| 309 | #endif | ||
| 310 | #ifdef CLOCK_TAI | ||
| 311 | CLOCK_TAI, | ||
| 312 | #endif | ||
| 313 | #ifdef CLOCK_VIRTUAL | ||
| 314 | CLOCK_VIRTUAL, | ||
| 315 | #endif | ||
| 316 | #ifdef CLOCK_UPTIME | ||
| 317 | CLOCK_UPTIME, | ||
| 318 | #endif | ||
| 319 | #ifdef CLOCK_PROCESS_CPUTIME_ID | ||
| 320 | CLOCK_PROCESS_CPUTIME_ID, | ||
| 321 | #endif | ||
| 322 | #ifdef CLOCK_THREAD_CPUTIME_ID | ||
| 323 | CLOCK_THREAD_CPUTIME_ID, | ||
| 324 | #endif | ||
| 325 | }; | ||
| 326 | |||
| 327 | static int | ||
| 328 | getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data) | ||
| 329 | { | ||
| 330 | SHA512_CTX *ctx = data; | ||
| 331 | |||
| 332 | SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr)); | ||
| 333 | return (0); | ||
| 334 | } | ||
| 335 | |||
| 336 | static int | ||
| 337 | getentropy_fallback(void *buf, size_t len) | ||
| 338 | { | ||
| 339 | uint8_t results[SHA512_DIGEST_LENGTH]; | ||
| 340 | int save_errno = errno, e, pgs = getpagesize(), faster = 0, repeat; | ||
| 341 | static int cnt; | ||
| 342 | struct timespec ts; | ||
| 343 | struct timeval tv; | ||
| 344 | struct rusage ru; | ||
| 345 | sigset_t sigset; | ||
| 346 | struct stat st; | ||
| 347 | SHA512_CTX ctx; | ||
| 348 | static pid_t lastpid; | ||
| 349 | pid_t pid; | ||
| 350 | size_t i, ii, m; | ||
| 351 | char *p; | ||
| 352 | |||
| 353 | pid = getpid(); | ||
| 354 | if (lastpid == pid) { | ||
| 355 | faster = 1; | ||
| 356 | repeat = 2; | ||
| 357 | } else { | ||
| 358 | faster = 0; | ||
| 359 | lastpid = pid; | ||
| 360 | repeat = REPEAT; | ||
| 361 | } | ||
| 362 | for (i = 0; i < len; ) { | ||
| 363 | int j; | ||
| 364 | SHA512_Init(&ctx); | ||
| 365 | for (j = 0; j < repeat; j++) { | ||
| 366 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 367 | if (e != -1) { | ||
| 368 | cnt += (int)tv.tv_sec; | ||
| 369 | cnt += (int)tv.tv_usec; | ||
| 370 | } | ||
| 371 | |||
| 372 | dl_iterate_phdr(getentropy_phdr, &ctx); | ||
| 373 | |||
| 374 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) | ||
| 375 | HX(clock_gettime(cl[ii], &ts) == -1, ts); | ||
| 376 | |||
| 377 | HX((pid = getpid()) == -1, pid); | ||
| 378 | HX((pid = getsid(pid)) == -1, pid); | ||
| 379 | HX((pid = getppid()) == -1, pid); | ||
| 380 | HX((pid = getpgid(0)) == -1, pid); | ||
| 381 | HX((e = getpriority(0, 0)) == -1, e); | ||
| 382 | |||
| 383 | if (!faster) { | ||
| 384 | ts.tv_sec = 0; | ||
| 385 | ts.tv_nsec = 1; | ||
| 386 | (void) nanosleep(&ts, NULL); | ||
| 387 | } | ||
| 388 | |||
| 389 | HX(sigpending(&sigset) == -1, sigset); | ||
| 390 | HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, | ||
| 391 | sigset); | ||
| 392 | |||
| 393 | HF(getentropy); /* an addr in this library */ | ||
| 394 | HF(printf); /* an addr in libc */ | ||
| 395 | p = (char *)&p; | ||
| 396 | HD(p); /* an addr on stack */ | ||
| 397 | p = (char *)&errno; | ||
| 398 | HD(p); /* the addr of errno */ | ||
| 399 | |||
| 400 | if (i == 0) { | ||
| 401 | struct sockaddr_storage ss; | ||
| 402 | struct statvfs stvfs; | ||
| 403 | struct termios tios; | ||
| 404 | struct statfs stfs; | ||
| 405 | socklen_t ssl; | ||
| 406 | off_t off; | ||
| 407 | |||
| 408 | /* | ||
| 409 | * Prime-sized mappings encourage fragmentation; | ||
| 410 | * thus exposing some address entropy. | ||
| 411 | */ | ||
| 412 | struct mm { | ||
| 413 | size_t npg; | ||
| 414 | void *p; | ||
| 415 | } mm[] = { | ||
| 416 | { 17, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 417 | { 11, MAP_FAILED }, { 2, MAP_FAILED }, | ||
| 418 | { 5, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 419 | { 7, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 420 | { 57, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 421 | { 131, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 422 | }; | ||
| 423 | |||
| 424 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 425 | HX(mm[m].p = mmap(NULL, | ||
| 426 | mm[m].npg * pgs, | ||
| 427 | PROT_READ|PROT_WRITE, | ||
| 428 | MAP_PRIVATE|MAP_ANON, -1, | ||
| 429 | (off_t)0), mm[m].p); | ||
| 430 | if (mm[m].p != MAP_FAILED) { | ||
| 431 | size_t mo; | ||
| 432 | |||
| 433 | /* Touch some memory... */ | ||
| 434 | p = mm[m].p; | ||
| 435 | mo = cnt % | ||
| 436 | (mm[m].npg * pgs - 1); | ||
| 437 | p[mo] = 1; | ||
| 438 | cnt += (int)((long)(mm[m].p) | ||
| 439 | / pgs); | ||
| 440 | } | ||
| 441 | |||
| 442 | /* Check cnts and times... */ | ||
| 443 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); | ||
| 444 | ii++) { | ||
| 445 | HX((e = clock_gettime(cl[ii], | ||
| 446 | &ts)) == -1, ts); | ||
| 447 | if (e != -1) | ||
| 448 | cnt += (int)ts.tv_nsec; | ||
| 449 | } | ||
| 450 | |||
| 451 | HX((e = getrusage(RUSAGE_SELF, | ||
| 452 | &ru)) == -1, ru); | ||
| 453 | if (e != -1) { | ||
| 454 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 455 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 456 | } | ||
| 457 | } | ||
| 458 | |||
| 459 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 460 | if (mm[m].p != MAP_FAILED) | ||
| 461 | munmap(mm[m].p, mm[m].npg * pgs); | ||
| 462 | mm[m].p = MAP_FAILED; | ||
| 463 | } | ||
| 464 | |||
| 465 | HX(stat(".", &st) == -1, st); | ||
| 466 | HX(statvfs(".", &stvfs) == -1, stvfs); | ||
| 467 | HX(statfs(".", &stfs) == -1, stfs); | ||
| 468 | |||
| 469 | HX(stat("/", &st) == -1, st); | ||
| 470 | HX(statvfs("/", &stvfs) == -1, stvfs); | ||
| 471 | HX(statfs("/", &stfs) == -1, stfs); | ||
| 472 | |||
| 473 | HX((e = fstat(0, &st)) == -1, st); | ||
| 474 | if (e == -1) { | ||
| 475 | if (S_ISREG(st.st_mode) || | ||
| 476 | S_ISFIFO(st.st_mode) || | ||
| 477 | S_ISSOCK(st.st_mode)) { | ||
| 478 | HX(fstatvfs(0, &stvfs) == -1, | ||
| 479 | stvfs); | ||
| 480 | HX(fstatfs(0, &stfs) == -1, | ||
| 481 | stfs); | ||
| 482 | HX((off = lseek(0, (off_t)0, | ||
| 483 | SEEK_CUR)) < 0, off); | ||
| 484 | } | ||
| 485 | if (S_ISCHR(st.st_mode)) { | ||
| 486 | HX(tcgetattr(0, &tios) == -1, | ||
| 487 | tios); | ||
| 488 | } else if (S_ISSOCK(st.st_mode)) { | ||
| 489 | memset(&ss, 0, sizeof ss); | ||
| 490 | ssl = sizeof(ss); | ||
| 491 | HX(getpeername(0, | ||
| 492 | (void *)&ss, &ssl) == -1, | ||
| 493 | ss); | ||
| 494 | } | ||
| 495 | } | ||
| 496 | |||
| 497 | HX((e = getrusage(RUSAGE_CHILDREN, | ||
| 498 | &ru)) == -1, ru); | ||
| 499 | if (e != -1) { | ||
| 500 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 501 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 502 | } | ||
| 503 | } else { | ||
| 504 | /* Subsequent hashes absorb previous result */ | ||
| 505 | HD(results); | ||
| 506 | } | ||
| 507 | |||
| 508 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 509 | if (e != -1) { | ||
| 510 | cnt += (int)tv.tv_sec; | ||
| 511 | cnt += (int)tv.tv_usec; | ||
| 512 | } | ||
| 513 | |||
| 514 | HD(cnt); | ||
| 515 | } | ||
| 516 | #ifdef HAVE_GETAUXVAL | ||
| 517 | #ifdef AT_RANDOM | ||
| 518 | /* Not as random as you think but we take what we are given */ | ||
| 519 | p = (char *) getauxval(AT_RANDOM); | ||
| 520 | if (p) | ||
| 521 | HR(p, 16); | ||
| 522 | #endif | ||
| 523 | #ifdef AT_SYSINFO_EHDR | ||
| 524 | p = (char *) getauxval(AT_SYSINFO_EHDR); | ||
| 525 | if (p) | ||
| 526 | HR(p, pgs); | ||
| 527 | #endif | ||
| 528 | #ifdef AT_BASE | ||
| 529 | p = (char *) getauxval(AT_BASE); | ||
| 530 | if (p) | ||
| 531 | HD(p); | ||
| 532 | #endif | ||
| 533 | #endif | ||
| 534 | |||
| 535 | SHA512_Final(results, &ctx); | ||
| 536 | memcpy((char *)buf + i, results, min(sizeof(results), len - i)); | ||
| 537 | i += min(sizeof(results), len - i); | ||
| 538 | } | ||
| 539 | explicit_bzero(&ctx, sizeof ctx); | ||
| 540 | explicit_bzero(results, sizeof results); | ||
| 541 | if (gotdata(buf, len) == 0) { | ||
| 542 | errno = save_errno; | ||
| 543 | return (0); /* satisfied */ | ||
| 544 | } | ||
| 545 | errno = EIO; | ||
| 546 | return (-1); | ||
| 547 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_netbsd.c b/src/lib/libcrypto/crypto/getentropy_netbsd.c deleted file mode 100644 index 45d68c9fda..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_netbsd.c +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_netbsd.c,v 1.3 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014 Pawel Jakub Dawidek <pjd@FreeBSD.org> | ||
| 5 | * Copyright (c) 2014 Brent Cook <bcook@openbsd.org> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <sys/types.h> | ||
| 24 | #include <sys/sysctl.h> | ||
| 25 | |||
| 26 | #include <errno.h> | ||
| 27 | #include <stddef.h> | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Derived from lib/libc/gen/arc4random.c from FreeBSD. | ||
| 31 | */ | ||
| 32 | static size_t | ||
| 33 | getentropy_sysctl(u_char *buf, size_t size) | ||
| 34 | { | ||
| 35 | int mib[2]; | ||
| 36 | size_t len, done; | ||
| 37 | |||
| 38 | mib[0] = CTL_KERN; | ||
| 39 | mib[1] = KERN_ARND; | ||
| 40 | done = 0; | ||
| 41 | |||
| 42 | do { | ||
| 43 | len = size; | ||
| 44 | if (sysctl(mib, 2, buf, &len, NULL, 0) == -1) | ||
| 45 | return (done); | ||
| 46 | done += len; | ||
| 47 | buf += len; | ||
| 48 | size -= len; | ||
| 49 | } while (size > 0); | ||
| 50 | |||
| 51 | return (done); | ||
| 52 | } | ||
| 53 | |||
| 54 | int | ||
| 55 | getentropy(void *buf, size_t len) | ||
| 56 | { | ||
| 57 | if (len <= 256 && | ||
| 58 | getentropy_sysctl(buf, len) == len) { | ||
| 59 | return (0); | ||
| 60 | } | ||
| 61 | |||
| 62 | errno = EIO; | ||
| 63 | return (-1); | ||
| 64 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_osx.c b/src/lib/libcrypto/crypto/getentropy_osx.c deleted file mode 100644 index c5bbb7e338..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_osx.c +++ /dev/null | |||
| @@ -1,429 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_osx.c,v 1.10 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | ||
| 5 | * Copyright (c) 2014 Bob Beck <beck@obtuse.com> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <sys/types.h> | ||
| 24 | #include <sys/param.h> | ||
| 25 | #include <sys/ioctl.h> | ||
| 26 | #include <sys/resource.h> | ||
| 27 | #include <sys/syscall.h> | ||
| 28 | #include <sys/sysctl.h> | ||
| 29 | #include <sys/statvfs.h> | ||
| 30 | #include <sys/socket.h> | ||
| 31 | #include <sys/mount.h> | ||
| 32 | #include <sys/mman.h> | ||
| 33 | #include <sys/stat.h> | ||
| 34 | #include <sys/time.h> | ||
| 35 | #include <stdlib.h> | ||
| 36 | #include <stdint.h> | ||
| 37 | #include <stdio.h> | ||
| 38 | #include <termios.h> | ||
| 39 | #include <fcntl.h> | ||
| 40 | #include <signal.h> | ||
| 41 | #include <string.h> | ||
| 42 | #include <errno.h> | ||
| 43 | #include <unistd.h> | ||
| 44 | #include <time.h> | ||
| 45 | #include <mach/mach_time.h> | ||
| 46 | #include <mach/mach_host.h> | ||
| 47 | #include <mach/host_info.h> | ||
| 48 | #include <sys/socketvar.h> | ||
| 49 | #include <sys/vmmeter.h> | ||
| 50 | #include <netinet/in.h> | ||
| 51 | #include <netinet/tcp.h> | ||
| 52 | #include <netinet/udp.h> | ||
| 53 | #include <netinet/ip_var.h> | ||
| 54 | #include <netinet/tcp_var.h> | ||
| 55 | #include <netinet/udp_var.h> | ||
| 56 | #include <CommonCrypto/CommonDigest.h> | ||
| 57 | #define SHA512_Update(a, b, c) (CC_SHA512_Update((a), (b), (c))) | ||
| 58 | #define SHA512_Init(xxx) (CC_SHA512_Init((xxx))) | ||
| 59 | #define SHA512_Final(xxx, yyy) (CC_SHA512_Final((xxx), (yyy))) | ||
| 60 | #define SHA512_CTX CC_SHA512_CTX | ||
| 61 | #define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH | ||
| 62 | |||
| 63 | #define REPEAT 5 | ||
| 64 | #define min(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 65 | |||
| 66 | #define HX(a, b) \ | ||
| 67 | do { \ | ||
| 68 | if ((a)) \ | ||
| 69 | HD(errno); \ | ||
| 70 | else \ | ||
| 71 | HD(b); \ | ||
| 72 | } while (0) | ||
| 73 | |||
| 74 | #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) | ||
| 75 | #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) | ||
| 76 | #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) | ||
| 77 | |||
| 78 | int getentropy(void *buf, size_t len); | ||
| 79 | |||
| 80 | static int gotdata(char *buf, size_t len); | ||
| 81 | static int getentropy_urandom(void *buf, size_t len); | ||
| 82 | static int getentropy_fallback(void *buf, size_t len); | ||
| 83 | |||
| 84 | int | ||
| 85 | getentropy(void *buf, size_t len) | ||
| 86 | { | ||
| 87 | int ret = -1; | ||
| 88 | |||
| 89 | if (len > 256) { | ||
| 90 | errno = EIO; | ||
| 91 | return (-1); | ||
| 92 | } | ||
| 93 | |||
| 94 | /* | ||
| 95 | * Try to get entropy with /dev/urandom | ||
| 96 | * | ||
| 97 | * This can fail if the process is inside a chroot or if file | ||
| 98 | * descriptors are exhausted. | ||
| 99 | */ | ||
| 100 | ret = getentropy_urandom(buf, len); | ||
| 101 | if (ret != -1) | ||
| 102 | return (ret); | ||
| 103 | |||
| 104 | /* | ||
| 105 | * Entropy collection via /dev/urandom and sysctl have failed. | ||
| 106 | * | ||
| 107 | * No other API exists for collecting entropy, and we have | ||
| 108 | * no failsafe way to get it on OSX that is not sensitive | ||
| 109 | * to resource exhaustion. | ||
| 110 | * | ||
| 111 | * We have very few options: | ||
| 112 | * - Even syslog_r is unsafe to call at this low level, so | ||
| 113 | * there is no way to alert the user or program. | ||
| 114 | * - Cannot call abort() because some systems have unsafe | ||
| 115 | * corefiles. | ||
| 116 | * - Could raise(SIGKILL) resulting in silent program termination. | ||
| 117 | * - Return EIO, to hint that arc4random's stir function | ||
| 118 | * should raise(SIGKILL) | ||
| 119 | * - Do the best under the circumstances.... | ||
| 120 | * | ||
| 121 | * This code path exists to bring light to the issue that OSX | ||
| 122 | * does not provide a failsafe API for entropy collection. | ||
| 123 | * | ||
| 124 | * We hope this demonstrates that OSX should consider | ||
| 125 | * providing a new failsafe API which works in a chroot or | ||
| 126 | * when file descriptors are exhausted. | ||
| 127 | */ | ||
| 128 | #undef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 129 | #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 130 | raise(SIGKILL); | ||
| 131 | #endif | ||
| 132 | ret = getentropy_fallback(buf, len); | ||
| 133 | if (ret != -1) | ||
| 134 | return (ret); | ||
| 135 | |||
| 136 | errno = EIO; | ||
| 137 | return (ret); | ||
| 138 | } | ||
| 139 | |||
| 140 | /* | ||
| 141 | * Basic sanity checking; wish we could do better. | ||
| 142 | */ | ||
| 143 | static int | ||
| 144 | gotdata(char *buf, size_t len) | ||
| 145 | { | ||
| 146 | char any_set = 0; | ||
| 147 | size_t i; | ||
| 148 | |||
| 149 | for (i = 0; i < len; ++i) | ||
| 150 | any_set |= buf[i]; | ||
| 151 | if (any_set == 0) | ||
| 152 | return (-1); | ||
| 153 | return (0); | ||
| 154 | } | ||
| 155 | |||
| 156 | static int | ||
| 157 | getentropy_urandom(void *buf, size_t len) | ||
| 158 | { | ||
| 159 | struct stat st; | ||
| 160 | size_t i; | ||
| 161 | int fd, flags; | ||
| 162 | int save_errno = errno; | ||
| 163 | |||
| 164 | start: | ||
| 165 | |||
| 166 | flags = O_RDONLY; | ||
| 167 | #ifdef O_NOFOLLOW | ||
| 168 | flags |= O_NOFOLLOW; | ||
| 169 | #endif | ||
| 170 | #ifdef O_CLOEXEC | ||
| 171 | flags |= O_CLOEXEC; | ||
| 172 | #endif | ||
| 173 | fd = open("/dev/urandom", flags, 0); | ||
| 174 | if (fd == -1) { | ||
| 175 | if (errno == EINTR) | ||
| 176 | goto start; | ||
| 177 | goto nodevrandom; | ||
| 178 | } | ||
| 179 | #ifndef O_CLOEXEC | ||
| 180 | fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); | ||
| 181 | #endif | ||
| 182 | |||
| 183 | /* Lightly verify that the device node looks sane */ | ||
| 184 | if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { | ||
| 185 | close(fd); | ||
| 186 | goto nodevrandom; | ||
| 187 | } | ||
| 188 | for (i = 0; i < len; ) { | ||
| 189 | size_t wanted = len - i; | ||
| 190 | ssize_t ret = read(fd, (char *)buf + i, wanted); | ||
| 191 | |||
| 192 | if (ret == -1) { | ||
| 193 | if (errno == EAGAIN || errno == EINTR) | ||
| 194 | continue; | ||
| 195 | close(fd); | ||
| 196 | goto nodevrandom; | ||
| 197 | } | ||
| 198 | i += ret; | ||
| 199 | } | ||
| 200 | close(fd); | ||
| 201 | if (gotdata(buf, len) == 0) { | ||
| 202 | errno = save_errno; | ||
| 203 | return (0); /* satisfied */ | ||
| 204 | } | ||
| 205 | nodevrandom: | ||
| 206 | errno = EIO; | ||
| 207 | return (-1); | ||
| 208 | } | ||
| 209 | |||
| 210 | static int tcpmib[] = { CTL_NET, AF_INET, IPPROTO_TCP, TCPCTL_STATS }; | ||
| 211 | static int udpmib[] = { CTL_NET, AF_INET, IPPROTO_UDP, UDPCTL_STATS }; | ||
| 212 | static int ipmib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_STATS }; | ||
| 213 | static int kmib[] = { CTL_KERN, KERN_USRSTACK }; | ||
| 214 | static int hwmib[] = { CTL_HW, HW_USERMEM }; | ||
| 215 | |||
| 216 | static int | ||
| 217 | getentropy_fallback(void *buf, size_t len) | ||
| 218 | { | ||
| 219 | uint8_t results[SHA512_DIGEST_LENGTH]; | ||
| 220 | int save_errno = errno, e, pgs = getpagesize(), faster = 0, repeat; | ||
| 221 | static int cnt; | ||
| 222 | struct timespec ts; | ||
| 223 | struct timeval tv; | ||
| 224 | struct rusage ru; | ||
| 225 | sigset_t sigset; | ||
| 226 | struct stat st; | ||
| 227 | SHA512_CTX ctx; | ||
| 228 | static pid_t lastpid; | ||
| 229 | pid_t pid; | ||
| 230 | size_t i, ii, m; | ||
| 231 | char *p; | ||
| 232 | struct tcpstat tcpstat; | ||
| 233 | struct udpstat udpstat; | ||
| 234 | struct ipstat ipstat; | ||
| 235 | u_int64_t mach_time; | ||
| 236 | unsigned int idata; | ||
| 237 | void *addr; | ||
| 238 | |||
| 239 | pid = getpid(); | ||
| 240 | if (lastpid == pid) { | ||
| 241 | faster = 1; | ||
| 242 | repeat = 2; | ||
| 243 | } else { | ||
| 244 | faster = 0; | ||
| 245 | lastpid = pid; | ||
| 246 | repeat = REPEAT; | ||
| 247 | } | ||
| 248 | for (i = 0; i < len; ) { | ||
| 249 | int j; | ||
| 250 | SHA512_Init(&ctx); | ||
| 251 | for (j = 0; j < repeat; j++) { | ||
| 252 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 253 | if (e != -1) { | ||
| 254 | cnt += (int)tv.tv_sec; | ||
| 255 | cnt += (int)tv.tv_usec; | ||
| 256 | } | ||
| 257 | |||
| 258 | mach_time = mach_absolute_time(); | ||
| 259 | HD(mach_time); | ||
| 260 | |||
| 261 | ii = sizeof(addr); | ||
| 262 | HX(sysctl(kmib, sizeof(kmib) / sizeof(kmib[0]), | ||
| 263 | &addr, &ii, NULL, 0) == -1, addr); | ||
| 264 | |||
| 265 | ii = sizeof(idata); | ||
| 266 | HX(sysctl(hwmib, sizeof(hwmib) / sizeof(hwmib[0]), | ||
| 267 | &idata, &ii, NULL, 0) == -1, idata); | ||
| 268 | |||
| 269 | ii = sizeof(tcpstat); | ||
| 270 | HX(sysctl(tcpmib, sizeof(tcpmib) / sizeof(tcpmib[0]), | ||
| 271 | &tcpstat, &ii, NULL, 0) == -1, tcpstat); | ||
| 272 | |||
| 273 | ii = sizeof(udpstat); | ||
| 274 | HX(sysctl(udpmib, sizeof(udpmib) / sizeof(udpmib[0]), | ||
| 275 | &udpstat, &ii, NULL, 0) == -1, udpstat); | ||
| 276 | |||
| 277 | ii = sizeof(ipstat); | ||
| 278 | HX(sysctl(ipmib, sizeof(ipmib) / sizeof(ipmib[0]), | ||
| 279 | &ipstat, &ii, NULL, 0) == -1, ipstat); | ||
| 280 | |||
| 281 | HX((pid = getpid()) == -1, pid); | ||
| 282 | HX((pid = getsid(pid)) == -1, pid); | ||
| 283 | HX((pid = getppid()) == -1, pid); | ||
| 284 | HX((pid = getpgid(0)) == -1, pid); | ||
| 285 | HX((e = getpriority(0, 0)) == -1, e); | ||
| 286 | |||
| 287 | if (!faster) { | ||
| 288 | ts.tv_sec = 0; | ||
| 289 | ts.tv_nsec = 1; | ||
| 290 | (void) nanosleep(&ts, NULL); | ||
| 291 | } | ||
| 292 | |||
| 293 | HX(sigpending(&sigset) == -1, sigset); | ||
| 294 | HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, | ||
| 295 | sigset); | ||
| 296 | |||
| 297 | HF(getentropy); /* an addr in this library */ | ||
| 298 | HF(printf); /* an addr in libc */ | ||
| 299 | p = (char *)&p; | ||
| 300 | HD(p); /* an addr on stack */ | ||
| 301 | p = (char *)&errno; | ||
| 302 | HD(p); /* the addr of errno */ | ||
| 303 | |||
| 304 | if (i == 0) { | ||
| 305 | struct sockaddr_storage ss; | ||
| 306 | struct statvfs stvfs; | ||
| 307 | struct termios tios; | ||
| 308 | struct statfs stfs; | ||
| 309 | socklen_t ssl; | ||
| 310 | off_t off; | ||
| 311 | |||
| 312 | /* | ||
| 313 | * Prime-sized mappings encourage fragmentation; | ||
| 314 | * thus exposing some address entropy. | ||
| 315 | */ | ||
| 316 | struct mm { | ||
| 317 | size_t npg; | ||
| 318 | void *p; | ||
| 319 | } mm[] = { | ||
| 320 | { 17, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 321 | { 11, MAP_FAILED }, { 2, MAP_FAILED }, | ||
| 322 | { 5, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 323 | { 7, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 324 | { 57, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 325 | { 131, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 326 | }; | ||
| 327 | |||
| 328 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 329 | HX(mm[m].p = mmap(NULL, | ||
| 330 | mm[m].npg * pgs, | ||
| 331 | PROT_READ|PROT_WRITE, | ||
| 332 | MAP_PRIVATE|MAP_ANON, -1, | ||
| 333 | (off_t)0), mm[m].p); | ||
| 334 | if (mm[m].p != MAP_FAILED) { | ||
| 335 | size_t mo; | ||
| 336 | |||
| 337 | /* Touch some memory... */ | ||
| 338 | p = mm[m].p; | ||
| 339 | mo = cnt % | ||
| 340 | (mm[m].npg * pgs - 1); | ||
| 341 | p[mo] = 1; | ||
| 342 | cnt += (int)((long)(mm[m].p) | ||
| 343 | / pgs); | ||
| 344 | } | ||
| 345 | |||
| 346 | /* Check cnts and times... */ | ||
| 347 | mach_time = mach_absolute_time(); | ||
| 348 | HD(mach_time); | ||
| 349 | cnt += (int)mach_time; | ||
| 350 | |||
| 351 | HX((e = getrusage(RUSAGE_SELF, | ||
| 352 | &ru)) == -1, ru); | ||
| 353 | if (e != -1) { | ||
| 354 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 355 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 356 | } | ||
| 357 | } | ||
| 358 | |||
| 359 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 360 | if (mm[m].p != MAP_FAILED) | ||
| 361 | munmap(mm[m].p, mm[m].npg * pgs); | ||
| 362 | mm[m].p = MAP_FAILED; | ||
| 363 | } | ||
| 364 | |||
| 365 | HX(stat(".", &st) == -1, st); | ||
| 366 | HX(statvfs(".", &stvfs) == -1, stvfs); | ||
| 367 | HX(statfs(".", &stfs) == -1, stfs); | ||
| 368 | |||
| 369 | HX(stat("/", &st) == -1, st); | ||
| 370 | HX(statvfs("/", &stvfs) == -1, stvfs); | ||
| 371 | HX(statfs("/", &stfs) == -1, stfs); | ||
| 372 | |||
| 373 | HX((e = fstat(0, &st)) == -1, st); | ||
| 374 | if (e == -1) { | ||
| 375 | if (S_ISREG(st.st_mode) || | ||
| 376 | S_ISFIFO(st.st_mode) || | ||
| 377 | S_ISSOCK(st.st_mode)) { | ||
| 378 | HX(fstatvfs(0, &stvfs) == -1, | ||
| 379 | stvfs); | ||
| 380 | HX(fstatfs(0, &stfs) == -1, | ||
| 381 | stfs); | ||
| 382 | HX((off = lseek(0, (off_t)0, | ||
| 383 | SEEK_CUR)) < 0, off); | ||
| 384 | } | ||
| 385 | if (S_ISCHR(st.st_mode)) { | ||
| 386 | HX(tcgetattr(0, &tios) == -1, | ||
| 387 | tios); | ||
| 388 | } else if (S_ISSOCK(st.st_mode)) { | ||
| 389 | memset(&ss, 0, sizeof ss); | ||
| 390 | ssl = sizeof(ss); | ||
| 391 | HX(getpeername(0, | ||
| 392 | (void *)&ss, &ssl) == -1, | ||
| 393 | ss); | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 397 | HX((e = getrusage(RUSAGE_CHILDREN, | ||
| 398 | &ru)) == -1, ru); | ||
| 399 | if (e != -1) { | ||
| 400 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 401 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 402 | } | ||
| 403 | } else { | ||
| 404 | /* Subsequent hashes absorb previous result */ | ||
| 405 | HD(results); | ||
| 406 | } | ||
| 407 | |||
| 408 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 409 | if (e != -1) { | ||
| 410 | cnt += (int)tv.tv_sec; | ||
| 411 | cnt += (int)tv.tv_usec; | ||
| 412 | } | ||
| 413 | |||
| 414 | HD(cnt); | ||
| 415 | } | ||
| 416 | |||
| 417 | SHA512_Final(results, &ctx); | ||
| 418 | memcpy((char *)buf + i, results, min(sizeof(results), len - i)); | ||
| 419 | i += min(sizeof(results), len - i); | ||
| 420 | } | ||
| 421 | explicit_bzero(&ctx, sizeof ctx); | ||
| 422 | explicit_bzero(results, sizeof results); | ||
| 423 | if (gotdata(buf, len) == 0) { | ||
| 424 | errno = save_errno; | ||
| 425 | return (0); /* satisfied */ | ||
| 426 | } | ||
| 427 | errno = EIO; | ||
| 428 | return (-1); | ||
| 429 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_solaris.c b/src/lib/libcrypto/crypto/getentropy_solaris.c deleted file mode 100644 index f0fcdcf28b..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_solaris.c +++ /dev/null | |||
| @@ -1,445 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_solaris.c,v 1.12 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | ||
| 5 | * Copyright (c) 2014 Bob Beck <beck@obtuse.com> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <sys/types.h> | ||
| 24 | #include <sys/param.h> | ||
| 25 | #include <sys/ioctl.h> | ||
| 26 | #include <sys/resource.h> | ||
| 27 | #include <sys/syscall.h> | ||
| 28 | #include <sys/statvfs.h> | ||
| 29 | #include <sys/socket.h> | ||
| 30 | #include <sys/mount.h> | ||
| 31 | #include <sys/mman.h> | ||
| 32 | #include <sys/stat.h> | ||
| 33 | #include <sys/time.h> | ||
| 34 | #include <stdlib.h> | ||
| 35 | #include <stdint.h> | ||
| 36 | #include <stdio.h> | ||
| 37 | #include <link.h> | ||
| 38 | #include <termios.h> | ||
| 39 | #include <fcntl.h> | ||
| 40 | #include <signal.h> | ||
| 41 | #include <string.h> | ||
| 42 | #include <errno.h> | ||
| 43 | #include <unistd.h> | ||
| 44 | #include <time.h> | ||
| 45 | #include <sys/sha2.h> | ||
| 46 | #define SHA512_Init SHA512Init | ||
| 47 | #define SHA512_Update SHA512Update | ||
| 48 | #define SHA512_Final SHA512Final | ||
| 49 | |||
| 50 | #include <sys/vfs.h> | ||
| 51 | #include <sys/statfs.h> | ||
| 52 | #include <sys/loadavg.h> | ||
| 53 | |||
| 54 | #define REPEAT 5 | ||
| 55 | #define min(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 56 | |||
| 57 | #define HX(a, b) \ | ||
| 58 | do { \ | ||
| 59 | if ((a)) \ | ||
| 60 | HD(errno); \ | ||
| 61 | else \ | ||
| 62 | HD(b); \ | ||
| 63 | } while (0) | ||
| 64 | |||
| 65 | #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) | ||
| 66 | #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) | ||
| 67 | #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) | ||
| 68 | |||
| 69 | int getentropy(void *buf, size_t len); | ||
| 70 | |||
| 71 | static int gotdata(char *buf, size_t len); | ||
| 72 | static int getentropy_urandom(void *buf, size_t len, const char *path, | ||
| 73 | int devfscheck); | ||
| 74 | static int getentropy_fallback(void *buf, size_t len); | ||
| 75 | static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data); | ||
| 76 | |||
| 77 | int | ||
| 78 | getentropy(void *buf, size_t len) | ||
| 79 | { | ||
| 80 | int ret = -1; | ||
| 81 | |||
| 82 | if (len > 256) { | ||
| 83 | errno = EIO; | ||
| 84 | return (-1); | ||
| 85 | } | ||
| 86 | |||
| 87 | /* | ||
| 88 | * Try to get entropy with /dev/urandom | ||
| 89 | * | ||
| 90 | * Solaris provides /dev/urandom as a symbolic link to | ||
| 91 | * /devices/pseudo/random@0:urandom which is provided by | ||
| 92 | * a devfs filesystem. Best practice is to use O_NOFOLLOW, | ||
| 93 | * so we must try the unpublished name directly. | ||
| 94 | * | ||
| 95 | * This can fail if the process is inside a chroot which lacks | ||
| 96 | * the devfs mount, or if file descriptors are exhausted. | ||
| 97 | */ | ||
| 98 | ret = getentropy_urandom(buf, len, | ||
| 99 | "/devices/pseudo/random@0:urandom", 1); | ||
| 100 | if (ret != -1) | ||
| 101 | return (ret); | ||
| 102 | |||
| 103 | /* | ||
| 104 | * Unfortunately, chroot spaces on Solaris are sometimes setup | ||
| 105 | * with direct device node of the well-known /dev/urandom name | ||
| 106 | * (perhaps to avoid dragging all of devfs into the space). | ||
| 107 | * | ||
| 108 | * This can fail if the process is inside a chroot or if file | ||
| 109 | * descriptors are exhausted. | ||
| 110 | */ | ||
| 111 | ret = getentropy_urandom(buf, len, "/dev/urandom", 0); | ||
| 112 | if (ret != -1) | ||
| 113 | return (ret); | ||
| 114 | |||
| 115 | /* | ||
| 116 | * Entropy collection via /dev/urandom has failed. | ||
| 117 | * | ||
| 118 | * No other API exists for collecting entropy, and we have | ||
| 119 | * no failsafe way to get it on Solaris that is not sensitive | ||
| 120 | * to resource exhaustion. | ||
| 121 | * | ||
| 122 | * We have very few options: | ||
| 123 | * - Even syslog_r is unsafe to call at this low level, so | ||
| 124 | * there is no way to alert the user or program. | ||
| 125 | * - Cannot call abort() because some systems have unsafe | ||
| 126 | * corefiles. | ||
| 127 | * - Could raise(SIGKILL) resulting in silent program termination. | ||
| 128 | * - Return EIO, to hint that arc4random's stir function | ||
| 129 | * should raise(SIGKILL) | ||
| 130 | * - Do the best under the circumstances.... | ||
| 131 | * | ||
| 132 | * This code path exists to bring light to the issue that Solaris | ||
| 133 | * does not provide a failsafe API for entropy collection. | ||
| 134 | * | ||
| 135 | * We hope this demonstrates that Solaris should consider | ||
| 136 | * providing a new failsafe API which works in a chroot or | ||
| 137 | * when file descriptors are exhausted. | ||
| 138 | */ | ||
| 139 | #undef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 140 | #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK | ||
| 141 | raise(SIGKILL); | ||
| 142 | #endif | ||
| 143 | ret = getentropy_fallback(buf, len); | ||
| 144 | if (ret != -1) | ||
| 145 | return (ret); | ||
| 146 | |||
| 147 | errno = EIO; | ||
| 148 | return (ret); | ||
| 149 | } | ||
| 150 | |||
| 151 | /* | ||
| 152 | * Basic sanity checking; wish we could do better. | ||
| 153 | */ | ||
| 154 | static int | ||
| 155 | gotdata(char *buf, size_t len) | ||
| 156 | { | ||
| 157 | char any_set = 0; | ||
| 158 | size_t i; | ||
| 159 | |||
| 160 | for (i = 0; i < len; ++i) | ||
| 161 | any_set |= buf[i]; | ||
| 162 | if (any_set == 0) | ||
| 163 | return (-1); | ||
| 164 | return (0); | ||
| 165 | } | ||
| 166 | |||
| 167 | static int | ||
| 168 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) | ||
| 169 | { | ||
| 170 | struct stat st; | ||
| 171 | size_t i; | ||
| 172 | int fd, flags; | ||
| 173 | int save_errno = errno; | ||
| 174 | |||
| 175 | start: | ||
| 176 | |||
| 177 | flags = O_RDONLY; | ||
| 178 | #ifdef O_NOFOLLOW | ||
| 179 | flags |= O_NOFOLLOW; | ||
| 180 | #endif | ||
| 181 | #ifdef O_CLOEXEC | ||
| 182 | flags |= O_CLOEXEC; | ||
| 183 | #endif | ||
| 184 | fd = open(path, flags, 0); | ||
| 185 | if (fd == -1) { | ||
| 186 | if (errno == EINTR) | ||
| 187 | goto start; | ||
| 188 | goto nodevrandom; | ||
| 189 | } | ||
| 190 | #ifndef O_CLOEXEC | ||
| 191 | fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); | ||
| 192 | #endif | ||
| 193 | |||
| 194 | /* Lightly verify that the device node looks sane */ | ||
| 195 | if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode) || | ||
| 196 | (devfscheck && (strcmp(st.st_fstype, "devfs") != 0))) { | ||
| 197 | close(fd); | ||
| 198 | goto nodevrandom; | ||
| 199 | } | ||
| 200 | for (i = 0; i < len; ) { | ||
| 201 | size_t wanted = len - i; | ||
| 202 | ssize_t ret = read(fd, (char *)buf + i, wanted); | ||
| 203 | |||
| 204 | if (ret == -1) { | ||
| 205 | if (errno == EAGAIN || errno == EINTR) | ||
| 206 | continue; | ||
| 207 | close(fd); | ||
| 208 | goto nodevrandom; | ||
| 209 | } | ||
| 210 | i += ret; | ||
| 211 | } | ||
| 212 | close(fd); | ||
| 213 | if (gotdata(buf, len) == 0) { | ||
| 214 | errno = save_errno; | ||
| 215 | return (0); /* satisfied */ | ||
| 216 | } | ||
| 217 | nodevrandom: | ||
| 218 | errno = EIO; | ||
| 219 | return (-1); | ||
| 220 | } | ||
| 221 | |||
| 222 | static const int cl[] = { | ||
| 223 | CLOCK_REALTIME, | ||
| 224 | #ifdef CLOCK_MONOTONIC | ||
| 225 | CLOCK_MONOTONIC, | ||
| 226 | #endif | ||
| 227 | #ifdef CLOCK_MONOTONIC_RAW | ||
| 228 | CLOCK_MONOTONIC_RAW, | ||
| 229 | #endif | ||
| 230 | #ifdef CLOCK_TAI | ||
| 231 | CLOCK_TAI, | ||
| 232 | #endif | ||
| 233 | #ifdef CLOCK_VIRTUAL | ||
| 234 | CLOCK_VIRTUAL, | ||
| 235 | #endif | ||
| 236 | #ifdef CLOCK_UPTIME | ||
| 237 | CLOCK_UPTIME, | ||
| 238 | #endif | ||
| 239 | #ifdef CLOCK_PROCESS_CPUTIME_ID | ||
| 240 | CLOCK_PROCESS_CPUTIME_ID, | ||
| 241 | #endif | ||
| 242 | #ifdef CLOCK_THREAD_CPUTIME_ID | ||
| 243 | CLOCK_THREAD_CPUTIME_ID, | ||
| 244 | #endif | ||
| 245 | }; | ||
| 246 | |||
| 247 | static int | ||
| 248 | getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data) | ||
| 249 | { | ||
| 250 | SHA512_CTX *ctx = data; | ||
| 251 | |||
| 252 | SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr)); | ||
| 253 | return (0); | ||
| 254 | } | ||
| 255 | |||
| 256 | static int | ||
| 257 | getentropy_fallback(void *buf, size_t len) | ||
| 258 | { | ||
| 259 | uint8_t results[SHA512_DIGEST_LENGTH]; | ||
| 260 | int save_errno = errno, e, pgs = getpagesize(), faster = 0, repeat; | ||
| 261 | static int cnt; | ||
| 262 | struct timespec ts; | ||
| 263 | struct timeval tv; | ||
| 264 | double loadavg[3]; | ||
| 265 | struct rusage ru; | ||
| 266 | sigset_t sigset; | ||
| 267 | struct stat st; | ||
| 268 | SHA512_CTX ctx; | ||
| 269 | static pid_t lastpid; | ||
| 270 | pid_t pid; | ||
| 271 | size_t i, ii, m; | ||
| 272 | char *p; | ||
| 273 | |||
| 274 | pid = getpid(); | ||
| 275 | if (lastpid == pid) { | ||
| 276 | faster = 1; | ||
| 277 | repeat = 2; | ||
| 278 | } else { | ||
| 279 | faster = 0; | ||
| 280 | lastpid = pid; | ||
| 281 | repeat = REPEAT; | ||
| 282 | } | ||
| 283 | for (i = 0; i < len; ) { | ||
| 284 | int j; | ||
| 285 | SHA512_Init(&ctx); | ||
| 286 | for (j = 0; j < repeat; j++) { | ||
| 287 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 288 | if (e != -1) { | ||
| 289 | cnt += (int)tv.tv_sec; | ||
| 290 | cnt += (int)tv.tv_usec; | ||
| 291 | } | ||
| 292 | |||
| 293 | dl_iterate_phdr(getentropy_phdr, &ctx); | ||
| 294 | |||
| 295 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) | ||
| 296 | HX(clock_gettime(cl[ii], &ts) == -1, ts); | ||
| 297 | |||
| 298 | HX((pid = getpid()) == -1, pid); | ||
| 299 | HX((pid = getsid(pid)) == -1, pid); | ||
| 300 | HX((pid = getppid()) == -1, pid); | ||
| 301 | HX((pid = getpgid(0)) == -1, pid); | ||
| 302 | HX((e = getpriority(0, 0)) == -1, e); | ||
| 303 | HX((getloadavg(loadavg, 3) == -1), loadavg); | ||
| 304 | |||
| 305 | if (!faster) { | ||
| 306 | ts.tv_sec = 0; | ||
| 307 | ts.tv_nsec = 1; | ||
| 308 | (void) nanosleep(&ts, NULL); | ||
| 309 | } | ||
| 310 | |||
| 311 | HX(sigpending(&sigset) == -1, sigset); | ||
| 312 | HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, | ||
| 313 | sigset); | ||
| 314 | |||
| 315 | HF(getentropy); /* an addr in this library */ | ||
| 316 | HF(printf); /* an addr in libc */ | ||
| 317 | p = (char *)&p; | ||
| 318 | HD(p); /* an addr on stack */ | ||
| 319 | p = (char *)&errno; | ||
| 320 | HD(p); /* the addr of errno */ | ||
| 321 | |||
| 322 | if (i == 0) { | ||
| 323 | struct sockaddr_storage ss; | ||
| 324 | struct statvfs stvfs; | ||
| 325 | struct termios tios; | ||
| 326 | socklen_t ssl; | ||
| 327 | off_t off; | ||
| 328 | |||
| 329 | /* | ||
| 330 | * Prime-sized mappings encourage fragmentation; | ||
| 331 | * thus exposing some address entropy. | ||
| 332 | */ | ||
| 333 | struct mm { | ||
| 334 | size_t npg; | ||
| 335 | void *p; | ||
| 336 | } mm[] = { | ||
| 337 | { 17, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 338 | { 11, MAP_FAILED }, { 2, MAP_FAILED }, | ||
| 339 | { 5, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 340 | { 7, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 341 | { 57, MAP_FAILED }, { 3, MAP_FAILED }, | ||
| 342 | { 131, MAP_FAILED }, { 1, MAP_FAILED }, | ||
| 343 | }; | ||
| 344 | |||
| 345 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 346 | HX(mm[m].p = mmap(NULL, | ||
| 347 | mm[m].npg * pgs, | ||
| 348 | PROT_READ|PROT_WRITE, | ||
| 349 | MAP_PRIVATE|MAP_ANON, -1, | ||
| 350 | (off_t)0), mm[m].p); | ||
| 351 | if (mm[m].p != MAP_FAILED) { | ||
| 352 | size_t mo; | ||
| 353 | |||
| 354 | /* Touch some memory... */ | ||
| 355 | p = mm[m].p; | ||
| 356 | mo = cnt % | ||
| 357 | (mm[m].npg * pgs - 1); | ||
| 358 | p[mo] = 1; | ||
| 359 | cnt += (int)((long)(mm[m].p) | ||
| 360 | / pgs); | ||
| 361 | } | ||
| 362 | |||
| 363 | /* Check cnts and times... */ | ||
| 364 | for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); | ||
| 365 | ii++) { | ||
| 366 | HX((e = clock_gettime(cl[ii], | ||
| 367 | &ts)) == -1, ts); | ||
| 368 | if (e != -1) | ||
| 369 | cnt += (int)ts.tv_nsec; | ||
| 370 | } | ||
| 371 | |||
| 372 | HX((e = getrusage(RUSAGE_SELF, | ||
| 373 | &ru)) == -1, ru); | ||
| 374 | if (e != -1) { | ||
| 375 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 376 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { | ||
| 381 | if (mm[m].p != MAP_FAILED) | ||
| 382 | munmap(mm[m].p, mm[m].npg * pgs); | ||
| 383 | mm[m].p = MAP_FAILED; | ||
| 384 | } | ||
| 385 | |||
| 386 | HX(stat(".", &st) == -1, st); | ||
| 387 | HX(statvfs(".", &stvfs) == -1, stvfs); | ||
| 388 | |||
| 389 | HX(stat("/", &st) == -1, st); | ||
| 390 | HX(statvfs("/", &stvfs) == -1, stvfs); | ||
| 391 | |||
| 392 | HX((e = fstat(0, &st)) == -1, st); | ||
| 393 | if (e == -1) { | ||
| 394 | if (S_ISREG(st.st_mode) || | ||
| 395 | S_ISFIFO(st.st_mode) || | ||
| 396 | S_ISSOCK(st.st_mode)) { | ||
| 397 | HX(fstatvfs(0, &stvfs) == -1, | ||
| 398 | stvfs); | ||
| 399 | HX((off = lseek(0, (off_t)0, | ||
| 400 | SEEK_CUR)) < 0, off); | ||
| 401 | } | ||
| 402 | if (S_ISCHR(st.st_mode)) { | ||
| 403 | HX(tcgetattr(0, &tios) == -1, | ||
| 404 | tios); | ||
| 405 | } else if (S_ISSOCK(st.st_mode)) { | ||
| 406 | memset(&ss, 0, sizeof ss); | ||
| 407 | ssl = sizeof(ss); | ||
| 408 | HX(getpeername(0, | ||
| 409 | (void *)&ss, &ssl) == -1, | ||
| 410 | ss); | ||
| 411 | } | ||
| 412 | } | ||
| 413 | |||
| 414 | HX((e = getrusage(RUSAGE_CHILDREN, | ||
| 415 | &ru)) == -1, ru); | ||
| 416 | if (e != -1) { | ||
| 417 | cnt += (int)ru.ru_utime.tv_sec; | ||
| 418 | cnt += (int)ru.ru_utime.tv_usec; | ||
| 419 | } | ||
| 420 | } else { | ||
| 421 | /* Subsequent hashes absorb previous result */ | ||
| 422 | HD(results); | ||
| 423 | } | ||
| 424 | |||
| 425 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | ||
| 426 | if (e != -1) { | ||
| 427 | cnt += (int)tv.tv_sec; | ||
| 428 | cnt += (int)tv.tv_usec; | ||
| 429 | } | ||
| 430 | |||
| 431 | HD(cnt); | ||
| 432 | } | ||
| 433 | SHA512_Final(results, &ctx); | ||
| 434 | memcpy((char *)buf + i, results, min(sizeof(results), len - i)); | ||
| 435 | i += min(sizeof(results), len - i); | ||
| 436 | } | ||
| 437 | explicit_bzero(&ctx, sizeof ctx); | ||
| 438 | explicit_bzero(results, sizeof results); | ||
| 439 | if (gotdata(buf, len) == 0) { | ||
| 440 | errno = save_errno; | ||
| 441 | return (0); /* satisfied */ | ||
| 442 | } | ||
| 443 | errno = EIO; | ||
| 444 | return (-1); | ||
| 445 | } | ||
diff --git a/src/lib/libcrypto/crypto/getentropy_win.c b/src/lib/libcrypto/crypto/getentropy_win.c deleted file mode 100644 index 2abeb27bc6..0000000000 --- a/src/lib/libcrypto/crypto/getentropy_win.c +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | /* $OpenBSD: getentropy_win.c,v 1.5 2016/08/07 03:27:21 tb Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
| 5 | * Copyright (c) 2014, Bob Beck <beck@obtuse.com> | ||
| 6 | * | ||
| 7 | * Permission to use, copy, modify, and distribute this software for any | ||
| 8 | * purpose with or without fee is hereby granted, provided that the above | ||
| 9 | * copyright notice and this permission notice appear in all copies. | ||
| 10 | * | ||
| 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | * | ||
| 19 | * Emulation of getentropy(2) as documented at: | ||
| 20 | * http://man.openbsd.org/getentropy.2 | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <windows.h> | ||
| 24 | #include <errno.h> | ||
| 25 | #include <stdint.h> | ||
| 26 | #include <sys/types.h> | ||
| 27 | #include <wincrypt.h> | ||
| 28 | #include <process.h> | ||
| 29 | |||
| 30 | int getentropy(void *buf, size_t len); | ||
| 31 | |||
| 32 | /* | ||
| 33 | * On Windows, CryptGenRandom is supposed to be a well-seeded | ||
| 34 | * cryptographically strong random number generator. | ||
| 35 | */ | ||
| 36 | int | ||
| 37 | getentropy(void *buf, size_t len) | ||
| 38 | { | ||
| 39 | HCRYPTPROV provider; | ||
| 40 | |||
| 41 | if (len > 256) { | ||
| 42 | errno = EIO; | ||
| 43 | return (-1); | ||
| 44 | } | ||
| 45 | |||
| 46 | if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, | ||
| 47 | CRYPT_VERIFYCONTEXT) == 0) | ||
| 48 | goto fail; | ||
| 49 | if (CryptGenRandom(provider, len, buf) == 0) { | ||
| 50 | CryptReleaseContext(provider, 0); | ||
| 51 | goto fail; | ||
| 52 | } | ||
| 53 | CryptReleaseContext(provider, 0); | ||
| 54 | return (0); | ||
| 55 | |||
| 56 | fail: | ||
| 57 | errno = EIO; | ||
| 58 | return (-1); | ||
| 59 | } | ||
diff --git a/src/lib/libcrypto/crypto/shlib_version b/src/lib/libcrypto/crypto/shlib_version deleted file mode 100644 index b9d357140a..0000000000 --- a/src/lib/libcrypto/crypto/shlib_version +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | # Don't forget to give libssl and libtls the same type of bump! | ||
| 2 | major=38 | ||
| 3 | minor=0 | ||
